ReactOS  0.4.15-dev-1150-g593bcce
tess.c File Reference
#include "gluos.h"
#include <assert.h>
#include "memalloc.h"
#include "tess.h"
#include "normal.h"
#include "sweep.h"
#include "tessmono.h"
#include "render.h"
Include dependency graph for tess.c:

Go to the source code of this file.

Classes

struct  EdgePair
 

Macros

#define GLU_TESS_DEFAULT_TOLERANCE   0.0
 
#define GLU_TESS_MESH   100112 /* void (*)(GLUmesh *mesh) */
 
#define TRUE   1
 
#define FALSE   0
 
#define MAX(a, b)   ((a) > (b) ? (a) : (b))
 
#define MAX_FAST_ALLOC
 
#define RequireState(tess, s)   if( tess->state != s ) GotoState(tess,s)
 

Functions

static void GLAPIENTRY noBegin (GLenum type)
 
static void GLAPIENTRY noEdgeFlag (GLboolean boundaryEdge)
 
static void GLAPIENTRY noVertex (void *data)
 
static void GLAPIENTRY noEnd (void)
 
static void GLAPIENTRY noError (GLenum errnum)
 
static void GLAPIENTRY noCombine (GLdouble coords[3], void *data[4], GLfloat weight[4], void **dataOut)
 
static void GLAPIENTRY noMesh (GLUmesh *mesh)
 
void GLAPIENTRY __gl_noBeginData (GLenum type, void *polygonData)
 
void GLAPIENTRY __gl_noEdgeFlagData (GLboolean boundaryEdge, void *polygonData)
 
void GLAPIENTRY __gl_noVertexData (void *data, void *polygonData)
 
void GLAPIENTRY __gl_noEndData (void *polygonData)
 
void GLAPIENTRY __gl_noErrorData (GLenum errnum, void *polygonData)
 
void GLAPIENTRY __gl_noCombineData (GLdouble coords[3], void *data[4], GLfloat weight[4], void **outData, void *polygonData)
 
GLUtesselator *GLAPIENTRY gluNewTess (void)
 
static void MakeDormant (GLUtesselator *tess)
 
static void GotoState (GLUtesselator *tess, enum TessState newState)
 
void GLAPIENTRY gluDeleteTess (GLUtesselator *tess)
 
void GLAPIENTRY gluTessProperty (GLUtesselator *tess, GLenum which, GLdouble value)
 
void GLAPIENTRY gluGetTessProperty (GLUtesselator *tess, GLenum which, GLdouble *value)
 
void GLAPIENTRY gluTessNormal (GLUtesselator *tess, GLdouble x, GLdouble y, GLdouble z)
 
void GLAPIENTRY gluTessCallback (GLUtesselator *tess, GLenum which, _GLUfuncptr fn)
 
static int AddVertex (GLUtesselator *tess, GLdouble coords[3], void *data)
 
static void CacheVertex (GLUtesselator *tess, GLdouble coords[3], void *data)
 
static int EmptyCache (GLUtesselator *tess)
 
void GLAPIENTRY gluTessVertex (GLUtesselator *tess, GLdouble coords[3], void *data)
 
void GLAPIENTRY gluTessBeginPolygon (GLUtesselator *tess, void *data)
 
void GLAPIENTRY gluTessBeginContour (GLUtesselator *tess)
 
void GLAPIENTRY gluTessEndContour (GLUtesselator *tess)
 
void GLAPIENTRY gluTessEndPolygon (GLUtesselator *tess)
 
void GLAPIENTRY gluBeginPolygon (GLUtesselator *tess)
 
void GLAPIENTRY gluNextContour (GLUtesselator *tess, GLenum type)
 
void GLAPIENTRY gluEndPolygon (GLUtesselator *tess)
 

Macro Definition Documentation

◆ FALSE

#define FALSE   0

Definition at line 54 of file tess.c.

◆ GLU_TESS_DEFAULT_TOLERANCE

#define GLU_TESS_DEFAULT_TOLERANCE   0.0

Definition at line 47 of file tess.c.

◆ GLU_TESS_MESH

#define GLU_TESS_MESH   100112 /* void (*)(GLUmesh *mesh) */

Definition at line 48 of file tess.c.

◆ MAX

#define MAX (   a,
  b 
)    ((a) > (b) ? (a) : (b))

Definition at line 86 of file tess.c.

◆ MAX_FAST_ALLOC

#define MAX_FAST_ALLOC
Value:
(MAX(sizeof(EdgePair), \
MAX(sizeof(GLUvertex),sizeof(GLUface))))
Definition: mesh.h:126
Definition: mesh.c:63
#define MAX(a, b)
Definition: tess.c:86

Definition at line 87 of file tess.c.

◆ RequireState

#define RequireState (   tess,
  s 
)    if( tess->state != s ) GotoState(tess,s)

Definition at line 152 of file tess.c.

◆ TRUE

#define TRUE   1

Definition at line 51 of file tess.c.

Function Documentation

◆ __gl_noBeginData()

void GLAPIENTRY __gl_noBeginData ( GLenum  type,
void polygonData 
)

Definition at line 67 of file tess.c.

68  {}

Referenced by gluNewTess(), gluTessCallback(), and gluTessEndPolygon().

◆ __gl_noCombineData()

void GLAPIENTRY __gl_noCombineData ( GLdouble  coords[3],
void data[4],
GLfloat  weight[4],
void **  outData,
void polygonData 
)

