Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/glutess/_tess is written in an unsupported language. File is not indexed.

0001 // see license file for original license.
0002 
0003 #ifndef tools_glutess__tess
0004 #define tools_glutess__tess
0005 
0006 #include "mesh"
0007 #include "dict"
0008 #include "priorityq"
0009 
0010 #include <csetjmp>
0011 
0012 /* The begin/end calls must be properly nested.  We keep track of
0013  * the current state to enforce the ordering.
0014  */
0015 enum TessState { T_DORMANT, T_IN_POLYGON, T_IN_CONTOUR };
0016 
0017 /* We cache vertex data for single-contour polygons so that we can
0018  * try a quick-and-dirty decomposition first.
0019  */
0020 #define GLU_TESS_MAX_CACHE 100
0021 
0022 typedef struct CachedVertex {
0023   GLUdouble     coords[3];
0024   void          *data;
0025 } CachedVertex;
0026 
0027 struct GLUtesselator {
0028 
0029   /*** state needed for collecting the input data ***/
0030 
0031   enum TessState state;         /* what begin/end calls have we seen? */
0032 
0033   GLUhalfEdge   *lastEdge;      /* lastEdge->Org is the most recent vertex */
0034   GLUmesh       *mesh;          /* stores the input contours, and eventually
0035                                    the tessellation itself */
0036 
0037   void          (GLUAPIENTRY *callError)( GLUenum errnum );
0038 
0039   /*** state needed for projecting onto the sweep plane ***/
0040 
0041   GLUdouble     normal[3];      /* user-specified normal (if provided) */
0042   GLUdouble     sUnit[3];       /* unit vector in s-direction (debugging) */
0043   GLUdouble     tUnit[3];       /* unit vector in t-direction (debugging) */
0044 
0045   /*** state needed for the line sweep ***/
0046 
0047   GLUdouble     relTolerance;   /* tolerance for merging features */
0048   GLUenum       windingRule;    /* rule for determining polygon interior */
0049   GLUboolean    fatalError;     /* fatal error: needed combine callback */
0050 
0051   Dict          *dict;          /* edge dictionary for sweep line */
0052   PriorityQ     *pq;            /* priority queue of vertex events */
0053   GLUvertex     *event;         /* current sweep event being processed */
0054 
0055   void          (GLUAPIENTRY *callCombine)( GLUdouble coords[3], void *data[4],
0056                                 GLUfloat weight[4], void **outData );
0057 
0058   /*** state needed for rendering callbacks (see render.c) ***/
0059 
0060   GLUboolean    flagBoundary;   /* mark boundary edges (use EdgeFlag) */
0061   GLUboolean    boundaryOnly;   /* Extract contours, not triangles */
0062   GLUface       *lonelyTriList;
0063     /* list of triangles which could not be rendered as strips or fans */
0064 
0065   void          (GLUAPIENTRY *callBegin)( GLUenum type );
0066   void          (GLUAPIENTRY *callEdgeFlag)( GLUboolean boundaryEdge );
0067   void          (GLUAPIENTRY *callVertex)( void *data );
0068   void          (GLUAPIENTRY *callEnd)( void );
0069   void          (GLUAPIENTRY *callMesh)( GLUmesh *mesh );
0070 
0071 
0072   /*** state needed to cache single-contour polygons for renderCache() */
0073 
0074   GLUboolean    emptyCache;             /* empty cache on next vertex() call */
0075   int           cacheCount;             /* number of cached vertices */
0076   CachedVertex  cache[GLU_TESS_MAX_CACHE];      /* the vertex data */
0077 
0078   /*** rendering callbacks that also pass polygon data  ***/ 
0079   void          (GLUAPIENTRY *callBeginData)( GLUenum type, void *polygonData );
0080   void          (GLUAPIENTRY *callEdgeFlagData)( GLUboolean boundaryEdge, 
0081                                      void *polygonData );
0082   void          (GLUAPIENTRY *callVertexData)( void *data, void *polygonData );
0083   void          (GLUAPIENTRY *callEndData)( void *polygonData );
0084   void          (GLUAPIENTRY *callErrorData)( GLUenum errnum, void *polygonData );
0085   void          (GLUAPIENTRY *callCombineData)( GLUdouble coords[3], void *data[4],
0086                                     GLUfloat weight[4], void **outData,
0087                                     void *polygonData );
0088 
0089   jmp_buf env;                  /* place to jump to when memAllocs fail */
0090 
0091   void *polygonData;            /* client data for current polygon */
0092 };
0093 
0094 void GLUAPIENTRY __gl_noBeginData( GLUenum type, void *polygonData );
0095 void GLUAPIENTRY __gl_noEdgeFlagData( GLUboolean boundaryEdge, void *polygonData );
0096 void GLUAPIENTRY __gl_noVertexData( void *data, void *polygonData );
0097 void GLUAPIENTRY __gl_noEndData( void *polygonData );
0098 void GLUAPIENTRY __gl_noErrorData( GLUenum errnum, void *polygonData );
0099 void GLUAPIENTRY __gl_noCombineData( GLUdouble coords[3], void *data[4],
0100                          GLUfloat weight[4], void **outData,
0101                          void *polygonData );
0102 
0103 #define CALL_BEGIN_OR_BEGIN_DATA(a) \
0104    if (tess->callBeginData != &__gl_noBeginData) \
0105       (*tess->callBeginData)((a),tess->polygonData); \
0106    else (*tess->callBegin)((a));
0107 
0108 #define CALL_VERTEX_OR_VERTEX_DATA(a) \
0109    if (tess->callVertexData != &__gl_noVertexData) \
0110       (*tess->callVertexData)((a),tess->polygonData); \
0111    else (*tess->callVertex)((a));
0112 
0113 #define CALL_EDGE_FLAG_OR_EDGE_FLAG_DATA(a) \
0114    if (tess->callEdgeFlagData != &__gl_noEdgeFlagData) \
0115       (*tess->callEdgeFlagData)((a),tess->polygonData); \
0116    else (*tess->callEdgeFlag)((a));
0117 
0118 #define CALL_END_OR_END_DATA() \
0119    if (tess->callEndData != &__gl_noEndData) \
0120       (*tess->callEndData)(tess->polygonData); \
0121    else (*tess->callEnd)();
0122 
0123 #define CALL_COMBINE_OR_COMBINE_DATA(a,b,c,d) \
0124    if (tess->callCombineData != &__gl_noCombineData) \
0125       (*tess->callCombineData)((a),(b),(c),(d),tess->polygonData); \
0126    else (*tess->callCombine)((a),(b),(c),(d));
0127 
0128 #define CALL_ERROR_OR_ERROR_DATA(a) \
0129    if (tess->callErrorData != &__gl_noErrorData) \
0130       (*tess->callErrorData)((a),tess->polygonData); \
0131    else (*tess->callError)((a));
0132 
0133 #endif