1 // File OpenGl_GraphicDriver_711.cxx
2 // Created Mardi 28 janvier 1997
6 // 27/08/97 ; PCT : ajout coordonne texture
8 //-Copyright MatraDatavision 1997
12 //-Design Declaration des variables specifiques aux Drivers
14 //-Warning Un driver encapsule les Pex et OpenGl drivers
23 #include <OpenGl_GraphicDriver.jxx>
24 #include <Aspect_DriverDefinitionError.hxx>
27 #include <OSD_Timer.hxx>
29 #include <OpenGl_tgl_funcs.hxx>
33 //-Global data definitions
37 void OpenGl_GraphicDriver::TriangleMesh (const Graphic3d_CGroup& ACGroup,
38 const Graphic3d_Array1OfVertex& ListVertex,
39 const Standard_Boolean )
42 Graphic3d_CGroup MyCGroup = ACGroup;
44 Standard_Integer Lower = ListVertex.Lower ();
46 CALL_DEF_TRIKE atrike;
48 atrike.NbPoints = int (ListVertex.Length ());
49 atrike.TypePoints = 1;
50 atrike.UPoints.Points = (CALL_DEF_POINT *) &ListVertex (Lower);
53 PrintFunction ("call_togl_triangle");
54 PrintCGroup (MyCGroup, 1);
56 call_togl_triangle (&MyCGroup, &atrike);
60 void OpenGl_GraphicDriver::TriangleMesh (const Graphic3d_CGroup& ACGroup,
61 const Graphic3d_Array1OfVertexN& ListVertex,
62 const Standard_Boolean )
65 Graphic3d_CGroup MyCGroup = ACGroup;
67 Standard_Real X, Y, Z;
68 Standard_Real DX, DY, DZ;
70 Standard_Integer i, j;
71 Standard_Integer Lower = ListVertex.Lower ();
72 Standard_Integer Upper = ListVertex.Upper ();
74 CALL_DEF_TRIKE atrike;
75 CALL_DEF_POINTN *points;
77 i = ListVertex.Length ();
79 // Allocation dynamique
80 points = new CALL_DEF_POINTN [i];
82 atrike.NbPoints = int (i);
83 atrike.TypePoints = 2;
84 atrike.UPoints.PointsN = points;
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);
99 PrintFunction ("call_togl_triangle");
100 PrintCGroup (MyCGroup, 1);
102 call_togl_triangle (&MyCGroup, &atrike);
104 // Desallocation dynamique
110 void OpenGl_GraphicDriver::TriangleMesh(const Graphic3d_CGroup& ACGroup,
111 const Graphic3d_Array1OfVertexNT& ListVertex,
112 const Standard_Boolean )
115 Graphic3d_CGroup MyCGroup = ACGroup;
117 Standard_Real X, Y, Z;
118 Standard_Real DX, DY, DZ;
120 Standard_Integer i, j;
121 Standard_Integer Lower = ListVertex.Lower ();
122 Standard_Integer Upper = ListVertex.Upper ();
124 CALL_DEF_TRIKE atrike;
125 CALL_DEF_POINTNT *points;
127 i = ListVertex.Length ();
129 // Allocation dynamique
130 points = new CALL_DEF_POINTNT [i];
132 atrike.NbPoints = int (i);
133 atrike.TypePoints = 5;
134 atrike.UPoints.PointsNT = points;
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);
152 PrintFunction ("call_togl_triangle");
153 PrintCGroup (MyCGroup, 1);
155 call_togl_triangle (&MyCGroup, &atrike);
157 // Desallocation dynamique
162 void OpenGl_GraphicDriver::TriangleSet (const Graphic3d_CGroup& ACGroup,
163 const Graphic3d_Array1OfVertex& ListVertex,
164 const Aspect_Array1OfEdge& ListEdge,
165 const Standard_Boolean )
168 Graphic3d_CGroup MyCGroup = ACGroup;
171 Standard_Real seconds, CPUtime;
172 Standard_Integer minutes, hours;
174 Standard_Integer i, j, k;
175 Standard_Integer Lower, Upper;
176 Standard_Integer OffSet;
178 CALL_DEF_LISTPOINTS alpoints;
179 CALL_DEF_LISTEDGES aledges;
180 CALL_DEF_EDGE *edges;
182 // Permettra une generalisation plus facile a une methode du style
183 // PolygonSet (ListVertex, ListEdge, Bounds).
185 CALL_DEF_LISTINTEGERS albounds;
187 theTimer.Reset();theTimer.Start();
189 i = ListVertex.Length ();
190 j = ListEdge.Length ();
193 Lower = ListVertex.Lower ();
194 Upper = ListVertex.Upper ();
197 // Allocation dynamique
198 edges = new CALL_DEF_EDGE [j];
199 integers= new int [k];
202 alpoints.NbPoints = int (i);
204 alpoints.NbPoints = i;
206 alpoints.TypePoints = 1;
207 alpoints.UPoints.Points = (CALL_DEF_POINT *) &ListVertex (Lower);
210 aledges.NbEdges = int (j);
214 aledges.Edges = edges;
217 albounds.NbIntegers = int (k);
219 albounds.NbIntegers = k;
221 albounds.Integers = integers;
223 Lower = ListEdge.Lower ();
224 Upper = ListEdge.Upper ();
226 // Parcours des aretes
227 for (j=0, i=Lower; i<=Upper; i++, j++) {
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 ());
233 edges[j].Index1 = ListEdge (i).FirstIndex ()-OffSet;
234 edges[j].Index2 = ListEdge (i).LastIndex ()-OffSet;
235 edges[j].Type = ListEdge (i).Type ();
239 // Parcours des limites (ici toutes les limites sont egales a 3.
240 for (j=0; j<albounds.NbIntegers; j++) integers[j] = 3;
243 PrintFunction ("call_togl_polygon_indices");
244 PrintCGroup (MyCGroup, 1);
249 theTimer.Show(seconds, minutes, hours, CPUtime);
251 cout<<"opengl_driver general stuff in : sec: "<<seconds<< "; min: " << minutes <<endl;
254 theTimer.Reset();theTimer.Start();
255 call_togl_polygon_indices (&MyCGroup, &alpoints, &aledges, &albounds);
257 theTimer.Show(seconds, minutes, hours, CPUtime);
259 cout<<"call_togl_polygon_indices in : sec: "<<seconds<< "; min: " << minutes <<endl;
261 // Desallocation dynamique
267 void OpenGl_GraphicDriver::TriangleSet (const Graphic3d_CGroup& ACGroup,
268 const Graphic3d_Array1OfVertexN& ListVertex,
269 const Aspect_Array1OfEdge& ListEdge,
270 const Standard_Boolean )
273 Graphic3d_CGroup MyCGroup = ACGroup;
275 Standard_Real X, Y, Z;
276 Standard_Real DX, DY, DZ;
278 Standard_Integer i, j, k;
279 Standard_Integer Lower, Upper;
280 Standard_Integer OffSet;
282 CALL_DEF_LISTPOINTS alpoints;
283 CALL_DEF_POINTN *points;
284 CALL_DEF_LISTEDGES aledges;
285 CALL_DEF_EDGE *edges;
287 // Permettra une generalisation plus facile a une methode du style
288 // PolygonSet (ListVertex, ListEdge, Bounds).
290 CALL_DEF_LISTINTEGERS albounds;
292 i = ListVertex.Length ();
293 j = ListEdge.Length ();
296 Lower = ListVertex.Lower ();
297 Upper = ListVertex.Upper ();
300 // Allocation dynamique
301 points = new CALL_DEF_POINTN [i];
302 edges = new CALL_DEF_EDGE [j];
303 integers= new int [k];
305 alpoints.NbPoints = int (i);
306 alpoints.TypePoints = 2;
307 alpoints.UPoints.PointsN= points;
309 aledges.NbEdges = int (j);
310 aledges.Edges = edges;
312 albounds.NbIntegers = int (k);
313 albounds.Integers = integers;
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);
327 Lower = ListEdge.Lower ();
328 Upper = ListEdge.Upper ();
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 ());
337 // Parcours des limites (ici toutes les limites sont egales a 3.
338 for (j=0; j<albounds.NbIntegers; j++) integers[j] = 3;
341 PrintFunction ("call_togl_polygon_indices");
342 PrintCGroup (MyCGroup, 1);
344 call_togl_polygon_indices (&MyCGroup, &alpoints, &aledges, &albounds);
346 // Desallocation dynamique
353 void OpenGl_GraphicDriver::TriangleSet (const Graphic3d_CGroup& ACGroup,
354 const Graphic3d_Array1OfVertexC& ListVertex,
355 const Aspect_Array1OfEdge& ListEdge,
356 const Standard_Boolean )
359 Graphic3d_CGroup MyCGroup = ACGroup;
361 Standard_Real X, Y, Z;
362 Standard_Real R, G, B;
364 Standard_Integer i, j, k;
365 Standard_Integer Lower, Upper;
366 Standard_Integer OffSet;
368 CALL_DEF_LISTPOINTS alpoints;
369 CALL_DEF_POINTC *points;
370 CALL_DEF_LISTEDGES aledges;
371 CALL_DEF_EDGE *edges;
373 // Permettra une generalisation plus facile a une methode du style
374 // PolygonSet (ListVertex, ListEdge, Bounds).
376 CALL_DEF_LISTINTEGERS albounds;
378 i = ListVertex.Length ();
379 j = ListEdge.Length ();
382 Lower = ListVertex.Lower ();
383 Upper = ListVertex.Upper ();
386 // Allocation dynamique
387 points = new CALL_DEF_POINTC [i];
388 edges = new CALL_DEF_EDGE [j];
389 integers= new int [k];
391 alpoints.NbPoints = int (i);
392 alpoints.TypePoints = 3;
393 alpoints.UPoints.PointsC= points;
395 aledges.NbEdges = int (j);
396 aledges.Edges = edges;
398 albounds.NbIntegers = int (k);
399 albounds.Integers = integers;
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);
413 Lower = ListEdge.Lower ();
414 Upper = ListEdge.Upper ();
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 ());
423 // Parcours des limites (ici toutes les limites sont egales a 3.
424 for (j=0; j<albounds.NbIntegers; j++) integers[j] = 3;
427 PrintFunction ("call_togl_polygon_indices");
428 PrintCGroup (MyCGroup, 1);
430 call_togl_polygon_indices (&MyCGroup, &alpoints, &aledges, &albounds);
432 // Desallocation dynamique
439 void OpenGl_GraphicDriver::TriangleSet (const Graphic3d_CGroup& ACGroup,
440 const Graphic3d_Array1OfVertexNC& ListVertex,
441 const Aspect_Array1OfEdge& ListEdge,
442 const Standard_Boolean )
444 Graphic3d_CGroup MyCGroup = ACGroup;
446 Standard_Real X, Y, Z;
447 Standard_Real R, G, B;
448 Standard_Real DX, DY, DZ;
450 Standard_Integer i, j, k;
451 Standard_Integer Lower, Upper;
452 Standard_Integer OffSet;
454 CALL_DEF_LISTPOINTS alpoints;
455 CALL_DEF_POINTNC *points;
456 CALL_DEF_LISTEDGES aledges;
457 CALL_DEF_EDGE *edges;
459 // Permettra une generalisation plus facile a une methode du style
460 // PolygonSet (ListVertex, ListEdge, Bounds).
462 CALL_DEF_LISTINTEGERS albounds;
464 i = ListVertex.Length ();
465 j = ListEdge.Length ();
468 Lower = ListVertex.Lower ();
469 Upper = ListVertex.Upper ();
472 // Allocation dynamique
473 points = new CALL_DEF_POINTNC [i];
474 edges = new CALL_DEF_EDGE [j];
475 integers= new int [k];
477 alpoints.NbPoints = int (i);
478 alpoints.TypePoints = 4;
479 alpoints.UPoints.PointsNC= points;
481 aledges.NbEdges = int (j);
482 aledges.Edges = edges;
484 albounds.NbIntegers = int (k);
485 albounds.Integers = integers;
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);
503 Lower = ListEdge.Lower ();
504 Upper = ListEdge.Upper ();
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 ());
513 // Parcours des limites (ici toutes les limites sont egales a 3.
514 for (j=0; j<albounds.NbIntegers; j++) integers[j] = 3;
517 PrintFunction ("call_togl_polygon_indices");
518 PrintCGroup (MyCGroup, 1);
520 call_togl_polygon_indices (&MyCGroup, &alpoints, &aledges, &albounds);
522 // Desallocation dynamique
531 void OpenGl_GraphicDriver::TriangleSet(const Graphic3d_CGroup& ACGroup,
532 const Graphic3d_Array1OfVertexNT& ListVertex,
533 const Aspect_Array1OfEdge& ListEdge,
534 const Standard_Boolean )
537 Graphic3d_CGroup MyCGroup = ACGroup;
538 Standard_Real X, Y, Z;
539 Standard_Real DX, DY, DZ;
541 Standard_Integer i, j, k;
542 Standard_Integer Lower, Upper;
543 Standard_Integer OffSet;
545 CALL_DEF_LISTPOINTS alpoints;
546 CALL_DEF_POINTNT *points;
547 CALL_DEF_LISTEDGES aledges;
548 CALL_DEF_EDGE *edges;
550 // Permettra une generalisation plus facile a une methode du style
551 // PolygonSet (ListVertex, ListEdge, Bounds).
553 CALL_DEF_LISTINTEGERS albounds;
555 i = ListVertex.Length ();
556 j = ListEdge.Length ();
559 Lower = ListVertex.Lower ();
560 Upper = ListVertex.Upper ();
563 // Allocation dynamique
564 points = new CALL_DEF_POINTNT [i];
565 edges = new CALL_DEF_EDGE [j];
566 integers= new int [k];
568 alpoints.NbPoints = int (i);
569 alpoints.TypePoints = 5;
570 alpoints.UPoints.PointsNT= points;
572 aledges.NbEdges = int (j);
573 aledges.Edges = edges;
575 albounds.NbIntegers = int (k);
576 albounds.Integers = integers;
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);
593 Lower = ListEdge.Lower ();
594 Upper = ListEdge.Upper ();
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 ());
603 // Parcours des limites (ici toutes les limites sont egales a 3.
604 for (j=0; j<albounds.NbIntegers; j++) integers[j] = 3;
607 PrintFunction ("call_togl_polygon_indices");
608 PrintCGroup (MyCGroup, 1);
610 call_togl_polygon_indices (&MyCGroup, &alpoints, &aledges, &albounds);
612 // Desallocation dynamique