46 #ifdef BUILD_PYRAMID_DLL
47 #define EGS_PYRAMID_EXPORT __declspec(dllexport)
49 #define EGS_PYRAMID_EXPORT __declspec(dllimport)
51 #define EGS_PYRAMID_LOCAL
55 #ifdef HAVE_VISIBILITY
56 #define EGS_PYRAMID_EXPORT __attribute__ ((visibility ("default")))
57 #define EGS_PYRAMID_LOCAL __attribute__ ((visibility ("hidden")))
59 #define EGS_PYRAMID_EXPORT
60 #define EGS_PYRAMID_LOCAL
155 for (
int j=0; j<n; j++) {
163 EGS_Float axp = a*xp;
168 if (!open && d + axp < 0) {
171 EGS_Float t = -d/axp;
173 return p->isInside2D(p->getProjection(xo + t*xp));
189 EGS_Float &t,
int *newmed = 0,
EGS_Vector *normal = 0) {
192 int convex = p->isConvex();
193 for (
int j=0; j<n; j++) {
194 if (convex || s[j]->isInside2D(x)) {
196 if (s[j]->
howfar(
true,x,u,t)) {
202 if (p->howfar(
true,x,u,t)) {
212 if (normal) *normal = jhit < n ? s[jhit]->getNormal() :
216 for (
int j=0; j<n; j++) {
218 EGS_Float up = u*s[j]->getNormal(), xp = s[j]->distance(x);
219 if (up > 0 && xp < 0) {
220 EGS_Float tt = -xp/up;
221 if (tt <= t+boundaryTolerance && s[j]->isInside2D(x+u*tt)) {
228 EGS_Float up = u*p->getNormal(), xp = p->distance(x);
229 if (up > 0 && xp < 0) {
230 EGS_Float tt = -xp/up;
231 if (tt <= t+boundaryTolerance && p->isInside2D(x+u*tt)) {
243 if (normal) *normal = jhit < n ? s[jhit]->getNormal()*(-1) :
251 for (
int j=0; j<n; j++) {
252 EGS_Float t = s[j]->hownear(
true,x);
261 EGS_Float t = p->hownear(
true,x);
269 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?
bool open
is the pyramid open ?
virtual void printInfo() const
Print information about this geometry.
A class representing 2D vectors.
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.
EGS_Vector a
the base normal vector.
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
EGS_2DPolygon and EGS_PolygonT class header file.
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_2DVector xop
the tip projection on the base polygon
A template class for 3D polygons.
EGS_Float d
distance from tip to base polygon (always positive)
A template class for modeling pyramids.
EGS_BaseGeometry class header file.
EGS_Vector xo
the tip of the pyramid