]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Start implementation of the "16564: EDF 509 GEOM : 3D line with mathematical equation...
authorrnv <rnv@opencascade.com>
Wed, 4 May 2011 13:32:04 +0000 (13:32 +0000)
committerrnv <rnv@opencascade.com>
Wed, 4 May 2011 13:32:04 +0000 (13:32 +0000)
19 files changed:
idl/GEOM_Gen.idl
src/BasicGUI/BasicGUI_CurveDlg.cxx
src/BasicGUI/BasicGUI_CurveDlg.h
src/BasicGUI/BasicGUI_ParamCurveWidget.cxx [new file with mode: 0644]
src/BasicGUI/BasicGUI_ParamCurveWidget.h [new file with mode: 0644]
src/BasicGUI/Makefile.am
src/GEOM/GEOM_Engine.cxx
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx
src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx
src/GEOMImpl/GEOMImpl_IPolyline.hxx
src/GEOMImpl/GEOMImpl_ISpline.hxx
src/GEOMImpl/GEOMImpl_PolylineDriver.cxx
src/GEOMImpl/GEOMImpl_SplineDriver.cxx
src/GEOMImpl/GEOMImpl_Types.hxx
src/GEOMImpl/Makefile.am
src/GEOM_I/GEOM_ICurvesOperations_i.cc
src/GEOM_I/GEOM_ICurvesOperations_i.hh
src/GEOM_SWIG/geompyDC.py

index a63bd51c624a3f76f3aa4c533505fbebfae528f8..ba85debacb3ac62f4a1771e7d5a609af7a59fa47 100644 (file)
@@ -135,6 +135,21 @@ module GEOM
     FOM_AutoCorrect
   };
 
+  /*!
+   * Kind of the curves.
+   * Used in the function GEOM_Gen.MakeCurveParametric()
+   */
+  enum curve_type {
+    /*! Polyline curve */
+    Polyline,
+    
+    /*! Bezier curve */
+    Bezier,
+
+    /*! Interpolation, curve */
+    Interpolation
+  };
+
 
   typedef sequence<string>      string_array;
   typedef sequence<short>       short_array;
@@ -2595,6 +2610,25 @@ module GEOM
                                          in boolean  theIsClosed,
                                          in boolean  theDoReordering);
 
+    /*!
+     *  Creates a curve using the parametric definition of the basic points.
+     *  \param thexExpr parametric equation of the coordinates X.
+     *  \param theyExpr parametric equation of the coordinates Y.
+     *  \param thezExpr parametric equation of the coordinates Z.
+     *  \param theParamMin the minimal value of the parameter.
+     *  \param theParamMax the maximum value of the parameter.
+     *  \param theParamStep the step of the parameter.
+     *  \param theCurveType the type of the curve.
+     *  \return New GEOM_Object, containing the created curve.
+     */    
+    GEOM_Object MakeCurveParametric(in string thexExpr,
+                                   in string theyExpr,
+                                   in string thezExpr,
+                                   in double theParamMin,
+                                   in double theParamMax,
+                                   in double theParamStep,
+                                   in curve_type theCurveType);
+
     /*!
      *  Create a sketcher (wire or face), following the textual description,
      *  passed through \a theCommand argument. \n
index d7af0b9b00ecf8c0c7773259f0b0fe98e89088a7..fa10f10309271cd34b655e5c8729cd84e733b7b5 100644 (file)
@@ -24,6 +24,7 @@
 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
 
 #include "BasicGUI_CurveDlg.h"
+#include "BasicGUI_ParamCurveWidget.h"
 
 #include <DlgRef.h>
 #include <GeometryGUI.h>
@@ -69,6 +70,20 @@ BasicGUI_CurveDlg::BasicGUI_CurveDlg( GeometryGUI* theGeometryGUI, QWidget* pare
   mainFrame()->RadioButton2->setIcon( image3 );
   mainFrame()->RadioButton3->setIcon( image2 );
 
+  QGroupBox* creationModeCroup = new QGroupBox(this);
+  QButtonGroup* bg = new QButtonGroup(this);
+
+  creationModeCroup->setTitle( tr( "GEOM_CURVE_CRMODE" ) );  
+  QHBoxLayout * creationModeLayout = new QHBoxLayout(creationModeCroup);
+  myBySelectionBtn = new QRadioButton(  tr( "GEOM_CURVE_SELECTION" ) ,creationModeCroup );
+  myAnaliticalBtn = new QRadioButton(  tr( "GEOM_CURVE_ANALITICAL" ) ,creationModeCroup );
+
+  bg->addButton(myBySelectionBtn);
+  bg->addButton(myAnaliticalBtn);
+  
+  creationModeLayout->addWidget(myBySelectionBtn);
+  creationModeLayout->addWidget(myAnaliticalBtn);
+
   GroupPoints = new DlgRef_1Sel3Check( centralWidget() );
 
   GroupPoints->GroupBox1->setTitle( tr( "GEOM_NODES" ) );
@@ -88,9 +103,13 @@ BasicGUI_CurveDlg::BasicGUI_CurveDlg( GeometryGUI* theGeometryGUI, QWidget* pare
 
   GroupPoints->CheckButton3->hide();
 
+  myParams = new BasicGUI_ParamCurveWidget( centralWidget() );
+
   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
   layout->setMargin( 0 ); layout->setSpacing( 6 );
+  layout->addWidget( creationModeCroup );
   layout->addWidget( GroupPoints );
+  layout->addWidget( myParams );
   /***************************************************************/
 
   setHelpFileName( "create_curve_page.html" );
@@ -123,6 +142,26 @@ void BasicGUI_CurveDlg::Init()
   localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
 
   showOnlyPreviewControl();
+  myBySelectionBtn->setChecked(true);
+
+  /* Get setting of step value from file configuration */
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+  double step = resMgr ? resMgr->doubleValue( "Geometry", "SettingsGeomStep", 10. ) : 10.;
+
+  double aMax( 100. ), aMin( 0.0 );
+
+  /* min, max, step and decimals for spin boxes & initial values */
+  initSpinBox( myParams->myPMin, COORD_MIN, COORD_MAX, step, "length_precision" );
+  initSpinBox( myParams->myPMax, COORD_MIN, COORD_MAX, step, "length_precision" );
+  initSpinBox( myParams->myPStep, COORD_MIN, COORD_MAX, step, "length_precision" );
+  myParams->myPMin->setValue( aMin );
+  myParams->myPMax->setValue( aMax );
+  myParams->myPStep->setValue( step );
+  myParams->myXExpr->setText("t");
+  myParams->myYExpr->setText("t");
+  myParams->myZExpr->setText("t");
+  
+  myParams->hide();
 
   /* signals and slots connections */
   connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog( ) ) );
