0012121: Optimization of existing selection classes
[occt.git] / src / OpenGl / OpenGl_GraphicDriver_705.cxx
CommitLineData
7fd59977 1
2// File OpenGl_GraphicDriver_705.cxx
3// Created Mardi 28 janvier 1997
4// Author CAL
5// Modified
6// 27/07/97 ; PCT : ajout coordonnee texture
7
8//-Copyright MatraDatavision 1997
9
10//-Version
11
12//-Design Declaration des variables specifiques aux Drivers
13
14//-Warning Un driver encapsule les Pex et OpenGl drivers
15
16//-References
17
18//-Language C++ 2.0
19
20//-Declarations
21
22// for the class
23#include <OpenGl_GraphicDriver.jxx>
24
25#include <Aspect_DriverDefinitionError.hxx>
26
27#include <OpenGl_tgl_funcs.hxx>
28
29//-Aliases
30
31//-Global data definitions
32
33//-Methods, in order
34
35void OpenGl_GraphicDriver::Polygon (const Graphic3d_CGroup& ACGroup,
36 const Graphic3d_Array1OfVertex& ListVertex,
37 const Graphic3d_TypeOfPolygon AType,
38 const Standard_Boolean )
39{
40 Graphic3d_CGroup MyCGroup = ACGroup;
41
42 Standard_Integer i;
43 Standard_Integer Lower = ListVertex.Lower ();
44
45 CALL_DEF_FACET afacet;
46
47 i = ListVertex.Length ();
48
49 afacet.TypeFacet = int (AType);
50
51 afacet.NormalIsDefined = 0;
52 afacet.ColorIsDefined = 0;
53
54 afacet.NbPoints = int (i);
55 afacet.TypePoints = 1;
56 afacet.UPoints.Points = (CALL_DEF_POINT *) &ListVertex (Lower);
57
58 if (MyTraceLevel) {
59 PrintFunction ("call_togl_polygon");
60 PrintCGroup (MyCGroup, 1);
61 }
62 call_togl_polygon (&MyCGroup, &afacet);
63
64}
65
66void OpenGl_GraphicDriver::Polygon (const Graphic3d_CGroup& ACGroup,
67 const Graphic3d_Array1OfVertex& ListVertex,
68 const Graphic3d_Vector& Normal,
69 const Graphic3d_TypeOfPolygon AType,
70 const Standard_Boolean )
71{
72 Graphic3d_CGroup MyCGroup = ACGroup;
73
74
75 Standard_Real X, Y, Z;
76
77 Standard_Integer i;
78 Standard_Integer Lower = ListVertex.Lower ();
79
80 CALL_DEF_FACET afacet;
81
82 i = ListVertex.Length ();
83
84 afacet.TypeFacet = int (AType);
85
86 afacet.NormalIsDefined = 1;
87 afacet.ColorIsDefined = 0;
88
89 Normal.Coord (X, Y, Z);
90 afacet.Normal.dx = float (X);
91 afacet.Normal.dy = float (Y);
92 afacet.Normal.dz = float (Z);
93
94 afacet.NbPoints = int (i);
95 afacet.TypePoints = 1;
96 afacet.UPoints.Points = (CALL_DEF_POINT *) &ListVertex (Lower);
97
98 if (MyTraceLevel) {
99 PrintFunction ("call_togl_polygon");
100 PrintCGroup (MyCGroup, 1);
101 }
102 call_togl_polygon (&MyCGroup, &afacet);
103
104}
105
106void OpenGl_GraphicDriver::Polygon (const Graphic3d_CGroup& ACGroup,
107 const Graphic3d_Array1OfVertexN& ListVertex,
108 const Graphic3d_TypeOfPolygon AType,
109 const Standard_Boolean )
110{
111
112 Graphic3d_CGroup MyCGroup = ACGroup;
113
114 Standard_Real X, Y, Z;
115 Standard_Real DX, DY, DZ;
116
117 Standard_Integer i, j;
118 Standard_Integer Lower = ListVertex.Lower ();
119 Standard_Integer Upper = ListVertex.Upper ();
120
121 CALL_DEF_FACET afacet;
122 CALL_DEF_POINTN *points;
123
124 i = ListVertex.Length ();
125
126 // Allocation dynamique
127 points = new CALL_DEF_POINTN [i];
128
129 afacet.TypeFacet = int (AType);
130
131 afacet.NormalIsDefined = 0;
132 afacet.ColorIsDefined = 0;
133
134 afacet.NbPoints = int (i);
135 afacet.TypePoints = 2;
136 afacet.UPoints.PointsN = points;
137
138 // Parcours des sommets
139 for (j=0, i=Lower; i<=Upper; i++, j++) {
140 ListVertex (i).Coord (X, Y, Z);
141 points[j].Point.x = float (X);
142 points[j].Point.y = float (Y);
143 points[j].Point.z = float (Z);
144 ListVertex (i).Normal (DX, DY, DZ);
145 points[j].Normal.dx = float (DX);
146 points[j].Normal.dy = float (DY);
147 points[j].Normal.dz = float (DZ);
148 }
149
150 if (MyTraceLevel) {
151 PrintFunction ("call_togl_polygon");
152 PrintCGroup (MyCGroup, 1);
153 }
154 call_togl_polygon (&MyCGroup, &afacet);
155
156 // Desallocation dynamique
157 delete [] points;
158
159}
160
161void OpenGl_GraphicDriver::Polygon (const Graphic3d_CGroup& ACGroup,
162 const Graphic3d_Array1OfVertexN& ListVertex,
163 const Graphic3d_Vector& Normal,
164 const Graphic3d_TypeOfPolygon AType,
165 const Standard_Boolean )
166{
167 Graphic3d_CGroup MyCGroup = ACGroup;
168
169
170 Standard_Real X, Y, Z;
171 Standard_Real DX, DY, DZ;
172
173 Standard_Integer i, j;
174 Standard_Integer Lower = ListVertex.Lower ();
175 Standard_Integer Upper = ListVertex.Upper ();
176
177 CALL_DEF_FACET afacet;
178 CALL_DEF_POINTN *points;
179
180 i = ListVertex.Length ();
181
182 // Allocation dynamique
183 points = new CALL_DEF_POINTN [i];
184
185 afacet.TypeFacet = int (AType);
186
187 afacet.NormalIsDefined = 1;
188 afacet.ColorIsDefined = 0;
189
190 Normal.Coord (DX, DY, DZ);
191 afacet.Normal.dx = float (DX);
192 afacet.Normal.dy = float (DY);
193 afacet.Normal.dz = float (DZ);
194
195 afacet.NbPoints = int (i);
196 afacet.TypePoints = 2;
197 afacet.UPoints.PointsN = points;
198
199 // Parcours des sommets
200 for (j=0, i=Lower; i<=Upper; i++, j++) {
201 ListVertex (i).Coord (X, Y, Z);
202 points[j].Point.x = float (X);
203 points[j].Point.y = float (Y);
204 points[j].Point.z = float (Z);
205 ListVertex (i).Normal (DX, DY, DZ);
206 points[j].Normal.dx = float (DX);
207 points[j].Normal.dy = float (DY);
208 points[j].Normal.dz = float (DZ);
209 }
210
211 if (MyTraceLevel) {
212 PrintFunction ("call_togl_polygon");
213 PrintCGroup (MyCGroup, 1);
214 }
215 call_togl_polygon (&MyCGroup, &afacet);
216
217 // Desallocation dynamique
218 delete [] points;
219
220}
221
222
223void OpenGl_GraphicDriver::Polygon(const Graphic3d_CGroup& ACGroup,
224 const Graphic3d_Array1OfVertexNT& ListVertex,
225 const Graphic3d_TypeOfPolygon AType,
226 const Standard_Boolean )
227{
228
229 Graphic3d_CGroup MyCGroup = ACGroup;
230
231
232 Standard_Real X, Y, Z;
233 Standard_Real DX, DY, DZ;
234 Standard_Real TX, TY;
235
236 Standard_Integer i, j;
237 Standard_Integer Lower = ListVertex.Lower ();
238 Standard_Integer Upper = ListVertex.Upper ();
239
240 CALL_DEF_FACET afacet;
241 CALL_DEF_POINTNT *points;
242
243 i = ListVertex.Length ();
244
245 // Allocation dynamique
246 points = new CALL_DEF_POINTNT [i];
247
248 afacet.TypeFacet = int (AType);
249
250 afacet.NormalIsDefined = 0;
251 afacet.ColorIsDefined = 0;
252
253 afacet.NbPoints = int (i);
254 afacet.TypePoints = 5;
255 afacet.UPoints.PointsNT = points;
256
257 // Parcours des sommets
258 for (j=0, i=Lower; i<=Upper; i++, j++) {
259 ListVertex (i).Coord (X, Y, Z);
260 points[j].Point.x = float (X);
261 points[j].Point.y = float (Y);
262 points[j].Point.z = float (Z);
263 ListVertex (i).Normal (DX, DY, DZ);
264 points[j].Normal.dx = float (DX);
265 points[j].Normal.dy = float (DY);
266 points[j].Normal.dz = float (DZ);
267 ListVertex (i).TextureCoordinate(TX, TY);
268 points[j].TextureCoord.tx = float(TX);
269 points[j].TextureCoord.ty = float(TY);
270 }
271
272 if (MyTraceLevel) {
273 PrintFunction ("call_togl_polygon");
274 PrintCGroup (MyCGroup, 1);
275 }
276 call_togl_polygon (&MyCGroup, &afacet);
277
278 // Desallocation dynamique
279 delete [] points;
280
281}
282
283
284void OpenGl_GraphicDriver::PolygonHoles (const Graphic3d_CGroup& ACGroup,
285 const TColStd_Array1OfInteger& Bounds,
286 const Graphic3d_Array1OfVertex& ListVertex,
287 const Standard_Boolean )
288{
289
290 Graphic3d_CGroup MyCGroup = ACGroup;
291
292 Standard_Real X, Y, Z;
293
294 Standard_Integer i, ii;
295 Standard_Integer j;
296 Standard_Integer k, kk;
297 Standard_Integer nb_points;
298 Standard_Integer begin_points;
299 Standard_Integer end_points;
300 Standard_Integer Lower, Upper;
301
302 CALL_DEF_LISTFACETS alfacets;
303 CALL_DEF_FACET *facets;
304 CALL_DEF_POINT *points;
305
306 i = ListVertex.Length ();
307 j = Bounds.Length ();
308
309 // Allocation dynamique
310 points = new CALL_DEF_POINT [i];
311 facets = new CALL_DEF_FACET [j];
312
313 alfacets.NbFacets = int (j);
314 alfacets.LFacets = facets;
315
316 begin_points = ListVertex.Lower ();
317 end_points = ListVertex.Upper ();
318
319 Lower = Bounds.Lower ();
320 Upper = Bounds.Upper ();
321
322 nb_points = 0;
323
324 // Parcours des facettes
325 for (k=0, kk=Lower; kk<=Upper; k++, kk++) {
326 facets[k].TypeFacet = 0; /* TOP_UNKNOWN */
327
328 facets[k].NormalIsDefined = 0;
329 facets[k].ColorIsDefined = 0;
330
331 facets[k].NbPoints = int (Bounds.Value (kk));
332 facets[k].TypePoints = 1;
333 facets[k].UPoints.Points = (points + nb_points);
334
335 // Parcours des sommets
336 for (i=0, ii=begin_points;
337 ((ii<=end_points) || (i==facets[k].NbPoints-1));
338 i++, ii++) {
339 ListVertex (ii).Coord (X, Y, Z);
340 points[nb_points+i].x = float (X);
341 points[nb_points+i].y = float (Y);
342 points[nb_points+i].z = float (Z);
343 }
344 begin_points += facets[k].NbPoints;
345 nb_points += facets[k].NbPoints;
346 }
347
348 if (MyTraceLevel) {
349 PrintFunction ("call_togl_polygon_holes");
350 PrintCGroup (MyCGroup, 1);
351 }
352 call_togl_polygon_holes (&MyCGroup, &alfacets);
353
354 // Desallocation dynamique
355 delete [] points;
356 delete [] facets;
357
358}
359
360void OpenGl_GraphicDriver::PolygonHoles (const Graphic3d_CGroup& ACGroup,
361 const TColStd_Array1OfInteger& Bounds,
362 const Graphic3d_Array1OfVertex& ListVertex,
363 const Graphic3d_Vector& Normal,
364 const Standard_Boolean )
365{
366
367 Graphic3d_CGroup MyCGroup = ACGroup;
368
369 Standard_Real X, Y, Z;
370 Standard_Real NX, NY, NZ;
371
372 Standard_Integer i, ii;
373 Standard_Integer j;
374 Standard_Integer k, kk;
375 Standard_Integer nb_points;
376 Standard_Integer begin_points;
377 Standard_Integer end_points;
378 Standard_Integer Lower, Upper;
379
380 CALL_DEF_LISTFACETS alfacets;
381 CALL_DEF_FACET *facets;
382 CALL_DEF_POINT *points;
383
384 i = ListVertex.Length ();
385 j = Bounds.Length ();
386
387 // Allocation dynamique
388 points = new CALL_DEF_POINT [i];
389 facets = new CALL_DEF_FACET [j];
390
391 alfacets.NbFacets = int (j);
392 alfacets.LFacets = facets;
393
394 begin_points = ListVertex.Lower ();
395 end_points = ListVertex.Upper ();
396
397 Lower = Bounds.Lower ();
398 Upper = Bounds.Upper ();
399
400 nb_points = 0;
401
402 Normal.Coord (NX, NY, NZ);
403
404 // Parcours des facettes
405 for (k=0, kk=Lower; kk<=Upper; k++, kk++) {
406 facets[k].TypeFacet = 0; /* TOP_UNKNOWN */
407
408 facets[k].ColorIsDefined = 0;
409 facets[k].NormalIsDefined = 1;
410 facets[k].Normal.dx = float (NX);
411 facets[k].Normal.dy = float (NY);
412 facets[k].Normal.dz = float (NZ);
413
414 facets[k].NbPoints = int (Bounds.Value (kk));
415 facets[k].TypePoints = 1;
416 facets[k].UPoints.Points = (points + nb_points);
417
418 // Parcours des sommets
419 for (i=0, ii=begin_points;
420 ((ii<=end_points) || (i==facets[k].NbPoints-1));
421 i++, ii++) {
422 ListVertex (ii).Coord (X, Y, Z);
423 points[nb_points+i].x = float (X);
424 points[nb_points+i].y = float (Y);
425 points[nb_points+i].z = float (Z);
426 }
427 begin_points += facets[k].NbPoints;
428 nb_points += facets[k].NbPoints;
429 }
430
431 if (MyTraceLevel) {
432 PrintFunction ("call_togl_polygon_holes");
433 PrintCGroup (MyCGroup, 1);
434 }
435 call_togl_polygon_holes (&MyCGroup, &alfacets);
436
437 // Desallocation dynamique
438 delete [] points;
439 delete [] facets;
440
441}
442
443void OpenGl_GraphicDriver::PolygonHoles (const Graphic3d_CGroup& ACGroup,
444 const TColStd_Array1OfInteger& Bounds,
445 const Graphic3d_Array1OfVertexN& ListVertex,
446 const Standard_Boolean )
447{
448
449 Graphic3d_CGroup MyCGroup = ACGroup;
450
451 Standard_Real X, Y, Z;
452 Standard_Real DX, DY, DZ;
453
454 Standard_Integer i, ii;
455 Standard_Integer j;
456 Standard_Integer k, kk;
457 Standard_Integer nb_points;
458 Standard_Integer begin_points;
459 Standard_Integer end_points;
460 Standard_Integer Lower, Upper;
461
462 CALL_DEF_LISTFACETS alfacets;
463 CALL_DEF_FACET *facets;
464 CALL_DEF_POINTN *points;
465
466 i = ListVertex.Length ();
467 j = Bounds.Length ();
468
469 // Allocation dynamique
470 points = new CALL_DEF_POINTN [i];
471 facets = new CALL_DEF_FACET [j];
472
473 alfacets.NbFacets = int (j);
474 alfacets.LFacets = facets;
475
476 begin_points = ListVertex.Lower ();
477 end_points = ListVertex.Upper ();
478
479 Lower = Bounds.Lower ();
480 Upper = Bounds.Upper ();
481
482 nb_points = 0;
483
484 // Parcours des facettes
485 for (k=0, kk=Lower; kk<=Upper; k++, kk++) {
486 facets[k].TypeFacet = 0; /* TOP_UNKNOWN */
487
488 facets[k].NormalIsDefined = 0;
489 facets[k].ColorIsDefined = 0;
490
491 facets[k].NbPoints = int (Bounds.Value (kk));
492 facets[k].TypePoints = 2;
493 facets[k].UPoints.PointsN = (points + nb_points);
494
495 // Parcours des sommets
496 for (i=0, ii=begin_points;
497 ((ii<=end_points) || (i==facets[k].NbPoints-1));
498 i++, ii++) {
499 ListVertex (ii).Coord (X, Y, Z);
500 points[nb_points+i].Point.x = float (X);
501 points[nb_points+i].Point.y = float (Y);
502 points[nb_points+i].Point.z = float (Z);
503 ListVertex (ii).Normal (DX, DY, DZ);
504 points[nb_points+i].Normal.dx = float (DX);
505 points[nb_points+i].Normal.dy = float (DY);
506 points[nb_points+i].Normal.dz = float (DZ);
507 }
508 begin_points += facets[k].NbPoints;
509 nb_points += facets[k].NbPoints;
510 }
511
512 if (MyTraceLevel) {
513 PrintFunction ("call_togl_polygon_holes");
514 PrintCGroup (MyCGroup, 1);
515 }
516 call_togl_polygon_holes (&MyCGroup, &alfacets);
517
518 // Desallocation dynamique
519 delete [] points;
520 delete [] facets;
521
522}
523
524void OpenGl_GraphicDriver::PolygonHoles (const Graphic3d_CGroup& ACGroup,
525 const TColStd_Array1OfInteger& Bounds,
526 const Graphic3d_Array1OfVertexN& ListVertex,
527 const Graphic3d_Vector& Normal,
528 const Standard_Boolean )
529{
530
531 Graphic3d_CGroup MyCGroup = ACGroup;
532
533 Standard_Real X, Y, Z;
534 Standard_Real DX, DY, DZ;
535 Standard_Real NX, NY, NZ;
536
537 Standard_Integer i, ii;
538 Standard_Integer j;
539 Standard_Integer k, kk;
540 Standard_Integer nb_points;
541 Standard_Integer begin_points;
542 Standard_Integer end_points;
543 Standard_Integer Lower, Upper;
544
545 CALL_DEF_LISTFACETS alfacets;
546 CALL_DEF_FACET *facets;
547 CALL_DEF_POINTN *points;
548
549 i = ListVertex.Length ();
550 j = Bounds.Length ();
551
552 // Allocation dynamique
553 points = new CALL_DEF_POINTN [i];
554 facets = new CALL_DEF_FACET [j];
555
556 alfacets.NbFacets = int (j);
557 alfacets.LFacets = facets;
558
559 begin_points = ListVertex.Lower ();
560 end_points = ListVertex.Upper ();
561
562 Lower = Bounds.Lower ();
563 Upper = Bounds.Upper ();
564
565 nb_points = 0;
566
567 Normal.Coord (NX, NY, NZ);
568
569 // Parcours des facettes
570 for (k=0, kk=Lower; kk<=Upper; k++, kk++) {
571 facets[k].TypeFacet = 0; /* TOP_UNKNOWN */
572
573 facets[k].ColorIsDefined = 0;
574 facets[k].NormalIsDefined = 1;
575 facets[k].Normal.dx = float (NX);
576 facets[k].Normal.dy = float (NY);
577 facets[k].Normal.dz = float (NZ);
578
579 facets[k].NbPoints = int (Bounds.Value (kk));
580 facets[k].TypePoints = 2;
581 facets[k].UPoints.PointsN = (points + nb_points);
582
583 // Parcours des sommets
584 for (i=0, ii=begin_points;
585 ((ii<=end_points) || (i==facets[k].NbPoints-1));
586 i++, ii++) {
587 ListVertex (ii).Coord (X, Y, Z);
588 points[nb_points+i].Point.x = float (X);
589 points[nb_points+i].Point.y = float (Y);
590 points[nb_points+i].Point.z = float (Z);
591 ListVertex (ii).Normal (DX, DY, DZ);
592 points[nb_points+i].Normal.dx = float (DX);
593 points[nb_points+i].Normal.dy = float (DY);
594 points[nb_points+i].Normal.dz = float (DZ);
595 }
596 begin_points += facets[k].NbPoints;
597 nb_points += facets[k].NbPoints;
598 }
599
600 if (MyTraceLevel) {
601 PrintFunction ("call_togl_polygon_holes");
602 PrintCGroup (MyCGroup, 1);
603 }
604 call_togl_polygon_holes (&MyCGroup, &alfacets);
605
606 // Desallocation dynamique
607 delete [] points;
608 delete [] facets;
609
610}