Dump Python extension

This commit is contained in:
ouv 2008-11-29 09:15:05 +00:00
parent 8eb6a5158a
commit d3b48c6524
22 changed files with 624 additions and 84 deletions

View File

@ -285,7 +285,14 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply()
{ {
if (mySMESHGUI->isActiveStudyLocked()) if (mySMESHGUI->isActiveStudyLocked())
return false; return false;
if (!isValid())
return false;
if (!myMesh->_is_nil()) { if (!myMesh->_is_nil()) {
QStringList aParameters;
aParameters << SpinBoxTol->text();
try { try {
SUIT_OverrideCursor aWaitCursor; SUIT_OverrideCursor aWaitCursor;
@ -303,6 +310,8 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply()
CheckBoxMerge->isChecked(), CheckBoxMerge->isChecked(),
SpinBoxTol->GetValue()); SpinBoxTol->GetValue());
aCompoundMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
SMESH::SetName( SMESH::FindSObject( aCompoundMesh ), LineEditName->text() ); SMESH::SetName( SMESH::FindSObject( aCompoundMesh ), LineEditName->text() );
mySMESHGUI->updateObjBrowser(); mySMESHGUI->updateObjBrowser();
} catch(...) { } catch(...) {
@ -486,3 +495,22 @@ void SMESHGUI_BuildCompoundDlg::onSelectMerge(bool toMerge)
TextLabelTol->setEnabled(toMerge); TextLabelTol->setEnabled(toMerge);
SpinBoxTol->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;
}

View File

@ -72,6 +72,8 @@ private:
void hideEvent( QHideEvent* ); /* ESC key */ void hideEvent( QHideEvent* ); /* ESC key */
void keyPressEvent( QKeyEvent* ); void keyPressEvent( QKeyEvent* );
bool isValid();
private: private:
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */

View File

@ -52,6 +52,8 @@
#include <SVTK_ViewModel.h> #include <SVTK_ViewModel.h>
#include <SVTK_ViewWindow.h> #include <SVTK_ViewWindow.h>
#include <SalomeApp_IntSpinBox.h>
// OCCT includes // OCCT includes
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx> #include <TColStd_IndexedMapOfInteger.hxx>
@ -65,7 +67,6 @@
#include <QPushButton> #include <QPushButton>
#include <QRadioButton> #include <QRadioButton>
#include <QCheckBox> #include <QCheckBox>
#include <QSpinBox>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QGridLayout> #include <QGridLayout>
@ -177,7 +178,7 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule)
// Controls for nb. steps defining // Controls for nb. steps defining
TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupArguments); TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupArguments);
SpinBox_NbSteps = new QSpinBox(GroupArguments); SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupArguments);
// CheckBox for groups generation // CheckBox for groups generation
MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments); MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
@ -359,6 +360,9 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply()
if (mySMESHGUI->isActiveStudyLocked()) if (mySMESHGUI->isActiveStudyLocked())
return false; return false;
if (!isValid())
return false;
if (myNbOkElements) { if (myNbOkElements) {
SMESH::DirStruct aVector; SMESH::DirStruct aVector;
@ -368,6 +372,12 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply()
long aNbSteps = (long)SpinBox_NbSteps->value(); 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 { try {
SUIT_OverrideCursor aWaitCursor; SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
@ -378,6 +388,8 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply()
else else
aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps); aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps);
myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
} catch (...) { } catch (...) {
} }
@ -755,3 +767,26 @@ void SMESHGUI_ExtrusionDlg::keyPressEvent( QKeyEvent* e )
ClickOnHelp(); 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;
}

View File

@ -45,7 +45,6 @@ class QGroupBox;
class QLabel; class QLabel;
class QLineEdit; class QLineEdit;
class QCheckBox; class QCheckBox;
class QSpinBox;
class QPushButton; class QPushButton;
class SMESHGUI; class SMESHGUI;
@ -55,6 +54,7 @@ class SMESHGUI_SpinBox;
class SVTK_Selector; class SVTK_Selector;
class LightApp_SelectionMgr; class LightApp_SelectionMgr;
class SUIT_SelectionFilter; class SUIT_SelectionFilter;
class SalomeApp_IntSpinBox;
//================================================================================= //=================================================================================
// class : SMESHGUI_ExtrusionDlg // class : SMESHGUI_ExtrusionDlg
@ -74,6 +74,8 @@ private:
void keyPressEvent( QKeyEvent* ); void keyPressEvent( QKeyEvent* );
int GetConstructorId(); int GetConstructorId();
bool isValid();
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator; SMESHGUI_IdValidator* myIdValidator;
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
@ -107,7 +109,7 @@ private:
QLabel* TextLabelDz; QLabel* TextLabelDz;
SMESHGUI_SpinBox* SpinBox_Dz; SMESHGUI_SpinBox* SpinBox_Dz;
QLabel* TextLabelNbSteps; QLabel* TextLabelNbSteps;
QSpinBox* SpinBox_NbSteps; SalomeApp_IntSpinBox* SpinBox_NbSteps;
QCheckBox* MakeGroupsCheck; QCheckBox* MakeGroupsCheck;
QGroupBox* GroupButtons; QGroupBox* GroupButtons;

View File

