+ fixes #0001798: Support general ellipsoid with three radii
This commit is contained in:
parent
1f450972d2
commit
267ca0813a
|
@ -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);
|
||||
|
|
|
@ -157,6 +157,7 @@ public:
|
|||
|
||||
App::PropertyFloatConstraint Radius1;
|
||||
App::PropertyFloatConstraint Radius2;
|
||||
App::PropertyFloatConstraint Radius3;
|
||||
App::PropertyFloatConstraint Angle1;
|
||||
App::PropertyFloatConstraint Angle2;
|
||||
App::PropertyFloatConstraint Angle3;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -762,6 +762,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="textLabel23">
|
||||
<property name="text">
|
||||
<string>Radius 3:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="ellipsoidRadius1">
|
||||
<property name="unit" stdset="0">
|
||||
|
@ -782,6 +789,16 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="ellipsoidRadius3">
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>4.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
|
@ -2003,6 +2020,7 @@
|
|||
<tabstop>sphereAngle2</tabstop>
|
||||
<tabstop>ellipsoidRadius1</tabstop>
|
||||
<tabstop>ellipsoidRadius2</tabstop>
|
||||
<tabstop>ellipsoidRadius3</tabstop>
|
||||
<tabstop>ellipsoidAngle3</tabstop>
|
||||
<tabstop>ellipsoidAngle1</tabstop>
|
||||
<tabstop>ellipsoidAngle2</tabstop>
|
||||
|
|
Loading…
Reference in New Issue
Block a user