PartDesign: for Prism feature use PrismExtension

This commit is contained in:
wmayer
2021-04-05 13:25:36 +02:00
parent 2b09a3ebec
commit 021f42f828
2 changed files with 7 additions and 22 deletions

View File

@@ -553,11 +553,8 @@ Prism::Prism()
ADD_PROPERTY_TYPE(Polygon, (6.0), "Prism", App::Prop_None, "Number of sides in the polygon, of the prism");
ADD_PROPERTY_TYPE(Circumradius, (2.0), "Prism", App::Prop_None, "Circumradius (centre to vertex) of the polygon, of the prism");
ADD_PROPERTY_TYPE(Height, (10.0f), "Prism", App::Prop_None, "The height of the prism");
ADD_PROPERTY_TYPE(FirstAngle, (0.0f), "Prism", App::Prop_None, "Angle in first direction");
ADD_PROPERTY_TYPE(SecondAngle, (0.0f), "Prism", App::Prop_None, "Angle in second direction");
static const App::PropertyQuantityConstraint::Constraints angleConstraint = { -89.99999, 89.99999, 1.0 };
FirstAngle.setConstraints(&angleConstraint);
SecondAngle.setConstraints(&angleConstraint);
Part::PrismExtension::initExtension(this);
primitiveType = FeaturePrimitive::Prism;
}
@@ -587,11 +584,8 @@ App::DocumentObjectExecReturn* Prism::execute(void)
mkPoly.Add(gp_Pnt(v.x,v.y,v.z));
BRepBuilderAPI_MakeFace mkFace(mkPoly.Wire());
// the direction vector for the prism is the height for z and the given angle
BRepPrimAPI_MakePrism mkPrism(mkFace.Face(),
gp_Vec(Height.getValue() * tan(Base::toRadians<double>(FirstAngle.getValue())),
Height.getValue() * tan(Base::toRadians<double>(SecondAngle.getValue())),
Height.getValue()));
return FeaturePrimitive::execute(mkPrism.Shape());
TopoDS_Shape prism = makePrism(Height.getValue(), mkFace.Face());
return FeaturePrimitive::execute(prism);
}
catch (Standard_Failure& e) {
return new App::DocumentObjectExecReturn(e.GetMessageString());
@@ -608,10 +602,6 @@ short int Prism::mustExecute() const
return 1;
if (Height.isTouched())
return 1;
if (FirstAngle.isTouched())
return 1;
if (SecondAngle.isTouched())
return 1;
return FeaturePrimitive::mustExecute();
}

View File

@@ -29,6 +29,7 @@
#include "FeatureAddSub.h"
#include <Mod/Part/App/AttachExtension.h>
#include <Mod/Part/App/PrismExtension.h>
namespace PartDesign
{
@@ -307,28 +308,22 @@ class PartDesignExport SubtractiveTorus : public Torus {
};
class PartDesignExport Prism : public PartDesign::FeaturePrimitive {
class PartDesignExport Prism : public PartDesign::FeaturePrimitive, public Part::PrismExtension {
PROPERTY_HEADER(PartDesign::Prism);
public:
Prism();
App::PropertyIntegerConstraint Polygon;
App::PropertyLength Circumradius;
App::PropertyLength Height;
App::PropertyAngle FirstAngle;
App::PropertyAngle SecondAngle;
/** @name methods override feature */
//@{
/// recalculate the Feature
App::DocumentObjectExecReturn *execute(void);
short mustExecute() const;
protected:
};
class PartDesignExport AdditivePrism : public Prism {