@ -371,7 +371,9 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply()
return false; return false;
} }
if ( !isValid() ) { // node id is invalid QString msg;
if ( !isValid( msg ) ) { // node id is invalid
if( !msg.isEmpty() )
SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ), SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ),
tr("INVALID_ID") ); tr("INVALID_ID") );
dlg()->show(); dlg()->show();
@ -407,6 +409,12 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply()
} }
if (aResult) if (aResult)
{ {
QStringList aParameters;
aParameters << myDlg->myX->text();
aParameters << myDlg->myY->text();
aParameters << myDlg->myZ->text();
aMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
myDlg->myId->setText(""); myDlg->myId->setText("");
SALOME_ListIO aList; SALOME_ListIO aList;
@ -431,10 +439,9 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply()
*/ */
//================================================================================ //================================================================================
bool SMESHGUI_MakeNodeAtPointOp::isValid() bool SMESHGUI_MakeNodeAtPointOp::isValid( QString& msg )
{ {
bool ok = true; bool ok = true;
if ( myMeshActor && if ( myMeshActor &&
myDlg->myMoveRBtn->isDown() && myDlg->myMoveRBtn->isDown() &&
!myDlg->myAutoSearchChkBox->isChecked() ) !myDlg->myAutoSearchChkBox->isChecked() )
@ -444,7 +451,14 @@ bool SMESHGUI_MakeNodeAtPointOp::isValid()
if ( id > 0 ) if ( id > 0 )
if (SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()) if (SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh())
ok = aMesh->FindNode( id ); 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; return ok;
} }
@ -537,7 +551,8 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
const bool preview = myDlg->myPreviewChkBox->isChecked(); const bool preview = myDlg->myPreviewChkBox->isChecked();
if ( autoSearch ) if ( autoSearch )
myDlg->myId->setText(""); myDlg->myId->setText("");
if ( preview && ( autoSearch || isValid() )) QString msg;
if ( preview && ( autoSearch || isValid( msg ) ))
{ {
try { try {
SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO()); SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());

View File

@ -59,7 +59,7 @@ protected:
virtual void activateSelection(); virtual void activateSelection();
bool isValid(); bool isValid( QString& );
protected slots: protected slots:
virtual bool onApply(); virtual bool onApply();

View File

@ -281,6 +281,22 @@ bool SMESHGUI_MoveNodesDlg::isValid (const bool theMess)
tr("NODE_ID_IS_NOT_DEFINED")); tr("NODE_ID_IS_NOT_DEFINED"));
return false; 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; return true;
} }
@ -325,6 +341,12 @@ bool SMESHGUI_MoveNodesDlg::onApply()
bool aResult = false; bool aResult = false;
try { try {
aResult = aMeshEditor->MoveNode(anId, myX->GetValue(), myY->GetValue(), myZ->GetValue()); 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 (...) { } catch (...) {
} }

View File

@ -297,7 +297,7 @@ QWidget* SMESHGUI_MultiEditDlg::createButtonFrame (QWidget* theParent)
// name : SMESHGUI_MultiEditDlg::isValid // name : SMESHGUI_MultiEditDlg::isValid
// Purpose : Verify validity of input data // 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() && return (!myMesh->_is_nil() &&
(myListBox->count() > 0 || (myToAllChk->isChecked() && myActor))); (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, bool SMESHGUI_UnionOfTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
const SMESH::long_array& theIds) const SMESH::long_array& theIds)
{ {
SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor(); SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor();
double aMaxAngle = myMaxAngleSpin->GetValue() * PI / 180.0; 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;
} }

View File

@ -106,7 +106,7 @@ protected:
void keyPressEvent( QKeyEvent* ); void keyPressEvent( QKeyEvent* );
QWidget* createButtonFrame( QWidget* ); QWidget* createButtonFrame( QWidget* );
QWidget* createMainFrame( QWidget*, const bool ); QWidget* createMainFrame( QWidget*, const bool );
bool isValid( const bool ) const; virtual bool isValid( const bool );
SMESH::long_array_var getIds(); SMESH::long_array_var getIds();
void updateButtons(); void updateButtons();
void setSelectionMode(); void setSelectionMode();
@ -189,6 +189,7 @@ public:
virtual ~SMESHGUI_UnionOfTrianglesDlg(); virtual ~SMESHGUI_UnionOfTrianglesDlg();
protected: protected:
virtual bool isValid( const bool );
virtual bool process( SMESH::SMESH_MeshEditor_ptr, const SMESH::long_array& ); virtual bool process( SMESH::SMESH_MeshEditor_ptr, const SMESH::long_array& );
private: private:

View File

