Subversion Repositories shark

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
55 pj 1
/* $Id: nurbs.c,v 1.1 2003-02-28 11:42:07 pj Exp $ */
2
 
3
/*
4
 * Mesa 3-D graphics library
5
 * Version:  3.3
6
 * Copyright (C) 1995-2000  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
/*
25
 * NURBS implementation written by Bogdan Sikorski (bogdan@cira.it)
26
 * See README2 for more info.
27
 */
28
 
29
 
30
#ifdef PC_HEADER
31
#include "all.h"
32
#else
33
#include <stdio.h>
34
#include <stdlib.h>
35
#include "gluP.h"
36
#include "nurbs.h"
37
#endif
38
 
39
 
40
void
41
call_user_error(GLUnurbsObj * nobj, GLenum error)
42
{
43
   nobj->error = error;
44
   if (nobj->error_callback != NULL) {
45
      (*(nobj->error_callback)) (error);
46
   }
47
   else {
48
      printf("NURBS error %d %s\n", error, (char *) gluErrorString(error));
49
   }
50
}
51
 
52
 
53
 
54
GLUnurbsObj *GLAPIENTRY
55
gluNewNurbsRenderer(void)
56
{
57
   GLUnurbsObj *n;
58
   GLfloat tmp_viewport[4];
59
   GLint i, j;
60
 
61
   n = (GLUnurbsObj *) malloc(sizeof(GLUnurbsObj));
62
   if (n) {
63
      /* init */
64
      n->culling = GL_FALSE;
65
      n->nurbs_type = GLU_NURBS_NONE;
66
      n->error = GLU_NO_ERROR;
67
      n->error_callback = NULL;
68
      n->auto_load_matrix = GL_TRUE;
69
      n->sampling_tolerance = 50.0;
70
      n->parametric_tolerance = 0.5;
71
      n->u_step = n->v_step = 100;
72
      n->sampling_method = GLU_PATH_LENGTH;
73
      n->display_mode = GLU_FILL;
74
      /* in case the user doesn't supply the sampling matrices */
75
      /* set projection and modelview to identity */
76
      for (i = 0; i < 4; i++)
77
         for (j = 0; j < 4; j++)
78
            if (i == j) {
79
               n->sampling_matrices.model[i * 4 + j] = 1.0;
80
               n->sampling_matrices.proj[i * 4 + j] = 1.0;
81
            }
82
            else {
83
               n->sampling_matrices.model[i * 4 + j] = 0.0;
84
               n->sampling_matrices.proj[i * 4 + j] = 0.0;
85
            }
86
      /* and set the viewport sampling matrix to current ciewport */
87
      glGetFloatv(GL_VIEWPORT, tmp_viewport);
88
      for (i = 0; i < 4; i++)
89
         n->sampling_matrices.viewport[i] = tmp_viewport[i];
90
      n->trim = NULL;
91
   }
92
   return n;
93
}
94
 
95
 
96
 
97
void GLAPIENTRY
98
gluDeleteNurbsRenderer(GLUnurbsObj * nobj)
99
{
100
   if (nobj) {
101
      free(nobj);
102
   }
103
}
104
 
105
 
106
 
107
void GLAPIENTRY
108
gluLoadSamplingMatrices(GLUnurbsObj * nobj,
109
                        const GLfloat modelMatrix[16],
110
                        const GLfloat projMatrix[16], const GLint viewport[4])
111
{
112
   GLint i;
113
 
114
   for (i = 0; i < 16; i++) {
115
      nobj->sampling_matrices.model[i] = modelMatrix[i];
116
      nobj->sampling_matrices.proj[i] = projMatrix[i];
117
   }
118
   for (i = 0; i < 4; i++)
119
      nobj->sampling_matrices.viewport[i] = viewport[i];
120
}
121
 
122
 