Definition at line 76 of file tess.c.

80  {}

Referenced by gluNewTess(), and gluTessCallback().

◆ __gl_noEdgeFlagData()

void GLAPIENTRY __gl_noEdgeFlagData ( GLboolean  boundaryEdge,
void polygonData 
)

Definition at line 69 of file tess.c.

70  {}

Referenced by gluNewTess(), gluTessCallback(), and gluTessEndPolygon().

◆ __gl_noEndData()

void GLAPIENTRY __gl_noEndData ( void polygonData)

Definition at line 73 of file tess.c.

73 {}

Referenced by gluNewTess(), gluTessCallback(), and gluTessEndPolygon().

◆ __gl_noErrorData()

void GLAPIENTRY __gl_noErrorData ( GLenum  errnum,
void polygonData 
)

Definition at line 74 of file tess.c.

75  {}

Referenced by gluNewTess(), and gluTessCallback().

◆ __gl_noVertexData()

void GLAPIENTRY __gl_noVertexData ( void data,
void polygonData 
)

Definition at line 71 of file tess.c.

72  {}

Referenced by gluNewTess(), gluTessCallback(), and gluTessEndPolygon().

◆ AddVertex()

static int AddVertex ( GLUtesselator tess,
GLdouble  coords[3],
void data 
)
static

Definition at line 345 of file tess.c.

346 {
347  GLUhalfEdge *e;
348 
349  e = tess->lastEdge;
350  if( e == NULL ) {
351  /* Make a self-loop (one vertex, one edge). */
352 
353  e = __gl_meshMakeEdge( tess->mesh );
354  if (e == NULL) return 0;
355  if ( !__gl_meshSplice( e, e->Sym ) ) return 0;
356  } else {
357  /* Create a new vertex and edge which immediately follow e
358  * in the ordering around the left face.
359  */
360  if (__gl_meshSplitEdge( e ) == NULL) return 0;
361  e = e->Lnext;
362  }
363 
364  /* The new vertex is now e->Org. */
365  e->Org->data = data;
366  e->Org->coords[0] = coords[0];
367  e->Org->coords[1] = coords[1];
368  e->Org->coords[2] = coords[2];
369 
370  /* The winding of an edge says how the winding number changes as we
371  * cross from the edge''s right face to its left face. We add the
372  * vertices in such an order that a CCW contour will add +1 to
373  * the winding number of the region inside the contour.
374  */
375  e->winding = 1;
376  e->Sym->winding = -1;
377 
378  tess->lastEdge = e;
379 
380  return 1;
381 }
GLuint coords
Definition: glext.h:7368
GLUhalfEdge * __gl_meshMakeEdge(GLUmesh *mesh)
Definition: mesh.c:275
#define e
Definition: ke_i.h:82
smooth NULL
Definition: ftsmooth.c:416
int __gl_meshSplice(GLUhalfEdge *eOrg, GLUhalfEdge *eDst)
Definition: mesh.c:328
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLUmesh * mesh
Definition: tess.h:66
GLUhalfEdge * lastEdge
Definition: tess.h:65
GLUhalfEdge * __gl_meshSplitEdge(GLUhalfEdge *eOrg)
Definition: mesh.c:475

Referenced by DECLARE_INTERFACE_(), EmptyCache(), and gluTessVertex().

◆ CacheVertex()

static void CacheVertex ( GLUtesselator tess,
GLdouble  coords[3],
void data 
)
static

Definition at line 384 of file tess.c.

385 {
386  CachedVertex *v = &tess->cache[tess->cacheCount];
387 
388  v->data = data;
389  v->coords[0] = coords[0];
390  v->coords[1] = coords[1];
391  v->coords[2] = coords[2];
392  ++tess->cacheCount;
393 }
void * data
Definition: tess.h:56
GLuint coords
Definition: glext.h:7368
CachedVertex cache[TESS_MAX_CACHE]
Definition: tess.h:108
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
const GLdouble * v
Definition: gl.h:2040
int cacheCount
Definition: tess.h:107

Referenced by gluTessVertex().

◆ EmptyCache()

static int EmptyCache ( GLUtesselator tess)
static

Definition at line 396 of file tess.c.

397 {
398  CachedVertex *v = tess->cache;
399  CachedVertex *vLast;
400 
401  tess->mesh = __gl_meshNewMesh();
402  if (tess->mesh == NULL) return 0;
403 
404  for( vLast = v + tess->cacheCount; v < vLast; ++v ) {
405  if ( !AddVertex( tess, v->coords, v->data ) ) return 0;
406  }
407  tess->cacheCount = 0;
408  tess->emptyCache = FALSE;
409 
410  return 1;
411 }
CachedVertex cache[TESS_MAX_CACHE]
Definition: tess.h:108
static int AddVertex(GLUtesselator *tess, GLdouble coords[3], void *data)
Definition: tess.c:345
GLboolean emptyCache
Definition: tess.h:106
smooth NULL
Definition: ftsmooth.c:416
GLUmesh * mesh
Definition: tess.h:66
GLUmesh * __gl_meshNewMesh(void)
Definition: mesh.c:603
const GLdouble * v
Definition: gl.h:2040
int cacheCount
Definition: tess.h:107
#define FALSE
Definition: tess.c:54

Referenced by gluTessEndPolygon(), and gluTessVertex().