@ -87,13 +87,14 @@
namespace SMESH 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; SUIT_OverrideCursor wc;
try { try {
_PTR(SObject) aSobj = SMESH::FindSObject( theMesh ); _PTR(SObject) aSobj = SMESH::FindSObject( theMesh );
SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor();
aMeshEditor->AddNode( x, y, z ); aMeshEditor->AddNode( x, y, z );
theMesh->SetParameters( SMESHGUI::JoinObjectParameters(theParameters) );
_PTR(Study) aStudy = GetActiveStudyDocument(); _PTR(Study) aStudy = GetActiveStudyDocument();
CORBA::Long anId = aStudy->StudyId(); CORBA::Long anId = aStudy->StudyId();
if (TVisualObjPtr aVisualObj = SMESH::GetVisualObj( anId, aSobj->GetID().c_str() ) ) { if (TVisualObjPtr aVisualObj = SMESH::GetVisualObj( anId, aSobj->GetID().c_str() ) ) {
@ -400,12 +401,21 @@ bool SMESHGUI_NodesDlg::ClickOnApply()
return false; return false;
} }
if( !isValid() )
return false;
/* Recup args and call method */ /* Recup args and call method */
double x = SpinBox_X->GetValue(); double x = SpinBox_X->GetValue();
double y = SpinBox_Y->GetValue(); double y = SpinBox_Y->GetValue();
double z = SpinBox_Z->GetValue(); double z = SpinBox_Z->GetValue();
QStringList aParameters;
aParameters << SpinBox_X->text();
aParameters << SpinBox_Y->text();
aParameters << SpinBox_Z->text();
mySimulation->SetVisibility( false ); mySimulation->SetVisibility( false );
SMESH::AddNode( myMesh, x, y, z ); SMESH::AddNode( myMesh, x, y, z, aParameters );
SMESH::SetPointRepresentation( true ); SMESH::SetPointRepresentation( true );
// select myMesh // select myMesh
@ -591,3 +601,25 @@ void SMESHGUI_NodesDlg::keyPressEvent( QKeyEvent* e )
ClickOnHelp(); 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;
}

View File

@ -77,6 +77,8 @@ private:
void hideEvent ( QHideEvent* ); void hideEvent ( QHideEvent* );
void keyPressEvent( QKeyEvent* ); void keyPressEvent( QKeyEvent* );
bool isValid();
QGroupBox* GroupConstructors; QGroupBox* GroupConstructors;
QRadioButton* Constructor1; QRadioButton* Constructor1;
QGroupBox* GroupCoordinates; QGroupBox* GroupCoordinates;

View File

@ -355,10 +355,13 @@ void SMESHGUI_RotationDlg::Init (bool ResetControls)
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_RotationDlg::ClickOnApply() bool SMESHGUI_RotationDlg::ClickOnApply()
{ {
if (mySMESHGUI->isActiveStudyLocked()) if (mySMESHGUI->isActiveStudyLocked())
return; return false;
if( !isValid() )
return false;
if (myNbOkElements && IsAxisOk()) { if (myNbOkElements && IsAxisOk()) {
QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts); QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
@ -379,6 +382,16 @@ void SMESHGUI_RotationDlg::ClickOnApply()
anAxis.vz = SpinBox_DZ->GetValue(); anAxis.vz = SpinBox_DZ->GetValue();
double anAngle = (SpinBox_Angle->GetValue())*PI/180; 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(); int actionButton = ActionGroup->checkedId();
bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ); bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
try { try {
@ -387,6 +400,8 @@ void SMESHGUI_RotationDlg::ClickOnApply()
switch ( actionButton ) { switch ( actionButton ) {
case MOVE_ELEMS_BUTTON: case MOVE_ELEMS_BUTTON:
aMeshEditor->Rotate(anElementsId, anAxis, anAngle, false); aMeshEditor->Rotate(anElementsId, anAxis, anAngle, false);
if( !myMesh->_is_nil())
myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
break; break;
case COPY_ELEMS_BUTTON: case COPY_ELEMS_BUTTON:
if ( makeGroups ) if ( makeGroups )
@ -394,11 +409,15 @@ void SMESHGUI_RotationDlg::ClickOnApply()
aMeshEditor->RotateMakeGroups(anElementsId, anAxis, anAngle); aMeshEditor->RotateMakeGroups(anElementsId, anAxis, anAngle);
else else
aMeshEditor->Rotate(anElementsId, anAxis, anAngle, true); aMeshEditor->Rotate(anElementsId, anAxis, anAngle, true);
if( !myMesh->_is_nil())
myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
break; break;
case MAKE_MESH_BUTTON: case MAKE_MESH_BUTTON:
SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh_var mesh =
aMeshEditor->RotateMakeMesh(anElementsId, anAxis, anAngle, makeGroups, aMeshEditor->RotateMakeMesh(anElementsId, anAxis, anAngle, makeGroups,
LineEditNewMesh->text().toLatin1().data()); LineEditNewMesh->text().toLatin1().data());
if( !mesh->_is_nil())
mesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
} }
} catch (...) { } catch (...) {
} }
@ -410,6 +429,8 @@ void SMESHGUI_RotationDlg::ClickOnApply()
Init(false); Init(false);
SelectionIntoArgument(); SelectionIntoArgument();
} }
return true;
} }
//================================================================================= //=================================================================================
@ -418,7 +439,7 @@ void SMESHGUI_RotationDlg::ClickOnApply()
//================================================================================= //=================================================================================
void SMESHGUI_RotationDlg::ClickOnOk() void SMESHGUI_RotationDlg::ClickOnOk()
{ {
ClickOnApply(); if( ClickOnApply() )
ClickOnCancel(); ClickOnCancel();
} }
@ -906,3 +927,30 @@ void SMESHGUI_RotationDlg::keyPressEvent( QKeyEvent* e )
ClickOnHelp(); 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;
}

View File

@ -72,6 +72,8 @@ private:
bool IsAxisOk(); bool IsAxisOk();
void setNewMeshName(); void setNewMeshName();
bool isValid();
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator; SMESHGUI_IdValidator* myIdValidator;
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
@ -130,7 +132,7 @@ private:
private slots: private slots:
void ClickOnOk(); void ClickOnOk();
void ClickOnCancel(); void ClickOnCancel();
void ClickOnApply(); bool ClickOnApply();
void ClickOnHelp(); void ClickOnHelp();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void SelectionIntoArgument(); void SelectionIntoArgument();

View File

