From cb6a45e3182e3b03ea1616411c26251a0c57b30b Mon Sep 17 00:00:00 2001 From: jgv Date: Fri, 12 Oct 2018 13:02:34 +0300 Subject: [PATCH] 0030204: BRepOffsetAPI_MakePipeShell crash Add protection from type mismatch while ensuring Same Parameter on U-edges --- src/BRepFill/BRepFill_Sweep.cxx | 15 ++++++++++++--- tests/bugs/modalg_7/bug30204_1 | 17 +++++++++++++++++ tests/bugs/modalg_7/bug30204_2 | 26 ++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 tests/bugs/modalg_7/bug30204_1 create mode 100644 tests/bugs/modalg_7/bug30204_2 diff --git a/src/BRepFill/BRepFill_Sweep.cxx b/src/BRepFill/BRepFill_Sweep.cxx index 578ad6cfe7..d5e9439330 100644 --- a/src/BRepFill/BRepFill_Sweep.cxx +++ b/src/BRepFill/BRepFill_Sweep.cxx @@ -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 index 0000000000..e4da5dc033 --- /dev/null +++ b/tests/bugs/modalg_7/bug30204_1 @@ -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 index 0000000000..767593caab --- /dev/null +++ b/tests/bugs/modalg_7/bug30204_2 @@ -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