47 egsWarning(
"createShape(dynamic shape): null input?\n");
58 int err = input->
getInput(
"shape name",shape_name);
60 egsWarning(
"createShape(dynamic shape): no inline shape definition"
61 " and no 'shape name' keyword\n");
66 egsWarning(
"createShape(dynamic shape): no shape named %s "
67 "exists\n",shape_name.c_str());
81 egsWarning(
"EGS_DynamicShape: no control points input.\n");
89 vector<EGS_Float> point;
94 string inputTag =
"control point";
95 string inputTag_backCompat =
"control point " + itos.str();
102 if (!currentInput || currentInput->
getInput(inputTag, point)) {
104 if (!currentInput || currentInput->
getInput(inputTag_backCompat, point)) {
112 if (point.size()!=6 && point.size()!=7) {
113 egsFatal(
"EGS_DynamicShape: Control point %i must specify either 6 or 7 values.\n",icpts);
117 rotsize=point.size();
120 egsFatal(
"EGS_DynamicShape: Time index of control point %i < time index of control point %i\n",icpts,
ncpts);
122 else if (point[0] < 0.) {
123 egsFatal(
"EGS_DynamicShape: Time index of control point %i < 0.0\n",icpts);
125 else if (
ncpts> 0 && point.size() != rotsize) {
126 egsFatal(
"EGS_DynamicShape: Rotation definition inconsistent \n");
131 if (
ncpts ==1 && point[0] > 0.0) {
132 egsWarning(
"EGS_DynamicShape: Time index of control point 1 > 0.0. This will generate many warning messages.\n");
135 vector<EGS_Float> T_vect;
136 vector<EGS_Float> R_vect;
138 T_vect.push_back(point[1]);
139 T_vect.push_back(point[2]);
140 T_vect.push_back(point[3]);
143 if (point.size()==6) {
144 R_vect.push_back(point[6]);
145 R_vect.push_back(point[4]);
147 if (point.size()==7) {
148 R_vect.push_back(point[4]);
149 R_vect.push_back(point[5]);
150 R_vect.push_back(point[6]);
161 inputTag_backCompat =
"control point " + itos.str();
166 egsFatal(
"EGS_DynamicShape: not enough or missing control points.\n");
169 egsFatal(
"EGS_DynamicShape: time index of last control point = 0. Something's wrong.\n");
173 for (
int i=0; i<=
ncpts-1; i++) {
208 shape->getNextShapePosition(rndm);
216 for (i=0; i<
ncpts; i++) {
224 egsWarning(
"EGS_DynamicShape: could not locate control point.\n");
229 vector<EGS_Float> translation_LB=
cpts[iindex-1].trnsl;
230 vector<EGS_Float> translation_UB=
cpts[iindex].trnsl;
231 vector<EGS_Float> translation_samp;
234 EGS_Float factor = (rand-
cpts[iindex-1].time)/(
cpts[iindex].time-
cpts[iindex-1].time);
237 translation_samp.push_back(translation_LB[0]+(translation_UB[0]-translation_LB[0])*factor);
238 translation_samp.push_back(translation_LB[1]+(translation_UB[1]-translation_LB[1])*factor);
239 translation_samp.push_back(translation_LB[2]+(translation_UB[2]-translation_LB[2])*factor);
241 gipt.
trnsl=translation_samp;
244 vector<EGS_Float> rotation_LB=
cpts[iindex-1].rot;
245 vector<EGS_Float> rotation_UB=
cpts[iindex].rot;
246 vector<EGS_Float> rotation_samp;
250 if (
cpts[iindex].rot.size()==2) {
251 rotation_samp.push_back((rotation_LB[0]+(rotation_UB[0]-rotation_LB[0])*factor)*(M_PI/180));
252 rotation_samp.push_back((rotation_LB[1]+(rotation_UB[1]-rotation_LB[1])*factor)*(M_PI/180));
254 else if (
cpts[iindex].rot.size()==3) {
255 rotation_samp.push_back((rotation_LB[0]+(rotation_UB[0]-rotation_LB[0])*factor)*(M_PI/180));
256 rotation_samp.push_back((rotation_LB[1]+(rotation_UB[1]-rotation_LB[1])*factor)*(M_PI/180));
257 rotation_samp.push_back((rotation_LB[2]+(rotation_UB[2]-rotation_LB[2])*factor)*(M_PI/180));
260 egsWarning(
"EGS_DynamicShape: Invalid number of rotation parameters\n");
262 gipt.
rot=rotation_samp;
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 shape class. All shapes in the EGSnrc C++ class library are derived from EGS_BaseShape.
static EGS_BaseShape * getShape(const string &Name)
Get a pointer to the shape named Name.
static EGS_BaseShape * createShape(EGS_Input *inp)
Create a shape from the information pointed to by inp.
void setTransformation(EGS_Input *inp)
Set the transformation attached to this shape.
virtual void updatePosition(EGS_Float time)
Update the position of the shape if it is in motion.
EGS_Float ptime
Time index corresponding to particle.
int getCoord(EGS_Float rand, EGS_ControlPoint &gipt)
Extract coordinates for the next dynamic shape position.
void getNextShapePosition(EGS_RandomGenerator *rndm)
Get the next state of the dynamic shape.
void buildDynamicShape(EGS_Input *dyninp)
Build the dynamic shape using input specifications.
vector< EGS_ControlPoint > cpts
Control points.
int ncpts
Number of control points.
EGS_BaseShape * shape
Base shape made dynamic.
void setName(EGS_Input *inp)
Set the name of the object from the information provided by inp.
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).
Global egspp functions header file.
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.
Structure representing a control point for dynamic motion.
vector< EGS_Float > rot
Rotation vector.
EGS_Float time
Time index for control point.
vector< EGS_Float > trnsl
Vector specifying x, y, z translation.