51 #ifdef BUILD_PLANES_DLL
52 #define EGS_PLANES_EXPORT __declspec(dllexport)
54 #define EGS_PLANES_EXPORT __declspec(dllimport)
56 #define EGS_PLANES_LOCAL
60 #ifdef HAVE_VISIBILITY
61 #define EGS_PLANES_EXPORT __attribute__ ((visibility ("default")))
62 #define EGS_PLANES_LOCAL __attribute__ ((visibility ("hidden")))
64 #define EGS_PLANES_EXPORT
65 #define EGS_PLANES_LOCAL
181 void checkIfUniform() {
188 for (
int j=1; j<
nreg; j++) {
189 EGS_Float dpj = p[j+1] - p[j];
190 if (fabs(dpj/dp-1) > boundaryTolerance) {
212 p =
new EGS_Float [np];
213 for (
int j=0; j<np; j++) {
214 p[j] = pos[j]/a.length();
216 if (p[j] < p[j-1])
egsFatal(
"EGS_PlanesT::EGS_PlanesT: "
217 " plane positions must be in increasing order\n");
231 else egsFatal(
"EGS_PlanesT::EGS_PlanesT: attempt to construct a "
232 "plane set with %d plane positions\n",np);
238 EGS_PlanesT(
const vector<EGS_Float> &pos,
const string &Name,
const T &A) :
242 p =
new EGS_Float [np];
243 for (
int j=0; j<np; j++) {
244 p[j] = pos[j]/a.length();
246 if (p[j] < p[j-1])
egsFatal(
"EGS_PlanesT::EGS_PlanesT: "
247 " plane positions must be in increasing order\n");
261 else egsFatal(
"EGS_PlanesT::EGS_PlanesT: attempt to construct a "
262 "plane set with %d plane positions\n",np);
268 EGS_PlanesT(EGS_Float xo, EGS_Float dx,
int np,
const string &Name,
270 if (np < 1)
egsFatal(
"EGS_PlanesT::EGS_PlanesT: attempt to construct"
271 " a plane set with %d plane positions\n",np);
272 if (dx <= 0)
egsFatal(
"EGS_PlanesT::EGS_PlanesT: attempt to construct"
273 " a plane set with a non-positive slice thickness %g\n",dx);
274 p =
new EGS_Float [np+1];
276 for (
int j=0; j<np; j++) {
286 EGS_Float *getPositions() {
295 if (xp < p[0] || xp > p_last) {
303 if (xp < p[0] || xp > p_last) {
322 double xp = a*x, up = a*u;
334 EGS_Float &t,
int *newmed=0,
EGS_Vector *normal=0) {
339 double xp = a*x, up = a*u;
344 if (up > 0 && ireg < n_plane) {
345 d = (p[ireg+1]-xp)/up;
390 *normal = a.normal()*(-dir);
395 if (xp <= p[0] && up > 0) {
399 else if (xp >= p_last && up < 0) {
400 d = (p_last - xp)/up;
403 else if (xp > p[0] && xp < p_last) {
407 if (xp-p[0] < boundaryTolerance && up > 0) {
411 else if (p_last-xp < boundaryTolerance && up < 0) {
423 *normal = a.normal()*(-1.);
426 *normal = a.normal();
439 EGS_Float t = xp - p[ireg];
440 if (ireg+1 <= n_plane) {
441 EGS_Float t2 = p[ireg+1] - xp;
457 const string &
getType()
const {
469 for (
int j=0; j<
nreg; j++) {
472 if (n_plane == nreg) {
478 "=======================================================\n");
481 EGS_Float position(
int j)
const {
586 const string &Name =
"");
598 for (
int j=0; j<np-1; j++)
608 EGS_Float &t,
int *newmed=0,
EGS_Vector *normal=0) {
613 int i1=planes[ireg]->howfar(0,x,u,t1,&m1,&n1);
615 int i2=planes[ireg+1]->howfar(-1,x,u,t2,&m2,&n2);
617 if (i1 == -1 && i2 == 0) {
653 if (newmed && res != ireg) {
664 int iaux = planes[0]->howfar(-1,x,u,t,newmed,normal);
667 int i1 = planes[
nreg]->howfar(0,x,u,t,newmed,normal);
675 EGS_Float t1 = planes[ireg]->hownear(0,x);
676 EGS_Float t2 = planes[ireg+1]->hownear(-1,x);
685 return planes[0]->hownear(-1,x);
687 return planes[np-1]->hownear(0,x);
689 const string &
getType()
const {
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
virtual EGS_Float hownear(int ireg, const EGS_Vector &x)=0
Calculate the distance to a boundary for position x in any direction.
virtual int inside(const EGS_Vector &x)=0
Returns the region index, if inside, or -1 if outside (obsolete)
virtual EGS_Float howfarToOutside(int ireg, const EGS_Vector &x, const EGS_Vector &u)
virtual const string & getType() const =0
Get the geometry type.
static int findRegion(EGS_Float xp, int np, const EGS_Float *p)
Find the bin to which xp belongs, given np bin edges p.
int nreg
Number of local regions in this geometry.
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.
virtual bool isInside(const EGS_Vector &x)=0
Is the position x inside the geometry?
virtual int medium(int ireg) const
Returns the medium index in region ireg.
virtual void printInfo() const
Print information about this geometry.
virtual int isWhere(const EGS_Vector &x)=0
In which region is poisition x?
A collection of non-parallel planes.
A set of parallel planes.
int n_plane
Number of planes - 1.
EGS_Float p_last
The last plane.
EGS_PlanesT(int np, const EGS_Float *pos, const string &Name, const T &A)
Construct a parallel plane set with np planes at positions pos.
T a
The projection operator.
bool isInside(const EGS_Vector &x)
EGS_PlanesT(const vector< EGS_Float > &pos, const string &Name, const T &A)
Construct a parallel plane set from the positions given by pos.
EGS_PlanesT(EGS_Float xo, EGS_Float dx, int np, const string &Name, const T &A)
Construct a parallel plane set starting at xo with uniform distance between the np+1 planes given by ...
EGS_Float * p
Plane positions.
A class representing 3D vectors.
EGS_BaseGeometry class header file.
Global egspp functions header file.
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 egsFatal
Always use this function for reporting fatal errors.
const EGS_Float veryFar
A very large float.