From 899108205130c440303459c059a8db0b2723e176 Mon Sep 17 00:00:00 2001 From: astromko Date: Fri, 17 May 2024 08:55:20 +0000 Subject: [PATCH] 0033156: Modeling Algorithms - Planar face creation problem Implemented suggested patch to avoid unnecessary replacement of a wire. Added the second test case. --- src/BRepLib/BRepLib_MakeFace.cxx | 22 ++++++++++++++++++---- tests/bugs/modalg_8/bug33156_2 | 21 +++++++++++++++++++++ tests/mkface/mkplane/bug33156 | 10 ---------- 3 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 tests/bugs/modalg_8/bug33156_2 delete mode 100644 tests/mkface/mkplane/bug33156 diff --git a/src/BRepLib/BRepLib_MakeFace.cxx b/src/BRepLib/BRepLib_MakeFace.cxx index 632372c33b..ce7340bfe5 100644 --- a/src/BRepLib/BRepLib_MakeFace.cxx +++ b/src/BRepLib/BRepLib_MakeFace.cxx @@ -273,18 +273,32 @@ BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Wire& W, aB.MakeWire (aW); TopoDS_Wire aWForw = W; + Standard_Boolean hasDegenerated = Standard_False; 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); + if (BRep_Tool::Degenerated(aE)) + { + hasDegenerated = Standard_True; + } + else + { + aB.Add(aW, aE); + } } - aW.Orientation (W.Orientation()); // return to original orient - aW.Closed (W.Closed()); + if (hasDegenerated) + { + aW.Orientation (W.Orientation()); // return to original orient + aW.Closed (W.Closed()); + } + else + { + aW = W; + } } else { diff --git a/tests/bugs/modalg_8/bug33156_2 b/tests/bugs/modalg_8/bug33156_2 new file mode 100644 index 0000000000..aa7c53da43 --- /dev/null +++ b/tests/bugs/modalg_8/bug33156_2 @@ -0,0 +1,21 @@ +puts "=============" +puts "0033156: Modeling Algorithms - Planar face creation problem" +puts "=============" + +pload MODELING +vertex v1 0 0 0 +vertex v2 10 0 0 +vertex v3 0 10 0 + +edge e1 v1 v2 +edge e2 v2 v3 +edge e3 v3 v1 + +wire w1 e1 e2 e3 +mkplane f1 w1 1 + +set state [issubshape w1 f1] + +if { [regexp "w1 is NOT sub-shape of f1" $state] == 1 } { + puts "Error : w1 is NOT sub-shape of f1" +} diff --git a/tests/mkface/mkplane/bug33156 b/tests/mkface/mkplane/bug33156 deleted file mode 100644 index b13453f689..0000000000 --- a/tests/mkface/mkplane/bug33156 +++ /dev/null @@ -1,10 +0,0 @@ -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