b311480e |
1 | // Created on: 1995-01-03 |
2 | // Created by: Frederic MAUPAS |
3 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
7fd59977 |
17 | //:o0 abv 16.02.99: POLYLINE allowed as 3d curve of edge |
18 | //gka,abv 05.04.99: S4136: improving tolerance management, eliminate BRepAPI::Precision() |
19 | |
7fd59977 |
20 | #include <BRep_Builder.hxx> |
21 | #include <BRep_Tool.hxx> |
22 | #include <BRepLib.hxx> |
23 | #include <BRepLib_MakeEdge.hxx> |
42cf5bc1 |
24 | #include <GCPnts_AbscissaPoint.hxx> |
25 | #include <Geom2d_Curve.hxx> |
26 | #include <Geom_CartesianPoint.hxx> |
7fd59977 |
27 | #include <Geom_Curve.hxx> |
7fd59977 |
28 | #include <Geom_Line.hxx> |
42cf5bc1 |
29 | #include <Geom_Surface.hxx> |
30 | #include <GeomAbs_Shape.hxx> |
31 | #include <GeomAdaptor_Curve.hxx> |
7fd59977 |
32 | #include <gp_Dir.hxx> |
33 | #include <gp_Lin.hxx> |
42cf5bc1 |
34 | #include <gp_Vec.hxx> |
35 | #include <Precision.hxx> |
7fd59977 |
36 | #include <ShapeAnalysis_Curve.hxx> |
37 | #include <ShapeConstruct_Curve.hxx> |
42cf5bc1 |
38 | #include <StdFail_NotDone.hxx> |
39 | #include <StepGeom_CartesianPoint.hxx> |
7fd59977 |
40 | #include <StepGeom_Curve.hxx> |
7fd59977 |
41 | #include <StepGeom_Pcurve.hxx> |
42cf5bc1 |
42 | #include <StepGeom_Polyline.hxx> |
7fd59977 |
43 | #include <StepGeom_SurfaceCurve.hxx> |
7fd59977 |
44 | #include <StepRepr_DefinitionalRepresentation.hxx> |
42cf5bc1 |
45 | #include <StepShape_Edge.hxx> |
46 | #include <StepShape_EdgeCurve.hxx> |
47 | #include <StepShape_OrientedEdge.hxx> |
48 | #include <StepShape_Vertex.hxx> |
7fd59977 |
49 | #include <StepShape_VertexPoint.hxx> |
caaeed1b |
50 | #include <StepToGeom.hxx> |
42cf5bc1 |
51 | #include <StepToTopoDS.hxx> |
52 | #include <StepToTopoDS_GeometricTool.hxx> |
53 | #include <StepToTopoDS_NMTool.hxx> |
54 | #include <StepToTopoDS_Tool.hxx> |
55 | #include <StepToTopoDS_TranslateEdge.hxx> |
56 | #include <StepToTopoDS_TranslateVertex.hxx> |
7fd59977 |
57 | #include <TCollection_HAsciiString.hxx> |
42cf5bc1 |
58 | #include <TopoDS.hxx> |
59 | #include <TopoDS_Edge.hxx> |
60 | #include <TopoDS_Shape.hxx> |
61 | #include <TopoDS_Vertex.hxx> |
62 | #include <Transfer_TransientProcess.hxx> |
63 | #include <UnitsMethods.hxx> |
82314bdf |
64 | #include <Standard_Failure.hxx> |
7fd59977 |
65 | |
42cf5bc1 |
66 | //#include <StepGeom_Polyline.hxx> |
67 | //#include <TransferBRep.hxx> |
68 | //:d8 |
69 | // Used in I-DEAS-like STP processing (ssv; 15.11.2010) |
7fd59977 |
70 | //#define DEBUG |
7fd59977 |
71 | // ============================================================================ |
72 | // Method : DecodeMakeEdgeError |
73 | // Purpose : |
74 | // ============================================================================ |
7fd59977 |
75 | static void DecodeMakeEdgeError(const BRepLib_MakeEdge& ME, |
76 | const Handle(Standard_Transient)& orig, |
77 | const Handle(Geom_Curve)& myCurve, |
78 | const TopoDS_Vertex& V1, |
79 | const TopoDS_Vertex& V2, |
0797d9d3 |
80 | const Standard_Real& U1, |
81 | const Standard_Real& U2, |
7fd59977 |
82 | StepToTopoDS_Tool& aTool, |
83 | const Handle(StepShape_TopologicalRepresentationItem)& /*tobind*/) |
84 | { |
0797d9d3 |
85 | (void)U1, (void)U2; // avoid compiler warning |
86 | |
7fd59977 |
87 | Handle(Transfer_TransientProcess) TP = aTool.TransientProcess(); |
88 | // if (!myCurve.IsNull() && !tobind.IsNull()) { |
89 | // TransferBRep::SetShapeResult |
90 | // (TP,tobind, MakeEdge(myCurve,V1,V2,U1,U2,BRepAPI::Precision()) ); |
91 | // aTool.Bind (tobind,E); SURTOUT PAS : noter pour debug/erreur |
92 | // } |
0797d9d3 |
93 | #ifdef OCCT_DEBUG |
7fd59977 |
94 | cout << "------------------------------------" << endl; |
95 | cout << "MakeEdge Error : " << ME.Error()<<" - "; |
96 | #endif |
97 | switch(ME.Error()) |
98 | { |
99 | case (BRepLib_EdgeDone): return; |
100 | case (BRepLib_PointProjectionFailed): |
101 | TP->AddFail(orig," Point Projection failed"); |
102 | break; |
103 | case (BRepLib_ParameterOutOfRange): |
104 | TP->AddFail(orig," Parameter Out Of Range"); |
105 | break; |
106 | case (BRepLib_DifferentPointsOnClosedCurve): |
107 | TP->AddFail(orig," Different Points on Closed Curve"); |
108 | break; |
109 | case (BRepLib_PointWithInfiniteParameter): |
110 | TP->AddFail(orig," Point with infinite Parameter"); |
111 | break; |
112 | case (BRepLib_DifferentsPointAndParameter): |
113 | if (!ShapeConstruct_Curve().AdjustCurve |
114 | (myCurve,BRep_Tool::Pnt(V1),BRep_Tool::Pnt(V2),Standard_True,Standard_True)) |
115 | TP->AddFail(orig," Different Points and Parameters"); |
116 | else TP->AddWarning(orig,"Different Points and Parameters, adjusted"); |
117 | break; |
118 | case (BRepLib_LineThroughIdenticPoints): |
119 | TP->AddFail(orig," Line through identic Points"); |
120 | break; |
121 | } |
0797d9d3 |
122 | #ifdef OCCT_DEBUG |
7fd59977 |
123 | cout << "Original Type : " << orig->DynamicType() << endl; |
124 | cout << "3D Curve Type : " << myCurve->DynamicType() << endl; |
125 | cout << "First Parameter : " << U1 << endl; |
126 | gp_Pnt p1 = BRep_Tool::Pnt(V1); |
127 | // cout << "First Point : "; |
128 | cout << "First Vertex : "<<p1.X()<<" "<<p1.Y()<<" "<<p1.Z()<<" "; |
129 | cout << "Distance Point - Vertex : "; |
130 | Standard_Real d1 = p1.Distance(myCurve->Value(U1)); |
131 | cout << d1 << endl; |
132 | cout << "Last Parameter : " << U2 << endl; |
133 | gp_Pnt p2 = BRep_Tool::Pnt(V2); |
134 | // cout << "Last Point : "; |
135 | cout << "Last Vertex : "<<p2.X()<<" "<<p2.Y()<<" "<<p2.Z()<<" "; |
136 | cout << "Distance Point - Vertex : "; |
137 | Standard_Real d2 = BRep_Tool::Pnt(V2).Distance(myCurve->Value(U2)); |
138 | cout << d2 << endl; |
139 | #endif |
140 | } |
141 | |
142 | // ============================================================================ |
143 | // Method : StepToTopoDS_TranslateEdge::StepToTopoDS_TranslateEdge |
144 | // Purpose : Empty Constructor |
145 | // ============================================================================ |
146 | |
147 | static Handle(Geom_Curve) MakeCurve |
148 | (const Handle(StepGeom_Curve)& C1, const Handle(Transfer_TransientProcess) TP) |
149 | { |
150 | Handle(Geom_Curve) C2 = Handle(Geom_Curve)::DownCast (TP->FindTransient(C1)); |
151 | if (!C2.IsNull()) return C2; |
caaeed1b |
152 | C2 = StepToGeom::MakeCurve (C1); |
153 | if (! C2.IsNull()) |
7fd59977 |
154 | TP->BindTransient (C1,C2); |
155 | return C2; |
156 | } |
157 | |
158 | static TopoDS_Edge MakeEdge |
159 | (const Handle(Geom_Curve)& C3D, |
160 | const TopoDS_Vertex& V1, const TopoDS_Vertex& V2, |
161 | const Standard_Real U1, const Standard_Real U2) //, const Standard_Real preci) |
162 | { |
163 | // fait son edge quoi qu il arrive |
164 | BRep_Builder B; |
165 | TopoDS_Edge E; |
166 | B.MakeEdge (E,C3D,Precision::Confusion());//preci); |
167 | B.Add (E,V1); B.Add (E,V2); |
168 | B.UpdateVertex(V1, U1, E, 0.);//preci); |
169 | B.UpdateVertex(V2, U2, E, 0.);//preci); |
170 | return E; |
171 | } |
172 | |
173 | StepToTopoDS_TranslateEdge::StepToTopoDS_TranslateEdge() |
174 | { |
175 | done = Standard_False; |
176 | } |
177 | |
178 | // ============================================================================ |
179 | // Method : StepToTopoDS_TranslateEdge::StepToTopoDS_TranslateEdge() |
180 | // Purpose : Constructor with an Edge and a Tool |
181 | // ============================================================================ |
182 | |
183 | StepToTopoDS_TranslateEdge::StepToTopoDS_TranslateEdge(const Handle(StepShape_Edge)& E, |
184 | StepToTopoDS_Tool& T, |
185 | StepToTopoDS_NMTool& NMTool) |
186 | { |
187 | Init(E, T, NMTool); |
188 | } |
189 | |
190 | // ============================================================================ |
191 | // Method : Init |
192 | // Purpose : Init with an Edge and a Tool. |
193 | // This method builds an Edge With 2 Vertices and 2 Parameters. |
194 | // The Edge is always build like FORWARD (BRepLib_MakeEdge) |
195 | // ============================================================================ |
196 | |
197 | void StepToTopoDS_TranslateEdge::Init(const Handle(StepShape_Edge)& aEdge, |
198 | StepToTopoDS_Tool& aTool, |
199 | StepToTopoDS_NMTool& NMTool) |
200 | { |
201 | Handle(Transfer_TransientProcess) TP = aTool.TransientProcess(); |
202 | |
203 | Handle(StepShape_OrientedEdge) OE = |
204 | Handle(StepShape_OrientedEdge)::DownCast(aEdge); |
205 | Handle(StepShape_Edge) wEdge = aEdge; |
206 | if ( ! OE.IsNull() ) wEdge = OE->EdgeElement(); |
207 | Handle(StepShape_EdgeCurve) EC = Handle(StepShape_EdgeCurve)::DownCast(wEdge); |
208 | |
209 | if (aTool.IsBound(EC)) { |
210 | myResult = aTool.Find(EC); |
211 | if (BRep_Tool::Degenerated(TopoDS::Edge(myResult))) { |
212 | TP->AddWarning(EC,"Degenerated Edge in several faces : transferred for each face"); |
213 | } |
214 | else { |
215 | myError = StepToTopoDS_TranslateEdgeDone; |
216 | done = Standard_True; |
217 | // BRep_Builder B; |
218 | //:S4136 B.SameRange(TopoDS::Edge(myResult), Standard_False); //:a5 abv 11 Feb 98 |
219 | //:S4136 B.SameParameter(TopoDS::Edge(myResult), Standard_False);//:a5 |
220 | return; |
221 | } |
222 | } |
223 | |
224 | // [BEGIN] Proceed with non-manifold cases (ssv; 12.11.2010) |
225 | if ( NMTool.IsActive() && NMTool.IsBound(EC) ) { |
226 | TopoDS_Shape existingShape = NMTool.Find(EC); |
227 | // Reverse shape's orientation if needed |
228 | if ( !OE->Orientation() ) |
229 | existingShape.Reverse(); |
230 | myResult = existingShape; |
231 | myError = StepToTopoDS_TranslateEdgeDone; |
232 | done = Standard_True; |
233 | return; |
234 | } |
235 | // [END] Proceed with non-manifold cases (ssv; 12.11.2010) |
236 | |
237 | // [BEGIN] Proceed with I-DEAS-like STP (ssv; 15.11.2010) |
238 | const Handle(TCollection_HAsciiString) anECName = EC->Name(); |
239 | if ( NMTool.IsIDEASCase() && !anECName.IsNull() && !anECName->IsEmpty() && |
240 | NMTool.IsBound(anECName->String()) ) { |
241 | TopoDS_Shape existingShape = NMTool.Find(anECName->String()); |
242 | // Reverse shape's orientation if needed |
243 | if ( !OE->Orientation() ) |
244 | existingShape.Reverse(); |
245 | // Register Edge for final processing (I-DEAS case) |
246 | NMTool.RegisterNMEdge(existingShape); |
247 | myResult = existingShape; |
248 | myError = StepToTopoDS_TranslateEdgeDone; |
249 | done = Standard_True; |
250 | return; |
251 | } |
252 | // [END] Proceed with I-DEAS-like STP (ssv; 15.11.2010) |
253 | |
254 | BRep_Builder B; |
255 | |
256 | // Standard_Real preci = BRepAPI::Precision(); |
257 | |
258 | // Standard_Real precision = BRepAPI::Precision(); |
259 | |
260 | Handle(StepGeom_Curve) C = EC->EdgeGeometry(); |
545ef510 |
261 | if( C.IsNull()) |
262 | { |
263 | TP->AddFail(EC," Geom Curve in EdgeCurve is equal to 0"); |
264 | myError = StepToTopoDS_TranslateEdgeOther; |
265 | done = Standard_False; |
266 | return; |
267 | } |
7fd59977 |
268 | TopoDS_Edge E; |
269 | Handle(StepShape_Vertex) Vstart, Vend; |
270 | |
271 | // ----------------------------------------------------------- |
272 | // Extract the start and end Vertices corresponding to FORWARD |
273 | // (following the geometrical sense) |
274 | // ----------------------------------------------------------- |
275 | |
276 | // Standard_Boolean OrientedEdgeOrientation = OE->Orientation(); |
277 | Standard_Boolean EdgeCurveSameSense = EC->SameSense(); |
278 | |
279 | if (EdgeCurveSameSense) { |
280 | Vstart = EC->EdgeStart(); |
281 | Vend = EC->EdgeEnd(); |
282 | } |
283 | else { |
284 | Vend = EC->EdgeStart(); |
285 | Vstart = EC->EdgeEnd(); |
286 | } |
287 | |
288 | TopoDS_Vertex V1, V2; |
289 | |
290 | StepToTopoDS_TranslateVertex myTranVertex1(Vstart, aTool, NMTool); |
291 | StepToTopoDS_TranslateVertex myTranVertex2(Vend, aTool, NMTool); |
292 | |
293 | if (myTranVertex1.IsDone()) { |
294 | V1 = TopoDS::Vertex(myTranVertex1.Value()); |
295 | V1.Orientation(TopAbs_FORWARD); |
296 | } |
297 | if (Vend == Vstart) { |
298 | V2 = V1; |
299 | V2.Orientation(TopAbs_REVERSED); |
300 | } |
301 | else if (myTranVertex2.IsDone()) { |
302 | V2 = TopoDS::Vertex(myTranVertex2.Value()); |
303 | V2.Orientation(TopAbs_REVERSED); |
304 | } |
305 | done = Standard_True; |
306 | |
307 | // ---------------------------------------------------------- |
308 | // --- The EdgeCurve Geometry is of StepGeom_Curve Type |
309 | // --- It can be : * a Pcurve : no 3D curve is constructed |
310 | // --- * a Surface Curve, Intersection Curve |
311 | // --- or a Seam Curve |
312 | // --- * a 3D Curve |
313 | // ---------------------------------------------------------- |
314 | |
315 | if ( C->IsKind(STANDARD_TYPE(StepGeom_Pcurve))) { |
316 | B.MakeEdge(E); |
317 | //:S4136 B.UpdateEdge (E,preci); |
318 | B.Add(E, V1); // ?? en fin de TranslateEdgeLoop |
319 | B.Add(E, V2); |
320 | } |
321 | else if (C->IsKind(STANDARD_TYPE(StepGeom_SurfaceCurve)) ) { |
322 | // qui reprend les types SeamCurve et IntersectionCurve |
323 | // --- The Edge Geometry is a Surface Curve --- |
324 | // --- (3d + 2 Pcurve Or Surface) --- |
325 | Handle(StepGeom_SurfaceCurve) Sc = |
326 | Handle(StepGeom_SurfaceCurve)::DownCast(C); |
327 | Handle(StepGeom_Curve) C1 = Sc->Curve3d(); |
328 | // if (C1->IsKind(STANDARD_TYPE(StepGeom_Polyline))) { |
329 | // B.MakeEdge(E); |
330 | // B.UpdateEdge (E,preci); |
331 | // B.Add(E, V1); // ?? en fin de TranslateEdgeLoop |
332 | // B.Add(E, V2); |
333 | // } |
334 | // else { |
335 | MakeFromCurve3D (C1,EC,Vend,Precision(), E,V1,V2 , aTool); |
336 | // } |
337 | } |
338 | // else if (C->IsKind(STANDARD_TYPE(StepGeom_Polyline))) { |
339 | // B.MakeEdge(E); |
340 | // B.UpdateEdge (E,preci); |
341 | // B.Add(E, V1); // ?? en fin de TranslateEdgeLoop |
342 | // B.Add(E, V2); |
343 | // } |
344 | else { |
345 | // --- The Edge Geometry is a Single 3d Curve --- |
346 | MakeFromCurve3D (C,EC,Vend,Precision(), E,V1,V2 , aTool); |
347 | } |
348 | // On force les flags SameRange et SameParameter a Standard_False |
349 | if (done) { |
350 | //:S4136 B.SameRange(E, Standard_False); |
351 | //:S4136 B.SameParameter(E, Standard_False); |
352 | aTool.Bind(EC,E); |
353 | |
354 | // Bind Edge in NM tool (ssv; 15.11.2010) |
355 | if ( NMTool.IsActive() ) { |
356 | NMTool.Bind(EC, E); |
357 | if ( NMTool.IsIDEASCase() && !anECName.IsNull() && !anECName->IsEmpty() ) |
358 | NMTool.Bind(anECName->String(), E); |
359 | } |
360 | |
361 | myResult = E; |
362 | myError = StepToTopoDS_TranslateEdgeDone; |
363 | } |
364 | } |
365 | |
366 | |
367 | // ============================================================================ |
368 | // Method : MakeFromCurve3D |
369 | // Purpose : case of a Curve 3D (alone or in SurfaceCurve) |
370 | // ============================================================================ |
371 | |
372 | // auxiliary function |
373 | //:e6 abv 16 Apr 98: ProSTEP TR8, r0601_sy.stp, #14907 |
374 | static void GetCartesianPoints ( const Handle(StepShape_EdgeCurve)& EC, |
375 | gp_Pnt &P1, gp_Pnt &P2) |
376 | { |
377 | for ( Standard_Integer i=1; i<=2; i++ ) { |
378 | const Handle(StepShape_Vertex) V = ( (Standard_Boolean)(i==1) == EC->SameSense() ? EC->EdgeStart() : EC->EdgeEnd() ); |
379 | const Handle(StepShape_VertexPoint) VP = Handle(StepShape_VertexPoint)::DownCast(V); |
380 | if ( VP.IsNull() ) continue; |
381 | const Handle(StepGeom_CartesianPoint) P = Handle(StepGeom_CartesianPoint)::DownCast(VP->VertexGeometry()); |
caaeed1b |
382 | Handle(Geom_CartesianPoint) CP = StepToGeom::MakeCartesianPoint (P); |
383 | ( i==1 ? P1 : P2 ) = CP->Pnt(); |
7fd59977 |
384 | } |
385 | } |
386 | |
387 | void StepToTopoDS_TranslateEdge::MakeFromCurve3D |
388 | (const Handle(StepGeom_Curve)& C3D, const Handle(StepShape_EdgeCurve)& EC, |
389 | const Handle(StepShape_Vertex)& Vend, |
390 | const Standard_Real preci, TopoDS_Edge& E, |
391 | TopoDS_Vertex& V1, TopoDS_Vertex& V2, |
392 | StepToTopoDS_Tool& aTool) |
393 | { |
394 | Handle(Transfer_TransientProcess) TP = aTool.TransientProcess(); |
395 | Handle(Geom_Curve) C1 = MakeCurve(C3D,TP); |
396 | if (C1.IsNull()) { |
397 | TP->AddFail(C3D," Make Geom_Curve (3D) failed"); |
398 | myError = StepToTopoDS_TranslateEdgeOther; |
399 | done = Standard_False; |
400 | return; |
401 | } |
402 | // -- Statistics -- -> No Warning message |
403 | aTool.AddContinuity (C1); |
404 | BRep_Builder B; |
405 | Standard_Real temp1,temp2, U1,U2; |
406 | gp_Pnt pproj; |
407 | gp_Pnt pv1 = BRep_Tool::Pnt(V1); |
408 | gp_Pnt pv2 = BRep_Tool::Pnt(V2); |
409 | |
410 | //:e6 abv |
411 | gp_Pnt pnt1 = pv1, pnt2 = pv2; |
412 | if ( V1.IsSame ( V2 ) ) GetCartesianPoints ( EC, pnt1, pnt2 ); |
413 | ShapeAnalysis_Curve sac; |
414 | temp1 = sac.Project (C1,pnt1,preci,pproj,U1,Standard_False); |
415 | temp2 = sac.Project (C1,pnt2,preci,pproj,U2,Standard_False); |
416 | |
417 | if (!StepToTopoDS_GeometricTool::UpdateParam3d(C1, U1, U2, preci)) |
418 | TP->AddWarning(C3D,"Update of 3D-Parameters has failed"); |
419 | |
420 | //:d5: instead of AdjustCurve above which is incorrect if U1 and U2 are not ends |
94f71cad |
421 | GeomAdaptor_Curve aCA(C1); |
422 | gp_Pnt pU1 = aCA.Value ( U1 ), pU2 = aCA.Value ( U2 ); |
7fd59977 |
423 | temp1 = pU1.Distance ( pv1 ); |
424 | temp2 = pU2.Distance ( pv2 ); |
425 | if ( temp1 > preci || temp2 > preci ) { |
426 | TP->AddWarning (C3D,"Poor result from projection vertex / curve 3d"); |
427 | } |
428 | B.UpdateVertex ( V1, 1.000001*temp1 ); //:h6 abv 14 Jul 98: PRO8845 #2746: *=1.0001 |
429 | B.UpdateVertex ( V2, 1.000001*temp2 ); //:h6 |
430 | |
431 | BRepLib_MakeEdge ME(C1, V1, V2, U1, U2); |
432 | if (ME.IsDone()) { |
433 | E = ME.Edge(); |
434 | B.Range ( E, U1, U2 ); // abv 14 Mar 00: trj3_pm1-ug.stp #91739, edge 2 |
435 | } |
436 | else { |
437 | if (ME.Error() == BRepLib_DifferentPointsOnClosedCurve) { |
438 | // The Edge could be closed and trimmed by 2 Differents |
439 | // Vertices |
440 | if (C1->IsClosed()) { |
441 | // Attention : il faudra mettre a jour la topologie des |
442 | // vertex pour avoir des edges cul a cul ...... Good Luck! |
443 | aTool.Bind (Vend,V1); |
444 | TopoDS_Shape aLocalShape = V1.Reversed(); |
445 | V2 = TopoDS::Vertex(aLocalShape); |
446 | ME.Init(C1, V1, V2, U1, U2); |
447 | if (ME.IsDone()) { |
448 | TP->AddWarning(EC, "Wrong topology corrected : Closed Edge with TWO different Vertices"); |
449 | E = ME.Edge(); |
450 | } |
451 | else { |
452 | DecodeMakeEdgeError(ME, C3D, C1, V1, V2, U1, U2, aTool, EC); |
453 | E = MakeEdge (C1,V1,V2,U1,U2);//preci |
454 | myError = StepToTopoDS_TranslateEdgeDone; // ???? |
455 | done = Standard_True; |
456 | // return; |
457 | } |
458 | } |
459 | else { |
460 | // Then, this is should be coded as degenerated |
461 | // To be performed later !!! |
462 | // DecodeMakeEdgeError(ME, C3D, C1, V1, V2, U1, U2, aTool, EC); |
463 | myError = StepToTopoDS_TranslateEdgeDone; // ???? |
464 | // Bon, on la fait cette petite edge, mais faudra repasser |
465 | // pour l enlever ET FUSIONNER LES VERTEX, pour tout le shell ! |
466 | // courbe trop petite pour etre mise -> fait planter |
467 | done = Standard_True; |
468 | if (!V1.IsSame(V2)) { |
469 | TP->AddFail(EC, "This edge has null arc length"); |
470 | gp_Pnt P1 = BRep_Tool::Pnt(V1); |
471 | gp_Pnt P2 = BRep_Tool::Pnt(V2); |
472 | gp_Vec avec (P1,P2); gp_Dir adir (avec); gp_Lin alin (P1,adir); |
473 | C1 = new Geom_Line (alin); |
474 | U1 = 0.; U2 = P1.Distance(P2); |
475 | E = MakeEdge (C1,V1,V2,U1,U2);//,preci |
476 | } |
477 | else { |
478 | TP->AddFail(EC,"NULL EDGE, SKIPPED"); |
479 | myResult.Nullify(); |
480 | return; |
481 | } |
482 | } |
483 | } |
484 | else { |
485 | DecodeMakeEdgeError(ME, C3D, C1, V1, V2, U1, U2, aTool, EC); |
486 | E = MakeEdge (C1,V1,V2,U1,U2);//,preci |
487 | myError = StepToTopoDS_TranslateEdgeDone; // ???? |
488 | done = Standard_True; |
489 | } |
490 | } |
491 | } |
492 | |
493 | |
494 | // ============================================================================ |
495 | // Method : MakePCurve |
496 | // Purpose : Computes an individual pcurve (i.e. curve 2d) |
497 | // ============================================================================ |
498 | Handle(Geom2d_Curve) StepToTopoDS_TranslateEdge::MakePCurve |
499 | (const Handle(StepGeom_Pcurve)& PCU, const Handle(Geom_Surface)& ConvSurf) const |
500 | { |
501 | Handle(Geom2d_Curve) C2d; |
502 | const Handle(StepRepr_DefinitionalRepresentation) DRI = PCU->ReferenceToCurve(); |
503 | if( DRI.IsNull()) return C2d; |
504 | const Handle(StepGeom_Curve) StepCurve = Handle(StepGeom_Curve)::DownCast(DRI->ItemsValue(1)); |
82314bdf |
505 | try |
506 | { |
507 | C2d = StepToGeom::MakeCurve2d (StepCurve); |
508 | if (! C2d.IsNull()) { |
7fd59977 |
509 | // -- if the surface is a RectangularTrimmedSurface, |
510 | // -- send the BasisSurface. |
82314bdf |
511 | C2d = UnitsMethods::DegreeToRadian(C2d, ConvSurf); |
512 | } |
513 | |
514 | } |
515 | catch(Standard_Failure) |
516 | { |
517 | return C2d; |
7fd59977 |
518 | } |
519 | return C2d; |
520 | } |
521 | |
522 | |
523 | // ============================================================================ |
524 | // Method : Value |
525 | // Purpose : Returns the mapped edge |
526 | // ============================================================================ |
527 | |
528 | const TopoDS_Shape& StepToTopoDS_TranslateEdge::Value() const |
529 | { |
530 | StdFail_NotDone_Raise_if(!done,""); |
531 | return myResult; |
532 | } |
533 | |
534 | // ============================================================================ |
535 | // Method : Error |
536 | // Purpose : Returns the error code |
537 | // ============================================================================ |
538 | |
539 | StepToTopoDS_TranslateEdgeError StepToTopoDS_TranslateEdge::Error() const |
540 | { |
541 | return myError; |
542 | } |