2 ** License Applicability. Except to the extent portions of this file are
3 ** made subject to an alternative license as permitted in the SGI Free
4 ** Software License B, Version 1.1 (the "License"), the contents of this
5 ** file are subject only to the provisions of the License. You may not use
6 ** this file except in compliance with the License. You may obtain a copy
7 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
8 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
10 ** http://oss.sgi.com/projects/FreeB
12 ** Note that, as provided in the License, the Software is distributed on an
13 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
14 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
15 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
16 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
18 ** Original Code. The Original Code is: OpenGL Sample Implementation,
19 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
20 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
21 ** Copyright in any portions created by third parties is as indicated
22 ** elsewhere herein. All Rights Reserved.
24 ** Additional Notice Provisions: The application programming interfaces
25 ** established by SGI in conjunction with the Original Code are The
26 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
27 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
28 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
29 ** Window System(R) (Version 1.3), released October 19, 1998. This software
30 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
31 ** published by SGI, but has not been independently verified as being
32 ** compliant with the OpenGL(R) version 1.2.1 Specification.
36 ** Author: Eric Veach, July 1994.
38 ** $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
39 ** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libtess/tess.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
49 #include "priorityq.h"
51 /* The begin/end calls must be properly nested. We keep track of
52 * the current state to enforce the ordering.
54 enum TessState
{ T_DORMANT
, T_IN_POLYGON
, T_IN_CONTOUR
};
56 /* We cache vertex data for single-contour polygons so that we can
57 * try a quick-and-dirty decomposition first.
59 #define TESS_MAX_CACHE 100
61 typedef struct CachedVertex
{
66 struct GLUtesselator
{
68 /*** state needed for collecting the input data ***/
70 enum TessState state
; /* what begin/end calls have we seen? */
72 GLUhalfEdge
*lastEdge
; /* lastEdge->Org is the most recent vertex */
73 GLUmesh
*mesh
; /* stores the input contours, and eventually
74 the tessellation itself */
76 void (GLAPIENTRY
*callError
)( GLenum errnum
);
78 /*** state needed for projecting onto the sweep plane ***/
80 GLdouble normal
[3]; /* user-specified normal (if provided) */
81 GLdouble sUnit
[3]; /* unit vector in s-direction (debugging) */
82 GLdouble tUnit
[3]; /* unit vector in t-direction (debugging) */
84 /*** state needed for the line sweep ***/
86 GLdouble relTolerance
; /* tolerance for merging features */
87 GLenum windingRule
; /* rule for determining polygon interior */
88 GLboolean fatalError
; /* fatal error: needed combine callback */
90 Dict
*dict
; /* edge dictionary for sweep line */
91 PriorityQ
*pq
; /* priority queue of vertex events */
92 GLUvertex
*event
; /* current sweep event being processed */
94 void (GLAPIENTRY
*callCombine
)( GLdouble coords
[3], void *data
[4],
95 GLfloat weight
[4], void **outData
);
97 /*** state needed for rendering callbacks (see render.c) ***/
99 GLboolean flagBoundary
; /* mark boundary edges (use EdgeFlag) */
100 GLboolean boundaryOnly
; /* Extract contours, not triangles */
101 GLUface
*lonelyTriList
;
102 /* list of triangles which could not be rendered as strips or fans */
104 void (GLAPIENTRY
*callBegin
)( GLenum type
);
105 void (GLAPIENTRY
*callEdgeFlag
)( GLboolean boundaryEdge
);
106 void (GLAPIENTRY
*callVertex
)( void *data
);
107 void (GLAPIENTRY
*callEnd
)( void );
108 void (GLAPIENTRY
*callMesh
)( GLUmesh
*mesh
);
111 /*** state needed to cache single-contour polygons for renderCache() */
113 GLboolean emptyCache
; /* empty cache on next vertex() call */
114 int cacheCount
; /* number of cached vertices */
115 CachedVertex cache
[TESS_MAX_CACHE
]; /* the vertex data */
117 /*** rendering callbacks that also pass polygon data ***/
118 void (GLAPIENTRY
*callBeginData
)( GLenum type
, void *polygonData
);
119 void (GLAPIENTRY
*callEdgeFlagData
)( GLboolean boundaryEdge
,
121 void (GLAPIENTRY
*callVertexData
)( void *data
, void *polygonData
);
122 void (GLAPIENTRY
*callEndData
)( void *polygonData
);
123 void (GLAPIENTRY
*callErrorData
)( GLenum errnum
, void *polygonData
);
124 void (GLAPIENTRY
*callCombineData
)( GLdouble coords
[3], void *data
[4],
125 GLfloat weight
[4], void **outData
,
128 jmp_buf env
; /* place to jump to when memAllocs fail */
130 void *polygonData
; /* client data for current polygon */
133 void GLAPIENTRY
__gl_noBeginData( GLenum type
, void *polygonData
);
134 void GLAPIENTRY
__gl_noEdgeFlagData( GLboolean boundaryEdge
, void *polygonData
);
135 void GLAPIENTRY
__gl_noVertexData( void *data
, void *polygonData
);
136 void GLAPIENTRY
__gl_noEndData( void *polygonData
);
137 void GLAPIENTRY
__gl_noErrorData( GLenum errnum
, void *polygonData
);
138 void GLAPIENTRY
__gl_noCombineData( GLdouble coords
[3], void *data
[4],
139 GLfloat weight
[4], void **outData
,
142 #define CALL_BEGIN_OR_BEGIN_DATA(a) \
143 if (tess->callBeginData != &__gl_noBeginData) \
144 (*tess->callBeginData)((a),tess->polygonData); \
145 else (*tess->callBegin)((a));
147 #define CALL_VERTEX_OR_VERTEX_DATA(a) \
148 if (tess->callVertexData != &__gl_noVertexData) \
149 (*tess->callVertexData)((a),tess->polygonData); \
150 else (*tess->callVertex)((a));
152 #define CALL_EDGE_FLAG_OR_EDGE_FLAG_DATA(a) \
153 if (tess->callEdgeFlagData != &__gl_noEdgeFlagData) \
154 (*tess->callEdgeFlagData)((a),tess->polygonData); \
155 else (*tess->callEdgeFlag)((a));
157 #define CALL_END_OR_END_DATA() \
158 if (tess->callEndData != &__gl_noEndData) \
159 (*tess->callEndData)(tess->polygonData); \
160 else (*tess->callEnd)();
162 #define CALL_COMBINE_OR_COMBINE_DATA(a,b,c,d) \
163 if (tess->callCombineData != &__gl_noCombineData) \
164 (*tess->callCombineData)((a),(b),(c),(d),tess->polygonData); \
165 else (*tess->callCombine)((a),(b),(c),(d));
167 #define CALL_ERROR_OR_ERROR_DATA(a) \
168 if (tess->callErrorData != &__gl_noErrorData) \
169 (*tess->callErrorData)((a),tess->polygonData); \
170 else (*tess->callError)((a));