41 #ifndef EGS_CYLINDERS_
42 #define EGS_CYLINDERS_
54 #ifdef BUILD_CYLINDERS_DLL
55 #define EGS_CYLINDERS_EXPORT __declspec(dllexport)
57 #define EGS_CYLINDERS_EXPORT __declspec(dllimport)
59 #define EGS_CYLINDERS_LOCAL
63 #ifdef HAVE_VISIBILITY
64 #define EGS_CYLINDERS_EXPORT __attribute__ ((visibility ("default")))
65 #define EGS_CYLINDERS_LOCAL __attribute__ ((visibility ("hidden")))
67 #define EGS_CYLINDERS_EXPORT
68 #define EGS_CYLINDERS_LOCAL
150 EGS_Float last_t, last_d, last_B, last_A;
151 int last_ireg, last_dir;
175 const EGS_Vector &position,
const string &Name,
178 R=
new EGS_Float [nc];
179 R2=
new EGS_Float [nc];
181 for (
int i=0; i<nc; i++) {
183 R2[i]=radius[i]*radius[i];
191 const EGS_Vector &position,
const string &Name,
193 if (radius.size()>0) {
194 R=
new EGS_Float [radius.size()];
195 R2=
new EGS_Float [radius.size()];
197 for (std::size_t i=0; i<radius.size(); i++) {
199 R2[i]=radius[i]*radius[i];
207 EGS_Float rp=a*rc, rho_sq=rc.length2()-rp*rp;
208 if (rho_sq>R2[nreg-1]) {
216 EGS_Float rp=a*rc, rho_sq=rc.length2()-rp*rp;
217 if (rho_sq>R2[nreg-1]) {
223 return findRegion(rho_sq,nreg-1,R2)+1;
230 rho_sq=rc.length2()-rp*rp;
232 if (rho_sq>R2[nreg-1]) {
253 EGS_Float howfarToOutside(
int ireg,
const EGS_Vector &x,
264 EGS_Float rcp=a*rc, urc=u*rc;
265 EGS_Float C=rc.length2()-rcp*rcp-R2[nreg-1];
269 EGS_Float B=urc-up*rcp;
270 EGS_Float Dsq = sqrt(B*B-A*C);
271 EGS_Float d = B > 0 ? -C/(Dsq + B) : (Dsq - B)/A;
276 EGS_Float &t,
int *newmed = 0,
EGS_Vector *normal = 0) {
290 double rcp=a*rc, urc=u*rc;
298 double C=rc.length2()-rcp*rcp-R2[ireg];
307 double Dsq = B*B-A*C;
312 if (Dsq < -boundaryTolerance)
egsWarning(
"\nEGS_CylindersT::howfar(): "
313 "the particle may not be in the region\n we think it "
314 "is as Dsq = %g\n",Dsq);
318 d = B > 0 ? -C/(Dsq + B) : (Dsq - B)/A;
320 if (C > boundaryTolerance) {
321 egsWarning(
"\nEGS_CylindersT::howfar(): the particle "
322 "may not be in the region\n we think it is as "
325 rc.length2()-rcp*rcp,ireg,R2[ireg]);
332 last_x.
x,last_x.
y,last_x.
z,last_u.
x,last_u.
y,last_u.
z);
334 last_B,last_A,last_ireg,last_dir);
338 d = halfBoundaryTolerance;
344 double dR2=R2[ireg]-R2[ireg-1];
364 if (D_sq < -boundaryTolerance)
366 "particle may not be in the region\n we think "
367 "it is as D_sq = %g\n",D_sq);
377 d = C/(sqrt(D_sq) - B);
379 if (C < -boundaryTolerance)
egsWarning(
"EGS_CylindersT::howfar(): "
380 "the particle may not be in the region we think it "
381 "is as Cin = %g\n",C);
382 d = halfBoundaryTolerance;
390 double C=rc.length2()-rcp*rcp-R2[nreg-1],
397 d = C/(sqrt(D_sq) - B);
399 if (C < -boundaryTolerance) {
401 "we think that the particle is outside, but C=%g\n",C);
403 egsWarning(
" ireg=%d x=(%g,%g,%g) u=(%g,%g,%g)\n",
404 ireg,x.
x,x.
y,x.
z,u.
x,u.
y,u.
z);
406 d = halfBoundaryTolerance;
418 egsWarning(
"d is nan: A=%g B=%g ireg=%d R2=%g\n",
419 A,B,ireg,rc.length2()-rcp*rcp);
437 *newmed = medium(dir);
452 EGS_Float hownear(
int ireg,
const EGS_Vector &x) {
456 rho=sqrt(rc.length2()-rcp*rcp);
460 EGS_Float d=R[ireg]-rho;
463 EGS_Float dd=rho-R[ireg-1];
474 return rho-R[nreg-1];
478 int getMaxStep()
const {
482 const string &getType()
const {
486 void printInfo()
const {
491 for (
int j=0; j<nreg; j++) {
495 egsInformation(
"=====================================================\n");
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
virtual void printInfo() const
Print information about this geometry.
A set of concentric cylinders.
EGS_Float * R2
Radii squared.
EGS_CylindersT(int nc, const EGS_Float *radius, const EGS_Vector &position, const string &Name, const T &A)
Construct a set of concentric cylinders.
EGS_CylindersT(const vector< EGS_Float > &radius, const EGS_Vector &position, const string &Name, const T &A)
This is an overloaded member function, provided for convenience. It differs from the above function o...
T a
The projection operator.
EGS_Vector xo
A point on the cylinder axis.
~EGS_CylindersT()
Desctructor.
A class representing 3D vectors.
EGS_BaseGeometry class header file.
Global egspp functions header file.
Attempts to fix broken math header files.
EGS_Projector and EGS_2DVector class header file.
EGS_InfoFunction EGS_EXPORT egsInformation
Always use this function for reporting the progress of a simulation and any other type of information...
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.
const EGS_Float veryFar
A very large float.