123
void GLAPIENTRY
124
gluNurbsProperty(GLUnurbsObj * nobj, GLenum property, GLfloat value)
125
{
126
   GLenum val;
127
 
128
   switch (property) {
129
   case GLU_SAMPLING_TOLERANCE:
130
      if (value <= 0.0) {
131
         call_user_error(nobj, GLU_INVALID_VALUE);
132
         return;
133
      }
134
      nobj->sampling_tolerance = value;
135
      break;
136
   case GLU_PARAMETRIC_TOLERANCE:
137
      if (value <= 0.0) {
138
         call_user_error(nobj, GLU_INVALID_VALUE);
139
         return;
140
      }
141
      nobj->parametric_tolerance = value;
142
      break;
143
   case GLU_U_STEP:
144
      if (value <= 0.0) {
145
         call_user_error(nobj, GLU_INVALID_VALUE);
146
         return;
147
      }
148
      nobj->u_step = (GLint) value;
149
      break;
150
   case GLU_V_STEP:
151
      if (value <= 0.0) {
152
         call_user_error(nobj, GLU_INVALID_VALUE);
153
         return;
154
      }
155
      nobj->v_step = (GLint) value;
156
      break;
157
   case GLU_SAMPLING_METHOD:
158
      val = (GLenum) value;
159
      if (val != GLU_PATH_LENGTH && val != GLU_PARAMETRIC_ERROR
160
          && val != GLU_DOMAIN_DISTANCE) {
161
         call_user_error(nobj, GLU_INVALID_ENUM);
162
         return;
163
      }
164
      nobj->sampling_method = val;
165
      break;
166
   case GLU_DISPLAY_MODE:
167
      val = (GLenum) value;
168
      if (val != GLU_FILL && val != GLU_OUTLINE_POLYGON
169
          && val != GLU_OUTLINE_PATCH) {
170
         call_user_error(nobj, GLU_INVALID_ENUM);
171
         return;
172
      }
173
      if (nobj->nurbs_type == GLU_NURBS_CURVE) {
174
         call_user_error(nobj, GLU_NURBS_ERROR26);
175
         return;
176
      }
177
      nobj->display_mode = val;
178
      if (val == GLU_OUTLINE_PATCH)
179
         fprintf(stderr,
180
                 "NURBS, for the moment, can display only in POLYGON mode\n");
181
      break;
182
   case GLU_CULLING:
183
      val = (GLenum) value;
184
      if (val != GL_TRUE && val != GL_FALSE) {
185
         call_user_error(nobj, GLU_INVALID_ENUM);
186
         return;
187
      }
188
      nobj->culling = (GLboolean) value;
189
      break;
190
   case GLU_AUTO_LOAD_MATRIX:
191
      val = (GLenum) value;
192
      if (val != GL_TRUE && val != GL_FALSE) {
193
         call_user_error(nobj, GLU_INVALID_ENUM);
194
         return;
195
      }
196
      nobj->auto_load_matrix = (GLboolean) value;
197
      break;
198
   default:
199
      call_user_error(nobj, GLU_NURBS_ERROR26);
200
   }
201
}
202
 
203
 
204
void GLAPIENTRY
205
gluGetNurbsProperty(GLUnurbsObj * nobj, GLenum property, GLfloat * value)
206
{
207
   switch (property) {
208
   case GLU_SAMPLING_TOLERANCE:
209
      *value = nobj->sampling_tolerance;
210
      break;
211
   case GLU_DISPLAY_MODE:
212
      *value = (GLfloat) (GLint) nobj->display_mode;
213
      break;
214
   case GLU_CULLING:
215
      *value = nobj->culling ? 1.0 : 0.0;
216
      break;
217
   case GLU_AUTO_LOAD_MATRIX:
218
      *value = nobj->auto_load_matrix ? 1.0 : 0.0;
219
      break;
220
   default:
221
      call_user_error(nobj, GLU_INVALID_ENUM);
222
   }
223
}
224
 
225
 
226
 
