0022149: Strings with Japanese characters can not be displayed in 3D viewer
[occt.git] / src / OpenGl / OpenGl_subrs.cxx
CommitLineData
7fd59977 1/***********************************************************************
2
3FONCTION :
4----------
5File OpenGl_subrs :
6
7
8REMARQUES:
9----------
10
11
12HISTORIQUE DES MODIFICATIONS :
13--------------------------------
14xx-xx-xx : xxx ; Creation.
1511-03-96 : FMN ; Correction warning compilation
1601-04-96 : CAL ; Integration MINSK portage WNT
1726-04-96 : FMN ; Correction warning compilation
1810-06-96 : CAL ; Transparence dans call_subr_set_refl_props
1917-07-96 : CAL ; Suppression de CALL_PHIGS_ELEM_HLHSR_ID
2007-10-96 : FMN ; Suppression code inutile
2121-08-97 : PCT ; ajout deuxieme passe pour les textures
2223-12-97 : FMN ; Suppression TelBackInteriorStyle, TelBackInteriorStyleIndex
2329-12-97 : FMN ; Ajout cas 4 pour call_subr_polygon_indices()
2430-12-97 : FMN ; CTS18312: Correction back material
2508-04-98 : FGU ; Ajout emission
2630-11-98 : FMN ; S3819 : Textes toujours visibles
2716-06-2000 : ATS,GG : G005 : Group of functions: call_subr_parray
28
29************************************************************************/
30
31#define IMP190602 /* GG Avoid memory leaks after creating a polyline
32// with vertex colors primitive.
33// Thanks to Ivan Fontaine (SAMTECH) for this improvment
34*/
35
36/*----------------------------------------------------------------------*/
37/*
38* Includes
39*/
40
41
42#include <OpenGl_tgl_all.hxx>
43
44#include <stdio.h>
45#include <stddef.h>
46#include <stdlib.h>
47
48#include <InterfaceGraphic_Graphic3d.hxx>
49
50#include <OpenGl_cmn_varargs.hxx>
51#include <OpenGl_tsm.hxx>
52#include <OpenGl_tsm_ws.hxx>
53#include <OpenGl_telem.hxx>
54#include <OpenGl_tgl_funcs.hxx>
55#include <OpenGl_tgl_subrs.hxx>
56#include <OpenGl_telem_inquire.hxx>
57#include <OpenGl_telem_view.hxx>
58#include <OpenGl_tgl_elems.hxx>
59#include <OpenGl_Memory.hxx>
60
61void
62call_subr_set_line_colr( Tfloat r, Tfloat g, Tfloat b )
63{
64 CMN_KEY key;
65 TEL_COLOUR col;
66
67 col.rgb[0] = r,
68 col.rgb[1] = g,
69 col.rgb[2] = b;
70 key.data.pdata = &col;
71 TsmAddToStructure( TelPolylineColour, 1, &key );
72
73 return;
74}
75
76
77void
78call_subr_polyline( CALL_DEF_LISTPOINTS * alpoints )
79{
80 CMN_KEY key[4];
81 cmn_key kp[4];
82
83 kp[0] = &key[0], kp[1] = &key[1], kp[2] = &key[2], kp[3] = &key[3];
84 key[0].id = NUM_LINES_ID;
85 key[0].data.ldata = 1;
86 key[1].id = VERTICES_ID;
87 key[1].data.pdata = alpoints->UPoints.Points;
88 key[2].id = BOUNDS_DATA_ID;
89 key[2].data.pdata = &alpoints->NbPoints;
90 key[3].id = NUM_VERTICES_ID;
91 key[3].data.ldata = alpoints->NbPoints;
92 TsmAddToStructure( TelPolyline, -4, kp );
93
94 return;
95}
96
97
98void
99call_subr_polyline_data( CALL_DEF_LISTPOINTS * alpoints )
100{
101 CMN_KEY key[5];
102 cmn_key kp[5];
103 tel_point points;
104 tel_colour col;
105 register Tint i;
106
107 if( alpoints->TypePoints != 3 )
108 return; /* Coordinates and Vertex Colour not Specified */
109
110 points = new TEL_POINT[alpoints->NbPoints];
111 if( !points )
112 return;
113
114 col = new TEL_COLOUR[alpoints->NbPoints];
115 if( !col )
116 {
117 delete[] points;
118 return;
119 }
120
121 for( i = 0; i < alpoints->NbPoints; i++ )
122 {
123 points[i].xyz[0] = alpoints->UPoints.PointsC[i].Point.x;
124 points[i].xyz[1] = alpoints->UPoints.PointsC[i].Point.y;
125 points[i].xyz[2] = alpoints->UPoints.PointsC[i].Point.z;
126 col[i].rgb[0] = alpoints->UPoints.PointsC[i].Color.r;
127 col[i].rgb[1] = alpoints->UPoints.PointsC[i].Color.g;
128 col[i].rgb[2] = alpoints->UPoints.PointsC[i].Color.b;
129 }
130
131 key[0].id = NUM_LINES_ID;
132 key[0].data.ldata = 1;
133 key[1].id = VERTEX_COLOUR_VALS_ID;
134 key[1].data.pdata = col;
135 key[2].id = VERTICES_ID;
136 key[2].data.pdata = points;
137 key[3].id = BOUNDS_DATA_ID;
138 key[3].data.pdata = &alpoints->NbPoints;
139 key[4].id = NUM_VERTICES_ID;
140 key[4].data.ldata = alpoints->NbPoints;
141
142 for( i = 0; i < 5; i++ )
143 kp[i] = &key[i];
144
145 TsmAddToStructure( TelPolyline, -5, kp );
146
147#ifdef IMP190602
148 delete[] points;
149 delete col;
150#endif
151
152 return;
153}
154
155
156
157void
158call_subr_remnameset( Tint num, Tint *ns )
159{
160 CMN_KEY key;
161
162 key.id = num;
163 key.data.pdata = ns;
164 TsmAddToStructure( TelRemoveNameset, 1, &key );
165
166 return;
167}
168
169
170void
171call_subr_addnameset( Tint num, Tint *ns )
172{
173 CMN_KEY key;
174
175 key.id = num;
176 key.data.pdata = ns;
177 TsmAddToStructure( TelAddNameset, 1, &key );
178
179 return;
180}
181
182void
183call_subr_set_back_int_colr( Tfloat r, Tfloat g, Tfloat b, Tfloat a )
184{
185 CMN_KEY key;
186 TEL_COLOUR col;
187
188 col.rgb[0] = r,
189 col.rgb[1] = g,
190 col.rgb[2] = b;
191 key.data.pdata = &col;
192 TsmAddToStructure( TelBackInteriorColour, 1, &key );
193
194 return;
195}
196
197
198
199void
200call_subr_set_int_colr( Tfloat r, Tfloat g, Tfloat b, Tfloat a )
201{
202 CMN_KEY key;
203 TEL_COLOUR col;
204
205 col.rgb[0] = r,
206 col.rgb[1] = g,
207 col.rgb[2] = b;
208 key.data.pdata = &col;
209 TsmAddToStructure( TelInteriorColour, 1, &key );
210
211 return;
212}
213
214void
215call_subr_set_edge_colr( Tfloat r, Tfloat g, Tfloat b )
216{
217 CMN_KEY key;
218 TEL_COLOUR col;
219
220 col.rgb[0] = r,
221 col.rgb[1] = g,
222 col.rgb[2] = b;
223 key.data.pdata = &col;
224 TsmAddToStructure( TelEdgeColour, 1, &key );
225
226 return;
227}
228
229
230void
231call_subr_set_refl_props( CALL_DEF_MATERIAL * material, Tint tag )
232{
233 CMN_KEY key;
234 TEL_SURF_PROP surface;
235
236 /* Par defaut tout a 0 */
237 surface.amb = ( float )0.0;
238 surface.diff = ( float )0.0;
239 surface.spec = ( float )0.0;
240 surface.emsv = ( float )0.0;
241 surface.isamb = (int)0;
242 surface.isdiff = (int)0;
243 surface.isspec = (int)0;
244 surface.isemsv = (int)0;
245 surface.isphysic = (int)0;
246
247 /* Cas par cas pour l evaluation */
248 if( material->IsAmbient )
249 {
250 surface.amb = material->Ambient;
251 surface.isamb = 1;
252 }
253 if( material->IsDiffuse )
254 {
255 surface.diff = material->Diffuse;
256 surface.isdiff = 1;
257 }
258 if( material->IsSpecular )
259 {
260 surface.spec = material->Specular;
261 surface.isspec = 1;
262 }
263 if( material->IsEmission )
264 {
265 surface.emsv = material->Emission;
266 surface.isemsv = 1;
267 }
268
269 /* type de materiel */
270 if( material->IsPhysic )
271 surface.isphysic = 1;
272
273 /* Couleur du materiel */
274
275 /* Couleur eclairage ambient */
276 surface.ambcol.rgb[0] = material->ColorAmb.r;
277 surface.ambcol.rgb[1] = material->ColorAmb.g;
278 surface.ambcol.rgb[2] = material->ColorAmb.b;
279
280 /* Couleur eclairage diffus */
281 surface.difcol.rgb[0] = material->ColorDif.r;
282 surface.difcol.rgb[1] = material->ColorDif.g;
283 surface.difcol.rgb[2] = material->ColorDif.b;
284
285 /* Couleur eclairage speculaire */
286 surface.speccol.rgb[0] = material->ColorSpec.r;
287 surface.speccol.rgb[1] = material->ColorSpec.g;
288 surface.speccol.rgb[2] = material->ColorSpec.b;
289
290 /* Couleur d emission */
291 surface.emscol.rgb[0] = material->ColorEms.r;
292 surface.emscol.rgb[1] = material->ColorEms.g;
293 surface.emscol.rgb[2] = material->ColorEms.b;
294
295 surface.shine = ( float )128 * material->Shininess;
296 surface.env_reflexion = material->EnvReflexion;
297
298 /* Dans la couche C++ :
299 * prop->trans = 0. => opaque
300 * prop->trans = 1. => transparent
301 * en OpenGl c'est le contraire.
302 */
303 surface.trans = 1.0F - material->Transparency;
304
305 key.data.pdata = &surface;
306 TsmAddToStructure( tag ? TelBackSurfaceAreaProperties :
307 TelSurfaceAreaProperties, 1, &key );
308 return;
309}
310
311void
312call_subr_set_marker_colr( Tfloat r, Tfloat g, Tfloat b )
313{
314 CMN_KEY key;
315 TEL_COLOUR col;
316
317 col.rgb[0] = r,
318 col.rgb[1] = g,
319 col.rgb[2] = b;
320 key.data.pdata = &col;
321 TsmAddToStructure( TelPolymarkerColour, 1, &key );
322
323 return;
324}
325
326
327TStatus
328call_subr_get_exec_struct( Tint afather, Tint ason, Tint *ind )
329{
330 tsm_node node;
331 Tint i, num;
332
333 if( TsmGetStructure( afather, &num, &node ) == TSuccess )
334 {
335 for( i = 0; i < num; i++, node = node->next )
336 {
337 if( node->elem.el == TelExecuteStructure )
338 if( node->elem.data.ldata == ason )
339 {
340 *ind = (i+1);
341 return TSuccess;
342 }
343 }
344 }
345 return TFailure;
346}
347
348
349void
350call_subr_marker( CALL_DEF_MARKER * amarker )
351{
352 CMN_KEY key;
353 TEL_POINT pt;
354
355 key.id = 1;
356 pt.xyz[0] = amarker->x,
357 pt.xyz[1] = amarker->y,
358 pt.xyz[2] = amarker->z;
359 key.data.pdata = &pt;
360 TsmAddToStructure( TelMarkerSet, 1, &key );
361
362 return;
363}
364
365
366void
367call_subr_marker_set( CALL_DEF_LISTMARKERS * almarkers )
368{
369 CMN_KEY key;
370
371 key.id = almarkers->NbMarkers;
372 key.data.pdata = almarkers->Markers;
373 TsmAddToStructure( TelMarkerSet, 1, &key );
374
375 return;
376}
377
378
379void
380call_subr_polygon( CALL_DEF_FACET * afacet )
381{
382 CMN_KEY k[3];
383
384 k[0].id = NUM_VERTICES_ID;
385 k[0].data.ldata = afacet->NbPoints;
386
387 k[1].id = SHAPE_FLAG_ID;
388 k[1].data.ldata = TEL_SHAPE_UNKNOWN;
389
390 switch (afacet->TypeFacet) {
391 case 0 : /* TOP_UNKNOWN */
392 k[1].data.ldata = TEL_SHAPE_UNKNOWN;
393 break;
394 case 1 : /* TOP_COMPLEX */
395 k[1].data.ldata = TEL_SHAPE_COMPLEX;
396 break;
397 case 2 : /* TOP_CONCAVE */
398 k[1].data.ldata = TEL_SHAPE_CONCAVE;
399 break;
400 case 3 : /* TOP_CONVEX */
401 k[1].data.ldata = TEL_SHAPE_CONVEX;
402 break;
403 }
404
405#if defined(__sgi) || defined(IRIX)
406 /* Pb avec le tesselator sgi */
407 k[1].data.ldata = TEL_SHAPE_CONVEX;
408#endif
409
410 k[2].id = VERTICES_ID;
411 k[2].data.pdata = afacet->UPoints.Points;
412
413 TsmAddToStructure( TelPolygon, 3, &k[0], &k[1], &k[2] );
414
415 return;
416}
417
418
419void
420call_subr_polygon_data( CALL_DEF_FACET * afacet )
421{
422 CMN_KEY k[10];
423 cmn_key kp[10];
424 Tint nk = 0, i;
425 TEL_COLOUR col;
426 void *npt;
427 TEL_POINT *pts=0, *ptn=0;
428 TEL_TEXTURE_COORD *ptt=0;
429
430 k[nk].id = NUM_VERTICES_ID;
431 k[nk].data.ldata = afacet->NbPoints;
432 nk++;
433
434 if( afacet->ColorIsDefined )
435 {
436 col.rgb[0] = afacet->Color.r;
437 col.rgb[1] = afacet->Color.g;
438 col.rgb[2] = afacet->Color.b;
439
440 k[nk].id = FACET_COLOUR_VALS_ID;
441 k[nk].data.pdata = &col;
442 nk++;
443 }
444
445 if( afacet->NormalIsDefined )
446 {
447 npt = &afacet->Normal;
448 k[nk].id = FNORMALS_ID;
449 k[nk].data.pdata = npt;
450 nk++;
451 }
452
453 switch (afacet->TypePoints)
454 {
455 case 1:
456 {
457 k[nk].id = SHAPE_FLAG_ID;
458 k[nk].data.ldata = TEL_SHAPE_UNKNOWN;
459 switch (afacet->TypeFacet) {
460 case 0 : /* TOP_UNKNOWN */
461 k[nk].data.ldata = TEL_SHAPE_UNKNOWN;
462 break;
463 case 1 : /* TOP_COMPLEX */
464 k[nk].data.ldata = TEL_SHAPE_COMPLEX;
465 break;
466 case 2 : /* TOP_CONCAVE */
467 k[nk].data.ldata = TEL_SHAPE_CONCAVE;
468 break;
469 case 3 : /* TOP_CONVEX */
470 k[nk].data.ldata = TEL_SHAPE_CONVEX;
471 break;
472 }
473#if defined(__sgi) || defined(IRIX)
474 /* Pb avec le tesselator sgi */
475 k[nk].data.ldata = TEL_SHAPE_CONVEX;
476#endif
477 nk++;
478 k[nk].id = VERTICES_ID;
479 k[nk].data.pdata = afacet->UPoints.Points;
480 nk++;
481 break;
482 }
483 case 2:
484 {
485 Tint i;
486
487 k[nk].id = SHAPE_FLAG_ID;
488 k[nk].data.ldata = TEL_SHAPE_UNKNOWN;
489 switch (afacet->TypeFacet) {
490 case 0 : /* TOP_UNKNOWN */
491 k[nk].data.ldata = TEL_SHAPE_UNKNOWN;
492 break;
493 case 1 : /* TOP_COMPLEX */
494 k[nk].data.ldata = TEL_SHAPE_COMPLEX;
495 break;
496 case 2 : /* TOP_CONCAVE */
497 k[nk].data.ldata = TEL_SHAPE_CONCAVE;
498 break;
499 case 3 : /* TOP_CONVEX */
500 k[nk].data.ldata = TEL_SHAPE_CONVEX;
501 break;
502 }
503#if defined(__sgi) || defined(IRIX)
504 /* Pb avec le tesselator sgi */
505 k[nk].data.ldata = TEL_SHAPE_CONVEX;
506#endif
507 nk++;
508 //cmn_memreserve( pts, afacet->NbPoints, 0 );
509 pts = new TEL_POINT[afacet->NbPoints];
510 k[nk].id = VERTICES_ID;
511 k[nk].data.pdata = pts;
512 nk++;
513 //cmn_memreserve( ptn, afacet->NbPoints, 0 );
514 ptn = new TEL_POINT[afacet->NbPoints];
515 k[nk].id = VNORMALS_ID;
516 k[nk].data.pdata = ptn;
517 nk++;
518 for( i = 0; i < afacet->NbPoints; i++ )
519 {
520 pts[i].xyz[0] = afacet->UPoints.PointsN[i].Point.x;
521 pts[i].xyz[1] = afacet->UPoints.PointsN[i].Point.y;
522 pts[i].xyz[2] = afacet->UPoints.PointsN[i].Point.z;
523
524 ptn[i].xyz[0] = afacet->UPoints.PointsN[i].Normal.dx;
525 ptn[i].xyz[1] = afacet->UPoints.PointsN[i].Normal.dy;
526 ptn[i].xyz[2] = afacet->UPoints.PointsN[i].Normal.dz;
527 }
528 break;
529 }
530 case 5:
531 {
532 Tint i;
533
534 k[nk].id = SHAPE_FLAG_ID;
535 k[nk].data.ldata = TEL_SHAPE_UNKNOWN;
536 switch (afacet->TypeFacet) {
537 case 0 : /* TOP_UNKNOWN */
538 k[nk].data.ldata = TEL_SHAPE_UNKNOWN;
539 break;
540 case 1 : /* TOP_COMPLEX */
541 k[nk].data.ldata = TEL_SHAPE_COMPLEX;
542 break;
543 case 2 : /* TOP_CONCAVE */
544 k[nk].data.ldata = TEL_SHAPE_CONCAVE;
545 break;
546 case 3 : /* TOP_CONVEX */
547 k[nk].data.ldata = TEL_SHAPE_CONVEX;
548 break;
549 }
550#if defined(__sgi) || defined(IRIX)
551 /* Pb avec le tesselator sgi */
552 k[nk].data.ldata = TEL_SHAPE_CONVEX;
553#endif
554 nk++;
555 //cmn_memreserve( pts, afacet->NbPoints, 0 );
556 pts = new TEL_POINT[afacet->NbPoints];
557 k[nk].id = VERTICES_ID;
558 k[nk].data.pdata = pts;
559 nk++;
560 //cmn_memreserve( ptn, afacet->NbPoints, 0 );
561 ptn = new TEL_POINT[afacet->NbPoints];
562 k[nk].id = VNORMALS_ID;
563 k[nk].data.pdata = ptn;
564 nk++;
565 //cmn_memreserve( ptt, afacet->NbPoints, 0 );
566 ptt = new TEL_TEXTURE_COORD[afacet->NbPoints];
567 k[nk].id = VTEXTURECOORD_ID;
568 k[nk].data.pdata = ptt;
569 nk++;
570 for( i = 0; i < afacet->NbPoints; i++ )
571 {
572 pts[i].xyz[0] = afacet->UPoints.PointsNT[i].Point.x;
573 pts[i].xyz[1] = afacet->UPoints.PointsNT[i].Point.y;
574 pts[i].xyz[2] = afacet->UPoints.PointsNT[i].Point.z;
575
576 ptn[i].xyz[0] = afacet->UPoints.PointsNT[i].Normal.dx;
577 ptn[i].xyz[1] = afacet->UPoints.PointsNT[i].Normal.dy;
578 ptn[i].xyz[2] = afacet->UPoints.PointsNT[i].Normal.dz;
579
580 ptt[i].xy[0] = afacet->UPoints.PointsNT[i].TextureCoord.tx;
581 ptt[i].xy[1] = afacet->UPoints.PointsNT[i].TextureCoord.ty;
582 }
583 break;
584 }
585 }
586
587 for( i = 0; i < nk; i++ )
588 kp[i] = &k[i];
589
590 TsmAddToStructure( TelPolygon, -nk, kp );
591
592 if( pts )
593 {
594 //cmn_freemem( pts );
595 delete[] pts;
596 //cmn_freemem( ptn );
597 delete[] ptn;
598 //cmn_freemem( ptt );
599 delete[] ptt;
600 }
601
602 return;
603}
604
605
606void
607call_subr_polygon_indices( CALL_DEF_LISTPOINTS * alpoints,
608 CALL_DEF_LISTEDGES * aledges,
609 CALL_DEF_LISTINTEGERS * albounds )
610{
611 CMN_KEY k[10];
612 cmn_key kp[10];
613 Tint nk = 0, i;
614 tel_point varr=0;
615 tel_point narr=0;
616 tel_colour carr=0;
617 tel_texture_coord tarr=0;
618 Tint *edgvis=NULL, *bounds, *indices;
619 Tint num_indices;
620
621 k[nk].id = NUM_VERTICES_ID;
622 k[nk].data.ldata = alpoints->NbPoints;
623 nk++;
624
625 k[nk].id = NUM_FACETS_ID;
626 k[nk].data.ldata = albounds->NbIntegers;
627 nk++;
628
629 k[nk].id = SHAPE_FLAG_ID;
630 k[nk].data.ldata = TEL_SHAPE_UNKNOWN;
631 nk++;
632
633 if( aledges->NbEdges )
634 {
635 //cmn_memreserve( edgvis, aledges->NbEdges, 0 );
636 edgvis = new Tint[aledges->NbEdges];
637 if( !edgvis )
638 return;
639 for( i = 0; i < aledges->NbEdges; i++ )
640 edgvis[i] = aledges->Edges[i].Type ? CALL_PHIGS_EDGE_OFF :
641 CALL_PHIGS_EDGE_ON;
642 k[nk].id = EDGE_DATA_ID;
643 k[nk].data.pdata = edgvis;
644 nk++;
645 }
646
647 bounds = new Tint[albounds->NbIntegers];
648 if( !bounds )
649 {
650 delete[] edgvis;
651 return;
652 }
653 for( i = 0, num_indices = 0; i < albounds->NbIntegers; i++ )
654 {
655 bounds[i] = albounds->Integers[i];
656 num_indices += bounds[i];
657 }
658 k[nk].id = BOUNDS_DATA_ID;
659 k[nk].data.pdata = bounds;
660 nk++;
661
662 indices = new Tint[num_indices];
663 if( !indices )
664 {
665 delete[] edgvis;
666 delete[] bounds;
667 return;
668 }
669 for( i = 0; i < num_indices; i++ )
670 indices[i] = aledges->Edges[i].Index1;
671 k[nk].id = CONNECTIVITY_ID;
672 k[nk].data.pdata = indices;
673 nk++;
674
675 switch( alpoints->TypePoints )
676 {
677 case 1 : /* Vertex Coordinates Specified */
678 varr = new TEL_POINT[alpoints->NbPoints];
679 if( !varr )
680 {
681 delete[] edgvis;
682 delete[] bounds;
683 delete[] indices;
684 return;
685 }
686 for( i = 0; i < alpoints->NbPoints; i++ )
687 varr[i].xyz[0] = alpoints->UPoints.Points[i].x,
688 varr[i].xyz[1] = alpoints->UPoints.Points[i].y,
689 varr[i].xyz[2] = alpoints->UPoints.Points[i].z;
690 k[nk].id = VERTICES_ID;
691 k[nk].data.pdata = varr;
692 nk++;
693 break;
694
695 case 2 : /* Coordinates and Vertex Normal Specified */
696 varr = new TEL_POINT[alpoints->NbPoints];
697 if( !varr )
698 {
699 delete[] edgvis;
700 delete[] bounds;
701 delete[] indices;
702 return;
703 }
704 narr = new TEL_POINT[alpoints->NbPoints];
705 if( !narr )
706 {
707 delete[] edgvis;
708 delete[] bounds;
709 delete[] indices;
710 delete[] varr;
711 return;
712 }
713 for( i = 0; i < alpoints->NbPoints; i++ )
714 {
715 varr[i].xyz[0] = alpoints->UPoints.PointsN[i].Point.x,
716 varr[i].xyz[1] = alpoints->UPoints.PointsN[i].Point.y,
717 varr[i].xyz[2] = alpoints->UPoints.PointsN[i].Point.z;
718
719 narr[i].xyz[0] = alpoints->UPoints.PointsN[i].Normal.dx,
720 narr[i].xyz[1] = alpoints->UPoints.PointsN[i].Normal.dy,
721 narr[i].xyz[2] = alpoints->UPoints.PointsN[i].Normal.dz;
722 }
723 k[nk].id = VERTICES_ID;
724 k[nk].data.pdata = varr;
725 nk++;
726 k[nk].id = VNORMALS_ID;
727 k[nk].data.pdata = narr;
728 nk++;
729 break;
730
731 case 3 : /* Coordinates and Vertex Colour Specified */
732 varr = new TEL_POINT[alpoints->NbPoints];
733 if( !varr )
734 {
735 delete[] edgvis;
736 delete[] bounds;
737 delete[] indices;
738 return;
739 }
740 carr = new TEL_COLOUR[alpoints->NbPoints];
741 if( !carr )
742 {
743 delete[] edgvis;
744 delete[] bounds;
745 delete[] indices;
746 delete[] varr;
747 return;
748 }
749 for( i = 0; i < alpoints->NbPoints; i++ )
750 {
751 varr[i].xyz[0] = alpoints->UPoints.PointsC[i].Point.x,
752 varr[i].xyz[1] = alpoints->UPoints.PointsC[i].Point.y,
753 varr[i].xyz[2] = alpoints->UPoints.PointsC[i].Point.z;
754
755 carr[i].rgb[0] = alpoints->UPoints.PointsC[i].Color.r,
756 carr[i].rgb[1] = alpoints->UPoints.PointsC[i].Color.g,
757 carr[i].rgb[2] = alpoints->UPoints.PointsC[i].Color.b;
758 }
759 k[nk].id = VERTICES_ID;
760 k[nk].data.pdata = varr;
761 nk++;
762 k[nk].id = VERTEX_COLOUR_VALS_ID;
763 k[nk].data.pdata = carr;
764 nk++;
765 break;
766
767 case 4 : /* Coordinates and Vertex Colour and Vertex Normal Specified */
768 varr = new TEL_POINT[alpoints->NbPoints];
769 if( !varr )
770 {
771 delete[] edgvis;
772 delete[] bounds;
773 delete[] indices;
774 return;
775 }
776 carr = new TEL_COLOUR[alpoints->NbPoints];
777 if( !carr )
778 {
779 delete[] edgvis;
780 delete[] bounds;
781 delete[] indices;
782 delete[] varr;
783 return;
784 }
785 narr = new TEL_POINT[alpoints->NbPoints];
786 if( !narr )
787 {
788 delete[] edgvis;
789 delete[] bounds;
790 delete[] indices;
791 delete[] varr;
792 delete[] carr;
793 return;
794 }
795 for( i = 0; i < alpoints->NbPoints; i++ )
796 {
797 varr[i].xyz[0] = alpoints->UPoints.PointsNC[i].Point.x,
798 varr[i].xyz[1] = alpoints->UPoints.PointsNC[i].Point.y,
799 varr[i].xyz[2] = alpoints->UPoints.PointsNC[i].Point.z;
800
801 carr[i].rgb[0] = alpoints->UPoints.PointsNC[i].Color.r,
802 carr[i].rgb[1] = alpoints->UPoints.PointsNC[i].Color.g,
803 carr[i].rgb[2] = alpoints->UPoints.PointsNC[i].Color.b;
804
805 narr[i].xyz[0] = alpoints->UPoints.PointsNC[i].Normal.dx,
806 narr[i].xyz[1] = alpoints->UPoints.PointsNC[i].Normal.dy,
807 narr[i].xyz[2] = alpoints->UPoints.PointsNC[i].Normal.dz;
808 }
809 k[nk].id = VERTICES_ID;
810 k[nk].data.pdata = varr;
811 nk++;
812 k[nk].id = VERTEX_COLOUR_VALS_ID;
813 k[nk].data.pdata = carr;
814 nk++;
815 k[nk].id = VNORMALS_ID;
816 k[nk].data.pdata = narr;
817 nk++;
818 break;
819
820 case 5 : /* Coordinates and Vertex Normal and Texture Coordinates specified */
821 varr = new TEL_POINT[alpoints->NbPoints];
822 if( !varr )
823 {
824 delete[] edgvis;
825 delete[] bounds;
826 delete[] indices;
827 return;
828 }
829 narr = new TEL_POINT[alpoints->NbPoints];
830 if( !narr )
831 {
832 delete[] edgvis;
833 delete[] bounds;
834 delete[] indices;
835 delete[] varr;
836 return;
837 }
838 tarr = new TEL_TEXTURE_COORD[alpoints->NbPoints];
839
840 if( !tarr )
841 {
842 delete[] edgvis;
843 delete[] bounds;
844 delete[] indices;
845 delete[] varr;
846 delete[] narr;
847 return;
848 }
849 for( i = 0; i < alpoints->NbPoints; i++ )
850 {
851 varr[i].xyz[0] = alpoints->UPoints.PointsNT[i].Point.x,
852 varr[i].xyz[1] = alpoints->UPoints.PointsNT[i].Point.y,
853 varr[i].xyz[2] = alpoints->UPoints.PointsNT[i].Point.z;
854
855 narr[i].xyz[0] = alpoints->UPoints.PointsNT[i].Normal.dx,
856 narr[i].xyz[1] = alpoints->UPoints.PointsNT[i].Normal.dy,
857 narr[i].xyz[2] = alpoints->UPoints.PointsNT[i].Normal.dz;
858
859 tarr[i].xy[0] = alpoints->UPoints.PointsNT[i].TextureCoord.tx,
860 tarr[i].xy[1] = alpoints->UPoints.PointsNT[i].TextureCoord.ty;
861 }
862 k[nk].id = VERTICES_ID;
863 k[nk].data.pdata = varr;
864 nk++;
865 k[nk].id = VNORMALS_ID;
866 k[nk].data.pdata = narr;
867 nk++;
868 k[nk].id = VTEXTURECOORD_ID;
869 k[nk].data.pdata = tarr;
870 nk++;
871 break;
872 }
873
874 for( i = 0; i < nk; i++ )
875 kp[i] = &k[i];
876
877
878 TsmAddToStructure( TelPolygonIndices, -nk, kp );
879
880 delete[] edgvis;
881 delete[] bounds;
882 delete[] indices;
883 delete[] varr;
884 if( tarr )
885 delete[] tarr;
886 if( narr )
887 delete[] narr;
888 if( carr )
889 delete[] carr;
890
891 return;
892}
893
894
895void
896call_subr_polygon_set( CALL_DEF_LISTFACETS * alfacets )
897{
898 CMN_KEY key[3];
899 register Tint i, j, k;
900
901 Tint num_bounds, *bounds;
902 tel_point points;
903
904 num_bounds = alfacets->NbFacets;
905 bounds = new Tint[num_bounds];
906 if( !bounds )
907 return;
908
909 for( i = 0, j = 0; i < num_bounds; i++ )
910 j += alfacets->LFacets[i].NbPoints;
911
912 points = new TEL_POINT[j];
913 if( !points )
914 {
915 delete[] bounds;
916 return;
917 }
918
919 for( i = 0, k = 0; i < num_bounds; i++ )
920 for( j = 0; j < alfacets->LFacets[i].NbPoints; j++ )
921 {
922 points[k].xyz[0] = alfacets->LFacets[i].UPoints.Points[j].x;
923 points[k].xyz[1] = alfacets->LFacets[i].UPoints.Points[j].y;
924 points[k].xyz[2] = alfacets->LFacets[i].UPoints.Points[j].z;
925 k++;
926 }
927
928 key[0].id = NUM_FACETS_ID;
929 key[0].data.ldata = num_bounds;
930 key[1].id = BOUNDS_DATA_ID;
931 key[1].data.pdata = bounds;
932 key[2].id = VERTICES_ID;
933 key[2].data.pdata = points;
934 TsmAddToStructure( TelPolygonSet, 3, &key[0], &key[1], &key[2] );
935
936 delete[] bounds;
937 delete[] points;
938
939 return;
940}
941
942
943void
944call_subr_quadrangle( CALL_DEF_QUAD * aquad )
945{
946 CMN_KEY key[15];
947 cmn_key kp[15];
948 Tint nk = 0, i;
949 tel_point vertices, vnormals=0;
950 tel_texture_coord vtexturecoord=0;
951
952 /* key[nk].id = NUM_ROWS_ID; */
953 key[nk].id = NUM_COLUMNS_ID;
954 key[nk].data.ldata = aquad->SizeRow - 1;
955 nk++;
956 /* key[nk].id = NUM_COLUMNS_ID; */
957 key[nk].id = NUM_ROWS_ID;
958 key[nk].data.ldata = aquad->SizeCol - 1;
959 nk++;
960
961 //cmn_memreserve( vertices, aquad->NbPoints, 0 );
962 vertices = new TEL_POINT[aquad->NbPoints];
963 if( !vertices )
964 return;
965
966 switch( aquad->TypePoints )
967 {
968 case 1: /* Vertex Coordinates Specified */
969 for( i = 0; i < aquad->NbPoints; i++ )
970 {
971 vertices[i].xyz[0] = aquad->UPoints.Points[i].x;
972 vertices[i].xyz[1] = aquad->UPoints.Points[i].y;
973 vertices[i].xyz[2] = aquad->UPoints.Points[i].z;
974 }
975 break;
976
977 case 2: /* Coordinates and Vertex Normal Specified */
978 //cmn_memreserve( vnormals, aquad->NbPoints, 0 );
979 vnormals = new TEL_POINT[aquad->NbPoints];
980 if( !vnormals )
981 {
982 //cmn_freemem( vertices );
983 delete[] vertices;
984 return;
985 }
986 for( i = 0; i < aquad->NbPoints; i++ )
987 {
988 vertices[i].xyz[0] = aquad->UPoints.PointsN[i].Point.x;
989 vertices[i].xyz[1] = aquad->UPoints.PointsN[i].Point.y;
990 vertices[i].xyz[2] = aquad->UPoints.PointsN[i].Point.z;
991 vnormals[i].xyz[0] = aquad->UPoints.PointsN[i].Normal.dx;
992 vnormals[i].xyz[1] = aquad->UPoints.PointsN[i].Normal.dy;
993 vnormals[i].xyz[2] = aquad->UPoints.PointsN[i].Normal.dz;
994 }
995 key[nk].id = VNORMALS_ID;
996 key[nk].data.pdata = vnormals;
997 nk++;
998 break;
999
1000 case 5: /* Coordinates and Vertex Normal and Texture Coordinate Specified */
1001 vnormals = new TEL_POINT[aquad->NbPoints];
1002 if( !vnormals )
1003 {
1004 delete[] vertices;
1005 return;
1006 }
1007 vtexturecoord = new TEL_TEXTURE_COORD[aquad->NbPoints];
1008 if (!vtexturecoord)
1009 {
1010 delete[] vnormals;
1011 delete[] vertices;
1012 }
1013 for( i = 0; i < aquad->NbPoints; i++ )
1014 {
1015 vertices[i].xyz[0] = aquad->UPoints.PointsNT[i].Point.x;
1016 vertices[i].xyz[1] = aquad->UPoints.PointsNT[i].Point.y;
1017 vertices[i].xyz[2] = aquad->UPoints.PointsNT[i].Point.z;
1018 vnormals[i].xyz[0] = aquad->UPoints.PointsNT[i].Normal.dx;
1019 vnormals[i].xyz[1] = aquad->UPoints.PointsNT[i].Normal.dy;
1020 vnormals[i].xyz[2] = aquad->UPoints.PointsNT[i].Normal.dz;
1021 vtexturecoord[i].xy[0] = aquad->UPoints.PointsNT[i].TextureCoord.tx;
1022 vtexturecoord[i].xy[1] = aquad->UPoints.PointsNT[i].TextureCoord.ty;
1023 }
1024 key[nk].id = VNORMALS_ID;
1025 key[nk].data.pdata = vnormals;
1026 nk++;
1027 key[nk].id = VTEXTURECOORD_ID;
1028 key[nk].data.pdata = vtexturecoord;
1029 nk++;
1030 break;
1031 }
1032
1033 key[nk].id = VERTICES_ID;
1034 key[nk].data.pdata = vertices;
1035 nk++;
1036
1037 for( i = 0; i < nk; i++ )
1038 kp[i] = &key[i];
1039
1040 TsmAddToStructure( TelQuadrangle, -nk, kp );
1041
1042 delete[] vertices;
1043 if (vtexturecoord)
1044 delete[] vtexturecoord;
1045 if( vnormals )
1046 delete[] vnormals;
1047
1048 return;
1049}
1050
1051void
1052call_subr_set_text_colr( Tfloat r, Tfloat g, Tfloat b )
1053{
1054 CMN_KEY key;
1055 TEL_COLOUR col;
1056
1057 col.rgb[0] = r,
1058 col.rgb[1] = g,
1059 col.rgb[2] = b;
1060 key.data.pdata = &col;
1061 TsmAddToStructure( TelTextColour, 1, &key );
1062
1063 return;
1064}
1065
1066void
1067call_subr_set_text_colr_subtitle( Tfloat r, Tfloat g, Tfloat b )
1068{
1069 CMN_KEY key;
1070 TEL_COLOUR col;
1071
1072 col.rgb[0] = r,
1073 col.rgb[1] = g,
1074 col.rgb[2] = b;
1075 key.data.pdata = &col;
1076 TsmAddToStructure( TelTextColourSubTitle, 1, &key );
1077
1078 return;
1079}
1080
1081
1082void
1083call_subr_triangle( CALL_DEF_TRIKE * atrike )
1084{
1085 Tint i;
1086 tel_point vertices, vnormals=0;
1087 tel_texture_coord vtexturecoord=0;
1088 CMN_KEY key[15];
1089 cmn_key kp[15];
1090 Tint nk = 0;
1091
1092 vertices = new TEL_POINT[atrike->NbPoints];
1093 if( !vertices )
1094 return;
1095
1096 switch( atrike->TypePoints )
1097 {
1098 case 1: /* Vertex Coordinates Specified */
1099 for( i = 0; i < atrike->NbPoints; i++ )
1100 {
1101 vertices[i].xyz[0] = atrike->UPoints.Points[i].x;
1102 vertices[i].xyz[1] = atrike->UPoints.Points[i].y;
1103 vertices[i].xyz[2] = atrike->UPoints.Points[i].z;
1104 }
1105 break;
1106
1107 case 2: /* Coordinates and Vertex Normal Specified */
1108 vnormals = new TEL_POINT[atrike->NbPoints];
1109 if( !vnormals )
1110 {
1111 delete[] vertices;
1112 return;
1113 }
1114 for( i = 0; i < atrike->NbPoints; i++ )
1115 {
1116 vertices[i].xyz[0] = atrike->UPoints.PointsN[i].Point.x;
1117 vertices[i].xyz[1] = atrike->UPoints.PointsN[i].Point.y;
1118 vertices[i].xyz[2] = atrike->UPoints.PointsN[i].Point.z;
1119 vnormals[i].xyz[0] = atrike->UPoints.PointsN[i].Normal.dx;
1120 vnormals[i].xyz[1] = atrike->UPoints.PointsN[i].Normal.dy;
1121 vnormals[i].xyz[2] = atrike->UPoints.PointsN[i].Normal.dz;
1122 }
1123 key[nk].id = VNORMALS_ID;
1124 key[nk].data.pdata = vnormals;
1125 nk++;
1126 break;
1127 case 5: /* Coordinates and Vertex Normal and Texture Coordinates Specified */
1128 vnormals = new TEL_POINT[atrike->NbPoints];
1129 if( !vnormals )
1130 {
1131 delete[] vertices;
1132 return;
1133 }
1134 vtexturecoord = new TEL_TEXTURE_COORD[atrike->NbPoints];
1135 if (!vtexturecoord)
1136 {
1137 delete[] vnormals;
1138 delete[] vertices;
1139 }
1140 for( i = 0; i < atrike->NbPoints; i++ )
1141 {
1142 vertices[i].xyz[0] = atrike->UPoints.PointsNT[i].Point.x;
1143 vertices[i].xyz[1] = atrike->UPoints.PointsNT[i].Point.y;
1144 vertices[i].xyz[2] = atrike->UPoints.PointsNT[i].Point.z;
1145 vnormals[i].xyz[0] = atrike->UPoints.PointsNT[i].Normal.dx;
1146 vnormals[i].xyz[1] = atrike->UPoints.PointsNT[i].Normal.dy;
1147 vnormals[i].xyz[2] = atrike->UPoints.PointsNT[i].Normal.dz;
1148 vtexturecoord[i].xy[0] = atrike->UPoints.PointsNT[i].TextureCoord.tx;
1149 vtexturecoord[i].xy[1] = atrike->UPoints.PointsNT[i].TextureCoord.ty;
1150 }
1151 key[nk].id = VNORMALS_ID;
1152 key[nk].data.pdata = vnormals;
1153 nk++;
1154 key[nk].id = VTEXTURECOORD_ID;
1155 key[nk].data.pdata = vtexturecoord;
1156 nk++;
1157 break;
1158 }
1159
1160 key[nk].id = NUM_FACETS_ID;
1161 key[nk].data.ldata = atrike->NbPoints-2;
1162 nk++;
1163
1164 key[nk].id = VERTICES_ID;
1165 key[nk].data.pdata = vertices;
1166 nk++;
1167
1168 for( i = 0; i < nk; i++ )
1169 kp[i] = &key[i];
1170
1171 TsmAddToStructure( TelTriangleMesh, -nk, kp );
1172
1173 delete[] vertices;
1174 if( vnormals )
1175 delete[] vnormals;
1176
1177 return;
1178}
1179
1180
1181void
1182call_subr_set_highl_rep( Tint ind )
1183{
1184 CMN_KEY key;
1185
1186 key.data.ldata = ind;
1187 TsmAddToStructure( TelHighlightIndex, 1, &key );
1188
1189 return;
1190}
1191
1192
1193#define CALL_ 128
1194
1195void
1196call_subr_structure_exploration( Tint Id,
1197 Tint LabelBegin,
1198 Tint LabelEnd,
1199 Tint elem_num,
1200 Tint *elem_type,
1201 CALL_DEF_POINT *pt,
1202 CALL_DEF_NORMAL *npt,
1203 CALL_DEF_COLOR *cpt,
1204 CALL_DEF_NORMAL *nfa )
1205{
1206#define CALL_MAX_ELEMS_PRINT 1000000
1207 Tfloat r=0, g=0, b=0;
1208 Tfloat x=0, y=0, z=0;
1209 Tfloat nx=0, ny=0, nz=0;
1210 Tfloat dx=0, dy=0, dz=0;
1211
1212 static Tint Initialisation = 1;
1213
1214 Tchar *buffer=NULL;
1215 Tint actual_size; /* OUT content size */
1216 Tint err=0; /* OUT error indicator */
1217 TelType type; /* OUT element type */
1218 Tint size; /* OUT element size */
1219 Tint ws; /* OUT workstation */
1220
1221 Tint index; /* element pointer value */
1222 Tint cur_index; /* OUT element pointer value */
1223 Teldata data; /* OUT data record */
1224
1225 register int i, j;
1226 Tint MAXPOINTS;
1227 Tint MAXAREAS;
1228
1229 static Tint idata, jdata, kdata;
1230
1231 Tint printall; /* print all structure elements or not */
1232 Tint dump; /* print or not */
1233
1234 static Tint IdCur; /* current structure id
1235 (for exploration step by step) */
1236 static Tint ElCur; /* current structure element number
1237 (for exploration step by step) */
1238 static Tint IndCur; /* current index point in the structure element
1239 (for exploration step by step) */
1240 static Tint JndCur; /* current index element in the structure element
1241 (for exploration step by step) */
1242 static Tint EndExplo;/* flag when the exploration of the current
1243 element is done.
1244 (for exploration step by step) */
1245
1246 if( Initialisation )
1247 {
1248 Initialisation = 0;
1249 IdCur = -1;
1250 ElCur = -1;
1251 IndCur = -1;
1252 JndCur = 0;
1253 }
1254
1255 dump = 0;
1256 printall = 1;
1257 MAXPOINTS = CALL_MAX_ELEMS_PRINT;
1258 MAXAREAS = CALL_MAX_ELEMS_PRINT;
1259
1260 if( (LabelBegin == 0) && (LabelEnd == 0) )
1261 {
1262 dump = 1;
1263 printall = 0;
1264 }
1265
1266 if( elem_num )
1267 {
1268 index = elem_num;
1269 dump = 1;
1270 printall = 1;
1271
1272 npt->dx = npt->dy = npt->dz = nx = ny = nz = ( float )0.0;
1273 nfa->dx = nfa->dy = nfa->dz = dx = dy = dz = ( float )0.0;
1274 pt->x = pt->y = pt->z = x = y = z = ( float )0.0;
1275 cpt->r = cpt->g = cpt->b = r = g = b = ( float )0.0;
1276
1277 if ( (Id != IdCur) || (ElCur != elem_num) || EndExplo )
1278 {
1279 IdCur = Id;
1280 ElCur = elem_num;
1281 IndCur = -1;
1282 JndCur = 0;
1283 }
1284 else
1285 {
1286 IndCur ++;
1287 }
1288 }
1289 else
1290 {
1291 index = 1;
1292 IdCur = -1;
1293 ElCur = -1;
1294 IndCur = -1;
1295 JndCur = 0;
1296 }
1297
1298 call_func_open_struct (Id);
1299
1300 while( index )
1301 {
1302 call_func_set_elem_ptr( index );
1303 if( call_func_inq_elem_ptr( &cur_index ) == TFailure )
1304 err = 1;
1305 else
1306 err = 0;
1307
1308 /* it's the end */
1309 if( ( index != cur_index ) || err )
1310 {
1311 index = 0;
1312 break;
1313 }
1314 if( TelInqCurElemTypeSize( &type, &size ) == TFailure )
1315 err = 1;
1316 else
1317 err = 0;
1318
1319 if( err || (type == CALL_PHIGS_ELEM_NIL) )
1320 {
1321 index = 0;
1322 break;
1323 }
1324
1325 if( elem_num )
1326 {
1327 EndExplo = 0;
1328 *elem_type = type;
1329 }
1330
1331 if( type == CALL_PHIGS_ELEM_LABEL )
1332 {
1333 buffer = (Tchar *)malloc( CALL_ );
1334 TelInqCurElemContent( CALL_, buffer, &actual_size, &data );
1335
1336 if( data.idata == LabelBegin )
1337 dump = 1;
1338 if( ( LabelBegin == 0 ) && ( LabelEnd == 0 ) )
1339 dump = 1;
1340 if( dump )
1341 {
1342 if( elem_num )
1343 {
1344 if( IndCur >= 1 )
1345 {
1346 EndExplo = 1;
1347 }
1348 else
1349 {
1350 x = ( float )data.idata;
1351 y = ( float )0.0;
1352 z = ( float )0.0;
1353 }
1354 }
1355 else
1356 {
1357 printf( "\tELEM_LABEL\n" );
1358 printf( "\t\tLABEL %d\n", data.idata );
1359 }
1360 }
1361
1362 if( data.idata == LabelEnd )
1363 dump = 0;
1364
1365 free( buffer );
1366 }
1367
1368 if( dump )
1369 {
1370 switch (type)
1371 {
1372 case CALL_PHIGS_ELEM_NIL :
1373 {
1374 if( elem_num )
1375 {
1376 if (IndCur >= 0)
1377 {
1378 EndExplo = 1;
1379 }
1380 else
1381 {
1382 x = y = z = ( float )0.0;
1383 }
1384 }
1385 else
1386 {
1387 printf("\tELEM_NIL\n");
1388 printf("\t\tNo data involved\n");
1389 }
1390 break;
1391 }
1392 case CALL_PHIGS_ELEM_POLYMARKER3 :
1393 {
1394 i = size;
1395 buffer = new Tchar[i];
1396 TelInqCurElemContent( i, buffer, &actual_size, &data );
1397 idata = size/sizeof( TEL_POINT );
1398 if( elem_num )
1399 {
1400 if( (IndCur > -1) && (IndCur < idata) )
1401 {
1402 i = IndCur;
1403 x = data.pts3[i].xyz[0];
1404 y = data.pts3[i].xyz[1];
1405 z = data.pts3[i].xyz[2];
1406 }
1407 if (IndCur >= idata)
1408 EndExplo = 1;
1409 }
1410 else
1411 {
1412 printf("\tELEM_POLYMARKER3\n");
1413 printf("\t\tPOLYMARKER 3 nb pts %d\n", idata);
1414 if (printall)
1415 {
1416 for (i=0; i<idata && i<MAXPOINTS; i++)
1417 printf( "\t\tpoint %d : %f %f %f\n", i,
1418 data.pts3[i].xyz[0],
1419 data.pts3[i].xyz[1],
1420 data.pts3[i].xyz[2] );
1421 }
1422 else
1423 {
1424 i = 0;
1425 printf( "\t\tfirst point %d : %f %f %f\n", i,
1426 data.pts3[i].xyz[0],
1427 data.pts3[i].xyz[1],
1428 data.pts3[i].xyz[2] );
1429 i = idata - 1;
1430 printf("\t\tlast point %d : %f %f %f\n", i,
1431 data.pts3[i].xyz[0],
1432 data.pts3[i].xyz[1],
1433 data.pts3[i].xyz[2]);
1434 }
1435 }
1436 delete[] buffer;
1437 break;
1438 }
1439 case CALL_PHIGS_ELEM_FILL_AREA_SET3 :
1440 {
1441 i = size;
1442 buffer = new Tchar[i];
1443 TelInqCurElemContent( i, buffer, &actual_size, &data );
1444 jdata = data.fillareaset3data.num_bounds;
1445 if( elem_num )
1446 {
1447 if ((IndCur == 0) && (JndCur == 0))
1448 kdata = 0;
1449 if (JndCur >= jdata)
1450 EndExplo = 1;
1451 else
1452 {
1453 if (IndCur == 0)
1454 {
1455 idata = data.fillareaset3data.bounds[JndCur];
1456 }
1457 else
1458 {
1459 if ((IndCur > -1) && (IndCur < idata))
1460 {
1461 x =
1462 data.fillareaset3data.points[kdata+IndCur].xyz[0];
1463 y =
1464 data.fillareaset3data.points[kdata+IndCur].xyz[1];
1465 z =
1466 data.fillareaset3data.points[kdata+IndCur].xyz[2];
1467
1468 if(data.fillareaset3data.vrtflag ==
1469 CALL_PHIGS_VERT_COORD_NORMAL)
1470 {
1471 nx = data.fillareaset3data.vnormals[IndCur].xyz[0];
1472 ny = data.fillareaset3data.vnormals[IndCur].xyz[1];
1473 nz = data.fillareaset3data.vnormals[IndCur].xyz[2];
1474 }
1475 if(data.fillareaset3data.vrtflag ==
1476 CALL_PHIGS_VERT_COORD_COLOUR)
1477 {
1478 r =
1479 data.fillareaset3data.colours[kdata+IndCur].rgb[0];
1480 g =
1481 data.fillareaset3data.colours[kdata+IndCur].rgb[1];
1482 b =
1483 data.fillareaset3data.colours[kdata+IndCur].rgb[2];
1484 }
1485 if (data.fillareaset3data.vrtflag ==
1486 CALL_PHIGS_VERT_COORD_COLOUR_NORMAL)
1487 {
1488 nx = data.fillareaset3data.vnormals[IndCur].xyz[0];
1489 ny = data.fillareaset3data.vnormals[IndCur].xyz[1];
1490 nz = data.fillareaset3data.vnormals[IndCur].xyz[2];
1491 r =
1492 data.fillareaset3data.colours[kdata+IndCur].rgb[0];
1493 g =
1494 data.fillareaset3data.colours[kdata+IndCur].rgb[1];
1495 b =
1496 data.fillareaset3data.colours[kdata+IndCur].rgb[2];
1497 }
1498 }
1499 }
1500 if (IndCur >= idata)
1501 {
1502 kdata += data.fillareaset3data.bounds[JndCur];
1503 JndCur ++;
1504 IndCur = 0;
1505 }
1506 }
1507 }
1508 else
1509 {
1510 printf("\tELEM_FILL_AREA_SET3_DATA\n");
1511 printf("\t\tSET OF FILL AREA SET 3 WITH DATA\n");
1512 kdata = 0;
1513 printf("\t\tnb of faces %d\n", jdata);
1514 printf("\t\tfflag %d eflag %d vflag %d colr model RGB\n",
1515 data.fillareaset3data.faflag,
1516 data.fillareaset3data.edgflag,
1517 data.fillareaset3data.vrtflag );
1518 kdata = 0;
1519 for (j=0; j<jdata && j<MAXAREAS; j++)
1520 {
1521 idata = data.fillareaset3data.bounds[j];
1522 printf("\t\tface %d : %d vertices\n", j, idata);
1523 if (data.fillareaset3data.faflag ==
1524 CALL_PHIGS_FACET_NORMAL)
1525 printf("\t\t\tface normal %f %f %f\n",
1526 data.fillareaset3data.gnormal[j].xyz[0],
1527 data.fillareaset3data.gnormal[j].xyz[1],
1528 data.fillareaset3data.gnormal[j].xyz[2]);
1529 if (data.fillareaset3data.faflag ==
1530 CALL_PHIGS_FACET_COLOUR_NORMAL)
1531 printf("\t\t\tnormal %f %f %f\n",
1532 data.fillareaset3data.gnormal[j].xyz[0],
1533 data.fillareaset3data.gnormal[j].xyz[1],
1534 data.fillareaset3data.gnormal[j].xyz[2]);
1535 if (printall)
1536 for (i=0; i<idata && i<MAXPOINTS; i++)
1537 printf("\t\t\tvertex %d : %f %f %f\n", i,
1538 data.fillareaset3data.points[kdata+i].xyz[0],
1539 data.fillareaset3data.points[kdata+i].xyz[1],
1540 data.fillareaset3data.points[kdata+i].xyz[2]);
1541 else
1542 {
1543 i = 0;
1544 printf("\t\tfirst vertex %d : %f %f %f\n", i,
1545 data.fillareaset3data.points[kdata+i].xyz[0],
1546 data.fillareaset3data.points[kdata+i].xyz[1],
1547 data.fillareaset3data.points[kdata+i].xyz[2]);
1548
1549 i = idata - 1;
1550 printf("\t\tlast vertex %d : %f %f %f\n", i,
1551 data.fillareaset3data.points[kdata+i].xyz[0],
1552 data.fillareaset3data.points[kdata+i].xyz[1],
1553 data.fillareaset3data.points[kdata+i].xyz[2]);
1554 }
1555 kdata += data.fillareaset3data.bounds[j];
1556 }
1557 delete[] buffer;
1558 break;
1559 }
1560 }
1561 case CALL_PHIGS_ELEM_FILL_AREA3 :
1562 {
1563 i = size;
1564 buffer = new Tchar[i];
1565 TelInqCurElemContent( i, buffer, &actual_size, &data );
1566 idata = data.fillarea3data.num_points;
1567
1568 if( elem_num )
1569 {
1570 if( (IndCur > -1) && (IndCur < idata) )
1571 {
1572 i = IndCur;
1573 x = data.fillarea3data.points[i].xyz[0];
1574 y = data.fillarea3data.points[i].xyz[1];
1575 z = data.fillarea3data.points[i].xyz[2];
1576 }
1577 if( IndCur >= idata )
1578 EndExplo = 1;
1579 }
1580 else
1581 {
1582 printf( "\tELEM_FILL_AREA3\n" );
1583 printf( "\t\tFILL AREA 3 nb pts %d\n", idata );
1584 if( printall )
1585 {
1586 for( i=0; i<idata && i<MAXPOINTS; i++ )
1587 printf( "\t\tpoint %d : %f %f %f\n", i,
1588 data.fillarea3data.points[i].xyz[0],
1589 data.fillarea3data.points[i].xyz[1],
1590 data.fillarea3data.points[i].xyz[2] );
1591 }
1592 else
1593 {
1594 i = 0;
1595 printf("\t\tfirst point %d : %f %f %f\n", i,
1596 data.fillarea3data.points[i].xyz[0],
1597 data.fillarea3data.points[i].xyz[1],
1598 data.fillarea3data.points[i].xyz[2] );
1599 i = idata - 1;
1600 printf("\t\tlast point %d : %f %f %f\n", i,
1601 data.fillarea3data.points[i].xyz[0],
1602 data.fillarea3data.points[i].xyz[1],
1603 data.fillarea3data.points[i].xyz[2] );
1604 }
1605 }
1606 delete[] buffer;
1607 break;
1608 }
1609 case CALL_PHIGS_ELEM_ANNO_TEXT_REL3 :
1610 {
1611 buffer = new Tchar[size];
1612 TelInqCurElemContent( size, buffer, &actual_size, &data );
1613
1614 if( elem_num )
1615 {
1616 if (IndCur == 0)
1617 {
1618 x = data.atext3.ref_pt.xyz[0];
1619 y = data.atext3.ref_pt.xyz[1];
1620 z = data.atext3.ref_pt.xyz[2];
1621 }
1622 if (IndCur == 1)
1623 {
1624 x = data.atext3.anno.xyz[0];
1625 y = data.atext3.anno.xyz[1];
1626 z = data.atext3.anno.xyz[2];
1627 }
1628 if( IndCur >= 2 )
1629 EndExplo = 1;
1630 }
1631 else
1632 {
1633 printf( "\tELEM_ANNO_TEXT_REL3\n" );
13a22457 1634 printf( "\t\tANNOTATION TEXT RELATIVE 3 %S\n",
7fd59977 1635 data.atext3.string );
1636 printf( "\t\treference point %f %f %f\n",
1637 data.atext3.ref_pt.xyz[0],
1638 data.atext3.ref_pt.xyz[1],
1639 data.atext3.ref_pt.xyz[2] );
1640 printf( "\t\toffset %f %f %f\n",
1641 data.atext3.anno.xyz[0],
1642 data.atext3.anno.xyz[1],
1643 data.atext3.anno.xyz[2] );
1644 }
1645 delete[] buffer;
1646 break;
1647 }
1648 case CALL_PHIGS_ELEM_LINETYPE :
1649 {
1650 TelInqCurElemContent( 0, buffer, &actual_size, &data );
1651 if( elem_num )
1652 {
1653 if (IndCur >= 1)
1654 EndExplo = 1;
1655 else
1656 {
1657 x = ( float )data.idata;
1658 y = ( float )0.0;
1659 z = ( float )0.0;
1660 }
1661 }
1662 else {
1663 printf("\tELEM_LINETYPE\n");
1664 printf("\t\tLINETYPE %d\n", data.idata);
1665 }
1666 break;
1667 }
1668 case CALL_PHIGS_ELEM_LINEWIDTH :
1669 {
1670 TelInqCurElemContent( 0, buffer, &actual_size, &data );
1671 if( elem_num )
1672 {
1673 if (IndCur >= 1)
1674 EndExplo = 1;
1675 else
1676 {
1677 x = data.fdata;
1678 y = ( float )0.0;
1679 z = ( float )0.0;
1680 }
1681 }
1682 else
1683 {
1684 printf( "\tELEM_LINEWIDTH\n" );
1685 printf( "\t\tLINEWIDTH SCALE FACTOR %f\n", data.fdata);
1686 }
1687 break;
1688 }
1689 case CALL_PHIGS_ELEM_MARKER_TYPE :
1690 {
1691 TelInqCurElemContent( 0, buffer, &actual_size, &data );
1692 if( elem_num )
1693 {
1694 if( IndCur >= 1 )
1695 EndExplo = 1;
1696 else
1697 {
1698 x = ( float )data.idata;
1699 y = ( float )0.0;
1700 z = ( float )0.0;
1701 }
1702 }
1703 else
1704 {
1705 printf("\tELEM_MARKER_TYPE\n");
1706 printf("\t\tMARKER TYPE %d\n", data.idata);
1707 }
1708 break;
1709 }
1710 case CALL_PHIGS_ELEM_MARKER_SIZE :
1711 {
1712 TelInqCurElemContent( 0, buffer, &actual_size, &data );
1713 if( elem_num )
1714 {
1715 if (IndCur >= 1)
1716 EndExplo = 1;
1717 else
1718 {
1719 x = data.fdata;
1720 y = ( float )0.0;
1721 z = ( float )0.0;
1722 }
1723 }
1724 else
1725 {
1726 printf("\tELEM_MARKER_SIZE\n");
1727 printf("\t\tMARKER SIZE SCALE FACTOR %f\n", data.fdata);
1728 }
1729 break;
1730 }
1731#if 0
1732 case CALL_PHIGS_ELEM_TEXT_FONT : /* DECPHIGS */
1733 buffer = new Tchar[CALL_];
1734 TelInqCurElemContent (CALL_, buffer, &actual_size, &data);
1735 if( elem_num )
1736 if (IndCur >= 1)
1737 EndExplo = 1;
1738 else {
1739 x = data.idata;
1740 y = 0.0;
1741 z = 0.0;
1742 }
1743 else {
1744 printf("\tELEM_TEXT_FONT\n");
1745 printf("\t\tTEXT FONT %d\n", data.idata);
1746 }
1747 delete[] buffer;
1748 break;
1749#endif
1750 case CALL_PHIGS_ELEM_CHAR_EXPAN :
1751 {
1752 TelInqCurElemContent( 0, buffer, &actual_size, &data );
1753 if( elem_num )
1754 {
1755 if (IndCur >= 1)
1756 EndExplo = 1;
1757 else
1758 {
1759 x = data.fdata;
1760 y = ( float )0.0;
1761 z = ( float )0.0;
1762 }
1763 }
1764 else
1765 {
1766 printf("\tELEM_CHAR_EXPAN\n");
1767 printf("\t\tCHARACTER EXPANSION FACTOR %f\n",data.fdata);
1768 }
1769 break;
1770 }
1771 case CALL_PHIGS_ELEM_CHAR_SPACE :
1772 {
1773 TelInqCurElemContent( 0, buffer, &actual_size, &data );
1774 if( elem_num )
1775 {
1776 if (IndCur >= 1)
1777 EndExplo = 1;
1778 else
1779 {
1780 x = data.fdata;
1781 y = ( float )0.0;
1782 z = ( float )0.0;
1783 }
1784 }
1785 else
1786 {
1787 printf("\tELEM_CHAR_SPACE\n");
1788 printf("\t\tCHARACTER SPACING %f\n", data.fdata);
1789 }
1790 break;
1791 }
1792 case CALL_PHIGS_ELEM_ANNO_CHAR_HT :
1793 {
1794 TelInqCurElemContent( 0, buffer, &actual_size, &data );
1795 if( elem_num )
1796 {
1797 if (IndCur >= 1)
1798 EndExplo = 1;
1799 else
1800 {
1801 x = data.fdata;
1802 y = ( float )0.0;
1803 z = ( float )0.0;
1804 }
1805 }
1806 else
1807 {
1808 printf("\tELEM_ANNO_CHAR_HT\n");
1809 printf("\t\tANNOTATION TEXT CHARACTER HEIGHT %f\n",
1810 data.fdata);
1811 }
1812 break;
1813 }
1814 case CALL_PHIGS_ELEM_INT_STYLE :
1815 {
1816 TelInqCurElemContent( 0, buffer, &actual_size, &data );
1817 if( elem_num )
1818 {
1819 if (IndCur >= 1)
1820 EndExplo = 1;
1821 else
1822 {
1823 x = ( float )data.interior_style;
1824 y = ( float )0.0;
1825 z = ( float )0.0;
1826 }
1827 }
1828 else
1829 {
1830 printf("\tELEM_INT_STYLE\n");
1831 printf("\t\tINTERIOR STYLE %d\n", data.interior_style);
1832 }
1833 break;
1834 }
1835 case CALL_PHIGS_ELEM_INT_STYLE_IND :
1836 {
1837 TelInqCurElemContent( 0, buffer, &actual_size, &data );
1838 if( elem_num )
1839 {
1840 if (IndCur >= 1)
1841 EndExplo = 1;
1842 else
1843 {
1844 x = ( float )data.idata;
1845 y = ( float )0.0;
1846 z = ( float )0.0;
1847 }
1848 }
1849 else
1850 {
1851 printf("\tELEM_INT_STYLE_IND\n");
1852 printf("\t\tINTERIOR STYLE INDEX %d\n", data.idata);
1853 }
1854 break;
1855 }
1856 case CALL_PHIGS_ELEM_EDGE_FLAG :
1857 {
1858 TelInqCurElemContent( 0, buffer, &actual_size, &data );
1859 if( elem_num )
1860 {
1861 if (IndCur >= 1)
1862 EndExplo = 1;
1863 else
1864 {
1865 x = ( float )data.edge_flag;
1866 y = ( float )0.0;
1867 z = ( float )0.0;
1868 }
1869 }
1870 else
1871 {
1872 printf("\tELEM_EDGE_FLAG\n");
1873 printf("\t\tEDGE FLAG %d\n", data.edge_flag);
1874 }
1875 break;
1876 }
1877 case CALL_PHIGS_ELEM_EDGETYPE :
1878 {
1879 TelInqCurElemContent( 0, buffer, &actual_size, &data );
1880 if( elem_num )
1881 {
1882 if (IndCur >= 1)
1883 EndExplo = 1;
1884 else
1885 {
1886 x = ( float )data.idata;
1887 y = ( float )0.0;
1888 z = ( float )0.0;
1889 }
1890 }
1891 else
1892 {
1893 printf("\tELEM_EDGETYPE\n");
1894 printf("\t\tEDGETYPE %d\n", data.idata);
1895 }
1896 break;
1897 }
1898 case CALL_PHIGS_ELEM_EDGEWIDTH :
1899 {
1900 TelInqCurElemContent( 0, buffer, &actual_size, &data );
1901 if( elem_num )
1902 {
1903 if (IndCur >= 1)
1904 EndExplo = 1;
1905 else
1906 {
1907 x = data.fdata;
1908 y = ( float )0.0;
1909 z = ( float )0.0;
1910 }
1911 }
1912 else
1913 {
1914 printf("\tELEM_EDGEWIDTH\n");
1915 printf("\t\tEDGEWIDTH SCALE FACTOR %f\n", data.fdata);
1916 }
1917 break;
1918 }
1919 case CALL_PHIGS_ELEM_ADD_NAMES_SET :
1920 {
1921 buffer = new Tchar[size];
1922 TelInqCurElemContent( size, buffer, &actual_size, &data );
1923 idata = data.name_set.number;
1924 if( elem_num )
1925 {
1926 if( (IndCur > -1) && (IndCur < idata) )
1927 {
1928 i = IndCur;
1929 x = ( float )data.name_set.integers[i];
1930 y = ( float )0.0;
1931 z = ( float )0.0;
1932 }
1933 if( IndCur >= idata )
1934 EndExplo = 1;
1935 }
1936 else
1937 {
1938 printf("\tELEM_ADD_NAMES_SET\n");
1939 printf("\t\tADD NAMES TO SET\n");
1940 for( i=0; i<idata; i++ )
1941 printf("\t\tnames %d : %d\n",
1942 i, data.name_set.integers[i]);
1943 }
1944 delete[] buffer;
1945 break;
1946 }
1947 case CALL_PHIGS_ELEM_REMOVE_NAMES_SET :
1948 {
1949 buffer = new Tchar[size];
1950 TelInqCurElemContent( size, buffer, &actual_size, &data );
1951 idata = data.name_set.number;
1952 if( elem_num )
1953 {
1954 if( (IndCur > -1) && (IndCur < idata) )
1955 {
1956 i = IndCur;
1957 x = ( float )data.name_set.integers[i];
1958 y = ( float )0.0;
1959 z = ( float )0.0;
1960 }
1961 if (IndCur >= idata)
1962 EndExplo = 1;
1963 }
1964 else
1965 {
1966 printf("\tELEM_REMOVE_NAMES_SET\n");
1967 printf("\t\tREMOVE NAMES FROM SET\n");
1968 for( i=0; i<idata; i++ )
1969 printf("\t\tnames %d : %d\n",
1970 i, data.name_set.integers[i]);
1971 }
1972 delete[] buffer;
1973 break;
1974 }
1975 case CALL_PHIGS_ELEM_LOCAL_MODEL_TRAN3 :
1976 {
1977 TelInqCurElemContent( 0, buffer, &actual_size, &data );
1978 if( elem_num )
1979 {
1980 if (IndCur >= 0)
1981 EndExplo = 1;
1982 else
1983 {
1984 x = y = z = ( float )0.0;
1985 }
1986 }
1987 else
1988 {
1989 printf("\tELEM_LOCAL_MODEL_TRAN3\n");
1990 printf("\t\tLOCAL MODELLING TRANSFORMATION 3 comp %d\n",
1991 data.local_xform_3.compose_type);
1992 for( i=0; i<4; i++ )
1993 {
1994 printf("\t\t\t");
1995 for( j=0; j<4; j++ )
1996 printf(" %f", data.local_xform_3.mat3[i][j]);
1997 printf("\n");
1998 }
1999 }
2000 break;
2001 }
2002 case CALL_PHIGS_ELEM_VIEW_IND :
2003 {
2004 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2005 if( elem_num )
2006 {
2007 if (IndCur >= 1)
2008 EndExplo = 1;
2009 else
2010 {
2011 x = ( float )data.idata;
2012 y = ( float )0.0;
2013 z = ( float )0.0;
2014 }
2015 }
2016 else
2017 {
2018 printf("\tELEM_VIEW_IND\n");
2019 printf("\t\tVIEW INDEX %d\n", data.idata);
2020
2021 if(! call_subr_inquirews (Id, &ws))
2022 printf("\t\tERROR : no view definition\n");
2023 else
2024 {
2025 printf("\t\tview structure in %d workstation\n", ws);
2026 printf("\t\t**********************\n");
2027 printf("\t\tdefinition in the ws %d\n", ws);
2028 printf("\t\t**********************\n");
2029 TelPrintViewRepresentation( ws, Id );
2030 }
2031 }
2032 break;
2033 }
2034 case CALL_PHIGS_ELEM_EXEC_STRUCT :
2035 {
2036 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2037 if( elem_num )
2038 {
2039 if (IndCur >= 1)
2040 EndExplo = 1;
2041 else
2042 {
2043 x = ( float )data.idata;
2044 y = ( float )0.0;
2045 z = ( float )0.0;
2046 }
2047 }
2048 else
2049 {
2050 printf("\tELEM_EXEC_STRUCT\n");
2051 printf("\t\tEXECUTE STRUCTURE %d\n", data.idata);
2052 }
2053 break;
2054 }
2055 case CALL_PHIGS_ELEM_APPL_DATA :
2056 {
2057 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2058 if( elem_num )
2059 {
2060 if (IndCur >= 0)
2061 EndExplo = 1;
2062 else
2063 {
2064 x = y = z = ( float )0.0;
2065 }
2066 }
2067 else
2068 {
2069 printf("\tELEM_APPL_DATA\n");
2070 printf("\t\tcontent not exploited\n");
2071 }
2072 break;
2073 }
2074 case CALL_PHIGS_ELEM_PICK_ID :
2075 {
2076 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2077 if( elem_num )
2078 {
2079 if (IndCur >= 1)
2080 EndExplo = 1;
2081 else
2082 {
2083 x = ( float )data.idata;
2084 y = ( float )0.0;
2085 z = ( float )0.0;
2086 }
2087 }
2088 else
2089 {
2090 printf("\tELEM_PICK_ID\n");
2091 printf("\t\tPICK ID %d\n", data.idata);
2092 }
2093 break;
2094 }
2095 case CALL_PHIGS_ELEM_POLYLINE_SET3_DATA : /* DECPHIGS */
2096 {
2097 buffer = new Tchar[size];
2098 TelInqCurElemContent( size, buffer, &actual_size, &data);
2099 jdata = data.lineset3data.num_bounds;
2100
2101 if( elem_num )
2102 {
2103 if( ( IndCur == -1 ) && ( JndCur == 0 ) )
2104 kdata = 0;
2105
2106 if( JndCur >= jdata )
2107 EndExplo = 1;
2108 else
2109 {
2110 if (IndCur == 0)
2111 {
2112 idata = data.lineset3data.bounds[JndCur];
2113 }
2114 else
2115 {
2116 if ( ( IndCur > -1 ) && ( IndCur < idata ) )
2117 {
2118 x = data.lineset3data.points[kdata+IndCur].xyz[0];
2119 y = data.lineset3data.points[kdata+IndCur].xyz[1];
2120 z = data.lineset3data.points[kdata+IndCur].xyz[2];
2121
2122 if( data.lineset3data.colours )
2123 {
2124 r =
2125 data.lineset3data.colours[kdata+IndCur].rgb[0];
2126 g =
2127 data.lineset3data.colours[kdata+IndCur].rgb[1];
2128 b =
2129 data.lineset3data.colours[kdata+IndCur].rgb[2];
2130 }
2131 }
2132
2133 if( IndCur >= idata )
2134 {
2135 kdata += data.lineset3data.bounds[JndCur];
2136 JndCur ++;
2137 IndCur = 0;
2138 }
2139 }
2140 }
2141 }
2142 else
2143 {
2144 printf( "\tELEM_POLYLINE_SET3_DATA\n" );
2145 kdata = 0;
2146 printf( "\t\tPOLYLINE SET 3 WITH DATA\n" );
2147 printf( "\t\tnb of lines %d\n", jdata );
2148 printf( "\t\tvflag %d colr model RGB\n",
2149 data.lineset3data.vrtflag );
2150 for( j = 0; j < jdata && j < MAXAREAS; j++ )
2151 {
2152 idata = data.lineset3data.bounds[j];
2153 printf( "\t\tface %d : %d vertices\n", j, idata );
2154 if( printall )
2155 {
2156 for( i = 0; i < idata && i < MAXPOINTS; i++ )
2157 printf( "\t\t\tvertex %d : %f %f %f\n", i,
2158 data.lineset3data.points[kdata+i].xyz[0],
2159 data.lineset3data.points[kdata+i].xyz[1],
2160 data.lineset3data.points[kdata+i].xyz[2] );
2161 }
2162 else
2163 {
2164 i = 0;
2165 printf( "\t\tfirst vertex %d : %f %f %f\n", i,
2166 data.lineset3data.points[kdata+i].xyz[0],
2167 data.lineset3data.points[kdata+i].xyz[1],
2168 data.lineset3data.points[kdata+i].xyz[2] );
2169
2170 i = idata - 1;
2171 printf( "\t\tlast vertex %d : %f %f %f\n", i,
2172 data.lineset3data.points[kdata+i].xyz[0],
2173 data.lineset3data.points[kdata+i].xyz[1],
2174 data.lineset3data.points[kdata+i].xyz[2] );
2175 }
2176 kdata += data.lineset3data.bounds[j];
2177 }
2178 }
2179 delete[] buffer;
2180 break;
2181 }
2182 case CALL_PHIGS_ELEM_TRI_STRIP3_DATA :
2183 {
2184 buffer = new Tchar[size];
2185 TelInqCurElemContent( size, buffer, &actual_size, &data );
2186 idata = data.trianglestrip3data.num_facets + 2;
2187
2188 if( elem_num )
2189 {
2190 if (IndCur >= idata)
2191 EndExplo = 1;
2192 else
2193 {
2194 x = data.trianglestrip3data.points[IndCur].xyz[0];
2195 y = data.trianglestrip3data.points[IndCur].xyz[1];
2196 z = data.trianglestrip3data.points[IndCur].xyz[2];
2197
2198 if( data.trianglestrip3data.vrtflag ==
2199 CALL_PHIGS_VERT_COORD_COLOUR )
2200 {
2201 r = data.trianglestrip3data.colours[IndCur].rgb[0];
2202 g = data.trianglestrip3data.colours[IndCur].rgb[1];
2203 b = data.trianglestrip3data.colours[IndCur].rgb[2];
2204 }
2205 else if( data.trianglestrip3data.vrtflag ==
2206 CALL_PHIGS_VERT_COORD_NORMAL )
2207 {
2208 nx =
2209 data.trianglestrip3data.vnormals[IndCur].xyz[0];
2210 ny =
2211 data.trianglestrip3data.vnormals[IndCur].xyz[1];
2212 nz =
2213 data.trianglestrip3data.vnormals[IndCur].xyz[2];
2214 }
2215 else if( data.trianglestrip3data.vrtflag ==
2216 CALL_PHIGS_VERT_COORD_COLOUR_NORMAL )
2217 {
2218 nx =
2219 data.trianglestrip3data.vnormals[IndCur].xyz[0];
2220 ny =
2221 data.trianglestrip3data.vnormals[IndCur].xyz[1];
2222 nz =
2223 data.trianglestrip3data.vnormals[IndCur].xyz[2];
2224 r = data.trianglestrip3data.colours[IndCur].rgb[0];
2225 g = data.trianglestrip3data.colours[IndCur].rgb[1];
2226 b = data.trianglestrip3data.colours[IndCur].rgb[2];
2227 }
2228 }
2229 }
2230 else
2231 {
2232 printf("\tELEM_TRI_STRIP3_DATA\n");
2233 printf("\t\tTRIANGLE STRIP 3 WITH DATA\n");
2234 printf("\t\tnb of vertices %d\n", idata);
2235 printf("\t\tfflag %d vflag %d colr model RGB\n",
2236 data.trianglestrip3data.fctflag,
2237 data.trianglestrip3data.vrtflag);
2238 if( printall )
2239 for( i=0; i<idata && i<MAXPOINTS; i++ )
2240 printf("\t\t\tvertex %d : %f %f %f\n", i,
2241 data.trianglestrip3data.points[i].xyz[0],
2242 data.trianglestrip3data.points[i].xyz[1],
2243 data.trianglestrip3data.points[i].xyz[2] );
2244 else
2245 {
2246 i = 0;
2247 printf("\t\tfirst vertex %d : %f %f %f\n", i,
2248 data.trianglestrip3data.points[i].xyz[0],
2249 data.trianglestrip3data.points[i].xyz[1],
2250 data.trianglestrip3data.points[i].xyz[2]);
2251
2252 i = idata - 1;
2253 printf("\t\tlast vertex %d : %f %f %f\n", i,
2254 data.trianglestrip3data.points[i].xyz[0],
2255 data.trianglestrip3data.points[i].xyz[1],
2256 data.trianglestrip3data.points[i].xyz[2]);
2257 }
2258 }
2259 delete buffer;
2260 break;
2261 }
2262 case CALL_PHIGS_ELEM_QUAD_MESH3_DATA :
2263 {
2264 buffer = new Tchar[size];
2265 TelInqCurElemContent( size, buffer, &actual_size, &data);
2266 idata = (data.quadmesh3data.dim.x_dim+1) *
2267 (data.quadmesh3data.dim.y_dim+1);
2268
2269 if( elem_num )
2270 {
2271 if (IndCur >= idata)
2272 EndExplo = 1;
2273 else
2274 {
2275 x = data.quadmesh3data.points[IndCur].xyz[0];
2276 y = data.quadmesh3data.points[IndCur].xyz[1];
2277 z = data.quadmesh3data.points[IndCur].xyz[2];
2278
2279 if( data.quadmesh3data.vrtflag ==
2280 CALL_PHIGS_VERT_COORD_COLOUR )
2281 {
2282 r = data.quadmesh3data.colours[IndCur].rgb[0];
2283 g = data.quadmesh3data.colours[IndCur].rgb[1];
2284 b = data.quadmesh3data.colours[IndCur].rgb[2];
2285 }
2286 else if( data.quadmesh3data.vrtflag ==
2287 CALL_PHIGS_VERT_COORD_NORMAL )
2288 {
2289 nx = data.quadmesh3data.vnormals[IndCur].xyz[0];
2290 ny = data.quadmesh3data.vnormals[IndCur].xyz[1];
2291 nz = data.quadmesh3data.vnormals[IndCur].xyz[2];
2292 }
2293 else if( data.quadmesh3data.vrtflag ==
2294 CALL_PHIGS_VERT_COORD_COLOUR_NORMAL )
2295 {
2296 nx = data.quadmesh3data.vnormals[IndCur].xyz[0];
2297 ny = data.quadmesh3data.vnormals[IndCur].xyz[1];
2298 nz = data.quadmesh3data.vnormals[IndCur].xyz[2];
2299 r = data.quadmesh3data.colours[IndCur].rgb[0];
2300 g = data.quadmesh3data.colours[IndCur].rgb[1];
2301 b = data.quadmesh3data.colours[IndCur].rgb[2];
2302 }
2303 }
2304 }
2305 else
2306 {
2307 printf("\tELEM_QUAD_MESH3_DATA\n");
2308 printf("\t\tQUADRILATERAL MESH 3 WITH DATA\n");
2309 printf("\t\tdimensions %d %d\n",
2310 data.quadmesh3data.dim.x_dim,
2311 data.quadmesh3data.dim.y_dim);
2312 printf("\t\tnb of vertices %d\n", idata);
2313 printf("\t\tfflag %d vflag %d colr model RGB\n",
2314 data.quadmesh3data.fctflag,
2315 data.quadmesh3data.vrtflag);
2316 if( printall )
2317 {
2318 for( i=0; i<idata && i<MAXPOINTS; i++ )
2319 printf("\t\t\tvertex %d : %f %f %f\n", i,
2320 data.quadmesh3data.points[i].xyz[0],
2321 data.quadmesh3data.points[i].xyz[1],
2322 data.quadmesh3data.points[i].xyz[2]);
2323 }
2324 else
2325 {
2326 i = 0;
2327 printf("\t\tfirst vertex %d : %f %f %f\n", i,
2328 data.quadmesh3data.points[i].xyz[0],
2329 data.quadmesh3data.points[i].xyz[1],
2330 data.quadmesh3data.points[i].xyz[2]);
2331
2332 i = idata - 1;
2333 printf("\t\tlast vertex %d : %f %f %f\n", i,
2334 data.quadmesh3data.points[i].xyz[0],
2335 data.quadmesh3data.points[i].xyz[1],
2336 data.quadmesh3data.points[i].xyz[2]);
2337 }
2338 }
2339 delete[] buffer;
2340 break;
2341 }
2342 case CALL_PHIGS_ELEM_TEXT_COLR :
2343 {
2344 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2345 if( elem_num )
2346 {
2347 if (IndCur >= 1)
2348 EndExplo = 1;
2349 else
2350 {
2351 x = data.gnl_colour.rgb[0];
2352 y = data.gnl_colour.rgb[1];
2353 z = data.gnl_colour.rgb[2];
2354 }
2355 }
2356 else
2357 {
2358 printf("\tELEM_TEXT_COLR\n");
2359 printf("\t\tTEXT COLOUR r %f g %f b %f\n",
2360 data.gnl_colour.rgb[0],
2361 data.gnl_colour.rgb[1],
2362 data.gnl_colour.rgb[2] );
2363 }
2364 break;
2365 }
2366 case CALL_PHIGS_ELEM_MARKER_COLR :
2367 {
2368 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2369 if( elem_num )
2370 {
2371 if (IndCur >= 1)
2372 EndExplo = 1;
2373 else
2374 {
2375 x = data.gnl_colour.rgb[0];
2376 y = data.gnl_colour.rgb[1];
2377 z = data.gnl_colour.rgb[2];
2378 }
2379 }
2380 else
2381 {
2382 printf("\tELEM_MARKER_COLR\n");
2383 printf("\t\tPOLYMARKER COLOUR r %f g %f b %f\n",
2384 data.gnl_colour.rgb[0],
2385 data.gnl_colour.rgb[1],
2386 data.gnl_colour.rgb[2] );
2387 }
2388 break;
2389 }
2390 case CALL_PHIGS_ELEM_EDGE_COLR :
2391 {
2392 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2393 if( elem_num )
2394 {
2395 if (IndCur >= 1)
2396 EndExplo = 1;
2397 else
2398 {
2399 x = data.gnl_colour.rgb[0];
2400 y = data.gnl_colour.rgb[1];
2401 z = data.gnl_colour.rgb[2];
2402 }
2403 }
2404 else
2405 {
2406 printf("\tELEM_EDGE_COLR\n");
2407 printf("\t\tEDGE COLOUR r %f g %f b %f\n",
2408 data.gnl_colour.rgb[0],
2409 data.gnl_colour.rgb[1],
2410 data.gnl_colour.rgb[2]);
2411 }
2412 break;
2413 }
2414 case CALL_PHIGS_ELEM_LINE_COLR :
2415 {
2416 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2417 if( elem_num )
2418 {
2419 if (IndCur >= 1)
2420 EndExplo = 1;
2421 else
2422 {
2423 x = data.gnl_colour.rgb[0];
2424 y = data.gnl_colour.rgb[1];
2425 z = data.gnl_colour.rgb[2];
2426 }
2427 }
2428 else
2429 {
2430 printf("\tELEM_LINE_COLR\n");
2431 printf("\t\tPOLYLINE COLOUR r %f g %f b %f\n",
2432 data.gnl_colour.rgb[0],
2433 data.gnl_colour.rgb[1],
2434 data.gnl_colour.rgb[2]);
2435 }
2436 break;
2437 }
2438 case CALL_PHIGS_ELEM_INT_COLR :
2439 {
2440 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2441 if( elem_num )
2442 {
2443 if (IndCur >= 1)
2444 EndExplo = 1;
2445 else
2446 {
2447 x = data.gnl_colour.rgb[0];
2448 y = data.gnl_colour.rgb[1];
2449 z = data.gnl_colour.rgb[2];
2450 }
2451 }
2452 else
2453 {
2454 printf("\tELEM_INT_COLR\n");
2455 printf("\t\tINTERIOR COLOUR r %f g %f b %f\n",
2456 data.gnl_colour.rgb[0],
2457 data.gnl_colour.rgb[1],
2458 data.gnl_colour.rgb[2]);
2459 }
2460 break;
2461 }
2462 case CALL_PHIGS_ELEM_BACK_INT_COLR :
2463 {
2464 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2465 if( elem_num )
2466 {
2467 if (IndCur >= 1)
2468 EndExplo = 1;
2469 else
2470 {
2471 x = data.gnl_colour.rgb[0];
2472 y = data.gnl_colour.rgb[1];
2473 z = data.gnl_colour.rgb[2];
2474 }
2475 }
2476 else
2477 {
2478 printf("\tELEM_BACK_INT_COLR\n");
2479 printf("\t\tBACK INTERIOR COLOUR r %f g %f b %f\n",
2480 data.gnl_colour.rgb[0],
2481 data.gnl_colour.rgb[1],
2482 data.gnl_colour.rgb[2]);
2483 }
2484 break;
2485 }
2486 case CALL_PHIGS_ELEM_REFL_PROPS :
2487 {
2488 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2489 if( elem_num )
2490 {
2491 if (IndCur == 0)
2492 {
2493 x = data.surf_prop.amb;
2494 y = data.surf_prop.diff;
2495 z = data.surf_prop.trans;
2496 }
2497 if (IndCur == 1)
2498 {
2499 x = data.surf_prop.speccol.rgb[0];
2500 y = data.surf_prop.speccol.rgb[1];
2501 z = data.surf_prop.speccol.rgb[2];
2502 }
2503 if (IndCur == 2)
2504 {
2505 x = data.surf_prop.spec;
2506 y = data.surf_prop.shine;
2507 z = ( float )0.0;
2508 }
2509 if (IndCur >= 3)
2510 EndExplo = 1;
2511 }
2512 else
2513 {
2514 printf("\tELEM_REFL_PROPS\n");
2515 printf("\t\tREFLECTANCE PROPERTIES\n");
2516 printf("\t\tamb coef %f diff coef %f trans coef %f\n",
2517 data.surf_prop.amb,
2518 data.surf_prop.diff,
2519 data.surf_prop.trans);
2520 printf("\t\tspecular color r %f g %f b %f\n",
2521 data.surf_prop.speccol.rgb[0],
2522 data.surf_prop.speccol.rgb[1],
2523 data.surf_prop.speccol.rgb[2]);
2524 printf("\t\tspecular coef %f exp %f\n",
2525 data.surf_prop.spec,
2526 data.surf_prop.shine);
2527 }
2528 break;
2529 }
2530 case CALL_PHIGS_ELEM_BACK_REFL_PROPS :
2531 {
2532 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2533 if( elem_num )
2534 {
2535 if (IndCur == 0) {
2536 x = data.surf_prop.amb;
2537 y = data.surf_prop.diff;
2538 z = data.surf_prop.trans;
2539 }
2540 if (IndCur == 1) {
2541 x = data.surf_prop.speccol.rgb[0];
2542 y = data.surf_prop.speccol.rgb[1];
2543 z = data.surf_prop.speccol.rgb[2];
2544 }
2545 if (IndCur == 2) {
2546 x = data.surf_prop.spec;
2547 y = data.surf_prop.shine;
2548 z = ( float )0.0;
2549 }
2550 if (IndCur >= 3)
2551 EndExplo = 1;
2552 }
2553 else
2554 {
2555 printf("\tELEM_BACK_REFL_PROPS\n");
2556 printf("\t\tBACK REFLECTANCE PROPERTIES\n");
2557 printf("\t\tamb coef %f diff coef %f trans coef %f\n",
2558 data.surf_prop.amb,
2559 data.surf_prop.diff,
2560 data.surf_prop.trans);
2561 printf("\t\tspecular color r %f g %f b %f\n",
2562 data.surf_prop.speccol.rgb[0],
2563 data.surf_prop.speccol.rgb[1],
2564 data.surf_prop.speccol.rgb[2]);
2565 printf("\t\tspecular coef %f exp %f\n",
2566 data.surf_prop.spec,
2567 data.surf_prop.shine);
2568 }
2569 break;
2570 }
2571 case CALL_PHIGS_ELEM_INT_SHAD_METH :
2572 {
2573 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2574 if( elem_num )
2575 {
2576 if (IndCur >= 1)
2577 EndExplo = 1;
2578 else
2579 {
2580 x = ( float )data.idata;
2581 y = ( float )0.0;
2582 z = ( float )0.0;
2583 }
2584 }
2585 else
2586 {
2587 printf("\tELEM_INT_SHAD_METH\n");
2588 printf("\t\tINTERIOR SHADING METHOD %d\n", data.idata);
2589 }
2590 break;
2591 }
2592 case CALL_PHIGS_ELEM_INT_REFL_EQN :
2593 {
2594 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2595 if( elem_num )
2596 {
2597 if (IndCur >= 1)
2598 EndExplo = 1;
2599 else
2600 {
2601 x = ( float )data.idata;
2602 y = ( float )0.0;
2603 z = ( float )0.0;
2604 }
2605 }
2606 else
2607 {
2608 printf("\tELEM_INT_REFL_EQN\n");
2609 printf("\t\tREFLECTANCE EQUATION %d\n", data.idata);
2610 }
2611 break;
2612 }
2613 case CALL_PHIGS_ELEM_BACK_INT_REFL_EQN :
2614 {
2615 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2616 if( elem_num )
2617 {
2618 if (IndCur >= 1)
2619 EndExplo = 1;
2620 else
2621 {
2622 x = ( float )data.idata;
2623 y = ( float )0.0;
2624 z = ( float )0.0;
2625 }
2626 }
2627 else
2628 {
2629 printf("\tELEM_BACK_INT_REFL_EQN\n");
2630 printf("\t\tBACK INTERIOR REFLECTANCE EQUATION %d\n",
2631 data.idata);
2632 }
2633 break;
2634 }
2635 case CALL_PHIGS_ELEM_FACE_DISTING_MODE :
2636 {
2637 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2638 if( elem_num )
2639 {
2640 if (IndCur >= 1)
2641 EndExplo = 1;
2642 else
2643 {
2644 x = ( float )data.idata;
2645 y = ( float )0.0;
2646 z = ( float )0.0;
2647 }
2648 }
2649 else
2650 {
2651 printf("\tELEM_FACE_DISTING_MODE\n");
2652 printf("\t\tFACE DISTINGUISHING MODE %d\n", data.idata);
2653 }
2654 break;
2655 }
2656 case CALL_PHIGS_ELEM_FACE_CULL_MODE :
2657 {
2658 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2659 if( elem_num )
2660 {
2661 if (IndCur >= 1)
2662 EndExplo = 1;
2663 else
2664 {
2665 x = ( float )data.idata;
2666 y = ( float )0.0;
2667 z = ( float )0.0;
2668 }
2669 }
2670 else
2671 {
2672 printf("\tELEM_FACE_CULL_MODE\n");
2673 printf("\t\tFACE CULLING MODE %d\n", data.idata);
2674 }
2675 break;
2676 }
2677 case CALL_PHIGS_ELEM_LIGHT_SRC_STATE :
2678 {
2679 buffer = new Tchar[size];
2680 TelInqCurElemContent( size, buffer, &actual_size, &data );
2681 idata = data.light_source_state.on.number;
2682 jdata = data.light_source_state.off.number;
2683 if( elem_num )
2684 {
2685 if ( (IndCur >= idata) && (IndCur >= jdata) )
2686 EndExplo = 1;
2687 else
2688 {
2689 if (IndCur < idata)
2690 x = ( float )data.light_source_state.on.integers[IndCur];
2691 if (IndCur < jdata)
2692 nx = ( float )data.light_source_state.off.integers[IndCur];
2693 }
2694 }
2695 else
2696 {
2697 printf("\tELEM_LIGHT_SRC_STATE\n");
2698 for (i=0; i<idata; i++)
2699 printf("\t\tactive light %d\n",
2700 data.light_source_state.on.integers[i]);
2701 for (j=0; j<jdata; j++)
2702 printf("\t\tinactive light %d\n",
2703 data.light_source_state.off.integers[j]);
2704 }
2705 delete[] buffer;
2706 break;
2707 }
2708 case CALL_PHIGS_ELEM_DCUE_IND :
2709 {
2710 TelInqCurElemContent( 0, buffer, &actual_size, &data );
2711 if( elem_num )
2712 {
2713 if (IndCur >= 1)
2714 EndExplo = 1;
2715 else
2716 {
2717 x = ( float )data.idata;
2718 y = ( float )0.0;
2719 z = ( float )0.0;
2720 }
2721 }
2722 else
2723 {
2724 printf("\tELEM_DCUE_IND\n");
2725 printf("\t\tDEPTH CUE INDEX %d\n", data.idata);
2726 }
2727 break;
2728 }
2729 default:
2730 break;
2731 }
2732 }
2733
2734 if( elem_num )
2735 {
2736 index = 0;
2737 pt->x = x;
2738 pt->y = y;
2739 pt->z = z;
2740 npt->dx = nx;
2741 npt->dy = ny;
2742 npt->dz = nz;
2743 cpt->r = r;
2744 cpt->g = g;
2745 cpt->b = b;
2746 nfa->dx = dx;
2747 nfa->dy = dy;
2748 nfa->dz = dz;
2749
2750 if( EndExplo )
2751 *elem_type = 0;
2752 }
2753 else
2754 index ++;
2755 } /* while (index) */
2756
2757 call_func_close_struct ();
2758}
2759
2760Tint
2761call_subr_inquirews( Tint struct_id, Tint *ws_id )
2762{
2763 Tint act_size;
2764
2765 TsmGetWSPosted( struct_id, 1, ws_id, &act_size );
2766
2767 if( act_size )
2768 return 1;
2769 else
2770 return 0;
2771}
2772
2773
2774void
2775call_subr_polygon_holes( CALL_DEF_LISTFACETS * alfacets )
2776{
2777 register int i, j, k;
2778 int go;
2779 CMN_KEY k1, k2, k3;
2780
2781 Tint *bounds;
2782 TEL_POINT *points;
2783
2784 bounds = new Tint[alfacets->NbFacets];
2785
2786 j = 0;
2787 for( i=0; i<alfacets->NbFacets; i++ )
2788 j += alfacets->LFacets[i].NbPoints;
2789
2790 points = new TEL_POINT[j];
2791
2792 for( i = 0; i < alfacets->NbFacets; i++ )
2793 bounds[i] = alfacets->LFacets[i].NbPoints;
2794
2795 k = 0;
2796 for (i=0; i<alfacets->NbFacets; i++)
2797 {
2798 for (j=0; j<alfacets->LFacets[i].NbPoints; j++)
2799 {
2800 points[k].xyz[0] = alfacets->LFacets[i].UPoints.Points[j].x;
2801 points[k].xyz[1] = alfacets->LFacets[i].UPoints.Points[j].y;
2802 points[k].xyz[2] = alfacets->LFacets[i].UPoints.Points[j].z;
2803 k++;
2804 }
2805 }
2806
2807 go = 1;
2808 if( bounds == 0 )
2809 go = 0;
2810 if( points == 0 )
2811 go = 0;
2812
2813 if( go )
2814 {
2815 k1.id = NUM_FACETS_ID;
2816 k1.data.ldata = alfacets->NbFacets;
2817 k2.id = BOUNDS_DATA_ID;
2818 k2.data.pdata = bounds;
2819 k3.id = VERTICES_ID;
2820 k3.data.pdata = points;
2821
2822 TsmAddToStructure( TelPolygonHoles, 3, &k1, &k2, &k3 );
2823 }
2824
2825 if( bounds != 0 )
2826 delete[] bounds;
2827 if( points != 0 )
2828 delete[] points;
2829}
2830
2831void
2832call_subr_polygon_holes_data( CALL_DEF_LISTFACETS * alfacets )
2833{
2834 register Tint i, j, k, count=0;
2835 CMN_KEY key[10];
2836 cmn_key kk[10];
2837 int go;
2838 Tint num_vertices;
2839 Tint num_bounds, *bounds = 0;
2840 TEL_POINT *vertices = 0;
2841 TEL_POINT *vnormals = 0;
2842
2843 for( i = 0; i < 10; i++ )
2844 kk[i] = &key[i];
2845
2846 key[count].id = SHAPE_FLAG_ID;
2847 key[count].data.ldata = TEL_SHAPE_UNKNOWN;
2848 count++;
2849
2850 key[count].id = NUM_FACETS_ID;
2851 key[count].data.ldata = alfacets->NbFacets;
2852 count++;
2853
2854 num_bounds = alfacets->NbFacets;
2855 bounds = new Tint[num_bounds];
2856
2857 key[count].id = BOUNDS_DATA_ID;
2858 key[count].data.pdata = bounds;
2859 count++;
2860
2861 num_vertices = 0;
2862 for( i=0; i<num_bounds; i++ )
2863 num_vertices += alfacets->LFacets[i].NbPoints;
2864
2865 k = 0;
2866 for( i=0; i<num_bounds; i++ )
2867 {
2868 bounds[i] = alfacets->LFacets[i].NbPoints;
2869
2870 switch( alfacets->LFacets[i].TypePoints )
2871 {
2872 case 1 : /* Coordinates Specified */
2873 {
2874 if( vertices == 0 )
2875 {
2876 vertices = new TEL_POINT[num_vertices];
2877
2878 key[count].id = VERTICES_ID;
2879 key[count].data.pdata = vertices;
2880 count++;
2881 }
2882
2883 for( j=0; j<alfacets->LFacets[i].NbPoints; j++ )
2884 {
2885 vertices[k].xyz[0] = alfacets->LFacets[i].UPoints.Points[j].x;
2886 vertices[k].xyz[1] = alfacets->LFacets[i].UPoints.Points[j].y;
2887 vertices[k].xyz[2] = alfacets->LFacets[i].UPoints.Points[j].z;
2888 k++;
2889 }
2890
2891 break;
2892 }
2893
2894 case 2 : /* Coordinates and Vertex Normal Specified */
2895 {
2896 if( vertices == 0 )
2897 {
2898 vertices = new TEL_POINT[num_vertices];
2899
2900 key[count].id = VERTICES_ID;
2901 key[count].data.pdata = vertices;
2902 count++;
2903
2904 vnormals = new TEL_POINT[num_vertices];
2905 key[count].id = VNORMALS_ID;
2906 key[count].data.pdata = vnormals;
2907 count++;
2908 }
2909
2910 for( j=0; j<alfacets->LFacets[i].NbPoints; j++ )
2911 {
2912 vertices[k].xyz[0] =
2913 alfacets->LFacets[i].UPoints.PointsN[j].Point.x;
2914 vertices[k].xyz[1] =
2915 alfacets->LFacets[i].UPoints.PointsN[j].Point.y;
2916 vertices[k].xyz[2] =
2917 alfacets->LFacets[i].UPoints.PointsN[j].Point.z;
2918 vnormals[k].xyz[0] =
2919 alfacets->LFacets[i].UPoints.PointsN[j].Normal.dx;
2920 vnormals[k].xyz[1] =
2921 alfacets->LFacets[i].UPoints.PointsN[j].Normal.dy;
2922 vnormals[k].xyz[2] =
2923 alfacets->LFacets[i].UPoints.PointsN[j].Normal.dz;
2924 k++;
2925 }
2926
2927 break;
2928 }
2929 }
2930 }
2931
2932 go = 1;
2933 if(bounds == 0)
2934 go = 0;
2935 if(vertices == 0)
2936 go = 0;
2937 if(vnormals == 0)
2938 go = 0;
2939
2940 if(go)
2941 {
2942 TsmAddToStructure( TelPolygonHoles, -count, kk );
2943 }
2944
2945 if(bounds)
2946 delete[] bounds;
2947 if(vertices)
2948 delete[] vertices;
2949 if(vnormals)
2950 delete[] vnormals;
2951}
2952
2953
2954void
2955call_subr_curve( CALL_DEF_LISTPOINTS * alpoints )
2956{
2957 CMN_KEY key[3];
2958 cmn_key kp[3];
2959
2960 kp[0] = &key[0], kp[1] = &key[1], kp[2] = &key[2];
2961
2962 key[0].id = CURVE_TYPE_ID;
2963 key[0].data.ldata = TelBezierCurve;
2964
2965 key[1].id = CURVE_NUM_POINTS_ID;
2966 key[1].data.ldata = 20;
2967
2968 key[2].id = CURVE_VERTICES_ID;
2969 key[2].data.pdata = alpoints->UPoints.Points;
2970
2971 TsmAddToStructure( TelCurve, -3, kp );
2972
2973 return;
2974}
2975
2976/* *** PARRAY functions *** */
2977
2978void call_subr_parray( CALL_DEF_PARRAY *parray )
2979{
2980 CMN_KEY key;
2981 key.id = PARRAY_ID;
2982 key.data.pdata = (void *) parray;
2983
2984 TsmAddToStructure( TelParray, 1, &key );
2985}
2986
2987void call_subr_userdraw( CALL_DEF_USERDRAW *anobject )
2988{
2989 CMN_KEY key;
2990
2991 key.id = 1;
2992 key.data.pdata = anobject;
2993
2994 TsmAddToStructure( TelUserdraw, 1, &key );
2995}