◆ gluBeginPolygon()

void GLAPIENTRY gluBeginPolygon ( GLUtesselator tess)

Definition at line 611 of file tess.c.

612 {
613  gluTessBeginPolygon( tess, NULL );
614  gluTessBeginContour( tess );
615 }
void GLAPIENTRY gluTessBeginPolygon(GLUtesselator *tess, void *data)
Definition: tess.c:462
smooth NULL
Definition: ftsmooth.c:416
void GLAPIENTRY gluTessBeginContour(GLUtesselator *tess)
Definition: tess.c:476

◆ gluDeleteTess()

void GLAPIENTRY gluDeleteTess ( GLUtesselator tess)

Definition at line 193 of file tess.c.

194 {
195  RequireState( tess, T_DORMANT );
196  memFree( tess );
197 }
#define memFree
Definition: memalloc.h:41
Definition: tess.h:47
#define RequireState(tess, s)
Definition: tess.c:152

◆ gluEndPolygon()

void GLAPIENTRY gluEndPolygon ( GLUtesselator tess)

Definition at line 628 of file tess.c.

629 {
630  gluTessEndContour( tess );
631  gluTessEndPolygon( tess );
632 }
void GLAPIENTRY gluTessEndPolygon(GLUtesselator *tess)
Definition: tess.c:500
void GLAPIENTRY gluTessEndContour(GLUtesselator *tess)
Definition: tess.c:493

◆ gluGetTessProperty()

void GLAPIENTRY gluGetTessProperty ( GLUtesselator tess,
GLenum  which,
GLdouble value 
)

Definition at line 240 of file tess.c.

241 {
242  switch (which) {
243  case GLU_TESS_TOLERANCE:
244  /* tolerance should be in range [0..1] */
245  assert(0.0 <= tess->relTolerance && tess->relTolerance <= 1.0);
246  *value= tess->relTolerance;
247  break;
254  *value= tess->windingRule;
255  break;
257  assert(tess->boundaryOnly == TRUE || tess->boundaryOnly == FALSE);
258  *value= tess->boundaryOnly;
259  break;
260  default:
261  *value= 0.0;
263  break;
264  }
265 } /* gluGetTessProperty() */
#define GLU_TESS_BOUNDARY_ONLY
Definition: glu.h:240
static GLenum which
Definition: wgl_font.c:159
#define assert(x)
Definition: debug.h:53
#define CALL_ERROR_OR_ERROR_DATA(a)
Definition: tess.h:160
GLboolean boundaryOnly
Definition: tess.h:93
#define GLU_TESS_WINDING_POSITIVE
Definition: glu.h:262
#define TRUE
Definition: tess.c:51
GLenum windingRule
Definition: tess.h:80
#define GLU_TESS_WINDING_ODD
Definition: glu.h:260
#define GLU_TESS_WINDING_RULE
Definition: glu.h:239
#define GLU_INVALID_ENUM
Definition: glu.h:88
#define GLU_TESS_WINDING_NEGATIVE
Definition: glu.h:263
#define GLU_TESS_TOLERANCE
Definition: glu.h:241
#define GLU_TESS_WINDING_ABS_GEQ_TWO
Definition: glu.h:264
#define GLU_TESS_WINDING_NONZERO
Definition: glu.h:261
#define FALSE
Definition: tess.c:54
GLdouble relTolerance
Definition: tess.h:79

◆ gluNewTess()

GLUtesselator* GLAPIENTRY gluNewTess ( void  )

Definition at line 92 of file tess.c.

