]> OCCT Git - occt.git/commitdiff
0033156: Modeling Algorithms - Planar face creation problem
authorastromko <astromko@opencascade.com>
Fri, 17 May 2024 08:55:20 +0000 (08:55 +0000)
committerdpasukhi <dpasukhi@opencascade.com>
Sun, 19 May 2024 15:03:09 +0000 (16:03 +0100)
Implemented suggested patch to avoid unnecessary replacement of a wire.
Added the second test case.

src/BRepLib/BRepLib_MakeFace.cxx
tests/bugs/modalg_8/bug33156_2 [new file with mode: 0644]
tests/mkface/mkplane/bug33156 [deleted file]

index 632372c33bb1509de82fa1cfa13cbe652be1e9ed..ce7340bfe58bedad604c1dd290cc4fe0c2aa5775 100644 (file)
@@ -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 (file)
index 0000000..aa7c53d
--- /dev/null
@@ -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 (file)
index b13453f..0000000
+++ /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