source: trunk/src/opengl/glu/nurbs/internals/patch.cpp

Last change on this file was 2689, checked in by jeroen, 26 years ago

* empty log message *

File size: 19.8 KB
Line 
1/* $Id: patch.cpp,v 1.1 2000-02-09 08:50:27 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 * patch.c++
38 *
39 * $Date: 2000-02-09 08:50:27 $ $Revision: 1.1 $
40 * $Header: /home/ktk/tmp/odin/2007/netlabs.cvs/odin32/src/opengl/glu/nurbs/internals/patch.cpp,v 1.1 2000-02-09 08:50:27 jeroen Exp $
41 */
42
43#include <stdio.h>
44#include "glimports.h"
45#include "mystdio.h"
46#include "myassert.h"
47#include "mymath.h"
48#include "mystring.h"
49#include "patch.h"
50#include "mapdesc.h"
51#include "quilt.h"
52#include "nurbsconsts.h"
53#include "simplemath.h" //for abs function in ::singleStep();
54
55
56/*--------------------------------------------------------------------------
57 * Patch - copy patch from quilt and transform control points
58 *--------------------------------------------------------------------------
59 */
60
61Patch::Patch( Quilt_ptr geo, REAL *pta, REAL *ptb, Patch *n )
62{
63/* pspec[i].range is uninit here */
64 mapdesc = geo->mapdesc;
65 cullval = mapdesc->isCulling() ? CULL_ACCEPT : CULL_TRIVIAL_ACCEPT;
66 notInBbox = mapdesc->isBboxSubdividing() ? 1 : 0;
67 needsSampling = mapdesc->isRangeSampling() ? 1 : 0;
68 pspec[0].order = geo->qspec[0].order;
69 pspec[1].order = geo->qspec[1].order;
70 pspec[0].stride = pspec[1].order * MAXCOORDS;
71 pspec[1].stride = MAXCOORDS;
72
73 /* transform control points to sampling and culling spaces */
74 REAL *ps = geo->cpts;
75 geo->select( pta, ptb );
76 ps += geo->qspec[0].offset;
77 ps += geo->qspec[1].offset;
78 ps += geo->qspec[0].index * geo->qspec[0].order * geo->qspec[0].stride;
79 ps += geo->qspec[1].index * geo->qspec[1].order * geo->qspec[1].stride;
80
81 if( needsSampling ) {
82 mapdesc->xformSampling( ps, geo->qspec[0].order, geo->qspec[0].stride,
83 geo->qspec[1].order, geo->qspec[1].stride,
84 spts, pspec[0].stride, pspec[1].stride );
85 }
86
87 if( cullval == CULL_ACCEPT ) {
88 mapdesc->xformCulling( ps, geo->qspec[0].order, geo->qspec[0].stride,
89 geo->qspec[1].order, geo->qspec[1].stride,
90 cpts, pspec[0].stride, pspec[1].stride );
91 }
92
93 if( notInBbox ) {
94 mapdesc->xformBounding( ps, geo->qspec[0].order, geo->qspec[0].stride,
95 geo->qspec[1].order, geo->qspec[1].stride,
96 bpts, pspec[0].stride, pspec[1].stride );
97 }
98
99 /* set scale range */
100 pspec[0].range[0] = geo->qspec[0].breakpoints[geo->qspec[0].index];
101 pspec[0].range[1] = geo->qspec[0].breakpoints[geo->qspec[0].index+1];
102 pspec[0].range[2] = pspec[0].range[1] - pspec[0].range[0];
103
104 pspec[1].range[0] = geo->qspec[1].breakpoints[geo->qspec[1].index];
105 pspec[1].range[1] = geo->qspec[1].breakpoints[geo->qspec[1].index+1];
106 pspec[1].range[2] = pspec[1].range[1] - pspec[1].range[0];
107
108 // may need to subdivide to match range of sub-patch
109 if( pspec[0].range[0] != pta[0] ) {
110 assert( pspec[0].range[0] < pta[0] );
111 Patch lower( *this, 0, pta[0], 0 );
112 *this = lower;
113 }
114
115 if( pspec[0].range[1] != ptb[0] ) {
116 assert( pspec[0].range[1] > ptb[0] );
117 Patch upper( *this, 0, ptb[0], 0 );
118 }
119
120 if( pspec[1].range[0] != pta[1] ) {
121 assert( pspec[1].range[0] < pta[1] );
122 Patch lower( *this, 1, pta[1], 0 );
123 *this = lower;
124 }
125
126 if( pspec[1].range[1] != ptb[1] ) {
127 assert( pspec[1].range[1] > ptb[1] );
128 Patch upper( *this, 1, ptb[1], 0 );
129 }
130 checkBboxConstraint();
131 next = n;
132}
133
134/*--------------------------------------------------------------------------
135 * Patch - subdivide a patch along an isoparametric line
136 *--------------------------------------------------------------------------
137 */
138
139Patch::Patch( Patch& upper, int param, REAL value, Patch *n )
140{
141 Patch& lower = *this;
142
143 lower.cullval = upper.cullval;
144 lower.mapdesc = upper.mapdesc;
145 lower.notInBbox = upper.notInBbox;
146 lower.needsSampling = upper.needsSampling;
147 lower.pspec[0].order = upper.pspec[0].order;
148 lower.pspec[1].order = upper.pspec[1].order;
149 lower.pspec[0].stride = upper.pspec[0].stride;
150 lower.pspec[1].stride = upper.pspec[1].stride;
151 lower.next = n;
152
153 /* reset scale range */
154 switch( param ) {
155 case 0: {
156 REAL d = (value-upper.pspec[0].range[0]) / upper.pspec[0].range[2];
157 if( needsSampling )
158 mapdesc->subdivide( upper.spts, lower.spts, d, pspec[1].order,
159 pspec[1].stride, pspec[0].order, pspec[0].stride );
160
161 if( cullval == CULL_ACCEPT )
162 mapdesc->subdivide( upper.cpts, lower.cpts, d, pspec[1].order,
163 pspec[1].stride, pspec[0].order, pspec[0].stride );
164
165 if( notInBbox )
166 mapdesc->subdivide( upper.bpts, lower.bpts, d, pspec[1].order,
167 pspec[1].stride, pspec[0].order, pspec[0].stride );
168
169 lower.pspec[0].range[0] = upper.pspec[0].range[0];
170 lower.pspec[0].range[1] = value;
171 lower.pspec[0].range[2] = value - upper.pspec[0].range[0];
172 upper.pspec[0].range[0] = value;
173 upper.pspec[0].range[2] = upper.pspec[0].range[1] - value;
174
175 lower.pspec[1].range[0] = upper.pspec[1].range[0];
176 lower.pspec[1].range[1] = upper.pspec[1].range[1];
177 lower.pspec[1].range[2] = upper.pspec[1].range[2];
178 break;
179 }
180 case 1: {
181 REAL d = (value-upper.pspec[1].range[0]) / upper.pspec[1].range[2];
182 if( needsSampling )
183 mapdesc->subdivide( upper.spts, lower.spts, d, pspec[0].order,
184 pspec[0].stride, pspec[1].order, pspec[1].stride );
185 if( cullval == CULL_ACCEPT )
186 mapdesc->subdivide( upper.cpts, lower.cpts, d, pspec[0].order,
187 pspec[0].stride, pspec[1].order, pspec[1].stride );
188 if( notInBbox )
189 mapdesc->subdivide( upper.bpts, lower.bpts, d, pspec[0].order,
190 pspec[0].stride, pspec[1].order, pspec[1].stride );
191 lower.pspec[0].range[0] = upper.pspec[0].range[0];
192 lower.pspec[0].range[1] = upper.pspec[0].range[1];
193 lower.pspec[0].range[2] = upper.pspec[0].range[2];
194
195 lower.pspec[1].range[0] = upper.pspec[1].range[0];
196 lower.pspec[1].range[1] = value;
197 lower.pspec[1].range[2] = value - upper.pspec[1].range[0];
198 upper.pspec[1].range[0] = value;
199 upper.pspec[1].range[2] = upper.pspec[1].range[1] - value;
200 break;
201 }
202 }
203
204 // inherit bounding box
205 if( mapdesc->isBboxSubdividing() && ! notInBbox )
206 memcpy( lower.bb, upper.bb, sizeof( bb ) );
207
208 lower.checkBboxConstraint();
209 upper.checkBboxConstraint();
210}
211
212/*--------------------------------------------------------------------------
213 * clamp - clamp the sampling rate to a given maximum
214 *--------------------------------------------------------------------------
215 */
216
217void
218Patch::clamp( void )
219{
220 if( mapdesc->clampfactor != N_NOCLAMPING ) {
221 pspec[0].clamp( mapdesc->clampfactor );
222 pspec[1].clamp( mapdesc->clampfactor );
223 }
224}
225
226void
227Patchspec::clamp( REAL clampfactor )
228{
229 if( sidestep[0] < minstepsize )
230 sidestep[0] = clampfactor * minstepsize;
231 if( sidestep[1] < minstepsize )
232 sidestep[1] = clampfactor * minstepsize;
233 if( stepsize < minstepsize )
234 stepsize = clampfactor * minstepsize;
235}
236
237void
238Patch::checkBboxConstraint( void )
239{
240 if( notInBbox &&
241 mapdesc->bboxTooBig( bpts, pspec[0].stride, pspec[1].stride,
242 pspec[0].order, pspec[1].order, bb ) != 1 ) {
243 notInBbox = 0;
244 }
245}
246
247void
248Patch::bbox( void )
249{
250 if( mapdesc->isBboxSubdividing() )
251 mapdesc->surfbbox( bb );
252}
253
254/*--------------------------------------------------------------------------
255 * getstepsize - compute the sampling density across the patch
256 * and determine if patch needs to be subdivided
257 *--------------------------------------------------------------------------
258 */
259
260void
261Patch::getstepsize( void )
262{
263 pspec[0].minstepsize = pspec[1].minstepsize = 0;
264 pspec[0].needsSubdivision = pspec[1].needsSubdivision = 0;
265
266 if( mapdesc->isConstantSampling() ) {
267 // fixed number of samples per patch in each direction
268 // maxsrate is number of s samples per patch
269 // maxtrate is number of t samples per patch
270 pspec[0].getstepsize( mapdesc->maxsrate );
271 pspec[1].getstepsize( mapdesc->maxtrate );
272
273 } else if( mapdesc->isDomainSampling() ) {
274 // maxsrate is number of s samples per unit s length of domain
275 // maxtrate is number of t samples per unit t length of domain
276 pspec[0].getstepsize( mapdesc->maxsrate * pspec[0].range[2] );
277 pspec[1].getstepsize( mapdesc->maxtrate * pspec[1].range[2] );
278
279 } else if( ! needsSampling ) {
280 pspec[0].singleStep();
281 pspec[1].singleStep();
282 } else {
283 // upper bound on path length between sample points
284 REAL tmp[MAXORDER][MAXORDER][MAXCOORDS];
285 const int trstride = sizeof(tmp[0]) / sizeof(REAL);
286 const int tcstride = sizeof(tmp[0][0]) / sizeof(REAL);
287
288 assert( pspec[0].order <= MAXORDER );
289
290 /* points have been transformed, therefore they are homogeneous */
291
292 int val = mapdesc->project( spts, pspec[0].stride, pspec[1].stride,
293 &tmp[0][0][0], trstride, tcstride,
294 pspec[0].order, pspec[1].order );
295 if( val == 0 ) {
296 // control points cross infinity, therefore partials are undefined
297 pspec[0].getstepsize( mapdesc->maxsrate );
298 pspec[1].getstepsize( mapdesc->maxtrate );
299 } else {
300 REAL t1 = mapdesc->getProperty( N_PIXEL_TOLERANCE );
301// REAL t2 = mapdesc->getProperty( N_ERROR_TOLERANCE );
302 pspec[0].minstepsize = ( mapdesc->maxsrate > 0.0 ) ?
303 (pspec[0].range[2] / mapdesc->maxsrate) : 0.0;
304 pspec[1].minstepsize = ( mapdesc->maxtrate > 0.0 ) ?
305 (pspec[1].range[2] / mapdesc->maxtrate) : 0.0;
306 if( mapdesc->isParametricDistanceSampling() ||
307 mapdesc->isObjectSpaceParaSampling() ) {
308
309 REAL t2;
310 t2 = mapdesc->getProperty( N_ERROR_TOLERANCE );
311
312 // t2 is upper bound on the distance between surface and tessellant
313 REAL ssv[2], ttv[2];
314 REAL ss = mapdesc->calcPartialVelocity( ssv, &tmp[0][0][0], trstride, tcstride, pspec[0].order, pspec[1].order, 2, 0, pspec[0].range[2], pspec[1].range[2], 0 );
315 REAL st = mapdesc->calcPartialVelocity( 0, &tmp[0][0][0], trstride, tcstride, pspec[0].order, pspec[1].order, 1, 1, pspec[0].range[2], pspec[1].range[2], -1 );
316 REAL tt = mapdesc->calcPartialVelocity( ttv, &tmp[0][0][0], trstride, tcstride, pspec[0].order, pspec[1].order, 0, 2, pspec[0].range[2], pspec[1].range[2], 1 );
317 //make sure that ss st and tt are nonnegative:
318 if(ss <0) ss = -ss;
319 if(st <0) st = -st;
320 if(tt <0) tt = -tt;
321
322 if( ss != 0.0 && tt != 0.0 ) {
323 /* printf( "ssv[0] %g ssv[1] %g ttv[0] %g ttv[1] %g\n",
324 ssv[0], ssv[1], ttv[0], ttv[1] ); */
325 REAL ttq = ::sqrtf( (float) ss );
326 REAL ssq = ::sqrtf( (float) tt );
327 REAL ds = ::sqrtf( 4 * t2 * ttq / ( ss * ttq + st * ssq ) );
328 REAL dt = ::sqrtf( 4 * t2 * ssq / ( tt * ssq + st * ttq ) );
329 pspec[0].stepsize = ( ds < pspec[0].range[2] ) ? ds : pspec[0].range[2];
330 REAL scutoff = 2.0 * t2 / ( pspec[0].range[2] * pspec[0].range[2]);
331 pspec[0].sidestep[0] = (ssv[0] > scutoff) ? ::sqrtf( 2.0 * t2 / ssv[0] ) : pspec[0].range[2];
332 pspec[0].sidestep[1] = (ssv[1] > scutoff) ? ::sqrtf( 2.0 * t2 / ssv[1] ) : pspec[0].range[2];
333
334 pspec[1].stepsize = ( dt < pspec[1].range[2] ) ? dt : pspec[1].range[2];
335 REAL tcutoff = 2.0 * t2 / ( pspec[1].range[2] * pspec[1].range[2]);
336 pspec[1].sidestep[0] = (ttv[0] > tcutoff) ? ::sqrtf( 2.0 * t2 / ttv[0] ) : pspec[1].range[2];
337 pspec[1].sidestep[1] = (ttv[1] > tcutoff) ? ::sqrtf( 2.0 * t2 / ttv[1] ) : pspec[1].range[2];
338 } else if( ss != 0.0 ) {
339 REAL x = pspec[1].range[2] * st;
340 REAL ds = ( ::sqrtf( x * x + 8.0 * t2 * ss ) - x ) / ss;
341 pspec[0].stepsize = ( ds < pspec[0].range[2] ) ? ds : pspec[0].range[2];
342 REAL scutoff = 2.0 * t2 / ( pspec[0].range[2] * pspec[0].range[2]);
343 pspec[0].sidestep[0] = (ssv[0] > scutoff) ? ::sqrtf( 2.0 * t2 / ssv[0] ) : pspec[0].range[2];
344 pspec[0].sidestep[1] = (ssv[1] > scutoff) ? ::sqrtf( 2.0 * t2 / ssv[1] ) : pspec[0].range[2];
345 pspec[1].singleStep();
346 } else if( tt != 0.0 ) {
347 REAL x = pspec[0].range[2] * st;
348 REAL dt = ( ::sqrtf( x * x + 8.0 * t2 * tt ) - x ) / tt;
349 pspec[0].singleStep();
350 REAL tcutoff = 2.0 * t2 / ( pspec[1].range[2] * pspec[1].range[2]);
351 pspec[1].stepsize = ( dt < pspec[1].range[2] ) ? dt : pspec[1].range[2];
352 pspec[1].sidestep[0] = (ttv[0] > tcutoff) ? ::sqrtf( 2.0 * t2 / ttv[0] ) : pspec[1].range[2];
353 pspec[1].sidestep[1] = (ttv[1] > tcutoff) ? ::sqrtf( 2.0 * t2 / ttv[1] ) : pspec[1].range[2];
354 } else {
355 if( 4.0 * t2 > st * pspec[0].range[2] * pspec[1].range[2] ) {
356 pspec[0].singleStep();
357 pspec[1].singleStep();
358 } else {
359 REAL area = 4.0 * t2 / st;
360 REAL ds = ::sqrtf( area * pspec[0].range[2] / pspec[1].range[2] );
361 REAL dt = ::sqrtf( area * pspec[1].range[2] / pspec[0].range[2] );
362 pspec[0].stepsize = ( ds < pspec[0].range[2] ) ? ds : pspec[0].range[2];
363 pspec[0].sidestep[0] = pspec[0].range[2];
364 pspec[0].sidestep[1] = pspec[0].range[2];
365
366 pspec[1].stepsize = ( dt < pspec[1].range[2] ) ? dt : pspec[1].range[2];
367 pspec[1].sidestep[0] = pspec[1].range[2];
368 pspec[1].sidestep[1] = pspec[1].range[2];
369 }
370 }
371 } else if( mapdesc->isPathLengthSampling() ||
372 mapdesc->isObjectSpacePathSampling()) {
373 // t1 is upper bound on path length
374 REAL msv[2], mtv[2];
375 REAL ms = mapdesc->calcPartialVelocity( msv, &tmp[0][0][0], trstride, tcstride, pspec[0].order, pspec[1].order, 1, 0, pspec[0].range[2], pspec[1].range[2], 0 );
376 REAL mt = mapdesc->calcPartialVelocity( mtv, &tmp[0][0][0], trstride, tcstride, pspec[0].order, pspec[1].order, 0, 1, pspec[0].range[2], pspec[1].range[2], 1 );
377 REAL side_scale = 1.0;
378
379 if( ms != 0.0 ) {
380 if( mt != 0.0 ) {
381/* REAL d = t1 / ( ms * ms + mt * mt );*/
382/* REAL ds = mt * d;*/
383 REAL ds = t1 / (2.0*ms);
384/* REAL dt = ms * d;*/
385 REAL dt = t1 / (2.0*mt);
386 pspec[0].stepsize = ( ds < pspec[0].range[2] ) ? ds : pspec[0].range[2];
387 pspec[0].sidestep[0] = ( msv[0] * pspec[0].range[2] > t1 ) ? (side_scale* t1 / msv[0]) : pspec[0].range[2];
388 pspec[0].sidestep[1] = ( msv[1] * pspec[0].range[2] > t1 ) ? (side_scale* t1 / msv[1]) : pspec[0].range[2];
389
390 pspec[1].stepsize = ( dt < pspec[1].range[2] ) ? dt : pspec[1].range[2];
391 pspec[1].sidestep[0] = ( mtv[0] * pspec[1].range[2] > t1 ) ? (side_scale*t1 / mtv[0]) : pspec[1].range[2];
392 pspec[1].sidestep[1] = ( mtv[1] * pspec[1].range[2] > t1 ) ? (side_scale*t1 / mtv[1]) : pspec[1].range[2];
393 } else {
394 pspec[0].stepsize = ( t1 < ms * pspec[0].range[2] ) ? (t1 / ms) : pspec[0].range[2];
395 pspec[0].sidestep[0] = ( msv[0] * pspec[0].range[2] > t1 ) ? (t1 / msv[0]) : pspec[0].range[2];
396 pspec[0].sidestep[1] = ( msv[1] * pspec[0].range[2] > t1 ) ? (t1 / msv[1]) : pspec[0].range[2];
397
398 pspec[1].singleStep();
399 }
400 } else {
401 if( mt != 0.0 ) {
402 pspec[0].singleStep();
403
404 pspec[1].stepsize = ( t1 < mt * pspec[1].range[2] ) ? (t1 / mt) : pspec[1].range[2];
405 pspec[1].sidestep[0] = ( mtv[0] * pspec[1].range[2] > t1 ) ? (t1 / mtv[0]) : pspec[1].range[2];
406 pspec[1].sidestep[1] = ( mtv[1] * pspec[1].range[2] > t1 ) ? (t1 / mtv[1]) : pspec[1].range[2];
407 } else {
408 pspec[0].singleStep();
409 pspec[1].singleStep();
410 }
411 }
412 } else if( mapdesc->isSurfaceAreaSampling() ) {
413 // t is the square root of area
414/*
415 REAL msv[2], mtv[2];
416 REAL ms = mapdesc->calcPartialVelocity( msv, &tmp[0][0][0], trstride, tcstride, pspec[0].order, pspec[1].order, 1, 0, pspec[0].range[2], pspec[1].range[2], 0 );
417 REAL mt = mapdesc->calcPartialVelocity( mtv, &tmp[0][0][0], trstride, tcstride, pspec[0].order, pspec[1].order, 0, 1, pspec[0].range[2], pspec[1].range[2], 1 );
418 if( ms != 0.0 && mt != 0.0 ) {
419 REAL d = 1.0 / (ms * mt);
420 t *= M_SQRT2;
421 REAL ds = t * ::sqrtf( d * pspec[0].range[2] / pspec[1].range[2] );
422 REAL dt = t * ::sqrtf( d * pspec[1].range[2] / pspec[0].range[2] );
423 pspec[0].stepsize = ( ds < pspec[0].range[2] ) ? ds : pspec[0].range[2];
424 pspec[0].sidestep[0] = ( msv[0] * pspec[0].range[2] > t ) ? (t / msv[0]) : pspec[0].range[2];
425 pspec[0].sidestep[1] = ( msv[1] * pspec[0].range[2] > t ) ? (t / msv[1]) : pspec[0].range[2];
426
427 pspec[1].stepsize = ( dt < pspec[1].range[2] ) ? dt : pspec[1].range[2];
428 pspec[1].sidestep[0] = ( mtv[0] * pspec[1].range[2] > t ) ? (t / mtv[0]) : pspec[1].range[2];
429 pspec[1].sidestep[1] = ( mtv[1] * pspec[1].range[2] > t ) ? (t / mtv[1]) : pspec[1].range[2];
430 } else {
431 pspec[0].singleStep();
432 pspec[1].singleStep();
433 }
434*/
435 } else {
436 pspec[0].singleStep();
437 pspec[1].singleStep();
438 }
439 }
440 }
441
442#ifdef DEBUG
443 dprintf( "sidesteps %g %g %g %g, stepsize %g %g\n",
444 pspec[0].sidestep[0], pspec[0].sidestep[1],
445 pspec[1].sidestep[0], pspec[1].sidestep[1],
446 pspec[0].stepsize, pspec[1].stepsize );
447#endif
448
449 if( mapdesc->minsavings != N_NOSAVINGSSUBDIVISION ) {
450 REAL savings = 1./(pspec[0].stepsize * pspec[1].stepsize) ;
451 savings-= (2./( pspec[0].sidestep[0] + pspec[0].sidestep[1] )) *
452 (2./( pspec[1].sidestep[0] + pspec[1].sidestep[1] ));
453
454 savings *= pspec[0].range[2] * pspec[1].range[2];
455 if( savings > mapdesc->minsavings ) {
456 pspec[0].needsSubdivision = pspec[1].needsSubdivision = 1;
457 }
458 }
459
460 if( pspec[0].stepsize < pspec[0].minstepsize ) pspec[0].needsSubdivision = 1;
461 if( pspec[1].stepsize < pspec[1].minstepsize ) pspec[1].needsSubdivision = 1;
462 needsSampling = (needsSampling ? needsSamplingSubdivision() : 0);
463}
464
465void
466Patchspec::singleStep()
467{
468 stepsize = sidestep[0] = sidestep[1] = abs(range[2]);
469}
470
471void
472Patchspec::getstepsize( REAL max ) // max is number of samples for entire patch
473{
474 stepsize = ( max >= 1.0 ) ? range[2] / max : range[2];
475 if (stepsize < 0.0) {
476 stepsize = -stepsize;
477 }
478 sidestep[0] = sidestep[1] = minstepsize = stepsize;
479}
480
481int
482Patch::needsSamplingSubdivision( void )
483{
484 return (pspec[0].needsSubdivision || pspec[1].needsSubdivision) ? 1 : 0;
485}
486
487int
488Patch::needsNonSamplingSubdivision( void )
489{
490 return notInBbox;
491}
492
493int
494Patch::needsSubdivision( int param )
495{
496 return pspec[param].needsSubdivision;
497}
498
499int
500Patch::cullCheck( void )
501{
502 if( cullval == CULL_ACCEPT )
503 cullval = mapdesc->cullCheck( cpts, pspec[0].order, pspec[0].stride,
504 pspec[1].order, pspec[1].stride );
505 return cullval;
506}
507
Note: See TracBrowser for help on using the repository browser.