0022792: Globally defined symbol PI conflicts with VTK definition (Intel compiler)
[occt.git] / src / OpenGl / OpenGl_qstrip.cxx
CommitLineData
7fd59977 1#define G003
2#define G004
3/***********************************************************************
4
5FONCTION :
6----------
7File OpenGl_qstrip :
8
9
10REMARQUES:
11----------
12
13
14HISTORIQUE DES MODIFICATIONS :
15--------------------------------
16xx-xx-xx : xxx ; Creation.
1711-03-96 : FMN ; Correction warning compilation
1801-04-96 : CAL ; Integration MINSK portage WNT
1922-04-96 : FMN ; Suppression prototype inutile.
2009-08-96 : FMN ; Suppression appel glMatrixMode() avant glGetFloatv()
2121-10-96 : FMN ; Suppression LMC_COLOR fait dans OpenGl_execstruct.c
2230-06-97 : FMN ; Suppression OpenGl_telem_light.h
2318-07-97 : FMN ; Ajout desactivation des lights suivant front_lighting_model
2421-07-97 : FMN ; Amelioration des performances OPTIMISATION_FMN
25- suppression calcul inutile sur les front faces
2627-08-97 : FMN ; Correction affichage des edges
27On n'affiche que les edges dans le mode IS_EMPTY
2810-09-97 : FMN ; Amelioration des perfs liees aux lights.
2915-09-97 : PCT ; Ajout coordonnees textures
3024-09-97 : FMN ; Suppression OPTIMISATION_FMN.
3108-12-97 : FMN ; Suppression appel TsmGetAttri inutile.
3231-12-97 : FMN ; Simplification pour le highlight
3315-01-98 : FMN ; Ajout Hidden line
3417-02-00 : EUG ; Degeneration support
3517-02-00 : EUG ; Bitmap drawing support
3608-03-01 : GG ; BUC60823 Avoid crash in the normal computation method
37on confuse point.
38
39************************************************************************/
40
41#define BUC60876 /* GG 5/4/2001 Disable local display list
42// when animation is not required
43*/
44
45/*----------------------------------------------------------------------*/
46/*
47* Includes
48*/
49
50
51#include <OpenGl_tgl_all.hxx>
52
53#include <stddef.h>
54#include <stdio.h>
55
56#include <GL/gl.h>
57#include <GL/glu.h>
58
59#include <OpenGl_cmn_varargs.hxx>
60#include <OpenGl_telem_attri.hxx>
61#include <OpenGl_tsm.hxx>
62#include <OpenGl_telem.hxx>
63#include <OpenGl_telem_util.hxx>
64#include <OpenGl_telem_highlight.hxx>
65#include <OpenGl_telem_inquire.hxx>
66#include <OpenGl_telem_view.hxx>
67#include <OpenGl_tgl_funcs.hxx>
68#include <OpenGl_LightBox.hxx>
69#include <OpenGl_TextureBox.hxx>
70#include <OpenGl_Memory.hxx>
71
72/*----------------------------------------------------------------------*/
73/*
74* Constantes
75*/
76
77/*----------------------------------------------------------------------*/
78/*
79* Variables externes
80*/
81
82extern Tint ForbidSetTextureMapping; /* currently defined in tsm/tsm.c */
83
84#ifdef G003
85# include <float.h>
86# define DEF_DS_INTERNAL
87# include <OpenGl_degeneration.hxx>
88
89# ifdef G004
90extern GLboolean g_fBitmap;
91# endif /* G004 */
92
93# define OPENGL_RAND() ( ( unsigned )( s_Rand = s_Rand * 214013L + 2531011L ))
94
95extern int g_nDegenerateModel;
96extern float g_fSkipRatio;
97extern GLboolean g_fAnimation;
98
99#endif /* G003 */
100
101/*----------------------------------------------------------------------*/
102
103struct TEL_QSTRIP_DATA
104{
105 Tint shape_flag; /* TEL_SHAPE_UNKNOWN or TEL_SHAPE_COMPLEX or
106 TEL_SHAPE_CONVEX or TEL_SHAPE_CONCAVE */
107 Tint facet_flag; /* TEL_FA_NONE or TEL_FA_NORMAL */
108 Tint vertex_flag; /* TEL_VT_NONE or TEL_VT_NORMAL */
109 Tint num_rows,
110 num_columns; /* Number of rows and columns */
111 tel_point fnormals; /* Facet normals */
112 tel_colour fcolours; /* Facet colours */
113 tel_point vertices; /* Vertices */
114 tel_colour vcolours; /* Vertex colour values */
115 tel_point vnormals; /* Vertex normals */
116 tel_texture_coord vtexturecoord; /* Texture coordinates */
117#ifdef G003
118 DS_INTERNAL d;
119#endif /* G003 */
120 IMPLEMENT_MEMORY_OPERATORS
121};
122typedef TEL_QSTRIP_DATA* tel_qstrip_data;
123
124static TStatus QuadrangleDisplay( TSM_ELEM_DATA, Tint, cmn_key* );
125static TStatus QuadrangleAdd( TSM_ELEM_DATA, Tint, cmn_key* );
126static TStatus QuadrangleDelete( TSM_ELEM_DATA, Tint, cmn_key* );
127static TStatus QuadranglePrint( TSM_ELEM_DATA, Tint, cmn_key* );
128static TStatus QuadrangleInquire( TSM_ELEM_DATA, Tint, cmn_key* );
129
130static void
131draw_qstrip( tel_qstrip_data,
132 Tint, /* highlight flag */
133 Tint, /* front_lighting_model, */
134 Tint, /* interior_style, */
135 tel_colour /* edge_colour, */
136 );
137
138#ifdef G003
139static void draw_edges ( tel_qstrip_data, tel_colour, Tint, Tint );
140extern void draw_degenerates_as_points ( PDS_INTERNAL, tel_point, Tint );
141extern void draw_degenerates_as_bboxs ( PDS_INTERNAL, tel_point, Tint );
142extern void set_drawable_items ( GLboolean*, int );
143#else
144static void draw_edges ( tel_qstrip_data, tel_colour, Tint );
145#endif /* G003 */
146
147static void draw_line_strip ( tel_qstrip_data, tel_colour, Tint, Tint );
148
149static TEL_QSTRIP_DATA qstrip_defaults = {
150
151 TEL_SHAPE_UNKNOWN, /* shape_flag */
152 TEL_FA_NONE, /* facet_flag */
153 TEL_VT_NONE /* vertex_flag */
154
155};
156
157static TStatus ( *MtdTbl[] ) ( TSM_ELEM_DATA, Tint, cmn_key* ) = {
158
159 QuadrangleDisplay, /* PickTraverse */
160 QuadrangleDisplay,
161 QuadrangleAdd,
162 QuadrangleDelete,
163 QuadranglePrint,
164 QuadrangleInquire
165
166};
167
168/*----------------------------------------------------------------------*/
169
170MtblPtr TelQuadrangleInitClass ( TelType* el ) {
171
172 *el = TelQuadrangle;
173
174 return MtdTbl;
175
176} /* end TelQuadrangleInitClass */
177
178static TStatus
179QuadrangleAdd( TSM_ELEM_DATA d, Tint n, cmn_key *k )
180
181{
182 Tint i, j;
183 Tint nf, nv;
184 tel_qstrip_data data;
185
186 for( i = 0; i < n; i++ )
187 {
188 if( k[i]->id == NUM_ROWS_ID )
189 break;
190 }
191 if( i == n )
192 return TFailure;
193
194 if( !(k[i]->data.ldata) )
195 return TFailure;
196
197 for( j = 0; j < n; j++ )
198 {
199 if( k[j]->id == NUM_COLUMNS_ID )
200 break;
201 }
202 if( j == n )
203 return TFailure;
204
205 if( !(k[j]->data.ldata) )
206 return TFailure;
207
208 data = new TEL_QSTRIP_DATA();
209 if( !data )
210 return TFailure;
211
212 /* load defaults */
213 *data = qstrip_defaults;
214
215 data->num_rows = k[i]->data.ldata;
216 data->num_columns = k[j]->data.ldata;
217 nf = data->num_rows * data->num_columns;
218 nv = ( data->num_rows+1 ) * ( data->num_columns+1 );
219
220 data->vtexturecoord = 0;
221
222 for( i = 0; i < n; i++ )
223 {
224 switch( k[i]->id )
225 {
226 case SHAPE_FLAG_ID:
227 {
228 data->shape_flag = k[i]->data.ldata;
229 break;
230 }
231 case FNORMALS_ID:
232 {
233 data->facet_flag = TEL_FA_NORMAL;
234 data->fnormals = new TEL_POINT[nf];
235 memcpy( data->fnormals, k[i]->data.pdata, nf*sizeof(TEL_POINT) );
236 for( j = 0; j < nf; j++ )
237 vecnrm( data->fnormals[j].xyz );
238 break;
239 }
240 case FACET_COLOUR_VALS_ID:
241 {
242 data->fcolours = new TEL_COLOUR[nf];
243 memcpy( data->fcolours, k[i]->data.pdata, nf*sizeof(TEL_COLOUR) );
244 break;
245 }
246 case VERTICES_ID:
247 {
248 data->vertices = new TEL_POINT[nv];
249 memcpy( data->vertices, k[i]->data.pdata, nv*sizeof(TEL_POINT) );
250 break;
251 }
252 case VERTEX_COLOUR_VALS_ID:
253 {
254 data->vcolours = new TEL_COLOUR[nv];
255 memcpy( data->vcolours, k[i]->data.pdata, nv*sizeof(TEL_COLOUR) );
256 break;
257 }
258 case VNORMALS_ID:
259 {
260 data->vertex_flag = TEL_VT_NORMAL;
261 data->vnormals = new TEL_POINT[nv];
262 memcpy( data->vnormals, k[i]->data.pdata, nv*sizeof(TEL_POINT) );
263 for( j = 0; j < nv; j++ )
264 vecnrm( data->vnormals[j].xyz );
265 break;
266 }
267 case VTEXTURECOORD_ID:
268 {
269 data->vtexturecoord = new TEL_TEXTURE_COORD[nv];
270 memcpy( data->vtexturecoord, k[i]->data.pdata, nv*sizeof(TEL_TEXTURE_COORD) );
271 break;
272 }
273 default:
274 {
275 break;
276 }
277 }
278 }
279
280 if( data->facet_flag != TEL_FA_NORMAL )
281 {
282 /* calculate the normals and store */
283 data->fnormals = new TEL_POINT[nf];
284 for( i = 0; i < nf; i++ )
285 {
286 TEL_POINT p1, p2, p3, p4;
287 Tint r, c, id;
288
289 r = i/data->num_columns;
290 c = i%data->num_columns;
291
292 id = r*(data->num_columns+1) + c;
293 p1 = data->vertices[id];
294 p2 = data->vertices[id+data->num_columns+1];
295 p3 = data->vertices[id+data->num_columns+2];
296 p4 = data->vertices[id+1];
297
298 p4.xyz[0] -= p2.xyz[0];
299 p4.xyz[1] -= p2.xyz[1];
300 p4.xyz[2] -= p2.xyz[2];
301
302 p4.xyz[0] += p1.xyz[0];
303 p4.xyz[1] += p1.xyz[1];
304 p4.xyz[2] += p1.xyz[2];
305
306 TelGetNormal( p4.xyz, p1.xyz, p3.xyz, data->fnormals[i].xyz );
307 }
308#ifndef BUC60823
309 for( j = 0; j < nf; j++ )
310 vecnrm( data->fnormals[j].xyz );
311#endif
312 }
313 if( data->vertex_flag != TEL_VT_NORMAL )
314 {
315 Tint r, c, id;
316 /* calculate the vertex normals */
317 data->vnormals = new TEL_POINT[nv];
318 for( i = 0; i < nv; i++ )
319 {
320 if( i == 0 )
321 data->vnormals[i] = data->fnormals[i];
322 else if( i == (nv-1) )
323 data->vnormals[i] = data->fnormals[nf-1];
324 else if( i == (nv-data->num_columns-1) )
325 data->vnormals[i] = data->fnormals[nf-data->num_columns];
326 else if( i == data->num_columns )
327 data->vnormals[i] = data->fnormals[i-1];
328 else if( i%(data->num_columns+1) == 0 )
329 {
330 r = i/(data->num_columns+1);
331 data->vnormals[i].xyz[0] =
332 ( data->fnormals[(r-1)*data->num_columns].xyz[0] +
333 data->fnormals[r*data->num_columns].xyz[0] ) / ( float )2.0;
334 data->vnormals[i].xyz[1] =
335 ( data->fnormals[(r-1)*data->num_columns].xyz[1] +
336 data->fnormals[r*data->num_columns].xyz[1] ) / ( float )2.0;
337 data->vnormals[i].xyz[2] =
338 ( data->fnormals[(r-1)*data->num_columns].xyz[2] +
339 data->fnormals[r*data->num_columns].xyz[2] ) / ( float )2.0;
340 }
341 else if( i <= data->num_columns )
342 {
343 data->vnormals[i].xyz[0] = ( data->fnormals[i-1].xyz[0] +
344 data->fnormals[i].xyz[0] ) / ( float )2.0;
345 data->vnormals[i].xyz[1] = ( data->fnormals[i-1].xyz[1] +
346 data->fnormals[i].xyz[1] ) / ( float )2.0;
347 data->vnormals[i].xyz[2] = ( data->fnormals[i-1].xyz[2] +
348 data->fnormals[i].xyz[2] ) / ( float )2.0;
349 }
350 else if( i >= (nv-data->num_columns-1 ) )
351 {
352 c = i%(data->num_columns+1);
353 id = nf-data->num_columns+c;
354
355 data->vnormals[i].xyz[0] = ( data->fnormals[id-1].xyz[0] +
356 data->fnormals[id].xyz[0] ) / ( float )2.0;
357 data->vnormals[i].xyz[1] = ( data->fnormals[id-1].xyz[1] +
358 data->fnormals[id].xyz[1] ) / ( float )2.0;
359 data->vnormals[i].xyz[2] = ( data->fnormals[id-1].xyz[2] +
360 data->fnormals[id].xyz[2] ) / ( float )2.0;
361 }
362 else if( (i+1)%(data->num_columns+1) == 0 )
363 {
364 r = (i+1)/(data->num_columns+1);
365 data->vnormals[i].xyz[0] =
366 ( data->fnormals[(r-1)*data->num_columns-1].xyz[0] +
367 data->fnormals[r*data->num_columns-1].xyz[0] ) / ( float )2.0;
368 data->vnormals[i].xyz[1] =
369 ( data->fnormals[(r-1)*data->num_columns-1].xyz[1] +
370 data->fnormals[r*data->num_columns-1].xyz[1] ) / ( float )2.0;
371 data->vnormals[i].xyz[2] =
372 ( data->fnormals[(r-1)*data->num_columns-1].xyz[2] +
373 data->fnormals[r*data->num_columns-1].xyz[2] ) / ( float )2.0;
374 }
375 else
376 {
377 r = i/(data->num_columns+1);
378 c = i%(data->num_columns+1);
379
380 id = r*data->num_columns+c;
381
382 data->vnormals[i].xyz[0] =
383 ( data->fnormals[id].xyz[0] +
384 data->fnormals[id-data->num_columns].xyz[0] +
385 data->fnormals[id-1].xyz[0] +
386 data->fnormals[id-data->num_columns-1].xyz[0] ) / ( float )4.0;
387 data->vnormals[i].xyz[1] =
388 ( data->fnormals[id].xyz[1] +
389 data->fnormals[id-data->num_columns].xyz[1] +
390 data->fnormals[id-1].xyz[1] +
391 data->fnormals[id-data->num_columns-1].xyz[1] ) / ( float )4.0;
392 data->vnormals[i].xyz[2] =
393 ( data->fnormals[id].xyz[2] +
394 data->fnormals[id-data->num_columns].xyz[2] +
395 data->fnormals[id-1].xyz[2] +
396 data->fnormals[id-data->num_columns-1].xyz[2] ) / ( float )4.0;
397 }
398 }
399 }
400#ifdef G003
401 data -> d.list = 0;
402 data -> d.dlist = 0;
403 data -> d.degMode = 0;
404 data -> d.model = -1;
405 data -> d.skipRatio = 0.0F;
406 data->d.bDraw = new unsigned char[nv];
407#endif /* G003 */
408 ((tsm_elem_data)(d.pdata))->pdata = data;
409
410 return TSuccess;
411}
412/*----------------------------------------------------------------------*/
413
414static TStatus
415QuadrangleDisplay( TSM_ELEM_DATA data, Tint n, cmn_key *k )
416{
417 CMN_KEY k11, k12, k17, k111, k114;
418
419 Tint front_lighting_model;
420 Tint interior_style;
421 TEL_COLOUR interior_colour;
422 TEL_COLOUR edge_colour;
423
424 tel_qstrip_data d;
425
426 k12.id = TelInteriorReflectanceEquation;
427 k17.id = TelInteriorStyle;
428 k111.id = TelInteriorColour;
429 k111.data.pdata = &interior_colour;
430 k114.id = TelEdgeColour;
431 k114.data.pdata = &edge_colour;
432
433 TsmGetAttri( 4, &k12, &k17, &k111, &k114);
434
435 front_lighting_model = k12.data.ldata;
436 interior_style = k17.data.ldata;
437
438#ifdef PRINT
439 printf("QuadrangleDisplay \n");
440#endif
441
442 /*
443 * Use highlight colours
444 */
445
446 if( k[0]->id == TOn )
447 {
448 TEL_HIGHLIGHT hrep;
449
450 k11.id = TelHighlightIndex;
451 TsmGetAttri( 1, &k11 );
452 if( TelGetHighlightRep( TglActiveWs, k11.data.ldata, &hrep )
453 == TSuccess )
454 {
455 if( hrep.type == TelHLForcedColour )
456 {
457 edge_colour = interior_colour = hrep.col;
458 front_lighting_model = CALL_PHIGS_REFL_NONE;
459 }
460 else if( hrep.type == TelHLColour )
461 {
462 edge_colour = hrep.col;
463 k[0]->id = TOff;
464 }
465 }
466 else
467 {
468 TelGetHighlightRep( TglActiveWs, 0, &hrep );
469 if( hrep.type == TelHLForcedColour )
470 {
471 edge_colour = interior_colour = hrep.col;
472 front_lighting_model = CALL_PHIGS_REFL_NONE;
473 }
474 else if( hrep.type == TelHLColour )
475 {
476 edge_colour = hrep.col;
477 k[0]->id = TOff;
478 }
479 }
480 }
481
482 d = (tel_qstrip_data)data.pdata;
483
484 glColor3fv( interior_colour.rgb );
485
486 draw_qstrip( d,
487 k[0]->id,
488 front_lighting_model,
489 interior_style,
490 &edge_colour );
491
492 return TSuccess;
493}
494
495/*----------------------------------------------------------------------*/
496
497static void draw_qstrip (
498 tel_qstrip_data p,
499 Tint hflag,
500 Tint front_lighting_model,
501 Tint interior_style,
502 tel_colour edge_colour
503 )
504{
505
506 Tint i, m, newList = 0;
507 Tint nf, nv, nr, nc;
508 Tint lighting_model;
509 tel_point pv, pfn, pvn;
510 tel_colour pfc, pvc;
511 tel_texture_coord pvt;
512
513 pfn = p -> fnormals;
514 pfc = p -> fcolours;
515 pv = p -> vertices;
516 pvc = p -> vcolours;
517 pvn = p -> vnormals;
518 pvt = p -> vtexturecoord;
519
520 if ( hflag == TOn ) {
521
522 pvc = 0;
523 pfc = 0;
524
525 } /* end if */
526
527#ifdef G003
528 if ( g_nDegenerateModel < 2 && interior_style != TSM_EMPTY ) {
529#else
530 if ( interior_style != TSM_EMPTY ) {
531#endif /* G003 */
532 if ( front_lighting_model == CALL_PHIGS_REFL_NONE )
533
534 LightOff ();
535
536 else LightOn ();
537
538 lighting_model = front_lighting_model;
539 nr = p -> num_rows;
540 nc = p -> num_columns;
541 nf = nr * nc;
542 nv = ( nr + 1 ) * ( nc + 1 );
543#ifdef G003
544#ifdef BUC60876
545 if ( !g_fAnimation )
546 goto doDraw; /* Disable object display list out of animation */
547#endif
548# ifdef G004
549 if ( g_fBitmap )
550 goto doDraw; /* display lists are NOT shared between */
551 /* window's context and bitmap's one */
552# endif /* G004 */
553 if ( p -> d.model != front_lighting_model || !p -> d.list ||
554 p -> d.model == -1 ||
555 ( g_nDegenerateModel && p -> d.skipRatio != g_fSkipRatio )
556 ) {
557
558 p -> d.skipRatio = g_fSkipRatio;
559 p -> d.model = front_lighting_model;
560 p -> d.degMode = g_nDegenerateModel;
561
562 if ( g_fSkipRatio == 0.0 ) {
563
564 if ( !p -> d.list ) p -> d.list = glGenLists ( 1 );
565
566 glNewList ( p -> d.list, GL_COMPILE_AND_EXECUTE );
567 newList = 1;
568#endif /* G003 */
569#ifdef G004
570doDraw:
571#endif /* G004 */
572 if ( lighting_model == CALL_PHIGS_REFL_NONE ) {
573
574 if ( pvc ) {
575
576 for ( m = 0; m < nr; ++m ) {
577
578 glBegin ( GL_QUAD_STRIP );
579 glColor3fv ( pvc[ m * ( nc + 1 ) ].rgb );
580 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
581 glColor3fv ( pvc[ ( m + 1 ) * ( nc + 1 ) ].rgb );
582 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
583
584 for ( i = 1; i < nc + 1; ++i ) {
585
586 glColor3fv ( pvc[ i + m * ( nc + 1 ) ].rgb );
587 glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
588 glColor3fv ( pvc[ i + ( m + 1 ) * ( nc + 1 ) ].rgb );
589 glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
590
591 } /* end for */
592
593 glEnd ();
594
595 } /* end for */
596
597 } else if ( pfc ) {
598
599 glColor3fv ( pfc[ 0 ].rgb );
600
601 for ( m = 0; m < nr; ++m ) {
602
603 glBegin ( GL_QUAD_STRIP );
604 glColor3fv ( pfc[ m * nc ].rgb );
605 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
606 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
607
608 for ( i = 1; i < nc + 1; ++i ) {
609
610 glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
611 glColor3fv ( pfc[ i - 1 + m * nc ].rgb );
612 glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
613
614 } /* end for */
615
616 glEnd ();
617
618 } /* end for */
619
620 } else {
621
622 for ( m = 0; m < nr; ++m ) {
623
624 glBegin ( GL_QUAD_STRIP );
625 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
626 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
627
628 for ( i = 1; i < nc + 1; ++i ) {
629
630 glVertex3fv( pv[ i + m * ( nc + 1 ) ].xyz );
631 glVertex3fv( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
632
633 } /* end for */
634
635 glEnd ();
636
637 } /* end for */
638
639 } /* end else */
640
641 } else { /* lighting_model != TelLModelNone */
642
643 if ( pvt && !ForbidSetTextureMapping )
644
645 for ( m = 0; m < nr; ++m ) {
646
647 glBegin ( GL_QUAD_STRIP );
648 glNormal3fv ( pvn[ m * ( nc + 1 ) ].xyz );
649 glTexCoord2fv ( pvt[ m * ( nc + 1 ) ].xy );
650 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
651 glNormal3fv ( pvn[ ( m + 1 ) * ( nc + 1 ) ].xyz );
652 glTexCoord2fv ( pvt[ ( m + 1 ) * ( nc + 1 ) ].xy );
653 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
654
655 for ( i = 1; i < nc + 1; ++i ) {
656
657 glNormal3fv ( pvn[ i + m * ( nc + 1 ) ].xyz );
658 glTexCoord2fv ( pvt[ i + m * ( nc + 1 ) ].xy );
659 glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
660 glNormal3fv ( pvn[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
661 glTexCoord2fv ( pvt[ i + ( m + 1 ) * ( nc + 1 ) ].xy );
662 glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
663
664 } /* end for */
665
666 glEnd ();
667
668 } /* end for */
669
670 else
671
672 for ( m = 0; m < nr; ++m ) {
673
674 glBegin ( GL_QUAD_STRIP );
675 glNormal3fv ( pvn[ m * ( nc + 1 ) ].xyz );
676 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
677 glNormal3fv ( pvn[ ( m + 1 ) * ( nc + 1 ) ].xyz );
678 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
679
680 for ( i = 1; i < nc + 1; ++i ) {
681
682 glNormal3fv ( pvn[ i + m * ( nc + 1 ) ].xyz );
683 glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
684 glNormal3fv ( pvn[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
685 glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
686
687 } /* end for */
688
689 glEnd ();
690
691 } /* end for */
692
693 } /* end else */
694#ifdef G003
695 } else if ( g_fSkipRatio != 1.0 ) {
696
697 set_drawable_items ( p -> d.bDraw, nr );
698
699 if ( !p -> d.dlist ) p -> d.dlist = glGenLists ( 1 );
700
701 glNewList ( p -> d.dlist, GL_COMPILE_AND_EXECUTE );
702 newList = 1;
703
704 if ( lighting_model == CALL_PHIGS_REFL_NONE ) {
705
706 if ( pvc ) {
707
708 for ( m = 0; m < nr; ++m )
709
710 if ( p -> d.bDraw[ m ] ) {
711
712 glBegin ( GL_QUAD_STRIP );
713 glColor3fv ( pvc[ m * ( nc + 1 ) ].rgb );
714 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
715 glColor3fv ( pvc[ ( m + 1 ) * ( nc + 1 ) ].rgb );
716 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
717
718 for ( i = 1; i < nc + 1; ++i ) {
719
720 glColor3fv ( pvc[ i + ( m + 1 ) * ( nc + 1 ) ].rgb );
721 glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
722 glColor3fv ( pvc[ i + m * ( nc + 1 ) ].rgb );
723 glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
724
725 } /* end for */
726
727 glEnd ();
728
729 } /* end if */
730
731 } else if ( pfc ) {
732
733 glColor3fv ( pfc[ 0 ].rgb );
734
735 for ( m = 0; m < nr; ++m )
736
737 if ( p -> d.bDraw[ m ] ) {
738
739 glBegin ( GL_QUADS );
740 glColor3fv ( pfc[ m * nc ].rgb );
741 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
742 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
743
744 for ( i = 1; i < nc + 1; ++i ) {
745
746 glColor3fv ( pfc[ i - 1 + m * nc ].rgb );
747 glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
748 glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
749
750 } /* end for */
751
752 glEnd ();
753
754 } /* end if */
755
756 } else {
757
758 for ( m = 0; m < nr; ++m )
759
760 if ( p -> d.bDraw[ m ] ) {
761
762 glBegin ( GL_QUADS );
763 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
764 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
765
766 for ( i = 1; i < nc + 1; ++i ) {
767
768 glVertex3fv( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
769 glVertex3fv( pv[ i + m * ( nc + 1 ) ].xyz );
770
771 } /* end for */
772
773 glEnd ();
774
775 } /* end if */
776
777 } /* end else */
778
779 } else { /* lighting_model != TelLModelNone */
780
781 if ( pvt && !ForbidSetTextureMapping ) {
782
783 for ( m = 0; m < nr; ++m )
784
785 if ( p -> d.bDraw[ m ] ) {
786
787 glBegin ( GL_QUADS );
788 glNormal3fv ( pvn[ m * ( nc + 1 ) ].xyz );
789 glTexCoord2fv ( pvt[ m * ( nc + 1 ) ].xy );
790 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
791 glNormal3fv ( pvn[ ( m + 1 ) * ( nc + 1 ) ].xyz );
792 glTexCoord2fv ( pvt[ ( m + 1 ) * ( nc + 1 ) ].xy );
793 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
794
795 for ( i = 1; i < nc + 1; ++i ) {
796
797 glNormal3fv ( pvn[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
798 glTexCoord2fv ( pvt[ i + ( m + 1 ) * ( nc + 1 ) ].xy );
799 glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
800 glNormal3fv ( pvn[ i + m * ( nc + 1 ) ].xyz );
801 glTexCoord2fv ( pvt[ i + m * ( nc + 1 ) ].xy );
802 glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
803
804 } /* end for */
805
806 glEnd ();
807
808 } /* end if */
809
810 } else
811
812 for ( m = 0; m < nr; ++m )
813
814 if ( p -> d.bDraw[ m ] ) {
815
816 glBegin ( GL_QUADS );
817 glNormal3fv ( pvn[ m * ( nc + 1 ) ].xyz );
818 glVertex3fv ( pv[ m * ( nc + 1 ) ].xyz );
819 glNormal3fv ( pvn[ ( m + 1 ) * ( nc + 1 ) ].xyz );
820 glVertex3fv ( pv[ ( m + 1 ) * ( nc + 1 ) ].xyz );
821
822 for ( i = 1; i < nc + 1; ++i ) {
823
824 glNormal3fv ( pvn[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
825 glVertex3fv ( pv[ i + ( m + 1 ) * ( nc + 1 ) ].xyz );
826 glNormal3fv ( pvn[ i + m * ( nc + 1 ) ].xyz );
827 glVertex3fv ( pv[ i + m * ( nc + 1 ) ].xyz );
828
829 } /* end for */
830
831 glEnd ();
832
833 } /* end if */
834
835 } /* end else */
836
837 } else {
838
839 if ( !p -> d.dlist ) p -> d.dlist = glGenLists ( 1 );
840
841 glNewList ( p -> d.dlist, GL_COMPILE_AND_EXECUTE );
842 newList = 1;
843
844 } /* end else */
845 if ( newList ) glEndList ();
846
847 if ( g_nDegenerateModel ) return;
848
849 } else {
850
851 glCallList ( g_fSkipRatio == 0.0 ? p -> d.list : p -> d.dlist );
852
853 if ( g_nDegenerateModel ) return;
854
855 } /* end else */
856#endif /* G003 */
857 } /* end if ( interior_style != TSM_EMPTY ) */
858#ifdef G003
859 i = 0;
860
861 /* OCC11904 -- Temporarily disable environment mapping */
862 glPushAttrib(GL_ENABLE_BIT);
863 glDisable(GL_TEXTURE_1D);
864 glDisable(GL_TEXTURE_2D);
865
866 switch ( g_nDegenerateModel ) {
867
868default:
869 break;
870
871case 2: /* XXX_TDM_WIREFRAME */
872 i = 1;
873 break;
874
875case 3: /* XXX_TDM_MARKER */
876 draw_degenerates_as_points (
877 &p -> d, p -> vertices, ( p -> num_rows + 1 ) * ( p -> num_columns + 1 )
878 );
879
880 glPopAttrib();
881
882 return;
883
884case 4: /* XXX_TDM_BBOX */
885 draw_degenerates_as_bboxs (
886 &p -> d, p -> vertices, ( p -> num_rows + 1 ) * ( p -> num_columns + 1 )
887 );
888
889 glPopAttrib();
890
891 return;
892
893 } /* end switch */
894
895 draw_edges ( p, edge_colour, interior_style, i );
896#else
897 draw_edges ( p, edge_colour, interior_style );
898#endif /* G003 */
899
900 glPopAttrib();
901} /* end draw_qstrip */
902/*----------------------------------------------------------------------*/
903static TStatus
904QuadrangleDelete( TSM_ELEM_DATA data, Tint n, cmn_key *k )
905{
906 tel_qstrip_data p;
907
908 p = (tel_qstrip_data)data.pdata;
909 if( p->fnormals ) //cmn_freemem( p->fnormals );
910 delete[] p->fnormals;
911 if( p->fcolours ) //cmn_freemem( p->fcolours );
912 delete[] p->fcolours;
913 if( p->vertices ) //cmn_freemem( p->vertices );
914 delete[] p->vertices;
915 if( p->vcolours ) //cmn_freemem( p->vcolours );
916 delete[] p->vcolours;
917 if( p->vnormals ) //cmn_freemem( p->vnormals );
918 delete[] p->vnormals;
919 if (p->vtexturecoord) //cmn_freemem(p->vtexturecoord);
920 delete[] p->vtexturecoord;
921
922 if (data.pdata)
923 delete data.pdata;
924
925 return TSuccess;
926}
927
928/*----------------------------------------------------------------------*/
929static TStatus
930QuadranglePrint( TSM_ELEM_DATA data, Tint n, cmn_key *k )
931{
932 Tint i;
933 tel_qstrip_data p = (tel_qstrip_data)data.pdata;
934
935 fprintf(stdout, "TelQuadrangle. ");
936 fprintf(stdout, "\n\tNumber of Rows : %d\n", p->num_rows);
937 fprintf(stdout, "\n\tNumber of Columns : %d\n", p->num_columns);
938 switch( p->shape_flag )
939 {
940 case TEL_SHAPE_UNKNOWN:
941 fprintf( stdout, "\t\tShape Flag : UNKNOWN\n" );
942 break;
943
944 case TEL_SHAPE_COMPLEX:
945 fprintf( stdout, "\t\tShape Flag : COMPLEX\n" );
946 break;
947
948 case TEL_SHAPE_CONCAVE:
949 fprintf( stdout, "\t\tShape Flag : CONCAVE\n" );
950 break;
951
952 case TEL_SHAPE_CONVEX:
953 fprintf( stdout, "\t\tShape Flag : CONVEX\n" );
954 break;
955
956 }
957 switch( p->facet_flag )
958 {
959 case TEL_FA_NONE:
960 if( p->fcolours )
961 fprintf( stdout, "\t\tFacet Flag : COLOUR\n" );
962 else
963 fprintf( stdout, "\t\tFacet Flag : NONE\n" );
964 break;
965
966 case TEL_FA_NORMAL:
967 if( p->fcolours )
968 fprintf( stdout, "\t\tFacet Flag : COLOURNORMAL\n" );
969 else
970 fprintf( stdout, "\t\tFacet Flag : NORMAL\n" );
971 break;
972 }
973
974 switch( p->vertex_flag )
975 {
976 case TEL_VT_NONE:
977 if( p->vcolours )
978 fprintf( stdout, "\t\tVertex Flag : COLOUR\n" );
979 else
980 fprintf( stdout, "\t\tVertex Flag : NONE\n" );
981 break;
982
983 case TEL_VT_NORMAL:
984 if( p->vcolours )
985 fprintf( stdout, "\t\tVertex Flag : COLOURNORMAL\n" );
986 else
987 fprintf( stdout, "\t\tVertex Flag : NORMAL\n" );
988 break;
989 }
990 if( p->fnormals )
991 {
992 fprintf( stdout, "\n\t\tFacet Normals : " );
993 for( i = 0; i < (p->num_rows * p->num_columns); i++ )
994 fprintf( stdout, "\n\t\t v[%d] = %g %g %g", i,
995 p->fnormals[i].xyz[0],
996 p->fnormals[i].xyz[1],
997 p->fnormals[i].xyz[2] );
998 }
999 else
1000 fprintf( stdout, "\n\t\tFacet Normals not specified\n" );
1001
1002 if( p->fcolours )
1003 {
1004 fprintf( stdout, "\n\t\tFacet Colours : " );
1005 for( i = 0; i < (p->num_rows * p->num_columns+1); i++ )
1006 fprintf( stdout, "\n\t\t v[%d] = %g %g %g", i,
1007 p->fcolours[i].rgb[0],
1008 p->fcolours[i].rgb[1],
1009 p->fcolours[i].rgb[2] ); }
1010 else
1011 fprintf( stdout, "\n\t\tFacet Colours not specified\n" );
1012 if( p->vertices )
1013 {
1014 fprintf( stdout, "\n\t\tVertices : " );
1015 for( i = 0; i < (p->num_rows+1)*(p->num_columns+1); i++ )
1016 fprintf( stdout, "\n\t\t v[%d] = %g %g %g", i,
1017 p->vertices[i].xyz[0],
1018 p->vertices[i].xyz[1],
1019 p->vertices[i].xyz[2] ); }
1020
1021 fprintf( stdout, "\n" );
1022 if( p->vcolours )
1023 {
1024 fprintf( stdout, "\n\t\tVertex Colours : " );
1025 for( i = 0; i < (p->num_rows+1)*(p->num_columns+1); i++ )
1026 fprintf( stdout, "\n\t\t v[%d] = %g %g %g", i,
1027 p->vcolours[i].rgb[0],
1028 p->vcolours[i].rgb[1],
1029 p->vcolours[i].rgb[2] ); }
1030 else
1031 fprintf( stdout, "\n\t\tVertex Colours not specified\n" );
1032
1033 if( p->vnormals )
1034 {
1035 fprintf( stdout, "\n\t\tVertex Normals : " );
1036 for( i = 0; i < (p->num_rows+1)*(p->num_columns+1); i++ )
1037 fprintf( stdout, "\n\t\t v[%d] = %g %g %g", i,
1038 p->vnormals[i].xyz[0],
1039 p->vnormals[i].xyz[1],
1040 p->vnormals[i].xyz[2] ); }
1041 else
1042 fprintf( stdout, "\n\t\tVertex Normals not specified\n" );
1043
1044 if (p->vtexturecoord)
1045 {
1046 fprintf(stdout, "\n\t\tTexture Coordinates : ");
1047 for (i=0; i<(p->num_rows+1)*(p->num_columns+1); i++)
1048 fprintf(stdout, "\n\t\t v[%d] = %g %g", i,
1049 p->vtexturecoord[i].xy[0],
1050 p->vtexturecoord[i].xy[1]);
1051 }
1052 else
1053 fprintf( stdout, "\n\t\tTexture Coordinates not specified\n");
1054
1055 fprintf( stdout, "\n" );
1056
1057 return TSuccess;
1058}
1059
1060/*----------------------------------------------------------------------*/
1061#ifdef G003
1062static void draw_edges (
1063 tel_qstrip_data p,
1064 tel_colour edge_colour,
1065 Tint interior_style,
1066 Tint forceDraw
1067 )
1068{
1069#else
1070static void draw_edges (
1071 tel_qstrip_data p,
1072 tel_colour edge_colour,
1073 Tint interior_style
1074 )
1075{
1076#endif /* G003 */
1077 CMN_KEY k, k1, k2, k3, k4;
1078 Tint nf, nc, newList = 0;
1079 Tint edge_type, line_type_preserve;
1080 Tfloat edge_width, line_width_preserve;
1081 GLboolean texture_on;
1082 tel_point pv;
1083#ifdef G003
1084 if ( interior_style != TSM_HIDDENLINE && !forceDraw )
1085 {
1086#else
1087 if ( interior_style != TSM_HIDDENLINE )
1088 {
1089#endif /* G003 */
1090 k.id = TelEdgeFlag;
1091 TsmGetAttri ( 1, &k );
1092
1093 if ( k.data.ldata == TOff ) return;
1094
1095 } /* end if */
1096
1097 pv = p -> vertices;
1098
1099 LightOff ();
1100 texture_on = IsTextureEnabled ();
1101
1102 if ( texture_on ) DisableTexture ();
1103
1104 k1.id = TelPolylineWidth;
1105 k2.id = TelPolylineType;
1106 k3.id = TelEdgeType;
1107 k4.id = TelEdgeWidth;
1108 TsmGetAttri ( 4, &k1, &k2, &k3, &k4 );
1109
1110 line_width_preserve = k1.data.fdata;
1111 line_type_preserve = k2.data.ldata;
1112 edge_type = k3.data.ldata;
1113 edge_width = k4.data.fdata;
1114
1115 nc = p -> num_columns;
1116 nf = p -> num_rows * p->num_columns;
1117
1118 if ( line_width_preserve != edge_width ) {
1119
1120 k.id = TelPolylineWidth;
1121 k.data.fdata = edge_width;
1122 TsmSetAttri ( 1, &k );
1123
1124 } /* end if */
1125
1126 if ( line_type_preserve != edge_type ) {
1127
1128 k.id = TelPolylineType;
1129 k.data.ldata = edge_type;
1130 TsmSetAttri ( 1, &k );
1131
1132 } /* end if */
1133#ifdef G003
1134 if ( !forceDraw )
1135#endif /* G003 */
1136 draw_line_strip ( p, edge_colour, nf, nc );
1137#ifdef G003
1138 else {
1139#ifdef BUC60876
1140 if ( !g_fAnimation )
1141 goto doDraw; /* Disable object display list out of animation */
1142#endif
1143# ifdef G004
1144 if ( g_fBitmap )
1145 goto doDraw;
1146# endif /* G004 */
1147 if ( p -> d.degMode != 2 || p -> d.skipRatio != g_fSkipRatio || !p -> d.dlist ) {
1148
1149 if ( !p -> d.dlist ) p -> d.dlist = glGenLists ( 1 );
1150
1151 p -> d.degMode = 2;
1152 p -> d.skipRatio = g_fSkipRatio;
1153 glNewList ( p -> d.dlist, GL_COMPILE_AND_EXECUTE );
1154 newList = 1;
1155doDraw:
1156 glPushAttrib ( GL_DEPTH_BUFFER_BIT );
1157 glDisable ( GL_DEPTH_TEST );
1158
1159 if ( g_fSkipRatio == 0.0 )
1160
1161 draw_line_strip ( p, edge_colour, nf, nc );
1162
1163 else if ( g_fSkipRatio != 1.0 ) {
1164
1165 int i, m1, m2, n1, n2, n3, n4;
1166
1167 set_drawable_items ( p -> d.bDraw, nf );
1168
1169 glColor3fv ( edge_colour -> rgb );
1170
1171 for ( i = 0; i < nf; ++i )
1172
1173 if ( p -> d.bDraw[ i ] ) {
1174
1175 glBegin ( GL_LINE_STRIP );
1176 m1 = i / nc;
1177 m2 = i % nc;
1178 n1 = m1 * ( nc + 1 ) + m2;
1179 n2 = n1 + nc + 1;
1180 n3 = n2 + 1;
1181 n4 = n1 + 1;
1182
1183 glVertex3fv ( p -> vertices[ n1 ].xyz );
1184 glVertex3fv ( p -> vertices[ n2 ].xyz );
1185 glVertex3fv ( p -> vertices[ n3 ].xyz );
1186 glVertex3fv ( p -> vertices[ n4 ].xyz );
1187 glVertex3fv ( p -> vertices[ n1 ].xyz );
1188 glEnd();
1189
1190 } /* end if */
1191
1192 } /* end if */
1193
1194 glPopAttrib ();
1195 if ( newList ) glEndList ();
1196
1197 } else glCallList ( p -> d.dlist );
1198
1199 } /* end else */
1200#endif /* G003 */
1201 if ( line_width_preserve != edge_width ) {
1202
1203 k.id = TelPolylineWidth;
1204 k.data.fdata = line_width_preserve;
1205 TsmSetAttri ( 1, &k );
1206
1207 } /* end if */
1208
1209 if ( line_type_preserve != edge_type ) {
1210
1211 k.id = TelPolylineType;
1212 k.data.ldata = line_type_preserve;
1213 TsmSetAttri ( 1, &k );
1214
1215 } /* end if */
1216
1217 if ( texture_on ) EnableTexture ();
1218
1219} /* end draw_edges */
1220
1221static void draw_line_strip ( tel_qstrip_data p, tel_colour c, Tint nf, Tint nc ) {
1222
1223 int i, m1, m2, n1, n2, n3, n4;
1224
1225 glColor3fv ( c -> rgb );
1226
1227 for ( i = 0; i < nf; ++i ) {
1228
1229 glBegin ( GL_LINE_STRIP );
1230 m1 = i / nc;
1231 m2 = i % nc;
1232 n1 = m1 * ( nc + 1 ) + m2;
1233 n2 = n1 + nc + 1;
1234 n3 = n2 + 1;
1235 n4 = n1 + 1;
1236
1237 glVertex3fv ( p -> vertices[ n1 ].xyz );
1238 glVertex3fv ( p -> vertices[ n2 ].xyz );
1239 glVertex3fv ( p -> vertices[ n3 ].xyz );
1240 glVertex3fv ( p -> vertices[ n4 ].xyz );
1241 glVertex3fv ( p -> vertices[ n1 ].xyz );
1242 glEnd();
1243
1244 } /* end for */
1245
1246} /* end draw_line_strip */
1247/*----------------------------------------------------------------------*/
1248
1249static TStatus
1250QuadrangleInquire( TSM_ELEM_DATA data, Tint n, cmn_key *k )
1251{
1252 Tint i, j;
1253 tel_qstrip_data d;
1254 Tint size_reqd=0;
1255 TStatus status = TSuccess;
1256 Tchar *cur_ptr = 0;
1257 Tint nf, nv;
1258
1259 d = (tel_qstrip_data)data.pdata;
1260 nf = d->num_rows * d->num_columns;
1261 nv = ( d->num_rows + 1 ) * ( d->num_columns + 1 );
1262
1263 if( d->fcolours )
1264 size_reqd += ( nf * sizeof( TEL_COLOUR ) );
1265
1266 if( d->facet_flag == TEL_FA_NORMAL )
1267 size_reqd += ( nf * sizeof( TEL_POINT ) );
1268
1269 size_reqd += ( nv * sizeof( TEL_POINT ) );
1270
1271 if( d->vcolours )
1272 size_reqd += ( nv * sizeof( TEL_COLOUR ) );
1273
1274 if( d->vertex_flag == TEL_VT_NORMAL )
1275 size_reqd += ( nv * sizeof( TEL_POINT ) );
1276
1277 for( i = 0; i < n; i++ )
1278 {
1279 switch( k[i]->id )
1280 {
1281 case INQ_GET_SIZE_ID:
1282 {
1283 k[i]->data.ldata = size_reqd;
1284 break;
1285 }
1286
1287 case INQ_GET_CONTENT_ID:
1288 {
1289 TEL_INQ_CONTENT *c;
1290 Teldata *w;
1291
1292 c = (tel_inq_content)k[i]->data.pdata;
1293 c->act_size = size_reqd;
1294 w = c->data;
1295
1296 cur_ptr = c->buf;
1297 w->quadmesh3data.shpflag = d->shape_flag;
1298 w->quadmesh3data.dim.x_dim = d->num_rows;
1299 w->quadmesh3data.dim.y_dim = d->num_columns;
1300
1301 if( c->size >= size_reqd )
1302 {
1303 if( d->facet_flag == TEL_FA_NORMAL )
1304 {
1305 if( d->fcolours )
1306 {
1307 w->quadmesh3data.fctflag = TEL_FAFLAG_COLOURNORMAL;
1308 w->quadmesh3data.gnormals = (tel_point)(c->buf);
1309 for( j = 0; j < nf; j++ )
1310 {
1311 w->quadmesh3data.gnormals[j] = d->fnormals[j];
1312 }
1313 cur_ptr += ( nf * sizeof( TEL_POINT ) );
1314
1315 w->quadmesh3data.facet_colour_vals =
1316 (tel_colour)(cur_ptr);
1317 for( j = 0; j < nf; j++ )
1318 {
1319 w->quadmesh3data.facet_colour_vals[j] =
1320 d->fcolours[j];
1321 }
1322 cur_ptr += ( nf * sizeof( TEL_COLOUR ) );
1323 }
1324 else
1325 {
1326 w->quadmesh3data.fctflag = TEL_FAFLAG_NORMAL;
1327 w->quadmesh3data.facet_colour_vals = 0;
1328 w->quadmesh3data.gnormals = (tel_point)(c->buf);
1329 for( j = 0; j < nf; j++ )
1330 {
1331 w->quadmesh3data.gnormals[j] = d->fnormals[j];
1332 }
1333 cur_ptr += ( nf * sizeof( TEL_POINT ) );
1334 }
1335 }
1336 else
1337 {
1338 w->quadmesh3data.gnormals = 0;
1339 if( d->fcolours )
1340 {
1341 w->quadmesh3data.fctflag = TEL_FAFLAG_COLOUR;
1342 w->quadmesh3data.facet_colour_vals =
1343 (tel_colour)(c->buf );
1344 for( j = 0; j < nf; j++ )
1345 {
1346 w->quadmesh3data.facet_colour_vals[j] =
1347 d->fcolours[j];
1348 }
1349 cur_ptr += ( nf * sizeof( TEL_COLOUR ) );
1350 }
1351 else
1352 {
1353 w->quadmesh3data.fctflag = TEL_FAFLAG_NONE;
1354 w->quadmesh3data.facet_colour_vals = 0;
1355 }
1356 }
1357
1358 w->quadmesh3data.points = (tel_point)cur_ptr;
1359 for( j = 0; j < nv; j++ )
1360 {
1361 w->quadmesh3data.points[j] = d->vertices[j];
1362 }
1363 cur_ptr += ( nv * sizeof( TEL_POINT ) );
1364
1365 if( d->vertex_flag == TEL_VT_NORMAL )
1366 {
1367 if( d->vcolours )
1368 {
1369 w->quadmesh3data.vrtflag = TEL_VTFLAG_COLOURNORMAL;
1370 w->quadmesh3data.vnormals = (tel_point)(cur_ptr);
1371 for( j = 0; j < nv; j++ )
1372 {
1373 w->quadmesh3data.vnormals[j] = d->vnormals[i];
1374 }
1375 cur_ptr += ( nv * sizeof( TEL_POINT ) );
1376
1377 w->quadmesh3data.colours = (tel_colour)(cur_ptr);
1378
1379 for( j = 0; j < nv; j++ )
1380 {
1381 w->quadmesh3data.colours[j] = d->vcolours[i];
1382 }
1383 }
1384 else
1385 {
1386 w->quadmesh3data.vrtflag = TEL_VTFLAG_NORMAL;
1387 w->quadmesh3data.colours = 0;
1388 w->quadmesh3data.vnormals = (tel_point)(cur_ptr);
1389
1390 for( j = 0; j < nv; j++ )
1391 {
1392 w->quadmesh3data.vnormals[j] = d->vnormals[i];
1393 }
1394 }
1395 }
1396 else
1397 {
1398 w->quadmesh3data.vnormals = 0;
1399 if( d->vcolours )
1400 {
1401 w->quadmesh3data.vrtflag = TEL_VTFLAG_COLOUR;
1402 w->quadmesh3data.colours = (tel_colour)(cur_ptr);
1403 for( j = 0; j < nv; j++ )
1404 {
1405 w->quadmesh3data.colours[j] = d->vcolours[i];
1406 }
1407 }
1408 else
1409 {
1410 w->quadmesh3data.vrtflag = TEL_VTFLAG_NONE;
1411 w->quadmesh3data.colours = 0;
1412 }
1413 }
1414
1415 status = TSuccess;
1416 }
1417 else
1418 status = TFailure;
1419 break;
1420 }
1421 }
1422 }
1423 return status;
1424}
1425
1426/*----------------------------------------------------------------------*/