To create an \b Ellipse in the <b>Main Menu</b> select <b>New Entity - > Basic - > Ellipse</b>
-\n You can define an \b Ellipse by its <b>Center Point</b>, a \b
-Vector giving its normal, and its <b>Major & Minor Radiuses</b>.
+\n You can define an \b Ellipse by its <b>Center</b> point, a \b
+Vector giving its normal, another vector specifying the direction of
+ellipse's <b>Major Axis</b> and its <b>Major</b> & <b>Minor Radiuses</b>.
\n The \b Result of the operation will be a GEOM_Object (edge).
-\n <b>TUI Command:</b> <em>geompy.MakeEllipse(Point, Vector, RadiusMajor, RadiusMinor)</em>
+\note The parameters <b>Center</b>, <b>Vector</b> and <b>Major Axis</b>
+are optional. By default it is presumed that the <b>Center</b> point
+is located at the origin of the global coordinate system, the \b Vector
+corresponds to the OZ axis of the global coordinate system and <b>Major Axis</b>
+corresponds to the OX axis of the global coordinate system.
+
+
+\note Actual direction of the major axis vector is defined as
+<EM> Vmaj' = (Vn * Vmaj) * Vn</em> where \em Vn is a normal vector and
+\em Vmaj is an original vector of the major axis.
+
+\n <b>TUI Command (no major axis):</b> <em>geompy.MakeEllipse(Point, Vector, RadiusMajor, RadiusMinor)</em>
\n <b>Arguments:</b> Name + 1 vertex (for the center) + 1 edge (for
the direction) + 1 X Radius + 1 Y Radius.
-\note By default it is presumed that the <b>Center Point</b> is located at the Origin of the global
-coordinate system, and the \b Vector corresponds to OZ axis of the global
-coordinate system.
+\n <b>TUI Command (use major axis):</b><em>geompy.MakeEllipseVec(Point, Vector, RadiusMajor, RadiusMinor, VectorMajor)</em>
+\n <b>Arguments:</b> Name + 1 vertex (for the center) + 1 edge (for
+the normal direction) + 1 X Radius + 1 Y Radius + 1 edge (for the
+major axis direction)
\image html ellipse.png
# create vertices
p0 = geompy.MakeVertex(0., 0., 0.)
-p50 = geompy.MakeVertex(50., 50., 50.)
+p1 = geompy.MakeVertex(50., 50., 50.)
+p2 = geompy.MakeVertex(0., 50., 0.)
-# create a vector from two points
-vector = geompy.MakeVector(p0, p50)
+# create a normal vector from two points
+normal = geompy.MakeVector(p0, p1)
+
+# create a major axis vector from two points
+major = geompy.MakeVector(p0, p2)
# create an ellipse from a point, a vector and radiuses
-ellipse = geompy.MakeEllipse(p50, vector, 50, 25)
+ellipse1 = geompy.MakeEllipse(p1, normal, 50, 25)
+
+# create an ellipse from a point, a normal vector, radiuses and a major axis vector
+ellipse2 = geompy.MakeEllipse(p1, normal, 50, 25, major)
# add objects in the study
-id_vector = geompy.addToStudy(vector, "Vector")
-id_ellipse = geompy.addToStudy(ellipse,"Ellipse")
+id_normal = geompy.addToStudy(normal, "Normal")
+id_major = geompy.addToStudy(major, "Major Axis")
+id_ellipse1 = geompy.addToStudy(ellipse1, "Ellipse 1")
+id_ellipse2 = geompy.addToStudy(ellipse2, "Ellipse 2")
# display the ellipse and its normal vector
-gg.createAndDisplayGO(id_vector)
-gg.createAndDisplayGO(id_ellipse)
+gg.createAndDisplayGO(id_normal)
+gg.createAndDisplayGO(id_major)
+gg.createAndDisplayGO(id_ellipse1)
+gg.createAndDisplayGO(id_ellipse2)
\endcode
\anchor tui_creation_arc
gg.setTransparency(id_plane3,0.5)
\endcode
-*/
\ No newline at end of file
+*/
in double theRMajor,
in double theRMinor);
+ /*!
+ * Create an ellipse with given center, normal vector, main axis vector and radiuses.
+ * \param thePnt Ellipse center.
+ * \param theVec Vector, normal to the plane of the ellipse.
+ * \param theRMajor Major ellipse radius.
+ * \param theRMinor Minor ellipse radius.
+ * \param theVecMaj Vector, direction of the ellipse's main axis.
+ * \return New GEOM_Object, containing the created ellipse.
+ */
+ GEOM_Object MakeEllipseVec (in GEOM_Object thePnt,
+ in GEOM_Object theVec,
+ in double theRMajor,
+ in double theRMinor,
+ in GEOM_Object theVecMaj);
+
/*!
* Create an arc of circle, passing through three given points.
* \param thePnt1 Start point of the arc.
in GEOM_Object theVec,
in double theRMajor,
in double theRMinor) ;
+ GEOM_Object MakeEllipseVec (in GEOM_Object thePnt,
+ in GEOM_Object theVec,
+ in double theRMajor,
+ in double theRMinor,
+ in GEOM_Object theVecMaj) ;
GEOM_Object MakeArc (in GEOM_Object thePnt1,
in GEOM_Object thePnt2,
in GEOM_Object thePnt3) ;
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
mainFrame()->RadioButton3->close();
- GroupPoints = new DlgRef_2Sel2Spin( centralWidget() );
+ GroupPoints = new DlgRef_3Sel2Spin( centralWidget() );
GroupPoints->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
- GroupPoints->TextLabel1->setText( tr( "GEOM_CENTER" ) + " (Origin by default)" );
- GroupPoints->TextLabel2->setText( tr( "GEOM_VECTOR" ) + " (Z axis by default)" );
- GroupPoints->TextLabel3->setText( tr( "GEOM_RADIUS_MAJOR" ) );
- GroupPoints->TextLabel4->setText( tr( "GEOM_RADIUS_MINOR" ) );
+ GroupPoints->TextLabel1->setText( tr( "%1 (%2)" ).arg( tr( "GEOM_CENTER" ), tr( "ORIGIN_DEFAULT" ) ) );
+ GroupPoints->TextLabel2->setText( tr( "%1 (%2)" ).arg( tr( "GEOM_VECTOR" ), tr( "Z_AXIS_DEFAULT" ) ) );
+ GroupPoints->TextLabel3->setText( tr( "%1 (%2)" ).arg( tr( "GEOM_VECTOR_MAJOR" ), tr( "X_AXIS_DEFAULT" ) ) );
+ GroupPoints->TextLabel4->setText( tr( "GEOM_RADIUS_MAJOR" ) );
+ GroupPoints->TextLabel5->setText( tr( "GEOM_RADIUS_MINOR" ) );
GroupPoints->PushButton1->setIcon( image1 );
GroupPoints->PushButton2->setIcon( image1 );
+ GroupPoints->PushButton3->setIcon( image1 );
GroupPoints->LineEdit1->setReadOnly( true );
GroupPoints->LineEdit2->setReadOnly( true );
+ GroupPoints->LineEdit3->setReadOnly( true );
GroupPoints->LineEdit1->setEnabled( true );
GroupPoints->LineEdit2->setEnabled( false );
+ GroupPoints->LineEdit3->setEnabled( false );
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
GroupPoints->PushButton1->setDown(true);
- myPoint = myDir = GEOM::GEOM_Object::_nil();
+ myPoint = myDir = myMajor = GEOM::GEOM_Object::_nil();
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( GroupPoints->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
+ connect( GroupPoints->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupPoints->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
initName();
// reset
- myPoint = myDir = GEOM::GEOM_Object::_nil();
+ myPoint = myDir = myMajor = GEOM::GEOM_Object::_nil();
GroupPoints->LineEdit1->setText( "" );
GroupPoints->LineEdit2->setText( "" );
+ GroupPoints->LineEdit3->setText( "" );
GroupPoints->PushButton1->setDown(true);
GroupPoints->PushButton2->setDown(false);
+ GroupPoints->PushButton3->setDown(false);
GroupPoints->LineEdit1->setEnabled( true );
GroupPoints->LineEdit2->setEnabled( false );
+ GroupPoints->LineEdit3->setEnabled( false );
myEditCurrentArgument = GroupPoints->LineEdit1;
globalSelection(); // close local contexts, if any
if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = GEOM::GEOM_Object::_nil();
+ else if (myEditCurrentArgument == GroupPoints->LineEdit3) myMajor = GEOM::GEOM_Object::_nil();
return;
}
TopoDS_Shape aShape;
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
- if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
+ if ( myEditCurrentArgument == GroupPoints->LineEdit2 || myEditCurrentArgument == GroupPoints->LineEdit3 )
aNeedType = TopAbs_EDGE;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
}
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
myDir = aSelectedObject;
- if ( !myDir->_is_nil() && myPoint->_is_nil() )
+ if ( !myDir->_is_nil() && myMajor->_is_nil() )
+ GroupPoints->PushButton3->click();
+ }
+ else if ( myEditCurrentArgument == GroupPoints->LineEdit3 ) {
+ myMajor = aSelectedObject;
+ if ( !myMajor->_is_nil() && myPoint->_is_nil() )
GroupPoints->PushButton1->click();
}
}
if ( send == GroupPoints->PushButton1 ) {
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton2->setDown(false);
+ GroupPoints->PushButton3->setDown(false);
GroupPoints->LineEdit1->setEnabled( true );
GroupPoints->LineEdit2->setEnabled( false );
+ GroupPoints->LineEdit3->setEnabled( false );
}
else if ( send == GroupPoints->PushButton2 ) {
myEditCurrentArgument = GroupPoints->LineEdit2;
GroupPoints->PushButton1->setDown(false);
+ GroupPoints->PushButton3->setDown(false);
GroupPoints->LineEdit1->setEnabled( false );
GroupPoints->LineEdit2->setEnabled( true );
+ GroupPoints->LineEdit3->setEnabled( false );
+ }
+ else if ( send == GroupPoints->PushButton3 ) {
+ myEditCurrentArgument = GroupPoints->LineEdit3;
+ GroupPoints->PushButton1->setDown(false);
+ GroupPoints->PushButton2->setDown(false);
+ GroupPoints->LineEdit1->setEnabled( false );
+ GroupPoints->LineEdit2->setEnabled( false );
+ GroupPoints->LineEdit3->setEnabled( true );
}
globalSelection(); // close local contexts, if any
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
- if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
+ if ( myEditCurrentArgument == GroupPoints->LineEdit2 || myEditCurrentArgument == GroupPoints->LineEdit3 )
aNeedType = TopAbs_EDGE;
localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
{
QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 ||
- send == GroupPoints->LineEdit2 ) {
+ send == GroupPoints->LineEdit2 ||
+ send == GroupPoints->LineEdit3 ) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
GroupPoints->LineEdit1->setText( "" );
GroupPoints->LineEdit2->setText( "" );
+ GroupPoints->LineEdit3->setText( "" );
myPoint = myDir = GEOM::GEOM_Object::_nil();
//globalSelection( GEOM_POINT );
aParameters<<GroupPoints->SpinBox_DX->text();
aParameters<<GroupPoints->SpinBox_DY->text();
- GEOM::GEOM_Object_var anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeEllipse( myPoint, myDir, aMajorR, aMinorR );
+ GEOM::GEOM_Object_var anObj = myMajor->_is_nil() ?
+ GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeEllipse ( myPoint, myDir, aMajorR, aMinorR ) :
+ GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeEllipseVec( myPoint, myDir, aMajorR, aMinorR, myMajor );
if ( !anObj->_is_nil() ) {
if ( !IsPreview() )
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
objMap[GroupPoints->LineEdit1->text()] = myPoint;
if (!CORBA::is_nil(myDir))
objMap[GroupPoints->LineEdit2->text()] = myDir;
+ if (!CORBA::is_nil(myMajor))
+ objMap[GroupPoints->LineEdit3->text()] = myMajor;
addSubshapesToFather( objMap );
}
#include <GEOMBase_Skeleton.h>
-class DlgRef_2Sel2Spin;
+class DlgRef_3Sel2Spin;
//=================================================================================
// class : BasicGUI_EllipseDlg
void enterEvent( QEvent* );
private:
- GEOM::GEOM_Object_var myPoint, myDir;
+ GEOM::GEOM_Object_var myPoint, myDir, myMajor;
- DlgRef_2Sel2Spin* GroupPoints;
+ DlgRef_3Sel2Spin* GroupPoints;
private slots:
void ClickOnOk();
{
}
+//////////////////////////////////////////
+// DlgRef_3Sel2Spin
+//////////////////////////////////////////
+
+DlgRef_3Sel2Spin::DlgRef_3Sel2Spin( QWidget* parent, Qt::WindowFlags f )
+: QWidget( parent, f )
+{
+ setupUi( this );
+}
+
+DlgRef_3Sel2Spin::~DlgRef_3Sel2Spin()
+{
+}
+
//////////////////////////////////////////
// DlgRef_3Sel3Spin1Check
//////////////////////////////////////////
{
const double prec = 1e-12;
- if ( abs(theValue) < thePrecision)
+ if ( qAbs(theValue) < prec )
return "0";
QString aRes;
~DlgRef_3Sel1Spin();
};
+//////////////////////////////////////////
+// DlgRef_3Sel2Spin
+//////////////////////////////////////////
+
+#include "ui_DlgRef_3Sel2Spin_QTD.h"
+
+class DLGREF_EXPORT DlgRef_3Sel2Spin : public QWidget,
+ public Ui::DlgRef_3Sel2Spin_QTD
+{
+ Q_OBJECT
+
+public:
+ DlgRef_3Sel2Spin( QWidget* = 0, Qt::WindowFlags = 0 );
+ ~DlgRef_3Sel2Spin();
+};
+
//////////////////////////////////////////
// DlgRef_3Sel3Spin1Check
//////////////////////////////////////////
--- /dev/null
+<ui version="4.0" >
+ <class>DlgRef_3Sel2Spin_QTD</class>
+ <widget class="QWidget" name="DlgRef_3Sel2Spin_QTD" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>120</width>
+ <height>177</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle" >
+ <string/>
+ </property>
+ <layout class="QGridLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>0</number>
+ </property>
+ <item row="0" column="0" >
+ <widget class="QGroupBox" name="GroupBox1" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title" >
+ <string/>
+ </property>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="TextLabel1" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>TL1</string>
+ </property>
+ <property name="wordWrap" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QPushButton" name="PushButton1" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2" >
+ <widget class="QLineEdit" name="LineEdit1" />
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="TextLabel2" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>TL2</string>
+ </property>
+ <property name="wordWrap" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QPushButton" name="PushButton2" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2" >
+ <widget class="QLineEdit" name="LineEdit2" />
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="TextLabel3" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>TL3</string>
+ </property>
+ <property name="wordWrap" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QPushButton" name="PushButton3" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2" >
+ <widget class="QLineEdit" name="LineEdit3" />
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="TextLabel4" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>TL4</string>
+ </property>
+ <property name="wordWrap" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" colspan="2" >
+ <widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DX" />
+ </item>
+ <item row="4" column="0" >
+ <widget class="QLabel" name="TextLabel5" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>TL5</string>
+ </property>
+ <property name="wordWrap" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1" colspan="2" >
+ <widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DY" />
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11" />
+ <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
+ <customwidgets>
+ <customwidget>
+ <class>SalomeApp_DoubleSpinBox</class>
+ <extends>QDoubleSpinBox</extends>
+ <header location="global" >SalomeApp_DoubleSpinBox.h</header>
+ </customwidget>
+ </customwidgets>
+ <tabstops>
+ <tabstop>PushButton1</tabstop>
+ <tabstop>LineEdit1</tabstop>
+ <tabstop>PushButton2</tabstop>
+ <tabstop>LineEdit2</tabstop>
+ <tabstop>PushButton3</tabstop>
+ <tabstop>LineEdit3</tabstop>
+ <tabstop>SpinBox_DX</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>
ui_DlgRef_3Radio1Sel1Spin_QTD.h \
ui_DlgRef_3Sel1Check_QTD.h \
ui_DlgRef_3Sel1Spin_QTD.h \
+ ui_DlgRef_3Sel2Spin_QTD.h \
ui_DlgRef_3Sel3Spin1Check_QTD.h \
ui_DlgRef_3Sel3Spin2Check_QTD.h \
ui_DlgRef_3Sel4Spin2Check_QTD.h \
<translation>Import operation has finished with errors:</translation>
</message>
</context>
+ <context>
+ <name>BasicGUI_EllipseDlg</name>
+ <message>
+ <source>GEOM_VECTOR_MAJOR</source>
+ <translation>Major Axis</translation>
+ </message>
+ <message>
+ <source>ORIGIN_DEFAULT</source>
+ <translation>Origin by default</translation>
+ </message>
+ <message>
+ <source>X_AXIS_DEFAULT</source>
+ <translation>X axis by default</translation>
+ </message>
+ <message>
+ <source>Z_AXIS_DEFAULT</source>
+ <translation>Z axis by default</translation>
+ </message>
+ </context>
<context>
<name>BasicGUI_MarkerDlg</name>
<message>
TopoDS_Shape aShapePnt = aRefPoint->GetValue();
if (aShapePnt.ShapeType() != TopAbs_VERTEX) {
Standard_ConstructionError::Raise
- ("Circle creation aborted: invalid center argument, must be a point");
+ ("Ellipse creation aborted: invalid center argument, must be a point");
}
aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
}
TopoDS_Shape aShapeVec = aRefVector->GetValue();
if (aShapeVec.ShapeType() != TopAbs_EDGE) {
Standard_ConstructionError::Raise
- ("Circle creation aborted: invalid vector argument, must be a vector or an edge");
+ ("Ellipse creation aborted: invalid normal vector argument, must be a vector or an edge");
}
TopoDS_Edge anE = TopoDS::Edge(aShapeVec);
TopoDS_Vertex V1, V2;
aV = gp_Vec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2));
if (aV.Magnitude() < gp::Resolution()) {
Standard_ConstructionError::Raise
- ("Circle creation aborted: vector of zero length is given");
+ ("Ellipse creation aborted: normal vector of zero length is given");
}
}
}
+ // Main Axis vector
+ gp_Vec aVM = gp::DX();
+ Handle(GEOM_Function) aRefVectorMaj = aCI.GetVectorMajor();
+ if (!aRefVectorMaj.IsNull()) {
+ TopoDS_Shape aShapeVec = aRefVectorMaj->GetValue();
+ if (aShapeVec.ShapeType() != TopAbs_EDGE) {
+ Standard_ConstructionError::Raise
+ ("Ellipse creation aborted: invalid major axis vector argument, must be a vector or an edge");
+ }
+ TopoDS_Edge anE = TopoDS::Edge(aShapeVec);
+ TopoDS_Vertex V1, V2;
+ TopExp::Vertices(anE, V1, V2, Standard_True);
+ if (!V1.IsNull() && !V2.IsNull()) {
+ aVM = gp_Vec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2));
+ if (aVM.Magnitude() < gp::Resolution()) {
+ Standard_ConstructionError::Raise
+ ("Ellipse creation aborted: major axis vector of zero length is given");
+ }
+ if (aV.IsParallel(aVM, Precision::Angular())) {
+ Standard_ConstructionError::Raise
+ ("Ellipse creation aborted: normal and major axis vectors are parallel");
+ }
+ }
+ }
+
// Axes
- gp_Ax2 anAxes (aP, aV);
+ gp_Ax2 anAxes (aP, aV, aVM);
// Ellipse
gp_Elips anEll (anAxes, aCI.GetRMajor(), aCI.GetRMinor());
aShape = BRepBuilderAPI_MakeEdge(anEll).Edge();
//=============================================================================
Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
(Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
- double theRMajor, double theRMinor)
+ double theRMajor, double theRMinor,
+ Handle(GEOM_Object) theVecMaj)
{
SetErrorCode(KO);
// Not set thePnt means origin of global CS,
// Not set theVec means Z axis of global CS
+ // Not set theVecMaj means X axis of global CS
//if (thePnt.IsNull() || theVec.IsNull()) return NULL;
//Add a new Ellipse object
aCI.SetRMajor(theRMajor);
aCI.SetRMinor(theRMinor);
+ if (!theVecMaj.IsNull()) {
+ Handle(GEOM_Function) aRefVecMaj = theVecMaj->GetLastFunction();
+ if (aRefVecMaj.IsNull()) return NULL;
+ aCI.SetVectorMajor(aRefVecMaj);
+ }
+
//Compute the Ellipse value
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
}
//Make a Python command
- GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
- << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
+ if (!theVecMaj.IsNull()) {
+ GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
+ << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor
+ << ", " << theVecMaj << ")";
+ }
+ else {
+ GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
+ << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
+ }
SetErrorCode(OK);
return anEll;
Standard_EXPORT Handle(GEOM_Object) MakeEllipse (Handle(GEOM_Object) thePnt,
Handle(GEOM_Object) theVec,
- double theRMajor, double theRMinor);
+ double theRMajor, double theRMinor,
+ Handle(GEOM_Object) theVecMaj);
Standard_EXPORT Handle(GEOM_Object) MakeArc (Handle(GEOM_Object) thePnt1,
Handle(GEOM_Object) thePnt2,
//
#include "GEOM_Function.hxx"
-#define ELLIPS_ARG_CC 1
-#define ELLIPS_ARG_VV 2
-#define ELLIPS_ARG_RMAJ 3
-#define ELLIPS_ARG_RMIN 4
+#define ELLIPS_ARG_CC 1
+#define ELLIPS_ARG_VV 2
+#define ELLIPS_ARG_RMAJ 3
+#define ELLIPS_ARG_RMIN 4
+#define ELLIPS_ARG_VVMAJ 5
class GEOMImpl_IEllipse
{
void SetRMajor(double theR) { _func->SetReal(ELLIPS_ARG_RMAJ, theR); }
void SetRMinor(double theR) { _func->SetReal(ELLIPS_ARG_RMIN, theR); }
+ void SetVectorMajor(Handle(GEOM_Function) theV) { _func->SetReference(ELLIPS_ARG_VVMAJ, theV); }
+
Handle(GEOM_Function) GetCenter() { return _func->GetReference(ELLIPS_ARG_CC); }
Handle(GEOM_Function) GetVector() { return _func->GetReference(ELLIPS_ARG_VV); }
double GetRMajor() { return _func->GetReal(ELLIPS_ARG_RMAJ); }
double GetRMinor() { return _func->GetReal(ELLIPS_ARG_RMIN); }
+ Handle(GEOM_Function) GetVectorMajor() { return _func->GetReference(ELLIPS_ARG_VVMAJ); }
+
private:
Handle(GEOM_Function) _func;
//if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
//Get the arguments
- Handle(GEOM_Object) aPnt, aVec;
+ Handle(GEOM_Object) aPnt, aVec, aVecMaj;
+ if (!CORBA::is_nil(thePnt)) {
+ aPnt = GetOperations()->GetEngine()->GetObject
+ (thePnt->GetStudyID(), thePnt->GetEntry());
+ if (aPnt.IsNull()) return aGEOMObject._retn();
+ }
+ if (!CORBA::is_nil(theVec)) {
+ aVec = GetOperations()->GetEngine()->GetObject
+ (theVec->GetStudyID(), theVec->GetEntry());
+ if (aVec.IsNull()) return aGEOMObject._retn();
+ }
+
+ // Make Ellipse
+ Handle(GEOM_Object) anObject =
+ GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor, aVecMaj);
+ if (!GetOperations()->IsDone() || anObject.IsNull())
+ return aGEOMObject._retn();
+
+ return GetObject(anObject);
+}
+
+//=============================================================================
+/*!
+ * MakeEllipseVec
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipseVec
+ (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
+ CORBA::Double theRMajor, double theRMinor,
+ GEOM::GEOM_Object_ptr theVecMaj)
+{
+ GEOM::GEOM_Object_var aGEOMObject;
+
+ //Set a not done flag
+ GetOperations()->SetNotDone();
+
+ // Not set thePnt means origin of global CS,
+ // Not set theVec means Z axis of global CS
+ // Not set theVecMaj means X axis of global CS
+ //if (thePnt == NULL || theVec == NULL || theVecMaj == NULL) return aGEOMObject._retn();
+
+ //Get the arguments
+ Handle(GEOM_Object) aPnt, aVec, aVecMaj;
if (!CORBA::is_nil(thePnt)) {
aPnt = GetOperations()->GetEngine()->GetObject
(thePnt->GetStudyID(), thePnt->GetEntry());
(theVec->GetStudyID(), theVec->GetEntry());
if (aVec.IsNull()) return aGEOMObject._retn();
}
+ if (!CORBA::is_nil(theVecMaj)) {
+ aVecMaj = GetOperations()->GetEngine()->GetObject
+ (theVecMaj->GetStudyID(), theVecMaj->GetEntry());
+ if (aVecMaj.IsNull()) return aGEOMObject._retn();
+ }
// Make Ellipse
Handle(GEOM_Object) anObject =
- GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor);
+ GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor, aVecMaj);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
GEOM::GEOM_Object_ptr theVector,
double theRMajor, double theRMinor);
+ GEOM::GEOM_Object_ptr MakeEllipseVec (GEOM::GEOM_Object_ptr theCenter,
+ GEOM::GEOM_Object_ptr theVector,
+ double theRMajor, double theRMinor,
+ GEOM::GEOM_Object_ptr theVectorMajor);
+
GEOM::GEOM_Object_ptr MakeArc (GEOM::GEOM_Object_ptr thePnt1,
GEOM::GEOM_Object_ptr thePnt2,
GEOM::GEOM_Object_ptr thePnt3);
return anObj;
}
+//=============================================================================
+// MakeEllipseVec:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeEllipseVec (GEOM::GEOM_Object_ptr theCenter,
+ GEOM::GEOM_Object_ptr theVector,
+ CORBA::Double theRMajor,
+ CORBA::Double theRMinor,
+ GEOM::GEOM_Object_ptr theVectorMajor)
+{
+ beginService( " GEOM_Superv_i::MakeEllipseVec" );
+ MESSAGE("GEOM_Superv_i::MakeEllipseVec");
+ getCurvesOp();
+ GEOM::GEOM_Object_ptr anObj = myCurvesOp->MakeEllipseVec(theCenter, theVector, theRMajor, theRMinor, theVectorMajor);
+ endService( " GEOM_Superv_i::MakeEllipseVec" );
+ return anObj;
+}
+
//=============================================================================
// MakeArc:
//=============================================================================
GEOM::GEOM_Object_ptr MakeEllipse (GEOM::GEOM_Object_ptr theCenter,
GEOM::GEOM_Object_ptr theVector,
CORBA::Double theRMajor, CORBA::Double theRMinor);
+ GEOM::GEOM_Object_ptr MakeEllipseVec (GEOM::GEOM_Object_ptr theCenter,
+ GEOM::GEOM_Object_ptr theVector,
+ CORBA::Double theRMajor, CORBA::Double theRMinor,
+ GEOM::GEOM_Object_ptr theVectorMajor);
GEOM::GEOM_Object_ptr MakeArc (GEOM::GEOM_Object_ptr thePnt1,
GEOM::GEOM_Object_ptr thePnt2,
GEOM::GEOM_Object_ptr thePnt3);
# @param theVec Vector, normal to the plane of the ellipse.
# @param theRMajor Major ellipse radius.
# @param theRMinor Minor ellipse radius.
+ # @param theVecMaj Vector, direction by the main exis.
# @return New GEOM_Object, containing the created ellipse.
#
# @ref tui_creation_ellipse "Example"
- def MakeEllipse(self, thePnt, theVec, theRMajor, theRMinor):
+ def MakeEllipse(self, thePnt, theVec, theRMajor, theRMinor, theVecMaj=None):
# Example: see GEOM_TestAll.py
theRMajor, theRMinor, Parameters = ParseParameters(theRMajor, theRMinor)
- anObj = self.CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor)
+ if theVecMaj is not None:
+ anObj = self.CurvesOp.MakeEllipseVec(thePnt, theVec, theRMajor, theRMinor, theVecMaj)
+ else:
+ anObj = self.CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor)
+ pass
RaiseIfFailed("MakeEllipse", self.CurvesOp)
anObj.SetParameters(Parameters)
return anObj