[PD and Part] add possibility to create skew prisms

This commit is contained in:
donovaly
2020-08-09 04:24:34 +02:00
committed by wmayer
parent 3d4e987646
commit 6bbab49723
9 changed files with 515 additions and 96 deletions

View File

@@ -532,9 +532,14 @@ PROPERTY_SOURCE(PartDesign::Prism, PartDesign::FeaturePrimitive)
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(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(FirstSkew, (0.0f), "Prism", App::Prop_None, "Angle in first direction");
ADD_PROPERTY_TYPE(SecondSkew, (0.0f), "Prism", App::Prop_None, "Angle in second direction");
static const App::PropertyQuantityConstraint::Constraints angleConstraint = { -89.99999, 89.99999, 1.0 };
FirstSkew.setConstraints(&angleConstraint);
SecondSkew.setConstraints(&angleConstraint);
primitiveType = FeaturePrimitive::Prism;
}
@@ -563,11 +568,14 @@ App::DocumentObjectExecReturn* Prism::execute(void)
}
mkPoly.Add(gp_Pnt(v.x,v.y,v.z));
BRepBuilderAPI_MakeFace mkFace(mkPoly.Wire());
BRepPrimAPI_MakePrism mkPrism(mkFace.Face(), gp_Vec(0,0,Height.getValue()));
// the direction vector for the prism is the height for z and the skew
BRepPrimAPI_MakePrism mkPrism(mkFace.Face(),
gp_Vec(Height.getValue() * tan(Base::toRadians<double>(FirstSkew.getValue())),
Height.getValue() * tan(Base::toRadians<double>(SecondSkew.getValue())),
Height.getValue()));
return FeaturePrimitive::execute(mkPrism.Shape());
}
catch (Standard_Failure& e) {
return new App::DocumentObjectExecReturn(e.GetMessageString());
}
@@ -582,6 +590,10 @@ short int Prism::mustExecute() const
return 1;
if (Height.isTouched())
return 1;
if (FirstSkew.isTouched())
return 1;
if (SecondSkew.isTouched())
return 1;
return FeaturePrimitive::mustExecute();
}