diff --git a/src/BRepLib/BRepLib.cxx b/src/BRepLib/BRepLib.cxx index bac141645c..3eec408309 100644 --- a/src/BRepLib/BRepLib.cxx +++ b/src/BRepLib/BRepLib.cxx @@ -961,6 +961,9 @@ static void InternalSameParameter(const TopoDS_Shape& theSh, BRepTools_ReShape& TopExp_Explorer ex2; for(ex2.Init(curface,TopAbs_EDGE); ex2.More(); ex2.Next()){ const TopoDS_Edge& E = TopoDS::Edge(ex2.Current()); + if (BRep_Tool::Degenerated(E)) + continue; + TopoDS_Shape aNe = theReshaper.Value(E); Standard_Real aNewEtol = -1; GetEdgeTol(TopoDS::Edge(aNe), curface, aNewEtol); diff --git a/src/BRepLib/BRepLib_MakeFace.cxx b/src/BRepLib/BRepLib_MakeFace.cxx index fdbd362013..632372c33b 100644 --- a/src/BRepLib/BRepLib_MakeFace.cxx +++ b/src/BRepLib/BRepLib_MakeFace.cxx @@ -256,7 +256,7 @@ BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Wire& W, myError = BRepLib_NotPlanar; return; } - + // build the face and add the wire BRep_Builder B; myError = BRepLib_FaceDone; @@ -264,13 +264,40 @@ BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Wire& W, Standard_Real tol = Max(1.2*FS.ToleranceReached(), FS.Tolerance()); B.MakeFace(TopoDS::Face(myShape),FS.Surface(),FS.Location(),tol); - Add(W); + + TopoDS_Wire aW; + if (OnlyPlane) + { + // get rid of degenerative edges in the input wire + BRep_Builder aB; + aB.MakeWire (aW); + + TopoDS_Wire aWForw = W; + aWForw.Orientation (TopAbs_FORWARD); + TopoDS_Iterator anIter (aWForw); + for (; anIter.More(); anIter.Next()) + { + const TopoDS_Edge& aE = TopoDS::Edge (anIter.Value()); + + if (!BRep_Tool::Degenerated (aE)) + aB.Add (aW, aE); + } + + aW.Orientation (W.Orientation()); // return to original orient + aW.Closed (W.Closed()); + } + else + { + aW = W; + } + + Add (aW); // BRepLib::UpdateTolerances(myShape); // BRepLib::SameParameter(myShape, tol, Standard_True); // - if (BRep_Tool::IsClosed(W)) + if (BRep_Tool::IsClosed(aW)) CheckInside(); } diff --git a/tests/mkface/mkplane/bug33156 b/tests/mkface/mkplane/bug33156 new file mode 100644 index 0000000000..b13453f689 --- /dev/null +++ b/tests/mkface/mkplane/bug33156 @@ -0,0 +1,10 @@ +puts "=============" +puts "0033156: Modeling Algorithms - Planar face creation problem" +puts "=============" + +brestore [locate_data_file bug33156_face.brep] Face + +explode Face W +#Face_1 + +mkplane result Face_1 1