OSDN Git Service

3c4ef6ff6ce7a259b4fba4977d9e6c4c816da988
[android-x86/external-mesa.git] / src / glu / sgi / libnurbs / internals / mapdesc.h
1 /*
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:
9 **
10 ** http://oss.sgi.com/projects/FreeB
11 **
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.
17 **
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.
23 **
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.
33 */
34
35 /*
36  * mapdesc.h
37  *
38  * $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
39  * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/mapdesc.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
40  */
41
42 #ifndef __glumapdesc_h_
43 #define __glumapdesc_h_
44
45 #include "mystdio.h"
46 #include "types.h"
47 #include "defines.h"
48 #include "bufpool.h"
49 #include "nurbsconsts.h"
50
51 typedef REAL Maxmatrix[MAXCOORDS][MAXCOORDS];
52
53 class Backend;
54
55 class Mapdesc : public PooledObj {
56     friend class Maplist;
57                         
58 public:
59                         Mapdesc( long, int, int, Backend & );
60     int                 isProperty( long );
61     REAL                getProperty( long );
62     void                setProperty( long, REAL );
63     int                 isConstantSampling( void );
64     int                 isDomainSampling( void );
65     int                 isRangeSampling( void );
66     int                 isSampling( void );
67     int                 isParametricDistanceSampling( void );
68     int                 isObjectSpaceParaSampling( void );
69     int                 isObjectSpacePathSampling( void );
70     int                 isSurfaceAreaSampling( void );
71     int                 isPathLengthSampling( void );
72     int                 isCulling( void );
73     int                 isBboxSubdividing( void );
74     long                getType( void );
75
76     /* curve routines */
77     void                subdivide( REAL *, REAL *, REAL, int, int );
78     int                 cullCheck( REAL *, int, int );
79     void                xformBounding( REAL *, int, int, REAL *, int );
80     void                xformCulling( REAL *, int, int, REAL *, int );
81     void                xformSampling( REAL *, int, int, REAL *, int );
82     void                xformMat( Maxmatrix, REAL *, int, int, REAL *, int );
83     REAL                calcPartialVelocity ( REAL *, int, int, int, REAL );
84     int                 project( REAL *, int, REAL *, int, int );
85     REAL                calcVelocityRational( REAL *, int, int );
86     REAL                calcVelocityNonrational( REAL *, int, int );
87
88     /* surface routines */
89     void                subdivide( REAL *, REAL *, REAL, int, int, int, int );
90     int                 cullCheck( REAL *, int, int, int, int );
91     void                xformBounding( REAL *, int, int, int, int, REAL *, int, int );
92     void                xformCulling( REAL *, int, int, int, int, REAL *, int, int );
93     void                xformSampling( REAL *, int, int, int, int, REAL *, int, int );
94     void                xformMat( Maxmatrix, REAL *, int, int, int, int, REAL *, int, int );
95     REAL                calcPartialVelocity ( REAL *, REAL *, int, int, int, int, int, int, REAL, REAL, int );
96     int                 project( REAL *, int, int, REAL *, int, int, int, int);
97     void                surfbbox( REAL bb[2][MAXCOORDS] );
98
99     int                 bboxTooBig( REAL *, int, int, int, int, REAL [2][MAXCOORDS] );
100     int                 xformAndCullCheck( REAL *, int, int, int, int );
101
102     void                identify( REAL[MAXCOORDS][MAXCOORDS] );
103     void                setBboxsize( INREAL *);
104     inline void         setBmat( INREAL*, long, long );
105     inline void         setCmat( INREAL*, long, long );
106     inline void         setSmat( INREAL*, long, long );
107     inline int          isRational( void );
108     inline int          getNcoords( void );
109
110     REAL                pixel_tolerance;    /* pathlength sampling tolerance */
111     REAL                error_tolerance;    /* parametric error sampling tolerance*/
112     REAL                object_space_error_tolerance;    /* object space tess*/
113     REAL                clampfactor;
114     REAL                minsavings;
115     REAL                maxrate;
116     REAL                maxsrate;
117     REAL                maxtrate;
118     REAL                bboxsize[MAXCOORDS];
119
120 private:
121     long                type;
122     int                 isrational;
123     int                 ncoords;
124     int                 hcoords;
125     int                 inhcoords;
126     int                 mask;
127     Maxmatrix           bmat;
128     Maxmatrix           cmat;
129     Maxmatrix           smat;
130     REAL                s_steps;                /* max samples in s direction */
131     REAL                t_steps;                /* max samples in t direction */
132     REAL                sampling_method;        
133     REAL                culling_method;         /* check for culling */
134     REAL                bbox_subdividing;
135     Mapdesc *           next;
136     Backend &           backend;
137
138     void                bbox( REAL [2][MAXCOORDS], REAL *, int, int, int, int );
139     REAL                maxDifference( int, REAL *, int );
140     static void         copy( Maxmatrix, long, INREAL *, long, long );
141
142     /* individual control point routines */
143     static void         transform4d( float[4], float[4], float[4][4] );
144     static void         multmatrix4d ( float[4][4], const float[4][4],
145                                          const float[4][4] );
146     void                copyPt( REAL *, REAL * );
147     void                sumPt( REAL *, REAL *, REAL *, REAL, REAL );
148     void                xformSampling( REAL *, REAL * );
149     void                xformCulling( REAL *, REAL * );
150     void                xformRational( Maxmatrix, REAL *, REAL * );
151     void                xformNonrational( Maxmatrix, REAL *, REAL * );
152     unsigned int        clipbits( REAL * );
153 };
154
155 inline void
156 Mapdesc::setBmat( INREAL *mat, long rstride, long cstride )
157 {
158     copy( bmat, hcoords, mat, rstride, cstride );
159 }
160
161 inline void
162 Mapdesc::setCmat( INREAL *mat, long rstride, long cstride )
163 {
164     copy( cmat, hcoords, mat, rstride, cstride );
165 }
166
167 inline void
168 Mapdesc::setSmat( INREAL *mat, long rstride, long cstride )
169 {
170     copy( smat, hcoords, mat, rstride, cstride );
171 }
172
173 inline long
174 Mapdesc::getType( void )
175 {
176     return type;
177 }
178
179 inline void
180 Mapdesc::xformCulling( REAL *d, REAL *s )
181 {
182     if( isrational )
183         xformRational( cmat, d, s );
184     else
185         xformNonrational( cmat, d, s );
186 }
187
188 inline void
189 Mapdesc::xformSampling( REAL *d, REAL *s )
190 {
191     if( isrational )
192         xformRational( smat, d, s );
193     else
194         xformNonrational( smat, d, s );
195 }
196
197 inline int 
198 Mapdesc::isRational( void )
199 {
200     return isrational ? 1 : 0;
201 }
202
203 inline int              
204 Mapdesc::getNcoords( void ) 
205 {
206     return ncoords; 
207 }
208
209 inline int                      
210 Mapdesc::isConstantSampling( void ) 
211 {
212     return ((sampling_method == N_FIXEDRATE) ? 1 : 0); 
213 }
214
215 inline int                      
216 Mapdesc::isDomainSampling( void ) 
217
218     return ((sampling_method == N_DOMAINDISTANCE) ? 1 : 0); 
219 }
220
221 inline int                      
222 Mapdesc::isParametricDistanceSampling( void ) 
223 {
224     return ((sampling_method == N_PARAMETRICDISTANCE) ? 1 : 0);
225 }
226
227 inline int                      
228 Mapdesc::isObjectSpaceParaSampling( void ) 
229 {
230     return ((sampling_method == N_OBJECTSPACE_PARA) ? 1 : 0);
231 }
232
233 inline int                      
234 Mapdesc::isObjectSpacePathSampling( void ) 
235 {
236     return ((sampling_method == N_OBJECTSPACE_PATH) ? 1 : 0);
237 }
238
239 inline int                      
240 Mapdesc::isSurfaceAreaSampling( void ) 
241 {
242     return ((sampling_method == N_SURFACEAREA) ? 1 : 0);
243 }
244
245 inline int                      
246 Mapdesc::isPathLengthSampling( void ) 
247 {
248     return ((sampling_method == N_PATHLENGTH) ? 1 : 0);
249 }
250
251 inline int                      
252 Mapdesc::isRangeSampling( void ) 
253 {
254     return ( isParametricDistanceSampling() || isPathLengthSampling() ||
255             isSurfaceAreaSampling() ||
256             isObjectSpaceParaSampling() ||
257             isObjectSpacePathSampling());
258 }
259
260 inline int
261 Mapdesc::isSampling( void )
262 {
263     return isRangeSampling() || isConstantSampling() || isDomainSampling();
264 }
265
266 inline int                      
267 Mapdesc::isCulling( void ) 
268 {
269     return ((culling_method != N_NOCULLING) ? 1 : 0);
270 }
271
272 inline int                      
273 Mapdesc::isBboxSubdividing( void ) 
274 {
275     return ((bbox_subdividing != N_NOBBOXSUBDIVISION) ? 1 : 0);
276 }
277 #endif /* __glumapdesc_h_ */