44 #ifndef EGS_BASE_GEOMETRY_
45 #define EGS_BASE_GEOMETRY_
62 typedef EGS_I64 EGS_BPType;
63 #elif defined BPROPERTY32
64 typedef unsigned int EGS_BPType;
65 #elif defined BPROPERTY16
66 typedef unsigned short EGS_BPType;
68 typedef unsigned char EGS_BPType;
178 static int findRegion(EGS_Float xp,
int np,
const EGS_Float *p) {
180 while (mu - ml > 1) {
223 EGS_Float &t,
int *newmed=0,
EGS_Vector *normal=0) = 0;
237 virtual EGS_Float howfarToOutside(
int ireg,
const EGS_Vector &x,
297 return (ireg >= 0 && ireg < nreg);
307 return region_media ? region_media[ireg] : med;
331 virtual int computeIntersections(
int ireg,
int n,
const EGS_Vector &x,
343 void setMedium(
const string &Name);
352 void setMedium(
int start,
int end,
const string &Name,
int delta=1);
369 void setMedium(
int istart,
int iend,
int imed,
int delta=1);
397 static const char *getMediumName(
int ind);
407 static int addMedium(
const string &medname);
414 static int getMediumIndex(
const string &medname);
420 return has_rho_scaling;
427 return rhor && ireg >= 0 && ireg < nreg ? rhor[ireg] : 1;
435 virtual void setRelativeRho(
int start,
int end, EGS_Float rho);
446 virtual void setRelativeRho(
EGS_Input *);
448 EGS_Float getMediumRho(
int ind)
const;
455 return (has_B_scaling || has_Ref_rho);
461 if (has_Ref_rho && has_B_scaling) {
462 if (bfactor && ireg >= 0 && ireg < nreg) {
463 return getMediumRho(medium(ireg))/rhoRef*bfactor[ireg];
469 else if (has_Ref_rho && !has_B_scaling) {
470 if (ireg >= 0 && ireg < nreg) {
471 return getMediumRho(medium(ireg))/rhoRef;
477 else if (!has_Ref_rho && has_B_scaling) {
478 if (bfactor && ireg >= 0 && ireg < nreg) {
479 return bfactor[ireg];
496 virtual void setBScaling(
int start,
int end, EGS_Float bf);
571 static void clearGeometries();
592 static int getNGeometries();
600 static string getUniqueName();
620 void setBoundaryTolerance(
EGS_Input *inp);
625 boundaryTolerance = tol;
626 halfBoundaryTolerance = tol/2.;
633 return (prop & bproperty);
635 return ireg >= 0 && ireg < nreg ? prop & bp_array[ireg] :
false;
643 virtual void setBooleanProperty(EGS_BPType prop);
652 virtual void addBooleanProperty(
int bit);
660 virtual void setBooleanProperty(EGS_BPType prop,
int start,
int end,
669 virtual void addBooleanProperty(
int bit,
int start,
int end,
int step=1);
681 virtual void printInfo()
const;
688 static void describeGeometries();
715 static void setActiveGeometryList(
int list);
717 static int getLastError() {
721 static void resetErrorFlag() {
727 return boundaryTolerance;
731 virtual void getNumberRegions(
const string &str, vector<int> ®s);
734 virtual void getLabelRegions(
const string &str, vector<int> ®s);
738 return labels[i].name;
743 return labels.size();
750 int setLabels(
const string &inp);
752 virtual void updatePosition(EGS_Float time) { };
762 virtual void containsDynamic(
bool &hasdynamic) { };
835 virtual void setMedia(
EGS_Input *inp,
int nmed,
const int *med_ind);
903 static int active_glist;
Base class for advanced EGSnrc C++ applications.
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
virtual int getLabelCount()
Get the number of explicit labels in the geometry.
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)
int deref()
Decrease the reference count to this geometry.
virtual bool hasBooleanProperty(int ireg, EGS_BPType prop) const
Is the boolean property prop set for region ireg ?
EGS_BPType bproperty
A bit mask of boolean properties for the entire geometry.
bool debug
Debugging flag.
virtual EGS_Float getBScaling(int ireg) const
Get the B field scaling factor in region ireg.
virtual const string & getType() const =0
Get the geometry type.
static int findRegion(EGS_Float xp, int np, const EGS_Float *p)
Find the bin to which xp belongs, given np bin edges p.
int nreg
Number of local regions in this geometry.
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.
bool has_B_scaling
Does this geometry has B field scaling factor?
int nref
Number of references to this geometry.
bool is_convex
Is this geometry convex?
bool has_rho_scaling
Does this geometry have relative mass density scvaling?
virtual EGS_Float getVolume(int ireg)
Calculates the volume of region ireg.
void setDebug(bool deb)
Turn debugging on.
EGS_Float boundaryTolerance
Boundary tolerance for geometries that need it.
bool hasBScaling() const
Does this geometry object have a B field scaling feature?
short * region_media
Array of media indeces.
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?
const string & getName() const
Get the name of this geometry.
void setBoundaryTolerance(EGS_Float tol)
Set the value of the boundary tolerance from argument.
EGS_Float * rhor
Array with relative mass densities.
virtual EGS_Float getRelativeRho(int ireg) const
Get the relative mass density in region ireg.
EGS_Float * bfactor
Array with B field scaling factors.
bool isConvex() const
Is the geometry convex?
virtual const string & getLabelName(const int i)
Get the name of the i-th explicit label in the geometry.
virtual int getNRegDir(int idir)
virtual int getMaxStep() const
Returns the maximum number of steps through the geometry.
EGS_Application * app
The application this object belongs to.
bool hasRhoScaling() const
Does this geometry object have a mass density scaling feature?
void setMedium(int imed)
Set all regions to a medium with index imed.
virtual int medium(int ireg) const
Returns the medium index in region ireg.
static int error_flag
Set to non-zero status if a geometry problem is encountered.
string name
Name of this geometry.
int regions() const
Returns the number of local regions in this geometry.
virtual EGS_Float getBound(int idir, int ind)
Returns region boundaries in direction determined by idir.
vector< label > labels
Labels.
EGS_Float getBoundaryTolerance()
Get the value of the boundary tolerance.
int ref()
Increase the reference count to this geometry.
EGS_Float rhoRef
Reference density for B field scaling.
virtual int isWhere(const EGS_Vector &x)=0
In which region is poisition x?
EGS_BPType * bp_array
An array of boolean properties on a region by region basis.
Base random number generator class. All random number generators should be derived from this class.
A class representing 3D vectors.
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
#define EGS_EXPORT
Export symbols from the egspp library.
EGS_RandomGenerator class header file.
EGS_Vector methods for the manipulation of 3D vectors in cartesian co-ordinates.
EGS_Float t
distance to next region boundary
EGS_Float rhof
relative mass density in that region