| 1 |
/* $Id: nurbssrf.c,v 1.2 2000/11/02 00:28:54 mholst Exp $ */ |
| 2 |
|
| 3 |
/* |
| 4 |
* Mesa 3-D graphics library |
| 5 |
* Version: 2.0 |
| 6 |
* Copyright (C) 1995-1996 Brian Paul |
| 7 |
* |
| 8 |
* This library is free software; you can redistribute it and/or |
| 9 |
* modify it under the terms of the GNU Library General Public |
| 10 |
* License as published by the Free Software Foundation; either |
| 11 |
* version 2 of the License, or (at your option) any later version. |
| 12 |
* |
| 13 |
* This library is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
* Library General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Library General Public |
| 19 |
* License along with this library; if not, write to the Free |
| 20 |
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 21 |
*/ |
| 22 |
|
| 23 |
/* |
| 24 |
* NURBS implementation written by Bogdan Sikorski ([email protected]) |
| 25 |
* See README2 for more info. |
| 26 |
*/ |
| 27 |
|
| 28 |
|
| 29 |
#include <math.h> |
| 30 |
#include <stdlib.h> |
| 31 |
#include <stdio.h> |
| 32 |
#include <string.h> /* prototype of memcpy() */ |
| 33 |
#include "nurbs.h" |
| 34 |
|
| 35 |
|
| 36 |
static int |
| 37 |
get_surface_dim(GLenum type) |
| 38 |
{ |
| 39 |
switch(type) |
| 40 |
{ |
| 41 |
case GL_MAP2_VERTEX_3: return 3; |
| 42 |
case GL_MAP2_VERTEX_4: return 4; |
| 43 |
case GL_MAP2_INDEX: return 1; |
| 44 |
case GL_MAP2_COLOR_4: return 4; |
| 45 |
case GL_MAP2_NORMAL: return 3; |
| 46 |
case GL_MAP2_TEXTURE_COORD_1: return 1; |
| 47 |
case GL_MAP2_TEXTURE_COORD_2: return 2; |
| 48 |
case GL_MAP2_TEXTURE_COORD_3: return 3; |
| 49 |
case GL_MAP2_TEXTURE_COORD_4: return 4; |
| 50 |
default: abort(); /* TODO: is this OK? */ |
| 51 |
} |
| 52 |
return 0; /*never get here*/ |
| 53 |
} |
| 54 |
|
| 55 |
static GLenum |
| 56 |
test_nurbs_surface(GLUnurbsObj *nobj, surface_attribs *attrib) |
| 57 |
{ |
| 58 |
GLenum err; |
| 59 |
GLint tmp_int; |
| 60 |
|
| 61 |
if(attrib->sorder < 0 || attrib->torder < 0) |
| 62 |
{ |
| 63 |
call_user_error(nobj,GLU_INVALID_VALUE); |
| 64 |
return GLU_ERROR; |
| 65 |
} |
| 66 |
glGetIntegerv(GL_MAX_EVAL_ORDER,&tmp_int); |
| 67 |
if(attrib->sorder > tmp_int || attrib->sorder < 2) |
| 68 |
{ |
| 69 |
call_user_error(nobj,GLU_NURBS_ERROR1); |
| 70 |
return GLU_ERROR; |
| 71 |
} |
| 72 |
if(attrib->torder > tmp_int || attrib->torder < 2) |
| 73 |
{ |
| 74 |
call_user_error(nobj,GLU_NURBS_ERROR1); |
| 75 |
return GLU_ERROR; |
| 76 |
} |
| 77 |
if(attrib->sknot_count < attrib->sorder +2) |
| 78 |
{ |
| 79 |
call_user_error(nobj,GLU_NURBS_ERROR2); |
| 80 |
return GLU_ERROR; |
| 81 |
} |
| 82 |
if(attrib->tknot_count < attrib->torder +2) |
| 83 |
{ |
| 84 |
call_user_error(nobj,GLU_NURBS_ERROR2); |
| 85 |
return GLU_ERROR; |
| 86 |
} |
| 87 |
if(attrib->s_stride < 0 || attrib->t_stride < 0) |
| 88 |
{ |
| 89 |
call_user_error(nobj,GLU_NURBS_ERROR34); |
| 90 |
return GLU_ERROR; |
| 91 |
} |
| 92 |
if(attrib->sknot==NULL || attrib->tknot==NULL || attrib->ctrlarray==NULL) |
| 93 |
{ |
| 94 |
call_user_error(nobj,GLU_NURBS_ERROR36); |
| 95 |
return GLU_ERROR; |
| 96 |
} |
| 97 |
if((err=test_knot(attrib->tknot_count,attrib->tknot,attrib->torder)) |
| 98 |
!=GLU_NO_ERROR) |
| 99 |
{ |
| 100 |
call_user_error(nobj,err); |
| 101 |
return GLU_ERROR; |
| 102 |
} |
| 103 |
if((err=test_knot(attrib->sknot_count,attrib->sknot,attrib->sorder)) |
| 104 |
!=GLU_NO_ERROR) |
| 105 |
{ |
| 106 |
call_user_error(nobj,err); |
| 107 |
return GLU_ERROR; |
| 108 |
} |
| 109 |
return GLU_NO_ERROR; |
| 110 |
} |
| 111 |
|
| 112 |
static GLenum |
| 113 |
test_nurbs_surfaces(GLUnurbsObj *nobj) |
| 114 |
{ |
| 115 |
/* test the geometric data */ |
| 116 |
if(test_nurbs_surface(nobj,&(nobj->surface.geom))!=GLU_NO_ERROR) |
| 117 |
return GLU_ERROR; |
| 118 |
/* now test the attributive data */ |
| 119 |
/* color */ |
| 120 |
if(nobj->surface.color.type!=GLU_INVALID_ENUM) |
| 121 |
if(test_nurbs_surface(nobj,&(nobj->surface.color))!=GLU_NO_ERROR) |
| 122 |
return GLU_ERROR; |
| 123 |
/* normal */ |
| 124 |
if(nobj->surface.normal.type!=GLU_INVALID_ENUM) |
| 125 |
if(test_nurbs_surface(nobj,&(nobj->surface.normal))!=GLU_NO_ERROR) |
| 126 |
return GLU_ERROR; |
| 127 |
/* texture */ |
| 128 |
if(nobj->surface.texture.type!=GLU_INVALID_ENUM) |
| 129 |
if(test_nurbs_surface(nobj,&(nobj->surface.texture))!=GLU_NO_ERROR) |
| 130 |
return GLU_ERROR; |
| 131 |
return GLU_NO_ERROR; |
| 132 |
} |
| 133 |
|
| 134 |
static GLenum |
| 135 |
convert_surf(knot_str_type *s_knot, knot_str_type *t_knot, |
| 136 |
surface_attribs *attrib, GLfloat **new_ctrl, |
| 137 |
GLint *s_n_ctrl, GLint *t_n_ctrl) |
| 138 |
{ |
| 139 |
GLfloat **tmp_ctrl; |
| 140 |
GLfloat *ctrl_offset; |
| 141 |
GLint tmp_n_control; |
| 142 |
GLint i,j,t_cnt,s_cnt; |
| 143 |
GLint tmp_stride; |
| 144 |
GLint dim; |
| 145 |
GLenum err; |
| 146 |
|
| 147 |
/* valid range is empty? */ |
| 148 |
if((s_knot->unified_knot !=NULL && s_knot->unified_nknots==0) || |
| 149 |
(t_knot->unified_knot !=NULL && t_knot->unified_nknots==0)) |
| 150 |
{ |
| 151 |
if(s_knot->unified_knot) |
| 152 |
{ |
| 153 |
free(s_knot->unified_knot); |
| 154 |
s_knot->unified_knot=NULL; |
| 155 |
} |
| 156 |
if(t_knot->unified_knot) |
| 157 |
{ |
| 158 |
free(t_knot->unified_knot); |
| 159 |
t_knot->unified_knot=NULL; |
| 160 |
} |
| 161 |
*s_n_ctrl=0; |
| 162 |
*t_n_ctrl=0; |
| 163 |
return GLU_NO_ERROR; |
| 164 |
} |
| 165 |
t_cnt=attrib->tknot_count-attrib->torder; |
| 166 |
s_cnt=attrib->sknot_count-attrib->sorder; |
| 167 |
if((tmp_ctrl=(GLfloat **)malloc(sizeof(GLfloat *)*t_cnt))==NULL) |
| 168 |
return GLU_OUT_OF_MEMORY; |
| 169 |
if((err=explode_knot(s_knot))!=GLU_NO_ERROR) |
| 170 |
{ |
| 171 |
free(tmp_ctrl); |
| 172 |
if(s_knot->unified_knot) |
| 173 |
{ |
| 174 |
free(s_knot->unified_knot); |
| 175 |
s_knot->unified_knot=NULL; |
| 176 |
} |
| 177 |
return err; |
| 178 |
} |
| 179 |
if(s_knot->unified_knot) |
| 180 |
{ |
| 181 |
free(s_knot->unified_knot); |
| 182 |
s_knot->unified_knot=NULL; |
| 183 |
} |
| 184 |
if((err=calc_alphas(s_knot))!=GLU_NO_ERROR) |
| 185 |
{ |
| 186 |
free(tmp_ctrl); |
| 187 |
free(s_knot->new_knot); |
| 188 |
return err; |
| 189 |
} |
| 190 |
free(s_knot->new_knot); |
| 191 |
ctrl_offset=attrib->ctrlarray; |
| 192 |
dim=attrib->dim; |
| 193 |
for(i=0;i<t_cnt;i++) |
| 194 |
{ |
| 195 |
if((err=calc_new_ctrl_pts(ctrl_offset,attrib->s_stride,s_knot, |
| 196 |
dim,&(tmp_ctrl[i]),&tmp_n_control))!=GLU_NO_ERROR) |
| 197 |
{ |
| 198 |
for(--i;i<=0;i--) |
| 199 |
free(tmp_ctrl[i]); |
| 200 |
free(tmp_ctrl); |
| 201 |
free(s_knot->alpha); |
| 202 |
return err; |
| 203 |
} |
| 204 |
ctrl_offset+=attrib->t_stride; |
| 205 |
} |
| 206 |
free(s_knot->alpha); |
| 207 |
tmp_stride=dim*tmp_n_control; |
| 208 |
if((*new_ctrl=(GLfloat *)malloc(sizeof(GLfloat)*tmp_stride*t_cnt)) |
| 209 |
==NULL) |
| 210 |
{ |
| 211 |
for(i=0;i<t_cnt;i++) |
| 212 |
free(tmp_ctrl[i]); |
| 213 |
free(tmp_ctrl); |
| 214 |
return GLU_OUT_OF_MEMORY; |
| 215 |
} |
| 216 |
for(i=0;i<tmp_n_control;i++) |
| 217 |
for(j=0;j<t_cnt;j++) |
| 218 |
MEMCPY(*new_ctrl+j*dim+i*dim*t_cnt,tmp_ctrl[j]+dim*i, |
| 219 |
sizeof(GLfloat)*dim); |
| 220 |
for(i=0;i<t_cnt;i++) |
| 221 |
free(tmp_ctrl[i]); |
| 222 |
free(tmp_ctrl); |
| 223 |
*s_n_ctrl=tmp_n_control; |
| 224 |
|
| 225 |
if((tmp_ctrl=(GLfloat **)malloc(sizeof(GLfloat *)*(*s_n_ctrl)))==NULL) |
| 226 |
{ |
| 227 |
return GLU_OUT_OF_MEMORY; |
| 228 |
} |
| 229 |
if((err=explode_knot(t_knot))!=GLU_NO_ERROR) |
| 230 |
{ |
| 231 |
free(tmp_ctrl); |
| 232 |
if(t_knot->unified_knot) |
| 233 |
{ |
| 234 |
free(t_knot->unified_knot); |
| 235 |
t_knot->unified_knot=NULL; |
| 236 |
} |
| 237 |
return err; |
| 238 |
} |
| 239 |
if(t_knot->unified_knot) |
| 240 |
{ |
| 241 |
free(t_knot->unified_knot); |
| 242 |
t_knot->unified_knot=NULL; |
| 243 |
} |
| 244 |
if((err=calc_alphas(t_knot))!=GLU_NO_ERROR) |
| 245 |
{ |
| 246 |
free(tmp_ctrl); |
| 247 |
free(t_knot->new_knot); |
| 248 |
return err; |
| 249 |
} |
| 250 |
free(t_knot->new_knot); |
| 251 |
ctrl_offset=*new_ctrl; |
| 252 |
for(i=0;i<(*s_n_ctrl);i++) |
| 253 |
{ |
| 254 |
if((err=calc_new_ctrl_pts(ctrl_offset,dim,t_knot, |
| 255 |
dim,&(tmp_ctrl[i]),&tmp_n_control))!=GLU_NO_ERROR) |
| 256 |
{ |
| 257 |
for(--i;i<=0;i--) |
| 258 |
free(tmp_ctrl[i]); |
| 259 |
free(tmp_ctrl); |
| 260 |
free(t_knot->alpha); |
| 261 |
return err; |
| 262 |
} |
| 263 |
ctrl_offset+=dim*t_cnt; |
| 264 |
} |
| 265 |
free(t_knot->alpha); |
| 266 |
free(*new_ctrl); |
| 267 |
tmp_stride=dim*tmp_n_control; |
| 268 |
if((*new_ctrl=(GLfloat *)malloc(sizeof(GLfloat)*tmp_stride*(*s_n_ctrl))) |
| 269 |
==NULL) |
| 270 |
{ |
| 271 |
for(i=0;i<(*s_n_ctrl);i++) |
| 272 |
free(tmp_ctrl[i]); |
| 273 |
free(tmp_ctrl); |
| 274 |
return GLU_OUT_OF_MEMORY; |
| 275 |
} |
| 276 |
for(i=0;i<(*s_n_ctrl);i++) |
| 277 |
{ |
| 278 |
MEMCPY(*new_ctrl+i*tmp_stride,tmp_ctrl[i],sizeof(GLfloat)*tmp_stride); |
| 279 |
free(tmp_ctrl[i]); |
| 280 |
} |
| 281 |
free(tmp_ctrl); |
| 282 |
*t_n_ctrl=tmp_n_control; |
| 283 |
return GLU_NO_ERROR; |
| 284 |
} |
| 285 |
|
| 286 |
/* prepare the knot information structures */ |
| 287 |
static GLenum |
| 288 |
fill_knot_structures(GLUnurbsObj *nobj, |
| 289 |
knot_str_type *geom_s_knot, knot_str_type *geom_t_knot, |
| 290 |
knot_str_type *color_s_knot, knot_str_type *color_t_knot, |
| 291 |
knot_str_type *normal_s_knot, knot_str_type *normal_t_knot, |
| 292 |
knot_str_type *texture_s_knot, knot_str_type *texture_t_knot) |
| 293 |
{ |
| 294 |
GLint order; |
| 295 |
GLfloat *knot; |
| 296 |
GLint nknots; |
| 297 |
GLint t_min,t_max; |
| 298 |
|
| 299 |
geom_s_knot->unified_knot=NULL; |
| 300 |
knot=geom_s_knot->knot=nobj->surface.geom.sknot; |
| 301 |
nknots=geom_s_knot->nknots=nobj->surface.geom.sknot_count; |
| 302 |
order=geom_s_knot->order=nobj->surface.geom.sorder; |
| 303 |
geom_s_knot->delta_nknots=0; |
| 304 |
t_min=geom_s_knot->t_min=order-1; |
| 305 |
t_max=geom_s_knot->t_max=nknots-order; |
| 306 |
if(fabs(knot[t_min]-knot[t_max])<EPSILON) |
| 307 |
{ |
| 308 |
call_user_error(nobj,GLU_NURBS_ERROR3); |
| 309 |
return GLU_ERROR; |
| 310 |
} |
| 311 |
if(fabs(knot[0]-knot[t_min])<EPSILON) |
| 312 |
{ |
| 313 |
/* knot open at beggining */ |
| 314 |
geom_s_knot->open_at_begin=GL_TRUE; |
| 315 |
} |
| 316 |
else |
| 317 |
geom_s_knot->open_at_begin=GL_FALSE; |
| 318 |
if(fabs(knot[t_max]-knot[nknots-1])<EPSILON) |
| 319 |
{ |
| 320 |
/* knot open at end */ |
| 321 |
geom_s_knot->open_at_end=GL_TRUE; |
| 322 |
} |
| 323 |
else |
| 324 |
geom_s_knot->open_at_end=GL_FALSE; |
| 325 |
geom_t_knot->unified_knot=NULL; |
| 326 |
knot=geom_t_knot->knot=nobj->surface.geom.tknot; |
| 327 |
nknots=geom_t_knot->nknots=nobj->surface.geom.tknot_count; |
| 328 |
order=geom_t_knot->order=nobj->surface.geom.torder; |
| 329 |
geom_t_knot->delta_nknots=0; |
| 330 |
t_min=geom_t_knot->t_min=order-1; |
| 331 |
t_max=geom_t_knot->t_max=nknots-order; |
| 332 |
if(fabs(knot[t_min]-knot[t_max])<EPSILON) |
| 333 |
{ |
| 334 |
call_user_error(nobj,GLU_NURBS_ERROR3); |
| 335 |
return GLU_ERROR; |
| 336 |
} |
| 337 |
if(fabs(knot[0]-knot[t_min])<EPSILON) |
| 338 |
{ |
| 339 |
/* knot open at beggining */ |
| 340 |
geom_t_knot->open_at_begin=GL_TRUE; |
| 341 |
} |
| 342 |
else |
| 343 |
geom_t_knot->open_at_begin=GL_FALSE; |
| 344 |
if(fabs(knot[t_max]-knot[nknots-1])<EPSILON) |
| 345 |
{ |
| 346 |
/* knot open at end */ |
| 347 |
geom_t_knot->open_at_end=GL_TRUE; |
| 348 |
} |
| 349 |
else |
| 350 |
geom_t_knot->open_at_end=GL_FALSE; |
| 351 |
|
| 352 |
if(nobj->surface.color.type!=GLU_INVALID_ENUM) |
| 353 |
{ |
| 354 |
color_s_knot->unified_knot=(GLfloat *)1; |
| 355 |
knot=color_s_knot->knot=nobj->surface.color.sknot; |
| 356 |
nknots=color_s_knot->nknots=nobj->surface.color.sknot_count; |
| 357 |
order=color_s_knot->order=nobj->surface.color.sorder; |
| 358 |
color_s_knot->delta_nknots=0; |
| 359 |
t_min=color_s_knot->t_min=order-1; |
| 360 |
t_max=color_s_knot->t_max=nknots-order; |
| 361 |
if(fabs(knot[t_min]-knot[t_max])<EPSILON) |
| 362 |
{ |
| 363 |
call_user_error(nobj,GLU_NURBS_ERROR3); |
| 364 |
return GLU_ERROR; |
| 365 |
} |
| 366 |
if(fabs(knot[0]-knot[t_min])<EPSILON) |
| 367 |
{ |
| 368 |
/* knot open at beggining */ |
| 369 |
color_s_knot->open_at_begin=GL_TRUE; |
| 370 |
} |
| 371 |
else |
| 372 |
color_s_knot->open_at_begin=GL_FALSE; |
| 373 |
if(fabs(knot[t_max]-knot[nknots-1])<EPSILON) |
| 374 |
{ |
| 375 |
/* knot open at end */ |
| 376 |
color_s_knot->open_at_end=GL_TRUE; |
| 377 |
} |
| 378 |
else |
| 379 |
color_s_knot->open_at_end=GL_FALSE; |
| 380 |
color_t_knot->unified_knot=(GLfloat *)1; |
| 381 |
knot=color_t_knot->knot=nobj->surface.color.tknot; |
| 382 |
nknots=color_t_knot->nknots=nobj->surface.color.tknot_count; |
| 383 |
order=color_t_knot->order=nobj->surface.color.torder; |
| 384 |
color_t_knot->delta_nknots=0; |
| 385 |
t_min=color_t_knot->t_min=order-1; |
| 386 |
t_max=color_t_knot->t_max=nknots-order; |
| 387 |
if(fabs(knot[t_min]-knot[t_max])<EPSILON) |
| 388 |
{ |
| 389 |
call_user_error(nobj,GLU_NURBS_ERROR3); |
| 390 |
return GLU_ERROR; |
| 391 |
} |
| 392 |
if(fabs(knot[0]-knot[t_min])<EPSILON) |
| 393 |
{ |
| 394 |
/* knot open at beggining */ |
| 395 |
color_t_knot->open_at_begin=GL_TRUE; |
| 396 |
} |
| 397 |
else |
| 398 |
color_t_knot->open_at_begin=GL_FALSE; |
| 399 |
if(fabs(knot[t_max]-knot[nknots-1])<EPSILON) |
| 400 |
{ |
| 401 |
/* knot open at end */ |
| 402 |
color_t_knot->open_at_end=GL_TRUE; |
| 403 |
} |
| 404 |
else |
| 405 |
color_t_knot->open_at_end=GL_FALSE; |
| 406 |
} |
| 407 |
else |
| 408 |
{ |
| 409 |
color_s_knot->unified_knot=NULL; |
| 410 |
color_t_knot->unified_knot=NULL; |
| 411 |
} |
| 412 |
|
| 413 |
if(nobj->surface.normal.type!=GLU_INVALID_ENUM) |
| 414 |
{ |
| 415 |
normal_s_knot->unified_knot=(GLfloat *)1; |
| 416 |
knot=normal_s_knot->knot=nobj->surface.normal.sknot; |
| 417 |
nknots=normal_s_knot->nknots=nobj->surface.normal.sknot_count; |
| 418 |
order=normal_s_knot->order=nobj->surface.normal.sorder; |
| 419 |
normal_s_knot->delta_nknots=0; |
| 420 |
t_min=normal_s_knot->t_min=order-1; |
| 421 |
t_max=normal_s_knot->t_max=nknots-order; |
| 422 |
if(fabs(knot[t_min]-knot[t_max])<EPSILON) |
| 423 |
{ |
| 424 |
call_user_error(nobj,GLU_NURBS_ERROR3); |
| 425 |
return GLU_ERROR; |
| 426 |
} |
| 427 |
if(fabs(knot[0]-knot[t_min])<EPSILON) |
| 428 |
{ |
| 429 |
/* knot open at beggining */ |
| 430 |
normal_s_knot->open_at_begin=GL_TRUE; |
| 431 |
} |
| 432 |
else |
| 433 |
normal_s_knot->open_at_begin=GL_FALSE; |
| 434 |
if(fabs(knot[t_max]-knot[nknots-1])<EPSILON) |
| 435 |
{ |
| 436 |
/* knot open at end */ |
| 437 |
normal_s_knot->open_at_end=GL_TRUE; |
| 438 |
} |
| 439 |
else |
| 440 |
normal_s_knot->open_at_end=GL_FALSE; |
| 441 |
normal_t_knot->unified_knot=(GLfloat *)1; |
| 442 |
knot=normal_t_knot->knot=nobj->surface.normal.tknot; |
| 443 |
nknots=normal_t_knot->nknots=nobj->surface.normal.tknot_count; |
| 444 |
order=normal_t_knot->order=nobj->surface.normal.torder; |
| 445 |
normal_t_knot->delta_nknots=0; |
| 446 |
t_min=normal_t_knot->t_min=order-1; |
| 447 |
t_max=normal_t_knot->t_max=nknots-order; |
| 448 |
if(fabs(knot[t_min]-knot[t_max])<EPSILON) |
| 449 |
{ |
| 450 |
call_user_error(nobj,GLU_NURBS_ERROR3); |
| 451 |
return GLU_ERROR; |
| 452 |
} |
| 453 |
if(fabs(knot[0]-knot[t_min])<EPSILON) |
| 454 |
{ |
| 455 |
/* knot open at beggining */ |
| 456 |
normal_t_knot->open_at_begin=GL_TRUE; |
| 457 |
} |
| 458 |
else |
| 459 |
normal_t_knot->open_at_begin=GL_FALSE; |
| 460 |
if(fabs(knot[t_max]-knot[nknots-1])<EPSILON) |
| 461 |
{ |
| 462 |
/* knot open at end */ |
| 463 |
normal_t_knot->open_at_end=GL_TRUE; |
| 464 |
} |
| 465 |
else |
| 466 |
normal_t_knot->open_at_end=GL_FALSE; |
| 467 |
} |
| 468 |
else |
| 469 |
{ |
| 470 |
normal_s_knot->unified_knot=NULL; |
| 471 |
normal_t_knot->unified_knot=NULL; |
| 472 |
} |
| 473 |
|
| 474 |
if(nobj->surface.texture.type!=GLU_INVALID_ENUM) |
| 475 |
{ |
| 476 |
texture_s_knot->unified_knot=(GLfloat *)1; |
| 477 |
knot=texture_s_knot->knot=nobj->surface.texture.sknot; |
| 478 |
nknots=texture_s_knot->nknots=nobj->surface.texture.sknot_count; |
| 479 |
order=texture_s_knot->order=nobj->surface.texture.sorder; |
| 480 |
texture_s_knot->delta_nknots=0; |
| 481 |
t_min=texture_s_knot->t_min=order-1; |
| 482 |
t_max=texture_s_knot->t_max=nknots-order; |
| 483 |
if(fabs(knot[t_min]-knot[t_max])<EPSILON) |
| 484 |
{ |
| 485 |
call_user_error(nobj,GLU_NURBS_ERROR3); |
| 486 |
return GLU_ERROR; |
| 487 |
} |
| 488 |
if(fabs(knot[0]-knot[t_min])<EPSILON) |
| 489 |
{ |
| 490 |
/* knot open at beggining */ |
| 491 |
texture_s_knot->open_at_begin=GL_TRUE; |
| 492 |
} |
| 493 |
else |
| 494 |
texture_s_knot->open_at_begin=GL_FALSE; |
| 495 |
if(fabs(knot[t_max]-knot[nknots-1])<EPSILON) |
| 496 |
{ |
| 497 |
/* knot open at end */ |
| 498 |
texture_s_knot->open_at_end=GL_TRUE; |
| 499 |
} |
| 500 |
else |
| 501 |
texture_s_knot->open_at_end=GL_FALSE; |
| 502 |
texture_t_knot->unified_knot=(GLfloat *)1; |
| 503 |
knot=texture_t_knot->knot=nobj->surface.texture.tknot; |
| 504 |
nknots=texture_t_knot->nknots=nobj->surface.texture.tknot_count; |
| 505 |
order=texture_t_knot->order=nobj->surface.texture.torder; |
| 506 |
texture_t_knot->delta_nknots=0; |
| 507 |
t_min=texture_t_knot->t_min=order-1; |
| 508 |
t_max=texture_t_knot->t_max=nknots-order; |
| 509 |
if(fabs(knot[t_min]-knot[t_max])<EPSILON) |
| 510 |
{ |
| 511 |
call_user_error(nobj,GLU_NURBS_ERROR3); |
| 512 |
return GLU_ERROR; |
| 513 |
} |
| 514 |
if(fabs(knot[0]-knot[t_min])<EPSILON) |
| 515 |
{ |
| 516 |
/* knot open at beggining */ |
| 517 |
texture_t_knot->open_at_begin=GL_TRUE; |
| 518 |
} |
| 519 |
else |
| 520 |
texture_t_knot->open_at_begin=GL_FALSE; |
| 521 |
if(fabs(knot[t_max]-knot[nknots-1])<EPSILON) |
| 522 |
{ |
| 523 |
/* knot open at end */ |
| 524 |
texture_t_knot->open_at_end=GL_TRUE; |
| 525 |
} |
| 526 |
else |
| 527 |
texture_t_knot->open_at_end=GL_FALSE; |
| 528 |
} |
| 529 |
else |
| 530 |
{ |
| 531 |
texture_s_knot->unified_knot=NULL; |
| 532 |
texture_t_knot->unified_knot=NULL; |
| 533 |
} |
| 534 |
return GLU_NO_ERROR; |
| 535 |
} |
| 536 |
|
| 537 |
void |
| 538 |
free_new_ctrl(new_ctrl_type *p) |
| 539 |
{ |
| 540 |
if(p->geom_ctrl) |
| 541 |
free(p->geom_ctrl); |
| 542 |
if(p->geom_offsets) |
| 543 |
free(p->geom_offsets); |
| 544 |
if(p->color_ctrl) |
| 545 |
{ |
| 546 |
free(p->color_ctrl); |
| 547 |
if(p->color_offsets) |
| 548 |
free(p->color_offsets); |
| 549 |
} |
| 550 |
if(p->normal_ctrl) |
| 551 |
{ |
| 552 |
free(p->normal_ctrl); |
| 553 |
if(p->normal_offsets) |
| 554 |
free(p->normal_offsets); |
| 555 |
} |
| 556 |
if(p->texture_ctrl) |
| 557 |
{ |
| 558 |
free(p->texture_ctrl); |
| 559 |
if(p->texture_offsets) |
| 560 |
free(p->texture_offsets); |
| 561 |
} |
| 562 |
} |
| 563 |
|
| 564 |
/* convert surfaces - geometry and possible attribute ones into equivalent */ |
| 565 |
/* sequence of adjacent Bezier patches */ |
| 566 |
static GLenum |
| 567 |
convert_surfs(GLUnurbsObj *nobj, new_ctrl_type *new_ctrl) |
| 568 |
{ |
| 569 |
knot_str_type geom_s_knot,color_s_knot,normal_s_knot,texture_s_knot; |
| 570 |
knot_str_type geom_t_knot,color_t_knot,normal_t_knot,texture_t_knot; |
| 571 |
GLenum err; |
| 572 |
|
| 573 |
if((err=fill_knot_structures(nobj,&geom_s_knot,&geom_t_knot, |
| 574 |
&color_s_knot,&color_t_knot,&normal_s_knot,&normal_t_knot, |
| 575 |
&texture_s_knot,&texture_t_knot)) !=GLU_NO_ERROR) |
| 576 |
{ |
| 577 |
return err; |
| 578 |
} |
| 579 |
/* unify knots - all knots should have the same working range */ |
| 580 |
if((err=select_knot_working_range(nobj,&geom_s_knot,&color_s_knot, |
| 581 |
&normal_s_knot,&texture_s_knot)) !=GLU_NO_ERROR) |
| 582 |
{ |
| 583 |
call_user_error(nobj,err); |
| 584 |
return err; |
| 585 |
} |
| 586 |
if((err=select_knot_working_range(nobj,&geom_t_knot,&color_t_knot, |
| 587 |
&normal_t_knot,&texture_t_knot)) !=GLU_NO_ERROR) |
| 588 |
{ |
| 589 |
free_unified_knots(&geom_s_knot,&color_s_knot,&normal_s_knot, |
| 590 |
&texture_s_knot); |
| 591 |
call_user_error(nobj,err); |
| 592 |
return err; |
| 593 |
} |
| 594 |
|
| 595 |
/* convert the geometry surface */ |
| 596 |
nobj->surface.geom.dim=get_surface_dim(nobj->surface.geom.type); |
| 597 |
if((err=convert_surf(&geom_s_knot,&geom_t_knot,&(nobj->surface.geom), |
| 598 |
&(new_ctrl->geom_ctrl),&(new_ctrl->geom_s_pt_cnt), |
| 599 |
&(new_ctrl->geom_t_pt_cnt)))!=GLU_NO_ERROR) |
| 600 |
{ |
| 601 |
free_unified_knots(&geom_s_knot,&color_s_knot,&normal_s_knot, |
| 602 |
&texture_s_knot); |
| 603 |
free_unified_knots(&geom_t_knot,&color_t_knot,&normal_t_knot, |
| 604 |
&texture_t_knot); |
| 605 |
call_user_error(nobj,err); |
| 606 |
return err; |
| 607 |
} |
| 608 |
/* if additional attributive surfaces are given convert them as well */ |
| 609 |
if(color_s_knot.unified_knot) |
| 610 |
{ |
| 611 |
nobj->surface.color.dim=get_surface_dim(nobj->surface.color.type); |
| 612 |
if((err=convert_surf(&color_s_knot,&color_t_knot,&(nobj->surface.color), |
| 613 |
&(new_ctrl->color_ctrl),&(new_ctrl->color_s_pt_cnt), |
| 614 |
&(new_ctrl->color_t_pt_cnt)))!=GLU_NO_ERROR) |
| 615 |
{ |
| 616 |
free_unified_knots(&color_s_knot,&color_s_knot,&normal_s_knot, |
| 617 |
&texture_s_knot); |
| 618 |
free_unified_knots(&color_t_knot,&color_t_knot,&normal_t_knot, |
| 619 |
&texture_t_knot); |
| 620 |
free_new_ctrl(new_ctrl); |
| 621 |
call_user_error(nobj,err); |
| 622 |
return err; |
| 623 |
} |
| 624 |
} |
| 625 |
if(normal_s_knot.unified_knot) |
| 626 |
{ |
| 627 |
nobj->surface.normal.dim=get_surface_dim(nobj->surface.normal.type); |
| 628 |
if((err=convert_surf(&normal_s_knot,&normal_t_knot, |
| 629 |
&(nobj->surface.normal), |
| 630 |
&(new_ctrl->normal_ctrl),&(new_ctrl->normal_s_pt_cnt), |
| 631 |
&(new_ctrl->normal_t_pt_cnt)))!=GLU_NO_ERROR) |
| 632 |
{ |
| 633 |
free_unified_knots(&normal_s_knot,&normal_s_knot,&normal_s_knot, |
| 634 |
&texture_s_knot); |
| 635 |
free_unified_knots(&normal_t_knot,&normal_t_knot,&normal_t_knot, |
| 636 |
&texture_t_knot); |
| 637 |
free_new_ctrl(new_ctrl); |
| 638 |
call_user_error(nobj,err); |
| 639 |
return err; |
| 640 |
} |
| 641 |
} |
| 642 |
if(texture_s_knot.unified_knot) |
| 643 |
{ |
| 644 |
nobj->surface.texture.dim=get_surface_dim(nobj->surface.texture.type); |
| 645 |
if((err=convert_surf(&texture_s_knot,&texture_t_knot, |
| 646 |
&(nobj->surface.texture), |
| 647 |
&(new_ctrl->texture_ctrl),&(new_ctrl->texture_s_pt_cnt), |
| 648 |
&(new_ctrl->texture_t_pt_cnt)))!=GLU_NO_ERROR) |
| 649 |
{ |
| 650 |
free_unified_knots(&texture_s_knot,&texture_s_knot,&texture_s_knot, |
| 651 |
&texture_s_knot); |
| 652 |
free_unified_knots(&texture_t_knot,&texture_t_knot,&texture_t_knot, |
| 653 |
&texture_t_knot); |
| 654 |
free_new_ctrl(new_ctrl); |
| 655 |
call_user_error(nobj,err); |
| 656 |
return err; |
| 657 |
} |
| 658 |
} |
| 659 |
return GLU_NO_ERROR; |
| 660 |
} |
| 661 |
|
| 662 |
/* tesselate the "boundary" Bezier edge strips */ |
| 663 |
void |
| 664 |
tesselate_strip_t_line(GLint top_start,GLint top_end,GLint top_z, |
| 665 |
GLint bottom_start,GLint bottom_end,GLint bottom_z,GLint bottom_domain) |
| 666 |
{ |
| 667 |
GLint top_cnt,bottom_cnt,tri_cnt,k; |
| 668 |
GLint direction; |
| 669 |
|
| 670 |
top_cnt=top_end-top_start; |
| 671 |
direction= (top_cnt>=0 ? 1: -1); |
| 672 |
bottom_cnt=bottom_end-bottom_start; |
| 673 |
glBegin(GL_LINES); |
| 674 |
while(top_cnt) |
| 675 |
{ |
| 676 |
if(bottom_cnt) |
| 677 |
tri_cnt=top_cnt/bottom_cnt; |
| 678 |
else |
| 679 |
tri_cnt=abs(top_cnt); |
| 680 |
for(k=0;k<=tri_cnt;k++ , top_start+=direction) |
| 681 |
{ |
| 682 |
glEvalCoord2f((GLfloat)bottom_z/bottom_domain, |
| 683 |
(GLfloat)bottom_start/bottom_domain); |
| 684 |
glEvalPoint2(top_z,top_start); |
| 685 |
} |
| 686 |
if(bottom_cnt) |
| 687 |
{ |
| 688 |
glEvalCoord2f((GLfloat)bottom_z/bottom_domain, |
| 689 |
(GLfloat)bottom_start/bottom_domain); |
| 690 |
bottom_start+=direction; |
| 691 |
top_start-=direction; |
| 692 |
glEvalCoord2f((GLfloat)bottom_z/bottom_domain, |
| 693 |
(GLfloat)bottom_start/bottom_domain); |
| 694 |
glEvalCoord2f((GLfloat)bottom_z/bottom_domain, |
| 695 |
(GLfloat)bottom_start/bottom_domain); |
| 696 |
glEvalPoint2(top_z,top_start); |
| 697 |
} |
| 698 |
top_cnt-=direction*tri_cnt; |
| 699 |
bottom_cnt-=direction; |
| 700 |
} |
| 701 |
glEnd(); |
| 702 |
} |
| 703 |
|
| 704 |
void |
| 705 |
tesselate_strip_t_fill(GLint top_start,GLint top_end,GLint top_z, |
| 706 |
GLint bottom_start,GLint bottom_end,GLint bottom_z,GLint bottom_domain) |
| 707 |
{ |
| 708 |
GLint top_cnt,bottom_cnt,tri_cnt,k; |
| 709 |
GLint direction; |
| 710 |
|
| 711 |
top_cnt=top_end-top_start; |
| 712 |
direction= (top_cnt>=0 ? 1: -1); |
| 713 |
bottom_cnt=bottom_end-bottom_start; |
| 714 |
while(top_cnt) |
| 715 |
{ |
| 716 |
if(bottom_cnt) |
| 717 |
tri_cnt=top_cnt/bottom_cnt; |
| 718 |
else |
| 719 |
tri_cnt=abs(top_cnt); |
| 720 |
glBegin(GL_TRIANGLE_FAN); |
| 721 |
glEvalCoord2f((GLfloat)bottom_z/bottom_domain, |
| 722 |
(GLfloat)bottom_start/bottom_domain); |
| 723 |
for(k=0;k<=tri_cnt;k++ , top_start+=direction) |
| 724 |
glEvalPoint2(top_z,top_start); |
| 725 |
if(bottom_cnt) |
| 726 |
{ |
| 727 |
bottom_start+=direction; |
| 728 |
top_start-=direction; |
| 729 |
glEvalCoord2f((GLfloat)bottom_z/bottom_domain, |
| 730 |
(GLfloat)bottom_start/bottom_domain); |
| 731 |
} |
| 732 |
glEnd(); |
| 733 |
top_cnt-=direction*tri_cnt; |
| 734 |
bottom_cnt-=direction; |
| 735 |
} |
| 736 |
} |
| 737 |
|
| 738 |
void |
| 739 |
tesselate_strip_t(GLenum display_mode, GLint top_start, GLint top_end, |
| 740 |
GLint top_z, GLint bottom_start, GLint bottom_end, GLint bottom_z, |
| 741 |
GLint bottom_domain) |
| 742 |
{ |
| 743 |
if(display_mode==GL_FILL) |
| 744 |
tesselate_strip_t_fill(top_start,top_end,top_z,bottom_start, |
| 745 |
bottom_end,bottom_z,bottom_domain); |
| 746 |
else |
| 747 |
tesselate_strip_t_line(top_start,top_end,top_z,bottom_start, |
| 748 |
bottom_end,bottom_z,bottom_domain); |
| 749 |
} |
| 750 |
|
| 751 |
|
| 752 |
void |
| 753 |
tesselate_strip_s_fill(GLint top_start, GLint top_end, GLint top_z, |
| 754 |
GLint bottom_start, GLint bottom_end, GLint bottom_z, GLfloat bottom_domain) |
| 755 |
{ |
| 756 |
GLint top_cnt,bottom_cnt,tri_cnt,k; |
| 757 |
GLint direction; |
| 758 |
|
| 759 |
top_cnt=top_end-top_start; |
| 760 |
direction= (top_cnt>=0 ? 1: -1); |
| 761 |
bottom_cnt=bottom_end-bottom_start; |
| 762 |
while(top_cnt) |
| 763 |
{ |
| 764 |
if(bottom_cnt) |
| 765 |
tri_cnt=top_cnt/bottom_cnt; |
| 766 |
else |
| 767 |
tri_cnt=abs(top_cnt); |
| 768 |
glBegin(GL_TRIANGLE_FAN); |
| 769 |
glEvalCoord2f((GLfloat)bottom_start/bottom_domain, |
| 770 |
(GLfloat)bottom_z/bottom_domain); |
| 771 |
for(k=0;k<=tri_cnt;k++ , top_start+=direction) |
| 772 |
glEvalPoint2(top_start,top_z); |
| 773 |
if(bottom_cnt) |
| 774 |
{ |
| 775 |
bottom_start+=direction; |
| 776 |
top_start-=direction; |
| 777 |
glEvalCoord2f((GLfloat)bottom_start/bottom_domain, |
| 778 |
(GLfloat)bottom_z/bottom_domain); |
| 779 |
} |
| 780 |
glEnd(); |
| 781 |
top_cnt-=direction*tri_cnt; |
| 782 |
bottom_cnt-=direction; |
| 783 |
} |
| 784 |
} |
| 785 |
|
| 786 |
void |
| 787 |
tesselate_strip_s_line(GLint top_start, GLint top_end, GLint top_z, |
| 788 |
GLint bottom_start, GLint bottom_end, GLint bottom_z, GLfloat bottom_domain) |
| 789 |
{ |
| 790 |
GLint top_cnt,bottom_cnt,tri_cnt,k; |
| 791 |
GLint direction; |
| 792 |
|
| 793 |
top_cnt=top_end-top_start; |
| 794 |
direction= (top_cnt>=0 ? 1: -1); |
| 795 |
bottom_cnt=bottom_end-bottom_start; |
| 796 |
glBegin(GL_LINES); |
| 797 |
while(top_cnt) |
| 798 |
{ |
| 799 |
if(bottom_cnt) |
| 800 |
tri_cnt=top_cnt/bottom_cnt; |
| 801 |
else |
| 802 |
tri_cnt=abs(top_cnt); |
| 803 |
for(k=0;k<=tri_cnt;k++ , top_start+=direction) |
| 804 |
{ |
| 805 |
glEvalCoord2f((GLfloat)bottom_start/bottom_domain, |
| 806 |
(GLfloat)bottom_z/bottom_domain); |
| 807 |
glEvalPoint2(top_start,top_z); |
| 808 |
} |
| 809 |
if(bottom_cnt) |
| 810 |
{ |
| 811 |
glEvalCoord2f((GLfloat)bottom_start/bottom_domain, |
| 812 |
(GLfloat)bottom_z/bottom_domain); |
| 813 |
bottom_start+=direction; |
| 814 |
top_start-=direction; |
| 815 |
glEvalCoord2f((GLfloat)bottom_start/bottom_domain, |
| 816 |
(GLfloat)bottom_z/bottom_domain); |
| 817 |
glEvalPoint2(top_start,top_z); |
| 818 |
glEvalCoord2f((GLfloat)bottom_start/bottom_domain, |
| 819 |
(GLfloat)bottom_z/bottom_domain); |
| 820 |
} |
| 821 |
top_cnt-=direction*tri_cnt; |
| 822 |
bottom_cnt-=direction; |
| 823 |
} |
| 824 |
glEnd(); |
| 825 |
} |
| 826 |
|
| 827 |
void |
| 828 |
tesselate_strip_s(GLenum display_mode, GLint top_start, GLint top_end, |
| 829 |
GLint top_z, GLint bottom_start, GLint bottom_end, GLint bottom_z, |
| 830 |
GLfloat bottom_domain) |
| 831 |
{ |
| 832 |
if(display_mode==GL_FILL) |
| 833 |
tesselate_strip_s_fill(top_start,top_end,top_z,bottom_start, |
| 834 |
bottom_end,bottom_z,bottom_domain); |
| 835 |
else |
| 836 |
tesselate_strip_s_line(top_start,top_end,top_z,bottom_start, |
| 837 |
bottom_end,bottom_z,bottom_domain); |
| 838 |
} |
| 839 |
|
| 840 |
void |
| 841 |
tesselate_bottom_left_corner(GLenum display_mode, GLfloat s_1, GLfloat t_1) |
| 842 |
{ |
| 843 |
if(display_mode==GL_FILL) |
| 844 |
{ |
| 845 |
glBegin(GL_TRIANGLE_FAN); |
| 846 |
glEvalPoint2(1,1); |
| 847 |
glEvalCoord2f(s_1,0.0); |
| 848 |
glEvalCoord2f(0.0,0.0); |
| 849 |
glEvalCoord2f(0.0,t_1); |
| 850 |
} |
| 851 |
else |
| 852 |
{ |
| 853 |
glBegin(GL_LINES); |
| 854 |
glEvalCoord2f(0.0,0.0); |
| 855 |
glEvalCoord2f(0.0,t_1); |
| 856 |
glEvalCoord2f(0.0,0.0); |
| 857 |
glEvalPoint2(1,1); |
| 858 |
glEvalCoord2f(0.0,0.0); |
| 859 |
glEvalCoord2f(s_1,0.0); |
| 860 |
} |
| 861 |
glEnd(); |
| 862 |
} |
| 863 |
|
| 864 |
void |
| 865 |
tesselate_bottom_right_corner(GLenum display_mode, GLint v_top,GLint v_bottom, |
| 866 |
GLfloat s_1, GLfloat t_1) |
| 867 |
{ |
| 868 |
if(display_mode==GL_FILL) |
| 869 |
{ |
| 870 |
glBegin(GL_TRIANGLE_FAN); |
| 871 |
glEvalPoint2(1,v_top); |
| 872 |
glEvalCoord2f(0.0,v_bottom*t_1); |
| 873 |
glEvalCoord2f(0.0,(v_bottom+1)*t_1); |
| 874 |
glEvalCoord2f(s_1,(v_bottom+1)*t_1); |
| 875 |
} |
| 876 |
else |
| 877 |
{ |
| 878 |
glBegin(GL_LINES); |
| 879 |
glEvalCoord2f(0.0,(v_bottom+1)*t_1); |
| 880 |
glEvalPoint2(1,v_top); |
| 881 |
glEvalCoord2f(0.0,(v_bottom+1)*t_1); |
| 882 |
glEvalCoord2f(0.0,v_bottom*t_1); |
| 883 |
glEvalCoord2f(0.0,(v_bottom+1)*t_1); |
| 884 |
glEvalCoord2f(s_1,(v_bottom+1)*t_1); |
| 885 |
} |
| 886 |
glEnd(); |
| 887 |
} |
| 888 |
|
| 889 |
void |
| 890 |
tesselate_top_left_corner(GLenum display_mode, GLint u_right, GLint u_left, |
| 891 |
GLfloat s_1, GLfloat t_1) |
| 892 |
{ |
| 893 |
if(display_mode==GL_FILL) |
| 894 |
{ |
| 895 |
glBegin(GL_TRIANGLE_FAN); |
| 896 |
glEvalPoint2(u_right,1); |
| 897 |
glEvalCoord2f((u_left+1)*s_1,t_1); |
| 898 |
glEvalCoord2f((u_left+1)*s_1,0.0); |
| 899 |
glEvalCoord2f(u_left*s_1,0.0); |
| 900 |
} |
| 901 |
else |
| 902 |
{ |
| 903 |
glBegin(GL_LINES); |
| 904 |
glEvalCoord2f((u_left+1)*s_1,0.0); |
| 905 |
glEvalPoint2(u_right,1); |
| 906 |
glEvalCoord2f((u_left+1)*s_1,0.0); |
| 907 |
glEvalCoord2f(u_left*s_1,0.0); |
| 908 |
glEvalCoord2f((u_left+1)*s_1,0.0); |
| 909 |
glEvalCoord2f((u_left+1)*s_1,t_1); |
| 910 |
} |
| 911 |
glEnd(); |
| 912 |
} |
| 913 |
|
| 914 |
void |
| 915 |
tesselate_top_right_corner(GLenum display_mode, GLint u_left, GLint v_bottom, |
| 916 |
GLint u_right, GLint v_top, GLfloat s_1, GLfloat t_1) |
| 917 |
{ |
| 918 |
if(display_mode==GL_FILL) |
| 919 |
{ |
| 920 |
glBegin(GL_TRIANGLE_FAN); |
| 921 |
glEvalPoint2(u_left,v_bottom); |
| 922 |
glEvalCoord2f((u_right-1)*s_1,v_top*t_1); |
| 923 |
glEvalCoord2f(u_right*s_1,v_top*t_1); |
| 924 |
glEvalCoord2f(u_right*s_1,(v_top-1)*t_1); |
| 925 |
} |
| 926 |
else |
| 927 |
{ |
| 928 |
glBegin(GL_LINES); |
| 929 |
glEvalCoord2f(u_right*s_1,v_top*t_1); |
| 930 |
glEvalPoint2(u_left,v_bottom); |
| 931 |
glEvalCoord2f(u_right*s_1,v_top*t_1); |
| 932 |
glEvalCoord2f(u_right*s_1,(v_top-1)*t_1); |
| 933 |
glEvalCoord2f(u_right*s_1,v_top*t_1); |
| 934 |
glEvalCoord2f((u_right-1)*s_1,v_top*t_1); |
| 935 |
} |
| 936 |
glEnd(); |
| 937 |
} |
| 938 |
|
| 939 |
/* do mesh mapping of Bezier */ |
| 940 |
static void |
| 941 |
nurbs_map_bezier(GLenum display_mode,GLint *sfactors,GLint *tfactors, |
| 942 |
GLint s_bezier_cnt, GLint t_bezier_cnt, GLint s, GLint t) |
| 943 |
{ |
| 944 |
GLint top,bottom,right,left; |
| 945 |
|
| 946 |
|
| 947 |
if(s==0) |
| 948 |
{ |
| 949 |
top=*(tfactors+t*3); |
| 950 |
bottom=*(tfactors+t*3+1); |
| 951 |
} |
| 952 |
else |
| 953 |
if(s==s_bezier_cnt-1) |
| 954 |
{ |
| 955 |
top=*(tfactors+t*3+2); |
| 956 |
bottom=*(tfactors+t*3); |
| 957 |
} |
| 958 |
else |
| 959 |
{ |
| 960 |
top=bottom=*(tfactors+t*3); |
| 961 |
} |
| 962 |
if(t==0) |
| 963 |
{ |
| 964 |
left=*(sfactors+s*3+1); |
| 965 |
right=*(sfactors+s*3); |
| 966 |
} |
| 967 |
else |
| 968 |
if(t==t_bezier_cnt-1) |
| 969 |
{ |
| 970 |
left=*(sfactors+s*3); |
| 971 |
right=*(sfactors+s*3+2); |
| 972 |
} |
| 973 |
else |
| 974 |
{ |
| 975 |
left=right=*(sfactors+s*3); |
| 976 |
} |
| 977 |
|
| 978 |
if(top>bottom) |
| 979 |
{ |
| 980 |
if(left<right) |
| 981 |
{ |
| 982 |
glMapGrid2f(right, 0.0, 1.0, top, 0.0, 1.0); |
| 983 |
glEvalMesh2(display_mode,1,right, 1, top); |
| 984 |
tesselate_strip_s(display_mode,1,right,1,1,left,0,(GLfloat)left); |
| 985 |
tesselate_bottom_left_corner(display_mode,(GLfloat)(1.0/left), |
| 986 |
(GLfloat)(1.0/bottom)); |
| 987 |
/* tesselate_strip_t(display_mode,1,top,1,1,bottom,0,(GLfloat)bottom);*/ |
| 988 |
tesselate_strip_t(display_mode,top,1,1,bottom,1,0,(GLfloat)bottom); |
| 989 |
} |
| 990 |
else |
| 991 |
if(left==right) |
| 992 |
{ |
| 993 |
glMapGrid2f(right, 0.0, 1.0, top, 0.0, 1.0); |
| 994 |
glEvalMesh2(display_mode,1,right, 0, top); |
| 995 |
/* tesselate_strip_t(display_mode,0,top,1,0,bottom,0,(GLfloat)bottom);*/ |
| 996 |
tesselate_strip_t(display_mode,top,0,1,bottom,0,0,(GLfloat)bottom); |
| 997 |
} |
| 998 |
else |
| 999 |
{ |
| 1000 |
glMapGrid2f(left, 0.0, 1.0, top, 0.0, 1.0); |
| 1001 |
glEvalMesh2(display_mode,1,left, 0, top-1); |
| 1002 |
/* tesselate_strip_t(display_mode,0,top-1,1,0,bottom-1,0, |
| 1003 |
(GLfloat)bottom);*/ |
| 1004 |
tesselate_strip_t(display_mode,top-1,0,1,bottom-1,0,0, |
| 1005 |
(GLfloat)bottom); |
| 1006 |
tesselate_bottom_right_corner(display_mode,top-1,bottom-1, |
| 1007 |
(GLfloat)(1.0/right),(GLfloat)(1.0/bottom)); |
| 1008 |
/* tesselate_strip_s(display_mode,1,left,top-1,1,right,right, |
| 1009 |
(GLfloat)right);*/ |
| 1010 |
tesselate_strip_s(display_mode,left,1,top-1,right,1,right, |
| 1011 |
(GLfloat)right); |
| 1012 |
} |
| 1013 |
} |
| 1014 |
else |
| 1015 |
if(top==bottom) |
| 1016 |
{ |
| 1017 |
if(left<right) |
| 1018 |
{ |
| 1019 |
glMapGrid2f(right, 0.0, 1.0, top, 0.0, 1.0); |
| 1020 |
glEvalMesh2(display_mode,0,right, 1, top); |
| 1021 |
tesselate_strip_s(display_mode,0,right,1,0,left,0,(GLfloat)left); |
| 1022 |
} |
| 1023 |
else |
| 1024 |
if(left==right) |
| 1025 |
{ |
| 1026 |
glMapGrid2f(right, 0.0, 1.0, top, 0.0, 1.0); |
| 1027 |
glEvalMesh2(display_mode,0,right, 0, top); |
| 1028 |
} |
| 1029 |
else |
| 1030 |
{ |
| 1031 |
glMapGrid2f(left, 0.0, 1.0, top, 0.0, 1.0); |
| 1032 |
glEvalMesh2(display_mode,0,left, 0, top-1); |
| 1033 |
/* tesselate_strip_s(display_mode,0,left,top-1,0,right,right, |
| 1034 |
(GLfloat)right);*/ |
| 1035 |
tesselate_strip_s(display_mode,left,0,top-1,right,0,right, |
| 1036 |
(GLfloat)right); |
| 1037 |
} |
| 1038 |
} |
| 1039 |
else |
| 1040 |
{ |
| 1041 |
if(left<right) |
| 1042 |
{ |
| 1043 |
glMapGrid2f(right, 0.0, 1.0, bottom, 0.0, 1.0); |
| 1044 |
glEvalMesh2(display_mode,0,right-1, 1, bottom); |
| 1045 |
tesselate_strip_s(display_mode,0,right-1,1,0,left-1,0, |
| 1046 |
(GLfloat)left); |
| 1047 |
tesselate_top_left_corner(display_mode,right-1,left-1, |
| 1048 |
(GLfloat)(1.0/left),(GLfloat)(1.0/top)); |
| 1049 |
tesselate_strip_t(display_mode,1,bottom,right-1,1,top,top, |
| 1050 |
(GLfloat)top); |
| 1051 |
} |
| 1052 |
else |
| 1053 |
if(left==right) |
| 1054 |
{ |
| 1055 |
glMapGrid2f(right, 0.0, 1.0, bottom, 0.0, 1.0); |
| 1056 |
glEvalMesh2(display_mode,0,right-1, 0, bottom); |
| 1057 |
tesselate_strip_t(display_mode,0,bottom,right-1,0,top,top, |
| 1058 |
(GLfloat)top); |
| 1059 |
} |
| 1060 |
else |
| 1061 |
{ |
| 1062 |
glMapGrid2f(left, 0.0, 1.0, bottom, 0.0, 1.0); |
| 1063 |
glEvalMesh2(display_mode,0,left-1, 0, bottom-1); |
| 1064 |
tesselate_strip_t(display_mode,0,bottom-1,left-1,0,top-1,top, |
| 1065 |
(GLfloat)top); |
| 1066 |
tesselate_top_right_corner(display_mode,left-1,bottom-1,right,top, |
| 1067 |
(GLfloat)(1.0/right),(GLfloat)(1.0/top)); |
| 1068 |
/* tesselate_strip_s(display_mode,0,left-1,bottom-1,0,right-1,right, |
| 1069 |
(GLfloat)right);*/ |
| 1070 |
tesselate_strip_s(display_mode,left-1,0,bottom-1,right-1,0,right, |
| 1071 |
(GLfloat)right); |
| 1072 |
} |
| 1073 |
} |
| 1074 |
} |
| 1075 |
|
| 1076 |
/* draw NURBS surface in OUTLINE POLYGON mode */ |
| 1077 |
static void |
| 1078 |
draw_polygon_mode( GLenum display_mode, GLUnurbsObj *nobj, |
| 1079 |
new_ctrl_type *new_ctrl, GLint *sfactors, GLint *tfactors ) |
| 1080 |
{ |
| 1081 |
GLsizei offset; |
| 1082 |
GLint t_bezier_cnt,s_bezier_cnt; |
| 1083 |
GLboolean do_color,do_normal,do_texture; |
| 1084 |
GLint i,j; |
| 1085 |
|
| 1086 |
t_bezier_cnt=new_ctrl->t_bezier_cnt; |
| 1087 |
s_bezier_cnt=new_ctrl->s_bezier_cnt; |
| 1088 |
glEnable(nobj->surface.geom.type); |
| 1089 |
if(new_ctrl->color_ctrl) |
| 1090 |
{ |
| 1091 |
glEnable(nobj->surface.color.type); |
| 1092 |
do_color=GL_TRUE; |
| 1093 |
} |
| 1094 |
else |
| 1095 |
do_color=GL_FALSE; |
| 1096 |
if(new_ctrl->normal_ctrl) |
| 1097 |
{ |
| 1098 |
glEnable(nobj->surface.normal.type); |
| 1099 |
do_normal=GL_TRUE; |
| 1100 |
} |
| 1101 |
else |
| 1102 |
do_normal=GL_FALSE; |
| 1103 |
if(new_ctrl->texture_ctrl) |
| 1104 |
{ |
| 1105 |
glEnable(nobj->surface.texture.type); |
| 1106 |
do_texture=GL_TRUE; |
| 1107 |
} |
| 1108 |
else |
| 1109 |
do_texture=GL_FALSE; |
| 1110 |
for(j=0; j<s_bezier_cnt; j++) |
| 1111 |
{ |
| 1112 |
for(i=0; i<t_bezier_cnt; i++) |
| 1113 |
{ |
| 1114 |
offset=j*t_bezier_cnt + i; |
| 1115 |
if(fine_culling_test_3D(nobj,*(new_ctrl->geom_offsets + offset), |
| 1116 |
nobj->surface.geom.sorder,nobj->surface.geom.torder, |
| 1117 |
new_ctrl->geom_s_stride,new_ctrl->geom_t_stride, |
| 1118 |
nobj->surface.geom.dim)) |
| 1119 |
continue; |
| 1120 |
glMap2f(nobj->surface.geom.type,0.0,1.0,new_ctrl->geom_s_stride, |
| 1121 |
nobj->surface.geom.sorder,0.0,1.0,new_ctrl->geom_t_stride, |
| 1122 |
nobj->surface.geom.torder,*(new_ctrl->geom_offsets + offset)); |
| 1123 |
if(do_color) |
| 1124 |
{ |
| 1125 |
glMap2f(nobj->surface.color.type,0.0,1.0, |
| 1126 |
new_ctrl->color_s_stride,nobj->surface.color.sorder, |
| 1127 |
0.0,1.0,new_ctrl->color_t_stride,nobj->surface.color.torder, |
| 1128 |
*(new_ctrl->color_offsets + offset)); |
| 1129 |
} |
| 1130 |
if(do_normal) |
| 1131 |
{ |
| 1132 |
glMap2f(nobj->surface.normal.type,0.0,1.0, |
| 1133 |
new_ctrl->normal_s_stride,nobj->surface.normal.sorder, |
| 1134 |
0.0,1.0,new_ctrl->normal_t_stride, |
| 1135 |
nobj->surface.normal.torder, |
| 1136 |
*(new_ctrl->normal_offsets+offset)); |
| 1137 |
} |
| 1138 |
if(do_texture) |
| 1139 |
{ |
| 1140 |
glMap2f(nobj->surface.texture.type,0.0,1.0, |
| 1141 |
new_ctrl->texture_s_stride,nobj->surface.texture.sorder, |
| 1142 |
0.0,1.0,new_ctrl->texture_t_stride, |
| 1143 |
nobj->surface.texture.torder, |
| 1144 |
*(new_ctrl->texture_offsets+offset)); |
| 1145 |
} |
| 1146 |
/* glMapGrid2f(sfactors[j*3+0],0.0,1.0,tfactors[i*3+0],0.0,1.0); |
| 1147 |
glEvalMesh2(display_mode,0,sfactors[j*3+0],0,tfactors[i*3+0]);*/ |
| 1148 |
nurbs_map_bezier(display_mode,sfactors,tfactors,s_bezier_cnt, |
| 1149 |
t_bezier_cnt,j,i); |
| 1150 |
} |
| 1151 |
} |
| 1152 |
} |
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
/* draw NURBS surface in OUTLINE POLYGON mode */ |
| 1157 |
#if 0 |
| 1158 |
static void |
| 1159 |
draw_patch_mode( GLenum display_mode, GLUnurbsObj *nobj, |
| 1160 |
new_ctrl_type *new_ctrl, GLint *sfactors, GLint *tfactors ) |
| 1161 |
{ |
| 1162 |
GLsizei offset; |
| 1163 |
GLint t_bezier_cnt,s_bezier_cnt; |
| 1164 |
GLboolean do_color,do_normal,do_texture; |
| 1165 |
GLint i,j; |
| 1166 |
|
| 1167 |
t_bezier_cnt=new_ctrl->t_bezier_cnt; |
| 1168 |
s_bezier_cnt=new_ctrl->s_bezier_cnt; |
| 1169 |
glEnable(nobj->surface.geom.type); |
| 1170 |
if(new_ctrl->color_ctrl) |
| 1171 |
{ |
| 1172 |
glEnable(nobj->surface.color.type); |
| 1173 |
do_color=GL_TRUE; |
| 1174 |
} |
| 1175 |
else |
| 1176 |
do_color=GL_FALSE; |
| 1177 |
if(new_ctrl->normal_ctrl) |
| 1178 |
{ |
| 1179 |
glEnable(nobj->surface.normal.type); |
| 1180 |
do_normal=GL_TRUE; |
| 1181 |
} |
| 1182 |
else |
| 1183 |
do_normal=GL_FALSE; |
| 1184 |
if(new_ctrl->texture_ctrl) |
| 1185 |
{ |
| 1186 |
glEnable(nobj->surface.texture.type); |
| 1187 |
do_texture=GL_TRUE; |
| 1188 |
} |
| 1189 |
else |
| 1190 |
do_texture=GL_FALSE; |
| 1191 |
for(j=0; j<s_bezier_cnt; j++) |
| 1192 |
{ |
| 1193 |
for(i=0; i<t_bezier_cnt; i++) |
| 1194 |
{ |
| 1195 |
offset=j*t_bezier_cnt + i; |
| 1196 |
if(fine_culling_test_3D(nobj,*(new_ctrl->geom_offsets + offset), |
| 1197 |
nobj->surface.geom.sorder,nobj->surface.geom.torder, |
| 1198 |
new_ctrl->geom_s_stride,new_ctrl->geom_t_stride, |
| 1199 |
nobj->surface.geom.dim)) |
| 1200 |
continue; |
| 1201 |
glMap2f(nobj->surface.geom.type,0.0,1.0,new_ctrl->geom_s_stride, |
| 1202 |
nobj->surface.geom.sorder,0.0,1.0,new_ctrl->geom_t_stride, |
| 1203 |
nobj->surface.geom.torder,*(new_ctrl->geom_offsets + offset)); |
| 1204 |
if(do_color) |
| 1205 |
{ |
| 1206 |
glMap2f(nobj->surface.color.type,0.0,1.0, |
| 1207 |
new_ctrl->color_s_stride,nobj->surface.color.sorder, |
| 1208 |
0.0,1.0,new_ctrl->color_t_stride,nobj->surface.color.torder, |
| 1209 |
*(new_ctrl->color_offsets + offset)); |
| 1210 |
} |
| 1211 |
if(do_normal) |
| 1212 |
{ |
| 1213 |
glMap2f(nobj->surface.normal.type,0.0,1.0, |
| 1214 |
new_ctrl->normal_s_stride,nobj->surface.normal.sorder, |
| 1215 |
0.0,1.0,new_ctrl->normal_t_stride, |
| 1216 |
nobj->surface.normal.torder, |
| 1217 |
*(new_ctrl->normal_offsets+offset)); |
| 1218 |
} |
| 1219 |
if(do_texture) |
| 1220 |
{ |
| 1221 |
glMap2f(nobj->surface.texture.type,0.0,1.0, |
| 1222 |
new_ctrl->texture_s_stride,nobj->surface.texture.sorder, |
| 1223 |
0.0,1.0,new_ctrl->texture_t_stride, |
| 1224 |
nobj->surface.texture.torder, |
| 1225 |
*(new_ctrl->texture_offsets+offset)); |
| 1226 |
} |
| 1227 |
nurbs_map_bezier(display_mode,sfactors,tfactors,s_bezier_cnt, |
| 1228 |
t_bezier_cnt,i,j); |
| 1229 |
/* glMapGrid2f(sfactors[j],0.0,1.0,tfactors[i],0.0,1.0); |
| 1230 |
glEvalMesh2(display_mode,0,sfactors[j],0,tfactors[i]);*/ |
| 1231 |
} |
| 1232 |
} |
| 1233 |
} |
| 1234 |
#endif |
| 1235 |
|
| 1236 |
|
| 1237 |
|
| 1238 |
void |
| 1239 |
init_new_ctrl(new_ctrl_type *p) |
| 1240 |
{ |
| 1241 |
p->geom_ctrl=p->color_ctrl=p->normal_ctrl=p->texture_ctrl=NULL; |
| 1242 |
p->geom_offsets=p->color_offsets=p->normal_offsets=p->texture_offsets=NULL; |
| 1243 |
p->s_bezier_cnt=p->t_bezier_cnt=0; |
| 1244 |
} |
| 1245 |
|
| 1246 |
GLenum |
| 1247 |
augment_new_ctrl(GLUnurbsObj *nobj, new_ctrl_type *p) |
| 1248 |
{ |
| 1249 |
GLsizei offset_size; |
| 1250 |
GLint i,j; |
| 1251 |
|
| 1252 |
p->s_bezier_cnt=(p->geom_s_pt_cnt)/(nobj->surface.geom.sorder); |
| 1253 |
p->t_bezier_cnt=(p->geom_t_pt_cnt)/(nobj->surface.geom.torder); |
| 1254 |
offset_size=(p->s_bezier_cnt)*(p->t_bezier_cnt); |
| 1255 |
p->geom_t_stride=nobj->surface.geom.dim; |
| 1256 |
p->geom_s_stride=(p->geom_t_pt_cnt)*(nobj->surface.geom.dim); |
| 1257 |
p->color_t_stride=nobj->surface.color.dim; |
| 1258 |
p->color_s_stride=(p->color_t_pt_cnt)*(nobj->surface.color.dim); |
| 1259 |
p->normal_t_stride=nobj->surface.normal.dim; |
| 1260 |
p->normal_s_stride=(p->normal_t_pt_cnt)*(nobj->surface.normal.dim); |
| 1261 |
p->texture_t_stride=nobj->surface.texture.dim; |
| 1262 |
p->texture_s_stride=(p->texture_t_pt_cnt)*(nobj->surface.texture.dim); |
| 1263 |
if((p->geom_offsets=(GLfloat **)malloc(sizeof(GLfloat *)*offset_size))==NULL) |
| 1264 |
{ |
| 1265 |
call_user_error(nobj,GLU_OUT_OF_MEMORY); |
| 1266 |
return GLU_ERROR; |
| 1267 |
} |
| 1268 |
if(p->color_ctrl) |
| 1269 |
if((p->color_offsets=(GLfloat **)malloc(sizeof(GLfloat *)*offset_size))==NULL) |
| 1270 |
{ |
| 1271 |
free_new_ctrl(p); |
| 1272 |
call_user_error(nobj,GLU_OUT_OF_MEMORY); |
| 1273 |
return GLU_ERROR; |
| 1274 |
} |
| 1275 |
if(p->normal_ctrl) |
| 1276 |
if((p->normal_offsets=(GLfloat **)malloc(sizeof(GLfloat *)*offset_size))==NULL) |
| 1277 |
{ |
| 1278 |
free_new_ctrl(p); |
| 1279 |
call_user_error(nobj,GLU_OUT_OF_MEMORY); |
| 1280 |
return GLU_ERROR; |
| 1281 |
} |
| 1282 |
if(p->texture_ctrl) |
| 1283 |
if((p->texture_offsets=(GLfloat **)malloc(sizeof(GLfloat *)*offset_size))==NULL) |
| 1284 |
{ |
| 1285 |
free_new_ctrl(p); |
| 1286 |
call_user_error(nobj,GLU_OUT_OF_MEMORY); |
| 1287 |
return GLU_ERROR; |
| 1288 |
} |
| 1289 |
for(i=0;i<p->s_bezier_cnt;i++) |
| 1290 |
for(j=0;j<p->t_bezier_cnt;j++) |
| 1291 |
*(p->geom_offsets + i*(p->t_bezier_cnt) + j) = |
| 1292 |
p->geom_ctrl + i*(nobj->surface.geom.sorder)* |
| 1293 |
(nobj->surface.geom.dim)*(p->geom_t_pt_cnt) + |
| 1294 |
j*(nobj->surface.geom.dim)*(nobj->surface.geom.torder); |
| 1295 |
if(p->color_ctrl) |
| 1296 |
for(i=0;i<p->s_bezier_cnt;i++) |
| 1297 |
for(j=0;j<p->t_bezier_cnt;j++) |
| 1298 |
*(p->color_offsets + i*(p->t_bezier_cnt) + j) = |
| 1299 |
p->color_ctrl + i*(nobj->surface.color.sorder)* |
| 1300 |
(nobj->surface.color.dim)*(p->color_t_pt_cnt) + |
| 1301 |
j*(nobj->surface.color.dim)*(nobj->surface.color.torder); |
| 1302 |
if(p->normal_ctrl) |
| 1303 |
for(i=0;i<p->s_bezier_cnt;i++) |
| 1304 |
for(j=0;j<p->t_bezier_cnt;j++) |
| 1305 |
*(p->normal_offsets + i*(p->t_bezier_cnt) + j) = |
| 1306 |
p->normal_ctrl + i*(nobj->surface.normal.sorder)* |
| 1307 |
(nobj->surface.normal.dim)*(p->normal_t_pt_cnt) + |
| 1308 |
j*(nobj->surface.normal.dim)*(nobj->surface.normal.torder); |
| 1309 |
if(p->texture_ctrl) |
| 1310 |
for(i=0;i<p->s_bezier_cnt;i++) |
| 1311 |
for(j=0;j<p->t_bezier_cnt;j++) |
| 1312 |
*(p->texture_offsets + i*(p->t_bezier_cnt) + j) = |
| 1313 |
p->texture_ctrl + i*(nobj->surface.texture.sorder)* |
| 1314 |
(nobj->surface.texture.dim)*(p->texture_t_pt_cnt) + |
| 1315 |
j*(nobj->surface.texture.dim)*(nobj->surface.texture.torder); |
| 1316 |
return GLU_NO_ERROR; |
| 1317 |
} |
| 1318 |
|
| 1319 |
/* main NURBS surface procedure */ |
| 1320 |
void |
| 1321 |
do_nurbs_surface( GLUnurbsObj *nobj ) |
| 1322 |
{ |
| 1323 |
GLint *sfactors,*tfactors; |
| 1324 |
new_ctrl_type new_ctrl; |
| 1325 |
|
| 1326 |
/* test user supplied data */ |
| 1327 |
if(test_nurbs_surfaces(nobj)!=GLU_NO_ERROR) |
| 1328 |
return; |
| 1329 |
|
| 1330 |
init_new_ctrl(&new_ctrl); |
| 1331 |
|
| 1332 |
if(convert_surfs(nobj,&new_ctrl)!=GLU_NO_ERROR) |
| 1333 |
return; |
| 1334 |
if(augment_new_ctrl(nobj,&new_ctrl)!=GLU_NO_ERROR) |
| 1335 |
return; |
| 1336 |
if(glu_do_sampling_3D(nobj,&new_ctrl,&sfactors,&tfactors)!=GLU_NO_ERROR) |
| 1337 |
{ |
| 1338 |
free_new_ctrl(&new_ctrl); |
| 1339 |
return; |
| 1340 |
} |
| 1341 |
switch(nobj->display_mode) |
| 1342 |
{ |
| 1343 |
case GLU_FILL: |
| 1344 |
/* if(polygon_trimming(nobj,&new_ctrl,sfactors,tfactors)==GLU_NO_ERROR)*/ |
| 1345 |
draw_polygon_mode(GL_FILL,nobj,&new_ctrl,sfactors,tfactors); |
| 1346 |
break; |
| 1347 |
case GLU_OUTLINE_POLYGON: |
| 1348 |
/* TODO - missing trimming handeling */ |
| 1349 |
/* just for now - no OUTLINE_PATCH mode |
| 1350 |
draw_patch_mode(GL_LINE,nobj,&new_ctrl,sfactors,tfactors); |
| 1351 |
break; */ |
| 1352 |
case GLU_OUTLINE_PATCH: |
| 1353 |
/* if(polygon_trimming(nobj,&new_ctrl,sfactors,tfactors)==GLU_NO_ERROR)*/ |
| 1354 |
draw_polygon_mode(GL_LINE,nobj,&new_ctrl,sfactors,tfactors); |
| 1355 |
break; |
| 1356 |
default: |
| 1357 |
abort(); /* TODO: is this OK? */ |
| 1358 |
} |
| 1359 |
free(sfactors); |
| 1360 |
free(tfactors); |
| 1361 |
free_new_ctrl(&new_ctrl); |
| 1362 |
} |
| 1363 |
|