0022337: V3d_View::Print crashes in OCCT 6.5.0
[occt.git] / src / OpenGl / OpenGl_GraphicDriver_5.cxx
1
2
3 // File   OpenGl_GraphicDriver_5.cxx
4 // Created  Mardi 28 janvier 1997
5 // Author CAL
6
7 //-Copyright  MatraDatavision 1997
8
9 //-Version  
10
11 //-Design Declaration des variables specifiques aux Drivers
12
13 //-Warning  Un driver encapsule les Pex et OpenGl drivers
14
15 //-References 
16
17 //-Language C++ 2.0
18
19 //-Declarations
20
21 // for the class
22 #include <OpenGl_GraphicDriver.jxx>
23
24 #include <Aspect_DriverDefinitionError.hxx>
25
26 #include <OpenGl_tgl_funcs.hxx>
27
28 //-Aliases
29
30 //-Global data definitions
31
32 //-Methods, in order
33
34 void OpenGl_GraphicDriver::DumpGroup (const Graphic3d_CGroup& ACGroup) {
35
36   Graphic3d_CGroup MyCGroup = ACGroup;
37
38   if (MyTraceLevel) {
39     PrintFunction ("call_togl_structure_exploration");
40     PrintCGroup (MyCGroup, 1);
41   }
42   call_togl_structure_exploration
43     (long (MyCGroup.Struct->Id), long (MyCGroup.LabelBegin), long (MyCGroup.LabelEnd));
44
45 }
46
47 void OpenGl_GraphicDriver::DumpStructure (const Graphic3d_CStructure& ACStructure) {
48
49   Graphic3d_CStructure MyCStructure = ACStructure;
50
51   if (MyTraceLevel) {
52     PrintFunction ("call_togl_structure_exploration");
53     PrintCStructure (MyCStructure, 1);
54   }
55   call_togl_structure_exploration (long (MyCStructure.Id), 0, 0);
56
57 }
58
59 void OpenGl_GraphicDriver::DumpView (const Graphic3d_CView& ACView) {
60
61   Graphic3d_CView MyCView = ACView;
62
63   if (MyTraceLevel) {
64     PrintFunction ("call_togl_view_exploration");
65     PrintCView (MyCView, 1);
66   }
67   call_togl_view_exploration (long (MyCView.ViewId));
68
69 }
70
71 Standard_Boolean OpenGl_GraphicDriver::ElementExploration (const Graphic3d_CStructure & ACStructure, const Standard_Integer ElementNumber, Graphic3d_VertexNC& AVertex, Graphic3d_Vector& AVector) {
72
73   Graphic3d_CStructure MyCStructure = ACStructure;
74
75   Quantity_Color AColor;
76   long AType;
77
78   CALL_DEF_POINT Pt;
79   CALL_DEF_NORMAL Npt, Nfa;
80   CALL_DEF_COLOR Cpt;
81
82   if (MyTraceLevel) {
83     PrintFunction ("call_togl_element_exploration");
84     PrintCStructure (MyCStructure, 1);
85   }
86   call_togl_element_exploration (MyCStructure.Id, ElementNumber, &AType, &Pt, &Npt, &Cpt, &Nfa);
87
88   if (! AType) return (Standard_False);
89   else {
90     AVertex.SetCoord
91       (double (Pt.x), double (Pt.y), double (Pt.z));
92     AVertex.SetNormal
93       (double (Npt.dx), double (Npt.dy), double (Npt.dz));
94     AColor.SetValues
95       (double (Cpt.r), double (Cpt.g),
96       double (Cpt.b), Quantity_TOC_RGB);
97     AVertex.SetColor (AColor);
98     AVector.SetCoord
99       (double (Nfa.dx), double (Nfa.dy), double (Nfa.dz));
100     return (Standard_True);
101   }
102 }
103
104 Graphic3d_TypeOfPrimitive OpenGl_GraphicDriver::ElementType (const Graphic3d_CStructure & ACStructure, const Standard_Integer ElementNumber) {
105
106   Graphic3d_CStructure MyCStructure = ACStructure;
107
108   long AType;
109   Graphic3d_TypeOfPrimitive top;
110
111   if (MyTraceLevel) {
112     PrintFunction ("call_togl_element_type");
113     PrintCStructure (MyCStructure, 1);
114   }
115   call_togl_element_type (MyCStructure.Id, ElementNumber, &AType);
116
117   switch (AType) {
118
119     case 0:
120       top = Graphic3d_TOP_UNDEFINED;
121       break;
122     case 1:
123       top = Graphic3d_TOP_POLYLINE;
124       break;
125     case 2:
126       top = Graphic3d_TOP_POLYGON;
127       break;
128     case 3:
129       top = Graphic3d_TOP_TRIANGLEMESH;
130       break;
131     case 4:
132       top = Graphic3d_TOP_QUADRANGLEMESH;
133       break;
134     case 5:
135       top = Graphic3d_TOP_TEXT;
136       break;
137     case 6:
138       top = Graphic3d_TOP_MARKER;
139       break;
140     default:
141       top = Graphic3d_TOP_UNDEFINED;
142       break;
143
144   }
145
146   return (top);
147 }