39 #ifndef EGS_CYLINDERS_
40 #define EGS_CYLINDERS_
52 #ifdef BUILD_CYLINDERS_DLL
53 #define EGS_CYLINDERS_EXPORT __declspec(dllexport)
55 #define EGS_CYLINDERS_EXPORT __declspec(dllimport)
57 #define EGS_CYLINDERS_LOCAL
61 #ifdef HAVE_VISIBILITY
62 #define EGS_CYLINDERS_EXPORT __attribute__ ((visibility ("default")))
63 #define EGS_CYLINDERS_LOCAL __attribute__ ((visibility ("hidden")))
65 #define EGS_CYLINDERS_EXPORT
66 #define EGS_CYLINDERS_LOCAL
148 EGS_Float last_t, last_d, last_B, last_A;
149 int last_ireg, last_dir;
173 const EGS_Vector &position,
const string &Name,
176 R=
new EGS_Float [nc];
177 R2=
new EGS_Float [nc];
179 for (
int i=0; i<nc; i++) {
181 R2[i]=radius[i]*radius[i];
189 const EGS_Vector &position,
const string &Name,
191 if (radius.size()>0) {
192 R=
new EGS_Float [radius.size()];
193 R2=
new EGS_Float [radius.size()];
195 for (std::size_t i=0; i<radius.size(); i++) {
197 R2[i]=radius[i]*radius[i];
205 EGS_Float rp=a*rc, rho_sq=rc.length2()-rp*rp;
206 if (rho_sq>R2[nreg-1]) {
214 EGS_Float rp=a*rc, rho_sq=rc.length2()-rp*rp;
215 if (rho_sq>R2[nreg-1]) {
221 return findRegion(rho_sq,nreg-1,R2)+1;
228 rho_sq=rc.length2()-rp*rp;
230 if (rho_sq>R2[nreg-1]) {
251 EGS_Float howfarToOutside(
int ireg,
const EGS_Vector &x,
262 EGS_Float rcp=a*rc, urc=u*rc;
263 EGS_Float C=rc.length2()-rcp*rcp-R2[nreg-1];
267 EGS_Float B=urc-up*rcp;
268 EGS_Float Dsq = sqrt(B*B-A*C);
269 EGS_Float d = B > 0 ? -C/(Dsq + B) : (Dsq - B)/A;
274 EGS_Float &t,
int *newmed = 0,
EGS_Vector *normal = 0) {
288 double rcp=a*rc, urc=u*rc;
296 double C=rc.length2()-rcp*rcp-R2[ireg];
305 double Dsq = B*B-A*C;
310 if (Dsq < -boundaryTolerance)
egsWarning(
"\nEGS_CylindersT::howfar(): "
311 "the particle may not be in the region\n we think it "
312 "is as Dsq = %g\n",Dsq);
316 d = B > 0 ? -C/(Dsq + B) : (Dsq - B)/A;
318 if (C > boundaryTolerance) {
319 egsWarning(
"\nEGS_CylindersT::howfar(): the particle "
320 "may not be in the region\n we think it is as "
323 rc.length2()-rcp*rcp,ireg,R2[ireg]);
325 x.
x,x.
y,x.
z,u.x,u.y,u.z);
330 last_x.x,last_x.y,last_x.z,last_u.x,last_u.y,last_u.z);
332 last_B,last_A,last_ireg,last_dir);
336 d = halfBoundaryTolerance;
342 double dR2=R2[ireg]-R2[ireg-1];
362 if (D_sq < -boundaryTolerance)
364 "particle may not be in the region\n we think "
365 "it is as D_sq = %g\n",D_sq);
375 d = C/(sqrt(D_sq) - B);
377 if (C < -boundaryTolerance)
egsWarning(
"EGS_CylindersT::howfar(): "
378 "the particle may not be in the region we think it "
379 "is as Cin = %g\n",C);
380 d = halfBoundaryTolerance;
388 double C=rc.length2()-rcp*rcp-R2[nreg-1],
395 d = C/(sqrt(D_sq) - B);
397 if (C < -boundaryTolerance) {
399 "we think that the particle is outside, but C=%g\n",C);
401 egsWarning(
" ireg=%d x=(%g,%g,%g) u=(%g,%g,%g)\n",
402 ireg,x.
x,x.
y,x.
z,u.x,u.y,u.z);
404 d = halfBoundaryTolerance;
416 egsWarning(
"d is nan: A=%g B=%g ireg=%d R2=%g\n",
417 A,B,ireg,rc.length2()-rcp*rcp);
435 *newmed = medium(dir);
450 EGS_Float hownear(
int ireg,
const EGS_Vector &x) {
454 rho=sqrt(rc.length2()-rcp*rcp);
458 EGS_Float d=R[ireg]-rho;
461 EGS_Float dd=rho-R[ireg-1];
472 return rho-R[nreg-1];
476 int getMaxStep()
const {
480 const string &getType()
const {
484 void printInfo()
const {
487 egsInformation(
" midpoint of cylinders = (%g,%g,%g)\n",xo.x,xo.y,xo.z);
489 for (
int j=0; j<nreg; j++) {
493 egsInformation(
"=====================================================\n");
virtual void printInfo() const
Print information about this geometry.
EGS_Float * R2
Radii squared.
T a
The projection operator.
A class representing 3D vectors.
Global egspp functions header file.
EGS_CylindersT(int nc, const EGS_Float *radius, const EGS_Vector &position, const string &Name, const T &A)
Construct a set of concentric cylinders.
const EGS_Float veryFar
A very large float.
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
EGS_Vector xo
A point on the cylinder axis.
~EGS_CylindersT()
Desctructor.
EGS_InfoFunction EGS_EXPORT egsInformation
Always use this function for reporting the progress of a simulation and any other type of information...
A set of concentric cylinders.
Attempts to fix broken math header files.
EGS_Projector and EGS_2DVector class header file.
EGS_BaseGeometry class header file.
EGS_CylindersT(const vector< EGS_Float > &radius, const EGS_Vector &position, const string &Name, const T &A)
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.