Issue 0020154 : improve ellipse creeation function

This commit is contained in:
vsr 2009-02-25 13:31:16 +00:00
parent 476c4f91de
commit 46fd079b60
21 changed files with 497 additions and 47 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -4,17 +4,30 @@
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

View File

@ -116,21 +116,32 @@ gg = salome.ImportComponentGUI("GEOM")
# 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
@ -302,4 +313,4 @@ gg.setDisplayMode(id_plane3,1)
gg.setTransparency(id_plane3,0.5)
\endcode
*/
*/

View File

@ -2102,6 +2102,21 @@ module GEOM
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.

View File

@ -478,6 +478,11 @@ module GEOM
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) ;

View File

@ -68,19 +68,23 @@ BasicGUI_EllipseDlg::BasicGUI_EllipseDlg( GeometryGUI* theGeometryGUI, QWidget*
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 );
@ -114,7 +118,7 @@ void BasicGUI_EllipseDlg::Init()
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();
@ -137,9 +141,11 @@ void BasicGUI_EllipseDlg::Init()
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 ) ) );
@ -188,13 +194,16 @@ bool BasicGUI_EllipseDlg::ClickOnApply()
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
@ -219,6 +228,7 @@ void BasicGUI_EllipseDlg::SelectionIntoArgument()
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;
}
@ -232,7 +242,7 @@ void BasicGUI_EllipseDlg::SelectionIntoArgument()
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() ) {
@ -278,7 +288,12 @@ void BasicGUI_EllipseDlg::SelectionIntoArgument()
}
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();
}
}
@ -298,19 +313,31 @@ void BasicGUI_EllipseDlg::SetEditCurrentArgument()
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 );
@ -328,7 +355,8 @@ void BasicGUI_EllipseDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 ||
send == GroupPoints->LineEdit2 ) {
send == GroupPoints->LineEdit2 ||
send == GroupPoints->LineEdit3 ) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
@ -350,6 +378,7 @@ void BasicGUI_EllipseDlg::ActivateThisDialog()
GroupPoints->LineEdit1->setText( "" );
GroupPoints->LineEdit2->setText( "" );
GroupPoints->LineEdit3->setText( "" );
myPoint = myDir = GEOM::GEOM_Object::_nil();
//globalSelection( GEOM_POINT );
@ -429,7 +458,9 @@ bool BasicGUI_EllipseDlg::execute( ObjectList& objects )
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));
@ -450,6 +481,8 @@ void BasicGUI_EllipseDlg::addSubshapesToStudy()
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 );
}

View File

@ -28,7 +28,7 @@
#include <GEOMBase_Skeleton.h>
class DlgRef_2Sel2Spin;
class DlgRef_3Sel2Spin;
//=================================================================================
// class : BasicGUI_EllipseDlg
@ -54,9 +54,9 @@ private:
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();

View File

@ -542,6 +542,20 @@ DlgRef_3Sel1Spin::~DlgRef_3Sel1Spin()
{
}
//////////////////////////////////////////
// DlgRef_3Sel2Spin
//////////////////////////////////////////
DlgRef_3Sel2Spin::DlgRef_3Sel2Spin( QWidget* parent, Qt::WindowFlags f )
: QWidget( parent, f )
{
setupUi( this );
}
DlgRef_3Sel2Spin::~DlgRef_3Sel2Spin()
{
}
//////////////////////////////////////////
// DlgRef_3Sel3Spin1Check
//////////////////////////////////////////
@ -766,7 +780,7 @@ QString DlgRef::PrintDoubleValue( double theValue, int thePrecision )
{
const double prec = 1e-12;
if ( abs(theValue) < thePrecision)
if ( qAbs(theValue) < prec )
return "0";
QString aRes;

View File

@ -629,6 +629,22 @@ public:
~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
//////////////////////////////////////////

View File

@ -0,0 +1,199 @@
<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>

View File

@ -75,6 +75,7 @@ UIC_FILES = \
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 \

View File

@ -3760,6 +3760,25 @@ Please, select face, shell or solid and try again</translation>
<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>

View File

@ -79,7 +79,7 @@ Standard_Integer GEOMImpl_EllipseDriver::Execute(TFunction_Logbook& log) const
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));
}
@ -90,7 +90,7 @@ Standard_Integer GEOMImpl_EllipseDriver::Execute(TFunction_Logbook& log) const
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;
@ -99,12 +99,37 @@ Standard_Integer GEOMImpl_EllipseDriver::Execute(TFunction_Logbook& log) const
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();

View File

@ -334,12 +334,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR
//=============================================================================
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
@ -370,6 +372,12 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
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
@ -387,8 +395,15 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
}
//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;

View File

@ -51,7 +51,8 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations {
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,

View File

@ -23,10 +23,11 @@
//
#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
{
@ -40,12 +41,16 @@ 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;

View File

@ -181,7 +181,7 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipse
//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());
@ -195,7 +195,54 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipse
// 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();
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());
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();
}
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, aVecMaj);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();

View File

@ -57,6 +57,11 @@ class GEOM_I_EXPORT GEOM_ICurvesOperations_i :
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);

View File

@ -2532,6 +2532,23 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeEllipse (GEOM::GEOM_Object_ptr theCente
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:
//=============================================================================

View File

@ -557,6 +557,10 @@ public:
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);

View File

@ -652,13 +652,18 @@ class geompyDC(GEOM._objref_GEOM_Gen):
# @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