From 2328cae25d7a9452bdc6f9c6e1392e827d47f186 Mon Sep 17 00:00:00 2001 From: kgv Date: Tue, 19 Mar 2019 11:24:21 +0300 Subject: [PATCH] 0030593: Modeling Algorithms - ShapeUpgrade_ShapeDivide::Perform() throws Standard_NoMoreObject Added missing TopExp_Explorer::More() checks to ShapeUpgrade_ShapeDivide::Perform() and BRepCheck_Analyzer::Perform(). --- src/BRepCheck/BRepCheck_Analyzer.cxx | 1 - src/ShapeUpgrade/ShapeUpgrade_ShapeDivide.cxx | 78 +++++++++++-------- 2 files changed, 46 insertions(+), 33 deletions(-) diff --git a/src/BRepCheck/BRepCheck_Analyzer.cxx b/src/BRepCheck/BRepCheck_Analyzer.cxx index 869eb7cbd7..a10ce072a1 100644 --- a/src/BRepCheck/BRepCheck_Analyzer.cxx +++ b/src/BRepCheck/BRepCheck_Analyzer.cxx @@ -147,7 +147,6 @@ void BRepCheck_Analyzer::Perform(const TopoDS_Shape& S) if ( ! aRes.IsNull() ) { - aRes->SetFailStatus(exp.Current()); aRes->SetFailStatus(S); } } diff --git a/src/ShapeUpgrade/ShapeUpgrade_ShapeDivide.cxx b/src/ShapeUpgrade/ShapeUpgrade_ShapeDivide.cxx index 659a4aa5a8..a271dbdd7c 100644 --- a/src/ShapeUpgrade/ShapeUpgrade_ShapeDivide.cxx +++ b/src/ShapeUpgrade/ShapeUpgrade_ShapeDivide.cxx @@ -193,41 +193,55 @@ Standard_Boolean ShapeUpgrade_ShapeDivide::Perform(const Standard_Boolean newCon } Message_Msg doneMsg = GetFaceMsg(); - for(TopExp_Explorer exp(myShape,TopAbs_FACE); exp.More(); exp.Next()) { -//smh#8 + for (TopExp_Explorer exp (myShape,TopAbs_FACE); exp.More(); exp.Next()) + { TopoDS_Shape tmpF = exp.Current().Oriented ( TopAbs_FORWARD ); TopoDS_Face F = TopoDS::Face (tmpF); // protection against INTERNAL shapes: cts20105a.rle TopoDS_Shape sh = myContext->Apply ( F, TopAbs_SHAPE ); - for (TopExp_Explorer exp2(sh,TopAbs_FACE); exp2.More(); exp2.Next()) { -//szv: try-catch added - try { - OCC_CATCH_SIGNALS - for (; exp2.More(); exp2.Next()) { - TopoDS_Face face = TopoDS::Face ( exp2.Current() ); - SplitFace->Init(face); - SplitFace->SetContext(myContext); - SplitFace->Perform(); - if(SplitFace->Status(ShapeExtend_FAIL)) { - myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL2 ); - } - if(SplitFace->Status(ShapeExtend_DONE)) { - myContext->Replace(face,SplitFace->Result()); - SendMsg( face, doneMsg, Message_Info ); - if(SplitFace->Status(ShapeExtend_DONE1)) - myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 ); - if(SplitFace->Status(ShapeExtend_DONE2)) - myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE2 ); - } - } - } - catch (Standard_Failure const& anException) { -#ifdef OCCT_DEBUG - cout << "\nError: Exception in ShapeUpgrade_FaceDivide::Perform(): "; - anException.Print(cout); cout << endl; -#endif - (void)anException; - myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL2 ); - } + for (TopExp_Explorer exp2 (sh,TopAbs_FACE); exp2.More(); exp2.Next()) + { + try + { + OCC_CATCH_SIGNALS + for (; exp2.More(); exp2.Next()) + { + TopoDS_Face face = TopoDS::Face (exp2.Current()); + SplitFace->Init(face); + SplitFace->SetContext(myContext); + SplitFace->Perform(); + if (SplitFace->Status (ShapeExtend_FAIL)) + { + myStatus |= ShapeExtend::EncodeStatus (ShapeExtend_FAIL2); + } + if (SplitFace->Status (ShapeExtend_DONE)) + { + myContext->Replace (face, SplitFace->Result()); + SendMsg (face, doneMsg, Message_Info); + if (SplitFace->Status (ShapeExtend_DONE1)) + { + myStatus |= ShapeExtend::EncodeStatus (ShapeExtend_DONE1); + } + if (SplitFace->Status (ShapeExtend_DONE2)) + { + myStatus |= ShapeExtend::EncodeStatus (ShapeExtend_DONE2); + } + } + } + } + catch (Standard_Failure const& anException) + { + #ifdef OCCT_DEBUG + std::cout << "\nError: Exception in ShapeUpgrade_FaceDivide::Perform(): "; + anException.Print (std::cout); std::cout << std::endl; + #endif + (void )anException; + myStatus |= ShapeExtend::EncodeStatus (ShapeExtend_FAIL2); + } + + if (!exp2.More()) + { + break; + } } } }