227
void GLAPIENTRY
228
gluBeginCurve(GLUnurbsObj * nobj)
229
{
230
   if (nobj->nurbs_type == GLU_NURBS_CURVE) {
231
      call_user_error(nobj, GLU_NURBS_ERROR6);
232
      return;
233
   }
234
   nobj->nurbs_type = GLU_NURBS_CURVE;
235
   nobj->curve.geom.type = GLU_INVALID_ENUM;
236
   nobj->curve.color.type = GLU_INVALID_ENUM;
237
   nobj->curve.texture.type = GLU_INVALID_ENUM;
238
   nobj->curve.normal.type = GLU_INVALID_ENUM;
239
}
240
 
241
 
242
void GLAPIENTRY
243
gluEndCurve(GLUnurbsObj * nobj)
244
{
245
   if (nobj->nurbs_type == GLU_NURBS_NONE) {
246
      call_user_error(nobj, GLU_NURBS_ERROR7);
247
      return;
248
   }
249
   if (nobj->curve.geom.type == GLU_INVALID_ENUM) {
250
      call_user_error(nobj, GLU_NURBS_ERROR8);
251
      nobj->nurbs_type = GLU_NURBS_NONE;
252
      return;
253
   }
254
   glPushAttrib((GLbitfield) (GL_EVAL_BIT | GL_ENABLE_BIT));
255
   glDisable(GL_MAP1_VERTEX_3);
256
   glDisable(GL_MAP1_VERTEX_4);
257
   glDisable(GL_MAP1_INDEX);
258
   glDisable(GL_MAP1_COLOR_4);
259
   glDisable(GL_MAP1_NORMAL);
260
   glDisable(GL_MAP1_TEXTURE_COORD_1);
261
   glDisable(GL_MAP1_TEXTURE_COORD_2);
262
   glDisable(GL_MAP1_TEXTURE_COORD_3);
263
   glDisable(GL_MAP1_TEXTURE_COORD_4);
264
   glDisable(GL_MAP2_VERTEX_3);
265
   glDisable(GL_MAP2_VERTEX_4);
266
   glDisable(GL_MAP2_INDEX);
267
   glDisable(GL_MAP2_COLOR_4);
268
   glDisable(GL_MAP2_NORMAL);
269
   glDisable(GL_MAP2_TEXTURE_COORD_1);
270
   glDisable(GL_MAP2_TEXTURE_COORD_2);
271
   glDisable(GL_MAP2_TEXTURE_COORD_3);
272
   glDisable(GL_MAP2_TEXTURE_COORD_4);
273
   do_nurbs_curve(nobj);
274
   glPopAttrib();
275
   nobj->nurbs_type = GLU_NURBS_NONE;
276
}
277
 
278
 
279
void GLAPIENTRY
280
gluNurbsCurve(GLUnurbsObj * nobj, GLint nknots, GLfloat * knot,
281
              GLint stride, GLfloat * ctlarray, GLint order, GLenum type)
