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