0031984: Modeling Algorithms - Sweep crashes if Bi-normal is given IR-2021-04-16 WEEK-15
authorjgv <jgv@opencascade.com>
Tue, 13 Apr 2021 13:03:21 +0000 (16:03 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 16 Apr 2021 15:29:29 +0000 (18:29 +0300)
Small modification in BRepFill_Sweep: to avoid exception, return status NotDone if construction of pipe surface fails.

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

index 8970c4b..1eba8db 100644 (file)
@@ -2969,13 +2969,25 @@ void BRepFill_Sweep::Build(TopTools_MapOfShape& ReversedEdges,
     // Construction of the shell
     TopoDS_Shell shell;
     B.MakeShell(shell);
+    Standard_Integer aNbFaces = 0;
     for (ipath=1; ipath<=NbPath; ipath++) 
-      for (isec=1; isec <=NbLaw; isec++) {
-      const TopoDS_Shape& face = myFaces->Value(isec, ipath);
+      for (isec=1; isec <=NbLaw; isec++)
+      {
+        const TopoDS_Shape& face = myFaces->Value(isec, ipath);
        if (!face.IsNull() && 
-           (face.ShapeType() == TopAbs_FACE) ) B.Add(shell, face);
+           (face.ShapeType() == TopAbs_FACE) )
+        {
+          B.Add(shell, face);
+          aNbFaces++;
+        }
       }
 
+    if (aNbFaces == 0)
+    {
+      isDone = Standard_False;
+      return;
+    }
+
     TopTools_ListIteratorOfListOfShape It(myAuxShape);
     for (; It.More(); It.Next()) {
        const TopoDS_Shape& face = It.Value();
diff --git a/tests/bugs/modalg_7/bug31984 b/tests/bugs/modalg_7/bug31984
new file mode 100644 (file)
index 0000000..fa1a551
--- /dev/null
@@ -0,0 +1,12 @@
+puts "=============================================="
+puts " 0031984: Sweep crashes if Bi-normal is given"
+puts "=============================================="
+puts ""
+
+restore [locate_data_file bug31984.brep] a
+explode a
+
+mksweep a_1
+addsweep a_2
+setsweep -CN 0 0 1
+buildsweep result