Start implementation of the "16564: EDF 509 GEOM : 3D line with mathematical equation in GUI" issue.

This commit is contained in:
rnv 2011-05-04 13:32:04 +00:00
parent c3c821953a
commit 5652cf8774
19 changed files with 918 additions and 52 deletions

View File

@ -135,6 +135,21 @@ module GEOM
FOM_AutoCorrect 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<string> string_array;
typedef sequence<short> short_array; typedef sequence<short> short_array;
@ -2595,6 +2610,25 @@ module GEOM
in boolean theIsClosed, in boolean theIsClosed,
in boolean theDoReordering); 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, * Create a sketcher (wire or face), following the textual description,
* passed through \a theCommand argument. \n * passed through \a theCommand argument. \n

View File

@ -24,6 +24,7 @@
// Author : Lucien PIGNOLONI, Open CASCADE S.A.S. // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
#include "BasicGUI_CurveDlg.h" #include "BasicGUI_CurveDlg.h"
#include "BasicGUI_ParamCurveWidget.h"
#include <DlgRef.h> #include <DlgRef.h>
#include <GeometryGUI.h> #include <GeometryGUI.h>
@ -69,6 +70,20 @@ BasicGUI_CurveDlg::BasicGUI_CurveDlg( GeometryGUI* theGeometryGUI, QWidget* pare
mainFrame()->RadioButton2->setIcon( image3 ); mainFrame()->RadioButton2->setIcon( image3 );
mainFrame()->RadioButton3->setIcon( image2 ); 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 = new DlgRef_1Sel3Check( centralWidget() );
GroupPoints->GroupBox1->setTitle( tr( "GEOM_NODES" ) ); GroupPoints->GroupBox1->setTitle( tr( "GEOM_NODES" ) );
@ -88,9 +103,13 @@ BasicGUI_CurveDlg::BasicGUI_CurveDlg( GeometryGUI* theGeometryGUI, QWidget* pare
GroupPoints->CheckButton3->hide(); GroupPoints->CheckButton3->hide();
myParams = new BasicGUI_ParamCurveWidget( centralWidget() );
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( creationModeCroup );
layout->addWidget( GroupPoints ); layout->addWidget( GroupPoints );
layout->addWidget( myParams );
/***************************************************************/ /***************************************************************/
setHelpFileName( "create_curve_page.html" ); setHelpFileName( "create_curve_page.html" );
@ -123,6 +142,26 @@ void BasicGUI_CurveDlg::Init()
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
showOnlyPreviewControl(); 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 */ /* signals and slots connections */
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog( ) ) ); connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog( ) ) );
@ -141,6 +180,17 @@ void BasicGUI_CurveDlg::Init()
connect( myGeomGUI->getApp()->selectionMgr(), connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); 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" ) ); initName( tr( "GEOM_CURVE" ) );
resize(100,100); resize(100,100);
ConstructorsClicked( 0 ); ConstructorsClicked( 0 );
@ -321,7 +371,17 @@ GEOM::GEOM_IOperations_ptr BasicGUI_CurveDlg::createOperation()
//================================================================================= //=================================================================================
bool BasicGUI_CurveDlg::isValid( QString& msg ) 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,22 +403,58 @@ bool BasicGUI_CurveDlg::execute( ObjectList& objects )
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0 : 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; res = true;
break; break;
case 1 : 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; res = true;
break; break;
case 2 : case 2 :
anObj = anOper->MakeSplineInterpolation( points.in(), GroupPoints->CheckButton1->isChecked(), if( myBySelectionBtn->isChecked() )
GroupPoints->CheckButton2->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; res = true;
break; 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() ); objects.push_back( anObj._retn() );
}
return res; return res;
} }
@ -372,3 +468,32 @@ void BasicGUI_CurveDlg::addSubshapesToStudy()
for ( int i = 0; i < myPoints.count(); i++ ) for ( int i = 0; i < myPoints.count(); i++ )
GEOMBase::PublishSubObject( myPoints[i].get() ); 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();
}

View File

