EGSnrc C++ class library
Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
|
An dynamic shape. More...
#include <egs_dynamic_shape.h>
Classes | |
struct | EGS_ControlPoint |
Structure representing a control point for dynamic motion. More... | |
Public Member Functions | |
EGS_DynamicShape (EGS_BaseShape *Shape, EGS_Input *dyninp, const string &Name="", EGS_ObjectFactory *f=0) | |
Constructor for EGS_DynamicShape. More... | |
~EGS_DynamicShape () | |
Destructor for EGS_DynamicShape. | |
EGS_Vector | getPoint (EGS_RandomGenerator *rndm) |
Get a random point from the dynamic shape. More... | |
EGS_Vector | getRandomPoint (EGS_RandomGenerator *rndm) |
Returns a random 3D vector. More... | |
void | getPointSourceDirection (const EGS_Vector &Xo, EGS_RandomGenerator *rndm, EGS_Vector &u, EGS_Float &wt) |
Get the direction of the point source for a given position. More... | |
![]() | |
EGS_BaseShape (const string &Name="", EGS_ObjectFactory *f=0) | |
Construct a shape named Name. | |
virtual | ~EGS_BaseShape () |
Destructor. Deletes T if it is not null . | |
void | setTransformation (EGS_Input *inp) |
Set the transformation attached to this shape. More... | |
void | setTransformation (EGS_AffineTransform *t) |
Set the transformation attached to this shape. More... | |
const EGS_AffineTransform * | getTransform () const |
Get a pointer to the affine transformation attached to this shape. | |
virtual EGS_Float | area () const |
virtual void | updatePosition (EGS_Float time) |
Update the position of the shape if it is in motion. | |
![]() | |
EGS_Object (const string &Name="", EGS_ObjectFactory *f=0) | |
Create an EGS_Object named Name belonging to the object factory f. More... | |
EGS_Object (EGS_Input *inp, EGS_ObjectFactory *f=0) | |
Create an EGS_Object from the information pointed to by inp that belongs to object factory f. More... | |
const string & | getObjectName () const |
Get the object name. | |
void | setObjectName (const string &Name) |
Set the object name to Name. | |
const string & | getObjectType () const |
Get the object type. | |
virtual EGS_Object * | createObject (EGS_Input *inp) |
Create an object from the infromation pointed to by inp. More... | |
void | setName (EGS_Input *inp) |
Set the name of the object from the information provided by inp. More... | |
int | ref () |
Increase the reference count to this object. | |
int | deref () |
Decrease the reference count to this object. | |
void | setFactory (EGS_ObjectFactory *f) |
Set the factory to which the object belongs. More... | |
Protected Member Functions | |
void | getNextShapePosition (EGS_RandomGenerator *rndm) |
Get the next state of the dynamic shape. More... | |
void | containsDynamic (bool &hasdynamic) |
Determine whether the simulation geometry contains a dynamic shape. More... | |
bool | supportsDirectionMethod () const |
Check if the shape supports the direction method. More... | |
int | getCoord (EGS_Float rand, EGS_ControlPoint &gipt) |
Extract coordinates for the next dynamic shape position. More... | |
void | buildDynamicShape (EGS_Input *dyninp) |
Build the dynamic shape using input specifications. More... | |
Protected Attributes | |
EGS_BaseShape * | shape |
Base shape made dynamic. | |
vector< EGS_ControlPoint > | cpts |
Control points. | |
int | ncpts |
Number of control points. | |
EGS_Float | ptime |
Time index corresponding to particle. | |
![]() | |
EGS_AffineTransform * | T |
The affine transformation attached to the shape. | |
![]() | |
string | name |
The object name. | |
string | otype |
The object type. | |
int | nref |
Number of references to the object. | |
EGS_ObjectFactory * | factory |
The factory this object belongs to. | |
Additional Inherited Members | |
![]() | |
static EGS_BaseShape * | createShape (EGS_Input *inp) |
Create a shape from the information pointed to by inp. More... | |
static EGS_BaseShape * | getShape (const string &Name) |
Get a pointer to the shape named Name. More... | |
![]() | |
static string | getUniqueName (const EGS_Object *o=0) |
Create and return a unique object name. More... | |
static void | deleteObject (EGS_Object *o) |
Delete an object. More... | |
An dynamic shape.
A dynamic shape provides the functionality to model motion of shapes during the simulation. This is automatically synchronized with the motion of sources and geometries. To do this, the dynamic shape applies transformations to any other egs++ shape. By sampling a time index, continuous motion is modelled by interpolating between user-defined control points.
A dynamic shape is defined using
:start shape: library = egs_dynamic_shape :start shape: definition of the shape to be 'dynamic' :stop shape: :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 shape:
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 shape 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 106 of file egs_dynamic_shape.h.
EGS_DynamicShape::EGS_DynamicShape | ( | EGS_BaseShape * | Shape, |
EGS_Input * | dyninp, | ||
const string & | Name = "" , |
||
EGS_ObjectFactory * | f = 0 |
||
) |
Constructor for EGS_DynamicShape.
Shape | Base shape to be made dynamic |
dyninp | Input containing dynamic shape specifications |
Name | Name of the dynamic shape |
f | EGS_ObjectFactory pointer |
Definition at line 117 of file egs_dynamic_shape.h.
References egsWarning, epsilon, and EGS_Object::ref().
|
virtual |
Get a random point from the dynamic shape.
rndm | Random number generator |
Reimplemented from EGS_BaseShape.
Definition at line 167 of file egs_dynamic_shape.h.
|
virtual |
Returns a random 3D vector.
Uses the function getPoint() to pick a random position and then applies the affine transformation attached to the shape before returning it.
Reimplemented from EGS_BaseShape.
Definition at line 178 of file egs_dynamic_shape.h.
|
virtual |
Get the direction of the point source for a given position.
Xo | Position vector |
rndm | Random number generator |
u | Direction vector |
wt | Weight |
Reimplemented from EGS_BaseShape.
Definition at line 199 of file egs_dynamic_shape.h.
|
protectedvirtual |
Get the next state of the dynamic shape.
rndm | Random number generator |
Reimplemented from EGS_BaseShape.
Definition at line 180 of file egs_dynamic_shape.cpp.
References EGS_Application::activeApplication(), getCoord(), EGS_Application::getTimeIndex(), EGS_AffineTransform::getTransformation(), EGS_RandomGenerator::getUniform(), ptime, EGS_DynamicShape::EGS_ControlPoint::rot, EGS_Application::setTimeIndex(), EGS_BaseShape::setTransformation(), shape, and EGS_DynamicShape::EGS_ControlPoint::trnsl.
|
protected |
Determine whether the simulation geometry contains a dynamic shape.
hasdynamic | Boolean indicating if the simulation geometry contains a dynamic shape |
Definition at line 227 of file egs_dynamic_shape.h.
|
protectedvirtual |
Check if the shape supports the direction method.
Reimplemented from EGS_BaseShape.
Definition at line 235 of file egs_dynamic_shape.h.
References EGS_BaseShape::supportsDirectionMethod().
|
protected |
Extract coordinates for the next dynamic shape position.
rand | Random number for time sampling |
gipt | EGS_ControlPoint structure to store the coordinates |
Definition at line 211 of file egs_dynamic_shape.cpp.
References cpts, egsWarning, epsilon, ncpts, and EGS_DynamicShape::EGS_ControlPoint::trnsl.
Referenced by getNextShapePosition().
|
protected |
Build the dynamic shape using input specifications.
dyninp | Input containing dynamic shape specifications |
Definition at line 86 of file egs_dynamic_shape.cpp.
References cpts, egsFatal, egsWarning, EGS_Input::getInput(), ncpts, EGS_DynamicShape::EGS_ControlPoint::rot, EGS_Input::takeInputItem(), EGS_DynamicShape::EGS_ControlPoint::time, EGS_DynamicShape::EGS_ControlPoint::trnsl, and EGS_BaseShape::updatePosition().