0030204: BRepOffsetAPI_MakePipeShell crash IR-2018-10-19 IR-WEEK42
authorjgv <jgv@opencascade.com>
Fri, 12 Oct 2018 10:02:34 +0000 (13:02 +0300)
committerapn <apn@opencascade.com>
Thu, 18 Oct 2018 16:10:55 +0000 (19:10 +0300)
Add protection from type mismatch while ensuring Same Parameter on U-edges

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

index 578ad6c..d5e9439 100644 (file)
@@ -3052,10 +3052,19 @@ void BRepFill_Sweep::Build(TopTools_MapOfShape& ReversedEdges,
         if (i2 > myFaces->UpperRow())
           i2 = 0;
         if (i1 != 0)
-          Face1 = TopoDS::Face(myFaces->Value(i1, jj));
+        {
+          const TopoDS_Shape& aShape1 = myFaces->Value(i1, jj);
+          if (aShape1.ShapeType() == TopAbs_FACE)
+            Face1 = TopoDS::Face(aShape1);
+        }
         if (i2 != 0)
-          Face2 = TopoDS::Face(myFaces->Value(i2, jj));
-        CorrectSameParameter(anEdge, Face1, Face2);
+        {
+          const TopoDS_Shape& aShape2 = myFaces->Value(i2, jj);
+          if (aShape2.ShapeType() == TopAbs_FACE)
+            Face2 = TopoDS::Face(aShape2);
+        }
+        if (!Face1.IsNull() && !Face2.IsNull())
+          CorrectSameParameter(anEdge, Face1, Face2);
       }
     }
 
diff --git a/tests/bugs/modalg_7/bug30204_1 b/tests/bugs/modalg_7/bug30204_1
new file mode 100644 (file)
index 0000000..e4da5dc
--- /dev/null
@@ -0,0 +1,17 @@
+puts "============"
+puts "OCC30204"
+puts "============"
+puts ""
+###################################
+# BRepOffsetAPI_MakePipeShell crash
+###################################
+
+#test only for no crash
+
+restore [locate_data_file bug30204_path.brep] path
+restore [locate_data_file bug30204_base.brep] base
+
+mksweep path
+setsweep -CN 0 1 0
+addsweep base
+buildsweep result
diff --git a/tests/bugs/modalg_7/bug30204_2 b/tests/bugs/modalg_7/bug30204_2
new file mode 100644 (file)
index 0000000..767593c
--- /dev/null
@@ -0,0 +1,26 @@
+puts "============"
+puts "OCC30204"
+puts "============"
+puts ""
+###################################
+# BRepOffsetAPI_MakePipeShell crash
+###################################
+
+restore [locate_data_file bug30204_path.brep] path
+restore [locate_data_file bug30204_base.brep] base
+
+mksweep path
+addsweep base
+buildsweep result
+
+checkshape result
+
+checknbshapes result -shell 1 -face 20 -wire 20 -edge 44 -vertex 24
+
+set tolres [checkmaxtol result]
+
+if { ${tolres} > 2.e-7} {
+   puts "Error: bad tolerance of result"
+}
+
+checkprops result -s 6851.98