Skip to content

Commit

Permalink
Part: Revolve: port to use FaceMaker
Browse files Browse the repository at this point in the history
For old documents, default to old behavior. For new objects, default to
use FaceMakerBullseye
  • Loading branch information
DeepSOIC committed Oct 1, 2016
1 parent 399cb4b commit 199d3ed
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/Mod/Part/App/FeatureRevolution.cpp
Expand Up @@ -35,6 +35,7 @@
#include <Base/Tools.h>
#include <Base/Exception.h>
#include <App/Application.h>
#include "FaceMaker.h"

using namespace Part;

Expand All @@ -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
Expand All @@ -62,7 +64,8 @@ short Revolution::mustExecute() const
Source.isTouched() ||
Solid.isTouched() ||
AxisLink.isTouched() ||
Symmetric.isTouched())
Symmetric.isTouched() ||
FaceMakerClass.isTouched())
return 1;
return 0;
}
Expand Down Expand Up @@ -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<FaceMaker> 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())
Expand All @@ -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
}
4 changes: 4 additions & 0 deletions src/Mod/Part/App/FeatureRevolution.h
Expand Up @@ -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 */
//@{
Expand Down Expand Up @@ -79,6 +80,9 @@ class PartExport Revolution : public Part::Feature

private:
static App::PropertyFloatConstraint::Constraints angleRangeU;

protected:
virtual void setupObject();
};

} //namespace Part
Expand Down

0 comments on commit 199d3ed

Please sign in to comment.