diff --git a/src/Mod/PartDesign/App/FeatureAddSub.h b/src/Mod/PartDesign/App/FeatureAddSub.h index b84e79662a..fc5cc7e1cc 100644 --- a/src/Mod/PartDesign/App/FeatureAddSub.h +++ b/src/Mod/PartDesign/App/FeatureAddSub.h @@ -40,11 +40,6 @@ public: Subtractive }; - enum class RefineErrorPolicy { - Raise = 0, - Warn - }; - FeatureAddSub(); Type getAddSubType(); diff --git a/src/Mod/PartDesign/App/FeatureRefine.cpp b/src/Mod/PartDesign/App/FeatureRefine.cpp index c023860193..730d720788 100644 --- a/src/Mod/PartDesign/App/FeatureRefine.cpp +++ b/src/Mod/PartDesign/App/FeatureRefine.cpp @@ -50,12 +50,40 @@ FeatureRefine::FeatureRefine() this->Refine.setValue(hGrp->GetBool("RefineModel", true)); } -TopoShape FeatureRefine::refineShapeIfActive(const TopoShape& oldShape) const +bool FeatureRefine::onlyHasToRefine() const +{ + if( ! Refine.isTouched()){ + return false; + } + if (rawShape.isNull()){ + return false; + } + std::vector propList; + getPropertyList(propList); + for (auto prop : propList){ + if (prop != &Refine + /*&& prop != &SuppressedShape*/ + && prop->isTouched()){ + return false; + } + } + return true; +} + +TopoShape FeatureRefine::refineShapeIfActive(const TopoShape& oldShape, const RefineErrorPolicy onError) const { if (this->Refine.getValue()) { TopoShape shape(oldShape); - // Potentially also "fixShape" to repair it ( as a workaround to OCCT bugs? ) - return shape.makeElementRefine(); + try { + return shape.makeElementRefine(); + } + catch (Standard_Failure& err) { + if(onError == RefineErrorPolicy::Warn){ + Base::Console().Warning((std::string("Refine failed: ") + err.GetMessageString()).c_str()); + } else { + throw; + } + } } return oldShape; } diff --git a/src/Mod/PartDesign/App/FeatureRefine.h b/src/Mod/PartDesign/App/FeatureRefine.h index 49da26cc1c..a29fc1ee09 100644 --- a/src/Mod/PartDesign/App/FeatureRefine.h +++ b/src/Mod/PartDesign/App/FeatureRefine.h @@ -35,12 +35,22 @@ class PartDesignExport FeatureRefine : public PartDesign::Feature PROPERTY_HEADER_WITH_OVERRIDE(PartDesign::FeatureRefine); public: + + enum class RefineErrorPolicy { + Raise = 0, + Warn + }; + FeatureRefine(); App::PropertyBool Refine; protected: - TopoShape refineShapeIfActive(const TopoShape&) const; + //store the shape before refinement + TopoShape rawShape; + + bool onlyHasToRefine() const; + TopoShape refineShapeIfActive(const TopoShape& oldShape, const RefineErrorPolicy onError = RefineErrorPolicy::Raise) const; }; using FeatureRefinePython = App::FeaturePythonT;