EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
EGS_BaseGeometry Class Referenceabstract

Base geometry class. Every geometry class must be derived from EGS_BaseGeometry. More...

#include <egs_base_geometry.h>

Inheritance diagram for EGS_BaseGeometry:
EGS_AEnvelope EGS_Box EGS_CDGeometry EGS_ConeSet EGS_ConeStack EGS_cSpheres EGS_cSphericalShell EGS_CylindersT< T > EGS_EnvelopeGeometry EGS_FastEnvelope EGS_Hexagonal_Lattice EGS_IPlanes EGS_Lattice EGS_Mesh EGS_NDGeometry EGS_Octree EGS_ParallelCones EGS_PlaneCollection EGS_PlanesT< T > EGS_PrismT< T > EGS_PyramidT< T > EGS_RadialRepeater EGS_RoundRectCylindersT< Tx, Ty > EGS_SimpleCone EGS_SmartEnvelope EGS_Space EGS_StackGeometry EGS_TestMicro EGS_TransformedGeometry EGS_UnionGeometry EGS_VHPGeometry EGS_XYZGeometry EGS_XYZRepeater

Public Member Functions

 EGS_BaseGeometry (const string &Name)
 Construct a geometry named Name. More...
 
virtual ~EGS_BaseGeometry ()
 Destructor. More...
 
bool isConvex () const
 Is the geometry convex? More...
 
virtual int inside (const EGS_Vector &x)=0
 Returns the region index, if inside, or -1 if outside (obsolete) More...
 
virtual bool isInside (const EGS_Vector &x)=0
 Is the position x inside the geometry? More...
 
virtual int isWhere (const EGS_Vector &x)=0
 In which region is poisition x? More...
 
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. More...
 
virtual EGS_Float howfarToOutside (int ireg, const EGS_Vector &x, const EGS_Vector &u)
 
virtual EGS_Float hownear (int ireg, const EGS_Vector &x)=0
 Calculate the distance to a boundary for position x in any direction. More...
 
virtual EGS_Float getVolume (int ireg)
 Calculates the volume of region ireg. More...
 
virtual EGS_Float getBound (int idir, int ind)
 Returns region boundaries in direction determined by idir. More...
 
virtual int getNRegDir (int idir)
 
int regions () const
 Returns the number of local regions in this geometry. More...
 
virtual bool isRealRegion (int ireg) const
 Returnes true if ireg is a real region, false otherwise. More...
 
virtual int medium (int ireg) const
 Returns the medium index in region ireg. More...
 
virtual int getMaxStep () const
 Returns the maximum number of steps through the geometry. More...
 
virtual int computeIntersections (int ireg, int n, const EGS_Vector &x, const EGS_Vector &u, EGS_GeometryIntersections *isections)
 Calculates intersection distances to region boundaries. More...
 
void setMedium (const string &Name)
 Set all regions to a medium with name Name. More...
 
void setMedium (int start, int end, const string &Name, int delta=1)
 Set every delta'th region between start and end to the medium named Name. More...
 
void setMedium (int imed)
 Set all regions to a medium with index imed. More...
 
void setMedium (int istart, int iend, int imed, int delta=1)
 Set every delta'th region between start and end (inclusive) to imed. More...
 
void setMedia (EGS_Input *inp)
 Set the media in the geometry from the input pointed to by inp. More...
 
bool hasRhoScaling () const
 Does this geometry object have a mass density scaling feature? More...
 
virtual EGS_Float getRelativeRho (int ireg) const
 Get the relative mass density in region ireg. More...
 
virtual void setRelativeRho (int start, int end, EGS_Float rho)
 Set the relative mass density in regions. More...
 
virtual void setRelativeRho (EGS_Input *)
 Set the relative mass density from an user input. More...
 
EGS_Float getMediumRho (int ind) const
 
virtual void setApplication (EGS_Application *app)
 
bool hasBScaling () const
 Does this geometry object have a B field scaling feature?
 
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. More...
 
virtual void setBScaling (EGS_Input *)
 Set the B field scaling factor from an user input. More...
 
const string & getName () const
 Get the name of this geometry. More...
 
virtual const string & getType () const =0
 Get the geometry type. More...
 
void setDebug (bool deb)
 Turn debugging on. More...
 
void setName (EGS_Input *inp)
 Set the name of the geometry from the input inp. More...
 
void setBoundaryTolerance (EGS_Input *inp)
 Set the value of the boundary tolerance from the input inp. More...
 
void setBoundaryTolerance (EGS_Float tol)
 Set the value of the boundary tolerance from argument.
 
virtual bool hasBooleanProperty (int ireg, EGS_BPType prop) const
 Is the boolean property prop set for region ireg ?
 
virtual void setBooleanProperty (EGS_BPType prop)
 Set the boolean properties of the entire geometry to prop. More...
 
