From: dmv Date: Fri, 7 Nov 2008 12:20:55 +0000 (+0000) Subject: 0018862: EDF 657 GEOM : to be able to create an arc of ellipse X-Git-Tag: Phase8_Part1_16122008~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7dde2fd90a181bab975bbc8375348b6924b6f93b;p=modules%2Fgeom.git 0018862: EDF 657 GEOM : to be able to create an arc of ellipse --- diff --git a/doc/salome/gui/GEOM/images/arc.png b/doc/salome/gui/GEOM/images/arc.png index 02f1ffcb1..b7ef8777f 100755 Binary files a/doc/salome/gui/GEOM/images/arc.png and b/doc/salome/gui/GEOM/images/arc.png differ diff --git a/doc/salome/gui/GEOM/images/arc2.png b/doc/salome/gui/GEOM/images/arc2.png index 1d9c84fbe..6305cac1e 100644 Binary files a/doc/salome/gui/GEOM/images/arc2.png and b/doc/salome/gui/GEOM/images/arc2.png differ diff --git a/doc/salome/gui/GEOM/images/arcofellipse1.png b/doc/salome/gui/GEOM/images/arcofellipse1.png new file mode 100644 index 000000000..cd50fff1c Binary files /dev/null and b/doc/salome/gui/GEOM/images/arcofellipse1.png differ diff --git a/doc/salome/gui/GEOM/images/arcofellipse2.png b/doc/salome/gui/GEOM/images/arcofellipse2.png new file mode 100644 index 000000000..24172dfae Binary files /dev/null and b/doc/salome/gui/GEOM/images/arcofellipse2.png differ diff --git a/doc/salome/gui/GEOM/input/creating_arc.doc b/doc/salome/gui/GEOM/input/creating_arc.doc index 8ee49ca23..4537a8a0f 100644 --- a/doc/salome/gui/GEOM/input/creating_arc.doc +++ b/doc/salome/gui/GEOM/input/creating_arc.doc @@ -29,6 +29,17 @@ Point, End Point, boolean Sense) \image html arc2.png +Finally, it is possible to create an Arc of Ellipse, which is also done by three points: +the Arguments Point 1, Point 2 and the Center Point. The arc is built on the Ellipse that +lies in the plane defined by the three points, with the center in the Center point. +The major radius of the Ellipse is defined by the distance between the Center Point and +the most remote Argument point. The minor radius is defined by the shortest distance between the +other Argument point and the major radius. +\n TUI Command: geompy.MakeArcOfEllipse(Center Point, First Point, Second Point) +\n Arguments: Name + 3 vertices. + +\image html arcofellipse2.png + \n Examples: \image html arcsn.png @@ -40,4 +51,10 @@ Point, End Point, boolean Sense) \image html arcsn2.png
Reversed arc.
+\image html arcofellipse1.png +
Arc Of Ellipse.
+ +Our TUI Scripts provide you with useful examples of creation of +\ref tui_creation_arc "Basic Geometric Objects". */ + diff --git a/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc b/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc index d9c30a23b..89baf140d 100644 --- a/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc +++ b/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc @@ -132,6 +132,39 @@ id_ellipse = geompy.addToStudy(ellipse,"Ellipse") gg.createAndDisplayGO(id_vector) gg.createAndDisplayGO(id_ellipse) \endcode + +\anchor tui_creation_arc +

Creation of an Arc

+ +\code +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p0 = geompy.MakeVertex(0., 0., 0.) +p1 = geompy.MakeVertex(100., 0., 0.) +p2 = geompy.MakeVertex(50., 0., 50.) + +# create an arc from a three points +arc1 = geompy.MakeArc(p0, p1, p2) + +# create an arc from a center point, a start point and end point +arc2 = geompy.MakeArcCenter(p0, p1, p2, 1) + +# create an arc from a center point, a major point and minor point +arc3 = geompy.MakeArcOfEllipse(p0, p1, p2) + +# add objects in the study +id_arc1 = geompy.addToStudy(arc1, "Arc 1") +id_arc2 = geompy.addToStudy(arc2, "Arc 2") +id_arc3 = geompy.addToStudy(arc3, "Arc 3") + +# display the arcs +gg.createAndDisplayGO(id_arc1) +gg.createAndDisplayGO(id_arc2) +gg.createAndDisplayGO(id_arc3) +\endcode \anchor tui_creation_curve

