From 488c1a1fdf40284cf42cbb5e9fd910fc9b27166d Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 23 Jul 2017 15:46:57 +0200 Subject: [PATCH] handle exception thrown by BRepBuilderAPI_RefineModel --- src/Mod/Part/App/FeaturePartBoolean.cpp | 17 +++++++++++------ src/Mod/Part/App/FeaturePartCommon.cpp | 17 +++++++++++------ src/Mod/Part/App/FeaturePartFuse.cpp | 17 +++++++++++------ src/Mod/PartDesign/App/FeaturePrimitive.cpp | 11 ++++++++--- src/Mod/PartDesign/App/FeatureSketchBased.cpp | 11 ++++++++--- src/Mod/PartDesign/App/FeatureTransformed.cpp | 11 ++++++++--- 6 files changed, 57 insertions(+), 27 deletions(-) diff --git a/src/Mod/Part/App/FeaturePartBoolean.cpp b/src/Mod/Part/App/FeaturePartBoolean.cpp index 70cd415d0f..0d34375e5b 100644 --- a/src/Mod/Part/App/FeaturePartBoolean.cpp +++ b/src/Mod/Part/App/FeaturePartBoolean.cpp @@ -102,12 +102,17 @@ App::DocumentObjectExecReturn *Boolean::execute(void) history.push_back(buildHistory(*mkBool.get(), TopAbs_FACE, resShape, ToolShape)); if (hGrp->GetBool("RefineModel", false)) { - TopoDS_Shape oldShape = resShape; - BRepBuilderAPI_RefineModel mkRefine(oldShape); - resShape = mkRefine.Shape(); - ShapeHistory hist = buildHistory(mkRefine, TopAbs_FACE, resShape, oldShape); - history[0] = joinHistory(history[0], hist); - history[1] = joinHistory(history[1], hist); + try { + TopoDS_Shape oldShape = resShape; + BRepBuilderAPI_RefineModel mkRefine(oldShape); + resShape = mkRefine.Shape(); + ShapeHistory hist = buildHistory(mkRefine, TopAbs_FACE, resShape, oldShape); + history[0] = joinHistory(history[0], hist); + history[1] = joinHistory(history[1], hist); + } + catch (Standard_Failure) { + // do nothing + } } this->Shape.setValue(resShape); diff --git a/src/Mod/Part/App/FeaturePartCommon.cpp b/src/Mod/Part/App/FeaturePartCommon.cpp index ffaffc8274..8155491364 100644 --- a/src/Mod/Part/App/FeaturePartCommon.cpp +++ b/src/Mod/Part/App/FeaturePartCommon.cpp @@ -140,12 +140,17 @@ App::DocumentObjectExecReturn *MultiCommon::execute(void) } } if (hGrp->GetBool("RefineModel", false)) { - TopoDS_Shape oldShape = resShape; - BRepBuilderAPI_RefineModel mkRefine(oldShape); - resShape = mkRefine.Shape(); - ShapeHistory hist = buildHistory(mkRefine, TopAbs_FACE, resShape, oldShape); - for (std::vector::iterator jt = history.begin(); jt != history.end(); ++jt) - *jt = joinHistory(*jt, hist); + try { + TopoDS_Shape oldShape = resShape; + BRepBuilderAPI_RefineModel mkRefine(oldShape); + resShape = mkRefine.Shape(); + ShapeHistory hist = buildHistory(mkRefine, TopAbs_FACE, resShape, oldShape); + for (std::vector::iterator jt = history.begin(); jt != history.end(); ++jt) + *jt = joinHistory(*jt, hist); + } + catch (Standard_Failure) { + // do nothing + } } this->Shape.setValue(resShape); diff --git a/src/Mod/Part/App/FeaturePartFuse.cpp b/src/Mod/Part/App/FeaturePartFuse.cpp index 5df58b829e..9b711cc72d 100644 --- a/src/Mod/Part/App/FeaturePartFuse.cpp +++ b/src/Mod/Part/App/FeaturePartFuse.cpp @@ -164,12 +164,17 @@ App::DocumentObjectExecReturn *MultiFuse::execute(void) } } if (hGrp->GetBool("RefineModel", false)) { - TopoDS_Shape oldShape = resShape; - BRepBuilderAPI_RefineModel mkRefine(oldShape); - resShape = mkRefine.Shape(); - ShapeHistory hist = buildHistory(mkRefine, TopAbs_FACE, resShape, oldShape); - for (std::vector::iterator jt = history.begin(); jt != history.end(); ++jt) - *jt = joinHistory(*jt, hist); + try { + TopoDS_Shape oldShape = resShape; + BRepBuilderAPI_RefineModel mkRefine(oldShape); + resShape = mkRefine.Shape(); + ShapeHistory hist = buildHistory(mkRefine, TopAbs_FACE, resShape, oldShape); + for (std::vector::iterator jt = history.begin(); jt != history.end(); ++jt) + *jt = joinHistory(*jt, hist); + } + catch (Standard_Failure) { + // do nothing + } } this->Shape.setValue(resShape); diff --git a/src/Mod/PartDesign/App/FeaturePrimitive.cpp b/src/Mod/PartDesign/App/FeaturePrimitive.cpp index f8fdd78909..079acb8a3c 100644 --- a/src/Mod/PartDesign/App/FeaturePrimitive.cpp +++ b/src/Mod/PartDesign/App/FeaturePrimitive.cpp @@ -75,9 +75,14 @@ TopoDS_Shape FeaturePrimitive::refineShapeIfActive(const TopoDS_Shape& oldShape) Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign"); if (hGrp->GetBool("RefineModel", false)) { - Part::BRepBuilderAPI_RefineModel mkRefine(oldShape); - TopoDS_Shape resShape = mkRefine.Shape(); - return resShape; + try { + Part::BRepBuilderAPI_RefineModel mkRefine(oldShape); + TopoDS_Shape resShape = mkRefine.Shape(); + return resShape; + } + catch (Standard_Failure) { + return oldShape; + } } return oldShape; diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index 98f22f2350..741e3ac48b 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -1024,9 +1024,14 @@ TopoDS_Shape ProfileBased::refineShapeIfActive(const TopoDS_Shape& oldShape) con Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign"); if (hGrp->GetBool("RefineModel", false)) { - Part::BRepBuilderAPI_RefineModel mkRefine(oldShape); - TopoDS_Shape resShape = mkRefine.Shape(); - return resShape; + try { + Part::BRepBuilderAPI_RefineModel mkRefine(oldShape); + TopoDS_Shape resShape = mkRefine.Shape(); + return resShape; + } + catch (Standard_Failure) { + return oldShape; + } } return oldShape; diff --git a/src/Mod/PartDesign/App/FeatureTransformed.cpp b/src/Mod/PartDesign/App/FeatureTransformed.cpp index f1c675408c..6bfa55c2ed 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.cpp +++ b/src/Mod/PartDesign/App/FeatureTransformed.cpp @@ -377,9 +377,14 @@ TopoDS_Shape Transformed::refineShapeIfActive(const TopoDS_Shape& oldShape) cons Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign"); if (hGrp->GetBool("RefineModel", false)) { - Part::BRepBuilderAPI_RefineModel mkRefine(oldShape); - TopoDS_Shape resShape = mkRefine.Shape(); - return resShape; + try { + Part::BRepBuilderAPI_RefineModel mkRefine(oldShape); + TopoDS_Shape resShape = mkRefine.Shape(); + return resShape; + } + catch (Standard_Failure) { + return oldShape; + } } return oldShape;