EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_geometry_tester.cpp
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ geometry tester
5 # Copyright (C) 2015 National Research Council Canada
6 #
7 # This file is part of EGSnrc.
8 #
9 # EGSnrc is free software: you can redistribute it and/or modify it under
10 # the terms of the GNU Affero General Public License as published by the
11 # Free Software Foundation, either version 3 of the License, or (at your
12 # option) any later version.
13 #
14 # EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
17 # more details.
18 #
19 # You should have received a copy of the GNU Affero General Public License
20 # along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
21 #
22 ###############################################################################
23 #
24 # Author: Iwan Kawrakow, 2005
25 #
26 # Contributors: Reid Townson
27 # Hubert Ho
28 #
29 ###############################################################################
30 */
31 
32 
37 #include "egs_geometry_tester.h"
38 #include "egs_input.h"
39 #include "egs_base_geometry.h"
40 #include "egs_rndm.h"
41 #include "egs_shapes.h"
42 #include "egs_timer.h"
43 #include "egs_math.h"
44 #include "egs_functions.h"
45 
46 #include <cstdio>
47 #include <string>
48 using namespace std;
49 
50 //static int __geometry_error = 0;
51 
52 #ifndef SKIP_DOXYGEN
53 
58 class EGS_LOCAL EGS_PrivateTester {
59 
60 public:
61 
62  EGS_PrivateTester(EGS_GeometryTester *, EGS_Input *);
63  ~EGS_PrivateTester() {
64  /*
65  if( inside_shape ) delete inside_shape;
66  if( inside_time_shape ) delete inside_time_shape;
67  if( hownear_shape ) delete hownear_shape;
68  if( howfar_shape ) delete howfar_shape;
69  if( howfar_time_shape ) delete howfar_time_shape;
70  */
71  EGS_Object::deleteObject(inside_shape);
72  EGS_Object::deleteObject(inside_time_shape);
73  EGS_Object::deleteObject(hownear_shape);
74  EGS_Object::deleteObject(hownear_time_shape);
75  EGS_Object::deleteObject(howfar_shape);
76  EGS_Object::deleteObject(howfar_time_shape);
77  };
78  void testInside(EGS_BaseGeometry *);
79  void testInsideTime(EGS_BaseGeometry *);
80  void testHownear(int ntry, EGS_BaseGeometry *);
81  void testHownearTime(EGS_BaseGeometry *);
82  void testHowfar(EGS_BaseGeometry *, bool time);
83 
84  FILE *fp_info, *fp_warn, *fp_inside, *fp_hownear, *fp_howfar;
85  FILE *fp_this_test;
86 
87 private:
88 
89  EGS_GeometryTester *parent;
90  EGS_RandomGenerator *rndm;
91 
92  int n_inside;
93  EGS_BaseShape *inside_shape;
94 
95  int n_inside_time;
96  EGS_BaseShape *inside_time_shape;
97 
98  int n_hownear;
99  EGS_BaseShape *hownear_shape;
100 
101  int n_hownear_time;
102  EGS_BaseShape *hownear_time_shape;
103 
104  int n_howfar;
105  EGS_BaseShape *howfar_shape;
106  bool check_infinity;
107 
108  int n_howfar_time;
109  EGS_BaseShape *howfar_time_shape;
110  bool store_steps;
111 
112  void setTest(EGS_Input *i, const char *delim, int &n, EGS_BaseShape **s);
113 
114  int beginTest(int n, const EGS_BaseShape *s, const char *func,
115  const char *name, const EGS_BaseGeometry *g);
116 
117 };
118 #endif
119 
121  p = new EGS_PrivateTester(this,i);
122 }
123 
125  delete p;
126 }
127 
129  p->testInside(g);
130 }
131 
133  p->testInsideTime(g);
134 }
135 
137  p->testHownear(ntry,g);
138 }
139 
141  p->testHownearTime(g);
142 }
143 
145  p->testHowfar(g,false);
146 }
147 
149  p->testHowfar(g,true);
150 }
151 
153  fprintf(p->fp_this_test,"%g %g %g\n",x.x,x.y,x.z);
154 };
155 
156 #ifndef SKIP_DOXYGEN
157 EGS_PrivateTester::EGS_PrivateTester(EGS_GeometryTester *p, EGS_Input *input) {
158  if (!p) egsFatal("EGS_PrivateTester::EGS_PrivateTester:\n"
159  " attempt to construct a tester with a null parent\n");
160  parent = p;
161  rndm = 0;
162  n_inside = 0;
163  n_inside_time = 0;
164  n_hownear = 0;
165  n_hownear_time = 0;
166  n_howfar = 0;
167  n_howfar_time = 0;
168  inside_shape = 0;
169  inside_time_shape = 0;
170  hownear_shape = 0;
171  howfar_shape = 0;
172  hownear_time_shape = 0;
173  howfar_time_shape = 0;
174  hownear_shape = 0;
175  store_steps = true;
176  check_infinity = true;
177  fp_info = stdout;
178  fp_warn = stderr;
179  fp_inside = stdout;
180  fp_hownear = stdout;
181  fp_howfar = stdout;
182 
183  rndm = EGS_RandomGenerator::createRNG(input);
184  if (!rndm) {
186  }
187 
188  setTest(input,"inside test",n_inside,&inside_shape);
189  fp_inside = fp_this_test;
190 
191  setTest(input,"inside time test",n_inside_time,&inside_time_shape);
192 
193  setTest(input,"hownear test",n_hownear,&hownear_shape);
194  fp_hownear = fp_this_test;
195 
196  setTest(input,"hownear time test",n_hownear_time,&hownear_time_shape);
197 
198  setTest(input,"howfar test",n_howfar,&howfar_shape);
199  fp_howfar = fp_this_test;
200 
201  setTest(input,"howfar time test",n_howfar_time,&howfar_time_shape);
202 
203 }
204 
205 void EGS_PrivateTester::setTest(EGS_Input *input, const char *delim, int &n,
206  EGS_BaseShape **s) {
207  EGS_Input *i = input->takeInputItem(delim);
208  if (!i) fprintf(fp_warn,"EGS_PrivateTester::EGS_setTest: \n"
209  " no '%s' specification\n",delim);
210  else {
211  string shape_name;
212  int ierr = i->getInput("bounding shape name",shape_name);
213  EGS_BaseShape *shape = 0;
214  if (!ierr) {
215  shape = EGS_BaseShape::getShape(shape_name);
216  }
217  if (!shape) {
218  EGS_Input *ishape = i->takeInputItem("bounding shape");
219  if (!ishape) fprintf(fp_warn,"EGS_PrivateTester::EGS_setTest: \n"
220  " no 'bounding shape' definition for %s\n",delim);
221  else {
222  shape = EGS_BaseShape::createShape(ishape);
223  delete ishape;
224  }
225  }
226  if (!shape) fprintf(fp_warn,"EGS_PrivateTester::EGS_PrivateTester:"
227  "\n got null shape for %s\n",delim);
228  else {
229  shape->ref();
230  *s = shape;
231  }
232  int err = i->getInput("ntest",n);
233  if (err) fprintf(fp_warn,"EGS_PrivateTester::setTest: \n"
234  " missing/wrong 'ntest' input for %s\n",delim);
235  string fname;
236  fp_this_test = stdout;
237  err = i->getInput("file name",fname);
238  if (!err && fname.size() > 0) {
239  fp_this_test = fopen(fname.c_str(),"w");
240  if (!fp_this_test) {
241  fprintf(fp_warn,"EGS_PrivateTester::setTest: \n"
242  " failed to open file %s from writing\n",fname.c_str());
243  fp_this_test = stdout;
244  }
245  }
246  int ci;
247  err = i->getInput("check infinity",ci);
248  if (!err && ci == 0) {
249  check_infinity = false;
250  }
251 
252  string delimeter(delim);
253  if (delimeter == "howfar time test") {
254  string ss;
255  i->getInput("store steps",ss);
256  if (ss == "no" || ss == "0") {
257  fprintf(fp_info,"will not store steps in howfar test\n");
258  store_steps = false;
259  }
260  }
261 
262  delete i;
263  }
264 }
265 
266 void EGS_PrivateTester::testInside(EGS_BaseGeometry *g) {
267  if (beginTest(n_inside,inside_shape,"testInside()","inside test",g)) {
268  return;
269  }
270  int n_in = 0;
271  fp_this_test = fp_inside;
272  for (int j=0; j<n_inside; j++) {
273  EGS_Vector x = inside_shape->getRandomPoint(rndm);
274  int ireg = g->inside(x);
275  if (ireg >= 0) {
276  n_in++;
277  parent->printPosition(x);
278  }
279  }
280  fprintf(fp_info,"finished inside test. Point inside: %d (%g)\n",
281  n_in,((double) n_in)/((double) n_inside));
282 }
283 
284 void EGS_PrivateTester::testInsideTime(EGS_BaseGeometry *g) {
285  if (beginTest(n_inside_time,inside_time_shape,"testInsideTime()",
286  "inside time test",g)) {
287  return;
288  }
289  int n_in = 0;
290  EGS_Timer t;
291  for (int j=0; j<n_inside_time; j++) {
292  EGS_Vector x = inside_time_shape->getRandomPoint(rndm);
293  int ireg = g->inside(x);
294  if (ireg >= 0) {
295  n_in++;
296  }
297  }
298  EGS_Float cpu = t.time();
299  fprintf(fp_info,"finished inside time test.\n");
300  fprintf(fp_info," point inside: %d (%g)\n",n_in,
301  ((double) n_in)/((double) n_inside_time));
302  fprintf(fp_info," cpu time: %g seconds\n",cpu);
303 }
304 
305 void EGS_PrivateTester::testHownear(int ntry, EGS_BaseGeometry *g) {
306  if (ntry < 1) {
307  fprintf(fp_warn,"EGS_GeometryTester::testHownear(): ntry must be >0\n");
308  return;
309  }
310  if (beginTest(n_hownear,hownear_shape,"testHownear()","hownear test",g)) {
311  return;
312  }
313  int n_fail = 0;
314  for (int j=0; j<n_hownear; j++) {
315  EGS_Vector x = hownear_shape->getRandomPoint(rndm);
316  int ireg = g->inside(x);
317  EGS_Float tperp = g->hownear(ireg,x);
318  for (int i=0; i<ntry; i++) {
319  EGS_Float cost = 2*rndm->getUniform()-1;
320  EGS_Float sint = tperp*sqrt(1-cost*cost);
321  EGS_Float cphi, sphi;
322  rndm->getAzimuth(cphi,sphi);
323  EGS_Vector xi(x.x+sint*cphi,x.y+sint*sphi,x.z+tperp*cost);
324  int ireg_i = g->inside(xi);
325  if (ireg_i != ireg) {
326  n_fail++;
327  fprintf(fp_hownear," point (%g,%g,%g) with tperp=%g fails for "
328  "(%g,%g,%g): %d %d\n",x.x,x.y,x.z,tperp,xi.x,xi.y,xi.z,ireg,ireg_i);
329  }
330  }
331  }
332  fprintf(fp_info,"finished hownear test. number of failed points: %d\n",
333  n_fail);
334 }
335 
336 void EGS_PrivateTester::testHownearTime(EGS_BaseGeometry *g) {
337  if (beginTest(n_hownear_time,hownear_time_shape,"testHownearTime()",
338  "hownear time test",g)) {
339  return;
340  }
341  double sum_tperp = 0;
342  EGS_Timer t;
343  for (int j=0; j<n_hownear_time; j++) {
344  EGS_Vector x = hownear_time_shape->getRandomPoint(rndm);
345  int ireg = g->inside(x);
346  sum_tperp += g->hownear(ireg,x);
347  }
348  EGS_Float cpu = t.time();
349  fprintf(fp_info,"finished hownear time test.\n");
350  fprintf(fp_info," average tperp: %g\n",sum_tperp/n_hownear_time);
351  fprintf(fp_info," cpu time: %g seconds\n",cpu);
352 }
353 
354 
355 #define N_MAX_STEP 200
356 
357 void EGS_PrivateTester::testHowfar(EGS_BaseGeometry *g, bool time) {
358  EGS_Vector positions[N_MAX_STEP];
359  int regions[N_MAX_STEP];
360  int btest;
361  int ncase;
362  EGS_BaseShape *hshape;
363  bool ss;
364  if (time) {
365  ncase = n_howfar_time;
366  btest = beginTest(n_howfar_time,howfar_time_shape,"testHowfarTime()",
367  "howfar time test",g);
368  hshape = howfar_time_shape;
369  ss = store_steps;
370  fprintf(fp_info,"Store steps: %d\n",ss);
371  }
372  else {
373  ncase = n_howfar;
374  btest = beginTest(n_howfar,howfar_shape,"testHowfar()","howfar test",g);
375  hshape = howfar_shape;
376  ss = true;
377  }
378  if (btest) {
379  return;
380  }
381  const EGS_AffineTransform *T = hshape->getTransform();
382  egsWarning("has transofrmation: %d\n",(T != 0));
383  //EGS_BaseGeometry::geometry_error = &__geometry_error;
384  EGS_Timer timer;
385  fp_this_test = fp_howfar;
386  double nstep = 0;
387  for (int j=0; j<ncase; j++) {
388  EGS_Vector x = hshape->getRandomPoint(rndm);
389  EGS_Float cost = 2*rndm->getUniform()-1;
390  EGS_Float sint = sqrt(1-cost*cost);
391  EGS_Float cphi, sphi;
392  rndm->getAzimuth(cphi,sphi);
393  EGS_Vector u(sint*cphi,sint*sphi,cost);
394  EGS_Vector Xo(x);
395  bool go_back = true;
396  //egsWarning("x = (%g,%g,%g) u = (%g,%g,%g)\n",x.x,x.y,x.z,u.x,u.y,u.z);
397 retry:
398  //if( !go_back ) egsWarning("Initial position: (%g,%g,%g) direction: "
399  // "(%g,%g,%g)\n",x.x,x.y,x.z,u.x,u.y,u.z);
400  EGS_Float t_step = veryFar;
401  int ireg = g->inside(x);
402  int ireg_first = ireg;
403  ireg = g->howfar(ireg,x,u,t_step);
404  if (ireg < 0 && ireg != ireg_first && !time) {
405  EGS_Vector tmp(x + u*t_step);
406  parent->printPosition(tmp);
407  }
408  //egsWarning("ireg: %d new_ireg: %d t = %g\n",ireg_first,ireg,t_step);
409  int n_step = 0;
410  if (ireg >= 0) {
411  x += u*t_step;
412  if (ss) {
413  positions[n_step] = x;
414  regions[n_step++] = ireg;
415  }
416  if (!time) {
417  parent->printPosition(x);
418  }
419  }
420  //if( !go_back && ireg >= 0 ) egsWarning("Starting loop: ireg=%d "
421  // "x=(%g,%g,%g)\n",ireg,x.x,x.y,x.z);
422  while (ireg >= 0) {
423  t_step = veryFar;
424  int ireg_new = g->howfar(ireg,x,u,t_step);
425  //if( !go_back ) egsWarning("new region=%d step=%g x=(%g,%g,%g)\n",
426  // ireg_new,t_step,x.x,x.y,x.z);
427  //if( __geometry_error ) {
428  // egsWarning("Geometry error occured\n");
429  // __geometry_error = 0;
430  // if( go_back ) {
431  // go_back = false; x = Xo; goto retry;
432  // }
433  //}
434  if (ireg_new == ireg) {
435  break;
436  }
437  // if the above condition is true,
438  // we assume to be in an anfinite geometry with a direction
439  // such that we never get out.
440  ireg = ireg_new;
441  x += u*t_step;
442  nstep += 1;
443  if (ss) {
444  positions[n_step] = x;
445  regions[n_step++] = ireg;
446  if (n_step >= N_MAX_STEP) {
447  if (go_back) {
448  egsWarning("testHowfar(): number of steps exceeded %d for"
449  " case %d:\n",N_MAX_STEP,j+1);
450  egsWarning(" direction = (%g,%g,%g)\n",u.x,u.y,u.z);
451  egsWarning(" initial position = (%g,%g,%g) region = %d\n",
452  Xo.x,Xo.y,Xo.z,ireg_first);
453  for (int j=0; j<N_MAX_STEP; j++)
454  egsWarning("x = (%g,%g,%g) ireg = %d\n",positions[j].x,
455  positions[j].y,positions[j].z,regions[j]);
456  go_back = false;
457  g->setDebug(true);
458  x = Xo;
459  goto retry;
460  }
461  egsFatal("\nQuiting now\n\n");
462  }
463  }
464  if (!time) {
465  if (check_infinity && x.length2() > 1e10) {
466  egsWarning("testHowfar(): x -> infinity for case %d?\n",
467  j+1);
468  egsWarning(" direction = (%g,%g,%g)\n",u.x,u.y,u.z);
469  egsWarning(" initial position = (%g,%g,%g) region = %d\n",
470  Xo.x,Xo.y,Xo.z,ireg_first);
471  for (int j=0; j<n_step; j++) egsWarning("x = (%g,%g,%g) "
472  "ireg = %d\n",positions[j].x,positions[j].y,
473  positions[j].z,regions[j]);
474  }
475  if (ireg >= 0) {
476  int itest = g->inside(x);
477  if (itest < 0) {
478  egsWarning("testHowfar(): after howfar step ireg = %d"
479  " but inside() returns %d\n",ireg,itest);
480  egsWarning(" position = (%g,%g,%g)\n",x.x,x.y,x.z);
481  egsWarning(" direction = (%g,%g,%g)\n",u.x,u.y,u.z);
482  egsWarning(" initial position = (%g,%g,%g) "
483  "region = %d\n",Xo.x,Xo.y,Xo.z,ireg_first);
484  for (int j=0; j<n_step; j++) egsWarning("x = (%g,%g,%g) "
485  "ireg = %d\n",positions[j].x,positions[j].y,
486  positions[j].z,regions[j]);
487  break;
488  }
489  }
490  parent->printPosition(x);
491  }
492  }
493  }
494  EGS_Float cpu = timer.time();
495  if (time) {
496  fprintf(fp_info,"finished howfar time test, cpu time = %g seconds\n",
497  cpu);
498  fprintf(fp_info," average number of steps: %g\n",nstep/ncase);
499  }
500  else {
501  fprintf(fp_info,"finished howfar test.\n");
502  }
503 }
504 
505 
506 int EGS_PrivateTester::beginTest(int n, const EGS_BaseShape *s,
507  const char *func, const char *name, const EGS_BaseGeometry *g) {
508  if (!s) {
509  fprintf(fp_warn,"EGS_GeometryTester::%s: no bounding shape defined\n",
510  func);
511  return 1;
512  }
513  if (n <= 0) {
514  fprintf(fp_warn,"EGS_GeometryTester::%s: number of test cases to run "
515  "is less than 1 (%d)\n",func,n);
516  return 2;
517  }
518  fprintf(fp_info,"\nEGS_GeometryTester::%s: starting %s\n",func,name);
519  fprintf(fp_info," number of cases: %d\n",n);
520  fprintf(fp_info," bounding shape: %s\n",s->getObjectType().c_str());
521  //fprintf(fp_info," geometry:\n"); g->printInfo();
522  fprintf(fp_info," geometry: %s (type %s)\n",g->getName().c_str(),
523  g->getType().c_str());
524  return 0;
525 }
526 #endif
527 
528 #ifndef SKIP_DOXYGEN
529 class EGS_LOCAL EGS_CylTester : public EGS_GeometryTester {
530 public:
531  EGS_CylTester(const EGS_Vector &A,EGS_Input *i) :
532  EGS_GeometryTester(i), a(A) {
533  a.normalize();
534  };
535  ~EGS_CylTester() {};
536  void printPosition(const EGS_Vector &x) {
537  EGS_Float z = x*a;
538  EGS_Float r = sqrt(x.length2()-z*z);
539  fprintf(p->fp_this_test,"%g %g\n",z,r);
540  };
541 private:
542  EGS_Vector a;
543 };
544 
545 class EGS_LOCAL EGS_SphereTester : public EGS_GeometryTester {
546 public:
547  EGS_SphereTester(const EGS_Vector &Xo, EGS_Input *i) :
548  EGS_GeometryTester(i), xo(Xo) {};
549  ~EGS_SphereTester() {};
550  void printPosition(const EGS_Vector &x) {
551  EGS_Vector xp(x-xo);
552  EGS_Float r2 = xp.length2();
553  fprintf(p->fp_this_test,"%g %g\n",xp.z,sqrt(r2-xp.z*xp.z));
554  };
555 private:
556  EGS_Vector xo;
557 };
558 
559 class EGS_LOCAL EGS_TransformedTester : public EGS_GeometryTester {
560 public:
561  EGS_TransformedTester(const EGS_AffineTransform &t, EGS_Input *i) :
562  EGS_GeometryTester(i), T(t) {};
563  ~EGS_TransformedTester() {};
564  void printPosition(const EGS_Vector &x) {
565  EGS_Vector xp(x*T);
566  fprintf(p->fp_this_test,"%g %g %g\n",xp.x,xp.y,xp.z);
567  };
568 private:
570 };
571 #endif
572 
574  if (!input) {
575  egsWarning("EGS_GeometryTester::getGeometryTester:\n"
576  " input is null?\n");
577  return 0;
578  }
579  bool delete_it = false;
580  EGS_Input *i;
581  if (input->isA("geometry tester")) {
582  i = input;
583  }
584  else {
585  i = input->takeInputItem("geometry tester");
586  if (!i) {
587  egsWarning("EGS_GeometryTester::getGeometryTester:\n"
588  " no 'geometry tester' input\n");
589  return 0;
590  }
591  delete_it = true;
592  }
593  EGS_Input *ishape;
594  while ((ishape = i->takeInputItem("bounding shape"))) {
595  egsWarning("*** adding shape\n");
597  delete ishape;
598  }
599  string type;
600  EGS_GeometryTester *tester;
601  int err = i->getInput("output type",type);
602  if (err || i->compare(type,"normal")) {
603  tester = new EGS_GeometryTester(i);
604  }
605  else if (i->compare(type,"cylindrical")) {
606  vector<EGS_Float> axis;
607  int err1 = i->getInput("axis",axis);
608  if (!err1 && axis.size() == 3) {
609  tester = new EGS_CylTester(EGS_Vector(axis[0],axis[1],axis[2]),i);
610  }
611  else {
612  egsWarning("EGS_GeometryTester::getGeometryTester: no 'axis'"
613  " input for cylindrical output type\n");
614  tester = new EGS_GeometryTester(i);
615  }
616  }
617  else if (i->compare(type,"spherical")) {
618  vector<EGS_Float> Xo;
619  int err1 = i->getInput("midpoint",Xo);
620  if (!err1 && Xo.size() == 3) {
621  tester = new EGS_SphereTester(EGS_Vector(Xo[0],Xo[1],Xo[2]),i);
622  }
623  else {
624  tester = new EGS_SphereTester(EGS_Vector(),i);
625  }
626  }
627  else if (i->compare(type,"transformed")) {
629  if (!t) {
630  egsWarning("EGS_GeometryTester::getGeometryTester: no "
631  "transformation defined for a transformed tester\n");
632  tester = new EGS_GeometryTester(i);
633  }
634  else {
635  tester = new EGS_TransformedTester(*t,i);
636  delete t;
637  }
638  }
639  else {
640  egsWarning("EGS_GeometryTester::getGeometryTester: unknown tester"
641  " type %s\n",type.c_str());
642  tester = new EGS_GeometryTester(i);
643  }
644  if (delete_it) {
645  delete i;
646  }
647  return tester;
648 }
649 
EGS_GeometryTester class header file.
virtual const string & getType() const =0
Get the geometry type.
A class for testing geometries.
EGS_Float time()
Returns the CPU time in seconds since start() was called.
Definition: egs_timer.cpp:106
virtual void printPosition(const EGS_Vector &x)
Outputs the position x to a file.
virtual EGS_Vector getRandomPoint(EGS_RandomGenerator *rndm)
Returns a random 3D vector.
Definition: egs_shapes.h:134
bool isA(const string &key) const
Definition: egs_input.cpp:278
void testHownear(int ntry, EGS_BaseGeometry *g)
Performs a hownear test.
A class providing affine transformations.
static EGS_BaseShape * createShape(EGS_Input *inp)
Create a shape from the information pointed to by inp.
Definition: egs_shapes.cpp:51
void testInsideTime(EGS_BaseGeometry *)
Performs an inside time test.
virtual ~EGS_GeometryTester()
Destructor.
EGS_Input class header file.
EGS_Float y
y-component
Definition: egs_vector.h:61
A class representing 3D vectors.
Definition: egs_vector.h:56
static EGS_BaseShape * getShape(const string &Name)
Get a pointer to the shape named Name.
Definition: egs_shapes.cpp:63
Global egspp functions header file.
static void deleteObject(EGS_Object *o)
Delete an object.
Base shape class. All shapes in the EGSnrc C++ class library are derived from EGS_BaseShape.
Definition: egs_shapes.h:112
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.
const EGS_Float veryFar
A very large float.
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
void testHowfarTime(EGS_BaseGeometry *)
Performs a howfar time test.
Base random number generator class. All random number generators should be derived from this class...
Definition: egs_rndm.h:67
const EGS_AffineTransform * getTransform() const
Get a pointer to the affine transformation attached to this shape.
Definition: egs_shapes.h:178
EGS_Float z
z-component
Definition: egs_vector.h:62
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.
EGS_RandomGenerator class header file.
EGS_GeometryTester(EGS_Input *)
Construct a geometry tester from an input tree.
virtual int inside(const EGS_Vector &x)=0
Returns the region index, if inside, or -1 if outside (obsolete)
int ref()
Increase the reference count to this object.
EGS_BaseShape and shape classes header file.
A simple class for measuring CPU time.
Definition: egs_timer.h:57
virtual EGS_Float hownear(int ireg, const EGS_Vector &x)=0
Calculate the distance to a boundary for position x in any direction.
Attempts to fix broken math header files.
static EGS_GeometryTester * getGeometryTester(EGS_Input *i)
Creates a geometry tester object from the input i.
void testHownearTime(EGS_BaseGeometry *)
Performs a hownear time test.
const string & getObjectType() const
Get the object type.
EGS_Float x
x-component
Definition: egs_vector.h:60
static EGS_AffineTransform * getTransformation(EGS_Input *inp)
Constructs an affine transformation object from the input pointed to by inp and returns a pointer to ...
static EGS_RandomGenerator * createRNG(EGS_Input *inp, int sequence=0)
Create a RNG object from the information pointed to by inp and return a pointer to it...
Definition: egs_rndm.cpp:408
A class for storing information in a tree-like structure of key-value pairs. This class is used throu...
Definition: egs_input.h:182
const string & getName() const
Get the name of this geometry.
static bool compare(const string &s1, const string &s2)
Definition: egs_input.cpp:1170
static EGS_RandomGenerator * defaultRNG(int sequence=0)
Returns a pointer to the default egspp RNG.
Definition: egs_rndm.cpp:464
void setDebug(bool deb)
Turn debugging on.
void testHowfar(EGS_BaseGeometry *)
Performs a howfar test.
EGS_BaseGeometry class header file.
EGS_Timer class header file.
void testInside(EGS_BaseGeometry *g)
Performs an inside test.
EGS_Input * takeInputItem(const string &key, bool self=true)
Get the property named key.
Definition: egs_input.cpp:226
int getInput(const string &key, vector< string > &values) const
Assign values to an array of strings from an input identified by key.
Definition: egs_input.cpp:338
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.