EGSnrc C++ class library
Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
|
A dynamic geometry. More...
#include <egs_dynamic_geometry.h>
Classes | |
struct | EGS_ControlPoint |
Structure to store control point information for dynamic geometry. More... | |
Public Member Functions | |
EGS_DynamicGeometry (EGS_BaseGeometry *G, EGS_Input *dyninp, const string &Name="") | |
Construct a dynamic geometry using G as the geometry and cpts as the control points. More... | |
~EGS_DynamicGeometry () | |
void | setTransformation (EGS_AffineTransform t) |
Sets the current state transform of the geometry. This is called when checking location. Same as gtransformed. More... | |
int | computeIntersections (int ireg, int n, const EGS_Vector &x, const EGS_Vector &u, EGS_GeometryIntersections *isections) |
Computes intersections of a particle with the dynamic geometry. More... | |
bool | isRealRegion (int ireg) const |
Checks if a region is real. More... | |
bool | isInside (const EGS_Vector &x) |
Checks if a point is inside the dynamic geometry. More... | |
int | isWhere (const EGS_Vector &x) |
Checks the location of a point. More... | |
int | inside (const EGS_Vector &x) |
Alias for isWhere method. More... | |
int | medium (int ireg) const |
Returns the medium index of a region. More... | |
EGS_Float | howfarToOutside (int ireg, const EGS_Vector &x, const EGS_Vector &u) |
Computes the distance to the outside of the dynamic geometry. More... | |
int | howfar (int ireg, const EGS_Vector &x, const EGS_Vector &u, EGS_Float &t, int *newmed=0, EGS_Vector *normal=0) |
Computes the distance to the nearest boundary. More... | |
EGS_Float | hownear (int ireg, const EGS_Vector &x) |
Computes the distance to the nearest boundary. More... | |
int | getMaxStep () const |
Returns the maximum step allowed for the dynamic geometry. More... | |
bool | hasBooleanProperty (int ireg, EGS_BPType prop) const |
Checks if the dynamic geometry has a specific boolean property in a region. More... | |
void | setBooleanProperty (EGS_BPType prop) |
Sets a boolean property for the dynamic geometry. More... | |
void | addBooleanProperty (int bit) |
Adds a boolean property for the dynamic geometry. More... | |
void | setBooleanProperty (EGS_BPType prop, int start, int end, int step=1) |
Sets a boolean property for a range of regions in the dynamic geometry. More... | |
void | addBooleanProperty (int bit, int start, int end, int step=1) |
Adds a boolean property for a range of regions in the dynamic geometry. More... | |
const string & | getType () const |
Returns the type of the dynamic geometry. More... | |
EGS_Float | getRelativeRho (int ireg) const |
Gets the relative density of a region in the dynamic geometry. More... | |
void | setRelativeRho (int start, int end, EGS_Float rho) |
Sets the relative density for a range of regions in the dynamic geometry. More... | |
void | setRelativeRho (EGS_Input *) |
This is just a placeholder function. | |
EGS_Float | getBScaling (int ireg) const |
Gets the magnetic field scaling factor for a region in the dynamic geometry. More... | |
void | setBScaling (int start, int end, EGS_Float bf) |
Sets the magnetic field scaling factor for a range of regions in the dynamic geometry. More... | |
void | setBScaling (EGS_Input *) |
This is just a placeholder function. | |
void | getLabelRegions (const string &str, vector< int > ®s) |
Retrieves regions labeled with a given string. More... | |
void | getNextGeom (EGS_RandomGenerator *rndm) |
Updates the next particle state for geometries. It is tasked with determining the next state of the dynamic geometry. More... | |
void | updatePosition (EGS_Float time) |
Updates the position of the dynamic geometry to the specified time. More... | |
void | containsDynamic (bool &hasdynamic) |
Determines whether the simulation geometry contains a dynamic geometry. More... | |
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... | |
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... | |
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? | |
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? | |
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 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 > ®s) |
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. | |
Protected Member Functions | |
void | setMedia (EGS_Input *inp, int, const int *) |
Don't define media in the transformed geometry definition. More... | |
int | getCoordGeom (EGS_Float rand, EGS_ControlPoint &gipt) |
Extract coordinates for the next dynamic geometry position. More... | |
void | buildDynamicGeometry (EGS_BaseGeometry *g, EGS_Input *dyninp) |
Builds the dynamic geometry using input specifications. More... | |
Protected Attributes | |
EGS_BaseGeometry * | g |
The geometry undergoing dynamic motion. | |
string | type |
The geometry type. | |
EGS_AffineTransform | T |
Affine transformation representing the current state. | |
vector< EGS_ControlPoint > | cpts |
Control points for dynamic motion. | |
int | ncpts |
Number of control points. | |
EGS_Float | ptime |
Time index corresponding to the particle. | |
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? | |
EGS_Float * | rhor |
Array with relative mass densities. | |
bool | has_B_scaling |
Does this geometry has B field scaling factor? | |
bool | has_Ref_rho |
EGS_Float * | bfactor |
Array with B field scaling factors. | |
EGS_Float | rhoRef |
Reference density for B field scaling. | |
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< label > | labels |
Labels. More... | |
EGS_Application * | app |
The application this object belongs to. | |
Additional Inherited Members | |
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_BaseGeometry * | createGeometry (EGS_Input *) |
Create a geometry (or geometries) from a given input. More... | |
static EGS_BaseGeometry * | createSingleGeometry (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_BaseGeometry * | getGeometry (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. | |
static int | getLastError () |
static void | resetErrorFlag () |
Static Protected Attributes inherited from EGS_BaseGeometry | |
static int | error_flag = 0 |
Set to non-zero status if a geometry problem is encountered. | |
A dynamic geometry.
A dynamic geometry provides the functionality to model motion of geometries during the simulation. This is automatically synchronized with the motion of sources and shapes. To do this, the geometry applies transformations to a previously defined geometry. By sampling a time index, continuous motion is modelled by interpolating between user-defined control points.
A dynamic geometry is defined using
:start geometry: name = ... library = egs_dynamic_geometry my geometry = name of a predefined geometry that we want to add motion to :start motion: # units of cm and degrees control point = timeIndex(1) xtrans(1) ytrans(1) ztrans(1) xrot(1) yrot(1) zrot(1) control point = timeIndex(2) xtrans(2) ytrans(2) ztrans(2) xrot(2) yrot(2) zrot(2) . . . control point = timeIndex(N) xtrans(N) ytrans(N) ztrans(N) xrot(N) yrot(N) zrot(N) :stop motion: :stop geometry:
Control points must be defined such that timeIndex(i+1)>=timeIndex(i), where timeIndex(i) is the value of time index for control point i. The timeIndex(i) are automatically normalized by timeIndex(N), where N is the number of control points.
A translation from the starting position of the geometry is applied according to xtrans, ytrans and ztrans. A rotation follows the same rotation technique as in EGS_AffineTransform, using the rotation input parameter for 2 or 3 values. Angles are in degrees and translations in cm.
Continuous, dynamic motion between control points is simulated by choosing a random number, R, on (0,1] and, for timeIndex(i)<R<=timeIndex(i+1), setting the translation or rotation parameter P by interpolation: P=P(i)+[P(i+1)-P(i)]/[timeIndex(i+1)-timeIndex(i)]*[R-timeIndex(i)]
It is generally expected that the user provide timeIndex(1)=0.0. However, the geometry can function with timeIndex(1)>0.0, in the case where a user desires to eliminate particles associated with a range of timeIndex values, but there will be a lot of warning messages.
Definition at line 110 of file egs_dynamic_geometry.h.
EGS_DynamicGeometry::EGS_DynamicGeometry | ( | EGS_BaseGeometry * | G, |
EGS_Input * | dyninp, | ||
const string & | Name = "" |
||
) |
Construct a dynamic geometry using G as the geometry and cpts as the control points.
G | Pointer to the base geometry to be transformed dynamically. |
dyninp | Input containing dynamic geometry specifications. |
Name | Name of the dynamic geometry. |
Definition at line 131 of file egs_dynamic_geometry.h.
References buildDynamicGeometry(), egsWarning, epsilon, and EGS_BaseGeometry::getType().
EGS_DynamicGeometry::~EGS_DynamicGeometry | ( | ) |
Destructor.
Definition at line 164 of file egs_dynamic_geometry.h.
void EGS_DynamicGeometry::setTransformation | ( | EGS_AffineTransform | t | ) |
Sets the current state transform of the geometry. This is called when checking location. Same as gtransformed.
t | Affine transformation to set. |
Definition at line 175 of file egs_dynamic_geometry.h.
Referenced by getNextGeom(), and updatePosition().
|
virtual |
Computes intersections of a particle with the dynamic geometry.
ireg | Region index. |
n | Number of particles. |
x | Particle position. |
u | Particle direction. |
isections | Geometry intersections. |
Reimplemented from EGS_BaseGeometry.
Definition at line 304 of file egs_dynamic_geometry.cpp.
References EGS_BaseGeometry::computeIntersections(), g, EGS_AffineTransform::inverseTransform(), EGS_AffineTransform::rotateInverse(), and T.
|
virtual |
Checks if a region is real.
ireg | Region index. |
Reimplemented from EGS_BaseGeometry.
Definition at line 312 of file egs_dynamic_geometry.cpp.
References g, and EGS_BaseGeometry::isRealRegion().
|
virtual |
Checks if a point is inside the dynamic geometry.
x | Point to check. |
Implements EGS_BaseGeometry.
Definition at line 316 of file egs_dynamic_geometry.cpp.
References g, EGS_AffineTransform::inverseTransform(), EGS_BaseGeometry::isInside(), and T.
|
virtual |
Checks the location of a point.
x | Point to check. |
Implements EGS_BaseGeometry.
Definition at line 322 of file egs_dynamic_geometry.cpp.
References g, EGS_AffineTransform::inverseTransform(), EGS_BaseGeometry::isWhere(), and T.
Referenced by inside().
|
virtual |
Alias for isWhere method.
x | Point to check. |
Implements EGS_BaseGeometry.
Definition at line 328 of file egs_dynamic_geometry.cpp.
References isWhere().
|
virtual |
Returns the medium index of a region.
ireg | Region index. |
Reimplemented from EGS_BaseGeometry.
Definition at line 332 of file egs_dynamic_geometry.cpp.
References g, and EGS_BaseGeometry::medium().
|
virtual |
Computes the distance to the outside of the dynamic geometry.
ireg | Region index. |
x | Particle position. |
u | Particle direction. |
Reimplemented from EGS_BaseGeometry.
Definition at line 336 of file egs_dynamic_geometry.cpp.
References g, EGS_AffineTransform::getRotation(), EGS_BaseGeometry::howfarToOutside(), and T.
|
virtual |
Computes the distance to the nearest boundary.
ireg | Region index. |
x | Particle position. |
u | Particle direction. |
t | Output: distance to the nearest boundary. |
newmed | Output: new medium index after crossing the boundary. |
normal | Output: normal vector at the intersection point. |
Implements EGS_BaseGeometry.
Definition at line 341 of file egs_dynamic_geometry.cpp.
References g, EGS_AffineTransform::getRotation(), EGS_BaseGeometry::howfar(), EGS_AffineTransform::inverseTransform(), EGS_AffineTransform::rotateInverse(), and T.
|
virtual |
Computes the distance to the nearest boundary.
ireg | Region index. |
x | Particle position. |
Implements EGS_BaseGeometry.
Definition at line 353 of file egs_dynamic_geometry.cpp.
References g, EGS_BaseGeometry::hownear(), EGS_AffineTransform::inverseTransform(), and T.
|
virtual |
Returns the maximum step allowed for the dynamic geometry.
Reimplemented from EGS_BaseGeometry.
Definition at line 359 of file egs_dynamic_geometry.cpp.
References g, and EGS_BaseGeometry::getMaxStep().
|
virtual |
Checks if the dynamic geometry has a specific boolean property in a region.
ireg | Region index. |
prop | Boolean property type. |
Reimplemented from EGS_BaseGeometry.
Definition at line 363 of file egs_dynamic_geometry.cpp.
References g, and EGS_BaseGeometry::hasBooleanProperty().
|
virtual |
Sets a boolean property for the dynamic geometry.
prop | Boolean property type. |
Reimplemented from EGS_BaseGeometry.
Definition at line 367 of file egs_dynamic_geometry.cpp.
References g, and EGS_BaseGeometry::setBooleanProperty().
|
virtual |
Adds a boolean property for the dynamic geometry.
bit | Bit index of the property to add. |
Reimplemented from EGS_BaseGeometry.
Definition at line 371 of file egs_dynamic_geometry.cpp.
References EGS_BaseGeometry::addBooleanProperty(), and g.
|
virtual |
Sets a boolean property for a range of regions in the dynamic geometry.
prop | Boolean property type. |
start | Start index of the range. |
end | End index of the range. |
step | Step size for the range. |
Reimplemented from EGS_BaseGeometry.
Definition at line 375 of file egs_dynamic_geometry.cpp.
References g, and EGS_BaseGeometry::setBooleanProperty().
|
virtual |
Adds a boolean property for a range of regions in the dynamic geometry.
bit | Bit index of the property to add. |
start | Start index of the range. |
end | End index of the range. |
step | Step size for the range. |
Reimplemented from EGS_BaseGeometry.
Definition at line 379 of file egs_dynamic_geometry.cpp.
References EGS_BaseGeometry::addBooleanProperty(), and g.
|
virtual |
Returns the type of the dynamic geometry.
Implements EGS_BaseGeometry.
Definition at line 383 of file egs_dynamic_geometry.cpp.
References type.
|
virtual |
Gets the relative density of a region in the dynamic geometry.
ireg | Region index. |
Reimplemented from EGS_BaseGeometry.
Definition at line 387 of file egs_dynamic_geometry.cpp.
References g, and EGS_BaseGeometry::getRelativeRho().
|
virtual |
Sets the relative density for a range of regions in the dynamic geometry.
start | Start index of the range. |
end | End index of the range. |
rho | Relative density to set. |
Reimplemented from EGS_BaseGeometry.
Definition at line 51 of file egs_dynamic_geometry.cpp.
|
virtual |
Gets the magnetic field scaling factor for a region in the dynamic geometry.
ireg | Region index. |
Reimplemented from EGS_BaseGeometry.
Definition at line 391 of file egs_dynamic_geometry.cpp.
References g, and EGS_BaseGeometry::getBScaling().
|
virtual |
Sets the magnetic field scaling factor for a range of regions in the dynamic geometry.
start | Start index of the range. |
end | End index of the range. |
bf | Magnetic field scaling factor to set. |
Reimplemented from EGS_BaseGeometry.
Definition at line 61 of file egs_dynamic_geometry.cpp.
|
virtual |
Retrieves regions labeled with a given string.
str | Label to search for. |
regs | Output: List of region indices with the specified label. |
Reimplemented from EGS_BaseGeometry.
Definition at line 117 of file egs_dynamic_geometry.cpp.
References g, and EGS_BaseGeometry::getLabelRegions().
|
virtual |
Updates the next particle state for geometries. It is tasked with determining the next state of the dynamic geometry.
rndm | Random number generator. |
Reimplemented from EGS_BaseGeometry.
Definition at line 395 of file egs_dynamic_geometry.cpp.
References EGS_Application::activeApplication(), EGS_BaseGeometry::app, g, getCoordGeom(), EGS_Application::getTimeIndex(), EGS_AffineTransform::getTransformation(), EGS_RandomGenerator::getUniform(), ptime, EGS_DynamicGeometry::EGS_ControlPoint::rot, EGS_Application::setTimeIndex(), setTransformation(), and EGS_DynamicGeometry::EGS_ControlPoint::trnsl.
|
virtual |
Updates the position of the dynamic geometry to the specified time.
time | Time index to update to. |
Reimplemented from EGS_BaseGeometry.
Definition at line 428 of file egs_dynamic_geometry.cpp.
References g, getCoordGeom(), EGS_AffineTransform::getTransformation(), EGS_DynamicGeometry::EGS_ControlPoint::rot, setTransformation(), and EGS_DynamicGeometry::EGS_ControlPoint::trnsl.
Referenced by buildDynamicGeometry().
|
virtual |
Determines whether the simulation geometry contains a dynamic geometry.
hasdynamic | Output: True if the simulation contains a dynamic geometry, false otherwise. |
Reimplemented from EGS_BaseGeometry.
Definition at line 446 of file egs_dynamic_geometry.cpp.
|
protectedvirtual |
Don't define media in the transformed geometry definition.
This function is re-implemented to warn the user not to define media in the definition of a transformed geometry. Instead, media should be defined when specifying the geometry to be transformed.
Reimplemented from EGS_BaseGeometry.
Definition at line 46 of file egs_dynamic_geometry.cpp.
References egsWarning.
|
protected |
Extract coordinates for the next dynamic geometry position.
rand | Random number for time sampling. |
gipt | EGS_ControlPoint structure to store the coordinates. |
Definition at line 234 of file egs_dynamic_geometry.cpp.
References cpts, egsWarning, epsilon, ncpts, and EGS_DynamicGeometry::EGS_ControlPoint::trnsl.
Referenced by getNextGeom(), and updatePosition().
|
protected |
Builds the dynamic geometry using input specifications.
g | Pointer to the base geometry to be transformed dynamically. |
dyninp | Input containing dynamic geometry specifications. |
Definition at line 125 of file egs_dynamic_geometry.cpp.
References cpts, egsFatal, egsWarning, EGS_Input::getInput(), ncpts, EGS_DynamicGeometry::EGS_ControlPoint::rot, EGS_Input::takeInputItem(), EGS_DynamicGeometry::EGS_ControlPoint::time, EGS_DynamicGeometry::EGS_ControlPoint::trnsl, and updatePosition().
Referenced by EGS_DynamicGeometry().