virtual void addBooleanProperty (int bit)
 Add a boolean property for the entire geometry by setting the bit'th bit. More...
 
virtual void setBooleanProperty (EGS_BPType prop, int start, int end, int step=1)
 Set the boolean properties of every step'th region between start and end (inclusive) to prop. More...
 
virtual void addBooleanProperty (int bit, int start, int end, int step=1)
 Add a boolean property to every step'th region between start and end (inclusive) by setting the bit'th bit. More...
 
virtual void printInfo () const
 Print information about this geometry. More...
 
int ref ()
 Increase the reference count to this geometry. More...
 
int deref ()
 Decrease the reference count to this geometry. More...
 
EGS_Float getBoundaryTolerance ()
 Get the value of the boundary tolerance.
 
virtual void getNumberRegions (const string &str, vector< int > &regs)
 Get a list of all the regions labeled with a number.
 
virtual void getLabelRegions (const string &str, vector< int > &regs)
 Get the list of all regions labeled with str.
 
virtual const string & getLabelName (const int i)
 Get the name of the i-th explicit label in the geometry.
 
virtual int getLabelCount ()
 Get the number of explicit labels in the geometry.
 
int setLabels (EGS_Input *input)
 Set the labels from an input block.
 
int setLabels (const string &inp)
 Set the labels from an input string.
 

Static Public Member Functions

static int findRegion (EGS_Float xp, int np, const EGS_Float *p)
 Find the bin to which xp belongs, given np bin edges p. More...
 
static int nMedia ()
 Get the number of media registered so far by all geometries. More...
 
static const char * getMediumName (int ind)
 Get the name of medium with index ind. More...
 
static int addMedium (const string &medname)
 Add a medium or get the index of an existing medium. More...
 
static int getMediumIndex (const string &medname)
 Get the index of a medium named medname. More...
 
static EGS_BaseGeometrycreateGeometry (EGS_Input *)
 Create a geometry (or geometries) from a given input. More...
 
static EGS_BaseGeometrycreateSingleGeometry (EGS_Input *inp)
 Create a single geometry from the input inp. More...
 
static void clearGeometries ()
 Clears (deletes) all geometries in the currently active geometry list. More...
 
static EGS_BaseGeometrygetGeometry (const string &Name)
 Get a pointer to the geometry named Name. More...
 
static EGS_BaseGeometry ** getGeometries ()
 
static int getNGeometries ()
 
static string getUniqueName ()
 Get a unique geometry name. More...
 
static void describeGeometries ()
 Describes all existing geometries. More...
 
static void setActiveGeometryList (int list)
 Set the currently active geometry list. More...
 
static int getLastError ()
 
static void resetErrorFlag ()
 

Protected Member Functions

virtual void setMedia (EGS_Input *inp, int nmed, const int *med_ind)
 Set media. More...
 

Protected Attributes

int nreg
 Number of local regions in this geometry. More...
 
string name
 Name of this geometry. More...
 
short * region_media
 Array of media indeces. More...
 
int med
 Medium index. More...
 
bool has_rho_scaling
 Does this geometry have relative mass density scvaling? More...
 
EGS_Float * rhor
 Array with relative mass densities. More...
 
bool has_B_scaling
 Does this geometry has B field scaling factor? More...
 
bool has_Ref_rho
 
EGS_Float * bfactor
 Array with B field scaling factors. More...
 
EGS_Float rhoRef
 Reference density for B field scaling. More...
 
int nref
 Number of references to this geometry. More...
 
bool debug
 Debugging flag. More...
 
bool is_convex
 Is this geometry convex? More...
 
EGS_BPType bproperty
 A bit mask of boolean properties for the entire geometry. More...
 
EGS_BPType * bp_array
 An array of boolean properties on a region by region basis. More...
 
EGS_Float boundaryTolerance
 Boundary tolerance for geometries that need it.
 
EGS_Float halfBoundaryTolerance
 
vector< labellabels
 Labels. More...
 
EGS_Applicationapp
 The application this object belongs to.
 

Static Protected Attributes

static int error_flag = 0
 Set to non-zero status if a geometry problem is encountered.
 

Detailed Description

Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.

The EGS_BaseGeometry class specifies the EGSnrc geometry interface. See the geometry module documentation for more details.

Todo:
Add time dependence
Todo:
Deal with volume calculation. While it is trivial to provide a generic volume calculation by Monte Carlo integration, it would be braindead to use such an approach for geometries that can actually calculate the volume in each of their regions analytically.
Examples:
geometry/egs_box/egs_box.cpp.

Definition at line 93 of file egs_base_geometry.h.

Constructor & Destructor Documentation

EGS_BaseGeometry::EGS_BaseGeometry ( const string &  Name)

Construct a geometry named Name.

All geometries must have a unique name that is used to refer to them in the input file specifying the geometry.