@@ -141,6 +180,17 @@ void BasicGUI_CurveDlg::Init()
   connect( myGeomGUI->getApp()->selectionMgr(),
            SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
 
+  connect( myBySelectionBtn, SIGNAL( clicked() ), this, SLOT( CreationModeChanged() ) );
+  connect( myAnaliticalBtn, SIGNAL( clicked() ), this, SLOT( CreationModeChanged() ) );
+
+  connect(myParams->myPMin, SIGNAL(valueChanged(double)),    this, SLOT(ValueChangedInSpinBox(double)));
+  connect(myParams->myPMax, SIGNAL(valueChanged(double)),    this, SLOT(ValueChangedInSpinBox(double)));
+  connect(myParams->myPStep, SIGNAL(valueChanged(double)),    this, SLOT(ValueChangedInSpinBox(double)));
+
+  connect(myParams->myXExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()));
+  connect(myParams->myYExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()));
+  connect(myParams->myZExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()));
+
   initName( tr( "GEOM_CURVE" ) );
   resize(100,100);
   ConstructorsClicked( 0 );  
@@ -321,7 +371,17 @@ GEOM::GEOM_IOperations_ptr BasicGUI_CurveDlg::createOperation()
 //=================================================================================
 bool BasicGUI_CurveDlg::isValid( QString& msg )
 {
-  return myPoints.count() > 1;
+  if( myBySelectionBtn->isChecked() )
+    return myPoints.count() > 1;
+  else {
+    bool ok = myParams->myPMin->isValid( msg, !IsPreview() ) &&
+              myParams->myPMax->isValid( msg, !IsPreview() ) &&
+              myParams->myPStep->isValid( msg, !IsPreview() );
+    ok &= !myParams->myXExpr->text().isEmpty();
+    ok &= !myParams->myYExpr->text().isEmpty();
+    ok &= !myParams->myZExpr->text().isEmpty();
+    return ok;
+  }
 }
 
 //=================================================================================
@@ -343,23 +403,59 @@ bool BasicGUI_CurveDlg::execute( ObjectList& objects )
 
   switch ( getConstructorId() ) {
   case 0 :
-    anObj = anOper->MakePolyline( points.in(), GroupPoints->CheckButton1->isChecked() );
+    if( myBySelectionBtn->isChecked() )
+      anObj = anOper->MakePolyline( points.in(), GroupPoints->CheckButton1->isChecked() );
+    else
+      anObj = anOper->MakeCurveParametric(qPrintable(myParams->myXExpr->text()),
+                                         qPrintable(myParams->myYExpr->text()),
+                                         qPrintable(myParams->myZExpr->text()),
+                                         myParams->myPMin->value(),
+                                         myParams->myPMax->value(),
+                                         myParams->myPStep->value(),
+                                         GEOM::Polyline);
     res = true;
     break;
   case 1 :
-    anObj = anOper->MakeSplineBezier( points.in(), GroupPoints->CheckButton1->isChecked() );
+    if( myBySelectionBtn->isChecked() )
+      anObj = anOper->MakeSplineBezier( points.in(), GroupPoints->CheckButton1->isChecked() );
+    else
+      anObj = anOper->MakeCurveParametric(qPrintable(myParams->myXExpr->text()),
+                                         qPrintable(myParams->myYExpr->text()),
+                                         qPrintable(myParams->myZExpr->text()),
+                                         myParams->myPMin->value(),
+                                         myParams->myPMax->value(),
+                                         myParams->myPStep->value(),
+                                         GEOM::Bezier);
+
     res = true;
     break;
   case 2 :
-    anObj = anOper->MakeSplineInterpolation( points.in(), GroupPoints->CheckButton1->isChecked(),
-                                             GroupPoints->CheckButton2->isChecked() );
+    if( myBySelectionBtn->isChecked() )
+      anObj = anOper->MakeSplineInterpolation( points.in(), GroupPoints->CheckButton1->isChecked(),
+                                              GroupPoints->CheckButton2->isChecked() );
+    else
+      anObj = anOper->MakeCurveParametric(qPrintable(myParams->myXExpr->text()),
+                                         qPrintable(myParams->myYExpr->text()),
+                                         qPrintable(myParams->myZExpr->text()),
+                                         myParams->myPMin->value(),
+                                         myParams->myPMax->value(),
+                                         myParams->myPStep->value(),
+                                         GEOM::Interpolation);
     res = true;
     break;
   }
 
-  if ( !anObj->_is_nil() )
+  if ( !anObj->_is_nil() ) {
+    if(myAnaliticalBtn->isChecked() && !IsPreview()) {
+      QStringList aParameters;
+      aParameters<<myParams->myPMin->text();
+      aParameters<<myParams->myPMax->text();
+      aParameters<<myParams->myPStep->text();
+      anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+    }
     objects.push_back( anObj._retn() );
-
+  }
+  
   return res;
 }
 
@@ -372,3 +468,32 @@ void BasicGUI_CurveDlg::addSubshapesToStudy()
   for ( int i = 0; i < myPoints.count(); i++ )
     GEOMBase::PublishSubObject( myPoints[i].get() );
 }
+
+//=================================================================================
+// function : CreationModeChanged
+// purpose  :
+//=================================================================================
+void BasicGUI_CurveDlg::CreationModeChanged() {
+  const QObject* s = sender();
+  GroupPoints->setVisible(myBySelectionBtn == s);
+  myParams->setVisible(myBySelectionBtn != s);
+  
+  ConstructorsClicked( getConstructorId() );
+}
+
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose  :
+//=================================================================================
+void BasicGUI_CurveDlg::ValueChangedInSpinBox(double/*theValue*/)
+{
+  processPreview();
+}
+
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose  :
+//=================================================================================
+void BasicGUI_CurveDlg::OnEditingFinished() {
+  processPreview();
+}
index 982579788df5171b0785371141b8dd379d0d7482..19e48cb088b7bff234da70e5ccc1b57535c6435c 100644 (file)
@@ -32,6 +32,8 @@
 #include <list>
 
 class DlgRef_1Sel3Check;
+class QRadioButton;
+class BasicGUI_ParamCurveWidget;
 
 //=================================================================================
 // class    : BasicGUI_CurveDlg
@@ -59,6 +61,9 @@ private:
 private:
   DlgRef_1Sel3Check*                 GroupPoints;
   QList<GEOM::GeomObjPtr>            myPoints;
+  QRadioButton*                      myAnaliticalBtn;
+  QRadioButton*                      myBySelectionBtn;
+  BasicGUI_ParamCurveWidget*         myParams; 
 
 private slots:
   void                               ClickOnOk();
@@ -71,6 +76,9 @@ private slots:
   void                               CheckButtonToggled();
   void                               SelectionIntoArgument();
   void                               SetEditCurrentArgument();
+  void                               CreationModeChanged();
+  void                               ValueChangedInSpinBox(double/*theValue*/);
+  void                               OnEditingFinished();
 };
 
 #endif // BASICGUI_CURVEDLG_H
