0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / StepToTopoDS / StepToTopoDS_Tool.cxx
1 // Created on: 1995-01-03
2 // Created by: Frederic MAUPAS
3 // Copyright (c) 1995-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 //  Complement : CKY, alimentation du TransientProcess
18 //    (Bind general;  BindVertex ?)
19
20 #include <Geom2d_Curve.hxx>
21 #include <Geom_Surface.hxx>
22 #include <StepToTopoDS_Tool.hxx>
23 #include <TopoDS_Edge.hxx>
24 #include <TopoDS_Shape.hxx>
25 #include <TopoDS_Vertex.hxx>
26 #include <Transfer_TransientProcess.hxx>
27 #include <TransferBRep.hxx>
28
29 // ============================================================================
30 // Method  : StepToTopoDS_Tool::StepToTopoDS_Tool
31 // Purpose : Empty Constructor
32 // ============================================================================
33 StepToTopoDS_Tool::StepToTopoDS_Tool()
34 : myComputePC(Standard_False),
35   myNbC0Surf(0),
36   myNbC1Surf(0),
37   myNbC2Surf(0),
38   myNbC0Cur2(0),
39   myNbC1Cur2(0),
40   myNbC2Cur2(0),
41   myNbC0Cur3(0),
42   myNbC1Cur3(0),
43   myNbC2Cur3(0)
44 {
45 }
46
47 // ============================================================================
48 // Method  : StepToTopoDS_Tool::StepToTopoDS_Tool
49 // Purpose : Constructor with a Map and a TransientProcess
50 // ============================================================================
51
52 StepToTopoDS_Tool::StepToTopoDS_Tool(const StepToTopoDS_DataMapOfTRI& Map, 
53                                    const Handle(Transfer_TransientProcess)& TP)
54 {
55   Init(Map, TP);
56 }
57
58 // ============================================================================
59 // Method  : Init
60 // Purpose : Init with a Map
61 // ============================================================================
62
63 void StepToTopoDS_Tool::Init(const StepToTopoDS_DataMapOfTRI& Map, 
64                             const Handle(Transfer_TransientProcess)& TP)
65
66   myComputePC = Standard_False;
67
68   StepToTopoDS_PointVertexMap aVertexMap;
69   StepToTopoDS_PointEdgeMap   aEdgeMap;
70   
71   myDataMap   = Map;
72   myVertexMap = aVertexMap;
73   myEdgeMap   = aEdgeMap;
74   myTransProc = TP;
75
76   myNbC0Surf = myNbC1Surf = myNbC2Surf = 0;
77   myNbC0Cur2 = myNbC1Cur2 = myNbC2Cur2 = 0;
78   myNbC0Cur3 = myNbC1Cur3 = myNbC2Cur3 = 0;
79
80
81 }
82
83 // ============================================================================
84 // Method  : StepToTopoDS_Tool::IsBound
85 // Purpose : Indicates weither a TRI is bound or not in the Map
86 // ============================================================================
87
88 Standard_Boolean StepToTopoDS_Tool::IsBound(const Handle(StepShape_TopologicalRepresentationItem)& TRI)
89 {
90   return myDataMap.IsBound(TRI);
91 }
92
93 // ============================================================================
94 // Method  : StepToTopoDS_Tool::Bind
95 // Purpose : Binds a TRI with a Shape in the Map
96 // ============================================================================
97
98 void StepToTopoDS_Tool::Bind(const Handle(StepShape_TopologicalRepresentationItem)& TRI, const TopoDS_Shape& S)
99 {
100   myDataMap.Bind(TRI, S);
101   TransferBRep::SetShapeResult (myTransProc,TRI,S);
102 }
103
104 // ============================================================================
105 // Method  : StepToTopoDS_Tool::Find
106 // Purpose : Returns the Shape corresponding to the bounded TRI
107 // ============================================================================
108
109 const TopoDS_Shape& StepToTopoDS_Tool::Find(const Handle(StepShape_TopologicalRepresentationItem)& TRI)
110 {
111   return myDataMap.Find(TRI);
112 }
113
114
115 // ============================================================================
116 // Method  : StepToTopoDS_Tool::ClearEdgeMap
117 // Purpose : 
118 // ============================================================================
119
120 void StepToTopoDS_Tool::ClearEdgeMap()
121 {
122   myEdgeMap.Clear();
123 }
124
125 // ============================================================================
126 // Method  : StepToTopoDS_Tool::IsEdgeBound
127 // Purpose : 
128 // ============================================================================
129
130 Standard_Boolean StepToTopoDS_Tool::IsEdgeBound(const StepToTopoDS_PointPair& PP)
131 {
132   return myEdgeMap.IsBound(PP);
133 }
134
135 // ============================================================================
136 // Method  : StepToTopoDS_Tool_BindEdge
137 // Purpose : 
138 // ============================================================================
139
140 void StepToTopoDS_Tool::BindEdge(const StepToTopoDS_PointPair& PP, const TopoDS_Edge& E)
141 {
142   myEdgeMap.Bind(PP, E);
143 }
144
145 // ============================================================================
146 // Method  : StepToTopoDS_Tool::FindEdge
147 // Purpose : 
148 // ============================================================================
149
150 const TopoDS_Edge& StepToTopoDS_Tool::FindEdge(const StepToTopoDS_PointPair& PP)
151 {
152   return myEdgeMap.Find(PP);
153 }
154
155 // ============================================================================
156 // Method  : StepToTopoDS_Tool::ClearVertexMap
157 // Purpose : 
158 // ============================================================================
159
160 void StepToTopoDS_Tool::ClearVertexMap()
161 {
162   myVertexMap.Clear();
163 }
164
165 // ============================================================================
166 // Method  : StepToTopoDS_Tool::IsVertexBound
167 // Purpose : 
168 // ============================================================================
169
170 Standard_Boolean StepToTopoDS_Tool::IsVertexBound(const Handle(StepGeom_CartesianPoint)& PG)
171 {
172   return myVertexMap.IsBound(PG);
173 }
174
175 // ============================================================================
176 // Method  : StepToTopoDS_Tool::BindVertex
177 // Purpose : 
178 // ============================================================================
179
180 void StepToTopoDS_Tool::BindVertex(const Handle(StepGeom_CartesianPoint)& P, const TopoDS_Vertex& V)
181 {
182   myVertexMap.Bind(P, V);
183 #ifdef OCCT_DEBUG
184   TransferBRep::SetShapeResult (myTransProc,P,V);
185 #endif
186 }
187
188 // ============================================================================
189 // Method  : StepToTopoDS_Tool::FindVertex
190 // Purpose : 
191 // ============================================================================
192
193 const TopoDS_Vertex& StepToTopoDS_Tool::FindVertex(const Handle(StepGeom_CartesianPoint)& P)
194 {
195   return myVertexMap.Find(P);
196 }
197
198 // ============================================================================
199 // Method  : ComputePCurve
200 // Purpose : 
201 // ============================================================================
202
203 void StepToTopoDS_Tool::ComputePCurve(const Standard_Boolean B)
204 {
205   myComputePC = B;
206 }
207
208 // ============================================================================
209 // Method  : ComputePCurve
210 // Purpose : 
211 // ============================================================================
212
213 Standard_Boolean StepToTopoDS_Tool::ComputePCurve() const
214 {
215   return myComputePC;
216 }
217
218 // ============================================================================
219 // Method  : StepToTopoDS_Tool::TransientProcess
220 // Purpose : Returns the TransientProcess
221 // ============================================================================
222
223 Handle(Transfer_TransientProcess) StepToTopoDS_Tool::TransientProcess() const
224 {
225   return myTransProc;
226 }
227
228
229 //===========
230 // AddStatistics
231 //===========
232
233 void  StepToTopoDS_Tool::AddContinuity (const Handle(Geom_Surface)& GeomSurf)
234 {
235   switch(GeomSurf->Continuity())
236     {
237     case GeomAbs_C0:    myNbC0Surf ++;  break;
238     case GeomAbs_C1:    myNbC1Surf ++;  break;
239     default:            myNbC2Surf ++;
240     }
241 }
242
243 void  StepToTopoDS_Tool::AddContinuity (const Handle(Geom_Curve)&   GeomCurve)
244 {
245   switch(GeomCurve->Continuity())
246     {
247     case GeomAbs_C0:    myNbC0Cur3 ++;  break;
248     case GeomAbs_C1:    myNbC1Cur3 ++;  break;
249     default:            myNbC2Cur3 ++;
250     }
251 }
252
253 void  StepToTopoDS_Tool::AddContinuity (const Handle(Geom2d_Curve)& GeomCur2d)
254 {
255   switch(GeomCur2d->Continuity())
256     {
257     case GeomAbs_C0:    myNbC0Cur2 ++;  break;
258     case GeomAbs_C1:    myNbC1Cur2 ++;  break;
259     default:            myNbC2Cur2 ++;
260     }
261 }
262
263 //===========
264 // Statistics
265 //===========
266
267 Standard_Integer StepToTopoDS_Tool::C0Surf() const
268 {
269   return myNbC0Surf;
270 }
271
272
273 Standard_Integer StepToTopoDS_Tool::C1Surf() const
274 {
275   return myNbC1Surf;
276 }
277
278
279 Standard_Integer StepToTopoDS_Tool::C2Surf() const
280 {
281   return myNbC2Surf;
282 }
283
284
285 //===========
286 // Statistics
287 //===========
288
289 Standard_Integer StepToTopoDS_Tool::C0Cur2() const
290 {
291   return myNbC0Cur2;
292 }
293
294
295 Standard_Integer StepToTopoDS_Tool::C1Cur2() const
296 {
297   return myNbC1Cur2;
298 }
299
300
301 Standard_Integer StepToTopoDS_Tool::C2Cur2() const
302 {
303   return myNbC2Cur2;
304 }
305
306
307 //===========
308 // Statistics
309 //===========
310
311 Standard_Integer StepToTopoDS_Tool::C0Cur3() const
312 {
313   return myNbC0Cur3;
314 }
315
316
317 Standard_Integer StepToTopoDS_Tool::C1Cur3() const
318 {
319   return myNbC1Cur3;
320 }
321
322
323 Standard_Integer StepToTopoDS_Tool::C2Cur3() const
324 {
325   return myNbC2Cur3;
326 }
327