@ -32,6 +32,8 @@
#include <list> #include <list>
class DlgRef_1Sel3Check; class DlgRef_1Sel3Check;
class QRadioButton;
class BasicGUI_ParamCurveWidget;
//================================================================================= //=================================================================================
// class : BasicGUI_CurveDlg // class : BasicGUI_CurveDlg
@ -59,6 +61,9 @@ private:
private: private:
DlgRef_1Sel3Check* GroupPoints; DlgRef_1Sel3Check* GroupPoints;
QList<GEOM::GeomObjPtr> myPoints; QList<GEOM::GeomObjPtr> myPoints;
QRadioButton* myAnaliticalBtn;
QRadioButton* myBySelectionBtn;
BasicGUI_ParamCurveWidget* myParams;
private slots: private slots:
void ClickOnOk(); void ClickOnOk();
@ -71,6 +76,9 @@ private slots:
void CheckButtonToggled(); void CheckButtonToggled();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void CreationModeChanged();
void ValueChangedInSpinBox(double/*theValue*/);
void OnEditingFinished();
}; };
#endif // BASICGUI_CURVEDLG_H #endif // BASICGUI_CURVEDLG_H

View File

@ -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(){
}

View File

@ -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

View File

@ -36,7 +36,8 @@ salomeinclude_HEADERS = \
BasicGUI_MarkerDlg.h \ BasicGUI_MarkerDlg.h \
BasicGUI_PlaneDlg.h \ BasicGUI_PlaneDlg.h \
BasicGUI_PointDlg.h \ BasicGUI_PointDlg.h \
BasicGUI_VectorDlg.h BasicGUI_VectorDlg.h \
BasicGUI_ParamCurveWidget.h
# #
# OBSOLETE: BasicGUI_WorkingPlaneDlg.h # OBSOLETE: BasicGUI_WorkingPlaneDlg.h
# #
@ -56,7 +57,8 @@ dist_libBasicGUI_la_SOURCES = \
BasicGUI_VectorDlg.cxx \ BasicGUI_VectorDlg.cxx \
BasicGUI_PlaneDlg.cxx \ BasicGUI_PlaneDlg.cxx \
BasicGUI_CurveDlg.cxx \ BasicGUI_CurveDlg.cxx \
BasicGUI_MarkerDlg.cxx BasicGUI_MarkerDlg.cxx \
BasicGUI_ParamCurveWidget.cxx
# #
# OBSOLETE: BasicGUI_WorkingPlaneDlg.cxx # OBSOLETE: BasicGUI_WorkingPlaneDlg.cxx
# #
@ -70,7 +72,8 @@ MOC_FILES = \
BasicGUI_VectorDlg_moc.cxx \ BasicGUI_VectorDlg_moc.cxx \
BasicGUI_PlaneDlg_moc.cxx \ BasicGUI_PlaneDlg_moc.cxx \
BasicGUI_CurveDlg_moc.cxx \ BasicGUI_CurveDlg_moc.cxx \
BasicGUI_MarkerDlg_moc.cxx BasicGUI_MarkerDlg_moc.cxx \
BasicGUI_ParamCurveWidget_moc.cxx
# #
# OBSOLETE: BasicGUI_WorkingPlaneDlg_moc.cxx # OBSOLETE: BasicGUI_WorkingPlaneDlg_moc.cxx
# #

View File