282
{
283
   if (nobj->nurbs_type == GLU_NURBS_TRIM) {
284
#if 0
285
/* TODO: NOT IMPLEMENTED YET */
286
      nurbs_trim *ptr1;
287
      trim_list *ptr2;
288
 
289
      if (type != GLU_MAP1_TRIM_2 && type != GLU_MAP1_TRIM_3) {
290
         call_user_error(nobj, GLU_NURBS_ERROR14);
291
         return;
292
      }
293
      for (ptr1 = nobj->trim; ptr1->next; ptr1 = ptr1->next);
294
      if (ptr1->trim_loop) {
295
         for (ptr2 = ptr1->trim_loop; ptr2->next; ptr2 = ptr2->next);
296
         if ((ptr2->next = (trim_list *) malloc(sizeof(trim_list))) == NULL) {
297
            call_user_error(nobj, GLU_OUT_OF_MEMORY);
298
            return;
299
         }
300
         ptr2 = ptr2->next;
301
      }
302
      else {
303
         if ((ptr2 = (trim_list *) malloc(sizeof(trim_list))) == NULL) {
304
            call_user_error(nobj, GLU_OUT_OF_MEMORY);
305
            return;
306
         }
307
         ptr1->trim_loop = ptr2;
308
      }
309
      ptr2->trim_type = GLU_TRIM_NURBS;
310
      ptr2->curve.nurbs_curve.knot_count = nknots;
311
      ptr2->curve.nurbs_curve.knot = knot;
312
      ptr2->curve.nurbs_curve.stride = stride;
313
      ptr2->curve.nurbs_curve.ctrlarray = ctlarray;
314
      ptr2->curve.nurbs_curve.order = order;
315
      ptr2->curve.nurbs_curve.dim = (type == GLU_MAP1_TRIM_2 ? 2 : 3);
316
      ptr2->curve.nurbs_curve.type = type;
317
      ptr2->next = NULL;
318
#endif
319
   }
320
   else {
321
      if (type == GLU_MAP1_TRIM_2 || type == GLU_MAP1_TRIM_3) {
322
         call_user_error(nobj, GLU_NURBS_ERROR22);
323
         return;
324
      }
325
      if (nobj->nurbs_type != GLU_NURBS_CURVE) {
326
         call_user_error(nobj, GLU_NURBS_ERROR10);
327
         return;
328
      }
329
      switch (type) {
330
      case GL_MAP1_VERTEX_3:
331
      case GL_MAP1_VERTEX_4:
332
         if (nobj->curve.geom.type != GLU_INVALID_ENUM) {
333
            call_user_error(nobj, GLU_NURBS_ERROR8);
334
            return;
335
         }
336
         nobj->curve.geom.type = type;
337
         nobj->curve.geom.knot_count = nknots;
338
         nobj->curve.geom.knot = knot;
339
         nobj->curve.geom.stride = stride;
340
         nobj->curve.geom.ctrlarray = ctlarray;
341
         nobj->curve.geom.order = order;
342
         break;
343
      case GL_MAP1_INDEX:
344
      case GL_MAP1_COLOR_4:
345
         nobj->curve.color.type = type;
346
         nobj->curve.color.knot_count = nknots;
347
         nobj->curve.color.knot = knot;
348
         nobj->curve.color.stride = stride;
349
         nobj->curve.color.ctrlarray = ctlarray;
350
         nobj->curve.color.order = order;
351
         break;
352
      case GL_MAP1_NORMAL:
353
         nobj->curve.normal.type = type;
354
         nobj->curve.normal.knot_count = nknots;
355
         nobj->curve.normal.knot = knot;
356
         nobj->curve.normal.stride = stride;
357
         nobj->curve.normal.ctrlarray = ctlarray;
358
         nobj->curve.normal.order = order;
359
         break;
360
      case GL_MAP1_TEXTURE_COORD_1:
361
      case GL_MAP1_TEXTURE_COORD_2:
362
      case GL_MAP1_TEXTURE_COORD_3:
363
      case GL_MAP1_TEXTURE_COORD_4:
364
         nobj->curve.texture.type = type;
365
         nobj->curve.texture.knot_count = nknots;
366
         nobj->curve.texture.knot = knot;
367
         nobj->curve.texture.stride = stride;
368
         nobj->curve.texture.ctrlarray = ctlarray;
369
         nobj->curve.texture.order = order;
370
         break;
371
      default:
372
         call_user_error(nobj, GLU_INVALID_ENUM);
373
      }
374
   }
375
}
376
 
377
 
