Part: Revolve: port to use FaceMaker
For old documents, default to old behavior. For new objects, default to use FaceMakerBullseye
This commit is contained in:
parent
399cb4bda3
commit
199d3edf13
|
@ -35,6 +35,7 @@
|
|||
#include <Base/Tools.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <App/Application.h>
|
||||
#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<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())
|
||||
|
@ -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
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
App::PropertyFloatConstraint Angle;
|
||||
App::PropertyBool Symmetric; //like "Midplane" in PartDesign
|
||||
App::PropertyBool Solid;
|
||||
App::PropertyString FaceMakerClass;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
|
@ -79,6 +80,9 @@ public:
|
|||
|
||||
private:
|
||||
static App::PropertyFloatConstraint::Constraints angleRangeU;
|
||||
|
||||
protected:
|
||||
virtual void setupObject();
|
||||
};
|
||||
|
||||
} //namespace Part
|
||||
|
|
Loading…
Reference in New Issue
Block a user