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_XYZGeometry Class Reference

An XYZ-geometry. More...

#include <egs_nd_geometry.h>

Inheritance diagram for EGS_XYZGeometry:
EGS_BaseGeometry EGS_DeformedXYZ

Public Member Functions

 EGS_XYZGeometry (EGS_PlanesX *Xp, EGS_PlanesY *Yp, EGS_PlanesZ *Zp, const string &Name="")
 
bool isInside (const EGS_Vector &x)
 
int isWhere (const EGS_Vector &x)
 
int inside (const EGS_Vector &x)
 
int computeIntersections (int ireg, int n, const EGS_Vector &X, const EGS_Vector &u, EGS_GeometryIntersections *isections)
 
EGS_Float howfarToOutside (int ireg, const EGS_Vector &x, const EGS_Vector &u)
 
int howfar (int ireg, const EGS_Vector &x, const EGS_Vector &u, EGS_Float &t, int *newmed=0, EGS_Vector *normal=0)
 
EGS_Float hownear (int ireg, const EGS_Vector &x)
 
EGS_Float getVolume (int ireg)
 
EGS_Float getBound (int idir, int ind)
 
int getNRegDir (int idir)
 
int getMaxStep () const
 
int getNx () const
 
int getNy () const
 
int getNz () const
 
EGS_Float * getXPositions ()
 
EGS_Float * getYPositions ()
 
EGS_Float * getZPositions ()
 
const string & getType () const
 
void printInfo () const
 
void voxelizeGeometry (EGS_Input *input)
 
void setXYZLabels (EGS_Input *input)
 
virtual void getLabelRegions (const string &str, vector< int > &regs)
 
void getXLabelRegions (const string &str, vector< int > &regs)
 
void getYLabelRegions (const string &str, vector< int > &regs)
 
void getZLabelRegions (const string &str, vector< int > &regs)
 
- Public Member Functions inherited from EGS_BaseGeometry
 EGS_BaseGeometry (const string &Name)
 Construct a geometry named Name. More...
 
virtual ~EGS_BaseGeometry ()
 Destructor. More...
 
bool isConvex () const
 Is the geometry convex? More...
 
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...
 
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...
 
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...
 
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 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 getDigits (int i)
 
static EGS_XYZGeometryconstructGeometry (const char *dens_or_egphant_file, const char *ramp_file, int dens_or_egphant=0)
 
static EGS_XYZGeometryconstructCTGeometry (const char *dens_or_egphant_file)
 
- Static Public Member Functions inherited from EGS_BaseGeometry
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

void setup ()
 
void setMedia (EGS_Input *inp, int nmed, const int *med_ind)
 
int howfarFromOut (const EGS_Vector &x, const EGS_Vector &u, EGS_Float &t, int &ix, int &iy, int &iz, int &face, EGS_Vector *normal=0)
 

Protected Attributes

EGS_PlanesXxp
 
EGS_PlanesYyp
 
EGS_PlanesZzp
 
EGS_Float * xpos
 
EGS_Float * ypos
 
EGS_Float * zpos
 
int nx
 
int ny
 
int nz
 
int nxy
 
- Protected Attributes inherited from EGS_BaseGeometry
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 string type = "EGS_XYZGeometry"
 
- Static Protected Attributes inherited from EGS_BaseGeometry
static int error_flag = 0
 Set to non-zero status if a geometry problem is encountered.
 

Detailed Description

An XYZ-geometry.

An EGS_XYZGeometry is a special case of an N-dimensional geometry but is provided as a separate object to offer an easier definition because XYZ-geometries are frequently used in practice. An XYZ-geometry is constructed using

:start geometry:
    library = egs_ndgeometry
    type = EGS_XYZGeometry
    x-planes = list of the x-plane positions
    y-planes = list of the y-plane positions
    z-planes = list of the z-plane positions
:stop geometry:

and therefore does not require that separate EGS_Xplanes, EGS_Yplanes and EGS_Zplanes objects are first defined and then put together with the dimension key to form an XYZ-geometry (although, it would not be wrong to define an XYZ-geometry that way). The main saving is realized when defining the media of a heterogeneous XYZ-geometry (see Media definition). By including

set medium = i1 i2 j1 j2 k1 k2 med

keys in the media definition section, one can set the medium in all regions between x-indeces i1 and i2 (inclusive), y-indeces j1 and j2, and z-indeces k1 and k2 to the medium with index med.

The following possibilities for defining XYZ geometries have been added since the 2.2.4 release of EGSnrc:

:start geometry:
    library = egs_ndgeometry
    type = EGS_XYZGeometry
    density matrix = density_file
    ct ramp = ramp_file
:stop geometry:

where the ramp_file defines mass density to medium conversion rules and the density_file defines planes and mass densities. The format of the ct ramp file is simple:

medium1  min_density1 max_density1 default_density1
medium2  min_density2 max_density2 default_density2
...

and defines that medium1 is to be used for all voxels with a mass density between min_density1 and max_density1, etc., assuming default_density1, etc., id the default mass density for this medium. There can be an arbitrary number of lines in the ct ramp file. The density_file is a binary file that contains: 1 byte set to 0 or 1 for data written on a big- or little-endian machine, number of regions in x-,y- and z-direction (32 bit integers), followed by Nx+1 x-plane positions, Ny+1 y-plane positions, Nz+1 z-plane positions (32 bit floats in increasing order), followed by Nx*Ny*Nz mass densities (32 bit floats) with the convention that the voxel (ix,iy,iz) is region ix+iy*Nx+iz*Nx*Ny in the mass density matrix. The ct ramp file is then used to convert the mass densities to media indeces.

You may also create an EGS_XYZGeometry using an egsphant file (see PIRS-794 and the CTCreate program):

:start geometry:
    library = egs_ndgeometry
    type = EGS_XYZGeometry
    egsphant file = your_phant.egsphant
    ct ramp = ramp_file
:stop geometry:

with ct ramp being the same format as discussed above. If you've compiled egs_nd_geometry with GZIP support (distrbuted separately from EGSnrc due to licensing requirements. See https://github.com/clrp-code/egspp-geometry-lib-extras/) you may also directly use egsphant files which have been compressed with gzip.

:start geometry:
    library = egs_ndgeometry
    type = EGS_XYZGeometry
    egsphant file = your_phant.egsphant.gz
    ct ramp = ramp_file
:stop geometry:

See ndgeom_egsphant.geom geometry file for an example of loading an egsphant file with egs_ndgeometry.

The other new possibility to define a XYZ geometry is

:start geometry:
    library = egs_ndgeometry
    type = EGS_XYZGeometry
    x-slabs = Xo  Dx  Nx
    y-slabs = Yo  Dy  Ny
    z-slabs = Zo  Dz  Nz
:stop geometry:

where, along the x axis, Xo is the position of the minimum boundary of the geometry, Dx is the uniform slab thickness, and Nx is the number of slabs (similarly for the y and z axes). The number of regions along x is Nx and the maximum x boundary is thus Xo + Nx*Dx.

A simple example:

:start geometry definition:

    :start geometry:
        name            = my_xyz
        library         = egs_ndgeometry
        type            = EGS_XYZGeometry
        x-planes        = -3 -1 1 3
        y-planes        = -3 -1 1 3
        z-planes        = -3 -1 1 3
        :start media input:
            media = water air
            set medium = 1 1
            set medium = 3 1
            set medium = 5 1
            set medium = 7 1
            set medium = 9 1
            set medium = 11 1
            set medium = 13 1
            set medium = 15 1
            set medium = 17 1
            set medium = 19 1
            set medium = 21 1
            set medium = 23 1
            set medium = 25 1
        :stop media input:
    :stop geometry:

    simulation geometry = my_xyz

:stop geometry definition:
egs_xyzgeometry.png
A simple example

Definition at line 740 of file egs_nd_geometry.h.


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