378
void GLAPIENTRY
379
gluBeginSurface(GLUnurbsObj * nobj)
380
{
381
   switch (nobj->nurbs_type) {
382
   case GLU_NURBS_NONE:
383
      nobj->nurbs_type = GLU_NURBS_SURFACE;
384
      nobj->surface.geom.type = GLU_INVALID_ENUM;
385
      nobj->surface.color.type = GLU_INVALID_ENUM;
386
      nobj->surface.texture.type = GLU_INVALID_ENUM;
387
      nobj->surface.normal.type = GLU_INVALID_ENUM;
388
      break;
389
   case GLU_NURBS_TRIM:
390
      call_user_error(nobj, GLU_NURBS_ERROR16);
391
      break;
392
   case GLU_NURBS_SURFACE:
393
   case GLU_NURBS_NO_TRIM:
394
   case GLU_NURBS_TRIM_DONE:
395
      call_user_error(nobj, GLU_NURBS_ERROR27);
396
      break;
397
   case GLU_NURBS_CURVE:
398
      call_user_error(nobj, GLU_NURBS_ERROR6);
399
      break;
400
   }
401
}
402
 
403
 
404
void GLAPIENTRY
405
gluEndSurface(GLUnurbsObj * nobj)
406
{
407
   switch (nobj->nurbs_type) {
408
   case GLU_NURBS_NONE:
409
      call_user_error(nobj, GLU_NURBS_ERROR13);
410
      break;
411
   case GLU_NURBS_TRIM:
412
      call_user_error(nobj, GLU_NURBS_ERROR12);
413
      break;
414
   case GLU_NURBS_TRIM_DONE:
415
/*            if(nobj->trim->trim_loop==NULL)
416
            {
417
                call_user_error(nobj,GLU_NURBS_ERROR18);
418
                return;
419
            }*/
420
      /* no break - fallthrough */
421
   case GLU_NURBS_NO_TRIM:
422
      glPushAttrib((GLbitfield)
423
                   (GL_EVAL_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT));
424
      glDisable(GL_MAP2_VERTEX_3);
425
      glDisable(GL_MAP2_VERTEX_4);
426
      glDisable(GL_MAP2_INDEX);
427
      glDisable(GL_MAP2_COLOR_4);
428
      glDisable(GL_MAP2_NORMAL);
429
      glDisable(GL_MAP2_TEXTURE_COORD_1);
430
      glDisable(GL_MAP2_TEXTURE_COORD_2);
431
      glDisable(GL_MAP2_TEXTURE_COORD_3);
432
      glDisable(GL_MAP2_TEXTURE_COORD_4);
433
/*            glDisable(GL_MAP1_VERTEX_3);
434
            glDisable(GL_MAP1_VERTEX_4);
435
            glDisable(GL_MAP1_INDEX);
436
            glDisable(GL_MAP1_COLOR_4);
437
            glDisable(GL_MAP1_NORMAL);
438
            glDisable(GL_MAP1_TEXTURE_COORD_1);
439
            glDisable(GL_MAP1_TEXTURE_COORD_2);
440
            glDisable(GL_MAP1_TEXTURE_COORD_3);
441
            glDisable(GL_MAP1_TEXTURE_COORD_4);*/
442
      do_nurbs_surface(nobj);
443
      glPopAttrib();
444
      break;
445
   default:
446
      call_user_error(nobj, GLU_NURBS_ERROR8);
447
   }
448
   nobj->nurbs_type = GLU_NURBS_NONE;
449
}
450
 
451
 
452
void GLAPIENTRY
453
gluNurbsSurface(GLUnurbsObj * nobj,
454
                GLint sknot_count, GLfloat * sknot,
455
                GLint tknot_count, GLfloat * tknot,
456
                GLint s_stride, GLint t_stride,
457
                GLfloat * ctrlarray, GLint sorder, GLint torder, GLenum type)