Examples:
geometry/egs_box/egs_box.cpp.

Definition at line 429 of file egs_base_geometry.cpp.

References boundaryTolerance, egsFatal, and getUniqueName().

EGS_BaseGeometry::~EGS_BaseGeometry ( )
virtual

Destructor.

If necessary, deallocates region_media. It also removes the geometry from the internally maintained static geometry list.

Definition at line 447 of file egs_base_geometry.cpp.

References bfactor, bp_array, has_B_scaling, has_rho_scaling, region_media, and rhor.

Member Function Documentation

bool EGS_BaseGeometry::isConvex ( ) const

Is the geometry convex?

A "convex" geometry is a geometry for which there is a single segment on a line that intersects it, which is inside the geometry. Example of convex geometries are spheres, cylinders, etc. An examples of non-convex geometries is a torus or a prism with a non-convex polygon as a base. Derived gometry classes should set is_convex to false if they are not convex. This method is needed, for instance, for N-dimensional geometries (the N-dimensional geometry logic only applies if all dimensions are convex or if there is a single concave dimension, which is also the last dimension.

Definition at line 124 of file egs_base_geometry.h.

Referenced by EGS_NDGeometry::EGS_NDGeometry(), and EGS_PrismT< T >::EGS_PrismT().

virtual int EGS_BaseGeometry::inside ( const EGS_Vector x)
pure virtual

Returns the region index, if inside, or -1 if outside (obsolete)

This method is obsolete, isInside() and isWhere() should be used instead.

Examples:
geometry/egs_box/egs_box.cpp.
virtual bool EGS_BaseGeometry::isInside ( const EGS_Vector x)
pure virtual

Is the position x inside the geometry?

This pure virtual method must be implemented by derived geometry classes to return true, if the position x is inside the geomtry and false otherwise.

Implemented in EGS_PlanesT< T >.

Examples:
geometry/egs_box/egs_box.cpp.

Referenced by volcor::findRegionsWithInscribed().

virtual int EGS_BaseGeometry::isWhere ( const EGS_Vector x)
pure virtual

In which region is poisition x?

This pure virtual method must be implemented by derived geometry classes to return the index of the region to which x belongs, if the position x is inside the geomtry and -1 otherwise.

Examples:
geometry/egs_box/egs_box.cpp.

Referenced by volcor::findRegionsWithInscribed(), EGS_SimpleApplication::run(), and EGS_Application::simulateSingleShower().

static int EGS_BaseGeometry::findRegion ( EGS_Float  xp,
int  np,
const EGS_Float *  p 
)
static

Find the bin to which xp belongs, given np bin edges p.

This static method uses a binary search and is provided for the convenience of the various classes that need to find a region index in order to implement the isWhere() method (e.g. sets of planes, cylinders, etc.). Arguably, it should not be a member of the base geomtry class.

Definition at line 160 of file egs_base_geometry.h.

virtual int EGS_BaseGeometry::howfar ( int  ireg,
const EGS_Vector x,
const EGS_Vector u,
EGS_Float &  t,
int *  newmed = 0,
EGS_Vector normal = 0 
)
pure virtual

Calculate the distance to a boundary from x along the direction u.

This is one of the 2 main geometry methods needed to implement the EGSnrc geometry specifcation (the other is hownear()). It must be implemented in derived geometry classes to calculate and return the following values, depending on ireg:

  • ireg >= 0 Assume position x is in local region ireg and calculate the distance d to the next region boundary along the direction u. If d > t, simply return ireg. If d <= t, set t to d and return the new region index.
  • ireg < 0 Assume that position x is outside. If the line defined by position x and direction u intersects the geometry, calculate the distance d to the entry point. If d <= t, set t to d and return the region index of the entry point, otherwise just return -1. If no intersection exists, or if d > t, just return -1.

In both cases, if an intersection is found at d <= t, and if the pointer newmed is not null, set it to the medium index in the new region. In the same way, if normal is not null, set it to the normal vector at the intersection point. The normal is needed for visualization purpsoses only (i.e., normal is always null in a normal simulation).

Examples:
geometry/egs_box/egs_box.cpp.

Referenced by computeIntersections(), EGS_SimpleApplication::run(), and EGS_Application::simulateSingleShower().

EGS_Float EGS_BaseGeometry::howfarToOutside ( int  ireg,
const EGS_Vector x,
const EGS_Vector u 
)
virtual

Calculate the distance to the outer geometry boundary from x along the direction u.

The base geometry provides a generic implementation for this method that uses howfar(). However, geometries that can can compute the distance to their outer boundary more rapidly should provide their own implementation. The reason for adding this method (May 2007) is that we have already run into 2 situations (CBCT and PET), where it is advantegeous to have this method for implementing advanced variance reduction techniques.

Examples:
geometry/egs_box/egs_box.cpp.

Definition at line 381 of file egs_base_geometry.cpp.

References egsFatal, loopMax, and veryFar.

virtual EGS_Float EGS_BaseGeometry::hownear ( int  ireg,
const EGS_Vector x 
)
pure virtual

Calculate the distance to a boundary for position x in any direction.

This is the second main geometry method needed to implement the EGSnrc geometry specifcation (the other is howfar()). It must be implemented in derived classes to calculate the nearest distance to a boundary for position x in any direction assuming that x is in region ireg (if ireg >= 0) or that x is outside (if ireg < 0).

Examples:
geometry/egs_box/egs_box.cpp.
virtual EGS_Float EGS_BaseGeometry::getVolume ( int  ireg)
virtual

Calculates the volume of region ireg.

Currently only implemented EGS_XYZGeometry, EGS_cSpheres, EGS_cSphericalShell, EGS_AEnvelope, and EGS_RZGeometry

Reimplemented in EGS_cSpheres, and EGS_RZGeometry.

Definition at line 239 of file egs_base_geometry.h.

virtual EGS_Float EGS_BaseGeometry::getBound ( int  idir,
int  ind 
)
virtual

Returns region boundaries in direction determined by idir.

Currently only implemented in EGS_XYZGeometry, where idir=0–> X-boundaries, idir=1–> Y-boundaries, idir=2–> Z-boundaries

Reimplemented in EGS_cSpheres, and EGS_RZGeometry.

Definition at line 248 of file egs_base_geometry.h.

Referenced by EGS_cSpheres::getBound().

virtual int EGS_BaseGeometry::getNRegDir ( int  idir)
virtual

Returns number of planar slabs/cylinders/etc in direction idir

Currently only implemented in EGS_XYZGeometry, where idir=0–> X-boundaries, idir=1–> Y-boundaries, idir=2–> Z-boundaries

Reimplemented in EGS_cSpheres, and EGS_RZGeometry.

Definition at line 257 of file egs_base_geometry.h.

Referenced by EGS_cSpheres::getNRegDir().

int EGS_BaseGeometry::regions ( ) const

Returns the number of local regions in this geometry.

The fact that this method is not virtual implies that derived geometry classes must set EGS_BaseGeometry::nreg to the number of regions in the geometry.

Definition at line 267 of file egs_base_geometry.h.

Referenced by EGS_NDGeometry::EGS_NDGeometry(), EGS_StackGeometry::EGS_StackGeometry(), and EGS_UnionGeometry::EGS_UnionGeometry().

virtual bool EGS_BaseGeometry::isRealRegion ( int  ireg) const
virtual

Returnes true if ireg is a real region, false otherwise.

This method is needed because of the region indexing style used by some composite geometries which results in a larger number of regions than actual regions. This method can be used in such cases to check if a region exists.

Definition at line 278 of file egs_base_geometry.h.

virtual int EGS_BaseGeometry::medium ( int  ireg) const
virtual

Returns the medium index in region ireg.

If a re-implementation of this method is undertaken, it can be safely assumed that this method is only invoked with ireg inside the geometry (unless, of course, there is a bug)

Definition at line 288 of file egs_base_geometry.h.

Referenced by computeIntersections().

virtual int EGS_BaseGeometry::getMaxStep ( ) const
virtual

Returns the maximum number of steps through the geometry.

This method is handy for detecting when a particle gets stuck at a boundary

Definition at line 297 of file egs_base_geometry.h.

int EGS_BaseGeometry::computeIntersections ( int  ireg,
int  n,
const EGS_Vector x,
const EGS_Vector u,
EGS_GeometryIntersections isections 
)
virtual

Calculates intersection distances to region boundaries.

For a given position x, direction u and region number ireg, this method returns the number of intersections with the geometry and distances, medium indeces and relative mass densities for all intersections, or, if this number is larger than the size n of isections, -1 (but the n intersections are still put in isections). If the position is outside, the method checks if the trajectory intersects the geometry and if yes, puts in the first element of isections the distance to the entry point and then finds all other intersections as in the case of x inside.

Definition at line 918 of file egs_base_geometry.cpp.

References getRelativeRho(), howfar(), EGS_GeometryIntersections::imed, EGS_GeometryIntersections::ireg, medium(), EGS_GeometryIntersections::rhof, EGS_GeometryIntersections::t, and veryFar.

void EGS_BaseGeometry::setMedium ( const string &  Name)

Set all regions to a medium with name Name.

This method obtains a index for the medium named Name from an internally maintained list of media and sets the medium index in all regions in the geometry to this index.

See Also
setMedium(int,int,const string &), setMedium(int), setMedium(int,int,int), setMedia() and nMedia().

Definition at line 480 of file egs_base_geometry.cpp.

References med, nreg, and region_media.

Referenced by EGS_NDGeometry::setMedia(), setMedia(), and setMedium().

void EGS_BaseGeometry::setMedium ( int  start,
int  end,
const string &  Name,
int  delta = 1 
)

Set every delta'th region between start and end to the medium named Name.

This method is similar to the previous method but only sets the medium index in all regions between start and end (inclusive). Note that...

Definition at line 496 of file egs_base_geometry.cpp.

References setMedium().

void EGS_BaseGeometry::setMedium ( int  imed)

Set all regions to a medium with index imed.

Note that...

Definition at line 340 of file egs_base_geometry.h.

void EGS_BaseGeometry::setMedium ( int  istart,
int  iend,
int  imed,
int  delta = 1 
)

Set every delta'th region between start and end (inclusive) to imed.

This method is similar to setMedium(int,int,constr string &,int).

See Also
setMedium(int), setMedium(int,int,constr string &,int) and setMedium(const string &)

Definition at line 502 of file egs_base_geometry.cpp.

References med, nreg, and region_media.

void EGS_BaseGeometry::setMedia ( EGS_Input inp)

Set the media in the geometry from the input pointed to by inp.

This method sets the media from a composite property 'media input' that has the key
media = list of media
and zero or more keys of the form
set medium = first last medium_index
See PIRS-899 for more details.

Examples:
geometry/egs_box/egs_box.cpp.

Definition at line 743 of file egs_base_geometry.cpp.

References EGS_Input::getInput(), EGS_Input::isA(), nMedia(), setBScaling(), setRelativeRho(), and EGS_Input::takeInputItem().

int EGS_BaseGeometry::nMedia ( )
static

Get the number of media registered so far by all geometries.

Returns the number of media registered sofar by all geometries. A static list of media names is maintained internally. Media names can be added using addMedium(), setMedium(int,int,const string&) or setMedium(const string&)

Definition at line 527 of file egs_base_geometry.cpp.

Referenced by EGS_SimpleApplication::EGS_SimpleApplication(), EGS_AdvancedApplication::helpInit(), and setMedia().

const char * EGS_BaseGeometry::getMediumName ( int  ind)
static

Get the name of medium with index ind.

Returns a pointer to the character array holding the name of the medium with index ind or null if there is no such medium index.

Definition at line 531 of file egs_base_geometry.cpp.

Referenced by EGS_SimpleApplication::EGS_SimpleApplication(), and EGS_AdvancedApplication::helpInit().

int EGS_BaseGeometry::addMedium ( const string &  medname)
static

Add a medium or get the index of an existing medium.

This function returns the index of a medium with the name medname in the static list of media names registered so far by all geometries. If a medium with name medname already exists, the index of this medium is returned. If no such medium name exists in the list, medname is first appended to the list and then its index is returned.

Definition at line 488 of file egs_base_geometry.cpp.

int EGS_BaseGeometry::getMediumIndex ( const string &  medname)
static

Get the index of a medium named medname.

If medname is found in the list of media, its index is returned. Otherwise the return value is -1.

Examples:
tutor7pp.cpp.

Definition at line 492 of file egs_base_geometry.cpp.

bool EGS_BaseGeometry::hasRhoScaling ( ) const

Does this geometry object have a mass density scaling feature?

Definition at line 401 of file egs_base_geometry.h.

Referenced by EGS_StackGeometry::EGS_StackGeometry(), EGS_UnionGeometry::EGS_UnionGeometry(), and EGS_AdvancedApplication::startNewParticle().

virtual EGS_Float EGS_BaseGeometry::getRelativeRho ( int  ireg) const
virtual

Get the relative mass density in region ireg.

Definition at line 408 of file egs_base_geometry.h.

Referenced by computeIntersections(), and EGS_AdvancedApplication::startNewParticle().

void EGS_BaseGeometry::setRelativeRho ( int  start,
int  end,
EGS_Float  rho 
)
virtual

Set the relative mass density in regions.

Sets the relative mass density to rho in all regions between start and end (inclusive).

Definition at line 813 of file egs_base_geometry.cpp.

References has_rho_scaling, nreg, and rhor.

Referenced by setMedia(), and setRelativeRho().

void EGS_BaseGeometry::setRelativeRho ( EGS_Input input)
virtual

Set the relative mass density from an user input.

Looks for input

set relative density = start end rho

and sets the relative mass density to rho in all regions between start and end (inclusive).

Definition at line 835 of file egs_base_geometry.cpp.

References egsWarning, EGS_Input::getInput(), setRelativeRho(), and EGS_Input::takeInputItem().

void EGS_BaseGeometry::setBScaling ( int  start,
int  end,
EGS_Float  bf 
)
virtual

Set the B field scaling factor in regions.

Sets the B field scaling factor to bf in all regions between start and end (inclusive).

Definition at line 861 of file egs_base_geometry.cpp.

References bfactor, has_B_scaling, and nreg.

Referenced by setBScaling(), and setMedia().

void EGS_BaseGeometry::setBScaling ( EGS_Input input)
virtual

Set the B field scaling factor from an user input.

Looks for input

set B scaling = start end bfact

and sets the B field scaling factor to bfact in all regions between start and end (inclusive).

Definition at line 883 of file egs_base_geometry.cpp.

References egsWarning, EGS_Input::getInput(), rhoRef, setBScaling(), and EGS_Input::takeInputItem().

const string& EGS_BaseGeometry::getName ( ) const

Get the name of this geometry.

Every geometry must have a name and this method can be used to retrieve the name of a geometry.

Definition at line 496 of file egs_base_geometry.h.

Referenced by createGeometry(), EGS_SimpleApplication::EGS_SimpleApplication(), and printInfo().

virtual const string& EGS_BaseGeometry::getType ( ) const
pure virtual

Get the geometry type.

This pure virtual function must be implemented in derived classes to return a short but descriptive geometry type string. getType() is used in printInfo() to describe a geometry.

Implemented in EGS_RZGeometry.

Examples:
geometry/egs_box/egs_box.cpp.

Referenced by EGS_RoundRectCylindersT< Tx, Ty >::EGS_RoundRectCylindersT(), EGS_SimpleApplication::EGS_SimpleApplication(), EGS_TransformedGeometry::EGS_TransformedGeometry(), and printInfo().

EGS_BaseGeometry * EGS_BaseGeometry::createGeometry ( EGS_Input input)
static

Create a geometry (or geometries) from a given input.

This static function looks for geometry definition by quering for a composite property geometry definition. Every individual geometry definition is contained in a geometry definition child property geometry. The return value of this function is the geometry specified with
simulation geometry = name of an existing geometry
if such input exists or the last constructed geometry. If the input inp does not contain any valid geometry definitions, null is returned.

Note that the geometry definition property is removed from the input inp by this method.

See Also
createSingleGeometry().

Definition at line 547 of file egs_base_geometry.cpp.

References egsFatal, egsWarning, EGS_Input::getInput(), getName(), EGS_Input::isA(), and EGS_Input::takeInputItem().

Referenced by createGeometry(), EGS_SimpleApplication::EGS_SimpleApplication(), and EGS_Application::initGeometry().

EGS_BaseGeometry * EGS_BaseGeometry::createSingleGeometry ( EGS_Input inp)
static

Create a single geometry from the input inp.

The input pointed to by inp must contain all information necessary to construct a geometry. The minimum information necessary is
library = the name of a geometry library
name = the name of this geometry
The library name should not include platform specific prefixes and file extensions. This function attemtps to dynamically load the library specified by the library key and to resolve the geometry creation function createGeometry that a geometry library must provide. If this succeeds, the geometry created by createGeometry using the input pointed to by inp is returned (if the input is not sufficient or valid to create the desired geometry, createGeometry will return null).

Definition at line 543 of file egs_base_geometry.cpp.

Referenced by setName().

void EGS_BaseGeometry::clearGeometries ( )
static

Clears (deletes) all geometries in the currently active geometry list.

This function deletes all geometries in the currently active list of geometries and also clears the internally maintained list of media.

Definition at line 464 of file egs_base_geometry.cpp.

void EGS_BaseGeometry::setDebug ( bool  deb)

Turn debugging on.

This is mainly useful in the development process of a new geometry. It sets the protected data member debug to deb.

Definition at line 560 of file egs_base_geometry.h.

EGS_BaseGeometry * EGS_BaseGeometry::getGeometry ( const string &  Name)
static

Get a pointer to the geometry named Name.

This function returns a pointer to the geometry named Name, if a geometry with such a name exists in the static list of geometries, or null if no such geometry exists.

Definition at line 468 of file egs_base_geometry.cpp.

Referenced by EGS_FanoSource::EGS_FanoSource(), and EGS_IsotropicSource::EGS_IsotropicSource().

string EGS_BaseGeometry::getUniqueName ( )
static

Get a unique geometry name.

This function is used to create a unique name for a nameless geometry. Normally geometry names should be specified explicitely when constructing geometries.

Definition at line 603 of file egs_base_geometry.cpp.

Referenced by EGS_BaseGeometry(), and setName().

void EGS_BaseGeometry::setName ( EGS_Input inp)

Set the name of the geometry from the input inp.

This method looks for a key name in the input pointed to by inp and sets the name of the geometry to the value of the name key. Derived geometry classes should always call this function to set their name from the input provided to the geometry creation function.

Examples:
geometry/egs_box/egs_box.cpp.

Definition at line 609 of file egs_base_geometry.cpp.

References createSingleGeometry(), egsWarning, EGS_Input::getInput(), getUniqueName(), EGS_Input::setContentFromString(), and EGS_Input::takeInputItem().

void EGS_BaseGeometry::setBoundaryTolerance ( EGS_Input inp)

Set the value of the boundary tolerance from the input inp.

This method looks for a key tolerance in the input pointed to by inp and sets the boundary tolerance of the geometry to the value of the tolerance key. Derived geometry classes should call this function to set their boundary tolerance from the input provided to the geometry creation function.

Examples:
geometry/egs_box/egs_box.cpp.

Definition at line 717 of file egs_base_geometry.cpp.

References boundaryTolerance, egsWarning, and EGS_Input::getInput().

void EGS_BaseGeometry::setBooleanProperty ( EGS_BPType  prop)
virtual

Set the boolean properties of the entire geometry to prop.

See Also
addBooleanProperty(int), setBooleanProperty(EGS_BPType,int,int,int) addBooleanProperty(int,int,int,int)

Definition at line 964 of file egs_base_geometry.cpp.

References bp_array, and bproperty.

Referenced by setBooleanProperty().

void EGS_BaseGeometry::addBooleanProperty ( int  bit)
virtual

Add a boolean property for the entire geometry by setting the bit'th bit.

See Also
setBooleanProperty(EGS_BPType), setBooleanProperty(EGS_BPType,int,int,int), addBooleanProperty(int,int,int,int)

Definition at line 972 of file egs_base_geometry.cpp.

References bp_array, bproperty, egsWarning, and nreg.

Referenced by addBooleanProperty().

void EGS_BaseGeometry::setBooleanProperty ( EGS_BPType  prop,
int  start,
int  end,
int  step = 1 
)
virtual

Set the boolean properties of every step'th region between start and end (inclusive) to prop.

See Also
setBooleanProperty(EGS_BPType), addBooleanProperty(int), addBooleanProperty(int,int,int,int)

Definition at line 987 of file egs_base_geometry.cpp.

References bp_array, nreg, and setBooleanProperty().

void EGS_BaseGeometry::addBooleanProperty ( int  bit,
int  start,
int  end,
int  step = 1 
)
virtual

Add a boolean property to every step'th region between start and end (inclusive) by setting the bit'th bit.

See Also
setBooleanProperty(EGS_BPType),addBooleanProperty(int), setBooleanProperty(EGS_BPType,int,int,int)

Definition at line 1011 of file egs_base_geometry.cpp.

References addBooleanProperty(), bp_array, egsWarning, and nreg.

void EGS_BaseGeometry::printInfo ( ) const
virtual

Print information about this geometry.

The default implementation of this function outputs a separation line, the geometry type (as returned by getType() ), the geometry name ( as returned by getName() ) and the number of regions in the geometry using egsInformation(). Derived geometry classes should first call the base class implementation of printInfo() and then add additional useful infromation to the output using egsInformation().

Examples:
geometry/egs_box/egs_box.cpp.

Definition at line 726 of file egs_base_geometry.cpp.

References egsInformation, getName(), getType(), hasBScaling(), and nreg.

Referenced by EGS_Application::describeSimulation().

void EGS_BaseGeometry::describeGeometries ( )
static

Describes all existing geometries.

This static function outputs information about all currently existing geometries using their printInfo() method

Definition at line 736 of file egs_base_geometry.cpp.

References egsInformation.

Referenced by EGS_SimpleApplication::EGS_SimpleApplication().

int EGS_BaseGeometry::ref ( )

Increase the reference count to this geometry.

Composite geometries that use other geometries should increase their reference count using this method. This is needed to prevent a geometry being destructed that is still in use by some other geometry.

Definition at line 678 of file egs_base_geometry.h.

Referenced by EGS_StackGeometry::EGS_StackGeometry(), EGS_UnionGeometry::EGS_UnionGeometry(), and EGS_Application::initGeometry().

int EGS_BaseGeometry::deref ( )

Decrease the reference count to this geometry.

Composite geometries should use this method to decrease the reference count to other geometries they use when destructed and delete the geometry, if the return value of this function is 0.

Definition at line 690 of file egs_base_geometry.h.

Referenced by EGS_Application::~EGS_Application(), and EGS_SimpleApplication::~EGS_SimpleApplication().

void EGS_BaseGeometry::setActiveGeometryList ( int  list)
static

Set the currently active geometry list.

Definition at line 405 of file egs_base_geometry.cpp.

Referenced by EGS_AdvancedApplication::helpInit(), EGS_Application::initGeometry(), and EGS_Application::~EGS_Application().

void EGS_BaseGeometry::setMedia ( EGS_Input inp,
int  nmed,
const int *  med_ind 
)
protectedvirtual

Set media.

This function repeaditley takes set media keys from the input pointed to by inp and assigns media indeces using the indeces stored in med_ind. Used internally by setMedia(EGS_Input *) but left as a protected method just in case it may be useful to derived geometry classes.

Reimplemented in EGS_FastEnvelope, EGS_EnvelopeGeometry, EGS_NDGeometry, EGS_AEnvelope, EGS_SmartEnvelope, EGS_UnionGeometry, and EGS_TransformedGeometry.

Definition at line 787 of file egs_base_geometry.cpp.

References egsWarning, EGS_Input::getInput(), med, setMedium(), and EGS_Input::takeInputItem().

Member Data Documentation

int EGS_BaseGeometry::nreg
protected
string EGS_BaseGeometry::name
protected

Name of this geometry.

Every geometry needs a name, so that it can be refered to by other geometries or objects.

Definition at line 748 of file egs_base_geometry.h.

short* EGS_BaseGeometry::region_media
protected

Array of media indeces.

This array is only allocated if the geometry has more than 1 region and not all regions have the same medium index and contains the media indeces of all regions in such cases.

Definition at line 756 of file egs_base_geometry.h.

Referenced by setMedium(), and ~EGS_BaseGeometry().

int EGS_BaseGeometry::med
protected

Medium index.

This variable holds the medium index for geometries that have a single region or geometries with multiple regions filled with the same medium.

Examples:
geometry/egs_box/egs_box.cpp.

Definition at line 764 of file egs_base_geometry.h.

Referenced by EGS_NDGeometry::setMedia(), setMedia(), and setMedium().

bool EGS_BaseGeometry::has_rho_scaling
protected

Does this geometry have relative mass density scvaling?

Definition at line 770 of file egs_base_geometry.h.

Referenced by EGS_StackGeometry::EGS_StackGeometry(), EGS_UnionGeometry::EGS_UnionGeometry(), setRelativeRho(), and ~EGS_BaseGeometry().

EGS_Float* EGS_BaseGeometry::rhor
protected

Array with relative mass densities.

Definition at line 775 of file egs_base_geometry.h.

Referenced by setRelativeRho(), and ~EGS_BaseGeometry().

bool EGS_BaseGeometry::has_B_scaling
protected

Does this geometry has B field scaling factor?

Definition at line 780 of file egs_base_geometry.h.

Referenced by EGS_StackGeometry::EGS_StackGeometry(), EGS_UnionGeometry::EGS_UnionGeometry(), setBScaling(), and ~EGS_BaseGeometry().

EGS_Float* EGS_BaseGeometry::bfactor
protected

Array with B field scaling factors.

Definition at line 785 of file egs_base_geometry.h.

Referenced by setBScaling(), and ~EGS_BaseGeometry().

EGS_Float EGS_BaseGeometry::rhoRef
protected

Reference density for B field scaling.

Definition at line 790 of file egs_base_geometry.h.

Referenced by setBScaling().

int EGS_BaseGeometry::nref
protected

Number of references to this geometry.

See Also
ref() and deref()

Definition at line 796 of file egs_base_geometry.h.

bool EGS_BaseGeometry::debug
protected

Debugging flag.

This is handy during the development of a new geometry.

Definition at line 812 of file egs_base_geometry.h.

bool EGS_BaseGeometry::is_convex
protected

Is this geometry convex?

By default this data member is set to true. This should be overwritten by derived geometry classes that are not convex.

See Also
isConvex().

Definition at line 822 of file egs_base_geometry.h.

Referenced by EGS_NDGeometry::EGS_NDGeometry(), EGS_PyramidT< T >::EGS_PyramidT(), EGS_StackGeometry::EGS_StackGeometry(), and EGS_UnionGeometry::EGS_UnionGeometry().

EGS_BPType EGS_BaseGeometry::bproperty
protected

A bit mask of boolean properties for the entire geometry.

Can be set using setBoolenProperty() or addBooleanProperty()

Definition at line 828 of file egs_base_geometry.h.

Referenced by addBooleanProperty(), and setBooleanProperty().

EGS_BPType* EGS_BaseGeometry::bp_array
protected

An array of boolean properties on a region by region basis.

Only allocated if neede (i.e. not all regions in a geometry have the same boolean properties.

Definition at line 835 of file egs_base_geometry.h.

Referenced by addBooleanProperty(), setBooleanProperty(), and ~EGS_BaseGeometry().

vector<label> EGS_BaseGeometry::labels
protected

Labels.

This variable holds the list of labels for the geometry. Each label consists of a name and a list of regions numbers associated with this label name.

Labels can be associated to regions by using the set label = name r1 r2 r3 ... input when defining a geometry. This method returns a list of all regions associated with this label in the geometry. Notably, for compound geometries the labels can be defined locally, but this method returns the global region numbers in the final geometry. Labels are therefore useful to determine region numbers in complicated geometrical constructs. They are also useful to track region numbers upon modyfying the geometry.

Definition at line 858 of file egs_base_geometry.h.

Referenced by getLabelRegions(), and setLabels().


The documentation for this class was generated from the following files: