Geant4 Cross Reference |
1 // see license file for original license. 2 3 #ifndef tools_glutess__tess 4 #define tools_glutess__tess 5 6 #include "mesh" 7 #include "dict" 8 #include "priorityq" 9 10 #include <csetjmp> 11 12 /* The begin/end calls must be properly nested 13 * the current state to enforce the ordering. 14 */ 15 enum TessState { T_DORMANT, T_IN_POLYGON, T_IN 16 17 /* We cache vertex data for single-contour pol 18 * try a quick-and-dirty decomposition first. 19 */ 20 #define GLU_TESS_MAX_CACHE 100 21 22 typedef struct CachedVertex { 23 GLUdouble coords[3]; 24 void *data; 25 } CachedVertex; 26 27 struct GLUtesselator { 28 29 /*** state needed for collecting the input d 30 31 enum TessState state; /* what begin/end ca 32 33 GLUhalfEdge *lastEdge; /* lastEdge->Org is 34 GLUmesh *mesh; /* stores the input contou 35 the tessell 36 37 void (GLUAPIENTRY *callError)( GLUenum er 38 39 /*** state needed for projecting onto the sw 40 41 GLUdouble normal[3]; /* user-specified norm 42 GLUdouble sUnit[3]; /* unit vector in s-dire 43 GLUdouble tUnit[3]; /* unit vector in t-dire 44 45 /*** state needed for the line sweep ***/ 46 47 GLUdouble relTolerance; /* tolerance for mer 48 GLUenum windingRule; /* rule for determinin 49 GLUboolean fatalError; /* fatal error: need 50 51 Dict *dict; /* edge dictionary for swe 52 PriorityQ *pq; /* priority queue of verte 53 GLUvertex *event; /* current sweep event b 54 55 void (GLUAPIENTRY *callCombine)( GLUdoubl 56 GLUfloat weight[4], void **outDa 57 58 /*** state needed for rendering callbacks (s 59 60 GLUboolean flagBoundary; /* mark boundary e 61 GLUboolean boundaryOnly; /* Extract contour 62 GLUface *lonelyTriList; 63 /* list of triangles which could not be re 64 65 void (GLUAPIENTRY *callBegin)( GLUenum ty 66 void (GLUAPIENTRY *callEdgeFlag)( GLUbool 67 void (GLUAPIENTRY *callVertex)( void *dat 68 void (GLUAPIENTRY *callEnd)( void ); 69 void (GLUAPIENTRY *callMesh)( GLUmesh *me 70 71 72 /*** state needed to cache single-contour po 73 74 GLUboolean emptyCache; /* empty cache on 75 int cacheCount; /* number of cached vert 76 CachedVertex cache[GLU_TESS_MAX_CACHE]; /* 77 78 /*** rendering callbacks that also pass poly 79 void (GLUAPIENTRY *callBeginData)( GLUenu 80 void (GLUAPIENTRY *callEdgeFlagData)( GLU 81 void *polygonData ); 82 void (GLUAPIENTRY *callVertexData)( void 83 void (GLUAPIENTRY *callEndData)( void *po 84 void (GLUAPIENTRY *callErrorData)( GLUenu 85 void (GLUAPIENTRY *callCombineData)( GLUd 86 GLUfloat weight[4], void **outData 87 void *polygonData ); 88 89 jmp_buf env; /* place to jump to when m 90 91 void *polygonData; /* client data for cur 92 }; 93 94 void GLUAPIENTRY __gl_noBeginData( GLUenum typ 95 void GLUAPIENTRY __gl_noEdgeFlagData( GLUboole 96 void GLUAPIENTRY __gl_noVertexData( void *data 97 void GLUAPIENTRY __gl_noEndData( void *polygon 98 void GLUAPIENTRY __gl_noErrorData( GLUenum err 99 void GLUAPIENTRY __gl_noCombineData( GLUdouble 100 GLUfloat weight[4], void **outData, 101 void *polygonData ); 102 103 #define CALL_BEGIN_OR_BEGIN_DATA(a) \ 104 if (tess->callBeginData != &__gl_noBeginDat 105 (*tess->callBeginData)((a),tess->polygon 106 else (*tess->callBegin)((a)); 107 108 #define CALL_VERTEX_OR_VERTEX_DATA(a) \ 109 if (tess->callVertexData != &__gl_noVertexD 110 (*tess->callVertexData)((a),tess->polygo 111 else (*tess->callVertex)((a)); 112 113 #define CALL_EDGE_FLAG_OR_EDGE_FLAG_DATA(a) \ 114 if (tess->callEdgeFlagData != &__gl_noEdgeF 115 (*tess->callEdgeFlagData)((a),tess->poly 116 else (*tess->callEdgeFlag)((a)); 117 118 #define CALL_END_OR_END_DATA() \ 119 if (tess->callEndData != &__gl_noEndData) \ 120 (*tess->callEndData)(tess->polygonData); 121 else (*tess->callEnd)(); 122 123 #define CALL_COMBINE_OR_COMBINE_DATA(a,b,c,d) 124 if (tess->callCombineData != &__gl_noCombin 125 (*tess->callCombineData)((a),(b),(c),(d) 126 else (*tess->callCombine)((a),(b),(c),(d)); 127 128 #define CALL_ERROR_OR_ERROR_DATA(a) \ 129 if (tess->callErrorData != &__gl_noErrorDat 130 (*tess->callErrorData)((a),tess->polygon 131 else (*tess->callError)((a)); 132 133 #endif