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[ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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.  We keep track of
 13  * the current state to enforce the ordering.
 14  */
 15 enum TessState { T_DORMANT, T_IN_POLYGON, T_IN_CONTOUR };
 16 
 17 /* We cache vertex data for single-contour polygons so that we can
 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 data ***/
 30 
 31   enum TessState state;   /* what begin/end calls have we seen? */
 32 
 33   GLUhalfEdge *lastEdge;  /* lastEdge->Org is the most recent vertex */
 34   GLUmesh *mesh;    /* stores the input contours, and eventually
 35                                    the tessellation itself */
 36 
 37   void    (GLUAPIENTRY *callError)( GLUenum errnum );
 38 
 39   /*** state needed for projecting onto the sweep plane ***/
 40 
 41   GLUdouble normal[3];  /* user-specified normal (if provided) */
 42   GLUdouble sUnit[3]; /* unit vector in s-direction (debugging) */
 43   GLUdouble tUnit[3]; /* unit vector in t-direction (debugging) */
 44 
 45   /*** state needed for the line sweep ***/
 46 
 47   GLUdouble relTolerance; /* tolerance for merging features */
 48   GLUenum windingRule;  /* rule for determining polygon interior */
 49   GLUboolean  fatalError; /* fatal error: needed combine callback */
 50 
 51   Dict    *dict;    /* edge dictionary for sweep line */
 52   PriorityQ *pq;    /* priority queue of vertex events */
 53   GLUvertex *event;   /* current sweep event being processed */
 54 
 55   void    (GLUAPIENTRY *callCombine)( GLUdouble coords[3], void *data[4],
 56               GLUfloat weight[4], void **outData );
 57 
 58   /*** state needed for rendering callbacks (see render.c) ***/
 59 
 60   GLUboolean  flagBoundary; /* mark boundary edges (use EdgeFlag) */
 61   GLUboolean  boundaryOnly; /* Extract contours, not triangles */
 62   GLUface *lonelyTriList;
 63     /* list of triangles which could not be rendered as strips or fans */
 64 
 65   void    (GLUAPIENTRY *callBegin)( GLUenum type );
 66   void    (GLUAPIENTRY *callEdgeFlag)( GLUboolean boundaryEdge );
 67   void    (GLUAPIENTRY *callVertex)( void *data );
 68   void    (GLUAPIENTRY *callEnd)( void );
 69   void    (GLUAPIENTRY *callMesh)( GLUmesh *mesh );
 70 
 71 
 72   /*** state needed to cache single-contour polygons for renderCache() */
 73 
 74   GLUboolean  emptyCache;   /* empty cache on next vertex() call */
 75   int   cacheCount;   /* number of cached vertices */
 76   CachedVertex  cache[GLU_TESS_MAX_CACHE];  /* the vertex data */
 77 
 78   /*** rendering callbacks that also pass polygon data  ***/ 
 79   void    (GLUAPIENTRY *callBeginData)( GLUenum type, void *polygonData );
 80   void    (GLUAPIENTRY *callEdgeFlagData)( GLUboolean boundaryEdge, 
 81              void *polygonData );
 82   void    (GLUAPIENTRY *callVertexData)( void *data, void *polygonData );
 83   void    (GLUAPIENTRY *callEndData)( void *polygonData );
 84   void    (GLUAPIENTRY *callErrorData)( GLUenum errnum, void *polygonData );
 85   void    (GLUAPIENTRY *callCombineData)( GLUdouble coords[3], void *data[4],
 86             GLUfloat weight[4], void **outData,
 87             void *polygonData );
 88 
 89   jmp_buf env;      /* place to jump to when memAllocs fail */
 90 
 91   void *polygonData;    /* client data for current polygon */
 92 };
 93 
 94 void GLUAPIENTRY __gl_noBeginData( GLUenum type, void *polygonData );
 95 void GLUAPIENTRY __gl_noEdgeFlagData( GLUboolean boundaryEdge, void *polygonData );
 96 void GLUAPIENTRY __gl_noVertexData( void *data, void *polygonData );
 97 void GLUAPIENTRY __gl_noEndData( void *polygonData );
 98 void GLUAPIENTRY __gl_noErrorData( GLUenum errnum, void *polygonData );
 99 void GLUAPIENTRY __gl_noCombineData( GLUdouble coords[3], void *data[4],
100        GLUfloat weight[4], void **outData,
101        void *polygonData );
102 
103 #define CALL_BEGIN_OR_BEGIN_DATA(a) \
104    if (tess->callBeginData != &__gl_noBeginData) \
105       (*tess->callBeginData)((a),tess->polygonData); \
106    else (*tess->callBegin)((a));
107 
108 #define CALL_VERTEX_OR_VERTEX_DATA(a) \
109    if (tess->callVertexData != &__gl_noVertexData) \
110       (*tess->callVertexData)((a),tess->polygonData); \
111    else (*tess->callVertex)((a));
112 
113 #define CALL_EDGE_FLAG_OR_EDGE_FLAG_DATA(a) \
114    if (tess->callEdgeFlagData != &__gl_noEdgeFlagData) \
115       (*tess->callEdgeFlagData)((a),tess->polygonData); \
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_noCombineData) \
125       (*tess->callCombineData)((a),(b),(c),(d),tess->polygonData); \
126    else (*tess->callCombine)((a),(b),(c),(d));
127 
128 #define CALL_ERROR_OR_ERROR_DATA(a) \
129    if (tess->callErrorData != &__gl_noErrorData) \
130       (*tess->callErrorData)((a),tess->polygonData); \
131    else (*tess->callError)((a));
132 
133 #endif