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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
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>
29 //=======================================================================
30 //function : TopoDSToStep_Tool
32 //=======================================================================
33 TopoDSToStep_Tool::TopoDSToStep_Tool()
34 :myLowestTol(0.),myReversedSurface (Standard_False)
36 myPCurveMode = Interface_Static::IVal("write.surfacecurve.mode");
39 //=======================================================================
40 //function : TopoDSToStep_Tool
42 //=======================================================================
44 TopoDSToStep_Tool::TopoDSToStep_Tool(const MoniTool_DataMapOfShapeTransient& M, const Standard_Boolean FacetedContext)
45 :myLowestTol(0.),myReversedSurface(Standard_False)
47 Init ( M, FacetedContext );
50 //=======================================================================
53 //=======================================================================
55 void TopoDSToStep_Tool::Init(const MoniTool_DataMapOfShapeTransient& M, const Standard_Boolean FacetedContext)
58 myFacetedContext = FacetedContext;
59 myPCurveMode = Interface_Static::IVal("write.surfacecurve.mode");
62 //=======================================================================
65 //=======================================================================
67 Standard_Boolean TopoDSToStep_Tool::IsBound(const TopoDS_Shape& S)
69 return myDataMap.IsBound(S);
72 //=======================================================================
75 //=======================================================================
77 void TopoDSToStep_Tool::Bind(const TopoDS_Shape& S,
78 const Handle(StepShape_TopologicalRepresentationItem)& T)
83 //=======================================================================
86 //=======================================================================
88 Handle(StepShape_TopologicalRepresentationItem) TopoDSToStep_Tool::Find(const TopoDS_Shape& S)
90 return Handle(StepShape_TopologicalRepresentationItem)::DownCast(myDataMap.Find(S));
93 //=======================================================================
96 //=======================================================================
98 Standard_Boolean TopoDSToStep_Tool::Faceted() const
100 return myFacetedContext;
103 //=======================================================================
104 //function : SetCurrentShell
106 //=======================================================================
108 void TopoDSToStep_Tool::SetCurrentShell(const TopoDS_Shell& S)
111 cout << "Process a Shell which is ";
112 switch(S.Orientation())
116 cout << "FORWARD in the Solid;" << endl;
119 case TopAbs_REVERSED:
121 cout << "REVERSED in the Solid;" << endl;
126 cout << "INTERNAL OR EXTERNAL SHELL" << endl;
133 //=======================================================================
134 //function : CurrentShell
136 //=======================================================================
138 const TopoDS_Shell& TopoDSToStep_Tool::CurrentShell() const
140 return myCurrentShell;
143 //=======================================================================
144 //function : SetCurrentFace
146 //=======================================================================
148 void TopoDSToStep_Tool::SetCurrentFace(const TopoDS_Face& F)
151 cout << " Process a Face which is ";
152 switch(F.Orientation())
156 cout << "FORWARD in the Shell;" << endl;
159 case TopAbs_REVERSED:
161 cout << "REVERSED in the Shell;" << endl;
166 cout << "INTERNAL OR EXTERNAL FACE" << endl;
170 Standard_Real FaceTol = BRep_Tool::Tolerance(F);
171 if (FaceTol > myLowestTol)
172 myLowestTol = FaceTol;
176 //=======================================================================
177 //function : CurrentFace
179 //=======================================================================
181 const TopoDS_Face& TopoDSToStep_Tool::CurrentFace() const
183 return myCurrentFace;
186 //=======================================================================
187 //function : SetCurrentWire
189 //=======================================================================
191 void TopoDSToStep_Tool::SetCurrentWire(const TopoDS_Wire& W)
194 cout << " Process a Wire which is ";
195 switch(W.Orientation())
199 cout << "FORWARD in the Face" << endl;
202 case TopAbs_REVERSED:
204 cout << "REVERSED in the Face;" << endl;
209 cout << "INTERNAL OR EXTERNAL Wire" << endl;
216 //=======================================================================
217 //function : CurrentWire
219 //=======================================================================
221 const TopoDS_Wire& TopoDSToStep_Tool::CurrentWire() const
223 return myCurrentWire;
226 //=======================================================================
227 //function : SetCurrentEdge
229 //=======================================================================
231 void TopoDSToStep_Tool::SetCurrentEdge(const TopoDS_Edge& E)
234 cout << " Process Edge which is ";
235 switch(E.Orientation())
239 cout << "FORWARD in the Wire" << endl;
242 case TopAbs_REVERSED:
244 cout << "REVERSED in the Wire" << endl;
249 cout << "INTERNAL OR EXTERNAL EDGE" << endl;
253 Standard_Real EdgeTol = BRep_Tool::Tolerance(E);
254 if (EdgeTol > myLowestTol)
255 myLowestTol = EdgeTol;
259 //=======================================================================
260 //function : CurrentEdge
262 //=======================================================================
264 const TopoDS_Edge& TopoDSToStep_Tool::CurrentEdge() const
266 return myCurrentEdge;
269 //=======================================================================
270 //function : SetCurrentVertex
272 //=======================================================================
274 void TopoDSToStep_Tool::SetCurrentVertex(const TopoDS_Vertex& V)
276 Standard_Real VertexTol = BRep_Tool::Tolerance(V);
277 if (VertexTol > myLowestTol)
278 myLowestTol = VertexTol;
282 //=======================================================================
283 //function : CurrentVertex
285 //=======================================================================
287 const TopoDS_Vertex& TopoDSToStep_Tool::CurrentVertex() const
289 return myCurrentVertex;
292 //=======================================================================
293 //function : Lowest3DTolerance
295 //=======================================================================
297 Standard_Real TopoDSToStep_Tool::Lowest3DTolerance() const
302 //=======================================================================
303 //function : SetSurfaceReversed
305 //=======================================================================
307 void TopoDSToStep_Tool::SetSurfaceReversed(const Standard_Boolean B)
309 myReversedSurface = B;
312 //=======================================================================
313 //function : SurfaceReversed
315 //=======================================================================
317 Standard_Boolean TopoDSToStep_Tool::SurfaceReversed() const
319 return myReversedSurface;
322 //=======================================================================
325 //=======================================================================
327 const MoniTool_DataMapOfShapeTransient &TopoDSToStep_Tool::Map () const
332 //=======================================================================
333 //function : PCurveMode
335 //=======================================================================
337 Standard_Integer TopoDSToStep_Tool::PCurveMode () const