PartDesign: Refine property for primitives #3488
This commit is contained in:
@@ -23,10 +23,14 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <Standard_Failure.hxx>
|
||||
#endif
|
||||
|
||||
|
||||
#include <Base/Parameter.h>
|
||||
#include <App/Application.h>
|
||||
#include <App/FeaturePythonPyImp.h>
|
||||
#include <Mod/Part/App/modelRefine.h>
|
||||
#include "FeatureAddSub.h"
|
||||
#include "FeaturePy.h"
|
||||
|
||||
@@ -42,6 +46,11 @@ FeatureAddSub::FeatureAddSub()
|
||||
: addSubType(Additive)
|
||||
{
|
||||
ADD_PROPERTY(AddSubShape,(TopoDS_Shape()));
|
||||
ADD_PROPERTY_TYPE(Refine,(0),"Part Design",(App::PropertyType)(App::Prop_None),"Refine shape (clean up redundant edges) after adding/subtracting");
|
||||
//init Refine property
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign");
|
||||
this->Refine.setValue(hGrp->GetBool("RefineModel", false));
|
||||
}
|
||||
|
||||
FeatureAddSub::Type FeatureAddSub::getAddSubType()
|
||||
@@ -49,6 +58,29 @@ FeatureAddSub::Type FeatureAddSub::getAddSubType()
|
||||
return addSubType;
|
||||
}
|
||||
|
||||
short FeatureAddSub::mustExecute() const
|
||||
{
|
||||
if (Refine.isTouched())
|
||||
return 1;
|
||||
return PartDesign::Feature::mustExecute();
|
||||
}
|
||||
|
||||
TopoDS_Shape FeatureAddSub::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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace App {
|
||||
|
||||
@@ -46,11 +46,16 @@ public:
|
||||
FeatureAddSub();
|
||||
|
||||
Type getAddSubType();
|
||||
|
||||
|
||||
virtual short mustExecute() const override;
|
||||
|
||||
Part::PropertyPartShape AddSubShape;
|
||||
App::PropertyBool Refine;
|
||||
|
||||
protected:
|
||||
Type addSubType;
|
||||
|
||||
TopoDS_Shape refineShapeIfActive(const TopoDS_Shape&) const;
|
||||
};
|
||||
|
||||
typedef App::FeaturePythonT<FeatureAddSub> FeatureAddSubPython;
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "FeaturePrimitive.h"
|
||||
#include "DatumPoint.h"
|
||||
#include "DatumCS.h"
|
||||
#include <Mod/Part/App/modelRefine.h>
|
||||
#include "FeaturePy.h"
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Tools.h>
|
||||
@@ -70,24 +69,6 @@ FeaturePrimitive::FeaturePrimitive()
|
||||
Part::AttachExtension::initExtension(this);
|
||||
}
|
||||
|
||||
TopoDS_Shape FeaturePrimitive::refineShapeIfActive(const TopoDS_Shape& oldShape) const
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign");
|
||||
if (hGrp->GetBool("RefineModel", false)) {
|
||||
try {
|
||||
Part::BRepBuilderAPI_RefineModel mkRefine(oldShape);
|
||||
TopoDS_Shape resShape = mkRefine.Shape();
|
||||
return resShape;
|
||||
}
|
||||
catch (Standard_Failure&) {
|
||||
return oldShape;
|
||||
}
|
||||
}
|
||||
|
||||
return oldShape;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn* FeaturePrimitive::execute(const TopoDS_Shape& primitiveShape)
|
||||
{
|
||||
try {
|
||||
@@ -124,7 +105,7 @@ App::DocumentObjectExecReturn* FeaturePrimitive::execute(const TopoDS_Shape& pri
|
||||
// lets check if the result is a solid
|
||||
if (boolOp.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Resulting shape is not a solid");
|
||||
|
||||
|
||||
int solidCount = countSolids(boolOp);
|
||||
if (solidCount > 1) {
|
||||
return new App::DocumentObjectExecReturn("Additive: Result has multiple solids. This is not supported at this time.");
|
||||
@@ -144,7 +125,7 @@ App::DocumentObjectExecReturn* FeaturePrimitive::execute(const TopoDS_Shape& pri
|
||||
// lets check if the result is a solid
|
||||
if (boolOp.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Resulting shape is not a solid");
|
||||
|
||||
|
||||
int solidCount = countSolids(boolOp);
|
||||
if (solidCount > 1) {
|
||||
return new App::DocumentObjectExecReturn("Subtractive: Result has multiple solids. This is not supported at this time.");
|
||||
|
||||
@@ -55,7 +55,6 @@ public:
|
||||
return "PartDesignGui::ViewProviderPrimitive";
|
||||
}
|
||||
Type getPrimitiveType() {return primitiveType;}
|
||||
TopoDS_Shape refineShapeIfActive(const TopoDS_Shape& oldShape) const;
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
virtual PyObject* getPyObject();
|
||||
|
||||
|
||||
@@ -76,7 +76,6 @@
|
||||
#include <App/Application.h>
|
||||
#include <App/OriginFeature.h>
|
||||
#include <App/Document.h>
|
||||
#include <Mod/Part/App/modelRefine.h>
|
||||
#include <Mod/Part/App/FaceMakerCheese.h>
|
||||
#include "FeatureSketchBased.h"
|
||||
#include "DatumPlane.h"
|
||||
@@ -92,12 +91,7 @@ ProfileBased::ProfileBased()
|
||||
ADD_PROPERTY_TYPE(Midplane,(0),"SketchBased", App::Prop_None, "Extrude symmetric to sketch face");
|
||||
ADD_PROPERTY_TYPE(Reversed, (0),"SketchBased", App::Prop_None, "Reverse extrusion direction");
|
||||
ADD_PROPERTY_TYPE(UpToFace,(0),"SketchBased",(App::PropertyType)(App::Prop_None),"Face where feature will end");
|
||||
ADD_PROPERTY_TYPE(Refine,(0),"SketchBased",(App::PropertyType)(App::Prop_None),"Refine shape (clean up redundant edges) after adding/subtracting");
|
||||
|
||||
//init Refine property
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign");
|
||||
this->Refine.setValue(hGrp->GetBool("RefineModel", false));
|
||||
}
|
||||
|
||||
short ProfileBased::mustExecute() const
|
||||
@@ -1043,22 +1037,6 @@ void ProfileBased::getAxis(const App::DocumentObject *pcReferenceAxis, const std
|
||||
throw Base::Exception("Rotation axis reference is invalid");
|
||||
}
|
||||
|
||||
TopoDS_Shape ProfileBased::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;
|
||||
}
|
||||
|
||||
Base::Vector3d ProfileBased::getProfileNormal() const {
|
||||
|
||||
Base::Vector3d SketchVector(0,0,1);
|
||||
|
||||
@@ -54,8 +54,6 @@ public:
|
||||
/// Face to extrude up to
|
||||
App::PropertyLinkSub UpToFace;
|
||||
|
||||
App::PropertyBool Refine;
|
||||
|
||||
short mustExecute() const;
|
||||
|
||||
/** calculates and updates the Placement property based on the features
|
||||
@@ -111,7 +109,6 @@ public:
|
||||
|
||||
protected:
|
||||
void remapSupportShape(const TopoDS_Shape&);
|
||||
TopoDS_Shape refineShapeIfActive(const TopoDS_Shape&) const;
|
||||
|
||||
/// Extract a face from a given LinkSub
|
||||
static void getUpToFaceFromLinkSub(TopoDS_Face& upToFace,
|
||||
|
||||
Reference in New Issue
Block a user