From: skv Date: Mon, 14 Apr 2014 15:47:25 +0000 (+0400) Subject: 0022550: [CEA 1137] "FuseCollinearEdgesWithinWire" fails on some wires X-Git-Tag: V7_4_0b1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6806d4fae5166351ee7678e87c0c1a2daddabdbe;p=modules%2Fgeom.git 0022550: [CEA 1137] "FuseCollinearEdgesWithinWire" fails on some wires --- diff --git a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx index 360b94c83..96f0bb6c6 100644 --- a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx @@ -976,10 +976,59 @@ TopoDS_Edge GEOMImpl_ShapeDriver::MakeEdgeFromWire(const TopoDS_Shape& aWire, if (concatcurve->Value(concatcurve->Lower())->Continuity()==GeomAbs_C0){ Standard_ConstructionError::Raise("Construction aborted : The given Wire has sharp bends between some Edges, no valid Edge can be built"); } - ResEdge = BRepLib_MakeEdge(concatcurve->Value(concatcurve->Lower()), - FirstVertex, LastVertex, - concatcurve->Value(concatcurve->Lower())->FirstParameter(), - concatcurve->Value(concatcurve->Lower())->LastParameter()); + + Standard_Boolean isValidEndVtx = Standard_True; + + if (closed_flag) { + // Check if closed curve is reordered. + Handle(Geom_Curve) aCurve = concatcurve->Value(concatcurve->Lower()); + Standard_Real aFPar = aCurve->FirstParameter(); + gp_Pnt aPFirst; + gp_Pnt aPntVtx = BRep_Tool::Pnt(FirstVertex); + Standard_Real aTolVtx = BRep_Tool::Tolerance(FirstVertex); + + aCurve->D0(aFPar, aPFirst); + + if (!aPFirst.IsEqual(aPntVtx, aTolVtx)) { + // The curve is reordered. Find the new first and last vertices. + TopTools_IndexedMapOfShape aMapVtx; + TopExp::MapShapes(theWire, TopAbs_VERTEX, aMapVtx); + + const Standard_Integer aNbVtx = aMapVtx.Extent(); + Standard_Integer iVtx; + + for (iVtx = 1; iVtx <= aNbVtx; iVtx++) { + const TopoDS_Vertex aVtx = TopoDS::Vertex(aMapVtx.FindKey(iVtx)); + const gp_Pnt aPnt = BRep_Tool::Pnt(aVtx); + const Standard_Real aTol = BRep_Tool::Tolerance(aVtx); + + if (aPFirst.IsEqual(aPnt, aTol)) { + // The coinsident vertex is found. + FirstVertex = aVtx; + LastVertex = aVtx; + FirstVertex.Orientation(TopAbs_FORWARD); + LastVertex.Orientation(TopAbs_REVERSED); + break; + } + } + + if (iVtx > aNbVtx) { + // It is necessary to create new vertices. + isValidEndVtx = Standard_False; + } + } + } + + if (isValidEndVtx) { + ResEdge = BRepLib_MakeEdge(concatcurve->Value(concatcurve->Lower()), + FirstVertex, LastVertex, + concatcurve->Value(concatcurve->Lower())->FirstParameter(), + concatcurve->Value(concatcurve->Lower())->LastParameter()); + } else { + ResEdge = BRepLib_MakeEdge(concatcurve->Value(concatcurve->Lower()), + concatcurve->Value(concatcurve->Lower())->FirstParameter(), + concatcurve->Value(concatcurve->Lower())->LastParameter()); + } } else {