]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
0018862: EDF 657 GEOM : to be able to create an arc of ellipse
authordmv <dmv@opencascade.com>
Fri, 7 Nov 2008 12:20:55 +0000 (12:20 +0000)
committerdmv <dmv@opencascade.com>
Fri, 7 Nov 2008 12:20:55 +0000 (12:20 +0000)
24 files changed:
doc/salome/gui/GEOM/images/arc.png
doc/salome/gui/GEOM/images/arc2.png
doc/salome/gui/GEOM/images/arcofellipse1.png [new file with mode: 0644]
doc/salome/gui/GEOM/images/arcofellipse2.png [new file with mode: 0644]
doc/salome/gui/GEOM/input/creating_arc.doc
doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc
idl/GEOM_Gen.idl
idl/GEOM_Superv.idl
resources/GEOMCatalog.xml.in
resources/Makefile.am
resources/arcofellipse.png [new file with mode: 0755]
src/BasicGUI/BasicGUI_ArcDlg.cxx
src/BasicGUI/BasicGUI_ArcDlg.h
src/GEOMGUI/GEOM_images.ts
src/GEOMImpl/GEOMImpl_ArcDriver.cxx
src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx
src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx
src/GEOMImpl/GEOMImpl_Types.hxx
src/GEOM_I/GEOM_ICurvesOperations_i.cc
src/GEOM_I/GEOM_ICurvesOperations_i.hh
src/GEOM_I_Superv/GEOM_Superv_i.cc
src/GEOM_I_Superv/GEOM_Superv_i.hh
src/GEOM_SWIG/GEOM_TestAll.py
src/GEOM_SWIG/geompyDC.py

index 02f1ffcb1f149247ca2b188cbc7ee7f72742daeb..b7ef8777f019f01f4d5ae7489a0c12dde98a5cee 100755 (executable)
Binary files a/doc/salome/gui/GEOM/images/arc.png and b/doc/salome/gui/GEOM/images/arc.png differ
index 1d9c84fbeb7e1747349f2159cc4f707e1e68d55c..6305cac1ea86fd809f6aad867c70a01e1138e8cc 100644 (file)
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 (file)
index 0000000..cd50fff
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 (file)
index 0000000..24172df
Binary files /dev/null and b/doc/salome/gui/GEOM/images/arcofellipse2.png differ
index 8ee49ca23c6a2996c774aa9937f248819f807bdd..4537a8a0fbf8ea95ed034549d4128b772530d815 100644 (file)
@@ -29,6 +29,17 @@ Point, End Point, boolean Sense)</em>
 
 \image html arc2.png
 
+Finally, it is possible to create an <b>Arc of Ellipse</b>, which is also done by three points: 
+the Arguments <b>Point 1</b>, <b>Point 2</b> and the <b>Center Point</b>. The arc is built on the Ellipse that 
+lies in the plane defined by the three points, with the center in the <b>Center point</b>. 
+The major radius of the Ellipse is defined by the distance between the <b>Center Point</b> 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 <b>TUI Command:</b> <em>geompy.MakeArcOfEllipse(Center Point, First Point, Second Point)</em>
+\n <b>Arguments:</b> Name + 3 vertices.
+
+\image html arcofellipse2.png
+
 \n <b>Examples:</b>
 
 \image html arcsn.png
@@ -40,4 +51,10 @@ Point, End Point, boolean Sense)</em>
 \image html arcsn2.png
 <center>Reversed arc.</center>
 
+\image html arcofellipse1.png
+<center>Arc Of Ellipse.</center>
+
+Our <b>TUI Scripts</b> provide you with useful examples of creation of
+\ref tui_creation_arc "Basic Geometric Objects".
 */
+
index d9c30a23b4bbdf7bc79237a996866c6cf340823a..89baf140d5ad9bbf223a9951ebc2d15501052812 100644 (file)
@@ -132,6 +132,39 @@ id_ellipse = geompy.addToStudy(ellipse,"Ellipse")
 gg.createAndDisplayGO(id_vector)
 gg.createAndDisplayGO(id_ellipse)
 \endcode
+
+\anchor tui_creation_arc
+<br><h2>Creation of an Arc</h2>
+
+\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
 <br><h2>Creation of a Curve</h2>