diff --git a/src/BasicGUI/BasicGUI_ParamCurveWidget.cxx b/src/BasicGUI/BasicGUI_ParamCurveWidget.cxx
new file mode 100644 (file)
index 0000000..8f7695a
--- /dev/null
@@ -0,0 +1,97 @@
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+// GEOM GEOMGUI : GUI for Geometry component
+// File   : BasicGUI_ParamCurveWidget.h
+// Author : Roman NIKOLAEV (roman.nikolaev@opencascade.com)
+
+#include "BasicGUI_ParamCurveWidget.h"
+
+#include <QLabel>
+#include <QLineEdit>
+#include <QGridLayout>
+#include <QGroupBox>
+
+#include <SalomeApp_DoubleSpinBox.h>
+
+
+BasicGUI_ParamCurveWidget::BasicGUI_ParamCurveWidget(QWidget* parent):
+  QWidget(parent) {
+
+  QGridLayout* l = new QGridLayout( this );
+  l->setSpacing( 0 );
+  l->setMargin( 0 );
+
+  QGroupBox* groupBox = new QGroupBox( tr("GEOM_PCURVE_TITLE"), this );
+
+  QGridLayout* gridLayout = new QGridLayout( groupBox );
+  gridLayout->setSpacing( 6 );
+  gridLayout->setMargin( 11 );
+  
+  //X Equation
+  QLabel* textLabel1 = new QLabel( tr("GEOM_PCURVE_X"), groupBox );
+  myXExpr = new QLineEdit( groupBox );
+
+  //Y Equation
+  QLabel* textLabel2 = new QLabel(tr("GEOM_PCURVE_Y"), groupBox);
+  myYExpr = new QLineEdit( groupBox );
+
+  //Z Equation
+  QLabel* textLabel3 = new QLabel( tr("GEOM_PCURVE_Z"), groupBox );
+  myZExpr = new QLineEdit( groupBox );
+
+  // Min and Max
+  QLabel* textLabel4 = new QLabel( tr("GEOM_PCURVE_MIN"), groupBox );
+  myPMin = new SalomeApp_DoubleSpinBox( groupBox );
+
+  // Min and Max
+  QLabel* textLabel5 = new QLabel( tr("GEOM_PCURVE_MAX"), groupBox );
+  myPMax = new SalomeApp_DoubleSpinBox( groupBox );    
+
+  // Step
+  QLabel* textLabel6 = new QLabel( tr("GEOM_PCURVE_STEP"), groupBox );
+  myPStep = new SalomeApp_DoubleSpinBox( groupBox );
+
+  //Layout
+  gridLayout->addWidget(textLabel1, 0, 0, 1, 1);
+  gridLayout->addWidget(myXExpr,    0, 1, 1, 1);
+
+  gridLayout->addWidget(textLabel2, 1, 0, 1, 1);
+  gridLayout->addWidget(myYExpr,    1, 1, 1, 1);
+
+  gridLayout->addWidget(textLabel3, 2, 0, 1, 1);
+  gridLayout->addWidget(myZExpr,    2, 1, 1, 1);
+
+  gridLayout->addWidget(textLabel4, 3, 0, 1, 1);
+  gridLayout->addWidget(myPMin,     3, 1, 1, 1);
+
+  gridLayout->addWidget(textLabel5, 4, 0, 1, 1);
+  gridLayout->addWidget(myPMax,     4, 1, 1, 1);
+
+  gridLayout->addWidget(textLabel6, 5, 0, 1, 1);
+  gridLayout->addWidget(myPStep,    5, 1, 1, 1);
+
+  l->addWidget(groupBox, 0, 0, 1, 1);
+}
+
+
+BasicGUI_ParamCurveWidget::~BasicGUI_ParamCurveWidget(){
+}
diff --git a/src/BasicGUI/BasicGUI_ParamCurveWidget.h b/src/BasicGUI/BasicGUI_ParamCurveWidget.h
new file mode 100644 (file)
index 0000000..8adb8cc
--- /dev/null
@@ -0,0 +1,51 @@
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+// GEOM GEOMGUI : GUI for Geometry component
+// File   : BasicGUI_ParamCurveWidget.h
+// Author : Roman NIKOLAEV (roman.nikolaev@opencascade.com)
+
+#ifndef BASICGUI_PARAM_CURVE_WIDGET_H
+#define BASICGUI_PARAM_CURVE_WIDGET_H
+#include <QWidget>
+
+class QLineEdit;
+class SalomeApp_DoubleSpinBox;
+
+class BasicGUI_ParamCurveWidget: public QWidget {
+  Q_OBJECT
+
+ public:  
+  BasicGUI_ParamCurveWidget(QWidget * parent = 0);
+  ~BasicGUI_ParamCurveWidget();
+  
+  public:
+  QLineEdit* myXExpr;
+  QLineEdit* myYExpr;
+  QLineEdit* myZExpr;
+
+  SalomeApp_DoubleSpinBox*           myPMin;
+  SalomeApp_DoubleSpinBox*           myPMax;
+  SalomeApp_DoubleSpinBox*           myPStep;
+  
+};
+
+#endif //BASICGUI_PARAM_CURVE_WIDGET_H
index 88c19b11d5f7a8c8ca944ccf432e900a5948b2eb..9f47697a05bcd004df20dee4717260384db5f19a 100644 (file)
@@ -36,7 +36,8 @@ salomeinclude_HEADERS =                       \
        BasicGUI_MarkerDlg.h            \
        BasicGUI_PlaneDlg.h             \
        BasicGUI_PointDlg.h             \
-       BasicGUI_VectorDlg.h
+       BasicGUI_VectorDlg.h            \
+       BasicGUI_ParamCurveWidget.h
 #
 # OBSOLETE: BasicGUI_WorkingPlaneDlg.h
 #
@@ -56,7 +57,8 @@ dist_libBasicGUI_la_SOURCES =         \
        BasicGUI_VectorDlg.cxx          \
        BasicGUI_PlaneDlg.cxx           \
        BasicGUI_CurveDlg.cxx           \
-       BasicGUI_MarkerDlg.cxx
+       BasicGUI_MarkerDlg.cxx          \
+       BasicGUI_ParamCurveWidget.cxx
 #
 # OBSOLETE: BasicGUI_WorkingPlaneDlg.cxx
 #
@@ -70,7 +72,8 @@ MOC_FILES =                                   \
        BasicGUI_VectorDlg_moc.cxx              \
        BasicGUI_PlaneDlg_moc.cxx               \
        BasicGUI_CurveDlg_moc.cxx               \
-       BasicGUI_MarkerDlg_moc.cxx
+       BasicGUI_MarkerDlg_moc.cxx              \
+       BasicGUI_ParamCurveWidget_moc.cxx
 #
 # OBSOLETE: BasicGUI_WorkingPlaneDlg_moc.cxx
 #