@ -49,6 +49,8 @@
#include <LightApp_Application.h> #include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <SalomeApp_IntSpinBox.h>
#include <SVTK_ViewModel.h> #include <SVTK_ViewModel.h>
#include <SVTK_Selector.h> #include <SVTK_Selector.h>
#include <SVTK_ViewWindow.h> #include <SVTK_ViewWindow.h>
@ -67,7 +69,6 @@
#include <QRadioButton> #include <QRadioButton>
#include <QComboBox> #include <QComboBox>
#include <QCheckBox> #include <QCheckBox>
#include <QSpinBox>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QGridLayout> #include <QGridLayout>
@ -154,7 +155,7 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule )
// Controls for iteration limit defining // Controls for iteration limit defining
TextLabelLimit = new QLabel(tr("ITERATION_LIMIT"), GroupArguments); TextLabelLimit = new QLabel(tr("ITERATION_LIMIT"), GroupArguments);
SpinBox_IterationLimit = new QSpinBox(GroupArguments); SpinBox_IterationLimit = new SalomeApp_IntSpinBox(GroupArguments);
// Controls for max. aspect ratio defining // Controls for max. aspect ratio defining
TextLabelAspectRatio = new QLabel(tr("MAX_ASPECT_RATIO"), GroupArguments); TextLabelAspectRatio = new QLabel(tr("MAX_ASPECT_RATIO"), GroupArguments);
@ -306,10 +307,13 @@ void SMESHGUI_SmoothingDlg::Init()
// function : ClickOnApply() // function : ClickOnApply()
// purpose : Called when user presses <Apply> button // purpose : Called when user presses <Apply> button
//================================================================================= //=================================================================================
void SMESHGUI_SmoothingDlg::ClickOnApply() bool SMESHGUI_SmoothingDlg::ClickOnApply()
{ {
if (mySMESHGUI->isActiveStudyLocked()) if (mySMESHGUI->isActiveStudyLocked())
return; return false;
if (!isValid())
return false;
if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) { if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts); QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
@ -333,6 +337,10 @@ void SMESHGUI_SmoothingDlg::ClickOnApply()
long anIterationLimit = (long)SpinBox_IterationLimit->value(); long anIterationLimit = (long)SpinBox_IterationLimit->value();
double aMaxAspectRatio = SpinBox_AspectRatio->GetValue(); 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; SMESH::SMESH_MeshEditor::Smooth_Method aMethod = SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH;
if (ComboBoxMethod->currentIndex() > 0) if (ComboBoxMethod->currentIndex() > 0)
aMethod = SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH; aMethod = SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH;
@ -348,6 +356,9 @@ void SMESHGUI_SmoothingDlg::ClickOnApply()
else else
aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(), aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(),
anIterationLimit, aMaxAspectRatio, aMethod); anIterationLimit, aMaxAspectRatio, aMethod);
myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
} catch (...) { } catch (...) {
} }
@ -361,6 +372,8 @@ void SMESHGUI_SmoothingDlg::ClickOnApply()
Init(); Init();
} }
} }
return true;
} }
//================================================================================= //=================================================================================
@ -369,7 +382,7 @@ void SMESHGUI_SmoothingDlg::ClickOnApply()
//================================================================================= //=================================================================================
void SMESHGUI_SmoothingDlg::ClickOnOk() void SMESHGUI_SmoothingDlg::ClickOnOk()
{ {
ClickOnApply(); if( ClickOnApply() )
ClickOnCancel(); ClickOnCancel();
} }
@ -757,3 +770,24 @@ void SMESHGUI_SmoothingDlg::keyPressEvent( QKeyEvent* e )
ClickOnHelp(); 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;
}

View File

@ -43,7 +43,7 @@ class QPushButton;
class QRadioButton; class QRadioButton;
class QComboBox; class QComboBox;
class QCheckBox; class QCheckBox;
class QSpinBox; class SalomeApp_IntSpinBox;
class SMESHGUI_IdValidator; class SMESHGUI_IdValidator;
class SMESHGUI_SpinBox; class SMESHGUI_SpinBox;
class SMESHGUI; class SMESHGUI;
@ -71,6 +71,8 @@ private:
void hideEvent( QHideEvent* ); /* ESC key */ void hideEvent( QHideEvent* ); /* ESC key */
void keyPressEvent( QKeyEvent* ); void keyPressEvent( QKeyEvent* );
bool isValid();
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator; SMESHGUI_IdValidator* myIdValidator;
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
@ -104,7 +106,7 @@ private:
QLabel* TextLabelMethod; QLabel* TextLabelMethod;
QComboBox* ComboBoxMethod; QComboBox* ComboBoxMethod;
QLabel* TextLabelLimit; QLabel* TextLabelLimit;
QSpinBox* SpinBox_IterationLimit; SalomeApp_IntSpinBox* SpinBox_IterationLimit;
QLabel* TextLabelAspectRatio; QLabel* TextLabelAspectRatio;
SMESHGUI_SpinBox* SpinBox_AspectRatio; SMESHGUI_SpinBox* SpinBox_AspectRatio;
QCheckBox* CheckBoxParametric; QCheckBox* CheckBoxParametric;
@ -114,7 +116,7 @@ private:
private slots: private slots:
void ClickOnOk(); void ClickOnOk();
void ClickOnCancel(); void ClickOnCancel();
void ClickOnApply(); bool ClickOnApply();
void ClickOnHelp(); void ClickOnHelp();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void SelectionIntoArgument(); void SelectionIntoArgument();

View File