93 {
94  GLUtesselator *tess;
95 
96  /* Only initialize fields which can be changed by the api. Other fields
97  * are initialized where they are used.
98  */
99 
100  if (memInit( MAX_FAST_ALLOC ) == 0) {
101  return 0; /* out of memory */
102  }
103  tess = (GLUtesselator *)memAlloc( sizeof( GLUtesselator ));
104  if (tess == NULL) {
105  return 0; /* out of memory */
106  }
107 
108  tess->state = T_DORMANT;
109 
110  tess->normal[0] = 0;
111  tess->normal[1] = 0;
112  tess->normal[2] = 0;
113 
116  tess->flagBoundary = FALSE;
117  tess->boundaryOnly = FALSE;
118 
119  tess->callBegin = &noBegin;
120  tess->callEdgeFlag = &noEdgeFlag;
121  tess->callVertex = &noVertex;
122  tess->callEnd = &noEnd;
123 
124  tess->callError = &noError;
125  tess->callCombine = &noCombine;
126  tess->callMesh = &noMesh;
127 
128  tess->callBeginData= &__gl_noBeginData;
129  tess->callEdgeFlagData= &__gl_noEdgeFlagData;
130  tess->callVertexData= &__gl_noVertexData;
131  tess->callEndData= &__gl_noEndData;
132  tess->callErrorData= &__gl_noErrorData;
133  tess->callCombineData= &__gl_noCombineData;
134 
135  tess->polygonData= NULL;
136 
137  return tess;
138 }
GLboolean flagBoundary
Definition: tess.h:92
void GLAPIENTRY __gl_noEndData(void *polygonData)
Definition: tess.c:73
static void GLAPIENTRY noEdgeFlag(GLboolean boundaryEdge)
Definition: tess.c:58
static void GLAPIENTRY noVertex(void *data)
Definition: tess.c:59
void GLAPIENTRY __gl_noVertexData(void *data, void *polygonData)
Definition: tess.c:71
enum TessState state
Definition: tess.h:63
void GLAPIENTRY __gl_noCombineData(GLdouble coords[3], void *data[4], GLfloat weight[4], void **outData, void *polygonData)
Definition: tess.c:76
static void GLAPIENTRY noEnd(void)
Definition: tess.c:60
GLdouble normal[3]
Definition: tess.h:73
void GLAPIENTRY __gl_noEdgeFlagData(GLboolean boundaryEdge, void *polygonData)
Definition: tess.c:69
GLboolean boundaryOnly
Definition: tess.h:93
smooth NULL
Definition: ftsmooth.c:416
static void GLAPIENTRY noError(GLenum errnum)
Definition: tess.c:61
static void GLAPIENTRY noMesh(GLUmesh *mesh)
Definition: tess.c:64
void GLAPIENTRY __gl_noErrorData(GLenum errnum, void *polygonData)
Definition: tess.c:74
GLenum windingRule
Definition: tess.h:80
#define GLU_TESS_WINDING_ODD
Definition: glu.h:260
static void GLAPIENTRY noBegin(GLenum type)
Definition: tess.c:57
#define GLU_TESS_DEFAULT_TOLERANCE
Definition: tess.c:47
#define memInit
Definition: memalloc.h:43
static void GLAPIENTRY noCombine(GLdouble coords[3], void *data[4], GLfloat weight[4], void **dataOut)
Definition: tess.c:62
void GLAPIENTRY __gl_noBeginData(GLenum type, void *polygonData)
Definition: tess.c:67
void * polygonData
Definition: tess.h:111
#define MAX_FAST_ALLOC
Definition: tess.c:87
Definition: tess.h:47
#define FALSE
Definition: tess.c:54
#define memAlloc
Definition: memalloc.h:48
GLdouble relTolerance
Definition: tess.h:79

◆ gluNextContour()

void GLAPIENTRY gluNextContour ( GLUtesselator tess,
GLenum  type 
)

Definition at line 620 of file tess.c.

621 {
622  gluTessEndContour( tess );
623  gluTessBeginContour( tess );
624 }
void GLAPIENTRY gluTessEndContour(GLUtesselator *tess)
Definition: tess.c:493
void GLAPIENTRY gluTessBeginContour(GLUtesselator *tess)
Definition: tess.c:476

◆ gluTessBeginContour()

void GLAPIENTRY gluTessBeginContour ( GLUtesselator tess)

Definition at line 476 of file tess.c.

477 {
478  RequireState( tess, T_IN_POLYGON );
479 
480  tess->state = T_IN_CONTOUR;
481  tess->lastEdge = NULL;
482  if( tess->cacheCount > 0 ) {
483  /* Just set a flag so we don't get confused by empty contours
484  * -- these can be generated accidentally with the obsolete
485  * NextContour() interface.
486  */
487  tess->emptyCache = TRUE;
488  }
489 }
enum TessState state
Definition: tess.h:63
GLboolean emptyCache
Definition: tess.h:106
smooth NULL
Definition: ftsmooth.c:416
#define TRUE
Definition: tess.c:51
GLUhalfEdge * lastEdge
Definition: tess.h:65
int cacheCount
Definition: tess.h:107
#define RequireState(tess, s)
Definition: tess.c:152

Referenced by gluBeginPolygon(), gluNextContour(), and GotoState().

◆ gluTessBeginPolygon()

void GLAPIENTRY gluTessBeginPolygon ( GLUtesselator tess,
void data 
)

Definition at line 462 of file tess.c.

463 {
464  RequireState( tess, T_DORMANT );
465 
466  tess->state = T_IN_POLYGON;
467  tess->cacheCount = 0;
468  tess->emptyCache = FALSE;
469  tess->mesh = NULL;
470 
471  tess->polygonData= data;
472 }
enum TessState state
Definition: tess.h:63
GLboolean emptyCache
Definition: tess.h:106
smooth NULL
Definition: ftsmooth.c:416
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLUmesh * mesh
Definition: tess.h:66
void * polygonData
Definition: tess.h:111
Definition: tess.h:47
int cacheCount
Definition: tess.h:107
#define RequireState(tess, s)
Definition: tess.c:152
#define FALSE
Definition: tess.c:54

Referenced by gluBeginPolygon(), and GotoState().

◆ gluTessCallback()

void GLAPIENTRY gluTessCallback ( GLUtesselator tess,
GLenum  which,
_GLUfuncptr  fn 
)

Definition at line 276 of file tess.c.

