2 // File OpenGl_GraphicDriver_705.cxx
3 // Created Mardi 28 janvier 1997
6 // 27/07/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::Polygon (const Graphic3d_CGroup& ACGroup,
36 const Graphic3d_Array1OfVertex& ListVertex,
37 const Graphic3d_TypeOfPolygon AType,
38 const Standard_Boolean )
40 Graphic3d_CGroup MyCGroup = ACGroup;
43 Standard_Integer Lower = ListVertex.Lower ();
45 CALL_DEF_FACET afacet;
47 i = ListVertex.Length ();
49 afacet.TypeFacet = int (AType);
51 afacet.NormalIsDefined = 0;
52 afacet.ColorIsDefined = 0;
54 afacet.NbPoints = int (i);
55 afacet.TypePoints = 1;
56 afacet.UPoints.Points = (CALL_DEF_POINT *) &ListVertex (Lower);
59 PrintFunction ("call_togl_polygon");
60 PrintCGroup (MyCGroup, 1);
62 call_togl_polygon (&MyCGroup, &afacet);
66 void 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 )
72 Graphic3d_CGroup MyCGroup = ACGroup;
75 Standard_Real X, Y, Z;
78 Standard_Integer Lower = ListVertex.Lower ();
80 CALL_DEF_FACET afacet;
82 i = ListVertex.Length ();
84 afacet.TypeFacet = int (AType);
86 afacet.NormalIsDefined = 1;
87 afacet.ColorIsDefined = 0;
89 Normal.Coord (X, Y, Z);
90 afacet.Normal.dx = float (X);
91 afacet.Normal.dy = float (Y);
92 afacet.Normal.dz = float (Z);
94 afacet.NbPoints = int (i);
95 afacet.TypePoints = 1;
96 afacet.UPoints.Points = (CALL_DEF_POINT *) &ListVertex (Lower);
99 PrintFunction ("call_togl_polygon");
100 PrintCGroup (MyCGroup, 1);
102 call_togl_polygon (&MyCGroup, &afacet);
106 void OpenGl_GraphicDriver::Polygon (const Graphic3d_CGroup& ACGroup,
107 const Graphic3d_Array1OfVertexN& ListVertex,
108 const Graphic3d_TypeOfPolygon AType,
109 const Standard_Boolean )
112 Graphic3d_CGroup MyCGroup = ACGroup;
114 Standard_Real X, Y, Z;
115 Standard_Real DX, DY, DZ;
117 Standard_Integer i, j;
118 Standard_Integer Lower = ListVertex.Lower ();
119 Standard_Integer Upper = ListVertex.Upper ();
121 CALL_DEF_FACET afacet;
122 CALL_DEF_POINTN *points;
124 i = ListVertex.Length ();
126 // Allocation dynamique
127 points = new CALL_DEF_POINTN [i];
129 afacet.TypeFacet = int (AType);
131 afacet.NormalIsDefined = 0;
132 afacet.ColorIsDefined = 0;
134 afacet.NbPoints = int (i);
135 afacet.TypePoints = 2;
136 afacet.UPoints.PointsN = points;
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);
151 PrintFunction ("call_togl_polygon");
152 PrintCGroup (MyCGroup, 1);
154 call_togl_polygon (&MyCGroup, &afacet);
156 // Desallocation dynamique
161 void 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 )
167 Graphic3d_CGroup MyCGroup = ACGroup;
170 Standard_Real X, Y, Z;
171 Standard_Real DX, DY, DZ;
173 Standard_Integer i, j;
174 Standard_Integer Lower = ListVertex.Lower ();
175 Standard_Integer Upper = ListVertex.Upper ();
177 CALL_DEF_FACET afacet;
178 CALL_DEF_POINTN *points;
180 i = ListVertex.Length ();
182 // Allocation dynamique
183 points = new CALL_DEF_POINTN [i];
185 afacet.TypeFacet = int (AType);
187 afacet.NormalIsDefined = 1;
188 afacet.ColorIsDefined = 0;
190 Normal.Coord (DX, DY, DZ);
191 afacet.Normal.dx = float (DX);
192 afacet.Normal.dy = float (DY);
193 afacet.Normal.dz = float (DZ);
195 afacet.NbPoints = int (i);
196 afacet.TypePoints = 2;
197 afacet.UPoints.PointsN = points;
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);
212 PrintFunction ("call_togl_polygon");
213 PrintCGroup (MyCGroup, 1);
215 call_togl_polygon (&MyCGroup, &afacet);
217 // Desallocation dynamique
223 void OpenGl_GraphicDriver::Polygon(const Graphic3d_CGroup& ACGroup,
224 const Graphic3d_Array1OfVertexNT& ListVertex,
225 const Graphic3d_TypeOfPolygon AType,
226 const Standard_Boolean )
229 Graphic3d_CGroup MyCGroup = ACGroup;
232 Standard_Real X, Y, Z;
233 Standard_Real DX, DY, DZ;
234 Standard_Real TX, TY;
236 Standard_Integer i, j;
237 Standard_Integer Lower = ListVertex.Lower ();
238 Standard_Integer Upper = ListVertex.Upper ();
240 CALL_DEF_FACET afacet;
241 CALL_DEF_POINTNT *points;
243 i = ListVertex.Length ();
245 // Allocation dynamique
246 points = new CALL_DEF_POINTNT [i];
248 afacet.TypeFacet = int (AType);
250 afacet.NormalIsDefined = 0;
251 afacet.ColorIsDefined = 0;
253 afacet.NbPoints = int (i);
254 afacet.TypePoints = 5;
255 afacet.UPoints.PointsNT = points;
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);
273 PrintFunction ("call_togl_polygon");
274 PrintCGroup (MyCGroup, 1);
276 call_togl_polygon (&MyCGroup, &afacet);
278 // Desallocation dynamique
284 void OpenGl_GraphicDriver::PolygonHoles (const Graphic3d_CGroup& ACGroup,
285 const TColStd_Array1OfInteger& Bounds,
286 const Graphic3d_Array1OfVertex& ListVertex,
287 const Standard_Boolean )
290 Graphic3d_CGroup MyCGroup = ACGroup;
292 Standard_Real X, Y, Z;
294 Standard_Integer i, ii;
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;
302 CALL_DEF_LISTFACETS alfacets;
303 CALL_DEF_FACET *facets;
304 CALL_DEF_POINT *points;
306 i = ListVertex.Length ();
307 j = Bounds.Length ();
309 // Allocation dynamique
310 points = new CALL_DEF_POINT [i];
311 facets = new CALL_DEF_FACET [j];
313 alfacets.NbFacets = int (j);
314 alfacets.LFacets = facets;
316 begin_points = ListVertex.Lower ();
317 end_points = ListVertex.Upper ();
319 Lower = Bounds.Lower ();
320 Upper = Bounds.Upper ();
324 // Parcours des facettes
325 for (k=0, kk=Lower; kk<=Upper; k++, kk++) {
326 facets[k].TypeFacet = 0; /* TOP_UNKNOWN */
328 facets[k].NormalIsDefined = 0;
329 facets[k].ColorIsDefined = 0;
331 facets[k].NbPoints = int (Bounds.Value (kk));
332 facets[k].TypePoints = 1;
333 facets[k].UPoints.Points = (points + nb_points);
335 // Parcours des sommets
336 for (i=0, ii=begin_points;
337 ((ii<=end_points) || (i==facets[k].NbPoints-1));
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);
344 begin_points += facets[k].NbPoints;
345 nb_points += facets[k].NbPoints;
349 PrintFunction ("call_togl_polygon_holes");
350 PrintCGroup (MyCGroup, 1);
352 call_togl_polygon_holes (&MyCGroup, &alfacets);
354 // Desallocation dynamique
360 void 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 )
367 Graphic3d_CGroup MyCGroup = ACGroup;
369 Standard_Real X, Y, Z;
370 Standard_Real NX, NY, NZ;
372 Standard_Integer i, ii;
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;
380 CALL_DEF_LISTFACETS alfacets;
381 CALL_DEF_FACET *facets;
382 CALL_DEF_POINT *points;
384 i = ListVertex.Length ();
385 j = Bounds.Length ();
387 // Allocation dynamique
388 points = new CALL_DEF_POINT [i];
389 facets = new CALL_DEF_FACET [j];
391 alfacets.NbFacets = int (j);
392 alfacets.LFacets = facets;
394 begin_points = ListVertex.Lower ();
395 end_points = ListVertex.Upper ();
397 Lower = Bounds.Lower ();
398 Upper = Bounds.Upper ();
402 Normal.Coord (NX, NY, NZ);
404 // Parcours des facettes
405 for (k=0, kk=Lower; kk<=Upper; k++, kk++) {
406 facets[k].TypeFacet = 0; /* TOP_UNKNOWN */
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);
414 facets[k].NbPoints = int (Bounds.Value (kk));
415 facets[k].TypePoints = 1;
416 facets[k].UPoints.Points = (points + nb_points);
418 // Parcours des sommets
419 for (i=0, ii=begin_points;
420 ((ii<=end_points) || (i==facets[k].NbPoints-1));
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);
427 begin_points += facets[k].NbPoints;
428 nb_points += facets[k].NbPoints;
432 PrintFunction ("call_togl_polygon_holes");
433 PrintCGroup (MyCGroup, 1);
435 call_togl_polygon_holes (&MyCGroup, &alfacets);
437 // Desallocation dynamique
443 void OpenGl_GraphicDriver::PolygonHoles (const Graphic3d_CGroup& ACGroup,
444 const TColStd_Array1OfInteger& Bounds,
445 const Graphic3d_Array1OfVertexN& ListVertex,
446 const Standard_Boolean )
449 Graphic3d_CGroup MyCGroup = ACGroup;
451 Standard_Real X, Y, Z;
452 Standard_Real DX, DY, DZ;
454 Standard_Integer i, ii;
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;
462 CALL_DEF_LISTFACETS alfacets;
463 CALL_DEF_FACET *facets;
464 CALL_DEF_POINTN *points;
466 i = ListVertex.Length ();
467 j = Bounds.Length ();
469 // Allocation dynamique
470 points = new CALL_DEF_POINTN [i];
471 facets = new CALL_DEF_FACET [j];
473 alfacets.NbFacets = int (j);
474 alfacets.LFacets = facets;
476 begin_points = ListVertex.Lower ();
477 end_points = ListVertex.Upper ();
479 Lower = Bounds.Lower ();
480 Upper = Bounds.Upper ();
484 // Parcours des facettes
485 for (k=0, kk=Lower; kk<=Upper; k++, kk++) {
486 facets[k].TypeFacet = 0; /* TOP_UNKNOWN */
488 facets[k].NormalIsDefined = 0;
489 facets[k].ColorIsDefined = 0;
491 facets[k].NbPoints = int (Bounds.Value (kk));
492 facets[k].TypePoints = 2;
493 facets[k].UPoints.PointsN = (points + nb_points);
495 // Parcours des sommets
496 for (i=0, ii=begin_points;
497 ((ii<=end_points) || (i==facets[k].NbPoints-1));
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);
508 begin_points += facets[k].NbPoints;
509 nb_points += facets[k].NbPoints;
513 PrintFunction ("call_togl_polygon_holes");
514 PrintCGroup (MyCGroup, 1);
516 call_togl_polygon_holes (&MyCGroup, &alfacets);
518 // Desallocation dynamique
524 void 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 )
531 Graphic3d_CGroup MyCGroup = ACGroup;
533 Standard_Real X, Y, Z;
534 Standard_Real DX, DY, DZ;
535 Standard_Real NX, NY, NZ;
537 Standard_Integer i, ii;
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;
545 CALL_DEF_LISTFACETS alfacets;
546 CALL_DEF_FACET *facets;
547 CALL_DEF_POINTN *points;
549 i = ListVertex.Length ();
550 j = Bounds.Length ();
552 // Allocation dynamique
553 points = new CALL_DEF_POINTN [i];
554 facets = new CALL_DEF_FACET [j];
556 alfacets.NbFacets = int (j);
557 alfacets.LFacets = facets;
559 begin_points = ListVertex.Lower ();
560 end_points = ListVertex.Upper ();
562 Lower = Bounds.Lower ();
563 Upper = Bounds.Upper ();
567 Normal.Coord (NX, NY, NZ);
569 // Parcours des facettes
570 for (k=0, kk=Lower; kk<=Upper; k++, kk++) {
571 facets[k].TypeFacet = 0; /* TOP_UNKNOWN */
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);
579 facets[k].NbPoints = int (Bounds.Value (kk));
580 facets[k].TypePoints = 2;
581 facets[k].UPoints.PointsN = (points + nb_points);
583 // Parcours des sommets
584 for (i=0, ii=begin_points;
585 ((ii<=end_points) || (i==facets[k].NbPoints-1));
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);
596 begin_points += facets[k].NbPoints;
597 nb_points += facets[k].NbPoints;
601 PrintFunction ("call_togl_polygon_holes");
602 PrintCGroup (MyCGroup, 1);
604 call_togl_polygon_holes (&MyCGroup, &alfacets);
606 // Desallocation dynamique