index 4f9afd0df19e7710f25a079b9038a9a5f4bd7ff1..fd153f76070b5c1c3bdf78103be1920c6e80f62f 100644 (file)
@@ -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);
 
 
     /*!
index 5ca45ef111460d0d535f18fd4787f70b197d7e2c..725d3607517c6c32bb1f5fef8b586bf9573a5c91 100644 (file)
@@ -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) ;
index 2739da315910312cb578874abbe03712dc3ec01f..ebf49b2e173bc4b8b8b6a756f76919818c59bc4a 100644 (file)
                         </outParameter-list>
                         <DataStream-list></DataStream-list>
                     </component-service>
+                    <component-service>
+                        <service-name>MakeArcOfEllipse</service-name>
+                        <service-author></service-author>
+                        <service-version></service-version>
+                        <service-comment>unknown</service-comment>
+                        <service-by-default>0</service-by-default>
+                        <inParameter-list>
+                            <inParameter>
+                                <inParameter-name>thePnt1</inParameter-name>
+                                <inParameter-type>GEOM_Object</inParameter-type>
+                                <inParameter-comment>unknown</inParameter-comment>
+                            </inParameter>
+                            <inParameter>
+                                <inParameter-name>thePnt2</inParameter-name>
+                                <inParameter-type>GEOM_Object</inParameter-type>
+                                <inParameter-comment>unknown</inParameter-comment>
+                            </inParameter>
+                            <inParameter>
+                                <inParameter-name>thePnt3</inParameter-name>
+                                <inParameter-type>GEOM_Object</inParameter-type>
+                                <inParameter-comment>unknown</inParameter-comment>
+                            </inParameter>
+                        </inParameter-list>
+                        <outParameter-list>
+                            <outParameter>
+                                <outParameter-name>return</outParameter-name>
+                                <outParameter-type>GEOM_Object</outParameter-type>
+                                <outParameter-comment>unknown</outParameter-comment>
+                            </outParameter>
+                        </outParameter-list>
+                        <DataStream-list></DataStream-list>
+                    </component-service>
                     <component-service>
                         <service-name>MakePolyline</service-name>
                         <service-author></service-author>
index bce407e4afa074d91f0ac587e51388fd456fde42..9f8e9ecfd25df96c7cda26054a956a38cc212a40 100644 (file)
@@ -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 (executable)
index 0000000..3f15b6e
Binary files /dev/null and b/resources/arcofellipse.png differ
index f0f7056e951e8960bc641c3d5c1450c97c2390de..3d3dee4e1931c6b122274752cc3bfedfc9f210ac 100644 (file)
@@ -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 );
 }
index 577181324be67e100acad6895a291e62a1f0fd3d..6b1b740ac1307e14717a3d6068e621fc792f86b3 100644 (file)
@@ -59,6 +59,7 @@ private:
 
   DlgRef_3Sel*                       Group3Pnts;
   DlgRef_3Sel1Check*                 Group3Pnts2;
+  DlgRef_3Sel*                       Group3Pnts3;
 
 private slots:
   void                               ClickOnOk();
index ddeb05af5dcc134628994bd87f88762e77b4454c..c3f1d2083970209c17f7c6d7b50ff2225c4ec730 100644 (file)
             <source>ICON_DLG_ARC_CENTER</source>
             <translation>arccenter.png</translation>
         </message>
+       <message>
+            <source>ICON_DLG_ARC_OF_ELLIPSE</source>
+            <translation>arcofellipse.png</translation>
+        </message>
         <message>
             <source>ICON_DLG_BASICPROPERTIES</source>
             <translation>basicproperties.png</translation>
index d08ae24cce2561693ab6f791d963ff6aa6246bda..fa9026bf4bfb2461f749104d266bfbe71ead9566 100644 (file)
 
 #include <GC_MakeArcOfCircle.hxx>
 #include <GC_MakeCircle.hxx>
+#include <GC_MakeArcOfEllipse.hxx>
+#include <GC_MakeEllipse.hxx>
 #include <Standard_ConstructionError.hxx>
 #include <Precision.hxx>
 #include <gp_Pnt.hxx>
 #include <gp_Vec.hxx>
 #include <gp_Circ.hxx>
+#include <gp_Elips.hxx>
 #include <Geom_Circle.hxx>
+#include <Geom_Ellipse.hxx>
 
 #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;
index 3bd246817d1fa83ce43cf6d7581f97ecf7938cfa..c9507c5faf933b3dce2f4b110b54be2c4322b386 100644 (file)
@@ -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
index ed6605d0dbc62d84ceb744096666751ecfa52eb3..60a1e56b8373dce9f91e1658f0a6445a7625fcf3 100644 (file)
@@ -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<Handle(GEOM_Object)> thePoints);
   Standard_EXPORT Handle(GEOM_Object) MakeSplineInterpolation (list<Handle(GEOM_Object)> thePoints);
 
index 56bdc81e4901d226d2613179560566efd0b1e6d5..d0cc196863d8700795fd77b124c48910b02467e0 100755 (executable)
@@ -85,6 +85,8 @@
 
 #define GEOM_SHAPES_ON_SHAPE 42
 
+#define GEOM_ELLIPSE_ARC 43
+
 
 //GEOM_Function types
 
 
 #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
index 94d8a03f5f4fb3e3045e9be12307d08c6724dd3f..740385c37a16704d67f77685e3e011bf94cde3b2 100644 (file)
@@ -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
index d341c457528365b0cc1dc49bb3d758c2cd8ed6c5..e719bf74dbd18a0d28999b5563400c3103b9d938 100644 (file)
@@ -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);
 
index 910c380bdc254a17e98a70baf65e9884d15c0ab5..7f4641c6511e318afbe876b65897e9c245e14655 100644 (file)
@@ -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:
 //=============================================================================
index e35bf641b5a01c985ee4a387ad68681797e8de8b..b081ff7989195da3f959446070326e27c5f2fc5c 100644 (file)
@@ -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);
index ca727edcbb7ed34a7fa73d2d14d9ed0b6eb8a9b3..d9a607048f7eca71e3648ed78cc03ee90090e9c9 100644 (file)
@@ -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")
index d3477a9a3853e1f341764b090ff7036af397a6d1..17baee494efc4d38c7827f1c5bf3d63ea9986513 100644 (file)
@@ -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.