Synchronize with trunk's revision r57629.
[reactos.git] / dll / opengl / glu32 / src / libnurbs / internals / nurbstess.h
1 /*
2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 *
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
29 */
30
31 /*
32 * nurbstess.h
33 *
34 */
35
36 #ifndef __glunurbstess_h_
37 #define __glunurbstess_h_
38
39 #include "mysetjmp.h"
40 #include "subdivider.h"
41 #include "renderhints.h"
42 #include "backend.h"
43 #include "maplist.h"
44 #include "reader.h"
45 #include "nurbsconsts.h"
46
47 struct Knotvector;
48 class Quilt;
49 class DisplayList;
50 class BasicCurveEvaluator;
51 class BasicSurfaceEvaluator;
52
53 class NurbsTessellator {
54 public:
55 NurbsTessellator( BasicCurveEvaluator &c,
56 BasicSurfaceEvaluator &e );
57 virtual ~NurbsTessellator( void );
58
59 void getnurbsproperty( long, INREAL * );
60 void getnurbsproperty( long, long, INREAL * );
61 void setnurbsproperty( long, INREAL );
62 void setnurbsproperty( long, long, INREAL );
63 void setnurbsproperty( long, long, INREAL * );
64 void setnurbsproperty( long, long, INREAL *, long, long );
65
66 // called before a tessellation begins/ends
67 virtual void bgnrender( void );
68 virtual void endrender( void );
69
70 // called to make a display list of the output vertices
71 virtual void makeobj( int n );
72 virtual void closeobj( void );
73
74 // called when a error occurs
75 virtual void errorHandler( int );
76
77 void bgnsurface( long );
78 void endsurface( void );
79 void bgntrim( void );
80 void endtrim( void );
81 void bgncurve( long );
82 void endcurve( void );
83 void pwlcurve( long, INREAL[], long, long );
84 void nurbscurve( long, INREAL[], long, INREAL[], long, long );
85 void nurbssurface( long, INREAL[], long, INREAL[], long, long,
86 INREAL[], long, long, long );
87
88 void defineMap( long, long, long );
89 void redefineMaps( void );
90
91 // recording of input description
92 void discardRecording( void * );
93 void * beginRecording( void );
94 void endRecording( void );
95 void playRecording( void * );
96
97 //for optimizing untrimmed nurbs in the case of domain distance sampling
98 void set_domain_distance_u_rate(REAL u_rate);
99 void set_domain_distance_v_rate(REAL v_rate);
100 void set_is_domain_distance_sampling(int flag);
101
102
103 protected:
104 Renderhints renderhints;
105 Maplist maplist;
106 Backend backend;
107
108 private:
109
110 void resetObjects( void );
111 int do_check_knots( Knotvector *, const char * );
112 void do_nurbserror( int );
113 void do_bgncurve( O_curve * );
114 void do_endcurve( void );
115 void do_freeall( void );
116 void do_freecurveall( O_curve * );
117 void do_freebgntrim( O_trim * );
118 void do_freebgncurve( O_curve * );
119 void do_freepwlcurve( O_pwlcurve * );
120 void do_freenurbscurve( O_nurbscurve * );
121 void do_freenurbssurface( O_nurbssurface * );
122 void do_freebgnsurface( O_surface * );
123 void do_bgnsurface( O_surface * );
124 void do_endsurface( void );
125 void do_bgntrim( O_trim * );
126 void do_endtrim( void );
127 void do_pwlcurve( O_pwlcurve * );
128 void do_nurbscurve( O_nurbscurve * );
129 void do_nurbssurface( O_nurbssurface * );
130 void do_freenurbsproperty( Property * );
131 void do_setnurbsproperty( Property * );
132 void do_setnurbsproperty2( Property * );
133
134 Subdivider subdivider;
135 JumpBuffer* jumpbuffer;
136 Pool o_pwlcurvePool;
137 Pool o_nurbscurvePool;
138 Pool o_curvePool;
139 Pool o_trimPool;
140 Pool o_surfacePool;
141 Pool o_nurbssurfacePool;
142 Pool propertyPool;
143 public:
144 Pool quiltPool;
145 private:
146 TrimVertexPool extTrimVertexPool;
147
148 int inSurface; /* bgnsurface seen */
149 int inCurve; /* bgncurve seen */
150 int inTrim; /* bgntrim seen */
151 int isCurveModified; /* curve changed */
152 int isTrimModified; /* trim curves changed */
153 int isSurfaceModified; /* surface changed */
154 int isDataValid; /* all data is good */
155 int numTrims; /* valid trim regions */
156 int playBack;
157
158 O_trim** nextTrim; /* place to link o_trim */
159 O_curve** nextCurve; /* place to link o_curve */
160 O_nurbscurve** nextNurbscurve; /* place to link o_nurbscurve */
161 O_pwlcurve** nextPwlcurve; /* place to link o_pwlcurve */
162 O_nurbssurface** nextNurbssurface; /* place to link o_nurbssurface */
163
164 O_surface* currentSurface;
165 O_trim* currentTrim;
166 O_curve* currentCurve;
167
168 DisplayList *dl;
169
170 };
171
172 #endif /* __glunurbstess_h_ */