@ -428,10 +428,13 @@ void SMESHGUI_SymmetryDlg::ConstructorsClicked (int constructorId)
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_SymmetryDlg::ClickOnApply() bool SMESHGUI_SymmetryDlg::ClickOnApply()
{ {
if (mySMESHGUI->isActiveStudyLocked()) if (mySMESHGUI->isActiveStudyLocked())
return; return false;
if( !isValid() )
return false;
if (myNbOkElements && IsMirrorOk()) { if (myNbOkElements && IsMirrorOk()) {
QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts); QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
@ -455,6 +458,13 @@ void SMESHGUI_SymmetryDlg::ClickOnApply()
aMirror.vz = SpinBox_DZ->GetValue(); 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; SMESH::SMESH_MeshEditor::MirrorType aMirrorType;
@ -475,6 +485,8 @@ void SMESHGUI_SymmetryDlg::ClickOnApply()
switch ( actionButton ) { switch ( actionButton ) {
case MOVE_ELEMS_BUTTON: case MOVE_ELEMS_BUTTON:
aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, false ); aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, false );
if( !myMesh->_is_nil())
myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
break; break;
case COPY_ELEMS_BUTTON: case COPY_ELEMS_BUTTON:
if ( makeGroups ) if ( makeGroups )
@ -482,11 +494,15 @@ void SMESHGUI_SymmetryDlg::ClickOnApply()
aMeshEditor->MirrorMakeGroups(anElementsId, aMirror, aMirrorType); aMeshEditor->MirrorMakeGroups(anElementsId, aMirror, aMirrorType);
else else
aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, true); aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, true);
if( !myMesh->_is_nil())
myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
break; break;
case MAKE_MESH_BUTTON: case MAKE_MESH_BUTTON:
SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh_var mesh =
aMeshEditor->MirrorMakeMesh(anElementsId, aMirror, aMirrorType, makeGroups, aMeshEditor->MirrorMakeMesh(anElementsId, aMirror, aMirrorType, makeGroups,
LineEditNewMesh->text().toLatin1().data()); LineEditNewMesh->text().toLatin1().data());
if( !mesh->_is_nil())
mesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
} }
} catch (...) { } catch (...) {
} }
@ -499,6 +515,8 @@ void SMESHGUI_SymmetryDlg::ClickOnApply()
ConstructorsClicked(GetConstructorId()); ConstructorsClicked(GetConstructorId());
SelectionIntoArgument(); SelectionIntoArgument();
} }
return true;
} }
//================================================================================= //=================================================================================
@ -507,7 +525,7 @@ void SMESHGUI_SymmetryDlg::ClickOnApply()
//================================================================================= //=================================================================================
void SMESHGUI_SymmetryDlg::ClickOnOk() void SMESHGUI_SymmetryDlg::ClickOnOk()
{ {
ClickOnApply(); if( ClickOnApply() )
ClickOnCancel(); ClickOnCancel();
} }
@ -1004,3 +1022,31 @@ void SMESHGUI_SymmetryDlg::keyPressEvent( QKeyEvent* e )
ClickOnHelp(); 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;
}

View File

@ -73,6 +73,8 @@ private:
bool IsMirrorOk(); bool IsMirrorOk();
void setNewMeshName(); void setNewMeshName();
bool isValid();
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator; SMESHGUI_IdValidator* myIdValidator;
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
@ -132,7 +134,7 @@ private slots:
void ConstructorsClicked( int ); void ConstructorsClicked( int );
void ClickOnOk(); void ClickOnOk();
void ClickOnCancel(); void ClickOnCancel();
void ClickOnApply(); bool ClickOnApply();
void ClickOnHelp(); void ClickOnHelp();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void SelectionIntoArgument(); void SelectionIntoArgument();

View File

@ -441,6 +441,11 @@ bool SMESHGUI_TranslationDlg::ClickOnApply()
aParameters << SpinBox1_1->text(); aParameters << SpinBox1_1->text();
aParameters << SpinBox1_2->text(); aParameters << SpinBox1_2->text();
aParameters << SpinBox1_3->text(); aParameters << SpinBox1_3->text();
if (GetConstructorId() == 0) {
aParameters << SpinBox2_1->text();
aParameters << SpinBox2_2->text();
aParameters << SpinBox2_3->text();
}
int actionButton = ActionGroup->checkedId(); int actionButton = ActionGroup->checkedId();
bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ); bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );

View File

