44 #ifndef EGS_BASE_GEOMETRY_
45 #define EGS_BASE_GEOMETRY_
64 typedef EGS_I64 EGS_BPType;
65 #elif defined BPROPERTY32
66 typedef unsigned int EGS_BPType;
67 #elif defined BPROPERTY16
68 typedef unsigned short EGS_BPType;
70 typedef unsigned char EGS_BPType;
79 static shared_ptr<EGS_BlockInput> geomBlockInput = make_shared<EGS_BlockInput>(
"geometry");
80 inline void setBaseGeometryInputs(
bool includeMediaBlock =
true) {
81 geomBlockInput->addSingleInput(
"library",
true,
"The type of geometry, loaded by shared library in egs++/dso.");
82 geomBlockInput->addSingleInput(
"name",
true,
"The user-declared unique name of this geometry. This is the name you may refer to elsewhere in the input file");
83 geomBlockInput->addSingleInput(
"set label",
false,
"A name for the label, followed by a list of local region numbers (found by viewing only this geometry). Then use the label name elsewhere in the input file to refer to those regions. E.g. 'set label = myLabel 0 1'");
85 if (includeMediaBlock) {
86 shared_ptr<EGS_BlockInput> mediaBlock = geomBlockInput->addBlockInput(
"media input");
87 mediaBlock->addSingleInput(
"media",
true,
"A list of media that are used in this geometry");
88 mediaBlock->addSingleInput(
"set medium",
false,
"2, 3 or 4 integers defining the medium for a region or range of regions.\nFor 2: region #, medium index from the media list for this geometry (starts at 0). For 3: start region, stop region, medium index. For 4: Same as 3, plus a step size for the region range.\nNeglect this input for a homogeneous geometry of the first medium in the media list. Repeat this input to specify each medium.");
195 static int findRegion(EGS_Float xp,
int np,
const EGS_Float *p) {
197 while (mu - ml > 1) {
240 EGS_Float &t,
int *newmed=0,
EGS_Vector *normal=0) = 0;
254 virtual EGS_Float howfarToOutside(
int ireg,
const EGS_Vector &x,
318 return (ireg >= 0 && ireg < nreg);
328 return region_media ? region_media[ireg] : med;
352 virtual int computeIntersections(
int ireg,
int n,
const EGS_Vector &x,
364 void setMedium(
const string &Name);
373 void setMedium(
int start,
int end,
const string &Name,
int delta=1);
390 void setMedium(
int istart,
int iend,
int imed,
int delta=1);
418 static const char *getMediumName(
int ind);
428 static int addMedium(
const string &medname);
435 static int getMediumIndex(
const string &medname);
441 return has_rho_scaling;
448 return rhor && ireg >= 0 && ireg < nreg ? rhor[ireg] : 1;
456 virtual void setRelativeRho(
int start,
int end, EGS_Float rho);
467 virtual void setRelativeRho(
EGS_Input *);
469 EGS_Float getMediumRho(
int ind)
const;
476 return (has_B_scaling || has_Ref_rho);
482 if (has_Ref_rho && has_B_scaling) {
483 if (bfactor && ireg >= 0 && ireg < nreg) {
484 return getMediumRho(medium(ireg))/rhoRef*bfactor[ireg];
490 else if (has_Ref_rho && !has_B_scaling) {
491 if (ireg >= 0 && ireg < nreg) {
492 return getMediumRho(medium(ireg))/rhoRef;
498 else if (!has_Ref_rho && has_B_scaling) {
499 if (bfactor && ireg >= 0 && ireg < nreg) {
500 return bfactor[ireg];
517 virtual void setBScaling(
int start,
int end, EGS_Float bf);
592 static void clearGeometries();
613 static int getNGeometries();
621 static string getUniqueName();
641 void setBoundaryTolerance(
EGS_Input *inp);
646 boundaryTolerance = tol;
647 halfBoundaryTolerance = tol/2.;
654 return (prop & bproperty);
656 return ireg >= 0 && ireg < nreg ? prop & bp_array[ireg] :
false;
664 virtual void setBooleanProperty(EGS_BPType prop);
673 virtual void addBooleanProperty(
int bit);
681 virtual void setBooleanProperty(EGS_BPType prop,
int start,
int end,
690 virtual void addBooleanProperty(
int bit,
int start,
int end,
int step=1);
702 virtual void printInfo()
const;
709 static void describeGeometries();
736 static void setActiveGeometryList(
int list);
738 static int getLastError() {
742 static void resetErrorFlag() {
748 return boundaryTolerance;
752 virtual int getGlobalRegionOffset(
const string geomName);
755 virtual void getNumberRegions(
const string &str, vector<int> ®s);
758 virtual void getLabelRegions(
const string &str, vector<int> ®s,
bool sanitize=
true);
762 return labels[i].name;
767 return labels.size();
774 int setLabels(
const string &inp);
776 virtual void updatePosition(EGS_Float time) {
804 bool validateRegions(
const std::vector<int> ®ions);
806 virtual void finishInitialization() { };
816 virtual void containsDynamic(
bool &hasdynamic) {
892 virtual void setMedia(
EGS_Input *inp,
int nmed,
const int *med_ind);
960 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 hasRhoScaling()
Does this geometry object have a mass density scaling feature?
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.
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.
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.
vector< EGS_Label > labels
Labels.
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