46 #ifdef BUILD_PRISM_DLL
47 #define EGS_PRISM_EXPORT __declspec(dllexport)
49 #define EGS_PRISM_EXPORT __declspec(dllimport)
51 #define EGS_PRISM_LOCAL
55 #ifdef HAVE_VISIBILITY
56 #define EGS_PRISM_EXPORT __attribute__ ((visibility ("default")))
57 #define EGS_PRISM_LOCAL __attribute__ ((visibility ("hidden")))
59 #define EGS_PRISM_EXPORT
60 #define EGS_PRISM_LOCAL
155 EGS_PrismT(T *P, EGS_Float D1, EGS_Float D2,
const string &Name=
"") :
157 d1(D1), d2(D2), open(false) {
173 EGS_Float d = p->distance(x);
174 if (d < d1 || d > d2) {
178 return p->isInside2D(x);
194 EGS_Float &t,
int *newmed = 0,
EGS_Vector *normal = 0) {
198 bool hit = p->howfar2D(ireg == 0 ?
true :
false,x,u,t,pv);
203 *newmed = !ireg ? -1 :
med;
206 *normal = p->getNormal(v);
208 return !ireg ? -1 : 0;
210 EGS_Float up = a*u, d = p->distance(x);
214 if (up > boundaryTolerance) {
217 else if (up < -boundaryTolerance) {
232 *normal = up>0 ? a*(-1) : a;
238 bool hit = p->howfar2D(
true,x,u,t,pv);
246 *normal = p->getNormal(v);
250 if (d < d1 || d > d2) {
252 if (d < d1 && up > boundaryTolerance) {
255 else if (d > d2 && up < -boundaryTolerance) {
260 if (p->isInside2D(xp)) {
266 *normal = up>0 ? a*(-1) : a;
273 bool hit = p->howfar2D(
false,x,u,tt,pv);
277 d = p->distance(x+u*tt);
278 if (d >= d1 && d <= d2) {
284 *normal = p->getNormal(v);
292 EGS_Float tperp = p->hownear2D(ireg == 0 ?
true :
false,x);
296 EGS_Float d = p->distance(x);
298 EGS_Float t = d2 - d;
318 if (p->isInside2D(x)) {
322 tperp = sqrt(tperp*tperp + t*t);
329 const string &
getType()
const {
341 egsInformation(
"===================================================\n");
EGS_PrismT(T *P, const string &Name="")
Construct an open prism using P as the base polygon.
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 void printInfo() const
Print information about this geometry.
EGS_PrismT(T *P, EGS_Float D1, EGS_Float D2, const string &Name="")
Construct a closed prism using P as the base polygon.
A class representing 2D vectors.
A class representing 3D vectors.
bool open
Is the prism open ?
Global egspp functions header file.
virtual int isWhere(const EGS_Vector &x)=0
In which region is poisition x?
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_Vector a
The normal vector to the base plane.
EGS_2DPolygon and EGS_PolygonT class header file.
A class for modeling prisms.
bool isConvex() const
Is the geometry convex?
EGS_PrismT< EGS_PolygonYZ > EGS_PrismX
A prism with base in the X-plane.
virtual int inside(const EGS_Vector &x)=0
Returns the region index, if inside, or -1 if outside (obsolete)
EGS_InfoFunction EGS_EXPORT egsInformation
Always use this function for reporting the progress of a simulation and any other type of information...
EGS_PrismT< EGS_PolygonXZ > EGS_PrismY
A prism with base in the Y-plane.
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 boundaryTolerance
Boundary tolerance for geometries that need it.
EGS_PrismT< EGS_PolygonXY > EGS_PrismZ
A prism with base in the Z-plane.
EGS_PrismT< EGS_Polygon > EGS_Prism
A prism with base in an arbitrary plane.
~EGS_PrismT()
Desctructor, deletes the base polygon.
EGS_BaseGeometry class header file.
EGS_Float d2
Distance of the bottom plane to the base (for closed prisms)