@ -894,8 +894,8 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand)
if ( sameMethods.empty() ) { if ( sameMethods.empty() ) {
const char * names[] = { const char * names[] = {
"RemoveElements","RemoveNodes","AddNode","AddEdge","AddFace","AddPolygonalFace", "RemoveElements","RemoveNodes","AddNode","AddEdge","AddFace","AddPolygonalFace",
"AddVolume","AddPolyhedralVolume","AddPolyhedralVolumeByFaces","MoveNode", "AddVolume","AddPolyhedralVolume","AddPolyhedralVolumeByFaces","MoveNode", "MoveClosestNodeToPoint",
"InverseDiag","DeleteDiag","Reorient","ReorientObject","SplitQuad","SplitQuadObject", "InverseDiag","DeleteDiag","Reorient","ReorientObject","TriToQuad","SplitQuad","SplitQuadObject",
"BestSplit","Smooth","SmoothObject","SmoothParametric","SmoothParametricObject", "BestSplit","Smooth","SmoothObject","SmoothParametric","SmoothParametricObject",
"ConvertToQuadratic","ConvertFromQuadratic","RenumberNodes","RenumberElements", "ConvertToQuadratic","ConvertFromQuadratic","RenumberNodes","RenumberElements",
"RotationSweep","RotationSweepObject","ExtrusionSweep","AdvancedExtrusion", "RotationSweep","RotationSweepObject","ExtrusionSweep","AdvancedExtrusion",
@ -1770,14 +1770,21 @@ const TCollection_AsciiString & _pyCommand::GetArg( int index )
if ( begPos < 1 ) if ( begPos < 1 )
begPos = myString.Location( "(", 1, Length() ) + 1; begPos = myString.Location( "(", 1, Length() ) + 1;
int i = 0, prevLen = 0; int i = 0, prevLen = 0, nbNestings = 0;
while ( begPos != EMPTY ) { while ( begPos != EMPTY ) {
begPos += prevLen; begPos += prevLen;
if( myString.Value( begPos ) == '(' )
nbNestings++;
// check if we are looking at the closing parenthesis // check if we are looking at the closing parenthesis
while ( begPos <= Length() && isspace( myString.Value( begPos ))) while ( begPos <= Length() && isspace( myString.Value( begPos )))
++begPos; ++begPos;
if ( begPos > Length() || myString.Value( begPos ) == ')' ) if ( begPos > Length() )
break; break;
if ( myString.Value( begPos ) == ')' ) {
nbNestings--;
if( nbNestings == 0 )
break;
}
myArgs.Append( GetWord( myString, begPos, true, true )); myArgs.Append( GetWord( myString, begPos, true, true ));
SetBegPos( ARG1_IND + i, begPos ); SetBegPos( ARG1_IND + i, begPos );
prevLen = myArgs.Last().Length(); prevLen = myArgs.Last().Length();

View File

@ -1563,9 +1563,8 @@ void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElemen
{ {
extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false ); extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false );
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "stepVector = " << theStepVector;
TPythonDump() << this << ".ExtrusionSweep( " 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 ); SMESH::ListOfGroups* aGroups = extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, true );
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "stepVector = " << theStepVector;
TPythonDump aPythonDump; TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups); DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".ExtrusionSweepMakeGroups( " aPythonDump << this << ".ExtrusionSweepMakeGroups( "
<< theIDsOfElements << ", stepVector, " << theNbOfSteps << " )"; << theIDsOfElements << ", " << theStepVector <<", " << theNbOfSteps << " )";
} }
return aGroups; return aGroups;
} }
@ -2287,12 +2285,11 @@ SMESH_MeshEditor_i::MirrorMakeGroups(const SMESH::long_array& theIDsO
{ {
SMESH::ListOfGroups * aGroups = mirror(theIDsOfElements, theMirror, theMirrorType, true, true); SMESH::ListOfGroups * aGroups = mirror(theIDsOfElements, theMirror, theMirrorType, true, true);
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump()<<"axis = "<<theMirror;
TPythonDump aPythonDump; TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups); DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".MirrorMakeGroups( " aPythonDump << this << ".MirrorMakeGroups( "
<< theIDsOfElements << ", " << theIDsOfElements << ", "
<< "axis, " << theMirror << ", "
<< mirrorTypeName(theMirrorType) << " )"; << mirrorTypeName(theMirrorType) << " )";
} }
return aGroups; return aGroups;
@ -2311,12 +2308,11 @@ SMESH_MeshEditor_i::MirrorObjectMakeGroups(SMESH::SMESH_IDSource_ptr t
SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = mirror(anElementsId, theMirror, theMirrorType, true, true); SMESH::ListOfGroups * aGroups = mirror(anElementsId, theMirror, theMirrorType, true, true);
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump()<<"axis = "<<theMirror;
TPythonDump aPythonDump; TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups); DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".MirrorObjectMakeGroups( " aPythonDump << this << ".MirrorObjectMakeGroups( "
<< theObject << ", " << theObject << ", "
<< "axis, " << theMirror << ", "
<< mirrorTypeName(theMirrorType) << " )"; << mirrorTypeName(theMirrorType) << " )";
} }
return aGroups; return aGroups;
@ -2659,10 +2655,9 @@ void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements,
CORBA::Boolean theCopy) CORBA::Boolean theCopy)
{ {
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "axis = " << theAxis;
TPythonDump() << this << ".Rotate( " TPythonDump() << this << ".Rotate( "
<< theIDsOfElements << theIDsOfElements << ", "
<< ", axis, " << theAxis << ", "
<< theAngle << ", " << theAngle << ", "
<< theCopy << " )"; << theCopy << " )";
} }
@ -2684,10 +2679,9 @@ void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject,
CORBA::Boolean theCopy) CORBA::Boolean theCopy)
{ {
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "axis = " << theAxis;
TPythonDump() << this << ".RotateObject( " TPythonDump() << this << ".RotateObject( "
<< theObject << theObject << ", "
<< ", axis, " << theAxis << ", "
<< theAngle << ", " << theAngle << ", "
<< theCopy << " )"; << theCopy << " )";
} }
@ -2711,12 +2705,11 @@ SMESH_MeshEditor_i::RotateMakeGroups(const SMESH::long_array& theIDsOfElements,
{ {
SMESH::ListOfGroups * aGroups = rotate(theIDsOfElements,theAxis,theAngle,true,true); SMESH::ListOfGroups * aGroups = rotate(theIDsOfElements,theAxis,theAngle,true,true);
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "axis = " << theAxis;
TPythonDump aPythonDump; TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups); DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".RotateMakeGroups( " aPythonDump << this << ".RotateMakeGroups( "
<< theIDsOfElements << theIDsOfElements << ", "
<< ", axis, " << theAxis << ", "
<< theAngle << " )"; << theAngle << " )";
} }
return aGroups; return aGroups;
@ -2736,12 +2729,11 @@ SMESH_MeshEditor_i::RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
SMESH::ListOfGroups * aGroups = rotate(anElementsId,theAxis,theAngle,true,true); SMESH::ListOfGroups * aGroups = rotate(anElementsId,theAxis,theAngle,true,true);
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "axis = " << theAxis;
TPythonDump aPythonDump; TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups); DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".RotateObjectMakeGroups( " aPythonDump << this << ".RotateObjectMakeGroups( "
<< theObject << theObject << ", "
<< ", axis, " << theAxis << ", "
<< theAngle << " )"; << theAngle << " )";
} }
return aGroups; return aGroups;

View File

