2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
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:
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.
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
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.
36 #ifndef __glumapdesc_h_
37 #define __glumapdesc_h_
43 #include "nurbsconsts.h"
45 typedef REAL Maxmatrix[MAXCOORDS][MAXCOORDS];
49 class Mapdesc : public PooledObj {
53 Mapdesc( long, int, int, Backend & );
54 int isProperty( long );
55 REAL getProperty( long );
56 void setProperty( long, REAL );
57 int isConstantSampling( void );
58 int isDomainSampling( void );
59 int isRangeSampling( void );
60 int isSampling( void );
61 int isParametricDistanceSampling( void );
62 int isObjectSpaceParaSampling( void );
63 int isObjectSpacePathSampling( void );
64 int isSurfaceAreaSampling( void );
65 int isPathLengthSampling( void );
66 int isCulling( void );
67 int isBboxSubdividing( void );
71 void subdivide( REAL *, REAL *, REAL, int, int );
72 int cullCheck( REAL *, int, int );
73 void xformBounding( REAL *, int, int, REAL *, int );
74 void xformCulling( REAL *, int, int, REAL *, int );
75 void xformSampling( REAL *, int, int, REAL *, int );
76 void xformMat( Maxmatrix, REAL *, int, int, REAL *, int );
77 REAL calcPartialVelocity ( REAL *, int, int, int, REAL );
78 int project( REAL *, int, REAL *, int, int );
79 REAL calcVelocityRational( REAL *, int, int );
80 REAL calcVelocityNonrational( REAL *, int, int );
82 /* surface routines */
83 void subdivide( REAL *, REAL *, REAL, int, int, int, int );
84 int cullCheck( REAL *, int, int, int, int );
85 void xformBounding( REAL *, int, int, int, int, REAL *, int, int );
86 void xformCulling( REAL *, int, int, int, int, REAL *, int, int );
87 void xformSampling( REAL *, int, int, int, int, REAL *, int, int );
88 void xformMat( Maxmatrix, REAL *, int, int, int, int, REAL *, int, int );
89 REAL calcPartialVelocity ( REAL *, REAL *, int, int, int, int, int, int, REAL, REAL, int );
90 int project( REAL *, int, int, REAL *, int, int, int, int);
91 void surfbbox( REAL bb[2][MAXCOORDS] );
93 int bboxTooBig( REAL *, int, int, int, int, REAL [2][MAXCOORDS] );
94 int xformAndCullCheck( REAL *, int, int, int, int );
96 void identify( REAL[MAXCOORDS][MAXCOORDS] );
97 void setBboxsize( INREAL *);
98 inline void setBmat( INREAL*, long, long );
99 inline void setCmat( INREAL*, long, long );
100 inline void setSmat( INREAL*, long, long );
101 inline int isRational( void );
102 inline int getNcoords( void );
104 REAL pixel_tolerance; /* pathlength sampling tolerance */
105 REAL error_tolerance; /* parametric error sampling tolerance*/
106 REAL object_space_error_tolerance; /* object space tess*/
112 REAL bboxsize[MAXCOORDS];
124 REAL s_steps; /* max samples in s direction */
125 REAL t_steps; /* max samples in t direction */
126 REAL sampling_method;
127 REAL culling_method; /* check for culling */
128 REAL bbox_subdividing;
132 void bbox( REAL [2][MAXCOORDS], REAL *, int, int, int, int );
133 REAL maxDifference( int, REAL *, int );
134 static void copy( Maxmatrix, long, INREAL *, long, long );
136 /* individual control point routines */
137 static void transform4d( float[4], float[4], float[4][4] );
138 static void multmatrix4d ( float[4][4], const float[4][4],
140 void copyPt( REAL *, REAL * );
141 void sumPt( REAL *, REAL *, REAL *, REAL, REAL );
142 void xformSampling( REAL *, REAL * );
143 void xformCulling( REAL *, REAL * );
144 void xformRational( Maxmatrix, REAL *, REAL * );
145 void xformNonrational( Maxmatrix, REAL *, REAL * );
146 unsigned int clipbits( REAL * );
150 Mapdesc::setBmat( INREAL *mat, long rstride, long cstride )
152 copy( bmat, hcoords, mat, rstride, cstride );
156 Mapdesc::setCmat( INREAL *mat, long rstride, long cstride )
158 copy( cmat, hcoords, mat, rstride, cstride );
162 Mapdesc::setSmat( INREAL *mat, long rstride, long cstride )
164 copy( smat, hcoords, mat, rstride, cstride );
168 Mapdesc::getType( void )
174 Mapdesc::xformCulling( REAL *d, REAL *s )
177 xformRational( cmat, d, s );
179 xformNonrational( cmat, d, s );
183 Mapdesc::xformSampling( REAL *d, REAL *s )
186 xformRational( smat, d, s );
188 xformNonrational( smat, d, s );
192 Mapdesc::isRational( void )
194 return isrational ? 1 : 0;
198 Mapdesc::getNcoords( void )
204 Mapdesc::isConstantSampling( void )
206 return ((sampling_method == N_FIXEDRATE) ? 1 : 0);
210 Mapdesc::isDomainSampling( void )
212 return ((sampling_method == N_DOMAINDISTANCE) ? 1 : 0);
216 Mapdesc::isParametricDistanceSampling( void )
218 return ((sampling_method == N_PARAMETRICDISTANCE) ? 1 : 0);
222 Mapdesc::isObjectSpaceParaSampling( void )
224 return ((sampling_method == N_OBJECTSPACE_PARA) ? 1 : 0);
228 Mapdesc::isObjectSpacePathSampling( void )
230 return ((sampling_method == N_OBJECTSPACE_PATH) ? 1 : 0);
234 Mapdesc::isSurfaceAreaSampling( void )
236 return ((sampling_method == N_SURFACEAREA) ? 1 : 0);
240 Mapdesc::isPathLengthSampling( void )
242 return ((sampling_method == N_PATHLENGTH) ? 1 : 0);
246 Mapdesc::isRangeSampling( void )
248 return ( isParametricDistanceSampling() || isPathLengthSampling() ||
249 isSurfaceAreaSampling() ||
250 isObjectSpaceParaSampling() ||
251 isObjectSpacePathSampling());
255 Mapdesc::isSampling( void )
257 return isRangeSampling() || isConstantSampling() || isDomainSampling();
261 Mapdesc::isCulling( void )
263 return ((culling_method != N_NOCULLING) ? 1 : 0);
267 Mapdesc::isBboxSubdividing( void )
269 return ((bbox_subdividing != N_NOBBOXSUBDIVISION) ? 1 : 0);
271 #endif /* __glumapdesc_h_ */