458
{
459
   if (nobj->nurbs_type == GLU_NURBS_NO_TRIM
460
       || nobj->nurbs_type == GLU_NURBS_TRIM
461
       || nobj->nurbs_type == GLU_NURBS_TRIM_DONE) {
462
      if (type == GL_MAP2_VERTEX_3 || type == GL_MAP2_VERTEX_4) {
463
         call_user_error(nobj, GLU_NURBS_ERROR8);
464
         return;
465
      }
466
   }
467
   else if (nobj->nurbs_type != GLU_NURBS_SURFACE) {
468
      call_user_error(nobj, GLU_NURBS_ERROR11);
469
      return;
470
   }
471
   switch (type) {
472
   case GL_MAP2_VERTEX_3:
473
   case GL_MAP2_VERTEX_4:
474
      nobj->surface.geom.sknot_count = sknot_count;
475
      nobj->surface.geom.sknot = sknot;
476
      nobj->surface.geom.tknot_count = tknot_count;
477
      nobj->surface.geom.tknot = tknot;
478
      nobj->surface.geom.s_stride = s_stride;
479
      nobj->surface.geom.t_stride = t_stride;
480
      nobj->surface.geom.ctrlarray = ctrlarray;
481
      nobj->surface.geom.sorder = sorder;
482
      nobj->surface.geom.torder = torder;
483
      nobj->surface.geom.type = type;
484
      nobj->nurbs_type = GLU_NURBS_NO_TRIM;
485
      break;
486
   case GL_MAP2_INDEX:
487
   case GL_MAP2_COLOR_4:
488
      nobj->surface.color.sknot_count = sknot_count;
489
      nobj->surface.color.sknot = sknot;
490
      nobj->surface.color.tknot_count = tknot_count;
491
      nobj->surface.color.tknot = tknot;
492
      nobj->surface.color.s_stride = s_stride;
493
      nobj->surface.color.t_stride = t_stride;
494
      nobj->surface.color.ctrlarray = ctrlarray;
495
      nobj->surface.color.sorder = sorder;
496
      nobj->surface.color.torder = torder;
497
      nobj->surface.color.type = type;
498
      break;
499
   case GL_MAP2_NORMAL:
500
      nobj->surface.normal.sknot_count = sknot_count;
501
      nobj->surface.normal.sknot = sknot;
502
      nobj->surface.normal.tknot_count = tknot_count;
503
      nobj->surface.normal.tknot = tknot;
504
      nobj->surface.normal.s_stride = s_stride;
505
      nobj->surface.normal.t_stride = t_stride;
506
      nobj->surface.normal.ctrlarray = ctrlarray;
507
      nobj->surface.normal.sorder = sorder;
508
      nobj->surface.normal.torder = torder;
509
      nobj->surface.normal.type = type;
510
      break;
511
   case GL_MAP2_TEXTURE_COORD_1:
512
   case GL_MAP2_TEXTURE_COORD_2:
513
   case GL_MAP2_TEXTURE_COORD_3:
514
   case GL_MAP2_TEXTURE_COORD_4:
515
      nobj->surface.texture.sknot_count = sknot_count;
516
      nobj->surface.texture.sknot = sknot;
517
      nobj->surface.texture.tknot_count = tknot_count;
518
      nobj->surface.texture.tknot = tknot;
519
      nobj->surface.texture.s_stride = s_stride;
520
      nobj->surface.texture.t_stride = t_stride;
521
      nobj->surface.texture.ctrlarray = ctrlarray;
522
      nobj->surface.texture.sorder = sorder;
523
      nobj->surface.texture.torder = torder;
524
      nobj->surface.texture.type = type;
525
      break;
526
   default:
527
      call_user_error(nobj, GLU_INVALID_ENUM);
528
   }
529
}
530
 
531
 
532
void GLAPIENTRY
533
gluNurbsCallback(GLUnurbsObj * nobj, GLenum which, void (GLCALLBACK * fn) ())
534
{
535
   nobj->error_callback = (void (GLCALLBACKPCAST) (GLenum)) fn;
536
 
537
   if (which != GLU_ERROR)
538
      call_user_error(nobj, GLU_INVALID_ENUM);
539
}
540
 
