47 #define EGS_BOX_EXPORT __declspec(dllexport)
49 #define EGS_BOX_EXPORT __declspec(dllimport)
55 #ifdef HAVE_VISIBILITY
56 #define EGS_BOX_EXPORT __attribute__ ((visibility ("default")))
57 #define EGS_BOX_LOCAL __attribute__ ((visibility ("hidden")))
59 #define EGS_BOX_EXPORT
106 EGS_Float ax, ay, az;
114 ax(a), ay(a), az(a), T(0) {
121 EGS_Box(EGS_Float Ax, EGS_Float Ay, EGS_Float Az,
124 ax(Ax), ay(Ay), az(Az), T(0) {
139 if (2*xp.
x + ax < 0 || 2*xp.x - ax > 0) {
142 if (2*xp.
y + ay < 0 || 2*xp.y - ay > 0) {
145 if (2*xp.
z + az < 0 || 2*xp.z - az > 0) {
167 EGS_Float &t,
int *newmed=0,
EGS_Vector *normal=0) {
171 up = u*T->getRotation();
178 t1 = (ax - 2*xp.x)/(2*up.
x);
182 t1 = -(ax + 2*xp.x)/(2*up.
x);
191 t1 = (ay - 2*xp.y)/(2*up.
y);
194 t1 = -(ay + 2*xp.y)/(2*up.
y);
198 n.
y = up.
y > 0 ? -1 : 1;
204 t1 = (az - 2*xp.z)/(2*up.
z);
207 t1 = -(az + 2*xp.z)/(2*up.
z);
213 n.
z = up.
z > 0 ? -1 : 1;
221 *normal = T->getRotation()*n;
231 if (2*xp.x + ax < 0 && up.x > 0) {
232 t1 = -(2*xp.x + ax)/(2*up.
x);
234 else if (2*xp.x - ax > 0 && up.
x < 0) {
235 t1 = -(2*xp.x - ax)/(2*up.
x);
238 EGS_Float y1 = xp.y + up.
y*t1, z1 = xp.z + up.
z*t1;
239 if (2*y1 + ay > 0 && 2*y1 - ay < 0 &&
240 2*z1 + az > 0 && 2*z1 - az < 0) {
268 if (2*xp.y + ay < 0 && up.y > 0) {
269 t1 = -(2*xp.y + ay)/(2*up.
y);
271 else if (2*xp.y - ay > 0 && up.
y < 0) {
272 t1 = -(2*xp.y - ay)/(2*up.
y);
275 EGS_Float x1 = xp.x + up.
x*t1, z1 = xp.z + up.
z*t1;
276 if (2*x1 + ax > 0 && 2*x1 - ax < 0 &&
277 2*z1 + az > 0 && 2*z1 - az < 0) {
305 if (2*xp.z + az < 0 && up.z > 0) {
306 t1 = -(2*xp.z + az)/(2*up.
z);
308 else if (2*xp.z - az > 0 && up.
z < 0) {
309 t1 = -(2*xp.z - az)/(2*up.
z);
312 EGS_Float x1 = xp.x + up.
x*t1, y1 = xp.y + up.
y*t1;
313 if (2*x1 + ax > 0 && 2*x1 - ax < 0 &&
314 2*y1 + ay > 0 && 2*y1 - ay < 0) {
348 EGS_Float t1 = xp.
x + 0.5*ax, t2 = 0.5*ax - xp.
x;
373 EGS_Float s1=0, s2=0;
375 if (2*xp.
x + ax < 0) {
376 EGS_Float t = -0.5*ax - xp.
x;
381 else if (2*xp.
x - ax > 0) {
382 EGS_Float t = xp.
x - 0.5*ax;
387 if (2*xp.
y + ay < 0) {
388 EGS_Float t = -0.5*ay - xp.
y;
393 else if (2*xp.
y - ay > 0) {
394 EGS_Float t = xp.
y - 0.5*ay;
399 if (2*xp.
z + az < 0) {
400 EGS_Float t = -0.5*az - xp.
z;
405 else if (2*xp.
z - az > 0) {
406 EGS_Float t = xp.
z - 0.5*az;
417 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 void printInfo() const
Print information about this geometry.
virtual EGS_Float howfarToOutside(int ireg, const EGS_Vector &x, const EGS_Vector &u)
A class for vector rotations.
EGS_BaseGeometry(const string &Name)
Construct a geometry named Name.
A class representing 3D vectors.
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.
virtual int inside(const EGS_Vector &x)=0
Returns the region index, if inside, or -1 if outside (obsolete)
virtual EGS_Float hownear(int ireg, const EGS_Vector &x)=0
Calculate the distance to a boundary for position x in any direction.
EGS_BaseGeometry class header file.