277 {
278  switch( which ) {
279  case GLU_TESS_BEGIN:
280  tess->callBegin = (fn == NULL) ? &noBegin : (void (GLAPIENTRY *)(GLenum)) fn;
281  return;
282  case GLU_TESS_BEGIN_DATA:
283  tess->callBeginData = (fn == NULL) ?
284  &__gl_noBeginData : (void (GLAPIENTRY *)(GLenum, void *)) fn;
285  return;
286  case GLU_TESS_EDGE_FLAG:
287  tess->callEdgeFlag = (fn == NULL) ? &noEdgeFlag :
288  (void (GLAPIENTRY *)(GLboolean)) fn;
289  /* If the client wants boundary edges to be flagged,
290  * we render everything as separate triangles (no strips or fans).
291  */
292  tess->flagBoundary = (fn != NULL);
293  return;
295  tess->callEdgeFlagData= (fn == NULL) ?
296  &__gl_noEdgeFlagData : (void (GLAPIENTRY *)(GLboolean, void *)) fn;
297  /* If the client wants boundary edges to be flagged,
298  * we render everything as separate triangles (no strips or fans).
299  */
300  tess->flagBoundary = (fn != NULL);
301  return;
302  case GLU_TESS_VERTEX:
303  tess->callVertex = (fn == NULL) ? &noVertex :
304  (void (GLAPIENTRY *)(void *)) fn;
305  return;
307  tess->callVertexData = (fn == NULL) ?
308  &__gl_noVertexData : (void (GLAPIENTRY *)(void *, void *)) fn;
309  return;
310  case GLU_TESS_END:
311  tess->callEnd = (fn == NULL) ? &noEnd : (void (GLAPIENTRY *)(void)) fn;
312  return;
313  case GLU_TESS_END_DATA:
314  tess->callEndData = (fn == NULL) ? &__gl_noEndData :
315  (void (GLAPIENTRY *)(void *)) fn;
316  return;
317  case GLU_TESS_ERROR:
318  tess->callError = (fn == NULL) ? &noError : (void (GLAPIENTRY *)(GLenum)) fn;
319  return;
320  case GLU_TESS_ERROR_DATA:
321  tess->callErrorData = (fn == NULL) ?
322  &__gl_noErrorData : (void (GLAPIENTRY *)(GLenum, void *)) fn;
323  return;
324  case GLU_TESS_COMBINE:
325  tess->callCombine = (fn == NULL) ? &noCombine :
326  (void (GLAPIENTRY *)(GLdouble [3],void *[4], GLfloat [4], void ** )) fn;
327  return;
329  tess->callCombineData = (fn == NULL) ? &__gl_noCombineData :
330  (void (GLAPIENTRY *)(GLdouble [3],
331  void *[4],
332  GLfloat [4],
333  void **,
334  void *)) fn;
335  return;
336  case GLU_TESS_MESH:
337  tess->callMesh = (fn == NULL) ? &noMesh : (void (GLAPIENTRY *)(GLUmesh *)) fn;
338  return;
339  default:
341  return;
342  }
343 }
double GLdouble
Definition: gl.h:163
GLboolean flagBoundary
Definition: tess.h:92
void GLAPIENTRY __gl_noEndData(void *polygonData)
Definition: tess.c:73
Definition: mesh.h:163
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
static void GLAPIENTRY noEdgeFlag(GLboolean boundaryEdge)
Definition: tess.c:58
#define GLU_TESS_END_DATA
Definition: glu.h:226
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
static void GLAPIENTRY noVertex(void *data)
Definition: tess.c:59
static GLenum which
Definition: wgl_font.c:159
#define CALL_ERROR_OR_ERROR_DATA(a)
Definition: tess.h:160
void GLAPIENTRY __gl_noVertexData(void *data, void *polygonData)
Definition: tess.c:71
void GLAPIENTRY __gl_noCombineData(GLdouble coords[3], void *data[4], GLfloat weight[4], void **outData, void *polygonData)
Definition: tess.c:76
static void GLAPIENTRY noEnd(void)
Definition: tess.c:60
#define GLU_TESS_COMBINE
Definition: glu.h:223
unsigned char GLboolean
Definition: gl.h:151
void GLAPIENTRY __gl_noEdgeFlagData(GLboolean boundaryEdge, void *polygonData)
Definition: tess.c:69
smooth NULL
Definition: ftsmooth.c:416
static void GLAPIENTRY noError(GLenum errnum)
Definition: tess.c:61
static void GLAPIENTRY noMesh(GLUmesh *mesh)
Definition: tess.c:64
void GLAPIENTRY __gl_noErrorData(GLenum errnum, void *polygonData)
Definition: tess.c:74
#define GLU_TESS_VERTEX_DATA
Definition: glu.h:225
#define GLU_TESS_BEGIN_DATA
Definition: glu.h:224
#define GLU_TESS_ERROR_DATA
Definition: glu.h:227
unsigned int GLenum
Definition: gl.h:150
#define GLU_TESS_END
Definition: glu.h:218
static void GLAPIENTRY noBegin(GLenum type)
Definition: tess.c:57
#define GLU_TESS_COMBINE_DATA
Definition: glu.h:229
#define GLU_TESS_ERROR
Definition: glu.h:220
static void GLAPIENTRY noCombine(GLdouble coords[3], void *data[4], GLfloat weight[4], void **dataOut)
Definition: tess.c:62
void GLAPIENTRY __gl_noBeginData(GLenum type, void *polygonData)
Definition: tess.c:67
float GLfloat
Definition: gl.h:161
#define GLU_INVALID_ENUM
Definition: glu.h:88
#define GLU_TESS_BEGIN
Definition: glu.h:214
#define GLU_TESS_EDGE_FLAG_DATA
Definition: glu.h:228
#define GLU_TESS_MESH
Definition: tess.c:48
#define GLU_TESS_EDGE_FLAG
Definition: glu.h:221
#define GLU_TESS_VERTEX
Definition: glu.h:216
#define GLAPIENTRY
Definition: glu.h:44

◆ gluTessEndContour()

void GLAPIENTRY gluTessEndContour ( GLUtesselator tess)

