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