2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Contributor(s): Tao Ju
20 * ***** END GPL LICENSE BLOCK *****
23 #ifndef __PROJECTIONS_H__
24 #define __PROJECTIONS_H__
29 #define CONTAINS_INDEX
30 #define GRID_DIMENSION 20
32 #if defined(_WIN32) && !(_MSC_VER >= 1900)
33 #define isnan(n) _isnan(n)
35 #define int64_t __int64
41 * Structures and classes for computing projections of triangles onto
42 * separating axes during scan conversion
47 extern const int vertmap[8][3];
48 extern const int centmap[3][3][3][2];
49 extern const int edgemap[12][2];
50 extern const int facemap[6][4];
53 * 0, 1, 2: cube face normals
59 * 10, 11, 12: cross of each triangle edge vector with each cube
65 * Structure for the projections inheritable from parent
67 struct TriangleProjection {
68 /// Projections of triangle (min and max)
69 int64_t tri_proj[NUM_AXES][2];
71 /// Normal of the triangle
78 /* This is a projection for the cube against a single projection
79 axis, see CubeTriangleIsect.cubeProj */
80 struct CubeProjection {
88 * Class for projections of cube / triangle vertices on the separating axes
90 class CubeTriangleIsect
93 /// Inheritable portion
94 TriangleProjection *inherit;
96 /// Projections of the cube vertices
97 CubeProjection cubeProj[NUM_AXES];
100 CubeTriangleIsect() {}
103 * Construction from a cube (axes aligned) and triangle
105 CubeTriangleIsect(int64_t cube[2][3], int64_t trig[3][3], int64_t error, int triind);
108 * Construction from a parent CubeTriangleIsect object and the index of
111 CubeTriangleIsect(CubeTriangleIsect *parent);
113 unsigned char getBoxMask( );
116 * Shifting a cube to a new origin
118 void shift(int off[3]);
121 * Method to test intersection of the triangle and the cube
123 int isIntersecting() const;
125 int isIntersectingPrimary(int edgeInd) const;
127 float getIntersectionPrimary(int edgeInd) const;
129 #ifdef WITH_CXX_GUARDEDALLOC
130 MEM_CXX_CLASS_ALLOC_FUNCS("DUALCON:CubeTriangleIsect")
135 #endif /* __PROJECTIONS_H__ */