index 5618f5b3a6b99edaa3613a127cc3974f5648ce69..c89ab8139229294ad480b919c2ae98b188c283fa 100644 (file)
@@ -1166,7 +1166,7 @@ void ReplaceVariables(TCollection_AsciiString& theCommand,
       else if(i == aTotalNbParams)
       {
         aStartPos = aCommand.Location(i-1, COMMA, 1, aCommand.Length()) + 2;
-        aEndPos = aCommand.Location(C_BRACKET, 1, aCommand.Length());
+        aEndPos = aCommand.Location(C_BRACKET, aStartPos , aCommand.Length());
       }
       //Replace other parameters (bettwen two ',' characters)
       else if(i != aFirstParam && i != aTotalNbParams )
index 2ee69bbde9550c0dce30e5249023e6f44da94dcf..fd5aec4c2b21678c60a6d54a84b0584831bd3512 100644 (file)
@@ -4334,6 +4334,49 @@ Otherwise the dimensions will be kept without modifications.</translation>
         <source>GEOM_IS_REORDER</source>
         <translation>Reorder vertices taking into account distances</translation>
     </message>
+    <message>
+        <source>GEOM_CURVE_CRMODE</source>
+        <translation>Creation Mode</translation>
+    </message>
+    <message>
+        <source>GEOM_CURVE_SELECTION</source>
+        <translation>By Selection</translation>
+    </message>
+    <message>
+        <source>GEOM_CURVE_ANALITICAL</source>
+        <translation>Analitical</translation>
+    </message>        
+</context>
+<context>
+    <name>BasicGUI_ParamCurveWidget</name>
+    <message>
+        <source>GEOM_PCURVE_TITLE</source>
+        <translation>Curve parameters</translation>
+    </message>
+    <message>
+        <source>GEOM_PCURVE_X</source>
+        <translation>X(t) equation</translation>
+    </message>
+    <message>
+        <source>GEOM_PCURVE_Y</source>
+        <translation>Y(t) equation</translation>
+    </message>
+    <message>
+        <source>GEOM_PCURVE_Z</source>
+        <translation>Z(t) equation</translation>
+    </message>
+    <message>
+        <source>GEOM_PCURVE_MIN</source>
+        <translation>Min t</translation>
+    </message>
+    <message>
+        <source>GEOM_PCURVE_MAX</source>
+        <translation>Max t</translation>
+    </message>        
+    <message>
+        <source>GEOM_PCURVE_STEP</source>
+        <translation>Step</translation>
+    </message>        
 </context>
 <context>
     <name>BasicGUI_EllipseDlg</name>
index 3d53948c382bdace1eaa0ba7e56eb43e4810d7af..54ac51a06dc5b8494fdb5f88b02710a93ff7fe18 100644 (file)
@@ -19,6 +19,9 @@
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 
+#include <Python.h>
+#include <structmember.h>
+
 #include <Standard_Stream.hxx>
 
 #include <GEOMImpl_ICurvesOperations.hxx>
 #include <Standard_Failure.hxx>
 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
 
+
+/* ==================================
+ * ===========  PYTHON ==============
+ * ==================================*/
+
+typedef struct {
+  PyObject_HEAD
+  int softspace;
+  std::string *out;
+  } PyStdOut;
+
+static void
+PyStdOut_dealloc(PyStdOut *self)
+{
+  PyObject_Del(self);
+}
+
+static PyObject *
+PyStdOut_write(PyStdOut *self, PyObject *args)
+{
+  char *c;
+  int l;
+  if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
+    return NULL;
+
+  //std::cerr << c ;
+  *(self->out)=*(self->out)+c;
+
+  Py_INCREF(Py_None);
+  return Py_None;
+}
+
+static PyMethodDef PyStdOut_methods[] = {
+  {"write",  (PyCFunction)PyStdOut_write,  METH_VARARGS,
+    PyDoc_STR("write(string) -> None")},
+  {NULL,    NULL}   /* sentinel */
+};
+
+static PyMemberDef PyStdOut_memberlist[] = {
+  {(char*)"softspace", T_INT,  offsetof(PyStdOut, softspace), 0,
+   (char*)"flag indicating that a space needs to be printed; used by print"},
+  {NULL} /* Sentinel */
+};
+
+static PyTypeObject PyStdOut_Type = {
+  /* The ob_type field must be initialized in the module init function
+   * to be portable to Windows without using C++. */
+  PyObject_HEAD_INIT(NULL)
+  0,                            /*ob_size*/
+  "PyOut",                      /*tp_name*/
+  sizeof(PyStdOut),             /*tp_basicsize*/
+  0,                            /*tp_itemsize*/
+  /* methods */
+  (destructor)PyStdOut_dealloc, /*tp_dealloc*/
+  0,                            /*tp_print*/
+  0,                            /*tp_getattr*/
+  0,                            /*tp_setattr*/
+  0,                            /*tp_compare*/
+  0,                            /*tp_repr*/
+  0,                            /*tp_as_number*/
+  0,                            /*tp_as_sequence*/
+  0,                            /*tp_as_mapping*/
+  0,                            /*tp_hash*/
+  0,                            /*tp_call*/
+  0,                            /*tp_str*/
+  PyObject_GenericGetAttr,      /*tp_getattro*/
+  /* softspace is writable:  we must supply tp_setattro */
+  PyObject_GenericSetAttr,      /* tp_setattro */
+  0,                            /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT,           /*tp_flags*/
+  0,                            /*tp_doc*/
+  0,                            /*tp_traverse*/
+  0,                            /*tp_clear*/
+  0,                            /*tp_richcompare*/
+  0,                            /*tp_weaklistoffset*/
+  0,                            /*tp_iter*/
+  0,                            /*tp_iternext*/
+  PyStdOut_methods,             /*tp_methods*/
+  PyStdOut_memberlist,          /*tp_members*/
+  0,                            /*tp_getset*/
+  0,                            /*tp_base*/
+  0,                            /*tp_dict*/
+  0,                            /*tp_descr_get*/
+  0,                            /*tp_descr_set*/
+  0,                            /*tp_dictoffset*/
+  0,                            /*tp_init*/
+  0,                            /*tp_alloc*/
+  0,                            /*tp_new*/
+  0,                            /*tp_free*/
+  0,                            /*tp_is_gc*/
+};
+
+PyObject * newPyStdOut( std::string& out )
+{
+  PyStdOut *self;
+  self = PyObject_New(PyStdOut, &PyStdOut_Type);
+  if (self == NULL)
+    return NULL;
+  self->softspace = 0;
+  self->out=&out;
+  return (PyObject*)self;
+}
+
+
+////////////////////////END PYTHON///////////////////////////
 //=============================================================================
 /*!
  *   constructor:
@@ -549,6 +657,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (std::list<Handle(G
 
   int aLen = thePoints.size();
   aCI.SetLength(aLen);
+  aCI.SetConstructorType(POINT_CONSTRUCTOR);
 
   int ind = 1;
   std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
@@ -620,6 +729,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
 
   int aLen = thePoints.size();
   aCI.SetLength(aLen);
+  aCI.SetConstructorType(POINT_CONSTRUCTOR);
 
   int ind = 1;
   std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
@@ -690,6 +800,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
   GEOMImpl_ISpline aCI (aFunction);
 
   int aLen = thePoints.size();
+  aCI.SetConstructorType(POINT_CONSTRUCTOR);
   aCI.SetLength(aLen);
 
   int ind = 1;
@@ -736,6 +847,221 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
   return aSpline;
 }
 
+//=============================================================================
+/*!
+ *  MakeCurveParametric
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr, 
+                                                                   double theParamMin, double theParamMax, double theParamStep, 
+                                                                   CurveType theCurveType) {
+  TCollection_AsciiString aPyScript;
+  aPyScript +="from math import *                                          \n";
+  aPyScript +="def X(t):                                                   \n";
+  aPyScript +="    return "; 
+  aPyScript += thexExpr;
+  aPyScript += "\n";                                                             
+  aPyScript +="def Y(t):                                                   \n";
+  aPyScript +="    return ";
+  aPyScript += theyExpr;
+  aPyScript += "\n";
+  
+  aPyScript +="def Z(t):                                                   \n";
+  aPyScript +="    return ";
+  aPyScript += thezExpr;
+  aPyScript += "\n";
+  
+  aPyScript +="def coordCalucator(tmin, tmax, tstep):                      \n";
+  aPyScript +="   coords = []                                              \n";
+  aPyScript +="   while tmin <= tmax :                                     \n";
+  aPyScript +="      coords.append([X(tmin), Y(tmin), Z(tmin)])            \n";
+  aPyScript +="      tmin = tmin + tstep                                   \n";
+  aPyScript +="   return coords                                            \n";
+  
+  SetErrorCode(KO);
+
+  if(theParamMin >= theParamMax) {
+    SetErrorCode("The minimum value of the parameter must be less than maximum value !!!");
+    return NULL;
+  }
+
+  if(theParamStep <= 0.0 ) {
+    SetErrorCode("Value of the step must be positive !!!");
+    return NULL;
+  }
+  
+  /* Initialize the Python interpreter */
+  if (! Py_IsInitialized()) {
+    SetErrorCode("Python interpreter is not initialized !!! ");
+    return NULL;
+  } 
+
+  PyGILState_STATE gstate;
+  gstate = PyGILState_Ensure();
+  
+  PyObject* main_mod = PyImport_AddModule("__main__");
+  PyObject* main_dict = PyModule_GetDict(main_mod);
+
+  PyObject* obj = PyRun_String(aPyScript.ToCString(), Py_file_input, main_dict, NULL);
+
+  if (obj == NULL) {
+    SetErrorCode("Error during run python script !!!");
+    PyGILState_Release(gstate);
+    return NULL;
+  } else {
+    Py_DECREF(obj);
+  }
+
+  PyObject * func = NULL;
+  func = PyObject_GetAttrString(main_mod, "coordCalucator");
+  
+  if (func == NULL){
+    SetErrorCode("Can't get function from python module !!!");
+    PyGILState_Release(gstate);
+    return NULL;
+  }
+  
+  PyObject* coords = PyObject_CallFunction(func,(char*)"(d, d, d)", theParamMin, theParamMax, theParamStep );
+  PyObject* new_stderr = NULL;
+
+  if (coords == NULL){
+    fflush(stderr);
+    std::string err_description="";
+    new_stderr = newPyStdOut(err_description);
+    PySys_SetObject((char*)"stderr", new_stderr);
+    PyErr_Print();
+    PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+    Py_DECREF(new_stderr);
+    MESSAGE("Can't evaluate coordCalucator()" << " error is " << err_description);
+    SetErrorCode("Can't evaluate the expressions, please check them !!!");
+    PyGILState_Release(gstate);
+    return NULL;
+  }
+
+  Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, PyList_Size( coords ) * 3);
+
+  if(PyList_Size( coords ) <= 0) {
+    SetErrorCode("Empty list of the points, please check input parameters !!!");
+    return NULL;
+  }    
+
+  int k=1;
+  for ( Py_ssize_t i = 0; i< PyList_Size( coords ); ++i ) {
+    PyObject* coord = PyList_GetItem( coords, i );
+    if (coord != NULL) {
+      for ( Py_ssize_t j = 0; j < PyList_Size(coord); ++j) {
+       PyObject* item = PyList_GetItem(coord, j);
+       aCoordsArray->SetValue(k, PyFloat_AsDouble(item));
+       k++;
+      }
+    }
+  }
+
+  Py_DECREF(coords);
+
+  
+  
+  PyGILState_Release(gstate);
+
+  Handle(GEOM_Object) aCurve; 
+  Handle(GEOM_Function) aFunction;
+  TCollection_AsciiString aCurveType;
+  
+  switch(theCurveType) {
+  case Polyline: {
+    //Add a new Polyline object
+    aCurve = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE);
+    
+    //Add a new Polyline function for creation a polyline relatively to points set
+    aFunction = aCurve->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS);
+    if (aFunction.IsNull()) return NULL;
+    
+    //Check if the function is set correctly
+    if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL;
+
+    GEOMImpl_IPolyline aCI (aFunction);
+
+    aCI.SetLength(PyList_Size( coords ));
+    aCI.SetConstructorType(COORD_CONSTRUCTOR);
+    aCI.SetIsClosed(false);
+    aCI.SetCoordinates(aCoordsArray);
+    aCurveType = "geompy.GEOM.Polyline";
+    break;
+  }
+  case Bezier: {
+    //Add a new Spline object
+    aCurve = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
+    //Add a new Spline function for creation a bezier curve relatively to points set
+    aFunction =
+      aCurve->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_BEZIER);
+    if (aFunction.IsNull()) return NULL;
+    
+    //Check if the function is set correctly
+    if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
+    
+    GEOMImpl_ISpline aCI (aFunction);
+
+    aCI.SetLength(PyList_Size( coords ));
+    aCI.SetConstructorType(COORD_CONSTRUCTOR);
+    aCI.SetIsClosed(false);
+    aCI.SetCoordinates(aCoordsArray);
+    aCurveType = "geompy.GEOM.Bezier";
+    break;
+  }
+  case Interpolation: {
+    //Add a new Spline object
+    aCurve = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE);
+
+    //Add a new Spline function for creation a bezier curve relatively to points set
+    aFunction = aCurve->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION);
+    if (aFunction.IsNull()) return NULL;
+    
+    //Check if the function is set correctly
+    if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL;
+
+    GEOMImpl_ISpline aCI (aFunction);
+    aCI.SetConstructorType(COORD_CONSTRUCTOR);
+    aCI.SetLength(PyList_Size( coords ));
+    aCI.SetIsClosed(false);
+    aCI.SetDoReordering(false);
+    aCI.SetCoordinates(aCoordsArray);
+    aCurveType = "geompy.GEOM.Interpolation";
+    break;
+  }
+  }
+
+  //Compute the Curve value
+  try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+    OCC_CATCH_SIGNALS;
+#endif
+    if (!GetSolver()->ComputeFunction(aFunction)) {
+      SetErrorCode("Curve 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 pd (aFunction);
+  pd << aCurve << " = geompy.MakeCurveParametric(";
+  pd << "\"" << thexExpr << "\", ";
+  pd << "\"" << theyExpr << "\", ";
+  pd << "\"" << thezExpr << "\", ";
+  
+  pd << theParamMin <<", ";
+  pd << theParamMax <<", ";
+  pd << theParamStep <<", ";
+  pd << aCurveType.ToCString() <<")";
+  
+  SetErrorCode(OK);
+  return aCurve;
+}
+
 //=============================================================================
 /*!
  *  MakeSketcher
@@ -923,3 +1249,4 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
   SetErrorCode(OK);
   return aSketcher;
 }
+
index d85dcf14d57aceffac8572f0fa579770780c1b87..01acdb7a2f3cf623ec4ae21838687053211711fc 100644 (file)
@@ -32,7 +32,11 @@ class GEOM_Engine;
 class Handle(GEOM_Object);
 
 class GEOMImpl_ICurvesOperations : public GEOM_IOperations {
+  
  public:
+
+  enum CurveType { Polyline, Bezier, Interpolation };
+  
   Standard_EXPORT GEOMImpl_ICurvesOperations(GEOM_Engine* theEngine, int theDocID);
   Standard_EXPORT ~GEOMImpl_ICurvesOperations();
 
@@ -73,6 +77,10 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations {
                                                                bool theIsClosed = false,
                                                                bool theDoReordering = false);
 
+  Standard_EXPORT Handle(GEOM_Object) MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr, 
+                                                         double theParamMin, double theParamMax, double theParamStep, 
+                                                         CurveType theCurveType);
+
   Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const char* theCommand,
                                                     std::list<double> theWorkingPlane);
   Standard_EXPORT Handle(GEOM_Object) Make3DSketcher (std::list<double> theCoordinates);
index d4b3ae66f57e6d9a11bebcceccf4860b8f3cebed..b9794dda13eb79df6c7a88d13e04fc007024e264 100644 (file)
 //NOTE: This is an interface to a function for the Polyline creation.
 
 #include "GEOM_Function.hxx"
+#include <TColStd_HArray1OfReal.hxx>
 
 #define POLY_ARG_LENG 1
 #define POLY_ARG_LAST 1
 #define POLY_ARG_CLOS 2
 
+#define POLY_CONSTRUCTOR 3
+#define POLY_ARG_ARRAY 4
+
 class GEOMImpl_IPolyline
 {
  public:
@@ -45,6 +49,18 @@ class GEOMImpl_IPolyline
 
   bool GetIsClosed() { return (bool)_func->GetInteger(POLY_ARG_CLOS); }
 
+  void SetConstructorType(int theConstructor) {_func->SetInteger(POLY_CONSTRUCTOR,theConstructor); }
+
+  int GetConstructorType() { return _func->GetInteger(POLY_CONSTRUCTOR); }
+
+  void SetCoordinates(const Handle(TColStd_HArray1OfReal)& theValue)
+              { _func->SetRealArray(POLY_ARG_ARRAY, theValue); }
+
+
+  Handle(TColStd_HArray1OfReal) GetCoordinates() { return _func->GetRealArray(POLY_ARG_ARRAY); }
+
+
+
  private:
 
   Handle(GEOM_Function) _func;
index d3304c162f0cfe5d244690e8f4df1fc353ae2898..5b95b58b597749e898e563dc091d67791f2cbc0f 100644 (file)
 //  NOTE: This is an interface to a function for the Spline creation.
 
 #include "GEOM_Function.hxx"
+#include <TColStd_HArray1OfReal.hxx>
 
 #define SPL_ARG_LENG 1
 #define SPL_ARG_CLOS 2
 #define SPL_ARG_REOR 3
 #define SPL_ARG_LAST 2
 
+#define SPL_CONSTRUCTOR 4
+#define SPL_ARG_ARRAY 5
+
 class GEOMImpl_ISpline
 {
  public:
@@ -50,6 +54,17 @@ class GEOMImpl_ISpline
 
   Handle(GEOM_Function) GetPoint(int theId) { return _func->GetReference(SPL_ARG_LAST + theId); }
 
+
+  void SetConstructorType(int theConstructor) {_func->SetInteger(SPL_CONSTRUCTOR,theConstructor); }
+
+  int GetConstructorType() { return _func->GetInteger(SPL_CONSTRUCTOR); }
+
+  void SetCoordinates(const Handle(TColStd_HArray1OfReal)& theValue)
+              { _func->SetRealArray(SPL_ARG_ARRAY, theValue); }
+
+
+  Handle(TColStd_HArray1OfReal) GetCoordinates() { return _func->GetRealArray(SPL_ARG_ARRAY); }
+
  private:
 
   Handle(GEOM_Function) _func;
index f04e719a609bd129e4d91a898578fb6070ce3002..517f440f067d9c864d1d737020fc22d6ae2bf65c 100644 (file)
@@ -26,6 +26,8 @@
 #include <GEOMImpl_Types.hxx>
 #include <GEOM_Function.hxx>
 
+#include <TColgp_Array1OfPnt.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
 #include <BRepBuilderAPI_MakePolygon.hxx>
 #include <BRep_Tool.hxx>
 #include <TopoDS.hxx>
@@ -68,42 +70,69 @@ Standard_Integer GEOMImpl_PolylineDriver::Execute(TFunction_Logbook& log) const
 
   GEOMImpl_IPolyline aCI (aFunction);
   Standard_Integer aType = aFunction->GetType();
-
+  
   TopoDS_Shape aShape;
 
   if (aType == POLYLINE_POINTS) {
+
+    bool useCoords = aCI.GetConstructorType() == COORD_CONSTRUCTOR;
+    TColgp_Array1OfPnt points(1, (useCoords ? aCI.GetLength() : 1) );
+    if(useCoords) {
+      Handle(TColStd_HArray1OfReal) aCoordsArray = aCI.GetCoordinates();
+      int anArrayLength = aCoordsArray->Length();
+      for (int i = 0, j = 1; i <= (anArrayLength-3); i += 3) {
+       gp_Pnt aPnt = gp_Pnt(aCoordsArray->Value(i+1), aCoordsArray->Value(i+2), aCoordsArray->Value(i+3));
+       points.SetValue(j,aPnt);
+       j++;
+      } 
+    }
+
     int aLen = aCI.GetLength();
     int ind = 1;
     BRepBuilderAPI_MakePolygon aMakePoly;
     for (; ind <= aLen; ind++)
     {
-      Handle(GEOM_Function) aRefPoint = aCI.GetPoint(ind);
-      TopoDS_Shape aShapePnt = aRefPoint->GetValue();
-      if (aShapePnt.ShapeType() != TopAbs_VERTEX) {
-        Standard_TypeMismatch::Raise
-          ("Polyline creation aborted : arguments are not a vertexes");
-        return 0;
-      }
-      if (aShapePnt.ShapeType() == TopAbs_VERTEX) {
-        aMakePoly.Add(TopoDS::Vertex(aShapePnt));
-        //if (!aMakePoly.Added()) return 0;
+      if(useCoords) {
+       aMakePoly.Add(BRepBuilderAPI_MakeVertex(points.Value(ind)));
+      } else {
+       Handle(GEOM_Function) aRefPoint = aCI.GetPoint(ind);
+       TopoDS_Shape aShapePnt = aRefPoint->GetValue();
+       if (aShapePnt.ShapeType() != TopAbs_VERTEX) {
+         Standard_TypeMismatch::Raise
+           ("Polyline creation aborted : arguments are not a vertexes");
+         return 0;
+       }
+       if (aShapePnt.ShapeType() == TopAbs_VERTEX) {
+         aMakePoly.Add(TopoDS::Vertex(aShapePnt));
+         //if (!aMakePoly.Added()) return 0;
+       }
       }
     }
     // Compare first and last point coordinates and close polyline if it's the same.
     if ( aLen > 2 ) {
-      Handle(GEOM_Function) aFPoint = aCI.GetPoint(1);
-      TopoDS_Shape aFirstPnt = aFPoint->GetValue();
-      TopoDS_Vertex aV1 = TopoDS::Vertex(aFirstPnt);
-
-      Handle(GEOM_Function) aLPoint = aCI.GetPoint(aLen);
-      TopoDS_Shape aLastPnt = aLPoint->GetValue();
-      TopoDS_Vertex aV2 = TopoDS::Vertex(aLastPnt);
-
+      TopoDS_Vertex aV1;
+      if( useCoords ) {
+       aV1 = BRepBuilderAPI_MakeVertex(points.Value(1));
+      } else {
+       Handle(GEOM_Function) aFPoint = aCI.GetPoint(1);
+       TopoDS_Shape aFirstPnt = aFPoint->GetValue();
+       aV1 = TopoDS::Vertex(aFirstPnt);
+      }
+      
+      TopoDS_Vertex aV2;
+      if( useCoords ) {
+       aV2 = BRepBuilderAPI_MakeVertex(points.Value(aLen));
+      } else {
+       Handle(GEOM_Function) aLPoint = aCI.GetPoint(aLen);
+       TopoDS_Shape aLastPnt = aLPoint->GetValue();
+       aV2 = TopoDS::Vertex(aLastPnt);
+      }
+      
       if ( (!aV1.IsNull() && !aV2.IsNull() && aV1.IsSame(aV2)) ||
            aCI.GetIsClosed())
         aMakePoly.Close();
     }
-
+    
     if (aMakePoly.IsDone()) {
       aShape = aMakePoly.Wire();
     }
@@ -112,11 +141,11 @@ Standard_Integer GEOMImpl_PolylineDriver::Execute(TFunction_Logbook& log) const
   }
 
   if (aShape.IsNull()) return 0;
-
+  
   aFunction->SetValue(aShape);
-
+  
   log.SetTouched(Label()); 
-
+  
   return 1;    
 }
 
index c8684cb19213aa0badccb55ded8e514f2a698b3e..7524942e3e266aa3183499ccd0146a47ce08638b 100644 (file)
@@ -27,6 +27,7 @@
 #include <GEOM_Function.hxx>
 
 #include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
 #include <BRep_Tool.hxx>
 
 #include <TopAbs.hxx>
@@ -81,30 +82,54 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const
   TopoDS_Shape aShape;
 
   if (aType == SPLINE_BEZIER || aType == SPLINE_INTERPOLATION) {
+
+    bool useCoords = aCI.GetConstructorType() == COORD_CONSTRUCTOR;
+    TColgp_Array1OfPnt points(1, (useCoords ? aCI.GetLength() : 1) );
+    if(useCoords) {
+      Handle(TColStd_HArray1OfReal) aCoordsArray = aCI.GetCoordinates();
+      int anArrayLength = aCoordsArray->Length();
+      for (int i = 0, j = 1; i <= (anArrayLength-3); i += 3) {
+       gp_Pnt aPnt = gp_Pnt(aCoordsArray->Value(i+1), aCoordsArray->Value(i+2), aCoordsArray->Value(i+3));
+       points.SetValue(j,aPnt);
+       j++;
+      } 
+    }
+
+    
     int ind, aLen = aCI.GetLength();
     if (aLen < 2) return 0;
     Standard_Boolean isSeveral = Standard_False;
     gp_Pnt aPrevP;
     int aRealLen = aLen;
     if (aType == SPLINE_BEZIER && aCI.GetIsClosed()) {
-      Handle(GEOM_Function) aFPoint = aCI.GetPoint(1);
-      TopoDS_Shape aFirstPnt = aFPoint->GetValue();
-      TopoDS_Vertex aV1 = TopoDS::Vertex(aFirstPnt);
-
-      Handle(GEOM_Function) aLPoint = aCI.GetPoint(aLen);
-      TopoDS_Shape aLastPnt = aLPoint->GetValue();
-      TopoDS_Vertex aV2 = TopoDS::Vertex(aLastPnt);
+      TopoDS_Vertex aV1;
+      if(useCoords) {
+       aV1 = BRepBuilderAPI_MakeVertex(points.Value(1));
+      } else {
+       Handle(GEOM_Function) aFPoint = aCI.GetPoint(1);
+       TopoDS_Shape aFirstPnt = aFPoint->GetValue();
+       aV1 = TopoDS::Vertex(aFirstPnt);
+      }
 
+      TopoDS_Vertex aV2;
+      if(useCoords) { 
+       aV2 = BRepBuilderAPI_MakeVertex(points.Value(aLen));
+      } else {
+       Handle(GEOM_Function) aLPoint = aCI.GetPoint(aLen);
+       TopoDS_Shape aLastPnt = aLPoint->GetValue();
+       aV2 = TopoDS::Vertex(aLastPnt);
+      }
+      
       if (!aV1.IsNull() && !aV2.IsNull() && !aV1.IsSame(aV2)) {
         aRealLen++;
       }
     }
+    
     TColgp_Array1OfPnt CurvePoints (1, aRealLen);
     for (ind = 1; ind <= aLen; ind++) {
-      Handle(GEOM_Function) aRefPoint = aCI.GetPoint(ind);
-      TopoDS_Shape aShapePnt = aRefPoint->GetValue();
-      if (aShapePnt.ShapeType() == TopAbs_VERTEX) {
-        gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
+      gp_Pnt aP;
+      if( useCoords ) { 
+       aP = points.Value(ind);
         if (!isSeveral && ind > 1) {
           if (aP.Distance(aPrevP) > Precision::Confusion()) {
             isSeveral = Standard_True;
@@ -112,6 +137,19 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const
         }
         CurvePoints.SetValue(ind, aP);
         aPrevP = aP;
+      } else {      
+       Handle(GEOM_Function) aRefPoint = aCI.GetPoint(ind);
+       TopoDS_Shape aShapePnt = aRefPoint->GetValue();
+       if (aShapePnt.ShapeType() == TopAbs_VERTEX) {
+         aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
+         if (!isSeveral && ind > 1) {
+           if (aP.Distance(aPrevP) > Precision::Confusion()) {
+             isSeveral = Standard_True;
+           }
+         }
+         CurvePoints.SetValue(ind, aP);
+         aPrevP = aP;
+       }
       }
     }
     if (aType == SPLINE_BEZIER) {
@@ -126,7 +164,7 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const
     } else {
       //GeomAPI_PointsToBSpline GBC (CurvePoints);
       //aShape = BRepBuilderAPI_MakeEdge(GBC).Edge();
-
+      
       Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt(1, aLen);
 
       if (aCI.GetDoReordering()) {
@@ -164,7 +202,7 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const
           aHCurvePoints->SetValue(ind, CurvePoints.Value(ind));
         }
       }
-
+      
       bool isClosed = aCI.GetIsClosed();
       GeomAPI_Interpolate GBC (aHCurvePoints, isClosed, gp::Resolution());
       GBC.Perform();
@@ -176,13 +214,13 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const
   }
   else {
   }
-
+  
   if (aShape.IsNull()) return 0;
-
+  
   aFunction->SetValue(aShape);
-
+  
   log.SetTouched(Label());
-
+  
   return 1;
 }
 
index 1f01c8317c80983ada3e20c1cc130b800605463b..4435dd6d9c8650394961e7132c3ae9d865b11193 100755 (executable)
 
 #define SHAPES_ON_SHAPE 1
 
+//Curve constructor type
+#define POINT_CONSTRUCTOR 0
+#define COORD_CONSTRUCTOR 1
+
 // Blocks
 #define BLOCK_FACE_FOUR_PNT       1
 #define BLOCK_FACE_FOUR_EDGES     2
index 94094bca3535eee743716390738aa58e57d898a5..9954c8994a75c8fe26c7667cb33b2f0adf848159 100644 (file)
@@ -227,6 +227,7 @@ libGEOMimpl_la_CPPFLAGS =           \
        $(CAS_CPPFLAGS)                 \
        $(KERNEL_CXXFLAGS)              \
        $(BOOST_CPPFLAGS)               \
+        $(PYTHON_INCLUDES)              \
        -I$(srcdir)/../ShHealOper       \
        -I$(srcdir)/../NMTTools         \
        -I$(srcdir)/../GEOM             \
@@ -243,7 +244,8 @@ libGEOMimpl_la_LDFLAGS  =                   \
        ../SKETCHER/libGEOMSketcher.la          \
        $(KERNEL_LDFLAGS) -lSALOMELocalTrace -lSALOMEBasics     \
        $(STDLIB)                               \
-       $(CAS_LDPATH) -lTKCAF -lTKFillet -lTKOffset
+       $(CAS_LDPATH) -lTKCAF -lTKFillet -lTKOffset \
+        $(PYTHON_LIBS)
 
 # extra dist files
 EXTRA_DIST += GUID.txt
index 831ca9bde26c60c58fb30e67ecda1fa5aac46ee4..9a56dc824a821e5b4bcea46b44aeee78df5406bb 100644 (file)
@@ -427,6 +427,46 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
   return GetObject(anObject);
 }
 
+//=============================================================================
+/*!
+ *  MakeCurveParametric
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr, 
+                                                                   double theParamMin, double theParamMax, double theParamStep, 
+                                                                   GEOM::curve_type theCurveType) {
+  GEOM::GEOM_Object_var aGEOMObject;
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+  
+  GEOMImpl_ICurvesOperations::CurveType aType;
+  switch(theCurveType) {
+  case GEOM::Polyline:
+    aType = GEOMImpl_ICurvesOperations::Polyline;
+    break;
+  case GEOM::Bezier:
+    aType = GEOMImpl_ICurvesOperations::Bezier;
+    break;
+  case GEOM::Interpolation:
+    aType = GEOMImpl_ICurvesOperations::Interpolation;
+    break;
+  default:
+    break;
+  }  
+  
+
+  // Make Polyline
+  Handle(GEOM_Object) anObject =
+    GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr, 
+                                          theParamMin, theParamMax, 
+                                          theParamStep, aType);
+  
+  if (!GetOperations()->IsDone() || anObject.IsNull())
+    return aGEOMObject._retn();  
+  
+  return GetObject(anObject);
+}
+
 //=============================================================================
 /*!
  *  MakeSketcher
index b629d46ca46c04f34b33c5b1dcdb5dadbdfa8ce6..15daf32c395ba9a78c28fb3fb2a7d03f3fdcbd20 100644 (file)
@@ -85,6 +85,10 @@ class GEOM_I_EXPORT GEOM_ICurvesOperations_i :
                                                  CORBA::Boolean        theIsClosed,
                                                  CORBA::Boolean        theDoReordering);
 
+  GEOM::GEOM_Object_ptr MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr, 
+                                           double theParamMin, double theParamMax, double theParamStep, 
+                                           GEOM::curve_type theCurveType);
+
   GEOM::GEOM_Object_ptr MakeSketcher (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane);
   
   GEOM::GEOM_Object_ptr Make3DSketcher (const GEOM::ListOfDouble& theCoordinates);
index af394ff657f10cb6bbb5674d6535b19fbc3ffee7..2492a8b9a4bf9fc99ab1ba432b776b1150af6ef5 100644 (file)
@@ -954,6 +954,28 @@ class geompyDC(GEOM._objref_GEOM_Gen):
             RaiseIfFailed("MakeSplineInterpolation", self.CurvesOp)
             return anObj
 
+
+        ## Creates a curve using the parametric definition of the basic points.
+        #  @param thexExpr parametric equation of the coordinates X.
+        #  @param theyExpr parametric equation of the coordinates Y.
+        #  @param thezExpr parametric equation of the coordinates Z.
+        #  @param theParamMin the minimal value of the parameter.
+        #  @param theParamMax the maximum value of the parameter.
+        #  @param theParamStep the step of the parameter.
+        #  @param theCurveType the type of the curve.
+        #  @return New GEOM_Object, containing the created curve.
+        #
+        #  @ref tui_creation_curve "Example"
+        def MakeCurveParametric(self, thexExpr, theyExpr, thezExpr,
+                                theParamMin, theParamMax, theParamStep, theCurveType):
+            theParamMin,theParamMax,theParamStep,Parameters = ParseParameters(theParamMin,theParamMax,theParamStep)
+            anObj = self.CurvesOp.MakeCurveParametric(thexExpr,theyExpr,thezExpr,theParamMin,theParamMax,theParamStep,theCurveType)
+            RaiseIfFailed("MakeSplineInterpolation", self.CurvesOp)
+            anObj.SetParameters(Parameters)
+            return anObj
+            
+
+
         # end of l4_curves
         ## @}