0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[occt.git] / src / TopoDSToStep / TopoDSToStep_Tool.cxx
1 // Created on: 1994-11-30
2 // Created by: Frederic MAUPAS
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <BRep_Tool.hxx>
19 #include <Interface_Static.hxx>
20 #include <StepShape_TopologicalRepresentationItem.hxx>
21 #include <TopoDS_Edge.hxx>
22 #include <TopoDS_Face.hxx>
23 #include <TopoDS_Shape.hxx>
24 #include <TopoDS_Shell.hxx>
25 #include <TopoDS_Vertex.hxx>
26 #include <TopoDS_Wire.hxx>
27 #include <TopoDSToStep_Tool.hxx>
28
29 //=======================================================================
30 //function : TopoDSToStep_Tool
31 //purpose  : 
32 //=======================================================================
33 TopoDSToStep_Tool::TopoDSToStep_Tool()
34      :myLowestTol(0.),myReversedSurface (Standard_False)
35 {
36   myPCurveMode = Interface_Static::IVal("write.surfacecurve.mode");
37 }
38
39 //=======================================================================
40 //function : TopoDSToStep_Tool
41 //purpose  : 
42 //=======================================================================
43
44 TopoDSToStep_Tool::TopoDSToStep_Tool(const MoniTool_DataMapOfShapeTransient& M, const Standard_Boolean FacetedContext)
45      :myLowestTol(0.),myReversedSurface(Standard_False)
46 {
47   Init ( M, FacetedContext );
48 }
49
50 //=======================================================================
51 //function : Init
52 //purpose  : 
53 //=======================================================================
54
55 void TopoDSToStep_Tool::Init(const MoniTool_DataMapOfShapeTransient& M, const Standard_Boolean FacetedContext)
56 {
57   myDataMap = M;
58   myFacetedContext = FacetedContext;
59   myPCurveMode = Interface_Static::IVal("write.surfacecurve.mode");
60 }
61
62 //=======================================================================
63 //function : IsBound
64 //purpose  : 
65 //=======================================================================
66
67 Standard_Boolean TopoDSToStep_Tool::IsBound(const TopoDS_Shape& S) 
68 {
69   return myDataMap.IsBound(S);
70 }
71
72 //=======================================================================
73 //function : Bind
74 //purpose  : 
75 //=======================================================================
76
77 void TopoDSToStep_Tool::Bind(const TopoDS_Shape& S,
78                              const Handle(StepShape_TopologicalRepresentationItem)& T) 
79 {
80   myDataMap.Bind(S, T);
81 }
82
83 //=======================================================================
84 //function : Find
85 //purpose  : 
86 //=======================================================================
87
88 Handle(StepShape_TopologicalRepresentationItem) TopoDSToStep_Tool::Find(const TopoDS_Shape& S)
89 {
90   return Handle(StepShape_TopologicalRepresentationItem)::DownCast(myDataMap.Find(S));
91 }
92
93 //=======================================================================
94 //function : Faceted
95 //purpose  : 
96 //=======================================================================
97
98 Standard_Boolean TopoDSToStep_Tool::Faceted() const 
99 {
100   return myFacetedContext;
101 }
102
103 //=======================================================================
104 //function : SetCurrentShell
105 //purpose  : 
106 //=======================================================================
107
108 void TopoDSToStep_Tool::SetCurrentShell(const TopoDS_Shell& S)
109 {
110 #ifdef OCCT_DEBUG
111   cout << "Process a Shell which is ";
112   switch(S.Orientation())
113     {
114     case TopAbs_FORWARD:
115       {
116         cout << "FORWARD in the Solid;" << endl;
117         break;
118       }
119     case TopAbs_REVERSED:
120       {
121         cout << "REVERSED in the Solid;" << endl;
122         break;
123       }
124     default:
125       {
126         cout << "INTERNAL OR EXTERNAL SHELL" << endl;
127       }
128     }
129 #endif
130   myCurrentShell = S;
131 }
132
133 //=======================================================================
134 //function : CurrentShell
135 //purpose  : 
136 //=======================================================================
137
138 const TopoDS_Shell& TopoDSToStep_Tool::CurrentShell() const 
139 {
140   return myCurrentShell;
141 }
142
143 //=======================================================================
144 //function : SetCurrentFace
145 //purpose  : 
146 //=======================================================================
147
148 void TopoDSToStep_Tool::SetCurrentFace(const TopoDS_Face& F)
149 {
150 #ifdef OCCT_DEBUG
151   cout << "  Process a Face which is ";
152   switch(F.Orientation())
153     {
154     case TopAbs_FORWARD:
155       {
156         cout << "FORWARD in the Shell;" << endl;
157         break;
158       }
159     case TopAbs_REVERSED:
160       {
161         cout << "REVERSED in the Shell;" << endl;
162         break;
163       }
164     default:
165       {
166         cout << "INTERNAL OR EXTERNAL FACE" << endl;
167       }
168     }
169 #endif  
170   Standard_Real FaceTol = BRep_Tool::Tolerance(F);
171   if (FaceTol > myLowestTol)
172     myLowestTol = FaceTol;
173   myCurrentFace = F;
174 }
175
176 //=======================================================================
177 //function : CurrentFace
178 //purpose  : 
179 //=======================================================================
180
181 const TopoDS_Face& TopoDSToStep_Tool::CurrentFace() const 
182 {
183   return myCurrentFace;
184 }
185
186 //=======================================================================
187 //function : SetCurrentWire
188 //purpose  : 
189 //=======================================================================
190
191 void TopoDSToStep_Tool::SetCurrentWire(const TopoDS_Wire& W)
192 {
193 #ifdef OCCT_DEBUG
194   cout << "    Process a Wire which is ";
195   switch(W.Orientation())
196     {
197     case TopAbs_FORWARD:
198       {
199         cout << "FORWARD in the Face" << endl;
200         break;
201       }
202     case TopAbs_REVERSED:
203       {
204         cout << "REVERSED in the Face;" << endl;
205         break;
206       }
207     default:
208       {
209         cout << "INTERNAL OR EXTERNAL Wire" << endl;
210       }
211     }
212 #endif  
213   myCurrentWire = W;
214 }
215
216 //=======================================================================
217 //function : CurrentWire
218 //purpose  : 
219 //=======================================================================
220
221 const TopoDS_Wire& TopoDSToStep_Tool::CurrentWire() const 
222 {
223   return myCurrentWire;
224 }
225
226 //=======================================================================
227 //function : SetCurrentEdge
228 //purpose  : 
229 //=======================================================================
230
231 void TopoDSToStep_Tool::SetCurrentEdge(const TopoDS_Edge& E)
232 {
233 #ifdef OCCT_DEBUG
234   cout << "      Process Edge which is ";
235   switch(E.Orientation())
236     {
237     case TopAbs_FORWARD:
238       {
239         cout << "FORWARD in the Wire" << endl;
240         break;
241       }
242     case TopAbs_REVERSED:
243       {
244         cout << "REVERSED in the Wire" << endl;
245         break;
246       }
247     default:
248       {
249         cout << "INTERNAL OR EXTERNAL EDGE" << endl;
250       }
251     }
252 #endif  
253   Standard_Real EdgeTol = BRep_Tool::Tolerance(E);
254   if (EdgeTol > myLowestTol)
255     myLowestTol = EdgeTol;
256   myCurrentEdge = E;
257 }
258
259 //=======================================================================
260 //function : CurrentEdge
261 //purpose  : 
262 //=======================================================================
263
264 const TopoDS_Edge& TopoDSToStep_Tool::CurrentEdge() const 
265 {
266   return myCurrentEdge;
267 }
268
269 //=======================================================================
270 //function : SetCurrentVertex
271 //purpose  : 
272 //=======================================================================
273
274 void TopoDSToStep_Tool::SetCurrentVertex(const TopoDS_Vertex& V)
275 {
276   Standard_Real VertexTol = BRep_Tool::Tolerance(V);
277   if (VertexTol > myLowestTol)
278     myLowestTol = VertexTol;
279   myCurrentVertex = V;
280 }
281
282 //=======================================================================
283 //function : CurrentVertex
284 //purpose  : 
285 //=======================================================================
286
287 const TopoDS_Vertex& TopoDSToStep_Tool::CurrentVertex() const 
288 {
289   return myCurrentVertex;
290 }
291
292 //=======================================================================
293 //function : Lowest3DTolerance
294 //purpose  : 
295 //=======================================================================
296
297 Standard_Real TopoDSToStep_Tool::Lowest3DTolerance() const
298 {
299   return myLowestTol;
300 }
301
302 //=======================================================================
303 //function : SetSurfaceReversed
304 //purpose  : 
305 //=======================================================================
306
307 void TopoDSToStep_Tool::SetSurfaceReversed(const Standard_Boolean B)
308 {
309   myReversedSurface = B;
310 }
311
312 //=======================================================================
313 //function : SurfaceReversed
314 //purpose  : 
315 //=======================================================================
316
317 Standard_Boolean TopoDSToStep_Tool::SurfaceReversed() const
318 {
319   return myReversedSurface;
320 }
321
322 //=======================================================================
323 //function : Map
324 //purpose  : 
325 //=======================================================================
326
327 const MoniTool_DataMapOfShapeTransient &TopoDSToStep_Tool::Map () const
328 {
329   return myDataMap;
330 }
331
332 //=======================================================================
333 //function : PCurveMode
334 //purpose  : 
335 //=======================================================================
336
337 Standard_Integer TopoDSToStep_Tool::PCurveMode () const
338 {
339   return myPCurveMode;
340 }