41 static bool EGS_DYNAMIC_GEOMETRY_LOCAL inputSet =
false;
49 egsWarning(
"EGS_DynamicGeometry::setMedia: don't use this method. Use the\n"
50 " setMedia() methods of the geometry objects that make up this geometry\n");
58 egsWarning(
"EGS_DynamicGeometry::setRelativeRho(): don't use this "
59 "method. Use the \n setRelativeRho() methods of the underlying "
68 egsWarning(
"EGS_DynamicGeometry::setBScaling(): don't use this "
69 "method. Use the \n setBScaling() methods of the underlying "
77 static void setInputs() {
80 setBaseGeometryInputs(
false);
82 geomBlockInput->getSingleInput(
"library")->setValues({
"egs_dynamic_geometry"});
85 geomBlockInput->addSingleInput(
"base geometry",
true,
"The name of a previously defined geometry");
86 shared_ptr<EGS_BlockInput> motionBlock = geomBlockInput->addBlockInput(
"motion",
true);
87 motionBlock->addSingleInput(
"control point",
true,
"Parameters to define motion: timeIndex xtrans ytrans ztrans xrot yrot zrot");
90 EGS_DYNAMIC_GEOMETRY_EXPORT
string getExample() {
94 # Example of egs_dynamic_geometry
97 library = egs_dynamic_geometry
99 # geometry geom must be defined before this one
100 # units of cm and degrees
102 control point = 0.0 xtrans(1) ytrans(1) ztrans(1) xrot(1) yrot(1) zrot(1)
103 control point = timeIndex(2) xtrans(2) ytrans(2) ztrans(2) xrot(2) yrot(2) zrot(2)
105 control point = 1.0 xtrans(N) ytrans(N) ztrans(N) xrot(N) yrot(N) zrot(N)
112 EGS_DYNAMIC_GEOMETRY_EXPORT shared_ptr<EGS_BlockInput> getInputs() {
116 return geomBlockInput;
126 egsWarning(
"createGeometry(EGS_DynamicGeometry): got a null pointer as a geometry?\n");
132 int err = input->
getInput(
"base geometry", gname);
134 err = input->
getInput(
"my geometry", gname);
136 egsWarning(
"createGeometry(EGS_DynamicGeometry):base geometry must be defined\n either inline or using 'base geometry = some_name'\n");
142 egsWarning(
"createGeometry(EGS_DynamicGeometry): no geometry named %s is defined\n", gname.c_str());
160 egsWarning(
"EGS_DynamicGeometry: no control points input.\n");
180 vector<EGS_Float> point;
181 EGS_ControlPoint cpt;
185 string inputTag =
"control point";
186 string inputTag_backCompat =
"control point " + itos.str();
194 if (!currentInput || currentInput->
getInput(inputTag, point)) {
196 if (!currentInput || currentInput->
getInput(inputTag_backCompat, point)) {
204 if (point.size() != 6 && point.size() != 7) {
205 egsWarning(
"EGS_DynamicGeometry: Control point %i must specify either 6 or 7 values.\n", icpts);
210 rotsize = point.size();
215 egsWarning(
"EGS_DynamicGeometry: Time index of control point %i < time index of control point %i\n", icpts,
ncpts);
219 else if (point[0] < 0.0) {
220 egsWarning(
"EGS_DynamicGeometry: Time index of control point %i < 0.0\n", icpts);
224 else if (
ncpts > 0 && point.size() != rotsize) {
225 egsWarning(
"EGS_DynamicGeometry: Rotation definition inconsistent \n");
229 if (
ncpts == 1 && point[0] > 0.0) {
230 egsWarning(
"EGS_DynamicGeometry: Time index of control point 1 > 0.0. This will generate many warning messages.\n");
232 vector<EGS_Float> T_vect;
233 vector<EGS_Float> R_vect;
236 T_vect.push_back(point[1]);
237 T_vect.push_back(point[2]);
238 T_vect.push_back(point[3]);
244 if (point.size() == 6) {
245 R_vect.push_back(point[6]);
246 R_vect.push_back(point[4]);
248 if (point.size() == 7) {
249 R_vect.push_back(point[4]);
250 R_vect.push_back(point[5]);
251 R_vect.push_back(point[6]);
264 inputTag_backCompat =
"control point " + itos.str();
269 egsFatal(
"EGS_DynamicGeometry: Not enough or missing control points.\n");
272 egsFatal(
"EGS_DynamicGeometry: Time index of last control point = 0. Something's wrong.\n");
277 for (
int i = 0; i <=
ncpts - 1; i++) {
292 for (i = 0; i <
ncpts; i++) {
300 egsWarning(
"EGS_DynamicGeometry: could not locate control point.\n");
308 vector<EGS_Float> translation_LB =
cpts[iindex - 1].trnsl;
309 vector<EGS_Float> translation_UB =
cpts[iindex].trnsl;
310 vector<EGS_Float> translation_samp;
315 EGS_Float factor = (rand -
cpts[iindex - 1].time) / (
cpts[iindex].time -
cpts[iindex - 1].time);
320 translation_samp.push_back(translation_LB[0] + (translation_UB[0] - translation_LB[0]) * factor);
321 translation_samp.push_back(translation_LB[1] + (translation_UB[1] - translation_LB[1]) * factor);
322 translation_samp.push_back(translation_LB[2] + (translation_UB[2] - translation_LB[2]) * factor);
325 gipt.trnsl = translation_samp;
329 vector<EGS_Float> rotation_LB =
cpts[iindex - 1].rot;
330 vector<EGS_Float> rotation_UB =
cpts[iindex].rot;
331 vector<EGS_Float> rotation_samp;
337 if (
cpts[iindex].rot.size() == 2) {
338 rotation_samp.push_back((rotation_LB[0] + (rotation_UB[0] - rotation_LB[0]) * factor) * (M_PI / 180));
339 rotation_samp.push_back((rotation_LB[1] + (rotation_UB[1] - rotation_LB[1]) * factor) * (M_PI / 180));
341 else if (
cpts[iindex].rot.size() == 3) {
342 rotation_samp.push_back((rotation_LB[0] + (rotation_UB[0] - rotation_LB[0]) * factor) * (M_PI / 180));
343 rotation_samp.push_back((rotation_LB[1] + (rotation_UB[1] - rotation_LB[1]) * factor) * (M_PI / 180));
344 rotation_samp.push_back((rotation_LB[2] + (rotation_UB[2] - rotation_LB[2]) * factor) * (M_PI / 180));
347 egsWarning(
"EGS_DynamicGeometry: Invalid number of rotation parameters\n");
351 gipt.rot = rotation_samp;
394 EGS_Float &t,
int *newmed,
EGS_Vector *normal) {
398 int inew =
g->
howfar(ireg, xt, ut, t, newmed, normal);
399 if (inew != ireg && normal) {
449 EGS_ControlPoint gipt;
478 g->getNextGeom(rndm);
483 EGS_ControlPoint gipt;
497 g->updatePosition(time);
507 bool EGS_DynamicGeometry::hasRhoScaling() {
515 void EGS_DynamicGeometry::finishInitialization() {
516 g->finishInitialization();
Base class for advanced EGSnrc C++ applications.
static EGS_Application * activeApplication()
Get the active application.
EGS_Float getTimeIndex()
Returns the value of the time synchronization parameter.
void setTimeIndex(EGS_Float temp_time)
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
virtual int getGlobalRegionOffset(const string geomName)
Get the global region number for the first region in the geometry.
virtual int computeIntersections(int ireg, int n, const EGS_Vector &x, const EGS_Vector &u, EGS_GeometryIntersections *isections)
Calculates intersection distances to region boundaries.
virtual EGS_Float hownear(int ireg, const EGS_Vector &x)=0
Calculate the distance to a boundary for position x in any direction.
virtual bool hasBooleanProperty(int ireg, EGS_BPType prop) const
Is the boolean property prop set for region ireg ?
virtual EGS_Float howfarToOutside(int ireg, const EGS_Vector &x, const EGS_Vector &u)
virtual EGS_Float getBScaling(int ireg) const
Get the B field scaling factor in region ireg.
static EGS_BaseGeometry * createSingleGeometry(EGS_Input *inp)
Create a single geometry from the input inp.
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_rho_scaling
Does this geometry have relative mass density scvaling?
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.
void setName(EGS_Input *inp)
Set the name of the geometry from the input inp.
virtual bool isInside(const EGS_Vector &x)=0
Is the position x inside the geometry?
virtual EGS_Float getRelativeRho(int ireg) const
Get the relative mass density in region ireg.
virtual void setBooleanProperty(EGS_BPType prop)
Set the boolean properties of the entire geometry to prop.
virtual int getMaxStep() const
Returns the maximum number of steps through the geometry.
EGS_Application * app
The application this object belongs to.
virtual int medium(int ireg) const
Returns the medium index in region ireg.
int setLabels(EGS_Input *input)
Set the labels from an input block.
int ref()
Increase the reference count to this geometry.
static EGS_BaseGeometry * getGeometry(const string &Name)
Get a pointer to the geometry named Name.
virtual void addBooleanProperty(int bit)
Add a boolean property for the entire geometry by setting the bit'th bit.
void setBoundaryTolerance(EGS_Input *inp)
Set the value of the boundary tolerance from the input inp.
virtual void getLabelRegions(const string &str, vector< int > ®s, bool sanitize=true)
Get the list of all regions labeled with str.
virtual int isWhere(const EGS_Vector &x)=0
In which region is poisition x?
void setBooleanProperty(EGS_BPType prop)
Sets a boolean property for the dynamic geometry.
int ncpts
Number of control points.
void getLabelRegions(const string &str, vector< int > ®s, bool sanitize=true)
Retrieves regions labeled with a given string.
EGS_BaseGeometry * g
The geometry undergoing dynamic motion.
void getNextGeom(EGS_RandomGenerator *rndm)
Updates the next particle state for geometries. It is tasked with determining the next state of the d...
bool isInside(const EGS_Vector &x)
Checks if a point is inside the dynamic geometry.
void setTransformation(EGS_AffineTransform t)
Sets the current state transform of the geometry. This is called when checking location....
int getMaxStep() const
Returns the maximum step allowed for the dynamic geometry.
void containsDynamic(bool &hasdynamic)
Determines whether the simulation geometry contains a dynamic geometry.
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.
EGS_Float hownear(int ireg, const EGS_Vector &x)
Computes the distance to the nearest boundary.
EGS_Float howfarToOutside(int ireg, const EGS_Vector &x, const EGS_Vector &u)
Computes the distance to the outside of the dynamic geometry.
string type
The geometry type.
void buildDynamicGeometry(EGS_BaseGeometry *g, EGS_Input *dyninp)
Builds the dynamic geometry using input specifications.
void updatePosition(EGS_Float time)
Updates the position of the dynamic geometry to the specified time.
void setMedia(EGS_Input *inp, int, const int *)
Don't define media in the transformed geometry definition.
EGS_Float getRelativeRho(int ireg) const
Gets the relative density of a region in the dynamic geometry.
vector< EGS_ControlPoint > cpts
Control points for dynamic motion.
int getCoordGeom(EGS_Float rand, EGS_ControlPoint &gipt)
Extract coordinates for the next dynamic geometry position.
bool hasBooleanProperty(int ireg, EGS_BPType prop) const
Checks if the dynamic geometry has a specific boolean property in a region.
EGS_AffineTransform T
Affine transformation representing the current state.
EGS_Float ptime
Time index corresponding to the particle.
const string & getType() const
Returns the type of the dynamic geometry.
void addBooleanProperty(int bit)
Adds a boolean property for the dynamic geometry.
void setBScaling(int start, int end, EGS_Float bf)
Sets the magnetic field scaling factor for a range of regions in the dynamic geometry.
bool isRealRegion(int ireg) const
Checks if a region is real.
int getGlobalRegionOffset(const string geomName)
Pass along getGlobalRegionOffset calls to the original geometry.
int medium(int ireg) const
Returns the medium index of a region.
int isWhere(const EGS_Vector &x)
Checks the location of a point.
void setRelativeRho(int start, int end, EGS_Float rho)
Sets the relative density for a range of regions in the dynamic geometry.
int inside(const EGS_Vector &x)
Alias for isWhere method.
EGS_Float getBScaling(int ireg) const
Gets the magnetic field scaling factor for a region in the dynamic geometry.
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.
Base random number generator class. All random number generators should be derived from this class.
EGS_Float getUniform()
Returns a random number uniformly distributed between zero (inclusive) and 1 (exclusive).
A class representing 3D vectors.
A dynamic geometry: header.
Global egspp functions header file.
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.
const EGS_Float epsilon
The epsilon constant for floating point comparisons.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.