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