541
void GLAPIENTRY
542
gluBeginTrim(GLUnurbsObj * nobj)
543
{
544
#if 0
545
   nurbs_trim *ptr;
546
#endif
547
 
548
   if (nobj->nurbs_type != GLU_NURBS_TRIM_DONE)
549
      if (nobj->nurbs_type != GLU_NURBS_NO_TRIM) {
550
         call_user_error(nobj, GLU_NURBS_ERROR15);
551
         return;
552
      }
553
   nobj->nurbs_type = GLU_NURBS_TRIM;
554
   fprintf(stderr, "NURBS - trimming not supported yet\n");
555
#if 0
556
   if ((ptr = (nurbs_trim *) malloc(sizeof(nurbs_trim))) == NULL) {
557
      call_user_error(nobj, GLU_OUT_OF_MEMORY);
558
      return;
559
   }
560
   if (nobj->trim) {
561
      nurbs_trim *tmp_ptr;
562
 
563
      for (tmp_ptr = nobj->trim; tmp_ptr->next; tmp_ptr = tmp_ptr->next);
564
      tmp_ptr->next = ptr;
565
   }
566
   else
567
      nobj->trim = ptr;
568
   ptr->trim_loop = NULL;
569
   ptr->segments = NULL;
570
   ptr->next = NULL;
571
#endif
572
}
573
 
574
void GLAPIENTRY
575
gluPwlCurve(GLUnurbsObj * nobj, GLint count, GLfloat * array, GLint stride,
576
            GLenum type)
577
{
578
#if 0
579
   nurbs_trim *ptr1;
580
   trim_list *ptr2;
581
#endif
582
   if (nobj->nurbs_type == GLU_NURBS_CURVE) {
583
      call_user_error(nobj, GLU_NURBS_ERROR9);
584
      return;
585
   }
586
   if (nobj->nurbs_type == GLU_NURBS_NONE) {
587
      call_user_error(nobj, GLU_NURBS_ERROR19);
588
      return;
589
   }
590
   if (type != GLU_MAP1_TRIM_2 && type != GLU_MAP1_TRIM_3) {
591
      call_user_error(nobj, GLU_NURBS_ERROR14);
592
      return;
593
   }
594
#if 0
595
   for (ptr1 = nobj->trim; ptr1->next; ptr1 = ptr1->next);
596
   if (ptr1->trim_loop) {
597
      for (ptr2 = ptr1->trim_loop; ptr2->next; ptr2 = ptr2->next);
598
      if ((ptr2->next = (trim_list *) malloc(sizeof(trim_list))) == NULL) {
599
         call_user_error(nobj, GLU_OUT_OF_MEMORY);
600
         return;
601
      }
602
      ptr2 = ptr2->next;
603
   }
604
   else {
605
      if ((ptr2 = (trim_list *) malloc(sizeof(trim_list))) == NULL) {
606
         call_user_error(nobj, GLU_OUT_OF_MEMORY);
607
         return;
608
      }
609
      ptr1->trim_loop = ptr2;
610
   }
611
   ptr2->trim_type = GLU_TRIM_PWL;
612
   ptr2->curve.pwl_curve.pt_count = count;
613
   ptr2->curve.pwl_curve.ctrlarray = array;
614
   ptr2->curve.pwl_curve.stride = stride;
615
   ptr2->curve.pwl_curve.dim = (type == GLU_MAP1_TRIM_2 ? 2 : 3);
616
   ptr2->curve.pwl_curve.type = type;
617
   ptr2->next = NULL;
618
#endif
619
}
620
 
621
void GLAPIENTRY
622
gluEndTrim(GLUnurbsObj * nobj)
623
{
624
   if (nobj->nurbs_type != GLU_NURBS_TRIM) {
625
      call_user_error(nobj, GLU_NURBS_ERROR17);
626
      return;
627
   }
628
   nobj->nurbs_type = GLU_NURBS_TRIM_DONE;
629
}