1 // Created on: 1995-03-29
2 // Created by: Frederic MAUPAS
3 // Copyright (c) 1995-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.
17 // gka 21.08.98 PRO7656
18 // gka 15.12.98 UKI60591 #1274560
19 //pdn 18.12.98 to keep pcurves
20 //:o0 abv 16.02.99: POLYLINE allowed as 3d curve of edge
21 //: abv 07.04.99: S4136: improve tolerance management and dealing with pcurves
22 // rln 02.06.99 removing #include <StepToTopoDS_DegeneratedTool.hxx>
23 // smh 31.01.01 BUC60810 : IsNull protection
24 #include <StepToTopoDS_TranslateEdgeLoop.ixx>
26 #include <StepToTopoDS.hxx>
27 #include <StepToTopoDS_TranslateVertex.hxx>
28 #include <StepToTopoDS_TranslateEdge.hxx>
29 #include <StepToTopoDS_GeometricTool.hxx>
30 #include <ShapeAnalysis_Curve.hxx>
31 #include <StepToGeom_MakeCurve2d.hxx>
32 #include <StepToGeom_MakeCurve.hxx>
34 #include <Geom_RectangularTrimmedSurface.hxx>
36 #include <StepShape_EdgeLoop.hxx>
37 #include <StepShape_Edge.hxx>
38 #include <StepShape_OrientedEdge.hxx>
39 #include <StepGeom_Curve.hxx>
40 #include <StepShape_EdgeCurve.hxx>
41 #include <StepGeom_Pcurve.hxx>
42 //#include <StepGeom_Polyline.hxx>
43 #include <StepGeom_SurfaceCurve.hxx>
44 #include <StepRepr_DefinitionalRepresentation.hxx>
45 #include <StepGeom_PcurveOrSurface.hxx>
47 #include <BRep_Builder.hxx>
48 #include <BRep_Tool.hxx>
51 #include <TopoDS_Wire.hxx>
52 #include <TopoDS_Edge.hxx>
53 #include <TopoDS_Vertex.hxx>
55 #include <BRep_TEdge.hxx>
56 #include <BRep_CurveRepresentation.hxx>
57 #include <BRep_ListOfCurveRepresentation.hxx>
58 #include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
60 #include <TopExp_Explorer.hxx>
63 #include <TopLoc_Location.hxx>
66 #include <Geom_Surface.hxx>
67 #include <Geom_Plane.hxx>
68 #include <Geom_Curve.hxx>
70 #include <Geom2d_Curve.hxx>
71 #include <Geom2d_BoundedCurve.hxx>
72 #include <Geom2d_Line.hxx>
75 #include <gp_Pnt2d.hxx>
77 #include <Precision.hxx>
78 #include <Interface_Static.hxx>
79 #include <Transfer_TransientProcess.hxx>
80 #include <TopoDS_Iterator.hxx>
81 #include <ShapeFix_EdgeProjAux.hxx>
82 #include <ShapeAnalysis_Edge.hxx>
83 #include <ShapeExtend_WireData.hxx>
84 #include <ShapeBuild_Edge.hxx>
86 #include <ShapeAlgo.hxx>
87 #include <ShapeAlgo_AlgoContainer.hxx>
88 #include <ShapeAlgo_ToolContainer.hxx>
90 #include <XSAlgo_AlgoContainer.hxx>
93 // ============================================================================
94 // Method : RemoveSinglePCurve
96 // ============================================================================
98 static void RemoveSinglePCurve (const TopoDS_Edge& aEdge, const TopoDS_Face& aFace)
100 ShapeBuild_Edge().RemovePCurve (aEdge, aFace);
103 // ============================================================================
104 // Method : RemovePCurves
106 // ============================================================================
108 static void RemovePCurves(const TopoDS_Wire& aWire, const TopoDS_Face& aFace)
110 TopExp_Explorer EdgeExp(aWire, TopAbs_EDGE);
111 while (EdgeExp.More()) {
112 const TopoDS_Edge& myEdge = TopoDS::Edge(EdgeExp.Current());
113 RemoveSinglePCurve(myEdge,aFace);
118 // ============================================================================
119 // Method : CheckPCurves
120 // Purpose : Checks the pcurves topological trimming parameter consistency
121 // and deviation between 2D ans 3D
122 // ============================================================================
124 static void CheckPCurves (TopoDS_Wire& aWire, const TopoDS_Face& aFace,
125 const Standard_Boolean isPlane,const Standard_Real preci )
127 if (isPlane) { RemovePCurves (aWire,aFace);return; }
129 Standard_Real w1, w2, cf, cl;
130 Handle(Geom_Surface) mySurf = BRep_Tool::Surface(aFace);
132 Handle(ShapeExtend_WireData) sbwd = new ShapeExtend_WireData ( aWire );
133 for (Standard_Integer i = 1; i <= sbwd->NbEdges(); i++) {
134 const TopoDS_Edge& myEdge = sbwd->Edge(i);
135 // B.SameRange( myEdge, Standard_True );
136 // B.SameParameter ( myEdge, Standard_True );
138 // First Check : 2D Parameters on Edge :
139 // Case 1 : w1 == w2 illegal => Drop the PCurve
140 // Case 2 : on bounded curve w1 < FirstParameter => w1 = FirstParameter
141 // w2 > LastParameter => w2 = LastParameter
143 Handle(Geom2d_Curve) thePC;
144 ShapeAnalysis_Edge sae;
145 if (!sae.PCurve (myEdge, aFace, thePC, w1, w2, Standard_False )) {
148 cf = thePC->FirstParameter();
149 cl = thePC->LastParameter();
152 RemoveSinglePCurve(myEdge,aFace);
154 cout<<"Removing pcuve w1=w2"<<endl;
160 B.Range(myEdge, aFace, cf, w2);
164 B.Range(myEdge, aFace, w1, cl);
168 if (w1 > w2 && mySurf->IsUPeriodic())
170 Standard_Real u1,u2,v1,v2;
171 mySurf->Bounds(u1,u2,v1,v2);
172 ElCLib::AdjustPeriodic(u1, u2,
173 Min(Abs(w2-w1)/2,Precision::PConfusion()),
175 B.Range(myEdge, aFace, w1, w2);
180 XSAlgo::AlgoContainer()->CheckPCurve (myEdge, aFace, preci, sbwd->IsSeam(i) );
184 // ============================================================================
185 // Method : StepToTopoDS_TranslateEdgeLoop::StepToTopoDS_TranslateEdgeLoop
186 // Purpose : Empty Constructor
187 // ============================================================================
189 StepToTopoDS_TranslateEdgeLoop::StepToTopoDS_TranslateEdgeLoop()
191 done = Standard_False;
194 // ============================================================================
195 // Method : StepToTopoDS_TranslateEdgeLoop::StepToTopoDS_TranslateEdgeLoop
196 // Purpose : Constructor with a FaceSurface and a Tool
197 // ============================================================================
199 StepToTopoDS_TranslateEdgeLoop::StepToTopoDS_TranslateEdgeLoop(const Handle(StepShape_FaceBound)& FB,
200 const TopoDS_Face& Face,
201 const Handle(Geom_Surface)& GeomSurf,
202 const Handle(StepGeom_Surface)& StepSurf,
203 const Standard_Boolean sameSense,
204 StepToTopoDS_Tool& T,
205 StepToTopoDS_NMTool& NMTool) {
206 Init(FB, Face, GeomSurf, StepSurf, sameSense, T, NMTool);
209 // ============================================================================
211 // Purpose : Init with a EdgeLoop and a Tool
212 // ============================================================================
214 void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& FaceBound,
215 const TopoDS_Face& Face,
216 const Handle(Geom_Surface)& GeomSurf,
217 const Handle(StepGeom_Surface)& StepSurf,
218 const Standard_Boolean sameSense,
219 StepToTopoDS_Tool& aTool,
220 StepToTopoDS_NMTool& NMTool) {
221 done = Standard_True;
222 Handle(StepShape_EdgeLoop) EL =
223 Handle(StepShape_EdgeLoop)::DownCast(FaceBound->Bound());
225 if (aTool.IsBound(EL)) {
226 myResult = TopoDS::Wire(aTool.Find(EL));
227 myError = StepToTopoDS_TranslateEdgeLoopDone;
228 done = Standard_True;
231 Standard_Integer modepcurve = Interface_Static::IVal("read.surfacecurve.mode");
232 // 0,1 : suivre le code, 2 : ne prendre que pcurve, 3 : ne prendre que C3D
235 Handle(Transfer_TransientProcess) TP = aTool.TransientProcess();
237 Standard_Real preci = Precision();
242 // Standard_Real U1,U2, U1a, U1b, U2a, U2b;
244 Standard_Boolean isSeam, isLikeSeam;
246 Handle(StepShape_Edge) StepEdge, StepEdge1;
247 Handle(StepShape_OrientedEdge) OrEdge1, OrEdge2;
248 Handle(StepGeom_Curve) StepCurve, StepCurve1, StepCurve2;
249 // Handle(StepGeom_Pcurve) StepPCurve, StepPCurve1, StepPCurve2;
250 Handle(StepRepr_DefinitionalRepresentation) DRI, Dri1, Dri2;
252 Handle(Geom2d_Curve) C2d, C2d1, C2d2, WhichC2d1, WhichC2d2;
253 // unused gp_Pnt Pdeb, Pmil, Pfin, pV1, pV2;
255 TopoDS_Edge suspectE; //:f1, degEdge;
257 Standard_Integer j, NbEdge = EL->NbEdgeList();
259 TP->AddWarning(EL,"Wire not done. EdgeLoop does not contain edges.");
260 done = Standard_False;
264 // default value set as Standard_True (if not correct see logic of algorithm).
265 Standard_Boolean hasPcurve = Standard_True;
266 Standard_Boolean isPlane = GeomSurf->IsKind(STANDARD_TYPE(Geom_Plane));
267 Handle(Geom_Surface) ConvSurf = GeomSurf;
268 if (GeomSurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
269 Handle(Geom_RectangularTrimmedSurface) theRTS =
270 Handle(Geom_RectangularTrimmedSurface)::DownCast(GeomSurf);
271 ConvSurf = theRTS->BasisSurface();
274 aTool.ComputePCurve(Standard_False);
276 // What is the Wire Orientation
277 Standard_Boolean ForwardWire = FaceBound->Orientation();
279 // --- Initialize target Wire ---
283 // Standard_Integer lastpcurve = 0;
285 // -----------------------------------------------
286 // Preparation : Make Vertices + Curves3d
287 // Hence, a closed curve limited by distinct vertices
288 // will give a unique vertex (if same coords)
290 // In addition : detect shared PCurve (cf SYRKO)
291 // This case may not be processed, PCurves has to be recomputed from scratch
292 // -----------------------------------------------
293 // Standard_Integer theSame = 1; //gka 15.12.98
295 for (j=1; j<=NbEdge; j++ ) {
296 OrEdge1 = EL->EdgeListValue(j);
297 StepEdge = OrEdge1->EdgeElement();
298 // if(j>1 && StepEdge == StepEdge1) theSame++; //gka 15.12.98
299 StepEdge1 = StepEdge; //
300 Handle(StepShape_EdgeCurve) EC = Handle(StepShape_EdgeCurve)::DownCast(StepEdge);
301 Handle(StepGeom_Curve) C = EC->EdgeGeometry();
303 if (C->IsKind(STANDARD_TYPE(StepGeom_SurfaceCurve))) {
304 Handle(StepGeom_SurfaceCurve) Sc = Handle(StepGeom_SurfaceCurve)::DownCast(C);
306 // if (modepcurve != 3) {
307 // lastpcurve = StepToTopoDS_GeometricTool::PCurve (Sc,StepSurf,StepPCurve1);
308 // if (StepPCurve1 == StepPCurve) modepcurve = -1;
309 // StepPCurve = StepPCurve1;
313 //// else if (C->IsKind(STANDARD_TYPE(StepGeom_Polyline))) { }
314 // else if (C->IsKind(STANDARD_TYPE(StepGeom_Pcurve))) {
315 // if (modepcurve != 3) {
316 // if (C == StepPCurve) modepcurve = -1;
317 // StepPCurve = Handle(StepGeom_Pcurve)::DownCast(C);
320 Handle(Geom_Curve) C1;
322 C1 = Handle(Geom_Curve)::DownCast (TP->FindTransient(C));
324 if (StepToGeom_MakeCurve::Convert(C,C1))
325 TP->BindTransient (C,C1);
329 Handle(StepShape_Vertex) Vstart, Vend;
330 if (EC->SameSense()) {
331 Vstart = EC->EdgeStart();
332 Vend = EC->EdgeEnd();
335 Vend = EC->EdgeStart();
336 Vstart = EC->EdgeEnd();
339 Standard_Boolean istV = aTool.IsBound(Vstart);
340 Standard_Boolean iseV = aTool.IsBound(Vend);
341 TopoDS_Vertex V1, V2;
342 StepToTopoDS_TranslateVertex myTranVertex1(Vstart, aTool, NMTool);
343 StepToTopoDS_TranslateVertex myTranVertex2(Vend, aTool, NMTool);
345 if (myTranVertex1.IsDone()) {
346 V1 = TopoDS::Vertex(myTranVertex1.Value());
348 // if (Vend == Vstart) { cas normal deja assure par aTool
349 // aTool.Bind (Vend,V1);
352 if (myTranVertex2.IsDone()) {
353 V2 = TopoDS::Vertex(myTranVertex2.Value());
354 gp_Pnt p1 = BRep_Tool::Pnt(V1);
355 gp_Pnt p2 = BRep_Tool::Pnt(V2);
356 if (p1.Distance(p2) <= Precision::Confusion() ) { //:S4136: preci) {
357 Standard_Boolean Fixed = Standard_True;
358 if(!iseV) aTool.Bind(Vend,V1); //gka 21.08.1998 bug PRO7656
359 else if(!istV) aTool.Bind (Vstart,V2);
360 else aTool.Bind (Vend,V1);
361 //Fixed = Standard_False;
362 //aTool.Bind (Vend,V1);
363 if (!C1.IsNull() && !C1->IsClosed() && Fixed)
364 TP->AddWarning(EL->EdgeListValue(j),
365 "Vertex of same coordinates, set confused");
369 // if (NbEdge!=1 && theSame == NbEdge) {
370 // TP->AddWarning(EL,"Wire was ignored. All edges are the same.");
371 // done = Standard_False;
374 // Fixed=Standard_True;
375 // if (modepcurve == -1) {
377 // TP->AddWarning(EL,"Shared Pcurve not allowed, Pcurves are recomputed");
380 //:f6 abv 29 Apr 98: BUC50070 #3815: make sure that each two edges are
381 // connected by the same vertex; else check that vertices confuse
382 // and make it be one vertex
383 // NOTE: this is done only for the case if at least one of edges
384 // was not yet translated; else nothing will help
385 for (j=1; j<=NbEdge; j++ ) {
386 OrEdge1 = EL->EdgeListValue ( j );
387 OrEdge2 = EL->EdgeListValue ( j < NbEdge ? j + 1 : 1 );
388 Handle(StepShape_EdgeCurve) EC1 =
389 Handle(StepShape_EdgeCurve)::DownCast ( OrEdge1->EdgeElement() );
390 Handle(StepShape_EdgeCurve) EC2 =
391 Handle(StepShape_EdgeCurve)::DownCast ( OrEdge2->EdgeElement() );
393 Handle(StepShape_Vertex) Vs1, Vs2,Vs11,Vs22;
394 Vs1 = ( OrEdge1->Orientation() ? EC1->EdgeEnd() : EC1->EdgeStart() );
395 Vs2 = ( OrEdge2->Orientation() ? EC2->EdgeStart() : EC2->EdgeEnd() );
397 Vs11 = ( OrEdge1->Orientation() ? EC1->EdgeStart() : EC1->EdgeEnd());
398 Vs22 = ( OrEdge2->Orientation() ? EC2->EdgeEnd() : EC2->EdgeStart() );
400 if((Vs1 == Vs2) || (Vs1 == Vs22) || (Vs2 == Vs11) || (Vs22 == Vs11)) continue;
401 //?? if ( Vs1.IsSame(Vs2) ) continue; // OK
403 StepToTopoDS_TranslateVertex myTranVertex1 (Vs1, aTool, NMTool);
404 StepToTopoDS_TranslateVertex myTranVertex2 (Vs2, aTool, NMTool);
406 TopoDS_Vertex V1, V2;
407 if ( myTranVertex1.IsDone() )
408 V1 = TopoDS::Vertex ( myTranVertex1.Value() );
409 if ( myTranVertex2.IsDone() )
410 V2 = TopoDS::Vertex ( myTranVertex2.Value() );
411 if ( V1.IsNull() || V2.IsNull() ) continue; // not treated
412 if ( V1.IsSame(V2) ) continue; // OK
414 gp_Pnt p1 = BRep_Tool::Pnt(V1);
415 gp_Pnt p2 = BRep_Tool::Pnt(V2);
416 Standard_Boolean locFixed = Standard_True;
417 if (p1.Distance(p2) <= preci) {
418 if ( ! aTool.IsBound ( EC1 ) ) aTool.Bind ( Vs1, V2 );
419 else if ( ! aTool.IsBound ( EC2 ) ) aTool.Bind ( Vs2, V1 );
420 else locFixed = Standard_False;
422 else locFixed = Standard_False;
423 if ( locFixed ) TP->AddWarning(EL,"Adjacent edges do not have common vertex; set confused");
424 else TP->AddWarning(EL,"Adjacent edges are not connected");
427 // -----------------------------------------------
428 // Iteration on each Oriented Edge of the EdgeLoop
429 // -----------------------------------------------
431 for (j=1; j<=NbEdge; j++ ) {
433 Standard_Boolean ThereIsLikeSeam = Standard_False;
436 cout << " Processing Edge :" << j << endl;
439 OrEdge1 = EL->EdgeListValue(j);
440 StepEdge = OrEdge1->EdgeElement();
441 Handle(StepShape_EdgeCurve) EC = Handle(StepShape_EdgeCurve)::DownCast(StepEdge);
447 StepToTopoDS_TranslateEdge myTranEdge;
449 myTranEdge.SetPrecision(preci);
450 myTranEdge.SetMaxTol(MaxTol());
451 myTranEdge.Init(OrEdge1, aTool, NMTool);
453 if (myTranEdge.IsDone()) {
455 E = TopoDS::Edge(myTranEdge.Value());
456 if (E.IsNull()) continue; // NULL, on saute
458 Handle(StepGeom_Curve) C = EC->EdgeGeometry();
460 if (OrEdge1->Orientation() && EC->SameSense())
461 E.Orientation(TopAbs_FORWARD);
462 else if (!OrEdge1->Orientation() && !EC->SameSense())
463 E.Orientation(TopAbs_FORWARD);
464 else E.Orientation(TopAbs_REVERSED);
466 isSeam = isLikeSeam = Standard_False;
468 // ------------------------------------------
469 // Map the StepEdge parametric representation
470 // ------------------------------------------
472 // --------------------------------------------
473 // CASE 1 : The Edge Geometry is of Pcurve Type
474 // --------------------------------------------
477 aTool.ComputePCurve(Standard_True);
478 hasPcurve = Standard_False;
480 else if (C->IsKind(STANDARD_TYPE(StepGeom_Pcurve))) {
481 Handle(StepGeom_Pcurve) StepPCurve = Handle(StepGeom_Pcurve)::DownCast(C);
482 C2d = myTranEdge.MakePCurve (StepPCurve,ConvSurf);
484 aTool.AddContinuity (C2d);
487 // -----------------------------------------
488 // CASE 2 : The curve is a SurfaceCurve i.e.
489 // - a 3D Curve (mandatory)
490 // - 2 PCurveOrSurface
491 // If modepcurve = 3, PCurve are ignored here
492 // -----------------------------------------
494 else if (modepcurve == 3) {
495 aTool.ComputePCurve(Standard_True);
496 hasPcurve = Standard_False;
498 else if (C->IsKind(STANDARD_TYPE(StepGeom_SurfaceCurve)) ) {
499 // recouvre les cas SeamCurve et IntersectionCurve
501 Handle(StepGeom_SurfaceCurve) SurfCurve =
502 Handle(StepGeom_SurfaceCurve)::DownCast(C);
504 Handle(StepGeom_Pcurve) StepPCurve, StepPCurve1, StepPCurve2;
505 Standard_Integer lastpcurve = StepToTopoDS_GeometricTool::PCurve(SurfCurve,StepSurf,StepPCurve,0);
506 hasPcurve = !StepPCurve.IsNull();
508 // De toute facon, on recalcule
510 if (isPlane) hasPcurve = Standard_False;
512 // -------------------------------------------
513 // --- Special Mapping Cases : ---
514 // --- the SurfaceCurve is a SeamCurve ---
515 // --- or is like a seam curve ---
516 // --- (see CATIA cylinder) ---
517 // -------------------------------------------
518 isLikeSeam = StepToTopoDS_GeometricTool::IsLikeSeam(SurfCurve,StepSurf,StepEdge,EL);
520 isSeam = StepToTopoDS_GeometricTool::IsSeamCurve(SurfCurve, StepSurf,StepEdge, EL);
522 if (isSeam || isLikeSeam) {
523 // isLikeSeam = Two faces on the same Surface
524 StepPCurve1 = SurfCurve->AssociatedGeometryValue(1).Pcurve();
525 StepPCurve2 = SurfCurve->AssociatedGeometryValue(2).Pcurve();
526 if (StepPCurve1.IsNull() || StepPCurve2.IsNull()) hasPcurve = Standard_False; //smh : BUC60810
528 C2d1 = myTranEdge.MakePCurve (StepPCurve1,ConvSurf);
529 C2d2 = myTranEdge.MakePCurve (StepPCurve2,ConvSurf);
530 hasPcurve = (!C2d1.IsNull() && !C2d2.IsNull());
535 ThereIsLikeSeam = Standard_True;
536 hasPcurve = Standard_True;
539 else if (hasPcurve) {
540 // GeometricTool : Pcurve a retourne StepPCurve
541 while (lastpcurve > 0) {
542 C2d1 = myTranEdge.MakePCurve (StepPCurve,ConvSurf);
544 hasPcurve = Standard_False;
548 lastpcurve = StepToTopoDS_GeometricTool::PCurve(SurfCurve,StepSurf,StepPCurve,lastpcurve);
550 aTool.AddContinuity (C2d);
554 // The edge geometry has no 2D representation
555 aTool.ComputePCurve(Standard_True);
559 // ----------------------------------------------------------
560 // CASE 3 : The EdgeCurve Geometry is not a Pcurve
561 // nor a SurfaceCurve (i.e. it is a single 3D curve)
562 // ----------------------------------------------------------
565 aTool.ComputePCurve(Standard_True);
566 hasPcurve = Standard_False;
569 // ----------------------------------
570 // update the edge with the pcurve(s)
571 // ----------------------------------
573 if (hasPcurve && (isSeam || ThereIsLikeSeam)) {
575 // -----------------------------------------------------------
576 // The Edge is a Seam Edge : The pcurve wich is FORWARD has to
578 // -----------------------------------------------------------
580 if ((!C2d1.IsNull()) && (!C2d2.IsNull())) {
581 TopAbs_Orientation CumulO, EdgeO, WireO, FaceO;
582 EdgeO = E.Orientation();
583 if (ForwardWire) WireO = TopAbs_FORWARD;
584 else WireO = TopAbs_REVERSED;
585 if (sameSense) FaceO = TopAbs_FORWARD;
586 else FaceO = TopAbs_REVERSED;
588 CumulO = TopAbs::Compose(EdgeO, WireO);
589 CumulO = TopAbs::Compose(CumulO, FaceO);
591 Standard_Boolean ForwardEdge = (CumulO == TopAbs_FORWARD);
593 // if(!ThereIsLikeSeam) ForwardEdge = Standard_True;
594 Standard_Integer forwardPC =
595 ShapeAnalysis_Curve().SelectForwardSeam (C2d1,C2d2);
596 if (forwardPC == 0) {
597 TP->AddFail(StepEdge," Seam curve not mapped");
598 done = Standard_False;
599 myError = StepToTopoDS_TranslateEdgeLoopOther;
602 else if (!ForwardEdge) forwardPC = 3 - forwardPC; // inverser 1-2
604 if (forwardPC == 1) {
606 // When the edge is a Seam, it is better to find the topological
607 // trimming right now.
608 // Remarque : pour bien faire, il faudrait, si necessaire, recalculer
609 // les trois courbes de maniere a ce qu`elles soient
610 // immediatement Same Range et Same Parameter.
611 B.UpdateEdge(E, C2d1, C2d2, Face, 0.);
612 //:S4136 FindParameter(C2d1, C2d2, E, Face, preci);
615 B.UpdateEdge(E, C2d1, Face, 0.); //preci
619 // When the edge is a Seam, it is better to find the topological
620 // trimming right now.
621 B.UpdateEdge(E, C2d2, C2d1, Face, 0.);
622 //:S4136 FindParameter(C2d1, C2d2, E, Face, preci);
625 B.UpdateEdge(E, C2d2, Face, 0.);
629 TP->AddFail(StepEdge," Seam curve not mapped");
630 done = Standard_False;
631 myError = StepToTopoDS_TranslateEdgeLoopOther;
637 // ---------------------------
638 // The Edge is a "normal" edge
639 // ---------------------------
642 if ( !C2d.IsNull() && !isLikeSeam ) {
643 B.UpdateEdge(E, C2d, Face, 0.);
646 TP->AddFail(StepEdge," Edge: Trimming of 2D curve failed");
647 // cout << "2D curve type : " << C2d->DynamicType() << endl;
648 done = Standard_False;
649 myError = StepToTopoDS_TranslateEdgeLoopOther;
656 // B.Add(W,E); -- DABORD regarder degeneree manquante !!!
659 TP->AddFail(StepEdge," an Edge not mapped");
660 done = Standard_False;
661 myError = StepToTopoDS_TranslateEdgeLoopOther;
665 else { // The Edge is Not mapped => switch to next wire ?
666 TP->AddFail(StepEdge," an Edge not mapped");
667 done = Standard_False;
668 myError = StepToTopoDS_TranslateEdgeLoopOther;
672 if (done) B.Add (W,E); // on le fait ici. Sauf si erreur rencontree ... !
674 Handle(StepShape_Vertex) Vs1, Vs2;
675 Vs1 = StepEdge->EdgeStart();
676 Vs2 = StepEdge->EdgeEnd();
677 if(!Vs1.IsNull() && !Vs2.IsNull() && Vs1==Vs2) {
678 done = Standard_True;
679 TP->AddFail(EL," Edge with equal vertices failed, scipped");
684 // The EdgeLoop is binded in the Wire
687 TP->AddFail(EL,"At least one edge failed : wire not done");
690 W.Closed (BRep_Tool::IsClosed (W));
693 // ----------------------------------------------
694 // Computes the 2D parameter of Vertices on Edges
695 // ----------------------------------------------
696 //pdn compute parameter of Vertices using progecting
697 if (!aTool.ComputePCurve())
698 for (TopoDS_Iterator EdgeIt(W);EdgeIt.More();EdgeIt.Next()){
699 TopoDS_Edge edge = TopoDS::Edge(EdgeIt.Value());
700 Handle(ShapeFix_EdgeProjAux) myEdgePro = ShapeAlgo::AlgoContainer()->ToolContainer()->EdgeProjAux();
701 myEdgePro->Init (Face, edge);
702 myEdgePro->Compute(preci);
703 if (myEdgePro->IsFirstDone() && myEdgePro->IsLastDone()) {
704 if (Abs (myEdgePro->FirstParam() - myEdgePro->LastParam()) < Precision::PConfusion())
706 B.Range(edge, Face,myEdgePro->FirstParam(), myEdgePro->LastParam());
709 RemoveSinglePCurve(edge, Face);
711 cout <<"Removing after prj"<<endl;
717 myError = StepToTopoDS_TranslateEdgeLoopDone;
718 done = Standard_True;
719 // Check des PCurves SYSTEMATIQUE, s il n y en a que quelques unes
720 // if (isPlane) RemovePCurves (W, Face);
721 // else CheckPCurves (W, Face);
722 CheckPCurves (W, Face,isPlane,preci);
724 // --------------------------------------------
725 // Control the UVLoop (Closed and Head To Tail)
726 // --------------------------------------------
728 // StepToTopoDS_GeometricToolError tError =
729 // StepToTopoDS_GeometricTool::CloseUV(W, Face, aTool);
730 // if(tError != StepToTopoDS_GeometricToolDone) {
731 // TP->AddWarning(StepEdge,StepToTopoDS::DecodeGeometricToolError(tError));
737 // ============================================================================
739 // Purpose : Return the mapped Shape
740 // ============================================================================
742 const TopoDS_Shape& StepToTopoDS_TranslateEdgeLoop::Value() const
744 StdFail_NotDone_Raise_if(!done,"");
748 // ============================================================================
750 // Purpose : Return the TranslateEdgeLoop error
751 // ============================================================================
753 StepToTopoDS_TranslateEdgeLoopError StepToTopoDS_TranslateEdgeLoop::Error() const