40 #include "glimports.h"
48 #include "nurbsconsts.h"
55 Curve::Curve( Quilt_ptr geo, REAL pta, REAL ptb,
Curve *c )
57 mapdesc = geo->mapdesc;
59 needsSampling = mapdesc->isRangeSampling() ? 1 : 0;
60 cullval = mapdesc->isCulling() ? CULL_ACCEPT : CULL_TRIVIAL_ACCEPT;
61 order = geo->qspec[0].order;
67 ps += qs->index * qs->order * qs->stride;
70 mapdesc->xformSampling( ps, qs->order, qs->stride, spts, stride );
72 if( cullval == CULL_ACCEPT )
73 mapdesc->xformCulling( ps, qs->order, qs->stride, cpts, stride );
76 range[0] = qs->breakpoints[qs->index];
77 range[1] = qs->breakpoints[qs->index+1];
78 range[2] = range[1] - range[0];
80 if( range[0] != pta ) {
81 Curve lower( *
this, pta, 0 );
85 if( range[1] != ptb ) {
86 Curve lower( *
this, ptb, 0 );
95 Curve::Curve(
Curve& upper, REAL value,
Curve *c )
100 lower.mapdesc = upper.mapdesc;
101 lower.needsSampling = upper.needsSampling;
102 lower.order = upper.order;
103 lower.stride = upper.stride;
104 lower.cullval = upper.cullval;
106 REAL d = (value - upper.range[0]) / upper.range[2];
109 mapdesc->subdivide( upper.spts, lower.spts, d, upper.stride, upper.order );
111 if( cullval == CULL_ACCEPT )
112 mapdesc->subdivide( upper.cpts, lower.cpts, d, upper.stride, upper.order );
114 lower.range[0] = upper.range[0];
115 lower.range[1] = value;
116 lower.range[2] = value - upper.range[0];
117 upper.range[0] = value;
118 upper.range[2] = upper.range[1] - value;
130 if( stepsize < minstepsize )
131 stepsize = mapdesc->clampfactor * minstepsize;
135 Curve::setstepsize( REAL max )
137 stepsize = ( max >= 1.0 ) ? (range[2] / max) : range[2];
138 minstepsize = stepsize;
142 Curve::getstepsize(
void )
146 if( mapdesc->isConstantSampling() ) {
149 setstepsize( mapdesc->maxrate );
150 }
else if( mapdesc->isDomainSampling() ) {
152 setstepsize( mapdesc->maxrate * range[2] );
156 assert( order <= MAXORDER );
159 REAL tmp[MAXORDER][MAXCOORDS];
160 const int tstride =
sizeof(tmp[0]) /
sizeof(REAL);
161 int val = mapdesc->project( spts, stride, &tmp[0][0], tstride, order );
165 setstepsize( mapdesc->maxrate );
167 REAL t = mapdesc->getProperty( N_PIXEL_TOLERANCE );
168 if( mapdesc->isParametricDistanceSampling() ) {
169 REAL d = mapdesc->calcPartialVelocity( &tmp[0][0], tstride, order, 2, range[2] );
170 stepsize = (d > 0.0) ? sqrtf( 8.0 * t / d ) : range[2];
171 minstepsize = ( mapdesc->maxrate > 0.0 ) ? (range[2] / mapdesc->maxrate) : 0.0;
172 }
else if( mapdesc->isPathLengthSampling() ) {
174 REAL d = mapdesc->calcPartialVelocity( &tmp[0][0], tstride, order, 1, range[2] );
175 stepsize = ( d > 0.0 ) ? (t / d) : range[2];
176 minstepsize = ( mapdesc->maxrate > 0.0 ) ? (range[2] / mapdesc->maxrate) : 0.0;
179 setstepsize( mapdesc->maxrate );
186 Curve::needsSamplingSubdivision(
void )
188 return ( stepsize < minstepsize ) ? 1 : 0;
192 Curve::cullCheck(
void )
194 if( cullval == CULL_ACCEPT )
195 cullval = mapdesc->cullCheck( cpts, order, stride );