0023380: BRepOffsetAPI_MakeFilling fails and leaves boundary faces with high tolerance
authorjgv <jgv@opencascade.com>
Thu, 5 Sep 2019 12:31:15 +0000 (15:31 +0300)
committerbugmaster <bugmaster@opencascade.com>
Mon, 9 Sep 2019 16:27:59 +0000 (19:27 +0300)
Avoid exception: use BRep_Builder for building wire instead of using BRepLib_MakeWire.

src/BRepFill/BRepFill_Filling.cxx
tests/bugs/modalg_7/bug23380 [new file with mode: 0644]

index 79f4006..dbdc1e6 100644 (file)
@@ -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 (file)
index 0000000..89ef379
--- /dev/null
@@ -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"
+}