@ -217,7 +217,6 @@ SMESH_NoteBook::~SMESH_NoteBook()
//================================================================================ //================================================================================
void SMESH_NoteBook::ReplaceVariables() void SMESH_NoteBook::ReplaceVariables()
{ {
for(int i=0;i<_commands.size();i++) { for(int i=0;i<_commands.size();i++) {
Handle(_pyCommand) aCmd = _commands[i]; Handle(_pyCommand) aCmd = _commands[i];
TCollection_AsciiString aMethod = aCmd->GetMethod(); TCollection_AsciiString aMethod = aCmd->GetMethod();
@ -296,6 +295,8 @@ void SMESH_NoteBook::ReplaceVariables()
} }
else if(aStates->GetObjectType().IsEqual("Mesh")) { else if(aStates->GetObjectType().IsEqual("Mesh")) {
TState aCurrentState = aStates->GetCurrectState();
int aCurrentStateSize = aCurrentState.size();
if(aMethod.IsEqual("Translate") || if(aMethod.IsEqual("Translate") ||
aMethod.IsEqual("TranslateMakeGroups") || aMethod.IsEqual("TranslateMakeGroups") ||
aMethod.IsEqual("TranslateMakeMesh")) { aMethod.IsEqual("TranslateMakeMesh")) {
@ -308,19 +309,107 @@ void SMESH_NoteBook::ReplaceVariables()
} }
} }
if(anArgIndex > 0) { if(anArgIndex > 0) {
for(int j = 0; j <= 2; j++) { if(aCurrentStateSize == 3) { // translation by dx, dy, dz
if(!aStates->GetCurrectState().at(j).IsEmpty()) { for(int j = 0; j < aCurrentStateSize; j++) {
if(!aCurrentState.at(j).IsEmpty()) {
isVariableFound = true; isVariableFound = true;
aCmd->SetArg(anArgIndex+j, aStates->GetCurrectState().at(j)); aCmd->SetArg(anArgIndex+j, aCurrentState.at(j));
} }
} }
} }
else if(aCurrentStateSize == 6) { // translation by x1, x2, y1, y2, z1, z2
// TODO
}
}
if(isVariableFound) { if(isVariableFound) {
aCmd->SetArg(anArgIndex - 1, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr"); aCmd->SetArg(anArgIndex - 1, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr");
aCmd->SetArg(anArgIndex - 2, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".DirStructStr"); aCmd->SetArg(anArgIndex - 2, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".DirStructStr");
} }
aStates->IncrementState(); 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) { if(MYDEBUG) {

View File

@ -185,6 +185,54 @@ class PointStructStr:
else: else:
self.z = zStr 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 # Parametrized substitute for DirStruct
class DirStructStr: class DirStructStr:
@ -192,12 +240,31 @@ class DirStructStr:
self.pointStruct = pointStruct self.pointStruct = pointStruct
# Returns list of variable values from salome notebook # Returns list of variable values from salome notebook
def ParseDirStruct(Vector): def ParsePointStruct(Point):
pntStr = Vector.pointStruct Parameters = "::"
pnt = PointStruct(pntStr.x, pntStr.y, pntStr.z) if isinstance(Point, PointStructStr):
Vector = DirStruct(pnt) 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) Parameters = str(pntStr.xStr) + ":" + str(pntStr.yStr) + ":" + str(pntStr.zStr)
return Vector, Parameters 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): def IsEqual(val1, val2, tol=PrecisionConfusion):
if abs(val1 - val2) < tol: if abs(val1 - val2) < tol:
@ -421,6 +488,32 @@ class smeshDC(SMESH._objref_SMESH_Gen):
def GetPattern(self): def GetPattern(self):
return SMESH._objref_SMESH_Gen.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: # Filtering. Auxiliary functions:
# ------------------------------ # ------------------------------
@ -1692,6 +1785,8 @@ class Mesh:
# @return Id of the new node # @return Id of the new node
# @ingroup l2_modif_add # @ingroup l2_modif_add
def AddNode(self, x, y, z): 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) return self.editor.AddNode( x, y, z)
## Creates a linear or quadratic edge (this is determined ## Creates a linear or quadratic edge (this is determined
@ -1847,8 +1942,21 @@ class Mesh:
# @return True if succeed else False # @return True if succeed else False
# @ingroup l2_modif_movenode # @ingroup l2_modif_movenode
def MoveNode(self, NodeID, x, y, z): 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) 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 ## Finds the node closest to a point
# @param x the X coordinate of a point # @param x the X coordinate of a point
# @param y the Y 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 theCriterion is FT_...; used to choose a neighbour to fuse with.
# @param MaxAngle is the maximum angle between element normals at which the fusion # @param MaxAngle is the maximum angle between element normals at which the fusion
# is still performed; theMaxAngle is mesured in radians. # 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. # @return TRUE in case of success, FALSE otherwise.
# @ingroup l2_modif_unitetri # @ingroup l2_modif_unitetri
def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle): 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 == []: if IDsOfElements == []:
IDsOfElements = self.GetElementsId() 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 ## Fuses the neighbouring triangles of the object into quadrangles
# @param theObject is mesh, submesh or group # @param theObject is mesh, submesh or group
@ -2132,6 +2253,8 @@ class Mesh:
MaxNbOfIterations, MaxAspectRatio, Method): MaxNbOfIterations, MaxAspectRatio, Method):
if IDsOfElements == []: if IDsOfElements == []:
IDsOfElements = self.GetElementsId() IDsOfElements = self.GetElementsId()
MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
self.mesh.SetParameters(Parameters)
return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes, return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
MaxNbOfIterations, MaxAspectRatio, Method) MaxNbOfIterations, MaxAspectRatio, Method)
@ -2164,6 +2287,8 @@ class Mesh:
MaxNbOfIterations, MaxAspectRatio, Method): MaxNbOfIterations, MaxAspectRatio, Method):
if IDsOfElements == []: if IDsOfElements == []:
IDsOfElements = self.GetElementsId() IDsOfElements = self.GetElementsId()
MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
self.mesh.SetParameters(Parameters)
return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes, return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
MaxNbOfIterations, MaxAspectRatio, Method) MaxNbOfIterations, MaxAspectRatio, Method)
@ -2269,6 +2394,10 @@ class Mesh:
IDsOfElements = self.GetElementsId() IDsOfElements = self.GetElementsId()
if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
StepVector = self.smeshpyD.GetDirStruct(StepVector) StepVector = self.smeshpyD.GetDirStruct(StepVector)
StepVector,StepVectorParameters = ParseDirStruct(StepVector)
NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
Parameters = StepVectorParameters + ":" + Parameters
self.mesh.SetParameters(Parameters)
if MakeGroups: if MakeGroups:
return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps) return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps) self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
@ -2436,6 +2565,8 @@ class Mesh:
IDsOfElements = self.GetElementsId() IDsOfElements = self.GetElementsId()
if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)): if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
Mirror = self.smeshpyD.GetAxisStruct(Mirror) Mirror = self.smeshpyD.GetAxisStruct(Mirror)
Mirror,Parameters = ParseAxisStruct(Mirror)
self.mesh.SetParameters(Parameters)
if Copy and MakeGroups: if Copy and MakeGroups:
return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType) return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy) self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
@ -2455,8 +2586,10 @@ class Mesh:
IDsOfElements = self.GetElementsId() IDsOfElements = self.GetElementsId()
if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)): if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
Mirror = self.smeshpyD.GetAxisStruct(Mirror) Mirror = self.smeshpyD.GetAxisStruct(Mirror)
Mirror,Parameters = ParseAxisStruct(Mirror)
mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType, mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
MakeGroups, NewMeshName) MakeGroups, NewMeshName)
mesh.SetParameters(Parameters)
return Mesh(self.smeshpyD,self.geompyD,mesh) return Mesh(self.smeshpyD,self.geompyD,mesh)
## Creates a symmetrical copy of the object ## 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 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
# @ingroup l2_modif_trsf # @ingroup l2_modif_trsf
def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False): def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
Parameters = ""
if IDsOfElements == []: if IDsOfElements == []:
IDsOfElements = self.GetElementsId() IDsOfElements = self.GetElementsId()
if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)): if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
Vector = self.smeshpyD.GetDirStruct(Vector) 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: if Copy and MakeGroups:
return self.editor.TranslateMakeGroups(IDsOfElements, Vector) return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
self.editor.Translate(IDsOfElements, Vector, Copy) self.editor.Translate(IDsOfElements, Vector, Copy)
self.mesh.SetParameters(Parameters)
return [] return []
## Creates a new mesh of translated elements ## Creates a new mesh of translated elements
@ -2525,12 +2656,10 @@ class Mesh:
# @return instance of Mesh class # @return instance of Mesh class
# @ingroup l2_modif_trsf # @ingroup l2_modif_trsf
def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""): def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
Parameters = ""
if IDsOfElements == []: if IDsOfElements == []:
IDsOfElements = self.GetElementsId() IDsOfElements = self.GetElementsId()
if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)): if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
Vector = self.smeshpyD.GetDirStruct(Vector) 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 = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
mesh.SetParameters(Parameters) mesh.SetParameters(Parameters)
@ -2571,16 +2700,25 @@ class Mesh:
## Rotates the elements ## Rotates the elements
# @param IDsOfElements list of elements ids # @param IDsOfElements list of elements ids
# @param Axis the axis of rotation (AxisStruct or geom line) # @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 Copy allows copying the rotated elements
# @param MakeGroups forces the generation of new groups from existing ones (if Copy) # @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 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
# @ingroup l2_modif_trsf # @ingroup l2_modif_trsf
def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False): 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 == []: if IDsOfElements == []:
IDsOfElements = self.GetElementsId() IDsOfElements = self.GetElementsId()
if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis) Axis = self.smeshpyD.GetAxisStruct(Axis)
Axis,AxisParameters = ParseAxisStruct(Axis)
Parameters = AxisParameters + ":" + Parameters
self.mesh.SetParameters(Parameters)
if Copy and MakeGroups: if Copy and MakeGroups:
return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians) return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy) self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
@ -2589,18 +2727,27 @@ class Mesh:
## Creates a new mesh of rotated elements ## Creates a new mesh of rotated elements
# @param IDsOfElements list of element ids # @param IDsOfElements list of element ids
# @param Axis the axis of rotation (AxisStruct or geom line) # @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 MakeGroups forces the generation of new groups from existing ones
# @param NewMeshName the name of the newly created mesh # @param NewMeshName the name of the newly created mesh
# @return instance of Mesh class # @return instance of Mesh class
# @ingroup l2_modif_trsf # @ingroup l2_modif_trsf
def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""): 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 == []: if IDsOfElements == []:
IDsOfElements = self.GetElementsId() IDsOfElements = self.GetElementsId()
if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis) Axis = self.smeshpyD.GetAxisStruct(Axis)
Axis,AxisParameters = ParseAxisStruct(Axis)
Parameters = AxisParameters + ":" + Parameters
mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians, mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
MakeGroups, NewMeshName) MakeGroups, NewMeshName)
mesh.SetParameters(Parameters)
return Mesh( self.smeshpyD, self.geompyD, mesh ) return Mesh( self.smeshpyD, self.geompyD, mesh )
## Rotates the object ## Rotates the object