| 1 |
/* |
| 2 |
* |
| 3 |
* Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* Further, this software is distributed without any warranty that it is |
| 16 |
* free of the rightful claim of any third person regarding infringement |
| 17 |
* or the like. Any license provided herein, whether implied or |
| 18 |
* otherwise, applies only to this software file. Patent licenses, if |
| 19 |
* any, provided herein do not apply to combinations of this program with |
| 20 |
* other software, or any other product whatsoever. |
| 21 |
* |
| 22 |
* You should have received a copy of the GNU Lesser General Public |
| 23 |
* License along with this library; if not, write to the Free Software |
| 24 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 |
* |
| 26 |
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 27 |
* Mountain View, CA 94043, or: |
| 28 |
* |
| 29 |
* http://www.sgi.com |
| 30 |
* |
| 31 |
* For further information regarding this notice, see: |
| 32 |
* |
| 33 |
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 34 |
* |
| 35 |
*/ |
| 36 |
|
| 37 |
/* |
| 38 |
* nurbstess.c++ - $Revision: 1.1.1.1 $ |
| 39 |
* Derrick Burns - 1991 |
| 40 |
*/ |
| 41 |
|
| 42 |
#include "glimports.h" |
| 43 |
#include "myassert.h" |
| 44 |
#include "mysetjmp.h" |
| 45 |
#include "mystdio.h" |
| 46 |
#include "nurbsconsts.h" |
| 47 |
#include "nurbstess.h" |
| 48 |
#include "bufpool.h" |
| 49 |
#include "quilt.h" |
| 50 |
#include "knotvector.h" |
| 51 |
#include "mapdesc.h" |
| 52 |
#include "maplist.h" |
| 53 |
|
| 54 |
void |
| 55 |
NurbsTessellator::resetObjects( void ) |
| 56 |
{ |
| 57 |
subdivider.clear(); |
| 58 |
} |
| 59 |
|
| 60 |
void |
| 61 |
NurbsTessellator::makeobj( int ) |
| 62 |
{ |
| 63 |
#ifndef NDEBUG |
| 64 |
dprintf( "makeobj\n" ); |
| 65 |
#endif |
| 66 |
} |
| 67 |
|
| 68 |
void |
| 69 |
NurbsTessellator::closeobj( void ) |
| 70 |
{ |
| 71 |
#ifndef NDEBUG |
| 72 |
dprintf( "closeobj\n" ); |
| 73 |
#endif |
| 74 |
} |
| 75 |
|
| 76 |
void |
| 77 |
NurbsTessellator::bgnrender( void ) |
| 78 |
{ |
| 79 |
#ifndef NDEBUG |
| 80 |
dprintf( "bgnrender\n" ); |
| 81 |
#endif |
| 82 |
} |
| 83 |
|
| 84 |
void |
| 85 |
NurbsTessellator::endrender( void ) |
| 86 |
{ |
| 87 |
#ifndef NDEBUG |
| 88 |
dprintf( "endrender\n" ); |
| 89 |
#endif |
| 90 |
} |
| 91 |
|
| 92 |
/*----------------------------------------------------------------------------- |
| 93 |
* do_freebgnsurface - free o_surface structure |
| 94 |
* |
| 95 |
* Client: do_freeall(), bgnsurface() |
| 96 |
*----------------------------------------------------------------------------- |
| 97 |
*/ |
| 98 |
void |
| 99 |
NurbsTessellator::do_freebgnsurface( O_surface *o_surface ) |
| 100 |
{ |
| 101 |
o_surface->deleteMe( o_surfacePool ); |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
/*----------------------------------------------------------------------------- |
| 106 |
* do_bgnsurface - begin the display of a surface |
| 107 |
* |
| 108 |
* Client: bgnsurface() |
| 109 |
*----------------------------------------------------------------------------- |
| 110 |
*/ |
| 111 |
void |
| 112 |
NurbsTessellator::do_bgnsurface( O_surface *o_surface ) |
| 113 |
{ |
| 114 |
if( inSurface ) { |
| 115 |
do_nurbserror( 27 ); |
| 116 |
endsurface(); |
| 117 |
} |
| 118 |
inSurface = 1; |
| 119 |
|
| 120 |
if( ! playBack ) bgnrender(); |
| 121 |
|
| 122 |
isTrimModified = 0; |
| 123 |
isSurfaceModified = 0; |
| 124 |
isDataValid = 1; |
| 125 |
numTrims = 0; |
| 126 |
currentSurface = o_surface; |
| 127 |
nextTrim = &( currentSurface->o_trim ); |
| 128 |
nextNurbssurface = &( currentSurface->o_nurbssurface ); |
| 129 |
} |
| 130 |
|
| 131 |
/*----------------------------------------------------------------------------- |
| 132 |
* do_bgncurve - begin the display of a curve |
| 133 |
* |
| 134 |
* Client: bgncurve() |
| 135 |
*----------------------------------------------------------------------------- |
| 136 |
*/ |
| 137 |
void |
| 138 |
NurbsTessellator::do_bgncurve( O_curve *o_curve ) |
| 139 |
{ |
| 140 |
if ( inCurve ) { |
| 141 |
do_nurbserror( 6 ); |
| 142 |
endcurve(); |
| 143 |
} |
| 144 |
|
| 145 |
inCurve = 1; |
| 146 |
currentCurve = o_curve; |
| 147 |
currentCurve->curvetype = ct_none; |
| 148 |
|
| 149 |
if( inTrim ) { |
| 150 |
if( *nextCurve != o_curve ) { |
| 151 |
isCurveModified = 1; |
| 152 |
*nextCurve = o_curve; |
| 153 |
} |
| 154 |
} else { |
| 155 |
if( ! playBack ) bgnrender(); |
| 156 |
isDataValid = 1; |
| 157 |
} |
| 158 |
nextCurve = &(o_curve->next); |
| 159 |
nextPwlcurve = &(o_curve->curve.o_pwlcurve); |
| 160 |
nextNurbscurve = &(o_curve->curve.o_nurbscurve); |
| 161 |
} |
| 162 |
|
| 163 |
/*----------------------------------------------------------------------------- |
| 164 |
* do_endcurve - |
| 165 |
* |
| 166 |
* Client: endcurve() |
| 167 |
*----------------------------------------------------------------------------- |
| 168 |
*/ |
| 169 |
|
| 170 |
void |
| 171 |
NurbsTessellator::do_endcurve( void ) |
| 172 |
{ |
| 173 |
if( ! inCurve ) { |
| 174 |
do_nurbserror( 7 ); |
| 175 |
return; |
| 176 |
} |
| 177 |
inCurve = 0; |
| 178 |
|
| 179 |
*nextCurve = 0; |
| 180 |
if (currentCurve->curvetype == ct_nurbscurve) |
| 181 |
*nextNurbscurve = 0; |
| 182 |
else |
| 183 |
*nextPwlcurve = 0; |
| 184 |
|
| 185 |
if ( ! inTrim ) { |
| 186 |
if( ! isDataValid ) { |
| 187 |
do_freecurveall( currentCurve ); |
| 188 |
return; |
| 189 |
} |
| 190 |
|
| 191 |
int errval; |
| 192 |
errval = ::mysetjmp( jumpbuffer ); |
| 193 |
if( errval == 0 ) { |
| 194 |
if( currentCurve->curvetype == ct_nurbscurve ) { |
| 195 |
subdivider.beginQuilts(); |
| 196 |
for( O_nurbscurve *n = currentCurve->curve.o_nurbscurve; n != 0; n = n->next ) |
| 197 |
subdivider.addQuilt( n->bezier_curves ); |
| 198 |
subdivider.endQuilts(); |
| 199 |
subdivider.drawCurves(); |
| 200 |
if( ! playBack ) endrender(); |
| 201 |
} else { |
| 202 |
/* XXX */ |
| 203 |
if( ! playBack ) endrender(); |
| 204 |
/*do_draw_pwlcurve( currentCurve->curve.o_pwlcurve ) */; |
| 205 |
do_nurbserror( 9 ); |
| 206 |
} |
| 207 |
} else { |
| 208 |
if( ! playBack ) endrender(); |
| 209 |
do_nurbserror( errval ); |
| 210 |
} |
| 211 |
do_freecurveall( currentCurve ); |
| 212 |
resetObjects(); |
| 213 |
} |
| 214 |
} |
| 215 |
|
| 216 |
/*----------------------------------------------------------------------------- |
| 217 |
* do_endsurface - mark end of surface, display surface, free immediate data |
| 218 |
* |
| 219 |
* Client: |
| 220 |
*----------------------------------------------------------------------------- |
| 221 |
*/ |
| 222 |
void |
| 223 |
NurbsTessellator::do_endsurface( void ) |
| 224 |
{ |
| 225 |
if( inTrim ) { |
| 226 |
do_nurbserror( 12 ); |
| 227 |
endtrim(); |
| 228 |
} |
| 229 |
|
| 230 |
if( ! inSurface ) { |
| 231 |
do_nurbserror( 13 ); |
| 232 |
return; |
| 233 |
} |
| 234 |
inSurface = 0; |
| 235 |
|
| 236 |
*nextNurbssurface = 0; |
| 237 |
|
| 238 |
if( ! isDataValid ) { |
| 239 |
do_freeall( ); |
| 240 |
return; |
| 241 |
} |
| 242 |
|
| 243 |
if( *nextTrim != 0 ) { |
| 244 |
isTrimModified = 1; |
| 245 |
*nextTrim = 0; |
| 246 |
} |
| 247 |
|
| 248 |
int errval; |
| 249 |
|
| 250 |
errval = ::mysetjmp( jumpbuffer ); |
| 251 |
if( errval == 0 ) { |
| 252 |
if( numTrims > 0 ) { |
| 253 |
|
| 254 |
subdivider.beginTrims(); |
| 255 |
for( O_trim *trim = currentSurface->o_trim; trim; trim = trim->next ) { |
| 256 |
subdivider.beginLoop(); |
| 257 |
for( O_curve *curve = trim->o_curve; curve; curve = curve->next ) { |
| 258 |
curve->used = 0; |
| 259 |
assert( curve->curvetype != ct_none ); |
| 260 |
if (curve->curvetype == ct_pwlcurve) { |
| 261 |
O_pwlcurve *c = curve->curve.o_pwlcurve; |
| 262 |
subdivider.addArc( c->npts, c->pts, curve->nuid ); |
| 263 |
} else { |
| 264 |
Quilt *quilt = curve->curve.o_nurbscurve->bezier_curves; |
| 265 |
Quiltspec *qspec = quilt->qspec; |
| 266 |
REAL *cpts = quilt->cpts + qspec->offset; |
| 267 |
REAL *cptsend = cpts + (qspec->width * qspec->order * qspec->stride); |
| 268 |
for( ; cpts != cptsend; cpts += qspec->order*qspec->stride ) |
| 269 |
subdivider.addArc( cpts, quilt, curve->nuid ); |
| 270 |
} |
| 271 |
} |
| 272 |
subdivider.endLoop(); |
| 273 |
} |
| 274 |
subdivider.endTrims(); |
| 275 |
} |
| 276 |
|
| 277 |
subdivider.beginQuilts(); |
| 278 |
for( O_nurbssurface *n = currentSurface->o_nurbssurface; n; n = n->next ) |
| 279 |
subdivider.addQuilt( n->bezier_patches ); |
| 280 |
subdivider.endQuilts(); |
| 281 |
subdivider.drawSurfaces( currentSurface->nuid ); |
| 282 |
if( ! playBack ) endrender(); |
| 283 |
} else { |
| 284 |
if( ! playBack ) endrender(); |
| 285 |
do_nurbserror( errval ); |
| 286 |
} |
| 287 |
|
| 288 |
do_freeall( ); |
| 289 |
resetObjects(); |
| 290 |
} |
| 291 |
|
| 292 |
/*----------------------------------------------------------------------------- |
| 293 |
* do_freeall - free all data allocated in immediate mode |
| 294 |
* |
| 295 |
* Client: |
| 296 |
*----------------------------------------------------------------------------- |
| 297 |
*/ |
| 298 |
void |
| 299 |
NurbsTessellator::do_freeall( void ) |
| 300 |
{ |
| 301 |
for( O_trim *o_trim = currentSurface->o_trim; o_trim; ) { |
| 302 |
O_trim *next_o_trim = o_trim->next; |
| 303 |
for( O_curve *curve = o_trim->o_curve; curve; ) { |
| 304 |
O_curve *next_o_curve = curve->next; |
| 305 |
do_freecurveall( curve ); |
| 306 |
curve = next_o_curve; |
| 307 |
} |
| 308 |
if( o_trim->save == 0 ) do_freebgntrim( o_trim ); |
| 309 |
o_trim = next_o_trim; |
| 310 |
} |
| 311 |
|
| 312 |
O_nurbssurface *nurbss, *next_nurbss; |
| 313 |
for( nurbss= currentSurface->o_nurbssurface; nurbss; nurbss = next_nurbss) { |
| 314 |
next_nurbss = nurbss->next; |
| 315 |
if( nurbss->save == 0 ) |
| 316 |
do_freenurbssurface( nurbss ); |
| 317 |
else |
| 318 |
nurbss->used = 0; |
| 319 |
} |
| 320 |
|
| 321 |
if( currentSurface->save == 0 ) do_freebgnsurface( currentSurface ); |
| 322 |
} |
| 323 |
|
| 324 |
void |
| 325 |
NurbsTessellator::do_freecurveall( O_curve *curve ) |
| 326 |
{ |
| 327 |
assert( curve->curvetype != ct_none ); |
| 328 |
|
| 329 |
if( curve->curvetype == ct_nurbscurve ) { |
| 330 |
O_nurbscurve *ncurve, *next_ncurve; |
| 331 |
for( ncurve=curve->curve.o_nurbscurve; ncurve; ncurve=next_ncurve ) { |
| 332 |
next_ncurve = ncurve->next; |
| 333 |
if( ncurve->save == 0 ) |
| 334 |
do_freenurbscurve( ncurve ); |
| 335 |
else |
| 336 |
ncurve->used = 0; |
| 337 |
} |
| 338 |
} else { |
| 339 |
O_pwlcurve *pcurve, *next_pcurve; |
| 340 |
for( pcurve=curve->curve.o_pwlcurve; pcurve; pcurve=next_pcurve ) { |
| 341 |
next_pcurve = pcurve->next; |
| 342 |
if( pcurve->save == 0 ) |
| 343 |
do_freepwlcurve( pcurve ); |
| 344 |
else |
| 345 |
pcurve->used = 0; |
| 346 |
} |
| 347 |
} |
| 348 |
if( curve->save == 0 ) |
| 349 |
do_freebgncurve( curve ); |
| 350 |
} |
| 351 |
|
| 352 |
|
| 353 |
/*----------------------------------------------------------------------------- |
| 354 |
* do_freebgntrim - free the space allocated for a trim loop |
| 355 |
* |
| 356 |
* Client: |
| 357 |
*----------------------------------------------------------------------------- |
| 358 |
*/ |
| 359 |
void |
| 360 |
NurbsTessellator::do_freebgntrim( O_trim *o_trim ) |
| 361 |
{ |
| 362 |
o_trim->deleteMe( o_trimPool ); |
| 363 |
} |
| 364 |
|
| 365 |
|
| 366 |
/*----------------------------------------------------------------------------- |
| 367 |
* do_bgntrim - link in a trim loop to the current trimmed surface description |
| 368 |
* |
| 369 |
* Client: bgntrim() |
| 370 |
*----------------------------------------------------------------------------- |
| 371 |
*/ |
| 372 |
void |
| 373 |
NurbsTessellator::do_bgntrim( O_trim *o_trim ) |
| 374 |
{ |
| 375 |
|
| 376 |
if( ! inSurface ) { |
| 377 |
do_nurbserror( 15 ); |
| 378 |
bgnsurface( 0 ); |
| 379 |
inSurface = 2; |
| 380 |
} |
| 381 |
|
| 382 |
if( inTrim ) { |
| 383 |
do_nurbserror( 16 ); |
| 384 |
endtrim(); |
| 385 |
} |
| 386 |
inTrim = 1; |
| 387 |
|
| 388 |
if( *nextTrim != o_trim ) { |
| 389 |
isTrimModified = 1; |
| 390 |
*nextTrim = o_trim; |
| 391 |
} |
| 392 |
|
| 393 |
currentTrim = o_trim; |
| 394 |
nextTrim = &(o_trim->next); |
| 395 |
nextCurve = &(o_trim->o_curve); |
| 396 |
} |
| 397 |
|
| 398 |
|
| 399 |
/*----------------------------------------------------------------------------- |
| 400 |
* do_endtrim - mark the end of the current trim loop |
| 401 |
* |
| 402 |
* Client: endtrim() |
| 403 |
*----------------------------------------------------------------------------- |
| 404 |
*/ |
| 405 |
void |
| 406 |
NurbsTessellator::do_endtrim( void ) |
| 407 |
{ |
| 408 |
if( ! inTrim ) { |
| 409 |
do_nurbserror( 17 ); |
| 410 |
return; |
| 411 |
} |
| 412 |
inTrim = 0; |
| 413 |
|
| 414 |
if( currentTrim->o_curve == 0 ) { |
| 415 |
do_nurbserror( 18 ); |
| 416 |
isDataValid = 0; |
| 417 |
} |
| 418 |
|
| 419 |
numTrims++; |
| 420 |
|
| 421 |
if( *nextCurve != 0 ) { |
| 422 |
isTrimModified = 1; |
| 423 |
*nextCurve = 0; |
| 424 |
} |
| 425 |
} |
| 426 |
|
| 427 |
/*----------------------------------------------------------------------------- |
| 428 |
* do_freepwlcurve - |
| 429 |
* |
| 430 |
* Client: |
| 431 |
*----------------------------------------------------------------------------- |
| 432 |
*/ |
| 433 |
void |
| 434 |
NurbsTessellator::do_freepwlcurve( O_pwlcurve *o_pwlcurve ) |
| 435 |
{ |
| 436 |
o_pwlcurve->deleteMe( o_pwlcurvePool ); |
| 437 |
} |
| 438 |
|
| 439 |
void |
| 440 |
NurbsTessellator::do_freebgncurve( O_curve *o_curve ) |
| 441 |
{ |
| 442 |
o_curve->deleteMe( o_curvePool ); |
| 443 |
} |
| 444 |
|
| 445 |
/*----------------------------------------------------------------------------- |
| 446 |
* do_pwlcurve - link in pwl trim loop to the current surface description |
| 447 |
* |
| 448 |
* Client: pwlcurve() |
| 449 |
*----------------------------------------------------------------------------- |
| 450 |
*/ |
| 451 |
void |
| 452 |
NurbsTessellator::do_pwlcurve( O_pwlcurve *o_pwlcurve ) |
| 453 |
{ |
| 454 |
if( ! inTrim ) { |
| 455 |
do_nurbserror( 19 ); |
| 456 |
if( o_pwlcurve->save == 0 ) |
| 457 |
do_freepwlcurve(o_pwlcurve ); |
| 458 |
return; |
| 459 |
} |
| 460 |
|
| 461 |
if( ! inCurve ) { |
| 462 |
bgncurve( 0 ); |
| 463 |
inCurve = 2; |
| 464 |
} |
| 465 |
|
| 466 |
if( o_pwlcurve->used ) { |
| 467 |
do_nurbserror( 20 ); |
| 468 |
isDataValid = 0; |
| 469 |
return; |
| 470 |
} else |
| 471 |
o_pwlcurve->used = 1; |
| 472 |
|
| 473 |
if( currentCurve->curvetype == ct_none ) { |
| 474 |
currentCurve->curvetype = ct_pwlcurve; |
| 475 |
} else if( currentCurve->curvetype != ct_pwlcurve ) { |
| 476 |
do_nurbserror( 21 ); |
| 477 |
isDataValid = 0; |
| 478 |
return; |
| 479 |
} |
| 480 |
|
| 481 |
if( *nextPwlcurve != o_pwlcurve ) { |
| 482 |
isCurveModified = 1; |
| 483 |
*nextPwlcurve = o_pwlcurve; |
| 484 |
} |
| 485 |
nextPwlcurve = &(o_pwlcurve->next); |
| 486 |
|
| 487 |
if( o_pwlcurve->owner != currentCurve ) { |
| 488 |
isCurveModified = 1; |
| 489 |
o_pwlcurve->owner = currentCurve; |
| 490 |
} |
| 491 |
|
| 492 |
if(inCurve == 2) |
| 493 |
endcurve(); |
| 494 |
} |
| 495 |
|
| 496 |
|
| 497 |
/*----------------------------------------------------------------------------- |
| 498 |
* do_freenurbscurve - |
| 499 |
* |
| 500 |
* Client: |
| 501 |
*----------------------------------------------------------------------------- |
| 502 |
*/ |
| 503 |
void |
| 504 |
NurbsTessellator::do_freenurbscurve( O_nurbscurve *o_nurbscurve ) |
| 505 |
{ |
| 506 |
o_nurbscurve->bezier_curves->deleteMe( quiltPool ); |
| 507 |
o_nurbscurve->deleteMe( o_nurbscurvePool ); |
| 508 |
} |
| 509 |
|
| 510 |
|
| 511 |
/*----------------------------------------------------------------------------- |
| 512 |
* do_nurbscurve - |
| 513 |
* |
| 514 |
* Client: nurbscurve() |
| 515 |
*----------------------------------------------------------------------------- |
| 516 |
*/ |
| 517 |
void |
| 518 |
NurbsTessellator::do_nurbscurve( O_nurbscurve *o_nurbscurve ) |
| 519 |
{ |
| 520 |
if ( ! inCurve ) { |
| 521 |
bgncurve( 0 ); |
| 522 |
inCurve = 2; |
| 523 |
} |
| 524 |
|
| 525 |
if( o_nurbscurve->used ) { |
| 526 |
/* error - curve was already called in current surface */ |
| 527 |
do_nurbserror( 23 ); |
| 528 |
isDataValid = 0; |
| 529 |
return; |
| 530 |
} else |
| 531 |
o_nurbscurve->used = 1; |
| 532 |
|
| 533 |
if( currentCurve->curvetype == ct_none ) { |
| 534 |
currentCurve->curvetype = ct_nurbscurve; |
| 535 |
} else if( currentCurve->curvetype != ct_nurbscurve ) { |
| 536 |
do_nurbserror( 24 ); |
| 537 |
isDataValid = 0; |
| 538 |
return; |
| 539 |
} |
| 540 |
|
| 541 |
if( *nextNurbscurve != o_nurbscurve ) { |
| 542 |
isCurveModified = 1; |
| 543 |
*nextNurbscurve = o_nurbscurve; |
| 544 |
} |
| 545 |
|
| 546 |
nextNurbscurve = &(o_nurbscurve->next); |
| 547 |
|
| 548 |
if( o_nurbscurve->owner != currentCurve ) { |
| 549 |
isCurveModified = 1; |
| 550 |
o_nurbscurve->owner = currentCurve; |
| 551 |
} |
| 552 |
|
| 553 |
if( o_nurbscurve->owner == 0 ) |
| 554 |
isCurveModified = 1; |
| 555 |
|
| 556 |
if( inCurve == 2 ) |
| 557 |
endcurve(); |
| 558 |
} |
| 559 |
|
| 560 |
|
| 561 |
/*----------------------------------------------------------------------------- |
| 562 |
* do_freenurbssurface - |
| 563 |
* |
| 564 |
* Client: |
| 565 |
*----------------------------------------------------------------------------- |
| 566 |
*/ |
| 567 |
|
| 568 |
void |
| 569 |
NurbsTessellator::do_freenurbssurface( O_nurbssurface *o_nurbssurface ) |
| 570 |
{ |
| 571 |
o_nurbssurface->bezier_patches->deleteMe( quiltPool ); |
| 572 |
o_nurbssurface->deleteMe( o_nurbssurfacePool ); |
| 573 |
} |
| 574 |
|
| 575 |
/*----------------------------------------------------------------------------- |
| 576 |
* do_nurbssurface - |
| 577 |
* |
| 578 |
* Client: nurbssurface() |
| 579 |
*----------------------------------------------------------------------------- |
| 580 |
*/ |
| 581 |
void |
| 582 |
NurbsTessellator::do_nurbssurface( O_nurbssurface *o_nurbssurface ) |
| 583 |
{ |
| 584 |
if( ! inSurface ) { |
| 585 |
bgnsurface( 0 ); |
| 586 |
inSurface = 2; |
| 587 |
} |
| 588 |
|
| 589 |
if( o_nurbssurface->used ) { |
| 590 |
/* error - surface was already called in current block */ |
| 591 |
do_nurbserror( 25 ); |
| 592 |
isDataValid = 0; |
| 593 |
return; |
| 594 |
} else |
| 595 |
o_nurbssurface->used = 1; |
| 596 |
|
| 597 |
if( *nextNurbssurface != o_nurbssurface ) { |
| 598 |
isSurfaceModified = 1; |
| 599 |
*nextNurbssurface = o_nurbssurface; |
| 600 |
} |
| 601 |
|
| 602 |
if( o_nurbssurface->owner != currentSurface ) { |
| 603 |
isSurfaceModified = 1; |
| 604 |
o_nurbssurface->owner = currentSurface; |
| 605 |
} |
| 606 |
nextNurbssurface = &(o_nurbssurface->next); |
| 607 |
|
| 608 |
if( inSurface == 2 ) |
| 609 |
endsurface(); |
| 610 |
} |
| 611 |
|
| 612 |
|
| 613 |
/*----------------------------------------------------------------------------- |
| 614 |
* do_freenurbsproperty |
| 615 |
* |
| 616 |
*----------------------------------------------------------------------------- |
| 617 |
*/ |
| 618 |
|
| 619 |
void |
| 620 |
NurbsTessellator::do_freenurbsproperty( Property *prop ) |
| 621 |
{ |
| 622 |
prop->deleteMe( propertyPool ); |
| 623 |
} |
| 624 |
|
| 625 |
|
| 626 |
/*----------------------------------------------------------------------------- |
| 627 |
* do_setnurbsproperty - |
| 628 |
* |
| 629 |
*----------------------------------------------------------------------------- |
| 630 |
*/ |
| 631 |
|
| 632 |
void |
| 633 |
NurbsTessellator::do_setnurbsproperty( Property *prop ) |
| 634 |
{ |
| 635 |
renderhints.setProperty( prop->tag, prop->value ); |
| 636 |
if( prop->save == 0 ) |
| 637 |
do_freenurbsproperty( prop ); |
| 638 |
} |
| 639 |
|
| 640 |
void |
| 641 |
NurbsTessellator::do_setnurbsproperty2( Property *prop ) |
| 642 |
{ |
| 643 |
Mapdesc *mapdesc = maplist.find( prop->type ); |
| 644 |
|
| 645 |
mapdesc->setProperty( prop->tag, prop->value ); |
| 646 |
if( prop->save == 0 ) |
| 647 |
do_freenurbsproperty( prop ); |
| 648 |
} |
| 649 |
|
| 650 |
void |
| 651 |
NurbsTessellator::errorHandler( int ) |
| 652 |
{ |
| 653 |
} |
| 654 |
|
| 655 |
void |
| 656 |
NurbsTessellator::do_nurbserror( int msg ) |
| 657 |
{ |
| 658 |
errorHandler( msg ); |
| 659 |
} |
| 660 |
|
| 661 |
int |
| 662 |
NurbsTessellator::do_check_knots( Knotvector *knots, char *msg ) |
| 663 |
{ |
| 664 |
int status = knots->validate(); |
| 665 |
if( status ) { |
| 666 |
do_nurbserror( status ); |
| 667 |
if( renderhints.errorchecking != N_NOMSG ) knots->show( msg ); |
| 668 |
} |
| 669 |
return status; |
| 670 |
} |
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|