59 #ifndef EGS_SMART_ENVELOPE_
60 #define EGS_SMART_ENVELOPE_
64 #ifdef BUILD_SMART_ENVELOPE_DLL
65 #define EGS_SMART_ENVELOPE_EXPORT __declspec(dllexport)
67 #define EGS_SMART_ENVELOPE_EXPORT __declspec(dllimport)
69 #define EGS_SMART_ENVELOPE_LOCAL
73 #ifdef HAVE_VISIBILITY
74 #define EGS_SMART_ENVELOPE_EXPORT __attribute__ ((visibility ("default")))
75 #define EGS_SMART_ENVELOPE_LOCAL __attribute__ ((visibility ("hidden")))
77 #define EGS_SMART_ENVELOPE_EXPORT
78 #define EGS_SMART_ENVELOPE_LOCAL
144 const vector<SmartEnvelopeAux *> &fgeoms,
const string &Name =
"");
149 return g->isInside(x);
153 int ibase = g->isWhere(x);
157 int j = gindex[ibase];
159 int i = geometries[j]->isWhere(x);
161 ibase = local_start[j] + i;
173 return g->isRealRegion(ireg);
175 int i = ireg - nbase;
176 int j = reg_to_inscr[i];
177 return geometries[j]->isRealRegion(ireg-local_start[j]);
180 int medium(
int ireg)
const {
182 return g->medium(ireg);
184 int i = ireg - nbase;
185 int j = reg_to_inscr[i];
186 return geometries[j]->medium(ireg-local_start[j]);
194 int ibase = ireg < nbase ? ireg : reg_to_base[ireg-nbase];
195 return g->howfarToOutside(ibase,x,u);
199 EGS_Float &t,
int *newmed = 0,
EGS_Vector *normal = 0) {
206 int ibase = g->howfar(ireg,x,u,t,newmed,normal);
207 int j = gindex[ireg];
211 int inscr = geometries[j]->howfar(-1,x,u,t,newmed,normal);
215 return local_start[j] + inscr;
218 if (ibase == ireg || ibase < 0) {
223 if (j >= 0 && itype[j]) {
227 int inscr = geometries[j]->isWhere(x+u*t);
230 *newmed = geometries[j]->medium(inscr);
232 return local_start[j] + inscr;
239 int ibase = reg_to_base[i];
240 int j = reg_to_inscr[i];
241 int ilocal = ireg-local_start[j];
242 int inew = geometries[j]->howfar(ilocal,x,u,t,newmed,normal);
244 int ibase_new = g->howfar(ibase,x,u,t,newmed,normal);
245 if (ibase_new != ibase) {
249 j = gindex[ibase_new];
250 if (j >= 0 && itype[j]) {
251 int inscr = geometries[j]->isWhere(x+u*t);
254 *newmed = geometries[j]->medium(inscr);
256 return local_start[j] + inscr;
264 *newmed = g->medium(ibase);
268 return local_start[j] + inew;
272 int ibase = g->howfar(ireg,x,u,t,newmed,normal);
274 int j = gindex[ibase];
275 if (j >= 0 && itype[j]) {
276 int inscr = geometries[j]->isWhere(x+u*t);
279 *newmed = geometries[j]->medium(inscr);
281 return local_start[j] + inscr;
292 tmin = g->hownear(ireg,x);
296 int j = gindex[ireg];
298 EGS_Float ti = geometries[j]->hownear(-1,x);
306 int j = reg_to_inscr[i];
307 int ilocal = ireg-local_start[j];
308 tmin = geometries[j]->hownear(ilocal,x);
310 int ibase = reg_to_base[i];
311 EGS_Float tbase = g->hownear(ibase,x);
318 return g->hownear(ireg,x);
324 for (
int j=0; j<n_in; j++) {
325 geometries[j]->getNextGeom(rndm);
327 g->getNextGeom(rndm);
330 void updatePosition(EGS_Float time) {
333 for (
int j=0; j<n_in; j++) {
334 geometries[j]->updatePosition(time);
336 g->updatePosition(time);
339 void containsDynamic(
bool &hasdynamic) {
342 for (
int j=0; j<n_in; j++) {
344 geometries[j]->containsDynamic(hasdynamic);
348 g->containsDynamic(hasdynamic);
353 int nstep = g->getMaxStep() + n_in;
354 for (
int j=0; j<n_in; ++j) {
355 nstep += geometries[j]->getMaxStep();
361 if (ireg >= 0 && ireg < nreg) {
363 return g->hasBooleanProperty(ireg,prop);
365 int i = ireg-nbase, j = reg_to_inscr[i];
366 return geometries[j]->hasBooleanProperty(ireg-local_start[j],prop);
371 setPropertyError(
"setBooleanProperty()");
374 setPropertyError(
"addBooleanProperty()");
377 setPropertyError(
"setBooleanProperty()");
380 setPropertyError(
"addBooleanProperty()");
383 const string &
getType()
const {
392 if (ireg < 0 || ireg >= nreg) {
396 return g->getRelativeRho(ireg);
399 int j = reg_to_inscr[i];
400 return geometries[j]->getRelativeRho(ireg-local_start[j]);
403 void setBScaling(
int start,
int end, EGS_Float bf);
406 if (ireg < 0 || ireg >= nreg) {
410 return g->getBScaling(ireg);
413 int j = reg_to_inscr[i];
414 return geometries[j]->getBScaling(ireg-local_start[j]);
443 void setPropertyError(
const char *funcname) {
444 egsFatal(
"EGS_SmartEnvelope::%s: don't use this method\n Define "
445 "properties in the constituent geometries instead\n",
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
virtual EGS_Float hownear(int ireg, const EGS_Vector &x)=0
Calculate the distance to a boundary for position x in any direction.
virtual int inside(const EGS_Vector &x)=0
Returns the region index, if inside, or -1 if outside (obsolete)
virtual bool hasBooleanProperty(int ireg, EGS_BPType prop) const
Is the boolean property prop set for region ireg ?
virtual EGS_Float howfarToOutside(int ireg, const EGS_Vector &x, const EGS_Vector &u)
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.
void setMedia(EGS_Input *inp)
Set the media in the geometry from the input pointed to by inp.
virtual const string & getType() const =0
Get the geometry type.
virtual void getLabelRegions(const string &str, vector< int > ®s)
Get the list of all regions labeled with str.
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.
virtual bool isRealRegion(int ireg) const
Returnes true if ireg is a real region, false otherwise.
virtual bool isInside(const EGS_Vector &x)=0
Is the position x inside the geometry?
virtual EGS_Float getRelativeRho(int ireg) const
Get the relative mass density in region ireg.
virtual void setBooleanProperty(EGS_BPType prop)
Set the boolean properties of the entire geometry to prop.
virtual int getMaxStep() const
Returns the maximum number of steps through the geometry.
virtual int medium(int ireg) const
Returns the medium index in region ireg.
virtual void setRelativeRho(int start, int end, EGS_Float rho)
Set the relative mass density in regions.
virtual void printInfo() const
Print information about this geometry.
virtual void addBooleanProperty(int bit)
Add a boolean property for the entire geometry by setting the bit'th bit.
virtual int isWhere(const EGS_Vector &x)=0
In which region is poisition x?
Base random number generator class. All random number generators should be derived from this class.
int n_in
Number of inscribed geometries.
int * gindex
Index of inscribed geometries.
EGS_BaseGeometry * g
The envelope geometry.
int * local_start
First region for each inscribed geometry.
int * reg_to_inscr
Region to inscribed geometry conversion.
static string type
Geometry type.
int * reg_to_base
Region to base region conversion.
EGS_BaseGeometry ** geometries
The inscribed geometries.
int nbase
Number of regions in the base geometry.
A class representing 3D vectors.
EGS_BaseGeometry class header file.
Global egspp functions header file.
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.