2 // File OpenGl_GraphicDriver_709.cxx
3 // Created Mardi 28 janvier 1997
6 // 27/08/97 ; PCT : ajout coordonnee 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>
25 #include <Aspect_DriverDefinitionError.hxx>
27 #include <OpenGl_tgl_funcs.hxx>
31 //-Global data definitions
35 void OpenGl_GraphicDriver::QuadrangleMesh (const Graphic3d_CGroup& ACGroup,
36 const Graphic3d_Array2OfVertex& ListVertex,
37 const Standard_Boolean )
40 Graphic3d_CGroup MyCGroup = ACGroup;
42 Standard_Real X, Y, Z;
44 Standard_Integer i, j, k;
45 Standard_Integer LowerRow = ListVertex.LowerRow ();
46 Standard_Integer UpperRow = ListVertex.UpperRow ();
47 Standard_Integer LowerCol = ListVertex.LowerCol ();
48 Standard_Integer UpperCol = ListVertex.UpperCol ();
51 CALL_DEF_POINT *points;
53 i = ListVertex.RowLength ();
54 j = ListVertex.ColLength ();
56 // Allocation dynamique
57 points = new CALL_DEF_POINT [i*j];
59 aquad.NbPoints = int (i*j);
61 aquad.SizeRow = int (i);
62 aquad.SizeCol = int (j);
63 aquad.UPoints.Points = points;
65 // Parcours des sommets
67 for (i=LowerRow; i<=UpperRow; i++)
68 for (j=LowerCol; j<=UpperCol; j++) {
69 ListVertex (i, j).Coord (X, Y, Z);
70 points[k].x = float (X);
71 points[k].y = float (Y);
72 points[k].z = float (Z);
77 PrintFunction ("call_togl_quadrangle");
78 PrintCGroup (MyCGroup, 1);
80 call_togl_quadrangle (&MyCGroup, &aquad);
82 // Desallocation dynamique
87 void OpenGl_GraphicDriver::QuadrangleMesh (const Graphic3d_CGroup& ACGroup,
88 const Graphic3d_Array2OfVertexN& ListVertex,
89 const Standard_Boolean )
92 Graphic3d_CGroup MyCGroup = ACGroup;
94 Standard_Real X, Y, Z;
95 Standard_Real DX, DY, DZ;
97 Standard_Integer i, j, k;
98 Standard_Integer LowerRow = ListVertex.LowerRow ();
99 Standard_Integer UpperRow = ListVertex.UpperRow ();
100 Standard_Integer LowerCol = ListVertex.LowerCol ();
101 Standard_Integer UpperCol = ListVertex.UpperCol ();
104 CALL_DEF_POINTN *points;
106 i = ListVertex.RowLength ();
107 j = ListVertex.ColLength ();
109 // Allocation dynamique
110 points = new CALL_DEF_POINTN [i*j];
112 aquad.NbPoints = int (i*j);
113 aquad.TypePoints = 2;
114 aquad.SizeRow = int (i);
115 aquad.SizeCol = int (j);
116 aquad.UPoints.PointsN = points;
118 // Parcours des sommets
120 for (i=LowerRow; i<=UpperRow; i++)
121 for (j=LowerCol; j<=UpperCol; j++) {
122 ListVertex (i, j).Coord (X, Y, Z);
123 points[k].Point.x = float (X);
124 points[k].Point.y = float (Y);
125 points[k].Point.z = float (Z);
126 ListVertex (i, j).Normal (DX, DY, DZ);
127 points[k].Normal.dx = float (DX);
128 points[k].Normal.dy = float (DY);
129 points[k].Normal.dz = float (DZ);
134 PrintFunction ("call_togl_quadrangle");
135 PrintCGroup (MyCGroup, 1);
137 call_togl_quadrangle (&MyCGroup, &aquad);
139 // Desallocation dynamique
145 void OpenGl_GraphicDriver::QuadrangleMesh(const Graphic3d_CGroup& ACGroup,
146 const Graphic3d_Array2OfVertexNT& ListVertex,
147 const Standard_Boolean )
150 Graphic3d_CGroup MyCGroup = ACGroup;
152 Standard_Real X, Y, Z;
153 Standard_Real DX, DY, DZ;
155 Standard_Integer i, j, k;
156 Standard_Integer LowerRow = ListVertex.LowerRow ();
157 Standard_Integer UpperRow = ListVertex.UpperRow ();
158 Standard_Integer LowerCol = ListVertex.LowerCol ();
159 Standard_Integer UpperCol = ListVertex.UpperCol ();
162 CALL_DEF_POINTNT *points;
164 i = ListVertex.RowLength ();
165 j = ListVertex.ColLength ();
167 // Allocation dynamique
168 points = new CALL_DEF_POINTNT [i*j];
170 aquad.NbPoints = int (i*j);
171 aquad.TypePoints = 5;
172 aquad.SizeRow = int (i);
173 aquad.SizeCol = int (j);
174 aquad.UPoints.PointsNT = points;
176 // Parcours des sommets
178 for (i=LowerRow; i<=UpperRow; i++)
179 for (j=LowerCol; j<=UpperCol; j++) {
180 ListVertex (i, j).Coord (X, Y, Z);
181 points[k].Point.x = float (X);
182 points[k].Point.y = float (Y);
183 points[k].Point.z = float (Z);
184 ListVertex (i, j).Normal (DX, DY, DZ);
185 points[k].Normal.dx = float (DX);
186 points[k].Normal.dy = float (DY);
187 points[k].Normal.dz = float (DZ);
188 ListVertex (i, j).TextureCoordinate(DX,DY);
189 points[k].TextureCoord.tx = float(DX);
190 points[k].TextureCoord.ty = float(DY);
195 PrintFunction ("call_togl_quadrangle");
196 PrintCGroup (MyCGroup, 1);
198 call_togl_quadrangle (&MyCGroup, &aquad);
200 // Desallocation dynamique
206 void OpenGl_GraphicDriver::QuadrangleSet (const Graphic3d_CGroup& ACGroup,
207 const Graphic3d_Array1OfVertex& ListVertex,
208 const Aspect_Array1OfEdge& ListEdge,
209 const Standard_Boolean )
212 Graphic3d_CGroup MyCGroup = ACGroup;
214 Standard_Integer i, j, k;
215 Standard_Integer Lower, Upper;
216 Standard_Integer OffSet;
218 CALL_DEF_LISTPOINTS alpoints;
219 CALL_DEF_LISTEDGES aledges;
220 CALL_DEF_EDGE *edges;
222 // Permettra une generalisation plus facile a une methode du style
223 // PolygonSet (ListVertex, ListEdge, Bounds).
225 CALL_DEF_LISTINTEGERS albounds;
227 i = ListVertex.Length ();
228 j = ListEdge.Length ();
231 Lower = ListVertex.Lower ();
232 Upper = ListVertex.Upper ();
235 // Allocation dynamique
236 edges = new CALL_DEF_EDGE [j];
237 integers= new int [k];
239 alpoints.NbPoints = int (i);
240 alpoints.TypePoints = 1;
241 alpoints.UPoints.Points = (CALL_DEF_POINT *) &ListVertex (Lower);
243 aledges.NbEdges = int (j);
244 aledges.Edges = edges;
246 albounds.NbIntegers = int (k);
247 albounds.Integers = integers;
249 Lower = ListEdge.Lower ();
250 Upper = ListEdge.Upper ();
252 // Parcours des aretes
253 for (j=0, i=Lower; i<=Upper; i++, j++) {
254 edges[j].Index1 = int (ListEdge (i).FirstIndex ()-OffSet);
255 edges[j].Index2 = int (ListEdge (i).LastIndex ()-OffSet);
256 edges[j].Type = int (ListEdge (i).Type ());
259 // Parcours des limites (ici toutes les limites sont egales a 4.
260 for (j=0; j<albounds.NbIntegers; j++) integers[j] = 4;
263 PrintFunction ("call_togl_polygon_indices");
264 PrintCGroup (MyCGroup, 1);
266 call_togl_polygon_indices (&MyCGroup, &alpoints, &aledges, &albounds);
268 // Desallocation dynamique
274 void OpenGl_GraphicDriver::QuadrangleSet (const Graphic3d_CGroup& ACGroup,
275 const Graphic3d_Array1OfVertexN& ListVertex,
276 const Aspect_Array1OfEdge& ListEdge,
277 const Standard_Boolean )
280 Graphic3d_CGroup MyCGroup = ACGroup;
282 Standard_Real X, Y, Z;
283 Standard_Real DX, DY, DZ;
285 Standard_Integer i, j, k;
286 Standard_Integer Lower, Upper;
287 Standard_Integer OffSet;
289 CALL_DEF_LISTPOINTS alpoints;
290 CALL_DEF_POINTN *points;
291 CALL_DEF_LISTEDGES aledges;
292 CALL_DEF_EDGE *edges;
294 // Permettra une generalisation plus facile a une methode du style
295 // PolygonSet (ListVertex, ListEdge, Bounds).
297 CALL_DEF_LISTINTEGERS albounds;
299 i = ListVertex.Length ();
300 j = ListEdge.Length ();
303 Lower = ListVertex.Lower ();
304 Upper = ListVertex.Upper ();
307 // Allocation dynamique
308 points = new CALL_DEF_POINTN [i];
309 edges = new CALL_DEF_EDGE [j];
310 integers= new int [k];
312 alpoints.NbPoints = int (i);
313 alpoints.TypePoints = 2;
314 alpoints.UPoints.PointsN= points;
316 aledges.NbEdges = int (j);
317 aledges.Edges = edges;
319 albounds.NbIntegers = int (k);
320 albounds.Integers = integers;
322 // Parcours des sommets
323 for (j=0, i=Lower; i<=Upper; i++, j++) {
324 ListVertex (i).Coord (X, Y, Z);
325 points[j].Point.x = float (X);
326 points[j].Point.y = float (Y);
327 points[j].Point.z = float (Z);
328 ListVertex (i).Normal (DX, DY, DZ);
329 points[j].Normal.dx = float (DX);
330 points[j].Normal.dy = float (DY);
331 points[j].Normal.dz = float (DZ);
334 Lower = ListEdge.Lower ();
335 Upper = ListEdge.Upper ();
337 // Parcours des aretes
338 for (j=0, i=Lower; i<=Upper; i++, j++) {
339 edges[j].Index1 = int (ListEdge (i).FirstIndex ()-OffSet);
340 edges[j].Index2 = int (ListEdge (i).LastIndex ()-OffSet);
341 edges[j].Type = int (ListEdge (i).Type ());
344 // Parcours des limites (ici toutes les limites sont egales a 4.
345 for (j=0; j<albounds.NbIntegers; j++) integers[j] = 4;
348 PrintFunction ("call_togl_polygon_indices");
349 PrintCGroup (MyCGroup, 1);
351 call_togl_polygon_indices (&MyCGroup, &alpoints, &aledges, &albounds);
353 // Desallocation dynamique
360 void OpenGl_GraphicDriver::QuadrangleSet (const Graphic3d_CGroup& ACGroup,
361 const Graphic3d_Array1OfVertexC& ListVertex,
362 const Aspect_Array1OfEdge& ListEdge,
363 const Standard_Boolean )
366 Graphic3d_CGroup MyCGroup = ACGroup;
368 Standard_Real X, Y, Z;
369 Standard_Real R, G, B;
371 Standard_Integer i, j, k;
372 Standard_Integer Lower, Upper;
373 Standard_Integer OffSet;
375 CALL_DEF_LISTPOINTS alpoints;
376 CALL_DEF_POINTC *points;
377 CALL_DEF_LISTEDGES aledges;
378 CALL_DEF_EDGE *edges;
380 // Permettra une generalisation plus facile a une methode du style
381 // PolygonSet (ListVertex, ListEdge, Bounds).
383 CALL_DEF_LISTINTEGERS albounds;
385 i = ListVertex.Length ();
386 j = ListEdge.Length ();
389 Lower = ListVertex.Lower ();
390 Upper = ListVertex.Upper ();
393 // Allocation dynamique
394 points = new CALL_DEF_POINTC [i];
395 edges = new CALL_DEF_EDGE [j];
396 integers= new int [k];
398 alpoints.NbPoints = int (i);
399 alpoints.TypePoints = 3;
400 alpoints.UPoints.PointsC= points;
402 aledges.NbEdges = int (j);
403 aledges.Edges = edges;
405 albounds.NbIntegers = int (k);
406 albounds.Integers = integers;
408 // Parcours des sommets
409 for (j=0, i=Lower; i<=Upper; i++, j++) {
410 ListVertex (i).Coord (X, Y, Z);
411 points[j].Point.x = float (X);
412 points[j].Point.y = float (Y);
413 points[j].Point.z = float (Z);
414 (ListVertex (i).Color ()).Values (R, G, B, Quantity_TOC_RGB);
415 points[j].Color.r = float (R);
416 points[j].Color.g = float (G);
417 points[j].Color.b = float (B);
420 Lower = ListEdge.Lower ();
421 Upper = ListEdge.Upper ();
423 // Parcours des aretes
424 for (j=0, i=Lower; i<=Upper; i++, j++) {
425 edges[j].Index1 = int (ListEdge (i).FirstIndex ()-OffSet);
426 edges[j].Index2 = int (ListEdge (i).LastIndex ()-OffSet);
427 edges[j].Type = int (ListEdge (i).Type ());
430 // Parcours des limites (ici toutes les limites sont egales a 4.
431 for (j=0; j<albounds.NbIntegers; j++) integers[j] = 4;
434 PrintFunction ("call_togl_polygon_indices");
435 PrintCGroup (MyCGroup, 1);
437 call_togl_polygon_indices (&MyCGroup, &alpoints, &aledges, &albounds);
439 // Desallocation dynamique
446 void OpenGl_GraphicDriver::QuadrangleSet (const Graphic3d_CGroup& ACGroup,
447 const Graphic3d_Array1OfVertexNC& ListVertex,
448 const Aspect_Array1OfEdge& ListEdge,
449 const Standard_Boolean )
452 Graphic3d_CGroup MyCGroup = ACGroup;
454 Standard_Real X, Y, Z;
455 Standard_Real R, G, B;
456 Standard_Real DX, DY, DZ;
458 Standard_Integer i, j, k;
459 Standard_Integer Lower, Upper;
460 Standard_Integer OffSet;
462 CALL_DEF_LISTPOINTS alpoints;
463 CALL_DEF_POINTNC *points;
464 CALL_DEF_LISTEDGES aledges;
465 CALL_DEF_EDGE *edges;
467 // Permettra une generalisation plus facile a une methode du style
468 // PolygonSet (ListVertex, ListEdge, Bounds).
470 CALL_DEF_LISTINTEGERS albounds;
472 i = ListVertex.Length ();
473 j = ListEdge.Length ();
476 Lower = ListVertex.Lower ();
477 Upper = ListVertex.Upper ();
480 // Allocation dynamique
481 points = new CALL_DEF_POINTNC [i];
482 edges = new CALL_DEF_EDGE [j];
483 integers= new int [k];
485 alpoints.NbPoints = int (i);
486 alpoints.TypePoints = 4;
487 alpoints.UPoints.PointsNC= points;
489 aledges.NbEdges = int (j);
490 aledges.Edges = edges;
492 albounds.NbIntegers = int (k);
493 albounds.Integers = integers;
495 // Parcours des sommets
496 for (j=0, i=Lower; i<=Upper; i++, j++) {
497 ListVertex (i).Coord (X, Y, Z);
498 points[j].Point.x = float (X);
499 points[j].Point.y = float (Y);
500 points[j].Point.z = float (Z);
501 ListVertex (i).Normal (DX, DY, DZ);
502 points[j].Normal.dx = float (DX);
503 points[j].Normal.dy = float (DY);
504 points[j].Normal.dz = float (DZ);
505 (ListVertex (i).Color ()).Values (R, G, B, Quantity_TOC_RGB);
506 points[j].Color.r = float (R);
507 points[j].Color.g = float (G);
508 points[j].Color.b = float (B);
511 Lower = ListEdge.Lower ();
512 Upper = ListEdge.Upper ();
514 // Parcours des aretes
515 for (j=0, i=Lower; i<=Upper; i++, j++) {
516 edges[j].Index1 = int (ListEdge (i).FirstIndex ()-OffSet);
517 edges[j].Index2 = int (ListEdge (i).LastIndex ()-OffSet);
518 edges[j].Type = int (ListEdge (i).Type ());
521 // Parcours des limites (ici toutes les limites sont egales a 4.
522 for (j=0; j<albounds.NbIntegers; j++) integers[j] = 4;
525 PrintFunction ("call_togl_polygon_indices");
526 PrintCGroup (MyCGroup, 1);
528 call_togl_polygon_indices (&MyCGroup, &alpoints, &aledges, &albounds);
530 // Desallocation dynamique
539 void OpenGl_GraphicDriver::QuadrangleSet(const Graphic3d_CGroup& ACGroup,
540 const Graphic3d_Array1OfVertexNT& ListVertex,
541 const Aspect_Array1OfEdge& ListEdge,
542 const Standard_Boolean )
545 Graphic3d_CGroup MyCGroup = ACGroup;
548 Standard_Real X, Y, Z;
549 Standard_Real DX, DY, DZ;
551 Standard_Integer i, j, k;
552 Standard_Integer Lower, Upper;
553 Standard_Integer OffSet;
555 CALL_DEF_LISTPOINTS alpoints;
556 CALL_DEF_POINTNT *points;
557 CALL_DEF_LISTEDGES aledges;
558 CALL_DEF_EDGE *edges;
560 // Permettra une generalisation plus facile a une methode du style
561 // PolygonSet (ListVertex, ListEdge, Bounds).
563 CALL_DEF_LISTINTEGERS albounds;
565 i = ListVertex.Length ();
566 j = ListEdge.Length ();
569 Lower = ListVertex.Lower ();
570 Upper = ListVertex.Upper ();
573 // Allocation dynamique
574 points = new CALL_DEF_POINTNT [i];
575 edges = new CALL_DEF_EDGE [j];
576 integers= new int [k];
578 alpoints.NbPoints = int (i);
579 alpoints.TypePoints = 5;
580 alpoints.UPoints.PointsNT= points;
582 aledges.NbEdges = int (j);
583 aledges.Edges = edges;
585 albounds.NbIntegers = int (k);
586 albounds.Integers = integers;
588 // Parcours des sommets
589 for (j=0, i=Lower; i<=Upper; i++, j++) {
590 ListVertex (i).Coord (X, Y, Z);
591 points[j].Point.x = float (X);
592 points[j].Point.y = float (Y);
593 points[j].Point.z = float (Z);
594 ListVertex (i).Normal (DX, DY, DZ);
595 points[j].Normal.dx = float (DX);
596 points[j].Normal.dy = float (DY);
597 points[j].Normal.dz = float (DZ);
598 ListVertex (i).TextureCoordinate(DX,DY);
599 points[j].TextureCoord.tx = float(DX);
600 points[j].TextureCoord.ty = float(DY);
603 Lower = ListEdge.Lower ();
604 Upper = ListEdge.Upper ();
606 // Parcours des aretes
607 for (j=0, i=Lower; i<=Upper; i++, j++) {
608 edges[j].Index1 = int (ListEdge (i).FirstIndex ()-OffSet);
609 edges[j].Index2 = int (ListEdge (i).LastIndex ()-OffSet);
610 edges[j].Type = int (ListEdge (i).Type ());
613 // Parcours des limites (ici toutes les limites sont egales a 4.
614 for (j=0; j<albounds.NbIntegers; j++) integers[j] = 4;
617 PrintFunction ("call_togl_polygon_indices");
618 PrintCGroup (MyCGroup, 1);
620 call_togl_polygon_indices (&MyCGroup, &alpoints, &aledges, &albounds);
622 // Desallocation dynamique