]> OCCT Git - occt.git/commitdiff
0033156: Modeling Algorithms - Planar face creation problem
authorknosulko <knosulko@opencascade.com>
Fri, 28 Oct 2022 13:38:45 +0000 (16:38 +0300)
committersmoskvin <smoskvin@opencascade.com>
Sun, 4 Dec 2022 10:42:28 +0000 (13:42 +0300)
BRepLib_MakeFace::BRepLib_MakeFace: deleted degenerative edges from the input wire;
add test tests\mkface\mkplane\bug33156.

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

index bac141645cc354708eae392592baf3fbce1c1d8e..3eec4083091ef843db389c9c50fe202d94d0fef9 100644 (file)
@@ -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);
index fdbd36201316ccb6d5db1fc0a89c8d079d42a513..632372c33bb1509de82fa1cfa13cbe652be1e9ed 100644 (file)
@@ -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 (file)
index 0000000..b13453f
--- /dev/null
@@ -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