diff --git a/src/Mod/PartDesign/App/FeatureBoolean.cpp b/src/Mod/PartDesign/App/FeatureBoolean.cpp index 51faf094e3..c0eb6c3ef8 100644 --- a/src/Mod/PartDesign/App/FeatureBoolean.cpp +++ b/src/Mod/PartDesign/App/FeatureBoolean.cpp @@ -31,6 +31,7 @@ # include # include # include +# include #endif #include "Body.h" @@ -38,7 +39,10 @@ #include #include +#include +#include #include +#include using namespace PartDesign; @@ -53,6 +57,11 @@ Boolean::Boolean() ADD_PROPERTY(Type,((long)0)); Type.setEnums(TypeEnums); + ADD_PROPERTY_TYPE(Refine,(0),"Part Design",(App::PropertyType)(App::Prop_None),"Refine shape (clean up redundant edges) after adding/subtracting"); + Base::Reference hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign"); + this->Refine.setValue(hGrp->GetBool("RefineModel", false)); + initExtension(this); } @@ -141,7 +150,9 @@ App::DocumentObjectExecReturn *Boolean::execute(void) result = boolOp; // Use result of this operation for fuse/cut of next body } - + + result = refineShapeIfActive(result); + int solidCount = countSolids(result); if (solidCount > 1) { return new App::DocumentObjectExecReturn("Boolean: Result has multiple solids. This is not supported at this time."); @@ -168,4 +179,20 @@ void Boolean::handleChangedPropertyName(Base::XMLReader &reader, const char * Ty } } +TopoDS_Shape Boolean::refineShapeIfActive(const TopoDS_Shape& oldShape) const +{ + if (this->Refine.getValue()) { + 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/FeatureBoolean.h b/src/Mod/PartDesign/App/FeatureBoolean.h index d38a0fe0c8..770a8595fa 100644 --- a/src/Mod/PartDesign/App/FeatureBoolean.h +++ b/src/Mod/PartDesign/App/FeatureBoolean.h @@ -46,6 +46,8 @@ public: /// The type of the boolean operation App::PropertyEnumeration Type; + App::PropertyBool Refine; + /** @name methods override feature */ //@{ /// Recalculate the feature @@ -60,6 +62,8 @@ public: protected: void handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName); + TopoDS_Shape refineShapeIfActive(const TopoDS_Shape&) const; + private: static const char* TypeEnums[];