diff --git a/src/Mod/Part/App/PrimitiveFeature.cpp b/src/Mod/Part/App/PrimitiveFeature.cpp
index 32ccbb38b..2928c041c 100644
--- a/src/Mod/Part/App/PrimitiveFeature.cpp
+++ b/src/Mod/Part/App/PrimitiveFeature.cpp
@@ -358,6 +358,8 @@ Ellipsoid::Ellipsoid(void)
Radius1.setConstraints(&floatRange);
ADD_PROPERTY_TYPE(Radius2,(4.0),"Ellipsoid",App::Prop_None,"The radius of the ellipsoid");
Radius2.setConstraints(&floatRange);
+ ADD_PROPERTY_TYPE(Radius3,(0.0),"Ellipsoid",App::Prop_None,"The radius of the ellipsoid");
+ Radius3.setConstraints(&floatRange);
ADD_PROPERTY_TYPE(Angle1,(-90.0f),"Ellipsoid",App::Prop_None,"The angle of the ellipsoid");
Angle1.setConstraints(&angleRangeV);
ADD_PROPERTY_TYPE(Angle2,(90.0f),"Ellipsoid",App::Prop_None,"The angle of the ellipsoid");
@@ -372,6 +374,8 @@ short Ellipsoid::mustExecute() const
return 1;
if (Radius2.isTouched())
return 1;
+ if (Radius3.isTouched())
+ return 1;
if (Angle1.isTouched())
return 1;
if (Angle2.isTouched())
@@ -388,6 +392,7 @@ App::DocumentObjectExecReturn *Ellipsoid::execute(void)
return new App::DocumentObjectExecReturn("Radius of ellipsoid too small");
if (Radius2.getValue() < Precision::Confusion())
return new App::DocumentObjectExecReturn("Radius of ellipsoid too small");
+
try {
gp_Pnt pnt(0.0,0.0,0.0);
gp_Dir dir(0.0,0.0,1.0);
@@ -397,19 +402,24 @@ App::DocumentObjectExecReturn *Ellipsoid::execute(void)
Angle1.getValue()/180.0f*M_PI,
Angle2.getValue()/180.0f*M_PI,
Angle3.getValue()/180.0f*M_PI);
- Standard_Real scale = Radius1.getValue()/Radius2.getValue();
- gp_Dir xDir = ax2.XDirection();
- gp_Dir yDir = ax2.YDirection();
+ Standard_Real scaleX = 1.0;
+ Standard_Real scaleZ = Radius1.getValue()/Radius2.getValue();
+ // issue #1798: A third radius has been introduced. To be backward
+ // compatible if Radius3 is 0.0 (default) it's handled to be the same
+ // as Radius2
+ Standard_Real scaleY = 1.0;
+ if (Radius3.getValue() >= Precision::Confusion())
+ scaleY = Radius3.getValue()/Radius2.getValue();
gp_GTrsf mat;
- mat.SetValue(1,1,xDir.X());
- mat.SetValue(2,1,xDir.Y());
- mat.SetValue(3,1,xDir.Z());
- mat.SetValue(1,2,yDir.X());
- mat.SetValue(2,2,yDir.Y());
- mat.SetValue(3,2,yDir.Z());
- mat.SetValue(1,3,dir.X()*scale);
- mat.SetValue(2,3,dir.Y()*scale);
- mat.SetValue(3,3,dir.Z()*scale);
+ mat.SetValue(1,1,scaleX);
+ mat.SetValue(2,1,0.0);
+ mat.SetValue(3,1,0.0);
+ mat.SetValue(1,2,0.0);
+ mat.SetValue(2,2,scaleY);
+ mat.SetValue(3,2,0.0);
+ mat.SetValue(1,3,0.0);
+ mat.SetValue(2,3,0.0);
+ mat.SetValue(3,3,scaleZ);
BRepBuilderAPI_GTransform mkTrsf(mkSphere.Shape(), mat);
TopoDS_Shape ResultShape = mkTrsf.Shape();
this->Shape.setValue(ResultShape);
diff --git a/src/Mod/Part/App/PrimitiveFeature.h b/src/Mod/Part/App/PrimitiveFeature.h
index baef52df5..3440579c5 100644
--- a/src/Mod/Part/App/PrimitiveFeature.h
+++ b/src/Mod/Part/App/PrimitiveFeature.h
@@ -157,6 +157,7 @@ public:
App::PropertyFloatConstraint Radius1;
App::PropertyFloatConstraint Radius2;
+ App::PropertyFloatConstraint Radius3;
App::PropertyFloatConstraint Angle1;
App::PropertyFloatConstraint Angle2;
App::PropertyFloatConstraint Angle3;
diff --git a/src/Mod/Part/Gui/DlgPrimitives.cpp b/src/Mod/Part/Gui/DlgPrimitives.cpp
index 79e2aea8c..fb1eb4547 100644
--- a/src/Mod/Part/Gui/DlgPrimitives.cpp
+++ b/src/Mod/Part/Gui/DlgPrimitives.cpp
@@ -209,6 +209,7 @@ DlgPrimitives::DlgPrimitives(QWidget* parent)
// ellipsoid
ui.ellipsoidRadius1->setMaximum(INT_MAX);
ui.ellipsoidRadius2->setMaximum(INT_MAX);
+ ui.ellipsoidRadius3->setMaximum(INT_MAX);
// torus
ui.torusRadius1->setMaximum(INT_MAX);
ui.torusRadius2->setMaximum(INT_MAX);
@@ -435,14 +436,16 @@ void DlgPrimitives::createPrimitive(const QString& placement)
"App.ActiveDocument.addObject(\"Part::Ellipsoid\",\"%1\")\n"
"App.ActiveDocument.%1.Radius1=%2\n"
"App.ActiveDocument.%1.Radius2=%3\n"
- "App.ActiveDocument.%1.Angle1=%4\n"
- "App.ActiveDocument.%1.Angle2=%5\n"
- "App.ActiveDocument.%1.Angle3=%6\n"
- "App.ActiveDocument.%1.Placement=%7\n"
- "App.ActiveDocument.%1.Label='%8'\n")
+ "App.ActiveDocument.%1.Radius3=%4\n"
+ "App.ActiveDocument.%1.Angle1=%5\n"
+ "App.ActiveDocument.%1.Angle2=%6\n"
+ "App.ActiveDocument.%1.Angle3=%7\n"
+ "App.ActiveDocument.%1.Placement=%8\n"
+ "App.ActiveDocument.%1.Label='%9'\n")
.arg(name)
.arg(ui.ellipsoidRadius1->value().getValue(),0,'f',2)
.arg(ui.ellipsoidRadius2->value().getValue(),0,'f',2)
+ .arg(ui.ellipsoidRadius3->value().getValue(),0,'f',2)
.arg(ui.ellipsoidAngle1->value().getValue(),0,'f',2)
.arg(ui.ellipsoidAngle2->value().getValue(),0,'f',2)
.arg(ui.ellipsoidAngle3->value().getValue(),0,'f',2)
diff --git a/src/Mod/Part/Gui/DlgPrimitives.ui b/src/Mod/Part/Gui/DlgPrimitives.ui
index 6f7280e38..4a2490c8e 100644
--- a/src/Mod/Part/Gui/DlgPrimitives.ui
+++ b/src/Mod/Part/Gui/DlgPrimitives.ui
@@ -762,6 +762,13 @@
+ -
+
+
+ Radius 3:
+
+
+
-
@@ -782,6 +789,16 @@
+ -
+
+
+ mm
+
+
+ 4.000000000000000
+
+
+
-
@@ -2003,6 +2020,7 @@
sphereAngle2
ellipsoidRadius1
ellipsoidRadius2
+ ellipsoidRadius3
ellipsoidAngle3
ellipsoidAngle1
ellipsoidAngle2