From: ouv Date: Sat, 29 Nov 2008 09:15:05 +0000 (+0000) Subject: Dump Python extension X-Git-Tag: TG_DumpPython_Extension_3~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d3b48c6524bfc64b2b70575cef0f4e11fd98e8b5;p=modules%2Fsmesh.git Dump Python extension --- diff --git a/src/SMESHGUI/SMESHGUI_BuildCompoundDlg.cxx b/src/SMESHGUI/SMESHGUI_BuildCompoundDlg.cxx index bbb6a03b4..a861781b0 100644 --- a/src/SMESHGUI/SMESHGUI_BuildCompoundDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_BuildCompoundDlg.cxx @@ -285,7 +285,14 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply() { if (mySMESHGUI->isActiveStudyLocked()) return false; + + if (!isValid()) + return false; + if (!myMesh->_is_nil()) { + QStringList aParameters; + aParameters << SpinBoxTol->text(); + try { SUIT_OverrideCursor aWaitCursor; @@ -303,6 +310,8 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply() CheckBoxMerge->isChecked(), SpinBoxTol->GetValue()); + aCompoundMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); + SMESH::SetName( SMESH::FindSObject( aCompoundMesh ), LineEditName->text() ); mySMESHGUI->updateObjBrowser(); } catch(...) { @@ -486,3 +495,22 @@ void SMESHGUI_BuildCompoundDlg::onSelectMerge(bool toMerge) TextLabelTol->setEnabled(toMerge); SpinBoxTol->setEnabled(toMerge); } + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool SMESHGUI_BuildCompoundDlg::isValid() +{ + QString msg; + bool ok = SpinBoxTol->isValid( msg, true ) && ok; + + if( !ok ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return false; + } + return true; +} diff --git a/src/SMESHGUI/SMESHGUI_BuildCompoundDlg.h b/src/SMESHGUI/SMESHGUI_BuildCompoundDlg.h index a05fd5fe3..af200ef9f 100644 --- a/src/SMESHGUI/SMESHGUI_BuildCompoundDlg.h +++ b/src/SMESHGUI/SMESHGUI_BuildCompoundDlg.h @@ -72,6 +72,8 @@ private: void hideEvent( QHideEvent* ); /* ESC key */ void keyPressEvent( QKeyEvent* ); + bool isValid(); + private: SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx index e09419d7a..83e18035a 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx @@ -52,6 +52,8 @@ #include #include +#include + // OCCT includes #include #include @@ -65,7 +67,6 @@ #include #include #include -#include #include #include #include @@ -177,7 +178,7 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule) // Controls for nb. steps defining TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupArguments); - SpinBox_NbSteps = new QSpinBox(GroupArguments); + SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupArguments); // CheckBox for groups generation MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments); @@ -359,6 +360,9 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply() if (mySMESHGUI->isActiveStudyLocked()) return false; + if (!isValid()) + return false; + if (myNbOkElements) { SMESH::DirStruct aVector; @@ -368,6 +372,12 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply() long aNbSteps = (long)SpinBox_NbSteps->value(); + QStringList aParameters; + aParameters << SpinBox_Dx->text(); + aParameters << SpinBox_Dy->text(); + aParameters << SpinBox_Dz->text(); + aParameters << SpinBox_NbSteps->text(); + try { SUIT_OverrideCursor aWaitCursor; SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); @@ -378,6 +388,8 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply() else aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps); + myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); + } catch (...) { } @@ -755,3 +767,26 @@ void SMESHGUI_ExtrusionDlg::keyPressEvent( QKeyEvent* e ) ClickOnHelp(); } } + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool SMESHGUI_ExtrusionDlg::isValid() +{ + QString msg; + bool ok = true; + ok = SpinBox_Dx->isValid( msg, true ) && ok; + ok = SpinBox_Dy->isValid( msg, true ) && ok; + ok = SpinBox_Dz->isValid( msg, true ) && ok; + ok = SpinBox_NbSteps->isValid( msg, true ) && ok; + + if( !ok ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return false; + } + return true; +} diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h index f9cffd5d2..7679d9231 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h @@ -45,7 +45,6 @@ class QGroupBox; class QLabel; class QLineEdit; class QCheckBox; -class QSpinBox; class QPushButton; class SMESHGUI; @@ -55,6 +54,7 @@ class SMESHGUI_SpinBox; class SVTK_Selector; class LightApp_SelectionMgr; class SUIT_SelectionFilter; +class SalomeApp_IntSpinBox; //================================================================================= // class : SMESHGUI_ExtrusionDlg @@ -74,6 +74,8 @@ private: void keyPressEvent( QKeyEvent* ); int GetConstructorId(); + bool isValid(); + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI_IdValidator* myIdValidator; LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ @@ -107,7 +109,7 @@ private: QLabel* TextLabelDz; SMESHGUI_SpinBox* SpinBox_Dz; QLabel* TextLabelNbSteps; - QSpinBox* SpinBox_NbSteps; + SalomeApp_IntSpinBox* SpinBox_NbSteps; QCheckBox* MakeGroupsCheck; QGroupBox* GroupButtons; diff --git a/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx b/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx index 1c47f52e9..74711ca31 100644 --- a/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx @@ -371,9 +371,11 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply() return false; } - if ( !isValid() ) { // node id is invalid - SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ), - tr("INVALID_ID") ); + QString msg; + if ( !isValid( msg ) ) { // node id is invalid + if( !msg.isEmpty() ) + SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ), + tr("INVALID_ID") ); dlg()->show(); return false; } @@ -407,6 +409,12 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply() } if (aResult) { + QStringList aParameters; + aParameters << myDlg->myX->text(); + aParameters << myDlg->myY->text(); + aParameters << myDlg->myZ->text(); + aMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); + myDlg->myId->setText(""); SALOME_ListIO aList; @@ -431,10 +439,9 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply() */ //================================================================================ -bool SMESHGUI_MakeNodeAtPointOp::isValid() +bool SMESHGUI_MakeNodeAtPointOp::isValid( QString& msg ) { bool ok = true; - if ( myMeshActor && myDlg->myMoveRBtn->isDown() && !myDlg->myAutoSearchChkBox->isChecked() ) @@ -444,7 +451,14 @@ bool SMESHGUI_MakeNodeAtPointOp::isValid() if ( id > 0 ) if (SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()) ok = aMesh->FindNode( id ); + if( !ok ) + msg += tr("INVALID_ID") + "\n"; } + + ok = myDlg->myX->isValid( msg, !myNoPreview ) && ok; + ok = myDlg->myY->isValid( msg, !myNoPreview ) && ok; + ok = myDlg->myZ->isValid( msg, !myNoPreview ) && ok; + return ok; } @@ -537,7 +551,8 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() const bool preview = myDlg->myPreviewChkBox->isChecked(); if ( autoSearch ) myDlg->myId->setText(""); - if ( preview && ( autoSearch || isValid() )) + QString msg; + if ( preview && ( autoSearch || isValid( msg ) )) { try { SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO()); diff --git a/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.h b/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.h index 5da7f3ad0..eb1fd9e52 100644 --- a/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.h +++ b/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.h @@ -59,7 +59,7 @@ protected: virtual void activateSelection(); - bool isValid(); + bool isValid( QString& ); protected slots: virtual bool onApply(); diff --git a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx index e4bbc8bed..aaeaa4481 100644 --- a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx @@ -281,6 +281,22 @@ bool SMESHGUI_MoveNodesDlg::isValid (const bool theMess) tr("NODE_ID_IS_NOT_DEFINED")); return false; } + + QString msg; + bool ok = true; + ok = myX->isValid( msg, theMess ) && ok; + ok = myY->isValid( msg, theMess ) && ok; + ok = myZ->isValid( msg, theMess ) && ok; + if( !ok ) { + if( theMess ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + } + return false; + } + return true; } @@ -325,6 +341,12 @@ bool SMESHGUI_MoveNodesDlg::onApply() bool aResult = false; try { aResult = aMeshEditor->MoveNode(anId, myX->GetValue(), myY->GetValue(), myZ->GetValue()); + + QStringList aParameters; + aParameters << myX->text(); + aParameters << myY->text(); + aParameters << myZ->text(); + aMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); } catch (...) { } diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx index 42dbb6b8e..325ccb484 100755 --- a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx @@ -297,7 +297,7 @@ QWidget* SMESHGUI_MultiEditDlg::createButtonFrame (QWidget* theParent) // name : SMESHGUI_MultiEditDlg::isValid // Purpose : Verify validity of input data //======================================================================= -bool SMESHGUI_MultiEditDlg::isValid (const bool /*theMess*/) const +bool SMESHGUI_MultiEditDlg::isValid (const bool /*theMess*/) { return (!myMesh->_is_nil() && (myListBox->count() > 0 || (myToAllChk->isChecked() && myActor))); @@ -1168,12 +1168,39 @@ SMESHGUI_UnionOfTrianglesDlg::~SMESHGUI_UnionOfTrianglesDlg() { } +bool SMESHGUI_UnionOfTrianglesDlg::isValid (const bool theMess) +{ + bool ok = SMESHGUI_MultiEditDlg::isValid( theMess ); + if( !ok ) + return false; + + QString msg; + ok = myMaxAngleSpin->isValid( msg, theMess ); + if( !ok ) { + if( theMess ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + } + return false; + } + + return ok; +} + bool SMESHGUI_UnionOfTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor, const SMESH::long_array& theIds) { SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor(); double aMaxAngle = myMaxAngleSpin->GetValue() * PI / 180.0; - return theEditor->TriToQuad(theIds, aCriterion, aMaxAngle); + bool ok = theEditor->TriToQuad(theIds, aCriterion, aMaxAngle); + if( ok ) { + QStringList aParameters; + aParameters << myMaxAngleSpin->text(); + myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); + } + return ok; } diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.h b/src/SMESHGUI/SMESHGUI_MultiEditDlg.h index 894b908ae..faa8558f4 100755 --- a/src/SMESHGUI/SMESHGUI_MultiEditDlg.h +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.h @@ -106,7 +106,7 @@ protected: void keyPressEvent( QKeyEvent* ); QWidget* createButtonFrame( QWidget* ); QWidget* createMainFrame( QWidget*, const bool ); - bool isValid( const bool ) const; + virtual bool isValid( const bool ); SMESH::long_array_var getIds(); void updateButtons(); void setSelectionMode(); @@ -189,6 +189,7 @@ public: virtual ~SMESHGUI_UnionOfTrianglesDlg(); protected: + virtual bool isValid( const bool ); virtual bool process( SMESH::SMESH_MeshEditor_ptr, const SMESH::long_array& ); private: diff --git a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx index 4bf4ddeb9..e8bba7c89 100644 --- a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx @@ -87,13 +87,14 @@ namespace SMESH { - void AddNode( SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z ) + void AddNode( SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z, const QStringList& theParameters ) { SUIT_OverrideCursor wc; try { _PTR(SObject) aSobj = SMESH::FindSObject( theMesh ); SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor(); aMeshEditor->AddNode( x, y, z ); + theMesh->SetParameters( SMESHGUI::JoinObjectParameters(theParameters) ); _PTR(Study) aStudy = GetActiveStudyDocument(); CORBA::Long anId = aStudy->StudyId(); if (TVisualObjPtr aVisualObj = SMESH::GetVisualObj( anId, aSobj->GetID().c_str() ) ) { @@ -400,12 +401,21 @@ bool SMESHGUI_NodesDlg::ClickOnApply() return false; } + if( !isValid() ) + return false; + /* Recup args and call method */ double x = SpinBox_X->GetValue(); double y = SpinBox_Y->GetValue(); double z = SpinBox_Z->GetValue(); + + QStringList aParameters; + aParameters << SpinBox_X->text(); + aParameters << SpinBox_Y->text(); + aParameters << SpinBox_Z->text(); + mySimulation->SetVisibility( false ); - SMESH::AddNode( myMesh, x, y, z ); + SMESH::AddNode( myMesh, x, y, z, aParameters ); SMESH::SetPointRepresentation( true ); // select myMesh @@ -591,3 +601,25 @@ void SMESHGUI_NodesDlg::keyPressEvent( QKeyEvent* e ) ClickOnHelp(); } } + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool SMESHGUI_NodesDlg::isValid() +{ + QString msg; + bool ok = true; + ok = SpinBox_X->isValid( msg, true ) && ok; + ok = SpinBox_Y->isValid( msg, true ) && ok; + ok = SpinBox_Z->isValid( msg, true ) && ok; + + if( !ok ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return false; + } + return true; +} diff --git a/src/SMESHGUI/SMESHGUI_NodesDlg.h b/src/SMESHGUI/SMESHGUI_NodesDlg.h index 908ad4198..a8e47b205 100644 --- a/src/SMESHGUI/SMESHGUI_NodesDlg.h +++ b/src/SMESHGUI/SMESHGUI_NodesDlg.h @@ -77,6 +77,8 @@ private: void hideEvent ( QHideEvent* ); void keyPressEvent( QKeyEvent* ); + bool isValid(); + QGroupBox* GroupConstructors; QRadioButton* Constructor1; QGroupBox* GroupCoordinates; diff --git a/src/SMESHGUI/SMESHGUI_RotationDlg.cxx b/src/SMESHGUI/SMESHGUI_RotationDlg.cxx index f564198de..b683f9f98 100644 --- a/src/SMESHGUI/SMESHGUI_RotationDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RotationDlg.cxx @@ -355,10 +355,13 @@ void SMESHGUI_RotationDlg::Init (bool ResetControls) // function : ClickOnApply() // purpose : //================================================================================= -void SMESHGUI_RotationDlg::ClickOnApply() +bool SMESHGUI_RotationDlg::ClickOnApply() { if (mySMESHGUI->isActiveStudyLocked()) - return; + return false; + + if( !isValid() ) + return false; if (myNbOkElements && IsAxisOk()) { QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts); @@ -379,6 +382,16 @@ void SMESHGUI_RotationDlg::ClickOnApply() anAxis.vz = SpinBox_DZ->GetValue(); double anAngle = (SpinBox_Angle->GetValue())*PI/180; + + QStringList aParameters; + aParameters << SpinBox_X->text(); + aParameters << SpinBox_Y->text(); + aParameters << SpinBox_Z->text(); + aParameters << SpinBox_DX->text(); + aParameters << SpinBox_DY->text(); + aParameters << SpinBox_DZ->text(); + aParameters << SpinBox_Angle->text(); + int actionButton = ActionGroup->checkedId(); bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ); try { @@ -387,6 +400,8 @@ void SMESHGUI_RotationDlg::ClickOnApply() switch ( actionButton ) { case MOVE_ELEMS_BUTTON: aMeshEditor->Rotate(anElementsId, anAxis, anAngle, false); + if( !myMesh->_is_nil()) + myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); break; case COPY_ELEMS_BUTTON: if ( makeGroups ) @@ -394,11 +409,15 @@ void SMESHGUI_RotationDlg::ClickOnApply() aMeshEditor->RotateMakeGroups(anElementsId, anAxis, anAngle); else aMeshEditor->Rotate(anElementsId, anAxis, anAngle, true); + if( !myMesh->_is_nil()) + myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); break; case MAKE_MESH_BUTTON: SMESH::SMESH_Mesh_var mesh = aMeshEditor->RotateMakeMesh(anElementsId, anAxis, anAngle, makeGroups, LineEditNewMesh->text().toLatin1().data()); + if( !mesh->_is_nil()) + mesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); } } catch (...) { } @@ -410,6 +429,8 @@ void SMESHGUI_RotationDlg::ClickOnApply() Init(false); SelectionIntoArgument(); } + + return true; } //================================================================================= @@ -418,8 +439,8 @@ void SMESHGUI_RotationDlg::ClickOnApply() //================================================================================= void SMESHGUI_RotationDlg::ClickOnOk() { - ClickOnApply(); - ClickOnCancel(); + if( ClickOnApply() ) + ClickOnCancel(); } //================================================================================= @@ -906,3 +927,30 @@ void SMESHGUI_RotationDlg::keyPressEvent( QKeyEvent* e ) ClickOnHelp(); } } + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool SMESHGUI_RotationDlg::isValid() +{ + bool ok = true; + QString msg; + + ok = SpinBox_X->isValid( msg, true ) && ok; + ok = SpinBox_Y->isValid( msg, true ) && ok; + ok = SpinBox_Z->isValid( msg, true ) && ok; + ok = SpinBox_DX->isValid( msg, true ) && ok; + ok = SpinBox_DY->isValid( msg, true ) && ok; + ok = SpinBox_DZ->isValid( msg, true ) && ok; + ok = SpinBox_Angle->isValid( msg, true ) && ok; + + if( !ok ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return false; + } + return true; +} diff --git a/src/SMESHGUI/SMESHGUI_RotationDlg.h b/src/SMESHGUI/SMESHGUI_RotationDlg.h index bee73659c..fbb2ee08d 100644 --- a/src/SMESHGUI/SMESHGUI_RotationDlg.h +++ b/src/SMESHGUI/SMESHGUI_RotationDlg.h @@ -72,6 +72,8 @@ private: bool IsAxisOk(); void setNewMeshName(); + bool isValid(); + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI_IdValidator* myIdValidator; LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ @@ -130,7 +132,7 @@ private: private slots: void ClickOnOk(); void ClickOnCancel(); - void ClickOnApply(); + bool ClickOnApply(); void ClickOnHelp(); void SetEditCurrentArgument(); void SelectionIntoArgument(); diff --git a/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx b/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx index 8090b5455..4b7b094be 100644 --- a/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx @@ -49,6 +49,8 @@ #include #include +#include + #include #include #include @@ -67,7 +69,6 @@ #include #include #include -#include #include #include #include @@ -154,7 +155,7 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule ) // Controls for iteration limit defining TextLabelLimit = new QLabel(tr("ITERATION_LIMIT"), GroupArguments); - SpinBox_IterationLimit = new QSpinBox(GroupArguments); + SpinBox_IterationLimit = new SalomeApp_IntSpinBox(GroupArguments); // Controls for max. aspect ratio defining TextLabelAspectRatio = new QLabel(tr("MAX_ASPECT_RATIO"), GroupArguments); @@ -306,10 +307,13 @@ void SMESHGUI_SmoothingDlg::Init() // function : ClickOnApply() // purpose : Called when user presses button //================================================================================= -void SMESHGUI_SmoothingDlg::ClickOnApply() +bool SMESHGUI_SmoothingDlg::ClickOnApply() { if (mySMESHGUI->isActiveStudyLocked()) - return; + return false; + + if (!isValid()) + return false; if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) { QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts); @@ -333,6 +337,10 @@ void SMESHGUI_SmoothingDlg::ClickOnApply() long anIterationLimit = (long)SpinBox_IterationLimit->value(); double aMaxAspectRatio = SpinBox_AspectRatio->GetValue(); + QStringList aParameters; + aParameters << SpinBox_IterationLimit->text(); + aParameters << SpinBox_AspectRatio->text(); + SMESH::SMESH_MeshEditor::Smooth_Method aMethod = SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH; if (ComboBoxMethod->currentIndex() > 0) aMethod = SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH; @@ -348,6 +356,9 @@ void SMESHGUI_SmoothingDlg::ClickOnApply() else aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(), anIterationLimit, aMaxAspectRatio, aMethod); + + myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); + } catch (...) { } @@ -361,6 +372,8 @@ void SMESHGUI_SmoothingDlg::ClickOnApply() Init(); } } + + return true; } //================================================================================= @@ -369,8 +382,8 @@ void SMESHGUI_SmoothingDlg::ClickOnApply() //================================================================================= void SMESHGUI_SmoothingDlg::ClickOnOk() { - ClickOnApply(); - ClickOnCancel(); + if( ClickOnApply() ) + ClickOnCancel(); } //================================================================================= @@ -757,3 +770,24 @@ void SMESHGUI_SmoothingDlg::keyPressEvent( QKeyEvent* e ) ClickOnHelp(); } } + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool SMESHGUI_SmoothingDlg::isValid() +{ + QString msg; + bool ok = true; + ok = SpinBox_IterationLimit->isValid( msg, true ) && ok; + ok = SpinBox_AspectRatio->isValid( msg, true ) && ok; + + if( !ok ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return false; + } + return true; +} diff --git a/src/SMESHGUI/SMESHGUI_SmoothingDlg.h b/src/SMESHGUI/SMESHGUI_SmoothingDlg.h index cf9d195ff..cb067431f 100644 --- a/src/SMESHGUI/SMESHGUI_SmoothingDlg.h +++ b/src/SMESHGUI/SMESHGUI_SmoothingDlg.h @@ -43,7 +43,7 @@ class QPushButton; class QRadioButton; class QComboBox; class QCheckBox; -class QSpinBox; +class SalomeApp_IntSpinBox; class SMESHGUI_IdValidator; class SMESHGUI_SpinBox; class SMESHGUI; @@ -71,6 +71,8 @@ private: void hideEvent( QHideEvent* ); /* ESC key */ void keyPressEvent( QKeyEvent* ); + bool isValid(); + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI_IdValidator* myIdValidator; LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ @@ -104,7 +106,7 @@ private: QLabel* TextLabelMethod; QComboBox* ComboBoxMethod; QLabel* TextLabelLimit; - QSpinBox* SpinBox_IterationLimit; + SalomeApp_IntSpinBox* SpinBox_IterationLimit; QLabel* TextLabelAspectRatio; SMESHGUI_SpinBox* SpinBox_AspectRatio; QCheckBox* CheckBoxParametric; @@ -114,7 +116,7 @@ private: private slots: void ClickOnOk(); void ClickOnCancel(); - void ClickOnApply(); + bool ClickOnApply(); void ClickOnHelp(); void SetEditCurrentArgument(); void SelectionIntoArgument(); diff --git a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx index 214cca5e0..6a41b5f05 100644 --- a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx @@ -428,10 +428,13 @@ void SMESHGUI_SymmetryDlg::ConstructorsClicked (int constructorId) // function : ClickOnApply() // purpose : //================================================================================= -void SMESHGUI_SymmetryDlg::ClickOnApply() +bool SMESHGUI_SymmetryDlg::ClickOnApply() { if (mySMESHGUI->isActiveStudyLocked()) - return; + return false; + + if( !isValid() ) + return false; if (myNbOkElements && IsMirrorOk()) { QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts); @@ -455,6 +458,13 @@ void SMESHGUI_SymmetryDlg::ClickOnApply() aMirror.vz = SpinBox_DZ->GetValue(); } + QStringList aParameters; + aParameters << SpinBox_X->text(); + aParameters << SpinBox_Y->text(); + aParameters << SpinBox_Z->text(); + aParameters << ( GetConstructorId() == 0 ? QString::number(0) : SpinBox_DX->text() ); + aParameters << ( GetConstructorId() == 0 ? QString::number(0) : SpinBox_DY->text() ); + aParameters << ( GetConstructorId() == 0 ? QString::number(0) : SpinBox_DZ->text() ); SMESH::SMESH_MeshEditor::MirrorType aMirrorType; @@ -475,6 +485,8 @@ void SMESHGUI_SymmetryDlg::ClickOnApply() switch ( actionButton ) { case MOVE_ELEMS_BUTTON: aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, false ); + if( !myMesh->_is_nil()) + myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); break; case COPY_ELEMS_BUTTON: if ( makeGroups ) @@ -482,11 +494,15 @@ void SMESHGUI_SymmetryDlg::ClickOnApply() aMeshEditor->MirrorMakeGroups(anElementsId, aMirror, aMirrorType); else aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, true); + if( !myMesh->_is_nil()) + myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); break; case MAKE_MESH_BUTTON: SMESH::SMESH_Mesh_var mesh = aMeshEditor->MirrorMakeMesh(anElementsId, aMirror, aMirrorType, makeGroups, LineEditNewMesh->text().toLatin1().data()); + if( !mesh->_is_nil()) + mesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); } } catch (...) { } @@ -499,6 +515,8 @@ void SMESHGUI_SymmetryDlg::ClickOnApply() ConstructorsClicked(GetConstructorId()); SelectionIntoArgument(); } + + return true; } //================================================================================= @@ -507,8 +525,8 @@ void SMESHGUI_SymmetryDlg::ClickOnApply() //================================================================================= void SMESHGUI_SymmetryDlg::ClickOnOk() { - ClickOnApply(); - ClickOnCancel(); + if( ClickOnApply() ) + ClickOnCancel(); } //================================================================================= @@ -1004,3 +1022,31 @@ void SMESHGUI_SymmetryDlg::keyPressEvent( QKeyEvent* e ) ClickOnHelp(); } } + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool SMESHGUI_SymmetryDlg::isValid() +{ + bool ok = true; + QString msg; + + ok = SpinBox_X->isValid( msg, true ) && ok; + ok = SpinBox_Y->isValid( msg, true ) && ok; + ok = SpinBox_Z->isValid( msg, true ) && ok; + if (GetConstructorId() != 0) { + ok = SpinBox_DX->isValid( msg, true ) && ok; + ok = SpinBox_DY->isValid( msg, true ) && ok; + ok = SpinBox_DZ->isValid( msg, true ) && ok; + } + + if( !ok ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return false; + } + return true; +} diff --git a/src/SMESHGUI/SMESHGUI_SymmetryDlg.h b/src/SMESHGUI/SMESHGUI_SymmetryDlg.h index faa9eebfa..21a36753f 100644 --- a/src/SMESHGUI/SMESHGUI_SymmetryDlg.h +++ b/src/SMESHGUI/SMESHGUI_SymmetryDlg.h @@ -73,6 +73,8 @@ private: bool IsMirrorOk(); void setNewMeshName(); + bool isValid(); + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI_IdValidator* myIdValidator; LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ @@ -132,7 +134,7 @@ private slots: void ConstructorsClicked( int ); void ClickOnOk(); void ClickOnCancel(); - void ClickOnApply(); + bool ClickOnApply(); void ClickOnHelp(); void SetEditCurrentArgument(); void SelectionIntoArgument(); diff --git a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx index 0bb49b04a..2b55740f3 100644 --- a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx @@ -441,6 +441,11 @@ bool SMESHGUI_TranslationDlg::ClickOnApply() aParameters << SpinBox1_1->text(); aParameters << SpinBox1_2->text(); aParameters << SpinBox1_3->text(); + if (GetConstructorId() == 0) { + aParameters << SpinBox2_1->text(); + aParameters << SpinBox2_2->text(); + aParameters << SpinBox2_3->text(); + } int actionButton = ActionGroup->checkedId(); bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ); diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index cde2fbebd..6cb6d199a 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -894,8 +894,8 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand) if ( sameMethods.empty() ) { const char * names[] = { "RemoveElements","RemoveNodes","AddNode","AddEdge","AddFace","AddPolygonalFace", - "AddVolume","AddPolyhedralVolume","AddPolyhedralVolumeByFaces","MoveNode", - "InverseDiag","DeleteDiag","Reorient","ReorientObject","SplitQuad","SplitQuadObject", + "AddVolume","AddPolyhedralVolume","AddPolyhedralVolumeByFaces","MoveNode", "MoveClosestNodeToPoint", + "InverseDiag","DeleteDiag","Reorient","ReorientObject","TriToQuad","SplitQuad","SplitQuadObject", "BestSplit","Smooth","SmoothObject","SmoothParametric","SmoothParametricObject", "ConvertToQuadratic","ConvertFromQuadratic","RenumberNodes","RenumberElements", "RotationSweep","RotationSweepObject","ExtrusionSweep","AdvancedExtrusion", @@ -1770,14 +1770,21 @@ const TCollection_AsciiString & _pyCommand::GetArg( int index ) if ( begPos < 1 ) begPos = myString.Location( "(", 1, Length() ) + 1; - int i = 0, prevLen = 0; + int i = 0, prevLen = 0, nbNestings = 0; while ( begPos != EMPTY ) { begPos += prevLen; + if( myString.Value( begPos ) == '(' ) + nbNestings++; // check if we are looking at the closing parenthesis while ( begPos <= Length() && isspace( myString.Value( begPos ))) ++begPos; - if ( begPos > Length() || myString.Value( begPos ) == ')' ) + if ( begPos > Length() ) break; + if ( myString.Value( begPos ) == ')' ) { + nbNestings--; + if( nbNestings == 0 ) + break; + } myArgs.Append( GetWord( myString, begPos, true, true )); SetBegPos( ARG1_IND + i, begPos ); prevLen = myArgs.Last().Length(); diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index f7da16dce..301d5f45f 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -1563,9 +1563,8 @@ void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElemen { extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false ); if ( !myPreviewMode ) { - TPythonDump() << "stepVector = " << theStepVector; TPythonDump() << this << ".ExtrusionSweep( " - << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )"; + << theIDsOfElements << ", " << theStepVector <<", " << theNbOfSteps << " )"; } } @@ -1637,11 +1636,10 @@ SMESH_MeshEditor_i::ExtrusionSweepMakeGroups(const SMESH::long_array& theIDsOfEl SMESH::ListOfGroups* aGroups = extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, true ); if ( !myPreviewMode ) { - TPythonDump() << "stepVector = " << theStepVector; TPythonDump aPythonDump; DumpGroupsList(aPythonDump,aGroups); aPythonDump << this << ".ExtrusionSweepMakeGroups( " - << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )"; + << theIDsOfElements << ", " << theStepVector <<", " << theNbOfSteps << " )"; } return aGroups; } @@ -2287,12 +2285,11 @@ SMESH_MeshEditor_i::MirrorMakeGroups(const SMESH::long_array& theIDsO { SMESH::ListOfGroups * aGroups = mirror(theIDsOfElements, theMirror, theMirrorType, true, true); if ( !myPreviewMode ) { - TPythonDump()<<"axis = "<GetIDs(); SMESH::ListOfGroups * aGroups = mirror(anElementsId, theMirror, theMirrorType, true, true); if ( !myPreviewMode ) { - TPythonDump()<<"axis = "<GetMethod(); @@ -296,7 +295,9 @@ void SMESH_NoteBook::ReplaceVariables() } else if(aStates->GetObjectType().IsEqual("Mesh")) { - if(aMethod.IsEqual("Translate") || + TState aCurrentState = aStates->GetCurrectState(); + int aCurrentStateSize = aCurrentState.size(); + if(aMethod.IsEqual("Translate") || aMethod.IsEqual("TranslateMakeGroups") || aMethod.IsEqual("TranslateMakeMesh")) { bool isVariableFound = false; @@ -308,12 +309,17 @@ void SMESH_NoteBook::ReplaceVariables() } } if(anArgIndex > 0) { - for(int j = 0; j <= 2; j++) { - if(!aStates->GetCurrectState().at(j).IsEmpty()) { - isVariableFound = true; - aCmd->SetArg(anArgIndex+j, aStates->GetCurrectState().at(j)); - } - } + if(aCurrentStateSize == 3) { // translation by dx, dy, dz + for(int j = 0; j < aCurrentStateSize; j++) { + if(!aCurrentState.at(j).IsEmpty()) { + isVariableFound = true; + aCmd->SetArg(anArgIndex+j, aCurrentState.at(j)); + } + } + } + else if(aCurrentStateSize == 6) { // translation by x1, x2, y1, y2, z1, z2 + // TODO + } } if(isVariableFound) { aCmd->SetArg(anArgIndex - 1, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr"); @@ -321,6 +327,89 @@ void SMESH_NoteBook::ReplaceVariables() } aStates->IncrementState(); } + else if(aMethod.IsEqual("Rotate") || + aMethod.IsEqual("RotateMakeGroups") || + aMethod.IsEqual("RotateMakeMesh") || + aMethod.IsEqual("Mirror") || + aMethod.IsEqual("MirrorMakeGroups") || + aMethod.IsEqual("MirrorMakeMesh")) { + bool isSubstitute = false; + int anArgIndex = 0; + for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) { + if(aCmd->GetArg(i).IsEqual("SMESH.AxisStruct")) { + anArgIndex = i+1; + break; + } + } + if(anArgIndex > 0) { + for(int j = 0; j < aCurrentStateSize; j++) { + if(!aCurrentState.at(j).IsEmpty()) { + if(j < 6) // from 0 to 5 - axis struct, 6 - angle + isSubstitute = true; + aCmd->SetArg(anArgIndex+j, aCurrentState.at(j)); + } + } + } + if(isSubstitute) + aCmd->SetArg(anArgIndex - 1, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".AxisStructStr"); + aStates->IncrementState(); + } + else if(aMethod.IsEqual("AddNode") || + aMethod.IsEqual("MoveClosestNodeToPoint")) { + for(int j = 0; j < aCurrentStateSize; j++) { + if(!aCurrentState.at(j).IsEmpty()) + aCmd->SetArg(j+1, aCurrentState.at(j)); + } + aStates->IncrementState(); + } + else if(aMethod.IsEqual("MoveNode")) { + for(int j = 0; j < aCurrentStateSize; j++) { + if(!aCurrentState.at(j).IsEmpty()) + aCmd->SetArg(j+2, aCurrentState.at(j)); + } + aStates->IncrementState(); + } + else if(aMethod.IsEqual("ExtrusionSweep") || + aMethod.IsEqual("ExtrusionSweepMakeGroups")) { + bool isSubstitute = false; + int anArgIndex = 0; + for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) { + if(aCmd->GetArg(i).IsEqual("SMESH.PointStruct")) { + anArgIndex = i+1; + break; + } + } + if(anArgIndex > 0) { + for(int j = 0; j < aCurrentStateSize; j++) { + if(!aCurrentState.at(j).IsEmpty()) { + if(j < 3) // from 0 to 2 - dir struct, 3 - number of steps + isSubstitute = true; + aCmd->SetArg(anArgIndex+j, aCurrentState.at(j)); + } + } + } + if(isSubstitute) { + aCmd->SetArg(anArgIndex - 1, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr"); + aCmd->SetArg(anArgIndex - 2, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".DirStructStr"); + } + aStates->IncrementState(); + } + else if(aMethod.IsEqual("TriToQuad") || + aMethod.IsEqual("Concatenate") || + aMethod.IsEqual("ConcatenateWithGroups")) { + if(aCurrentStateSize && !aCurrentState.at(0).IsEmpty()) + aCmd->SetArg(aCmd->GetNbArgs(), aCurrentState.at(0)); + aStates->IncrementState(); + } + else if(aMethod.IsEqual("Smooth") || + aMethod.IsEqual("SmoothParametric")) { + int anArgIndex = aCmd->GetNbArgs() - 2; + for(int j = 0; j < aCurrentStateSize; j++) { + if(!aCurrentState.at(j).IsEmpty()) + aCmd->SetArg(anArgIndex+j, aCurrentState.at(j)); + } + aStates->IncrementState(); + } } } if(MYDEBUG) { diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py index bb6465aee..2610d5ae4 100644 --- a/src/SMESH_SWIG/smeshDC.py +++ b/src/SMESH_SWIG/smeshDC.py @@ -185,6 +185,54 @@ class PointStructStr: else: self.z = zStr +# Parametrized substitute for AxisStruct +class AxisStructStr: + + x = 0 + y = 0 + z = 0 + dx = 0 + dy = 0 + dz = 0 + xStr = "" + yStr = "" + zStr = "" + dxStr = "" + dyStr = "" + dzStr = "" + + def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr): + self.xStr = xStr + self.yStr = yStr + self.zStr = zStr + self.dxStr = dxStr + self.dyStr = dyStr + self.dzStr = dzStr + if isinstance(xStr, str) and notebook.isVariable(xStr): + self.x = notebook.get(xStr) + else: + self.x = xStr + if isinstance(yStr, str) and notebook.isVariable(yStr): + self.y = notebook.get(yStr) + else: + self.y = yStr + if isinstance(zStr, str) and notebook.isVariable(zStr): + self.z = notebook.get(zStr) + else: + self.z = zStr + if isinstance(dxStr, str) and notebook.isVariable(dxStr): + self.dx = notebook.get(dxStr) + else: + self.dx = dxStr + if isinstance(dyStr, str) and notebook.isVariable(dyStr): + self.dy = notebook.get(dyStr) + else: + self.dy = dyStr + if isinstance(dzStr, str) and notebook.isVariable(dzStr): + self.dz = notebook.get(dzStr) + else: + self.dz = dzStr + # Parametrized substitute for DirStruct class DirStructStr: @@ -192,12 +240,31 @@ class DirStructStr: self.pointStruct = pointStruct # Returns list of variable values from salome notebook -def ParseDirStruct(Vector): - pntStr = Vector.pointStruct - pnt = PointStruct(pntStr.x, pntStr.y, pntStr.z) - Vector = DirStruct(pnt) - Parameters = str(pntStr.xStr) + ":" + str(pntStr.yStr) + ":" + str(pntStr.zStr) - return Vector, Parameters +def ParsePointStruct(Point): + Parameters = "::" + if isinstance(Point, PointStructStr): + Parameters = str(Point.xStr) + ":" + str(Point.yStr) + ":" + str(Point.zStr) + Point = PointStruct(Point.x, Point.y, Point.z) + return Point, Parameters + +# Returns list of variable values from salome notebook +def ParseDirStruct(Dir): + Parameters = "::" + if isinstance(Dir, DirStructStr): + pntStr = Dir.pointStruct + Parameters = str(pntStr.xStr) + ":" + str(pntStr.yStr) + ":" + str(pntStr.zStr) + Point = PointStruct(pntStr.x, pntStr.y, pntStr.z) + Dir = DirStruct(Point) + return Dir, Parameters + +# Returns list of variable values from salome notebook +def ParseAxisStruct(Axis): + Parameters = ":::::" + if isinstance(Axis, AxisStructStr): + Parameters = str(Axis.xStr) + ":" + str(Axis.yStr) + ":" + str(Axis.zStr) + ":" + Parameters += str(Axis.dxStr) + ":" + str(Axis.dyStr) + ":" + str(Axis.dzStr) + Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz) + return Axis, Parameters def IsEqual(val1, val2, tol=PrecisionConfusion): if abs(val1 - val2) < tol: @@ -421,6 +488,32 @@ class smeshDC(SMESH._objref_SMESH_Gen): def GetPattern(self): return SMESH._objref_SMESH_Gen.GetPattern(self) + ## Create a compound of Mesh objects + # @param theMeshArray array of Mesh objects + # @param theUniteIdenticalGroups flag used to unite identical mesh groups + # @param theMergeNodesAndElements flag used to merge mesh nodes and elements + # @param theMergeTolerance tolerance of merging + # @return a compound of Mesh objects + # @ingroup l1_auxiliary + def Concatenate( self, theMeshArray, theUniteIdenticalGroups, theMergeNodesAndElements, theMergeTolerance ): + theMergeTolerance,Parameters = geompyDC.ParseParameters(theMergeTolerance) + aMesh = SMESH._objref_SMESH_Gen.Concatenate( self, theMeshArray, theUniteIdenticalGroups, theMergeNodesAndElements, theMergeTolerance ) + aMesh.SetParameters(Parameters) + return aMesh + + ## Create a compound of Mesh objects + # @param theMeshArray array of Mesh objects + # @param theUniteIdenticalGroups flag used to unite identical mesh groups + # @param theMergeNodesAndElements flag used to merge mesh nodes and elements + # @param theMergeTolerance tolerance of merging + # @return a compound of Mesh objects + # @ingroup l1_auxiliary + def ConcatenateWithGroups( self, theMeshArray, theUniteIdenticalGroups, theMergeNodesAndElements, theMergeTolerance ): + theMergeTolerance,Parameters = geompyDC.ParseParameters(theMergeTolerance) + aMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups( self, theMeshArray, theUniteIdenticalGroups, theMergeNodesAndElements, theMergeTolerance ) + aMesh.SetParameters(Parameters) + return aMesh + # Filtering. Auxiliary functions: # ------------------------------ @@ -1692,6 +1785,8 @@ class Mesh: # @return Id of the new node # @ingroup l2_modif_add def AddNode(self, x, y, z): + x,y,z,Parameters = geompyDC.ParseParameters(x,y,z) + self.mesh.SetParameters(Parameters) return self.editor.AddNode( x, y, z) ## Creates a linear or quadratic edge (this is determined @@ -1847,8 +1942,21 @@ class Mesh: # @return True if succeed else False # @ingroup l2_modif_movenode def MoveNode(self, NodeID, x, y, z): + x,y,z,Parameters = geompyDC.ParseParameters(x,y,z) + self.mesh.SetParameters(Parameters) return self.editor.MoveNode(NodeID, x, y, z) + ## Finds the node closest to a point and moves it to a point location + # @param x the X coordinate of a point + # @param y the Y coordinate of a point + # @param z the Z coordinate of a point + # @return the ID of a node + # @ingroup l2_modif_throughp + def MoveClosestNodeToPoint(self, x, y, z, NodeID): + x,y,z,Parameters = geompyDC.ParseParameters(x,y,z) + self.mesh.SetParameters(Parameters) + return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID) + ## Finds the node closest to a point # @param x the X coordinate of a point # @param y the Y coordinate of a point @@ -1909,12 +2017,25 @@ class Mesh: # @param theCriterion is FT_...; used to choose a neighbour to fuse with. # @param MaxAngle is the maximum angle between element normals at which the fusion # is still performed; theMaxAngle is mesured in radians. + # Also it could be a name of variable which defines angle in degrees. # @return TRUE in case of success, FALSE otherwise. # @ingroup l2_modif_unitetri def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle): + flag = False + if isinstance(MaxAngle,str): + flag = True + MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle) + if flag: + MaxAngle = DegreesToRadians(MaxAngle) if IDsOfElements == []: IDsOfElements = self.GetElementsId() - return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle) + self.mesh.SetParameters(Parameters) + Functor = 0 + if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ): + Functor = theCriterion + else: + Functor = self.smeshpyD.GetFunctor(theCriterion) + return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle) ## Fuses the neighbouring triangles of the object into quadrangles # @param theObject is mesh, submesh or group @@ -2132,6 +2253,8 @@ class Mesh: MaxNbOfIterations, MaxAspectRatio, Method): if IDsOfElements == []: IDsOfElements = self.GetElementsId() + MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio) + self.mesh.SetParameters(Parameters) return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method) @@ -2164,6 +2287,8 @@ class Mesh: MaxNbOfIterations, MaxAspectRatio, Method): if IDsOfElements == []: IDsOfElements = self.GetElementsId() + MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio) + self.mesh.SetParameters(Parameters) return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method) @@ -2269,6 +2394,10 @@ class Mesh: IDsOfElements = self.GetElementsId() if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): StepVector = self.smeshpyD.GetDirStruct(StepVector) + StepVector,StepVectorParameters = ParseDirStruct(StepVector) + NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps) + Parameters = StepVectorParameters + ":" + Parameters + self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps) self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps) @@ -2436,6 +2565,8 @@ class Mesh: IDsOfElements = self.GetElementsId() if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)): Mirror = self.smeshpyD.GetAxisStruct(Mirror) + Mirror,Parameters = ParseAxisStruct(Mirror) + self.mesh.SetParameters(Parameters) if Copy and MakeGroups: return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType) self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy) @@ -2455,8 +2586,10 @@ class Mesh: IDsOfElements = self.GetElementsId() if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)): Mirror = self.smeshpyD.GetAxisStruct(Mirror) + Mirror,Parameters = ParseAxisStruct(Mirror) mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType, MakeGroups, NewMeshName) + mesh.SetParameters(Parameters) return Mesh(self.smeshpyD,self.geompyD,mesh) ## Creates a symmetrical copy of the object @@ -2504,17 +2637,15 @@ class Mesh: # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise # @ingroup l2_modif_trsf def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False): - Parameters = "" if IDsOfElements == []: IDsOfElements = self.GetElementsId() if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)): Vector = self.smeshpyD.GetDirStruct(Vector) - elif ( isinstance( Vector, DirStructStr ) ): - Vector,Parameters = ParseDirStruct(Vector) + Vector,Parameters = ParseDirStruct(Vector) + self.mesh.SetParameters(Parameters) if Copy and MakeGroups: return self.editor.TranslateMakeGroups(IDsOfElements, Vector) self.editor.Translate(IDsOfElements, Vector, Copy) - self.mesh.SetParameters(Parameters) return [] ## Creates a new mesh of translated elements @@ -2525,13 +2656,11 @@ class Mesh: # @return instance of Mesh class # @ingroup l2_modif_trsf def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""): - Parameters = "" if IDsOfElements == []: IDsOfElements = self.GetElementsId() if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)): Vector = self.smeshpyD.GetDirStruct(Vector) - elif ( isinstance( Vector, DirStructStr ) ): - Vector,Parameters = ParseDirStruct(Vector) + Vector,Parameters = ParseDirStruct(Vector) mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName) mesh.SetParameters(Parameters) return Mesh ( self.smeshpyD, self.geompyD, mesh ) @@ -2571,16 +2700,25 @@ class Mesh: ## Rotates the elements # @param IDsOfElements list of elements ids # @param Axis the axis of rotation (AxisStruct or geom line) - # @param AngleInRadians the angle of rotation (in radians) + # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees # @param Copy allows copying the rotated elements # @param MakeGroups forces the generation of new groups from existing ones (if Copy) # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise # @ingroup l2_modif_trsf def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False): + flag = False + if isinstance(AngleInRadians,str): + flag = True + AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians) + if flag: + AngleInRadians = DegreesToRadians(AngleInRadians) if IDsOfElements == []: IDsOfElements = self.GetElementsId() if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): Axis = self.smeshpyD.GetAxisStruct(Axis) + Axis,AxisParameters = ParseAxisStruct(Axis) + Parameters = AxisParameters + ":" + Parameters + self.mesh.SetParameters(Parameters) if Copy and MakeGroups: return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians) self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy) @@ -2589,18 +2727,27 @@ class Mesh: ## Creates a new mesh of rotated elements # @param IDsOfElements list of element ids # @param Axis the axis of rotation (AxisStruct or geom line) - # @param AngleInRadians the angle of rotation (in radians) + # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees # @param MakeGroups forces the generation of new groups from existing ones # @param NewMeshName the name of the newly created mesh # @return instance of Mesh class # @ingroup l2_modif_trsf def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""): + flag = False + if isinstance(AngleInRadians,str): + flag = True + AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians) + if flag: + AngleInRadians = DegreesToRadians(AngleInRadians) if IDsOfElements == []: IDsOfElements = self.GetElementsId() if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): Axis = self.smeshpyD.GetAxisStruct(Axis) + Axis,AxisParameters = ParseAxisStruct(Axis) + Parameters = AxisParameters + ":" + Parameters mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians, MakeGroups, NewMeshName) + mesh.SetParameters(Parameters) return Mesh( self.smeshpyD, self.geompyD, mesh ) ## Rotates the object