58 #ifndef EGS_SMART_ENVELOPE_
59 #define EGS_SMART_ENVELOPE_
63 #ifdef BUILD_SMART_ENVELOPE_DLL
64 #define EGS_SMART_ENVELOPE_EXPORT __declspec(dllexport)
66 #define EGS_SMART_ENVELOPE_EXPORT __declspec(dllimport)
68 #define EGS_SMART_ENVELOPE_LOCAL
72 #ifdef HAVE_VISIBILITY
73 #define EGS_SMART_ENVELOPE_EXPORT __attribute__ ((visibility ("default")))
74 #define EGS_SMART_ENVELOPE_LOCAL __attribute__ ((visibility ("hidden")))
76 #define EGS_SMART_ENVELOPE_EXPORT
77 #define EGS_SMART_ENVELOPE_LOCAL
143 const vector<SmartEnvelopeAux *> &fgeoms,
const string &Name =
"");
148 return g->isInside(x);
152 int ibase = g->isWhere(x);
156 int j = gindex[ibase];
158 int i = geometries[j]->isWhere(x);
160 ibase = local_start[j] + i;
172 return g->isRealRegion(ireg);
174 int i = ireg - nbase;
175 int j = reg_to_inscr[i];
176 return geometries[j]->isRealRegion(ireg-local_start[j]);
179 int medium(
int ireg)
const {
181 return g->medium(ireg);
183 int i = ireg - nbase;
184 int j = reg_to_inscr[i];
185 return geometries[j]->medium(ireg-local_start[j]);
193 int ibase = ireg < nbase ? ireg : reg_to_base[ireg-nbase];
194 return g->howfarToOutside(ibase,x,u);
198 EGS_Float &t,
int *newmed = 0,
EGS_Vector *normal = 0) {
205 int ibase = g->howfar(ireg,x,u,t,newmed,normal);
206 int j = gindex[ireg];
210 int inscr = geometries[j]->howfar(-1,x,u,t,newmed,normal);
214 return local_start[j] + inscr;
217 if (ibase == ireg || ibase < 0) {
222 if (j >= 0 && itype[j]) {
226 int inscr = geometries[j]->isWhere(x+u*t);
229 *newmed = geometries[j]->medium(inscr);
231 return local_start[j] + inscr;
238 int ibase = reg_to_base[i];
239 int j = reg_to_inscr[i];
240 int ilocal = ireg-local_start[j];
241 int inew = geometries[j]->howfar(ilocal,x,u,t,newmed,normal);
243 int ibase_new = g->howfar(ibase,x,u,t,newmed,normal);
244 if (ibase_new != ibase) {
248 j = gindex[ibase_new];
249 if (j >= 0 && itype[j]) {
250 int inscr = geometries[j]->isWhere(x+u*t);
253 *newmed = geometries[j]->medium(inscr);
255 return local_start[j] + inscr;
263 *newmed = g->medium(ibase);
267 return local_start[j] + inew;
271 int ibase = g->howfar(ireg,x,u,t,newmed,normal);
273 int j = gindex[ibase];
274 if (j >= 0 && itype[j]) {
275 int inscr = geometries[j]->isWhere(x+u*t);
278 *newmed = geometries[j]->medium(inscr);
280 return local_start[j] + inscr;
291 tmin = g->hownear(ireg,x);
295 int j = gindex[ireg];
297 EGS_Float ti = geometries[j]->hownear(-1,x);
305 int j = reg_to_inscr[i];
306 int ilocal = ireg-local_start[j];
307 tmin = geometries[j]->hownear(ilocal,x);
309 int ibase = reg_to_base[i];
310 EGS_Float tbase = g->hownear(ibase,x);
317 return g->hownear(ireg,x);
321 int nstep = g->getMaxStep() + n_in;
322 for (
int j=0; j<n_in; ++j) {
323 nstep += geometries[j]->getMaxStep();
329 if (ireg >= 0 && ireg < nreg) {
331 return g->hasBooleanProperty(ireg,prop);
333 int i = ireg-nbase, j = reg_to_inscr[i];
334 return geometries[j]->hasBooleanProperty(ireg-local_start[j],prop);
339 setPropertyError(
"setBooleanProperty()");
342 setPropertyError(
"addBooleanProperty()");
345 setPropertyError(
"setBooleanProperty()");
348 setPropertyError(
"addBooleanProperty()");
351 const string &
getType()
const {
360 if (ireg < 0 || ireg >= nreg) {
364 return g->getRelativeRho(ireg);
367 int j = reg_to_inscr[i];
368 return geometries[j]->getRelativeRho(ireg-local_start[j]);
371 void setBScaling(
int start,
int end, EGS_Float bf);
374 if (ireg < 0 || ireg >= nreg) {
378 return g->getBScaling(ireg);
381 int j = reg_to_inscr[i];
382 return geometries[j]->getBScaling(ireg-local_start[j]);
411 void setPropertyError(
const char *funcname) {
412 egsFatal(
"EGS_SmartEnvelope::%s: don't use this method\n Define "
413 "properties in the constituent geometries instead\n",
virtual const string & getType() const =0
Get the geometry type.
virtual bool isInside(const EGS_Vector &x)=0
Is the position x inside the geometry?
virtual bool hasBooleanProperty(int ireg, EGS_BPType prop) const
Is the boolean property prop set for region ireg ?
virtual int medium(int ireg) const
Returns the medium index in region ireg.
virtual void printInfo() const
Print information about this geometry.
int * gindex
Index of inscribed geometries.
virtual EGS_Float howfarToOutside(int ireg, const EGS_Vector &x, const EGS_Vector &u)
virtual int getMaxStep() const
Returns the maximum number of steps through the geometry.
A class representing 3D vectors.
int * reg_to_base
Region to base region conversion.
Global egspp functions header file.
virtual int isWhere(const EGS_Vector &x)=0
In which region is poisition x?
virtual int howfar(int ireg, const EGS_Vector &x, const EGS_Vector &u, EGS_Float &t, int *newmed=0, EGS_Vector *normal=0)=0
Calculate the distance to a boundary from x along the direction u.
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
virtual void setRelativeRho(int start, int end, EGS_Float rho)
Set the relative mass density in regions.
virtual EGS_Float getBScaling(int ireg) const
Get the B field scaling factor in region ireg.
virtual void setBScaling(int start, int end, EGS_Float bf)
Set the B field scaling factor in regions.
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.
virtual void getLabelRegions(const string &str, vector< int > ®s)
Get the list of all regions labeled with str.
void setMedia(EGS_Input *inp)
Set the media in the geometry from the input pointed to by inp.
virtual int inside(const EGS_Vector &x)=0
Returns the region index, if inside, or -1 if outside (obsolete)
int n_in
Number of inscribed geometries.
virtual EGS_Float hownear(int ireg, const EGS_Vector &x)=0
Calculate the distance to a boundary for position x in any direction.
int * reg_to_inscr
Region to inscribed geometry conversion.
virtual EGS_Float getRelativeRho(int ireg) const
Get the relative mass density in region ireg.
EGS_BaseGeometry * g
The envelope geometry.
int * local_start
First region for each inscribed geometry.
EGS_BaseGeometry ** geometries
The inscribed geometries.
static string type
Geometry type.
virtual bool isRealRegion(int ireg) const
Returnes true if ireg is a real region, false otherwise.
EGS_BaseGeometry class header file.
int nbase
Number of regions in the base geometry.
virtual void addBooleanProperty(int bit)
Add a boolean property for the entire geometry by setting the bit'th bit.
virtual void setBooleanProperty(EGS_BPType prop)
Set the boolean properties of the entire geometry to prop.