From 87a64d53ab4714dcaa89370d3c1b47f7d378d4ad Mon Sep 17 00:00:00 2001 From: kgv Date: Fri, 19 Oct 2018 11:06:41 +0300 Subject: [PATCH] 0030269: Modeling Algorithms - unhandled Standard_NullObject within BRepBndLib::Add() Added BRep_Tool::IsGeometric() check before every BRepAdaptor_Curve::Initialize(). --- src/BRepBndLib/BRepBndLib.cxx | 19 ++++-- src/BRepBndLib/BRepBndLib_1.cxx | 29 +++++---- tests/bugs/modalg_7/bug30269 | 104 ++++++++++++++++++++++++++++++++ tests/bugs/vis/bug641 | 35 +++-------- 4 files changed, 144 insertions(+), 43 deletions(-) create mode 100644 tests/bugs/modalg_7/bug30269 diff --git a/src/BRepBndLib/BRepBndLib.cxx b/src/BRepBndLib/BRepBndLib.cxx index 0c873acf15..6aa8c2dd49 100644 --- a/src/BRepBndLib/BRepBndLib.cxx +++ b/src/BRepBndLib/BRepBndLib.cxx @@ -116,8 +116,11 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B, Standard_Boolean useTria else { for (;ex2.More();ex2.Next()) { const TopoDS_Edge& anEdge = TopoDS::Edge(ex2.Current()); - BC.Initialize(anEdge); - BndLib_Add3dCurve::Add(BC, BRep_Tool::Tolerance(anEdge), B); + if (BRep_Tool::IsGeometric (anEdge)) + { + BC.Initialize (anEdge); + BndLib_Add3dCurve::Add (BC, BRep_Tool::Tolerance (anEdge), B); + } } B.Enlarge(BRep_Tool::Tolerance(F)); } @@ -198,8 +201,12 @@ void BRepBndLib::AddClose(const TopoDS_Shape& S, Bnd_Box& B) BRepAdaptor_Curve BC; for (ex.Init(S,TopAbs_EDGE); ex.More(); ex.Next()) { - BC.Initialize(TopoDS::Edge(ex.Current())); - BndLib_Add3dCurve::Add(BC,0.,B); + const TopoDS_Edge& anEdge = TopoDS::Edge (ex.Current()); + if (BRep_Tool::IsGeometric (anEdge)) + { + BC.Initialize (anEdge); + BndLib_Add3dCurve::Add(BC,0.,B); + } } // Add the vertices not in edges @@ -262,7 +269,7 @@ void BRepBndLib::AddOptimal(const TopoDS_Shape& S, Bnd_Box& B, for (;ex2.More();ex2.Next()) { Bnd_Box anEBox; const TopoDS_Edge& anE = TopoDS::Edge(ex2.Current()); - if(BRep_Tool::Degenerated(anE)) + if (BRep_Tool::Degenerated (anE) || !BRep_Tool::IsGeometric (anE)) { continue; } @@ -289,7 +296,7 @@ void BRepBndLib::AddOptimal(const TopoDS_Shape& S, Bnd_Box& B, for (;ex2.More();ex2.Next()) { Bnd_Box anEBox; const TopoDS_Edge& anE = TopoDS::Edge(ex2.Current()); - if(BRep_Tool::Degenerated(anE)) + if (BRep_Tool::Degenerated (anE) || !BRep_Tool::IsGeometric (anE)) { continue; } diff --git a/src/BRepBndLib/BRepBndLib_1.cxx b/src/BRepBndLib/BRepBndLib_1.cxx index 4eea3f20b3..4035a3b885 100644 --- a/src/BRepBndLib/BRepBndLib_1.cxx +++ b/src/BRepBndLib/BRepBndLib_1.cxx @@ -165,14 +165,17 @@ static Standard_Integer PointsForOBB(const TopoDS_Shape& theS, for(anExpE.Init(aF, TopAbs_EDGE); anExpE.More(); anExpE.Next()) { const TopoDS_Edge &anE = TopoDS::Edge(anExpE.Current()); - const BRepAdaptor_Curve anAC(anE); - if (!IsLinear(anAC)) + if (BRep_Tool::IsGeometric (anE)) { - if (!theIsTriangulationUsed) - // not linear and triangulation usage disabled - return 0; + const BRepAdaptor_Curve anAC(anE); + if (!IsLinear(anAC)) + { + if (!theIsTriangulationUsed) + // not linear and triangulation usage disabled + return 0; - break; + break; + } } } @@ -212,11 +215,15 @@ static Standard_Integer PointsForOBB(const TopoDS_Shape& theS, for(anExpE.Init(theS, TopAbs_EDGE, TopAbs_FACE); anExpE.More(); anExpE.Next()) { const TopoDS_Edge &anE = TopoDS::Edge(anExpE.Current()); - const BRepAdaptor_Curve anAC(anE); - - if (IsLinear(anAC)) - // skip linear edge as its vertices have already been added - continue; + if (BRep_Tool::IsGeometric (anE)) + { + const BRepAdaptor_Curve anAC(anE); + if (IsLinear(anAC)) + { + // skip linear edge as its vertices have already been added + continue; + } + } if (!theIsTriangulationUsed) // not linear and triangulation usage disabled diff --git a/tests/bugs/modalg_7/bug30269 b/tests/bugs/modalg_7/bug30269 new file mode 100644 index 0000000000..2a23c39d2f --- /dev/null +++ b/tests/bugs/modalg_7/bug30269 @@ -0,0 +1,104 @@ +puts "========" +puts "0030269: Modeling Algorithms - unhandled Standard_NullObject within BRepBndLib::Add()" +puts "========" +puts "" + +pload MODELING VISUALIZATION + +# sample Face with some Curve2ds missing +set aShapeData " +DBRep_DrawableShape + +CASCADE Topology V1, (c) Matra-Datavision +Locations 0 +Curve2ds 0 +Curves 2 +1 8111.3 2939 9014.2 0.23 5.2e-07 0.97 +1 9996.2 2940 8568.4 -0.229 3.64e-07 -0.97 +Polygon3D 0 +PolygonOnTriangulations 0 +Surfaces 2 +1 9056.7 2940 8807.3 1.29e-07 -1 5e-07 -1.26e-29 -5.03e-07 -1 1 1.288e-07 -6.48e-14 +1 10000 1519 8584.45 -0.97 -8.47e-08 0.23 0.23 0 0.97 -8.24e-08 1 1.95e-08 +Triangulations 0 + +TShapes 10 +Ve +1e-07 +8111.30 2940 9014.2 +0 0 + +0101101 +* +Ve +1e-07 +9996.21 2940 8568.4 +0 0 + +0101101 +* +Ed + 2.22e-16 0 0 0 +0 + +0101000 ++10 0 -9 0 * +Ve +1e-07 +8115 2940 9030 +0 0 + +0101101 +* +Ed + 1e-07 0 0 0 +1 1 0 0 16.5 +0 + +0101000 ++10 0 -7 0 * +Ve +1e-07 +10000 2940 8584.5 +0 0 + +0101101 +* +Ed + 2.22e-16 0 0 0 +0 + +0101000 ++7 0 -5 0 * +Ed + 1e-07 0 0 0 +1 2 0 -16.5 0 +4 C0 1 0 2 0 +0 + +0101000 ++5 0 -9 0 * +Wi + +0101000 +-8 0 +6 0 +4 0 +3 0 * +Fa +0 1e-07 1 0 + +0101000 +-2 0 * + +-1 4 +" + +set aFile [open "$imagedir/${casename}.brep" wb] +puts $aFile $aShapeData +close $aFile +restore "$imagedir/${casename}.brep" f +file delete "$imagedir/${casename}.brep" + +bounding f +bounding f -optimal +bounding f -obb +sprops f +vprops f diff --git a/tests/bugs/vis/bug641 b/tests/bugs/vis/bug641 index 1debf2818f..45796705e5 100755 --- a/tests/bugs/vis/bug641 +++ b/tests/bugs/vis/bug641 @@ -1,32 +1,15 @@ -puts "TODO OCC641 ALL: An exception was caught" -puts "TODO OCC641 ALL: \\*\\* Exception \\*\\*.*" -puts "TODO OCC641 ALL: Error : result shape is displayed wrongly" - puts "================" -puts "OCC641" -puts "SAM1559" +puts "OCC641 E x c e p t i o n during attemption to display shape ==>SAM1559 (#2901)" puts "================" puts "" -################################################# -## Exception during attemption to display shape ==>SAM1559 (#2901) -################################################# +pload MODELING VISUALIZATION restore [locate_data_file OCC641.brep] a - -vinit -vdisplay a +copy a m +tmirror m 0 0 0 0 1 0 +vinit View1 +vdisplay -dispMode 0 a m vfit - -copy a result - -if [catch {tmirror result 0 0 0 0 1 0 } res] { - puts "Error : function tmirror works wrongly" -} else { - if [catch { vdisplay result } res] { - puts "Error : result shape is displayed wrongly" - } - vfit -} - -checkview -screenshot -3d -path ${imagedir}/${test_image}.png - +vdump ${imagedir}/${casename}_wf.png +vdisplay -dispMode 1 a m +vdump ${imagedir}/${casename}_sh.png