50 #ifdef BUILD_PLANES_DLL
51 #define EGS_PLANES_EXPORT __declspec(dllexport)
53 #define EGS_PLANES_EXPORT __declspec(dllimport)
55 #define EGS_PLANES_LOCAL
59 #ifdef HAVE_VISIBILITY
60 #define EGS_PLANES_EXPORT __attribute__ ((visibility ("default")))
61 #define EGS_PLANES_LOCAL __attribute__ ((visibility ("hidden")))
63 #define EGS_PLANES_EXPORT
64 #define EGS_PLANES_LOCAL
180 void checkIfUniform() {
187 for (
int j=1; j<
nreg; j++) {
188 EGS_Float dpj = p[j+1] - p[j];
189 if (fabs(dpj/dp-1) > boundaryTolerance) {
211 p =
new EGS_Float [np];
212 for (
int j=0; j<np; j++) {
213 p[j] = pos[j]/a.length();
215 if (p[j] < p[j-1])
egsFatal(
"EGS_PlanesT::EGS_PlanesT: "
216 " plane positions must be in increasing order\n");
230 else egsFatal(
"EGS_PlanesT::EGS_PlanesT: attempt to construct a "
231 "plane set with %d plane positions\n",np);
237 EGS_PlanesT(
const vector<EGS_Float> &pos,
const string &Name,
const T &A) :
241 p =
new EGS_Float [np];
242 for (
int j=0; j<np; j++) {
243 p[j] = pos[j]/a.length();
245 if (p[j] < p[j-1])
egsFatal(
"EGS_PlanesT::EGS_PlanesT: "
246 " plane positions must be in increasing order\n");
260 else egsFatal(
"EGS_PlanesT::EGS_PlanesT: attempt to construct a "
261 "plane set with %d plane positions\n",np);
267 EGS_PlanesT(EGS_Float xo, EGS_Float dx,
int np,
const string &Name,
269 if (np < 1)
egsFatal(
"EGS_PlanesT::EGS_PlanesT: attempt to construct"
270 " a plane set with %d plane positions\n",np);
271 if (dx <= 0)
egsFatal(
"EGS_PlanesT::EGS_PlanesT: attempt to construct"
272 " a plane set with a non-positive slice thickness %g\n",dx);
273 p =
new EGS_Float [np+1];
275 for (
int j=0; j<np; j++) {
285 EGS_Float *getPositions() {
294 if (xp < p[0] || xp > p_last) {
302 if (xp < p[0] || xp > p_last) {
321 double xp = a*x, up = a*u;
333 EGS_Float &t,
int *newmed=0,
EGS_Vector *normal=0) {
338 double xp = a*x, up = a*u;
343 if (up > 0 && ireg < n_plane) {
344 d = (p[ireg+1]-xp)/up;
389 *normal = a.normal()*(-dir);
394 if (xp <= p[0] && up > 0) {
398 else if (xp >= p_last && up < 0) {
399 d = (p_last - xp)/up;
402 else if (xp > p[0] && xp < p_last) {
406 if (xp-p[0] < boundaryTolerance && up > 0) {
410 else if (p_last-xp < boundaryTolerance && up < 0) {
422 *normal = a.normal()*(-1.);
425 *normal = a.normal();
438 EGS_Float t = xp - p[ireg];
439 if (ireg+1 <= n_plane) {
440 EGS_Float t2 = p[ireg+1] - xp;
456 const string &
getType()
const {
468 for (
int j=0; j<
nreg; j++) {
471 if (n_plane == nreg) {
477 "=======================================================\n");
480 EGS_Float position(
int j)
const {
585 const string &Name =
"");
597 for (
int j=0; j<np-1; j++)
607 EGS_Float &t,
int *newmed=0,
EGS_Vector *normal=0) {
612 int i1=planes[ireg]->howfar(0,x,u,t1,&m1,&n1);
614 int i2=planes[ireg+1]->howfar(-1,x,u,t2,&m2,&n2);
616 if (i1 == -1 && i2 == 0) {
652 if (newmed && res != ireg) {
663 int iaux = planes[0]->howfar(-1,x,u,t,newmed,normal);
666 int i1 = planes[
nreg]->howfar(0,x,u,t,newmed,normal);
674 EGS_Float t1 = planes[ireg]->hownear(0,x);
675 EGS_Float t2 = planes[ireg+1]->hownear(-1,x);
684 return planes[0]->hownear(-1,x);
686 return planes[np-1]->hownear(0,x);
688 const string &
getType()
const {
virtual const string & getType() const =0
Get the geometry type.
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 EGS_Float howfarToOutside(int ireg, const EGS_Vector &x, const EGS_Vector &u)
A class representing 3D vectors.
Global egspp functions header file.
virtual int isWhere(const EGS_Vector &x)=0
In which region is poisition 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.
static int findRegion(EGS_Float xp, int np, const EGS_Float *p)
Find the bin to which xp belongs, given np bin edges p.
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.
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.
bool isInside(const EGS_Vector &x)
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 ...
virtual int inside(const EGS_Vector &x)=0
Returns the region index, if inside, or -1 if outside (obsolete)
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.
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 parallel planes.
A collection of non-parallel planes.
virtual EGS_Float hownear(int ireg, const EGS_Vector &x)=0
Calculate the distance to a boundary for position x in any direction.
EGS_Float * p
Plane positions.
T a
The projection operator.
int n_plane
Number of planes - 1.
EGS_Float p_last
The last plane.
EGS_Projector and EGS_2DVector class header file.
EGS_BaseGeometry class header file.
int nreg
Number of local regions in this geometry.