Definition at line 493 of file tess.c.

494 {
495  RequireState( tess, T_IN_CONTOUR );
496  tess->state = T_IN_POLYGON;
497 }
enum TessState state
Definition: tess.h:63
#define RequireState(tess, s)
Definition: tess.c:152

Referenced by gluEndPolygon(), gluNextContour(), and GotoState().

◆ gluTessEndPolygon()

void GLAPIENTRY gluTessEndPolygon ( GLUtesselator tess)

Definition at line 500 of file tess.c.

501 {
502  GLUmesh *mesh;
503 
504  if (setjmp(tess->env) != 0) {
505  /* come back here if out of memory */
507  return;
508  }
509 
510  RequireState( tess, T_IN_POLYGON );
511  tess->state = T_DORMANT;
512 
513  if( tess->mesh == NULL ) {
514  if( ! tess->flagBoundary && tess->callMesh == &noMesh ) {
515 
516  /* Try some special code to make the easy cases go quickly
517  * (eg. convex polygons). This code does NOT handle multiple contours,
518  * intersections, edge flags, and of course it does not generate
519  * an explicit mesh either.
520  */
521  if( __gl_renderCache( tess )) {
522  tess->polygonData= NULL;
523  return;
524  }
525  }
526  if ( !EmptyCache( tess ) ) longjmp(tess->env,1); /* could've used a label*/
527  }
528 
529  /* Determine the polygon normal and project vertices onto the plane
530  * of the polygon.
531  */
532  __gl_projectPolygon( tess );
533 
534  /* __gl_computeInterior( tess ) computes the planar arrangement specified
535  * by the given contours, and further subdivides this arrangement
536  * into regions. Each region is marked "inside" if it belongs
537  * to the polygon, according to the rule given by tess->windingRule.
538  * Each interior region is guaranteed be monotone.
539  */
540  if ( !__gl_computeInterior( tess ) ) {
541  longjmp(tess->env,1); /* could've used a label */
542  }
543 
544  mesh = tess->mesh;
545  if( ! tess->fatalError ) {
546  int rc = 1;
547 
548  /* If the user wants only the boundary contours, we throw away all edges
549  * except those which separate the interior from the exterior.
550  * Otherwise we tessellate all the regions marked "inside".
551  */
552  if( tess->boundaryOnly ) {
553  rc = __gl_meshSetWindingNumber( mesh, 1, TRUE );
554  } else {
556  }
557  if (rc == 0) longjmp(tess->env,1); /* could've used a label */
558 
560 
561  if( tess->callBegin != &noBegin || tess->callEnd != &noEnd
562  || tess->callVertex != &noVertex || tess->callEdgeFlag != &noEdgeFlag
563  || tess->callBeginData != &__gl_noBeginData
564  || tess->callEndData != &__gl_noEndData
565  || tess->callVertexData != &__gl_noVertexData
566  || tess->callEdgeFlagData != &__gl_noEdgeFlagData )
567  {
568  if( tess->boundaryOnly ) {
569  __gl_renderBoundary( tess, mesh ); /* output boundary contours */
570  } else {
571  __gl_renderMesh( tess, mesh ); /* output strips and fans */
572  }
573  }
574  if( tess->callMesh != &noMesh ) {
575 
576  /* Throw away the exterior faces, so that all faces are interior.
577  * This way the user doesn't have to check the "inside" flag,
578  * and we don't need to even reveal its existence. It also leaves
579  * the freedom for an implementation to not generate the exterior
580  * faces in the first place.
581  */
583  (*tess->callMesh)( mesh ); /* user wants the mesh itself */
584  tess->mesh = NULL;
585  tess->polygonData= NULL;
586  return;
587  }
588  }
590  tess->polygonData= NULL;
591  tess->mesh = NULL;
592 }
GLboolean flagBoundary
Definition: tess.h:92
void GLAPIENTRY __gl_noEndData(void *polygonData)
Definition: tess.c:73
Definition: mesh.h:163
static void GLAPIENTRY noEdgeFlag(GLboolean boundaryEdge)
Definition: tess.c:58
static void GLAPIENTRY noVertex(void *data)
Definition: tess.c:59
int __gl_computeInterior(GLUtesselator *tess)
Definition: sweep.c:1301
GLboolean __gl_renderCache(GLUtesselator *tess)
Definition: render.c:441
#define CALL_ERROR_OR_ERROR_DATA(a)
Definition: tess.h:160
void GLAPIENTRY __gl_noVertexData(void *data, void *polygonData)
Definition: tess.c:71
enum TessState state
Definition: tess.h:63
#define GLU_OUT_OF_MEMORY
Definition: glu.h:90
Definition: mesh.c:197
void __gl_renderMesh(GLUtesselator *tess, GLUmesh *mesh)
Definition: render.c:82
void __gl_meshDeleteMesh(GLUmesh *mesh)
Definition: mesh.c:711
static void GLAPIENTRY noEnd(void)
Definition: tess.c:60
void __gl_meshDiscardExterior(GLUmesh *mesh)
Definition: tessmono.c:155
void GLAPIENTRY __gl_noEdgeFlagData(GLboolean boundaryEdge, void *polygonData)
Definition: tess.c:69
GLboolean boundaryOnly
Definition: tess.h:93
smooth NULL
Definition: ftsmooth.c:416
jmp_buf env
Definition: tess.h:121
int longjmp(jmp_buf buf, int retval)
GLboolean fatalError
Definition: tess.h:81
static void GLAPIENTRY noMesh(GLUmesh *mesh)
Definition: tess.c:64
int __gl_meshTessellateInterior(GLUmesh *mesh)
Definition: tessmono.c:133
#define TRUE
Definition: tess.c:51
GLUmesh * mesh
Definition: tess.h:66
static int EmptyCache(GLUtesselator *tess)
Definition: tess.c:396
static void GLAPIENTRY noBegin(GLenum type)
Definition: tess.c:57
#define setjmp
Definition: setjmp.h:183
void __gl_projectPolygon(GLUtesselator *tess)
Definition: normal.c:198
int __gl_meshSetWindingNumber(GLUmesh *mesh, int value, GLboolean keepOnlyBoundary)
Definition: tessmono.c:179
void GLAPIENTRY __gl_noBeginData(GLenum type, void *polygonData)
Definition: tess.c:67
void __gl_renderBoundary(GLUtesselator *tess, GLUmesh *mesh)
Definition: render.c:339
void * polygonData
Definition: tess.h:111
void __gl_meshCheckMesh(GLUmesh *mesh)
Definition: mesh.c:742
Definition: tess.h:47
#define RequireState(tess, s)
Definition: tess.c:152

