diff --git a/src/BRepBndLib/BRepBndLib.cxx b/src/BRepBndLib/BRepBndLib.cxx index 5d015da737..a225c55540 100644 --- a/src/BRepBndLib/BRepBndLib.cxx +++ b/src/BRepBndLib/BRepBndLib.cxx @@ -306,9 +306,13 @@ void BRepBndLib::AddOptimal(const TopoDS_Shape& S, Bnd_Box& B, Tol); } } - Standard_Real xmin, ymin, zmin, xmax, ymax, zmax; - aLocBox.Get(xmin, ymin, zmin, xmax, ymax, zmax); - B.Update(xmin, ymin, zmin, xmax, ymax, zmax); + + if (!aLocBox.IsVoid()) + { + Standard_Real xmin, ymin, zmin, xmax, ymax, zmax; + aLocBox.Get(xmin, ymin, zmin, xmax, ymax, zmax); + B.Update(xmin, ymin, zmin, xmax, ymax, zmax); + } } } } @@ -703,6 +707,16 @@ void AdjustFaceBox(const BRepAdaptor_Surface& BS, Bnd_Box& FaceBox, const Bnd_Box& EdgeBox, const Standard_Real Tol) { + if (EdgeBox.IsVoid()) + { + return; + } + if (FaceBox.IsVoid()) + { + FaceBox = EdgeBox; + return; + } + Standard_Real fxmin, fymin, fzmin, fxmax, fymax, fzmax; Standard_Real exmin, eymin, ezmin, exmax, eymax, ezmax; // diff --git a/tests/bugs/modalg_7/optimal_bndbox_exception b/tests/bugs/modalg_7/optimal_bndbox_exception new file mode 100644 index 0000000000..4126d3a869 --- /dev/null +++ b/tests/bugs/modalg_7/optimal_bndbox_exception @@ -0,0 +1,93 @@ +puts "========" +puts "0032236: Modeling Algorithms - E x c e p t i o n on calculation optimal bounding box" +puts "========" +puts "" + +set aShapeData " +DBRep_DrawableShape + +CASCADE Topology V1, (c) Matra-Datavision +Locations 0 +Curve2ds 4 +1 -1.3333333333333335 0 0 1 +1 0 -1.6666666666666667 1 0 +1 1.6666666666666665 0 0 1 +1 0 1.3333333333333333 1 0 +Curves 0 +Polygon3D 0 +PolygonOnTriangulations 0 +Surfaces 1 +9 0 0 0 0 3 3 4 4 2 2 0 3 1.9999999999999998 0 1.6666666666666665 1.9999999999999998 0 0.3333333333333332 1.9999999999999996 0 -0.99999999999999989 2 +0 2.9999999999999991 0.66666666666666718 0 1.6666666666666659 0.66666666666666741 0 0.3333333333333332 0.66666666666666663 0 -0.99999999999999956 0.66666666666666663 +0 3.0000000000000009 -0.66666666666666718 0 1.6666666666666676 -0.66666666666666752 0 0.33333333333333331 -0.66666666666666652 0 -1.0000000000000002 -0.66666666666666685 +0 3.0000000000000004 -2 0 1.6666666666666667 -2 0 0.33333333333333326 -1.9999999999999996 0 -1 -2 + +-1.3333333333333335 4 +2.6666666666666665 4 + +-2.666666666666667 4 +1.3333333333333333 4 + +Triangulations 0 + +TShapes 8 +Ve +4.000004 +0 -1 -1 +0 0 + +0101101 +* +Ed + 4.000004 1 1 1 +2 1 1 0 -1.66666666666667 1.33333333333333 +0 + +0101000 ++8 0 -8 0 * +Ed + 4.000004 1 1 1 +2 2 1 0 -1.33333333333333 1.66666666666667 +0 + +0101000 ++8 0 -8 0 * +Ed + 4.000004 1 1 1 +2 3 1 0 -1.66666666666667 1.33333333333333 +0 + +0101000 ++8 0 -8 0 * +Ed + 4.000004 1 1 1 +2 4 1 0 -1.33333333333333 1.66666666666667 +0 + +0101000 ++8 0 -8 0 * +Wi + +0101100 +-7 0 +6 0 +5 0 -4 0 * +Fa +0 1e-07 1 0 + +0101000 ++3 0 * +Sh + +1101000 ++2 0 * + ++1 0 +" + +set aFile [open "$imagedir/${casename}.brep" wb] +puts $aFile $aShapeData +close $aFile + +restore "$imagedir/${casename}.brep" aShape +bounding -optimal aShape + +file delete "$imagedir/${casename}.brep"