Creation of a Curve

diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 4f9afd0df..fd153f760 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -2095,6 +2095,17 @@ module GEOM in GEOM_Object thePnt1, in GEOM_Object thePnt2, in boolean theSense); + + /*! + * Create an arc of ellipse of center C and two points P1 P2. + * \param theCenter Center point of the arc. + * \param thePnt1 Major radius is distance from center to Pnt1. + * \param thePnt2 define a plane and Minor radius as a shortest distance from Pnt2 to vector Center->Pnt1. + * \return New GEOM_Object, containing the created arc. + */ + GEOM_Object MakeArcOfEllipse (in GEOM_Object theCenter, + in GEOM_Object thePnt1, + in GEOM_Object thePnt2); /*! diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index 5ca45ef11..725d36075 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -480,6 +480,9 @@ module GEOM in GEOM_Object thePnt1, in GEOM_Object thePnt2, in boolean theSense) ; + GEOM_Object MakeArcOfEllipse (in GEOM_Object theCenter, + in GEOM_Object thePnt1, + in GEOM_Object thePnt2) ; GEOM_Object MakePolyline (in GEOM_List thePoints) ; GEOM_Object MakeSplineBezier (in GEOM_List thePoints) ; GEOM_Object MakeSplineInterpolation (in GEOM_List thePoints) ; diff --git a/resources/GEOMCatalog.xml.in b/resources/GEOMCatalog.xml.in index 2739da315..ebf49b2e1 100644 --- a/resources/GEOMCatalog.xml.in +++ b/resources/GEOMCatalog.xml.in @@ -4224,6 +4224,38 @@ + + MakeArcOfEllipse + + + unknown + 0 + + + thePnt1 + GEOM_Object + unknown + + + thePnt2 + GEOM_Object + unknown + + + thePnt3 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + MakePolyline diff --git a/resources/Makefile.am b/resources/Makefile.am index bce407e4a..9f8e9ecfd 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -38,6 +38,8 @@ ImportExport \ ShHealing \ angle.png \ arc.png \ +arccenter.png \ +arcofellipse.png \ archimede.png \ axisinertia.png \ basicproperties.png \ @@ -203,7 +205,6 @@ free_faces.png \ propagate.png \ redo.png \ undo.png \ -arccenter.png \ glue2.png \ remove_extra_edges.png \ coordsys.png \ diff --git a/resources/arcofellipse.png b/resources/arcofellipse.png new file mode 100755 index 000000000..3f15b6ef9 Binary files /dev/null and b/resources/arcofellipse.png differ diff --git a/src/BasicGUI/BasicGUI_ArcDlg.cxx b/src/BasicGUI/BasicGUI_ArcDlg.cxx index f0f7056e9..3d3dee4e1 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.cxx +++ b/src/BasicGUI/BasicGUI_ArcDlg.cxx @@ -58,6 +58,7 @@ BasicGUI_ArcDlg::BasicGUI_ArcDlg( GeometryGUI* theGeometryGUI, QWidget* parent, QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC" ) ) ); QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC_CENTER" ) ) ); QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); + QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC_OF_ELLIPSE" ) ) ); setWindowTitle( tr( "GEOM_ARC_TITLE" ) ); @@ -65,8 +66,7 @@ BasicGUI_ArcDlg::BasicGUI_ArcDlg( GeometryGUI* theGeometryGUI, QWidget* parent, mainFrame()->GroupConstructors->setTitle( tr( "GEOM_ARC" ) ); mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton2->setIcon( image1 ); - mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); - mainFrame()->RadioButton3->close(); + mainFrame()->RadioButton3->setIcon( image3 ); Group3Pnts = new DlgRef_3Sel( centralWidget() ); @@ -109,10 +109,30 @@ BasicGUI_ArcDlg::BasicGUI_ArcDlg( GeometryGUI* theGeometryGUI, QWidget* parent, Group3Pnts2->CheckButton1->setText( tr( "GEOM_REVERSE" ) ); + Group3Pnts3 = new DlgRef_3Sel( centralWidget() ); + + Group3Pnts3->GroupBox1->setTitle( tr( "GEOM_POINTS" ) ); + Group3Pnts3->TextLabel1->setText( tr( "GEOM_CENTER_POINT" ) ); + Group3Pnts3->TextLabel2->setText( tr( "GEOM_POINT_I" ).arg( 1 ) ); + Group3Pnts3->TextLabel3->setText( tr( "GEOM_POINT_I" ).arg( 2 ) ); + + Group3Pnts3->LineEdit1->setReadOnly( true ); + Group3Pnts3->LineEdit2->setReadOnly( true ); + Group3Pnts3->LineEdit3->setReadOnly( true ); + + Group3Pnts3->LineEdit1->setEnabled(true); + Group3Pnts3->LineEdit2->setEnabled(false); + Group3Pnts3->LineEdit3->setEnabled(false); + + Group3Pnts3->PushButton1->setIcon(image2); + Group3Pnts3->PushButton2->setIcon(image2); + Group3Pnts3->PushButton3->setIcon(image2); + QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->addWidget( Group3Pnts ); layout->addWidget( Group3Pnts2 ); + layout->addWidget( Group3Pnts3 ); setHelpFileName( "create_arc_page.html" ); @@ -166,9 +186,17 @@ void BasicGUI_ArcDlg::Init() connect( Group3Pnts2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( Group3Pnts2->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( Group3Pnts2->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); - + connect( Group3Pnts2->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( ReverseSense() ) ); + connect( Group3Pnts3->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( Group3Pnts3->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( Group3Pnts3->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + + connect( Group3Pnts3->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( Group3Pnts3->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( Group3Pnts3->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); @@ -211,9 +239,6 @@ bool BasicGUI_ArcDlg::ClickOnApply() //================================================================================= void BasicGUI_ArcDlg::SelectionIntoArgument() { - if ( getConstructorId() != 0 && getConstructorId() != 1 ) - return; - myEditCurrentArgument->setText( "" ); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); @@ -234,6 +259,12 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() else if ( myEditCurrentArgument == Group3Pnts2->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); return; break; + case 2: + if ( myEditCurrentArgument == Group3Pnts3->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == Group3Pnts3->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == Group3Pnts3->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); + return; + break; } } // nbSel == 1 @@ -314,6 +345,23 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() Group3Pnts2->PushButton1->click(); } break; + case 2: + if ( myEditCurrentArgument == Group3Pnts3->LineEdit1 ) { + myPoint1 = aSelectedObject; + if ( !myPoint1->_is_nil() && myPoint2->_is_nil() ) + Group3Pnts3->PushButton2->click(); + } + else if ( myEditCurrentArgument == Group3Pnts3->LineEdit2 ) { + myPoint2 = aSelectedObject; + if ( !myPoint2->_is_nil() && myPoint3->_is_nil() ) + Group3Pnts3->PushButton3->click(); + } + else if ( myEditCurrentArgument == Group3Pnts3->LineEdit3 ) { + myPoint3 = aSelectedObject; + if ( !myPoint3->_is_nil() && myPoint1->_is_nil() ) + Group3Pnts3->PushButton1->click(); + } + break; } } @@ -384,6 +432,32 @@ void BasicGUI_ArcDlg::SetEditCurrentArgument() Group3Pnts2->LineEdit3->setEnabled(true); } break; + case 2: + if ( send == Group3Pnts3->PushButton1 ) { + myEditCurrentArgument = Group3Pnts3->LineEdit1; + Group3Pnts3->PushButton2->setDown(false); + Group3Pnts3->PushButton3->setDown(false); + Group3Pnts3->LineEdit1->setEnabled(true); + Group3Pnts3->LineEdit2->setEnabled(false); + Group3Pnts3->LineEdit3->setEnabled(false); + } + else if ( send == Group3Pnts3->PushButton2 ) { + myEditCurrentArgument = Group3Pnts3->LineEdit2; + Group3Pnts3->PushButton1->setDown(false); + Group3Pnts3->PushButton3->setDown(false); + Group3Pnts3->LineEdit1->setEnabled(false); + Group3Pnts3->LineEdit2->setEnabled(true); + Group3Pnts3->LineEdit3->setEnabled(false); + } + else if ( send == Group3Pnts3->PushButton3 ) { + myEditCurrentArgument = Group3Pnts3->LineEdit3; + Group3Pnts3->PushButton1->setDown(false); + Group3Pnts3->PushButton2->setDown(false); + Group3Pnts3->LineEdit1->setEnabled(false); + Group3Pnts3->LineEdit2->setEnabled(false); + Group3Pnts3->LineEdit3->setEnabled(true); + } + break; } myEditCurrentArgument->setFocus(); // SelectionIntoArgument(); @@ -400,7 +474,8 @@ void BasicGUI_ArcDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); if ( send == Group3Pnts->LineEdit1 || send == Group3Pnts->LineEdit2 || send == Group3Pnts->LineEdit3 || - send == Group3Pnts2->LineEdit1 || send == Group3Pnts2->LineEdit2 || send == Group3Pnts2->LineEdit3 ) { + send == Group3Pnts2->LineEdit1 || send == Group3Pnts2->LineEdit2 || send == Group3Pnts2->LineEdit3 || + send == Group3Pnts3->LineEdit1 || send == Group3Pnts3->LineEdit2 || send == Group3Pnts3->LineEdit3 ) { myEditCurrentArgument = send; GEOMBase_Skeleton::LineEditReturnPressed(); } @@ -474,6 +549,14 @@ bool BasicGUI_ArcDlg::isValid( QString& msg ) return false; break; } + case 2: + { + if (Group3Pnts3->LineEdit1->text().trimmed().isEmpty() || + Group3Pnts3->LineEdit2->text().trimmed().isEmpty() || + Group3Pnts3->LineEdit3->text().trimmed().isEmpty()) + return false; + break; + } } return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() && !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 ); @@ -506,6 +589,14 @@ bool BasicGUI_ArcDlg::execute( ObjectList& objects ) } break; } + case 2: + { + if ( !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) ) { + anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeArcOfEllipse( myPoint1, myPoint2, myPoint3 ); + res = true; + } + break; + } } if ( !anObj->_is_nil() ) { objects.push_back( anObj._retn() ); @@ -527,8 +618,9 @@ void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId ) globalSelection(); // close local contexts, if any localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select Vertex on All Shapes - Group3Pnts2->hide(); Group3Pnts->show(); + Group3Pnts2->hide(); + Group3Pnts3->hide(); Group3Pnts->PushButton1->setDown(true); Group3Pnts->PushButton2->setDown(false); Group3Pnts->PushButton3->setDown(false); @@ -550,6 +642,7 @@ void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId ) Group3Pnts->hide(); Group3Pnts2->show(); + Group3Pnts3->hide(); Group3Pnts2->PushButton1->setDown(true); Group3Pnts2->PushButton2->setDown(false); Group3Pnts2->PushButton3->setDown(false); @@ -564,6 +657,28 @@ void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId ) myEditCurrentArgument = Group3Pnts2->LineEdit1; break; } + case 2: + { + globalSelection(); // close local contexts, if any + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select Vertex on All Shapes + + Group3Pnts->hide(); + Group3Pnts2->hide(); + Group3Pnts3->show(); + Group3Pnts3->PushButton1->setDown(true); + Group3Pnts3->PushButton2->setDown(false); + Group3Pnts3->PushButton3->setDown(false); + Group3Pnts3->LineEdit1->setText( "" ); + Group3Pnts3->LineEdit2->setText( "" ); + Group3Pnts3->LineEdit3->setText( "" ); + Group3Pnts3->LineEdit1->setEnabled(true); + Group3Pnts3->LineEdit2->setEnabled(false); + Group3Pnts3->LineEdit3->setEnabled(false); + myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); + + myEditCurrentArgument = Group3Pnts3->LineEdit1; + break; + } } qApp->processEvents(); @@ -608,6 +723,11 @@ void BasicGUI_ArcDlg::addSubshapesToStudy() objMap[Group3Pnts2->LineEdit2->text()] = myPoint2; objMap[Group3Pnts2->LineEdit3->text()] = myPoint3; break; + case 2: + objMap[Group3Pnts3->LineEdit1->text()] = myPoint1; + objMap[Group3Pnts3->LineEdit2->text()] = myPoint2; + objMap[Group3Pnts3->LineEdit3->text()] = myPoint3; + break; } addSubshapesToFather( objMap ); } diff --git a/src/BasicGUI/BasicGUI_ArcDlg.h b/src/BasicGUI/BasicGUI_ArcDlg.h index 577181324..6b1b740ac 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.h +++ b/src/BasicGUI/BasicGUI_ArcDlg.h @@ -59,6 +59,7 @@ private: DlgRef_3Sel* Group3Pnts; DlgRef_3Sel1Check* Group3Pnts2; + DlgRef_3Sel* Group3Pnts3; private slots: void ClickOnOk(); diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index ddeb05af5..c3f1d2083 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -18,6 +18,10 @@ ICON_DLG_ARC_CENTER arccenter.png + + ICON_DLG_ARC_OF_ELLIPSE + arcofellipse.png + ICON_DLG_BASICPROPERTIES basicproperties.png diff --git a/src/GEOMImpl/GEOMImpl_ArcDriver.cxx b/src/GEOMImpl/GEOMImpl_ArcDriver.cxx index d08ae24cc..fa9026bf4 100644 --- a/src/GEOMImpl/GEOMImpl_ArcDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ArcDriver.cxx @@ -36,12 +36,16 @@ #include #include +#include +#include #include #include #include #include #include +#include #include +#include #include "utilities.h" @@ -77,7 +81,7 @@ Standard_Integer GEOMImpl_ArcDriver::Execute(TFunction_Logbook& log) const Standard_Integer aType = aFunction->GetType(); TopoDS_Shape aShape; - if ((aType == CIRC_ARC_THREE_PNT) || (aType == CIRC_ARC_CENTER)) + if ((aType == CIRC_ARC_THREE_PNT) || (aType == CIRC_ARC_CENTER) || (aType == ELLIPSE_ARC_CENTER_TWO_PNT)) { Handle(GEOM_Function) aRefPoint1 = aCI.GetPoint1(); Handle(GEOM_Function) aRefPoint2 = aCI.GetPoint2(); @@ -107,9 +111,7 @@ Standard_Integer GEOMImpl_ArcDriver::Execute(TFunction_Logbook& log) const { GC_MakeArcOfCircle arc (aP1, aP2, aP3); aShape = BRepBuilderAPI_MakeEdge(arc).Edge(); - } - else // CIRC_ARC_CENTER - { + } else if ( aType == CIRC_ARC_CENTER ) { // CIRC_ARC_CENTER Standard_Boolean sense = aCI.GetSense(); Standard_Real aRad = aP1.Distance(aP2); @@ -125,9 +127,29 @@ Standard_Integer GEOMImpl_ArcDriver::Execute(TFunction_Logbook& log) const GC_MakeArcOfCircle arc (aGeomCirc->Circ(), aP2, aP3, Standard_True); aShape = BRepBuilderAPI_MakeEdge(arc).Edge(); + } else if ( aType == ELLIPSE_ARC_CENTER_TWO_PNT ) { // ELLIPSE_ARC_CENTER_TWO_PNT + if ( aP1.Distance(aP2) <= aP1.Distance(aP3) ) { + // Standard_ConstructionError::Raise("Arc creation aborted: the distance from Center Point to Point 1 needs to be bigger than the distance from Center Point to Point 2"); + cout << "aP1.Distance(aP2) <= aP1.Distance(aP3)" << endl; + gp_Pnt aTmpP = aP2; + aP2 = aP3; + aP3 = aTmpP; + } + + GC_MakeEllipse ellipse (aP2, aP3, aP1); + Handle(Geom_Ellipse) aGeomEllipse = ellipse.Value(); + + gp_Vec aV1 (aP1, aP2); + gp_Vec aV2 (aP1, aP3); + + double alpha = fabs(aV1.Angle(aV2)); + + GC_MakeArcOfEllipse arc (aGeomEllipse->Elips(), aP2, aP3, Standard_True); + aShape = BRepBuilderAPI_MakeEdge(arc).Edge(); } } - } else { + } + else { } if (aShape.IsNull()) return 0; diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx index 3bd246817..c9507c5fa 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx @@ -509,6 +509,67 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcCenter (Handle(GEOM_Objec return anArc; } +//============================================================================= +/*! + * MakeArcOfEllipse + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3) +{ + SetErrorCode(KO); + + if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL; + + //Add a new Circle Arc object + Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE_ARC); + + //Add a new Circle Arc function + Handle(GEOM_Function) aFunction = + anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), ELLIPSE_ARC_CENTER_TWO_PNT); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL; + GEOMImpl_IArc aCI (aFunction); + + Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction(); + Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction(); + Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction(); + + + if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL; + + aCI.SetPoint1(aRefPnt1); + aCI.SetPoint2(aRefPnt2); + aCI.SetPoint3(aRefPnt3); + + //Compute the Arc value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Arc driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcOfEllipse(" + << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")"; + + SetErrorCode(OK); + return anArc; +} + //============================================================================= /*! * MakeSplineBezier diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx index ed6605d0d..60a1e56b8 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx @@ -60,6 +60,10 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations { Handle(GEOM_Object) thePnt3, bool theSense); + Standard_EXPORT Handle(GEOM_Object) MakeArcOfEllipse (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3); + Standard_EXPORT Handle(GEOM_Object) MakeSplineBezier (list thePoints); Standard_EXPORT Handle(GEOM_Object) MakeSplineInterpolation (list thePoints); diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 56bdc81e4..d0cc19686 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -85,6 +85,8 @@ #define GEOM_SHAPES_ON_SHAPE 42 +#define GEOM_ELLIPSE_ARC 43 + //GEOM_Function types @@ -213,8 +215,9 @@ #define ELLIPSE_PNT_VEC_RR 1 -#define CIRC_ARC_THREE_PNT 1 -#define CIRC_ARC_CENTER 2 +#define CIRC_ARC_THREE_PNT 1 +#define CIRC_ARC_CENTER 2 +#define ELLIPSE_ARC_CENTER_TWO_PNT 3 #define FILLET_SHAPE_ALL 1 #define FILLET_SHAPE_EDGES 2 diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.cc b/src/GEOM_I/GEOM_ICurvesOperations_i.cc index 94d8a03f5..740385c37 100644 --- a/src/GEOM_I/GEOM_ICurvesOperations_i.cc +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.cc @@ -273,6 +273,43 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArcCenter return GetObject(anObject); } + +//============================================================================= +/*! + * MakeArc + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArcOfEllipse + (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn(); + + //Get the reference points + Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject + (thePnt1->GetStudyID(), thePnt1->GetEntry()); + Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject + (thePnt2->GetStudyID(), thePnt2->GetEntry()); + Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject + (thePnt3->GetStudyID(), thePnt3->GetEntry()); + + if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn(); + + // Make Arc + Handle(GEOM_Object) anObject = + GetOperations()->MakeArcOfEllipse(aPnt1, aPnt2, aPnt3); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakePolyline diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.hh b/src/GEOM_I/GEOM_ICurvesOperations_i.hh index d341c4575..e719bf74d 100644 --- a/src/GEOM_I/GEOM_ICurvesOperations_i.hh +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.hh @@ -64,6 +64,10 @@ class GEOM_I_EXPORT GEOM_ICurvesOperations_i : GEOM::GEOM_Object_ptr thePnt2, GEOM::GEOM_Object_ptr thePnt3, bool theSense); + + GEOM::GEOM_Object_ptr MakeArcOfEllipse (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3); GEOM::GEOM_Object_ptr MakePolyline (const GEOM::ListOfGO& thePoints); diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 910c380bd..7f4641c65 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -2545,6 +2545,21 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeArcCenter (GEOM::GEOM_Object_ptr theCen return anObj; } +//============================================================================= +// MakeArcOfEllipse: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeArcOfEllipse (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3) +{ + beginService( " GEOM_Superv_i::MakeArcOfEllipse" ); + MESSAGE("GEOM_Superv_i::MakeArcOfEllipse"); + getCurvesOp(); + GEOM::GEOM_Object_ptr anObj = myCurvesOp->MakeArcOfEllipse(thePnt1, thePnt2, thePnt3); + endService( " GEOM_Superv_i::MakeArcOfEllipse" ); + return anObj; +} + //============================================================================= // MakePolyline: //============================================================================= diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index e35bf641b..b081ff798 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -557,6 +557,9 @@ public: GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2, CORBA::Boolean theSense); + GEOM::GEOM_Object_ptr MakeArcOfEllipse (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3); GEOM::GEOM_Object_ptr MakePolyline (GEOM::GEOM_List_ptr thePoints); GEOM::GEOM_Object_ptr MakeSplineBezier (GEOM::GEOM_List_ptr thePoints); GEOM::GEOM_Object_ptr MakeSplineInterpolation (GEOM::GEOM_List_ptr thePoints); diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index ca727edcb..d9a607048 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -92,6 +92,7 @@ def TestAll (geompy, math): Arc = geompy.MakeArc(py, pz, px) #(3 GEOM_Object_ptr)->GEOM_Object_ptr Arc2 = geompy.MakeArcCenter(py, pz, px,0) #(3 GEOM_Object_ptr,Boolean)->GEOM_Object_ptr + Arc3 = geompy.MakeArcOfEllipse(p0, px, pz) #(3 GEOM_Object_ptr,Boolean)->GEOM_Object_ptr Circle = geompy.MakeCircle(p0, vz, radius1) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr Circle1 = geompy.MakeCircleThreePnt(p0, pxyz, px) #(3 GEOM_Object_ptr)->GEOM_Object_ptr Circle2 = geompy.MakeCircleCenter2Pnt(p0, pxyz, py) #(3 GEOM_Object_ptr)->GEOM_Object_ptr @@ -292,6 +293,8 @@ def TestAll (geompy, math): id_Plane1 = geompy.addToStudy(Plane1, "Plane by 3 points") id_Arc = geompy.addToStudy(Arc, "Arc") + id_Arc2 = geompy.addToStudy(Arc2, "Arc2") + id_Arc3 = geompy.addToStudy(Arc3, "Arc3") id_Circle = geompy.addToStudy(Circle, "Circle") id_Circle1 = geompy.addToStudy(Circle1, "Circle by 3 points") id_Circle2 = geompy.addToStudy(Circle2, "Circle by center and 2 points") diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index d3477a9a3..17baee494 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -492,6 +492,19 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.CurvesOp.MakeArcCenter(thePnt1, thePnt2, thePnt3, theSense) RaiseIfFailed("MakeArcCenter", self.CurvesOp) return anObj + + ## Create an arc of ellipse, of center and two points. + # @param theCenter Center of the arc. + # @param thePnt1 defines major radius of the arc by distance from Pnt1 to Pnt2. + # @param thePnt2 defines plane of ellipse and minor radius as distance from Pnt3 to line from Pnt1 to Pnt2. + # @return New GEOM_Object, containing the created arc. + # + # @ref swig_MakeArc "Example" + def MakeArcOfEllipse(self,theCenter, thePnt1, thePnt2): + # Example: see GEOM_TestAll.py + anObj = self.CurvesOp.MakeArcOfEllipse(theCenter, thePnt1, thePnt2) + RaiseIfFailed("MakeArcOfEllipse", self.CurvesOp) + return anObj ## Create a circle with given center, normal vector and radius. # @param thePnt Circle center.