Part & PartDesign Cone: allow equal radii (#12219)

* PartDesign_Cone: allow equal radii

* fix R2 < R1

* Part_Cone: allow equal radii
This commit is contained in:
Florian Foinant-Willig
2024-02-12 18:21:53 +01:00
committed by GitHub
parent 51f546f1f6
commit 1eb0444bd5
3 changed files with 22 additions and 15 deletions

View File

@@ -354,17 +354,21 @@ App::DocumentObjectExecReturn* Cone::execute()
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Radius of cone cannot be negative"));
if (Radius2.getValue() < 0.0)
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Radius of cone cannot be negative"));
if (Radius1.getValue() == Radius2.getValue())
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "The radii for cones must not be equal"));
if (Height.getValue() < Precision::Confusion())
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Height of cone too small"));
try {
if (std::abs(Radius1.getValue() - Radius2.getValue()) < Precision::Confusion()){
//Build a cylinder
BRepPrimAPI_MakeCylinder mkCylr(Radius1.getValue(),
Height.getValue(),
2.0 * M_PI);
return FeaturePrimitive::execute(mkCylr.Shape());
}
// Build a cone
BRepPrimAPI_MakeCone mkCone(Radius1.getValue(),
Radius2.getValue(),
Height.getValue(),
Base::toRadians<double>(Angle.getValue()));
return FeaturePrimitive::execute(mkCone.Shape());
}
catch (Standard_Failure& e) {