Referenced by gluEndPolygon().

◆ gluTessNormal()

void GLAPIENTRY gluTessNormal ( GLUtesselator tess,
GLdouble  x,
GLdouble  y,
GLdouble  z 
)

Definition at line 268 of file tess.c.

269 {
270  tess->normal[0] = x;
271  tess->normal[1] = y;
272  tess->normal[2] = z;
273 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble normal[3]
Definition: tess.h:73
GLdouble GLdouble z
Definition: glext.h:5874
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

◆ gluTessProperty()

void GLAPIENTRY gluTessProperty ( GLUtesselator tess,
GLenum  which,
GLdouble  value 
)

Definition at line 201 of file tess.c.

202 {
203  GLenum windingRule;
204 
205  switch( which ) {
206  case GLU_TESS_TOLERANCE:
207  if( value < 0.0 || value > 1.0 ) break;
208  tess->relTolerance = value;
209  return;
210 
212  windingRule = (GLenum) value;
213  if( windingRule != value ) break; /* not an integer */
214 
215  switch( windingRule ) {
221  tess->windingRule = windingRule;
222  return;
223  default:
224  break;
225  }
226 
228  tess->boundaryOnly = (value != 0);
229  return;
230 
231  default:
233  return;
234  }
236 }
#define GLU_TESS_BOUNDARY_ONLY
Definition: glu.h:240
static GLenum which
Definition: wgl_font.c:159
#define CALL_ERROR_OR_ERROR_DATA(a)
Definition: tess.h:160
GLboolean boundaryOnly
Definition: tess.h:93
#define GLU_TESS_WINDING_POSITIVE
Definition: glu.h:262
GLenum windingRule
Definition: tess.h:80
unsigned int GLenum
Definition: gl.h:150
GLsizei const GLfloat * value
Definition: glext.h:6069
#define GLU_INVALID_VALUE
Definition: glu.h:89
#define GLU_TESS_WINDING_ODD
Definition: glu.h:260
#define GLU_TESS_WINDING_RULE
Definition: glu.h:239
#define GLU_INVALID_ENUM
Definition: glu.h:88
#define GLU_TESS_WINDING_NEGATIVE
Definition: glu.h:263
#define GLU_TESS_TOLERANCE
Definition: glu.h:241
#define GLU_TESS_WINDING_ABS_GEQ_TWO
Definition: glu.h:264
#define GLU_TESS_WINDING_NONZERO
Definition: glu.h:261
GLdouble relTolerance
Definition: tess.h:79

◆ gluTessVertex()

void GLAPIENTRY gluTessVertex ( GLUtesselator tess,
GLdouble  coords[3],
void data 
)

Definition at line 415 of file tess.c.

416 {
417  int i, tooLarge = FALSE;
418  GLdouble x, clamped[3];
419 
420  RequireState( tess, T_IN_CONTOUR );
421 
422  if( tess->emptyCache ) {
423  if ( !EmptyCache( tess ) ) {
425  return;
426  }
427  tess->lastEdge = NULL;
428  }
429  for( i = 0; i < 3; ++i ) {
430  x = coords[i];
431  if( x < - GLU_TESS_MAX_COORD ) {
432  x = - GLU_TESS_MAX_COORD;
433  tooLarge = TRUE;
434  }
435  if( x > GLU_TESS_MAX_COORD ) {
437  tooLarge = TRUE;
438  }
439  clamped[i] = x;
440  }
441  if( tooLarge ) {
443  }
444 
445  if( tess->mesh == NULL ) {
446  if( tess->cacheCount < TESS_MAX_CACHE ) {
447  CacheVertex( tess, clamped, data );
448  return;
449  }
450  if ( !EmptyCache( tess ) ) {
452  return;
453  }
454  }
455  if ( !AddVertex( tess, clamped, data ) ) {
457  }
458 }
double GLdouble
Definition: gl.h:163
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define CALL_ERROR_OR_ERROR_DATA(a)
Definition: tess.h:160
#define GLU_OUT_OF_MEMORY
Definition: glu.h:90
GLuint coords
Definition: glext.h:7368
static int AddVertex(GLUtesselator *tess, GLdouble coords[3], void *data)
Definition: tess.c:345
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLboolean emptyCache
Definition: tess.h:106
smooth NULL
Definition: ftsmooth.c:416
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define TRUE
Definition: tess.c:51
GLUmesh * mesh
Definition: tess.h:66
static int EmptyCache(GLUtesselator *tess)
Definition: tess.c:396
#define GLU_TESS_COORD_TOO_LARGE
Definition: glu.h:256
GLUhalfEdge * lastEdge
Definition: tess.h:65
#define TESS_MAX_CACHE
Definition: tess.h:52
static void CacheVertex(GLUtesselator *tess, GLdouble coords[3], void *data)
Definition: tess.c:384
#define GLU_TESS_MAX_COORD
Definition: glu.h:284
int cacheCount
Definition: tess.h:107
#define RequireState(tess, s)
Definition: tess.c:152
#define FALSE
Definition: tess.c:54

◆ GotoState()

static void GotoState ( GLUtesselator tess,
enum TessState  newState 
)
static

Definition at line 154 of file tess.c.

155 {
156  while( tess->state != newState ) {
157  /* We change the current state one level at a time, to get to
158  * the desired state.
159  */
160  if( tess->state < newState ) {
161  switch( tess->state ) {
162  case T_DORMANT:
164  gluTessBeginPolygon( tess, NULL );
165  break;
166  case T_IN_POLYGON:
168  gluTessBeginContour( tess );
169  break;
170  default:
171  ;
172  }
173  } else {
174  switch( tess->state ) {
175  case T_IN_CONTOUR:
177  gluTessEndContour( tess );
178  break;
179  case T_IN_POLYGON:
181  /* gluTessEndPolygon( tess ) is too much work! */
182  MakeDormant( tess );
183  break;
184  default:
185  ;
186  }
187  }
188  }
189 }
void GLAPIENTRY gluTessBeginPolygon(GLUtesselator *tess, void *data)
Definition: tess.c:462
#define CALL_ERROR_OR_ERROR_DATA(a)
Definition: tess.h:160
enum TessState state
Definition: tess.h:63
#define GLU_TESS_MISSING_END_POLYGON
Definition: glu.h:254
#define GLU_TESS_MISSING_END_CONTOUR
Definition: glu.h:255
smooth NULL
Definition: ftsmooth.c:416
void GLAPIENTRY gluTessEndContour(GLUtesselator *tess)
Definition: tess.c:493
static void MakeDormant(GLUtesselator *tess)
Definition: tess.c:140
#define GLU_TESS_MISSING_BEGIN_POLYGON
Definition: glu.h:252
#define GLU_TESS_MISSING_BEGIN_CONTOUR
Definition: glu.h:253
void GLAPIENTRY gluTessBeginContour(GLUtesselator *tess)
Definition: tess.c:476
Definition: tess.h:47

◆ MakeDormant()

static void MakeDormant ( GLUtesselator tess)
static

Definition at line 140 of file tess.c.

141 {
142  /* Return the tessellator to its original dormant state. */
143 
144  if( tess->mesh != NULL ) {
145  __gl_meshDeleteMesh( tess->mesh );
146  }
147  tess->state = T_DORMANT;
148  tess->lastEdge = NULL;
149  tess->mesh = NULL;
150 }
enum TessState state
Definition: tess.h:63
void __gl_meshDeleteMesh(GLUmesh *mesh)
Definition: mesh.c:711
smooth NULL
Definition: ftsmooth.c:416
GLUmesh * mesh
Definition: tess.h:66
GLUhalfEdge * lastEdge
Definition: tess.h:65
Definition: tess.h:47

Referenced by GotoState().

◆ noBegin()

static void GLAPIENTRY noBegin ( GLenum  type)
static

Definition at line 57 of file tess.c.

57 {}

Referenced by gluNewTess(), gluTessCallback(), and gluTessEndPolygon().

◆ noCombine()

static void GLAPIENTRY noCombine ( GLdouble  coords[3],
void data[4],
GLfloat  weight[4],
void **  dataOut 
)
static

Definition at line 62 of file tess.c.

63  {}

Referenced by gluNewTess(), and gluTessCallback().

◆ noEdgeFlag()

static void GLAPIENTRY noEdgeFlag ( GLboolean  boundaryEdge)
static

Definition at line 58 of file tess.c.

58 {}

Referenced by gluNewTess(), gluTessCallback(), and gluTessEndPolygon().

◆ noEnd()

static void GLAPIENTRY noEnd ( void  )
static

Definition at line 60 of file tess.c.

60 {}

Referenced by gluNewTess(), gluTessCallback(), and gluTessEndPolygon().

◆ noError()

static void GLAPIENTRY noError ( GLenum  errnum)
static

Definition at line 61 of file tess.c.

61 {}

Referenced by gluNewTess(), and gluTessCallback().

◆ noMesh()

static void GLAPIENTRY noMesh ( GLUmesh mesh)
static

Definition at line 64 of file tess.c.

64 {}

Referenced by gluNewTess(), gluTessCallback(), and gluTessEndPolygon().

◆ noVertex()

static void GLAPIENTRY noVertex ( void data)
static

Definition at line 59 of file tess.c.

59 {}

Referenced by gluNewTess(), gluTessCallback(), and gluTessEndPolygon().