From 199d3edf132649280a22c11e59b81ffdba806b3c Mon Sep 17 00:00:00 2001 From: DeepSOIC Date: Sun, 25 Sep 2016 18:29:56 +0300 Subject: [PATCH] Part: Revolve: port to use FaceMaker For old documents, default to old behavior. For new objects, default to use FaceMakerBullseye --- src/Mod/Part/App/FeatureRevolution.cpp | 28 +++++++++++++++++++++++++- src/Mod/Part/App/FeatureRevolution.h | 4 ++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Mod/Part/App/FeatureRevolution.cpp b/src/Mod/Part/App/FeatureRevolution.cpp index 16024f3ad089..1e4a096f7797 100644 --- a/src/Mod/Part/App/FeatureRevolution.cpp +++ b/src/Mod/Part/App/FeatureRevolution.cpp @@ -35,6 +35,7 @@ #include #include #include +#include "FaceMaker.h" using namespace Part; @@ -52,6 +53,7 @@ Revolution::Revolution() Angle.setConstraints(&angleRangeU); ADD_PROPERTY_TYPE(Symmetric,(false),"Revolve",App::Prop_None,"Extend revolution symmetrically from the profile."); ADD_PROPERTY_TYPE(Solid,(false),"Revolve",App::Prop_None,"Make revolution a solid if possible"); + ADD_PROPERTY_TYPE(FaceMakerClass,(""),"Revolve",App::Prop_None,"Facemaker to use if Solid is true."); //default for old documents. For default for new objects, refer to setupObject(). } short Revolution::mustExecute() const @@ -62,7 +64,8 @@ short Revolution::mustExecute() const Source.isTouched() || Solid.isTouched() || AxisLink.isTouched() || - Symmetric.isTouched()) + Symmetric.isTouched() || + FaceMakerClass.isTouched()) return 1; return 0; } @@ -165,6 +168,21 @@ App::DocumentObjectExecReturn *Revolution::execute(void) //do it! Standard_Boolean makeSolid = Solid.getValue() ? Standard_True : Standard_False; + if (makeSolid && strlen(this->FaceMakerClass.getValue())>0){ + //new facemaking behavior: use facemaker class + std::unique_ptr fm_instance = FaceMaker::ConstructFromType(this->FaceMakerClass.getValue()); + FaceMaker* mkFace = &(*(fm_instance)); + TopoDS_Shape myShape = sourceShape.getShape(); + if(myShape.ShapeType() == TopAbs_COMPOUND) + mkFace->useCompound(TopoDS::Compound(myShape)); + else + mkFace->addShape(myShape); + mkFace->Build(); + myShape = mkFace->Shape(); + sourceShape = TopoShape(myShape); + + makeSolid = Standard_False;//don't ask TopoShape::revolve to make solid, as we've made faces... + } TopoDS_Shape revolve = sourceShape.revolve(revAx, angle, makeSolid); if (revolve.IsNull()) @@ -177,3 +195,11 @@ App::DocumentObjectExecReturn *Revolution::execute(void) return new App::DocumentObjectExecReturn(e->GetMessageString()); } } + + + +void Part::Revolution::setupObject() +{ + Part::Feature::setupObject(); + this->FaceMakerClass.setValue("Part::FaceMakerBullseye"); //default for newly created features +} diff --git a/src/Mod/Part/App/FeatureRevolution.h b/src/Mod/Part/App/FeatureRevolution.h index 4fa6d60558dd..b75958960a58 100644 --- a/src/Mod/Part/App/FeatureRevolution.h +++ b/src/Mod/Part/App/FeatureRevolution.h @@ -45,6 +45,7 @@ class PartExport Revolution : public Part::Feature App::PropertyFloatConstraint Angle; App::PropertyBool Symmetric; //like "Midplane" in PartDesign App::PropertyBool Solid; + App::PropertyString FaceMakerClass; /** @name methods override feature */ //@{ @@ -79,6 +80,9 @@ class PartExport Revolution : public Part::Feature private: static App::PropertyFloatConstraint::Constraints angleRangeU; + +protected: + virtual void setupObject(); }; } //namespace Part