0022149: Strings with Japanese characters can not be displayed in 3D viewer
[occt.git] / src / OpenGl / OpenGl_GraphicDriver_709.cxx
1
2 // File   OpenGl_GraphicDriver_709.cxx
3 // Created  Mardi 28 janvier 1997
4 // Author CAL
5 // Modified
6 //              27/08/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
35 void OpenGl_GraphicDriver::QuadrangleMesh (const Graphic3d_CGroup& ACGroup,
36                                            const Graphic3d_Array2OfVertex& ListVertex,
37                                            const Standard_Boolean ) 
38 {
39
40   Graphic3d_CGroup MyCGroup = ACGroup;
41
42   Standard_Real X, Y, Z;
43
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 ();
49
50   CALL_DEF_QUAD aquad;
51   CALL_DEF_POINT *points;
52
53   i = ListVertex.RowLength ();
54   j = ListVertex.ColLength ();
55
56   // Allocation dynamique
57   points  = new CALL_DEF_POINT [i*j];
58
59   aquad.NbPoints    = int (i*j);
60   aquad.TypePoints  = 1;
61   aquad.SizeRow   = int (i);
62   aquad.SizeCol   = int (j);
63   aquad.UPoints.Points  = points;
64
65   // Parcours des sommets
66   k = 0;
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);
73       k++;
74     }
75
76     if (MyTraceLevel) {
77       PrintFunction ("call_togl_quadrangle");
78       PrintCGroup (MyCGroup, 1);
79     }
80     call_togl_quadrangle (&MyCGroup, &aquad);
81
82     // Desallocation dynamique
83     delete [] points;
84
85 }
86
87 void OpenGl_GraphicDriver::QuadrangleMesh (const Graphic3d_CGroup& ACGroup,
88                                            const Graphic3d_Array2OfVertexN& ListVertex,
89                                            const Standard_Boolean ) 
90 {
91
92   Graphic3d_CGroup MyCGroup = ACGroup;
93
94   Standard_Real X, Y, Z;
95   Standard_Real DX, DY, DZ;
96
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 ();
102
103   CALL_DEF_QUAD aquad;
104   CALL_DEF_POINTN *points;
105
106   i = ListVertex.RowLength ();
107   j = ListVertex.ColLength ();
108
109   // Allocation dynamique
110   points  = new CALL_DEF_POINTN [i*j];
111
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;
117
118   // Parcours des sommets
119   k = 0;
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);
130       k++;
131     }
132
133     if (MyTraceLevel) {
134       PrintFunction ("call_togl_quadrangle");
135       PrintCGroup (MyCGroup, 1);
136     }
137     call_togl_quadrangle (&MyCGroup, &aquad);
138
139     // Desallocation dynamique
140     delete [] points;
141
142 }
143
144
145 void OpenGl_GraphicDriver::QuadrangleMesh(const Graphic3d_CGroup& ACGroup,
146                                           const Graphic3d_Array2OfVertexNT& ListVertex,
147                                           const Standard_Boolean ) 
148 {
149
150   Graphic3d_CGroup MyCGroup = ACGroup;
151
152   Standard_Real X, Y, Z;
153   Standard_Real DX, DY, DZ;
154
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 ();
160
161   CALL_DEF_QUAD aquad;
162   CALL_DEF_POINTNT *points;
163
164   i = ListVertex.RowLength ();
165   j = ListVertex.ColLength ();
166
167   // Allocation dynamique
168   points  = new CALL_DEF_POINTNT [i*j];
169
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;
175
176   // Parcours des sommets
177   k = 0;
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);
191       k++;
192     }
193
194     if (MyTraceLevel) {
195       PrintFunction ("call_togl_quadrangle");
196       PrintCGroup (MyCGroup, 1);
197     }
198     call_togl_quadrangle (&MyCGroup, &aquad);
199
200     // Desallocation dynamique
201     delete [] points;
202
203 }
204
205
206 void OpenGl_GraphicDriver::QuadrangleSet (const Graphic3d_CGroup& ACGroup,
207                                           const Graphic3d_Array1OfVertex& ListVertex,
208                                           const Aspect_Array1OfEdge& ListEdge,
209                                           const Standard_Boolean ) 
210 {
211
212   Graphic3d_CGroup MyCGroup = ACGroup;
213
214   Standard_Integer i, j, k;
215   Standard_Integer Lower, Upper;
216   Standard_Integer OffSet;
217
218   CALL_DEF_LISTPOINTS alpoints;
219   CALL_DEF_LISTEDGES aledges;
220   CALL_DEF_EDGE *edges;
221
222   // Permettra une generalisation plus facile a une methode du style
223   // PolygonSet (ListVertex, ListEdge, Bounds).
224   int *integers;
225   CALL_DEF_LISTINTEGERS albounds;
226
227   i = ListVertex.Length ();
228   j = ListEdge.Length ();
229   k = int (j/4);
230
231   Lower = ListVertex.Lower ();
232   Upper = ListVertex.Upper ();
233   OffSet  = Lower;
234
235   // Allocation dynamique
236   edges = new CALL_DEF_EDGE [j];
237   integers= new int [k];
238
239   alpoints.NbPoints = int (i);
240   alpoints.TypePoints = 1;
241   alpoints.UPoints.Points = (CALL_DEF_POINT *) &ListVertex (Lower);
242
243   aledges.NbEdges   = int (j);
244   aledges.Edges   = edges;
245
246   albounds.NbIntegers = int (k);
247   albounds.Integers = integers;
248
249   Lower = ListEdge.Lower ();
250   Upper = ListEdge.Upper ();
251
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 ());
257   }
258
259   // Parcours des limites (ici toutes les limites sont egales a 4.
260   for (j=0; j<albounds.NbIntegers; j++) integers[j] = 4;
261
262   if (MyTraceLevel) {
263     PrintFunction ("call_togl_polygon_indices");
264     PrintCGroup (MyCGroup, 1);
265   }
266   call_togl_polygon_indices (&MyCGroup, &alpoints, &aledges, &albounds);
267
268   // Desallocation dynamique
269   delete [] edges;
270   delete [] integers;
271
272 }
273
274 void OpenGl_GraphicDriver::QuadrangleSet (const Graphic3d_CGroup& ACGroup,
275                                           const Graphic3d_Array1OfVertexN& ListVertex,
276                                           const Aspect_Array1OfEdge& ListEdge,
277                                           const Standard_Boolean ) 
278 {
279
280   Graphic3d_CGroup MyCGroup = ACGroup;
281
282   Standard_Real X, Y, Z;
283   Standard_Real DX, DY, DZ;
284
285   Standard_Integer i, j, k;
286   Standard_Integer Lower, Upper;
287   Standard_Integer OffSet;
288
289   CALL_DEF_LISTPOINTS alpoints;
290   CALL_DEF_POINTN *points;
291   CALL_DEF_LISTEDGES aledges;
292   CALL_DEF_EDGE *edges;
293
294   // Permettra une generalisation plus facile a une methode du style
295   // PolygonSet (ListVertex, ListEdge, Bounds).
296   int *integers;
297   CALL_DEF_LISTINTEGERS albounds;
298
299   i = ListVertex.Length ();
300   j = ListEdge.Length ();
301   k = int (j/4);
302
303   Lower = ListVertex.Lower ();
304   Upper = ListVertex.Upper ();
305   OffSet  = Lower;
306
307   // Allocation dynamique
308   points  = new CALL_DEF_POINTN [i];
309   edges = new CALL_DEF_EDGE [j];
310   integers= new int [k];
311
312   alpoints.NbPoints = int (i);
313   alpoints.TypePoints = 2;
314   alpoints.UPoints.PointsN= points;
315
316   aledges.NbEdges   = int (j);
317   aledges.Edges   = edges;
318
319   albounds.NbIntegers = int (k);
320   albounds.Integers = integers;
321
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);
332   }
333
334   Lower = ListEdge.Lower ();
335   Upper = ListEdge.Upper ();
336
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 ());
342   }
343
344   // Parcours des limites (ici toutes les limites sont egales a 4.
345   for (j=0; j<albounds.NbIntegers; j++) integers[j] = 4;
346
347   if (MyTraceLevel) {
348     PrintFunction ("call_togl_polygon_indices");
349     PrintCGroup (MyCGroup, 1);
350   }
351   call_togl_polygon_indices (&MyCGroup, &alpoints, &aledges, &albounds);
352
353   // Desallocation dynamique
354   delete [] points;
355   delete [] edges;
356   delete [] integers;
357
358 }
359
360 void OpenGl_GraphicDriver::QuadrangleSet (const Graphic3d_CGroup& ACGroup,
361                                           const Graphic3d_Array1OfVertexC& ListVertex,
362                                           const Aspect_Array1OfEdge& ListEdge,
363                                           const Standard_Boolean ) 
364 {
365
366   Graphic3d_CGroup MyCGroup = ACGroup;
367
368   Standard_Real X, Y, Z;
369   Standard_Real R, G, B;
370
371   Standard_Integer i, j, k;
372   Standard_Integer Lower, Upper;
373   Standard_Integer OffSet;
374
375   CALL_DEF_LISTPOINTS alpoints;
376   CALL_DEF_POINTC *points;
377   CALL_DEF_LISTEDGES aledges;
378   CALL_DEF_EDGE *edges;
379
380   // Permettra une generalisation plus facile a une methode du style
381   // PolygonSet (ListVertex, ListEdge, Bounds).
382   int *integers;
383   CALL_DEF_LISTINTEGERS albounds;
384
385   i = ListVertex.Length ();
386   j = ListEdge.Length ();
387   k = int (j/4);
388
389   Lower = ListVertex.Lower ();
390   Upper = ListVertex.Upper ();
391   OffSet  = Lower;
392
393   // Allocation dynamique
394   points  = new CALL_DEF_POINTC [i];
395   edges = new CALL_DEF_EDGE [j];
396   integers= new int [k];
397
398   alpoints.NbPoints = int (i);
399   alpoints.TypePoints = 3;
400   alpoints.UPoints.PointsC= points;
401
402   aledges.NbEdges   = int (j);
403   aledges.Edges   = edges;
404
405   albounds.NbIntegers = int (k);
406   albounds.Integers = integers;
407
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);
418   }
419
420   Lower = ListEdge.Lower ();
421   Upper = ListEdge.Upper ();
422
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 ());
428   }
429
430   // Parcours des limites (ici toutes les limites sont egales a 4.
431   for (j=0; j<albounds.NbIntegers; j++) integers[j] = 4;
432
433   if (MyTraceLevel) {
434     PrintFunction ("call_togl_polygon_indices");
435     PrintCGroup (MyCGroup, 1);
436   }
437   call_togl_polygon_indices (&MyCGroup, &alpoints, &aledges, &albounds);
438
439   // Desallocation dynamique
440   delete [] points;
441   delete [] edges;
442   delete [] integers;
443
444 }
445
446 void OpenGl_GraphicDriver::QuadrangleSet (const Graphic3d_CGroup& ACGroup,
447                                           const Graphic3d_Array1OfVertexNC& ListVertex,
448                                           const Aspect_Array1OfEdge& ListEdge,
449                                           const Standard_Boolean ) 
450 {
451
452   Graphic3d_CGroup MyCGroup = ACGroup;
453
454   Standard_Real X, Y, Z;
455   Standard_Real R, G, B;
456   Standard_Real DX, DY, DZ;
457
458   Standard_Integer i, j, k;
459   Standard_Integer Lower, Upper;
460   Standard_Integer OffSet;
461
462   CALL_DEF_LISTPOINTS alpoints;
463   CALL_DEF_POINTNC *points;
464   CALL_DEF_LISTEDGES aledges;
465   CALL_DEF_EDGE *edges;
466
467   // Permettra une generalisation plus facile a une methode du style
468   // PolygonSet (ListVertex, ListEdge, Bounds).
469   int *integers;
470   CALL_DEF_LISTINTEGERS albounds;
471
472   i = ListVertex.Length ();
473   j = ListEdge.Length ();
474   k = int (j/4);
475
476   Lower = ListVertex.Lower ();
477   Upper = ListVertex.Upper ();
478   OffSet  = Lower;
479
480   // Allocation dynamique
481   points  = new CALL_DEF_POINTNC [i];
482   edges = new CALL_DEF_EDGE [j];
483   integers= new int [k];
484
485   alpoints.NbPoints = int (i);
486   alpoints.TypePoints = 4;
487   alpoints.UPoints.PointsNC= points;
488
489   aledges.NbEdges   = int (j);
490   aledges.Edges   = edges;
491
492   albounds.NbIntegers = int (k);
493   albounds.Integers = integers;
494
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);
509   }
510
511   Lower = ListEdge.Lower ();
512   Upper = ListEdge.Upper ();
513
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 ());
519   }
520
521   // Parcours des limites (ici toutes les limites sont egales a 4.
522   for (j=0; j<albounds.NbIntegers; j++) integers[j] = 4;
523
524   if (MyTraceLevel) {
525     PrintFunction ("call_togl_polygon_indices");
526     PrintCGroup (MyCGroup, 1);
527   }
528   call_togl_polygon_indices (&MyCGroup, &alpoints, &aledges, &albounds);
529
530   // Desallocation dynamique
531   delete [] points;
532   delete [] edges;
533   delete [] integers;
534
535 }
536
537
538
539 void OpenGl_GraphicDriver::QuadrangleSet(const Graphic3d_CGroup& ACGroup,
540                                          const Graphic3d_Array1OfVertexNT& ListVertex,
541                                          const Aspect_Array1OfEdge& ListEdge,
542                                          const Standard_Boolean ) 
543 {
544
545   Graphic3d_CGroup MyCGroup = ACGroup;
546
547
548   Standard_Real X, Y, Z;
549   Standard_Real DX, DY, DZ;
550
551   Standard_Integer i, j, k;
552   Standard_Integer Lower, Upper;
553   Standard_Integer OffSet;
554
555   CALL_DEF_LISTPOINTS alpoints;
556   CALL_DEF_POINTNT *points;
557   CALL_DEF_LISTEDGES aledges;
558   CALL_DEF_EDGE *edges;
559
560   // Permettra une generalisation plus facile a une methode du style
561   // PolygonSet (ListVertex, ListEdge, Bounds).
562   int *integers;
563   CALL_DEF_LISTINTEGERS albounds;
564
565   i = ListVertex.Length ();
566   j = ListEdge.Length ();
567   k = int (j/4);
568
569   Lower = ListVertex.Lower ();
570   Upper = ListVertex.Upper ();
571   OffSet  = Lower;
572
573   // Allocation dynamique
574   points  = new CALL_DEF_POINTNT [i];
575   edges = new CALL_DEF_EDGE [j];
576   integers= new int [k];
577
578   alpoints.NbPoints = int (i);
579   alpoints.TypePoints = 5;
580   alpoints.UPoints.PointsNT= points;
581
582   aledges.NbEdges   = int (j);
583   aledges.Edges   = edges;
584
585   albounds.NbIntegers = int (k);
586   albounds.Integers = integers;
587
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);
601   }
602
603   Lower = ListEdge.Lower ();
604   Upper = ListEdge.Upper ();
605
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 ());
611   }
612
613   // Parcours des limites (ici toutes les limites sont egales a 4.
614   for (j=0; j<albounds.NbIntegers; j++) integers[j] = 4;
615
616   if (MyTraceLevel) {
617     PrintFunction ("call_togl_polygon_indices");
618     PrintCGroup (MyCGroup, 1);
619   }
620   call_togl_polygon_indices (&MyCGroup, &alpoints, &aledges, &albounds);
621
622   // Desallocation dynamique
623   delete [] points;
624   delete [] edges;
625   delete [] integers;
626
627 }