@ -1166,7 +1166,7 @@ void ReplaceVariables(TCollection_AsciiString& theCommand,
else if(i == aTotalNbParams) else if(i == aTotalNbParams)
{ {
aStartPos = aCommand.Location(i-1, COMMA, 1, aCommand.Length()) + 2; 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) //Replace other parameters (bettwen two ',' characters)
else if(i != aFirstParam && i != aTotalNbParams ) else if(i != aFirstParam && i != aTotalNbParams )

View File

@ -4334,6 +4334,49 @@ Otherwise the dimensions will be kept without modifications.</translation>
<source>GEOM_IS_REORDER</source> <source>GEOM_IS_REORDER</source>
<translation>Reorder vertices taking into account distances</translation> <translation>Reorder vertices taking into account distances</translation>
</message> </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>
<context> <context>
<name>BasicGUI_EllipseDlg</name> <name>BasicGUI_EllipseDlg</name>

View File

@ -19,6 +19,9 @@
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#include <Python.h>
#include <structmember.h>
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
#include <GEOMImpl_ICurvesOperations.hxx> #include <GEOMImpl_ICurvesOperations.hxx>
@ -53,6 +56,111 @@
#include <Standard_Failure.hxx> #include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC #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: * constructor:
@ -549,6 +657,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (std::list<Handle(G
int aLen = thePoints.size(); int aLen = thePoints.size();
aCI.SetLength(aLen); aCI.SetLength(aLen);
aCI.SetConstructorType(POINT_CONSTRUCTOR);
int ind = 1; int ind = 1;
std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin(); std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
@ -620,6 +729,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
int aLen = thePoints.size(); int aLen = thePoints.size();
aCI.SetLength(aLen); aCI.SetLength(aLen);
aCI.SetConstructorType(POINT_CONSTRUCTOR);
int ind = 1; int ind = 1;
std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin(); std::list<Handle(GEOM_Object)>::iterator it = thePoints.begin();
@ -690,6 +800,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
GEOMImpl_ISpline aCI (aFunction); GEOMImpl_ISpline aCI (aFunction);
int aLen = thePoints.size(); int aLen = thePoints.size();
aCI.SetConstructorType(POINT_CONSTRUCTOR);
aCI.SetLength(aLen); aCI.SetLength(aLen);
int ind = 1; int ind = 1;
@ -736,6 +847,221 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
return aSpline; 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 * MakeSketcher
@ -923,3 +1249,4 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
SetErrorCode(OK); SetErrorCode(OK);
return aSketcher; return aSketcher;
} }

View File

@ -32,7 +32,11 @@ class GEOM_Engine;
class Handle(GEOM_Object); class Handle(GEOM_Object);
class GEOMImpl_ICurvesOperations : public GEOM_IOperations { class GEOMImpl_ICurvesOperations : public GEOM_IOperations {
public: public:
enum CurveType { Polyline, Bezier, Interpolation };
Standard_EXPORT GEOMImpl_ICurvesOperations(GEOM_Engine* theEngine, int theDocID); Standard_EXPORT GEOMImpl_ICurvesOperations(GEOM_Engine* theEngine, int theDocID);
Standard_EXPORT ~GEOMImpl_ICurvesOperations(); Standard_EXPORT ~GEOMImpl_ICurvesOperations();
@ -73,6 +77,10 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations {
bool theIsClosed = false, bool theIsClosed = false,
bool theDoReordering = 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, Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const char* theCommand,
std::list<double> theWorkingPlane); std::list<double> theWorkingPlane);
Standard_EXPORT Handle(GEOM_Object) Make3DSketcher (std::list<double> theCoordinates); Standard_EXPORT Handle(GEOM_Object) Make3DSketcher (std::list<double> theCoordinates);

View File

@ -22,11 +22,15 @@
//NOTE: This is an interface to a function for the Polyline creation. //NOTE: This is an interface to a function for the Polyline creation.
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include <TColStd_HArray1OfReal.hxx>
#define POLY_ARG_LENG 1 #define POLY_ARG_LENG 1
#define POLY_ARG_LAST 1 #define POLY_ARG_LAST 1
#define POLY_ARG_CLOS 2 #define POLY_ARG_CLOS 2
#define POLY_CONSTRUCTOR 3
#define POLY_ARG_ARRAY 4
class GEOMImpl_IPolyline class GEOMImpl_IPolyline
{ {
public: public:
@ -45,6 +49,18 @@ class GEOMImpl_IPolyline
bool GetIsClosed() { return (bool)_func->GetInteger(POLY_ARG_CLOS); } 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: private:
Handle(GEOM_Function) _func; Handle(GEOM_Function) _func;

View File

@ -22,12 +22,16 @@
// NOTE: This is an interface to a function for the Spline creation. // NOTE: This is an interface to a function for the Spline creation.
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include <TColStd_HArray1OfReal.hxx>
#define SPL_ARG_LENG 1 #define SPL_ARG_LENG 1
#define SPL_ARG_CLOS 2 #define SPL_ARG_CLOS 2
#define SPL_ARG_REOR 3 #define SPL_ARG_REOR 3
#define SPL_ARG_LAST 2 #define SPL_ARG_LAST 2
#define SPL_CONSTRUCTOR 4
#define SPL_ARG_ARRAY 5
class GEOMImpl_ISpline class GEOMImpl_ISpline
{ {
public: public:
@ -50,6 +54,17 @@ class GEOMImpl_ISpline
Handle(GEOM_Function) GetPoint(int theId) { return _func->GetReference(SPL_ARG_LAST + theId); } 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: private:
Handle(GEOM_Function) _func; Handle(GEOM_Function) _func;

View File

@ -26,6 +26,8 @@
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx> #include <GEOM_Function.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_MakePolygon.hxx> #include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
@ -72,32 +74,59 @@ Standard_Integer GEOMImpl_PolylineDriver::Execute(TFunction_Logbook& log) const
TopoDS_Shape aShape; TopoDS_Shape aShape;
if (aType == POLYLINE_POINTS) { 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 aLen = aCI.GetLength();
int ind = 1; int ind = 1;
BRepBuilderAPI_MakePolygon aMakePoly; BRepBuilderAPI_MakePolygon aMakePoly;
for (; ind <= aLen; ind++) for (; ind <= aLen; ind++)
{ {
Handle(GEOM_Function) aRefPoint = aCI.GetPoint(ind); if(useCoords) {
TopoDS_Shape aShapePnt = aRefPoint->GetValue(); aMakePoly.Add(BRepBuilderAPI_MakeVertex(points.Value(ind)));
if (aShapePnt.ShapeType() != TopAbs_VERTEX) { } else {
Standard_TypeMismatch::Raise Handle(GEOM_Function) aRefPoint = aCI.GetPoint(ind);
("Polyline creation aborted : arguments are not a vertexes"); TopoDS_Shape aShapePnt = aRefPoint->GetValue();
return 0; if (aShapePnt.ShapeType() != TopAbs_VERTEX) {
} Standard_TypeMismatch::Raise
if (aShapePnt.ShapeType() == TopAbs_VERTEX) { ("Polyline creation aborted : arguments are not a vertexes");
aMakePoly.Add(TopoDS::Vertex(aShapePnt)); return 0;
//if (!aMakePoly.Added()) 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. // Compare first and last point coordinates and close polyline if it's the same.
if ( aLen > 2 ) { if ( aLen > 2 ) {
Handle(GEOM_Function) aFPoint = aCI.GetPoint(1); TopoDS_Vertex aV1;
TopoDS_Shape aFirstPnt = aFPoint->GetValue(); if( useCoords ) {
TopoDS_Vertex aV1 = TopoDS::Vertex(aFirstPnt); aV1 = BRepBuilderAPI_MakeVertex(points.Value(1));
} else {
Handle(GEOM_Function) aFPoint = aCI.GetPoint(1);
TopoDS_Shape aFirstPnt = aFPoint->GetValue();
aV1 = TopoDS::Vertex(aFirstPnt);
}
Handle(GEOM_Function) aLPoint = aCI.GetPoint(aLen); TopoDS_Vertex aV2;
TopoDS_Shape aLastPnt = aLPoint->GetValue(); if( useCoords ) {
TopoDS_Vertex aV2 = TopoDS::Vertex(aLastPnt); 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)) || if ( (!aV1.IsNull() && !aV2.IsNull() && aV1.IsSame(aV2)) ||
aCI.GetIsClosed()) aCI.GetIsClosed())

View File

@ -27,6 +27,7 @@
#include <GEOM_Function.hxx> #include <GEOM_Function.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx> #include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <TopAbs.hxx> #include <TopAbs.hxx>
@ -81,30 +82,54 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const
TopoDS_Shape aShape; TopoDS_Shape aShape;
if (aType == SPLINE_BEZIER || aType == SPLINE_INTERPOLATION) { 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(); int ind, aLen = aCI.GetLength();
if (aLen < 2) return 0; if (aLen < 2) return 0;
Standard_Boolean isSeveral = Standard_False; Standard_Boolean isSeveral = Standard_False;
gp_Pnt aPrevP; gp_Pnt aPrevP;
int aRealLen = aLen; int aRealLen = aLen;
if (aType == SPLINE_BEZIER && aCI.GetIsClosed()) { if (aType == SPLINE_BEZIER && aCI.GetIsClosed()) {
Handle(GEOM_Function) aFPoint = aCI.GetPoint(1); TopoDS_Vertex aV1;
TopoDS_Shape aFirstPnt = aFPoint->GetValue(); if(useCoords) {
TopoDS_Vertex aV1 = TopoDS::Vertex(aFirstPnt); aV1 = BRepBuilderAPI_MakeVertex(points.Value(1));
} else {
Handle(GEOM_Function) aFPoint = aCI.GetPoint(1);
TopoDS_Shape aFirstPnt = aFPoint->GetValue();
aV1 = TopoDS::Vertex(aFirstPnt);
}
Handle(GEOM_Function) aLPoint = aCI.GetPoint(aLen); TopoDS_Vertex aV2;
TopoDS_Shape aLastPnt = aLPoint->GetValue(); if(useCoords) {
TopoDS_Vertex aV2 = TopoDS::Vertex(aLastPnt); 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)) { if (!aV1.IsNull() && !aV2.IsNull() && !aV1.IsSame(aV2)) {
aRealLen++; aRealLen++;
} }
} }
TColgp_Array1OfPnt CurvePoints (1, aRealLen); TColgp_Array1OfPnt CurvePoints (1, aRealLen);
for (ind = 1; ind <= aLen; ind++) { for (ind = 1; ind <= aLen; ind++) {
Handle(GEOM_Function) aRefPoint = aCI.GetPoint(ind); gp_Pnt aP;
TopoDS_Shape aShapePnt = aRefPoint->GetValue(); if( useCoords ) {
if (aShapePnt.ShapeType() == TopAbs_VERTEX) { aP = points.Value(ind);
gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
if (!isSeveral && ind > 1) { if (!isSeveral && ind > 1) {
if (aP.Distance(aPrevP) > Precision::Confusion()) { if (aP.Distance(aPrevP) > Precision::Confusion()) {
isSeveral = Standard_True; isSeveral = Standard_True;
@ -112,6 +137,19 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const
} }
CurvePoints.SetValue(ind, aP); CurvePoints.SetValue(ind, aP);
aPrevP = 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) { if (aType == SPLINE_BEZIER) {

View File

@ -293,6 +293,10 @@
#define SHAPES_ON_SHAPE 1 #define SHAPES_ON_SHAPE 1
//Curve constructor type
#define POINT_CONSTRUCTOR 0
#define COORD_CONSTRUCTOR 1
// Blocks // Blocks
#define BLOCK_FACE_FOUR_PNT 1 #define BLOCK_FACE_FOUR_PNT 1
#define BLOCK_FACE_FOUR_EDGES 2 #define BLOCK_FACE_FOUR_EDGES 2

View File

@ -227,6 +227,7 @@ libGEOMimpl_la_CPPFLAGS = \
$(CAS_CPPFLAGS) \ $(CAS_CPPFLAGS) \
$(KERNEL_CXXFLAGS) \ $(KERNEL_CXXFLAGS) \
$(BOOST_CPPFLAGS) \ $(BOOST_CPPFLAGS) \
$(PYTHON_INCLUDES) \
-I$(srcdir)/../ShHealOper \ -I$(srcdir)/../ShHealOper \
-I$(srcdir)/../NMTTools \ -I$(srcdir)/../NMTTools \
-I$(srcdir)/../GEOM \ -I$(srcdir)/../GEOM \
@ -243,7 +244,8 @@ libGEOMimpl_la_LDFLAGS = \
../SKETCHER/libGEOMSketcher.la \ ../SKETCHER/libGEOMSketcher.la \
$(KERNEL_LDFLAGS) -lSALOMELocalTrace -lSALOMEBasics \ $(KERNEL_LDFLAGS) -lSALOMELocalTrace -lSALOMEBasics \
$(STDLIB) \ $(STDLIB) \
$(CAS_LDPATH) -lTKCAF -lTKFillet -lTKOffset $(CAS_LDPATH) -lTKCAF -lTKFillet -lTKOffset \
$(PYTHON_LIBS)
# extra dist files # extra dist files
EXTRA_DIST += GUID.txt EXTRA_DIST += GUID.txt

View File

@ -427,6 +427,46 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
return GetObject(anObject); 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 * MakeSketcher

View File

@ -85,6 +85,10 @@ class GEOM_I_EXPORT GEOM_ICurvesOperations_i :
CORBA::Boolean theIsClosed, CORBA::Boolean theIsClosed,
CORBA::Boolean theDoReordering); 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 MakeSketcher (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane);
GEOM::GEOM_Object_ptr Make3DSketcher (const GEOM::ListOfDouble& theCoordinates); GEOM::GEOM_Object_ptr Make3DSketcher (const GEOM::ListOfDouble& theCoordinates);

View File

@ -954,6 +954,28 @@ class geompyDC(GEOM._objref_GEOM_Gen):
RaiseIfFailed("MakeSplineInterpolation", self.CurvesOp) RaiseIfFailed("MakeSplineInterpolation", self.CurvesOp)
return anObj 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 # end of l4_curves
## @} ## @}