From a53d3975c92735ce1d211587d26d677570617dd8 Mon Sep 17 00:00:00 2001 From: jgv Date: Thu, 5 Sep 2019 15:31:15 +0300 Subject: [PATCH] 0023380: BRepOffsetAPI_MakeFilling fails and leaves boundary faces with high tolerance Avoid exception: use BRep_Builder for building wire instead of using BRepLib_MakeWire. --- src/BRepFill/BRepFill_Filling.cxx | 37 ++++++++++++++++++++++--------- tests/bugs/modalg_7/bug23380 | 25 +++++++++++++++++++++ 2 files changed, 52 insertions(+), 10 deletions(-) create mode 100644 tests/bugs/modalg_7/bug23380 diff --git a/src/BRepFill/BRepFill_Filling.cxx b/src/BRepFill/BRepFill_Filling.cxx index 79f4006203..dbdc1e6826 100644 --- a/src/BRepFill/BRepFill_Filling.cxx +++ b/src/BRepFill/BRepFill_Filling.cxx @@ -91,31 +91,50 @@ static gp_Vec MakeFinVec( const TopoDS_Wire aWire, const TopoDS_Vertex aVertex ) static TopoDS_Wire WireFromList(TopTools_ListOfShape& Edges) { - BRepLib_MakeWire MW; + BRep_Builder BB; + TopoDS_Wire aWire; + BB.MakeWire(aWire); TopoDS_Edge anEdge = TopoDS::Edge(Edges.First()); - MW.Add(anEdge); + BB.Add(aWire, anEdge); Edges.RemoveFirst(); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anEdge, V1, V2, Standard_True); //with orientation + while (!Edges.IsEmpty()) { - TopoDS_Wire CurWire = MW.Wire(); - TopoDS_Vertex V1, V2; - TopExp::Vertices(CurWire, V1, V2); TopTools_ListIteratorOfListOfShape itl(Edges); for (; itl.More(); itl.Next()) { anEdge = TopoDS::Edge(itl.Value()); TopoDS_Vertex V3, V4; - TopExp::Vertices(anEdge, V3, V4); + TopExp::Vertices(anEdge, V3, V4, Standard_True); //with orientation if (V1.IsSame(V3) || V1.IsSame(V4) || V2.IsSame(V3) || V2.IsSame(V4)) + { + if (V1.IsSame(V3)) + { + anEdge.Reverse(); + V1 = V4; + } + else if (V1.IsSame(V4)) + V1 = V3; + else if (V2.IsSame(V3)) + V2 = V4; + else + { + anEdge.Reverse(); + V2 = V3; + } break; + } } - MW.Add(anEdge); + BB.Add(aWire, anEdge); Edges.Remove(itl); } - return (MW.Wire()); + aWire.Closed(Standard_True); + return aWire; } //======================================================================= @@ -707,8 +726,6 @@ void BRepFill_Filling::Build() } TopoDS_Wire FinalWire = WireFromList(FinalEdges); - if (!(FinalWire.Closed())) - throw Standard_Failure("Wire is not closed"); myFace = BRepLib_MakeFace( Surface, FinalWire ); } diff --git a/tests/bugs/modalg_7/bug23380 b/tests/bugs/modalg_7/bug23380 new file mode 100644 index 0000000000..89ef3793b7 --- /dev/null +++ b/tests/bugs/modalg_7/bug23380 @@ -0,0 +1,25 @@ +puts "=======================================================================================" +puts "OCC23380: BRepOffsetAPI_MakeFilling fails and leaves boundary faces with high tolerance" +puts "=======================================================================================" +puts "" + +brestore [locate_data_file bug23380.brep] b + +explode b +renamevar b_5 d +renamevar b_1 f +renamevar b_4 i +explode f E +explode d E +tolerance f +donly f_1 d_3 b_2 b_3 + +filling result 4 0 0 i f_1 f 1 d_3 d 1 b_2 0 b_3 0 + +checknbshapes result -face 1 -wire 1 -edge 4 -vertex 4 + +set tolres [checkmaxtol result] + +if { ${tolres} > 230.} { + puts "Error: bad tolerance of result" +}