\image html add_node.png
+\note You can also use variables defined in the SALOME \b NoteBook
+to specify coordinates of the node:
+
+\image html addnode_notebook.png
+
<br>
\anchor adding_edges_anchor
<h2>Adding edges</h2>
allowing to highlight important elements:
<li>\subpage modifying_meshes_page "modifying meshes" with a vast
array of dedicated operations.</li>
+<li>\subpage using_notebook_mesh_page.</li>
</ul>
Almost all mesh module functionalities are accessible via
--- /dev/null
+/*!
+
+\page using_notebook_mesh_page Using SALOME NoteBook
+
+It is possible to use variables defined through <b>SALOME NoteBook</b> for
+creation and modification of objects in the MESH module with the following
+limitations:
+
+<ul>
+<li> \ref radial_prism_algo_page "Distribution of Layers" hypothesis -
+ parametrical values are correctly applied, but they are not restored
+ after "Update study" operation.
+<li> \ref a1d_meshing_hypo_page "Number of Segments" hypothesis, Distribution
+ with Table Density and Distribution with Analytic Density - parametrical
+ values are not applicable.
+<li> \ref translation_page "Translation" dialog box, default mode
+ (translation by two points) - parametrical values are correctly applied,
+ but they are not restored after "Update study" operation.
+<li> \ref merging_nodes_page "Merging nodes" dialog box - parametrical value
+ (tolerance of coincident nodes detection) is correctly applied,
+ but it is not restored after "Update study" operation.
+<li> \ref revolution_page "Revolution" dialog box - it is impossible to
+ use the angle of revolution as "total angle" if it is defined as variable.
+<li> \ref extrusion_along_path_page "Extrusion along a path" dialog box - it is
+ impossible to use "Linear variation of the angles" mode if at least one of
+ those angles is defined as variable.
+<li> \ref pattern_mapping_page "Pattern mapping" dialog box - parametrical
+ values (indices of nodes) are correctly applied, but they are not restored
+ after "Update study" operation.
+<li> \ref clipping_page "Clipping" dialog box.
+<li> <b>Colors / Size</b> dialog box.
+</ul>
+*/
DIM_3D
};
+ typedef sequence<string> ListOfParameters;
+
interface SMESH_Hypothesis : SALOME::GenericObj
{
+
/*!
* Get the Hypothesis typeName
*/
* Get the internal Id
*/
long GetId();
+
+ /*!
+ * Set list of parameters
+ * \param theParameters is a string containing the notebook variables separated by ":" symbol,
+ * used for Hypothesis creation
+ */
+ void SetParameters (in string theParameters);
+
+ /*!
+ * Return list of notebook variables used for Hypothesis creation separated by ":" symbol
+ */
+ string GetParameters();
+
+ /*!
+ * Return list of last notebook variables used for Hypothesis creation.
+ */
+ ListOfParameters GetLastParameters();
+
+ /*!
+ * Set list of parameters
+ * \param theParameters is a string containing the last notebook variables separated by ":" symbol,
+ * used for Hypothesis creation
+ */
+ void SetLastParameters(in string theParameters);
+ /*!
+ * Clear parameters list
+ */
+ void ClearParameters();
+
/*!
* Verify whether hypothesis supports given entity type
*/
/*! Gets information about imported MED file */
SALOME_MED::MedFileInfo GetMEDFileInfo();
+
+ /*!
+ * Sets list of notebook variables used for Mesh operations separated by ":" symbol
+ * \param theParameters is a string containing the notebook variables
+ */
+ void SetParameters (in string theParameters);
+
+ /*!
+ * Returns list of notebook variables used for Mesh operations separated by ":" symbol
+ */
+ string GetParameters();
+
+ /*!
+ * Returns list of notebook variables used for last Mesh operation
+ */
+ string_array GetLastParameters();
};
interface SMESH_subMesh : SALOME::GenericObj, SMESH_IDSource
in double AngleInRadians,
in long NbOfSteps,
in double Tolerance);
+ /*!
+ * \brief Genarate dim+1 elements by rotation of the object around axis
+ * \param theObject - object containing elements to ratate
+ * \param Axix - rotation axis
+ * \param AngleInRadians - rotation angle
+ * \param NbOfSteps - number of elements to generate from one element
+ */
+ void RotationSweepObject1D(in SMESH_IDSource theObject,
+ in AxisStruct Axix,
+ in double AngleInRadians,
+ in long NbOfSteps,
+ in double Tolerance);
+ /*!
+ * \brief Same as previous but additionally create groups of elements
+ * generated from elements belonging to preexisting groups
+ */
+ ListOfGroups RotationSweepObject1DMakeGroups(in SMESH_IDSource theObject,
+ in AxisStruct Axix,
+ in double AngleInRadians,
+ in long NbOfSteps,
+ in double Tolerance);
+ /*!
+ * \brief Genarate dim+1 elements by rotation of the object around axis
+ * \param theObject - object containing elements to ratate
+ * \param Axix - rotation axis
+ * \param AngleInRadians - rotation angle
+ * \param NbOfSteps - number of elements to generate from one element
+ */
+ void RotationSweepObject2D(in SMESH_IDSource theObject,
+ in AxisStruct Axix,
+ in double AngleInRadians,
+ in long NbOfSteps,
+ in double Tolerance);
+ /*!
+ * \brief Same as previous but additionally create groups of elements
+ * generated from elements belonging to preexisting groups
+ */
+ ListOfGroups RotationSweepObject2DMakeGroups(in SMESH_IDSource theObject,
+ in AxisStruct Axix,
+ in double AngleInRadians,
+ in long NbOfSteps,
+ in double Tolerance);
/*!
* \brief Genarate dim+1 elements by extrusion of elements along vector
* \param IDsOfElements - elements to sweep
in PointStruct RefPoint,
out Extrusion_Error Error);
+ Extrusion_Error ExtrusionAlongPathObject1D(in SMESH_IDSource theObject,
+ in SMESH_Mesh PathMesh,
+ in GEOM::GEOM_Object PathShape,
+ in long NodeStart,
+ in boolean HasAngles,
+ in double_array Angles,
+ in boolean HasRefPoint,
+ in PointStruct RefPoint);
+ ListOfGroups ExtrusionAlongPathObject1DMakeGroups(in SMESH_IDSource theObject,
+ in SMESH_Mesh PathMesh,
+ in GEOM::GEOM_Object PathShape,
+ in long NodeStart,
+ in boolean HasAngles,
+ in double_array Angles,
+ in boolean HasRefPoint,
+ in PointStruct RefPoint,
+ out Extrusion_Error Error);
+
+ Extrusion_Error ExtrusionAlongPathObject2D(in SMESH_IDSource theObject,
+ in SMESH_Mesh PathMesh,
+ in GEOM::GEOM_Object PathShape,
+ in long NodeStart,
+ in boolean HasAngles,
+ in double_array Angles,
+ in boolean HasRefPoint,
+ in PointStruct RefPoint);
+ ListOfGroups ExtrusionAlongPathObject2DMakeGroups(in SMESH_IDSource theObject,
+ in SMESH_Mesh PathMesh,
+ in GEOM::GEOM_Object PathShape,
+ in long NodeStart,
+ in boolean HasAngles,
+ in double_array Angles,
+ in boolean HasRefPoint,
+ in PointStruct RefPoint,
+ out Extrusion_Error Error);
+
/*!
* Compute rotation angles for ExtrusionAlongPath as linear variation
* of given angles along path steps
_type = PARAM_ALGO;
_shapeType = 0; // to be set by algo with TopAbs_Enum
_param_algo_dim = -1; // to be set by algo parameter
+ _parameters = string();
}
//=============================================================================
{
_libName = string(theLibName);
}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void SMESH_Hypothesis::SetParameters(const char *theParameters)
+{
+ string aNewParameters(theParameters);
+ if(aNewParameters.size()==0 && _parameters.size()==0)
+ aNewParameters = " ";
+ if(_parameters.size()>0)
+ _parameters +="|";
+ _parameters +=aNewParameters;
+ SetLastParameters(theParameters);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void SMESH_Hypothesis::ClearParameters()
+{
+ _parameters = string();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+char* SMESH_Hypothesis::GetParameters() const
+{
+ return (char*)_parameters.c_str();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+char* SMESH_Hypothesis::GetLastParameters() const
+{
+ return (char*)_lastParameters.c_str();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void SMESH_Hypothesis::SetLastParameters(const char* theParameters)
+{
+ _lastParameters = string(theParameters);
+}
virtual const char* GetLibName() const;
void SetLibName(const char* theLibName);
+ void SetParameters(const char *theParameters);
+ char* GetParameters() const;
+
+ void SetLastParameters(const char* theParameters);
+ char* GetLastParameters() const;
+ void ClearParameters();
+
/*!
* \brief Initialize my parameter values by the mesh built on the geometry
* \param theMesh - the built mesh
private:
std::string _libName;
+ std::string _parameters;
+ std::string _lastParameters;
};
#endif
return NULL;
}
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+char* SMESHGUI::JoinObjectParameters(const QStringList& theParametersList)
+{
+ return theParametersList.join(":").toLatin1().data();
+}
+
//=============================================================================
/*!
*
static SUIT_ResourceMgr* resourceMgr();
static SUIT_Desktop* desktop();
static SalomeApp_Study* activeStudy();
+ static char* JoinObjectParameters(const QStringList& theParametersList);
+
bool isActiveStudyLocked();
static bool automaticUpdate();
{
if (mySMESHGUI->isActiveStudyLocked())
return false;
+
+ if (!isValid())
+ return false;
+
if (!myMesh->_is_nil()) {
+ QStringList aParameters;
+ aParameters << (CheckBoxMerge->isChecked() ? SpinBoxTol->text() : QString(" "));
try {
SUIT_OverrideCursor aWaitCursor;
CheckBoxMerge->isChecked(),
SpinBoxTol->GetValue());
+ aCompoundMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
+
SMESH::SetName( SMESH::FindSObject( aCompoundMesh ), LineEditName->text() );
mySMESHGUI->updateObjBrowser();
} catch(...) {
//=================================================================================
void SMESHGUI_BuildCompoundDlg::onSelectMerge(bool toMerge)
{
+
TextLabelTol->setEnabled(toMerge);
SpinBoxTol->setEnabled(toMerge);
+ if(!toMerge)
+ SpinBoxTol->SetValue(1e-05);
+}
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool SMESHGUI_BuildCompoundDlg::isValid()
+{
+ QString msg;
+ bool ok=true;
+ if(CheckBoxMerge->isChecked())
+ ok = SpinBoxTol->isValid( msg, true );
+
+ 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;
}
void hideEvent( QHideEvent* ); /* ESC key */
void keyPressEvent( QKeyEvent* );
+ bool isValid();
+
private:
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
!myMeshActor || myPathMesh->_is_nil() || myPathShape->_is_nil())
return false;
- SMESH::long_array_var anElementsId = new SMESH::long_array;
+ if (!isValid())
+ return false;
- if (MeshCheck->isChecked()) {
- // If "Select whole mesh, submesh or group" check box is on ->
- // get all elements of the required type from the object selected
+ SMESH::long_array_var anElementsId = new SMESH::long_array;
- // if MESH object is selected
- if (!CORBA::is_nil(SMESH::SMESH_Mesh::_narrow(myIDSource))) {
- // get mesh
- SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(myIDSource);
- // get IDs from mesh...
- if (Elements1dRB->isChecked())
- // 1d elements
- anElementsId = aMesh->GetElementsByType(SMESH::EDGE);
- else if (Elements2dRB->isChecked()) {
- anElementsId = aMesh->GetElementsByType(SMESH::FACE);
- }
- }
- // SUBMESH is selected
- if (!CORBA::is_nil(SMESH::SMESH_subMesh::_narrow(myIDSource))) {
- // get submesh
- SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(myIDSource);
- // get IDs from submesh
- if (Elements1dRB->isChecked())
- // 1d elements
- anElementsId = aSubMesh->GetElementsByType(SMESH::EDGE);
- else if (Elements2dRB->isChecked())
- // 2d elements
- anElementsId = aSubMesh->GetElementsByType(SMESH::FACE);
- }
- // GROUP is selected
- if (!CORBA::is_nil(SMESH::SMESH_GroupBase::_narrow(myIDSource))) {
- // get smesh group
- SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(myIDSource);
- // get IDs from group
- // 1d elements or 2d elements
- if (Elements1dRB->isChecked() && aGroup->GetType() == SMESH::EDGE ||
- Elements2dRB->isChecked() && aGroup->GetType() == SMESH::FACE)
- anElementsId = aGroup->GetListOfID();
- }
- } else {
+ if (!MeshCheck->isChecked()) {
// If "Select whole mesh, submesh or group" check box is off ->
// use only elements of given type selected by user
}
anElementsId->length(j);
}
- }
- if (anElementsId->length() <= 0) {
- return false;
+ if (anElementsId->length() <= 0) {
+ return false;
+ }
}
if (StartPointLineEdit->text().trimmed().isEmpty()) {
return false;
}
+ QStringList aParameters;
+
// get angles
SMESH::double_array_var anAngles = new SMESH::double_array;
if (AnglesGrp->isChecked()) {
- anAngles->length(AnglesList->count());
+ anAngles->length(myAnglesList.count());
int j = 0;
- bool bOk;
- for (int i = 0; i < AnglesList->count(); i++) {
- double angle = AnglesList->item(i)->text().toDouble(&bOk);
- if (bOk)
- anAngles[ j++ ] = angle*PI/180;
+ for (int i = 0; i < myAnglesList.count(); i++) {
+ double angle = myAnglesList[i];
+ anAngles[ j++ ] = angle*PI/180;
+ aParameters << AnglesList->item(i)->text();
}
anAngles->length(j);
}
aBasePoint.z = ZSpin->GetValue();
}
+ aParameters << XSpin->text();
+ aParameters << YSpin->text();
+ aParameters << ZSpin->text();
+
try {
SUIT_OverrideCursor wc;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
anAngles = aMeshEditor->LinearAnglesVariation( myPathMesh, myPathShape, anAngles );
SMESH::SMESH_MeshEditor::Extrusion_Error retVal;
- if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
- SMESH::ListOfGroups_var groups =
- aMeshEditor->ExtrusionAlongPathMakeGroups(anElementsId, myPathMesh,
- myPathShape, aNodeStart,
- AnglesGrp->isChecked(), anAngles,
- BasePointGrp->isChecked(), aBasePoint, retVal);
- else
- retVal = aMeshEditor->ExtrusionAlongPath(anElementsId, myPathMesh,
- myPathShape, aNodeStart,
- AnglesGrp->isChecked(), anAngles,
- BasePointGrp->isChecked(), aBasePoint);
+ if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
+ if( MeshCheck->isChecked() ) {
+ if( GetConstructorId() == 0 )
+ SMESH::ListOfGroups_var groups =
+ aMeshEditor->ExtrusionAlongPathObject1DMakeGroups(myIDSource, myPathMesh,
+ myPathShape, aNodeStart,
+ AnglesGrp->isChecked(), anAngles,
+ BasePointGrp->isChecked(), aBasePoint, retVal);
+ else
+ SMESH::ListOfGroups_var groups =
+ aMeshEditor->ExtrusionAlongPathObject2DMakeGroups(myIDSource, myPathMesh,
+ myPathShape, aNodeStart,
+ AnglesGrp->isChecked(), anAngles,
+ BasePointGrp->isChecked(), aBasePoint, retVal);
+ }
+ else
+ SMESH::ListOfGroups_var groups =
+ aMeshEditor->ExtrusionAlongPathMakeGroups(anElementsId, myPathMesh,
+ myPathShape, aNodeStart,
+ AnglesGrp->isChecked(), anAngles,
+ BasePointGrp->isChecked(), aBasePoint, retVal);
+ }
+ else {
+ if( MeshCheck->isChecked() ) {
+ if( GetConstructorId() == 0 )
+ retVal = aMeshEditor->ExtrusionAlongPathObject1D(myIDSource, myPathMesh,
+ myPathShape, aNodeStart,
+ AnglesGrp->isChecked(), anAngles,
+ BasePointGrp->isChecked(), aBasePoint);
+ else
+ retVal = aMeshEditor->ExtrusionAlongPathObject2D(myIDSource, myPathMesh,
+ myPathShape, aNodeStart,
+ AnglesGrp->isChecked(), anAngles,
+ BasePointGrp->isChecked(), aBasePoint);
+ }
+ else
+ retVal = aMeshEditor->ExtrusionAlongPath(anElementsId, myPathMesh,
+ myPathShape, aNodeStart,
+ AnglesGrp->isChecked(), anAngles,
+ BasePointGrp->isChecked(), aBasePoint);
+ }
+
+ if( retVal == SMESH::SMESH_MeshEditor::EXTR_OK )
+ myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
//wc.stop();
wc.suspend();
//=======================================================================
void SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded()
{
- AnglesList->addItem(QString::number(AngleSpin->GetValue()));
+ QString msg;
+ if( !AngleSpin->isValid( msg, true ) ) {
+ QString str( tr( "SMESH_INCORRECT_INPUT" ) );
+ if ( !msg.isEmpty() )
+ str += "\n" + msg;
+ SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
+ return;
+ }
+ AnglesList->addItem(AngleSpin->text());
+ myAnglesList.append(AngleSpin->GetValue());
+
+ updateLinearAngles();
}
//=======================================================================
{
QList<QListWidgetItem*> aList = AnglesList->selectedItems();
QListWidgetItem* anItem;
- foreach(anItem, aList) delete anItem;
+ foreach(anItem, aList) {
+ myAnglesList.removeAt(AnglesList->row(anItem));
+ delete anItem;
+ }
+
+ updateLinearAngles();
}
//=================================================================================
myFilterDlg->show();
}
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool SMESHGUI_ExtrusionAlongPathDlg::isValid()
+{
+ QString msg;
+ bool ok = true;
+ ok = XSpin->isValid( msg, true ) && ok;
+ ok = YSpin->isValid( msg, true ) && ok;
+ ok = ZSpin->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;
+}
+
+//=================================================================================
+// function : updateLinearAngles
+// purpose :
+//=================================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::updateLinearAngles()
+{
+ bool enableLinear = true;
+ for( int row = 0, nbRows = AnglesList->count(); row < nbRows; row++ ) {
+ if( QListWidgetItem* anItem = AnglesList->item( row ) ) {
+ enableLinear = false;
+ anItem->text().toDouble(&enableLinear);
+ if( !enableLinear )
+ break;
+ }
+ }
+ if( !enableLinear )
+ LinearAnglesCheck->setChecked( false );
+ LinearAnglesCheck->setEnabled( enableLinear );
+}
int GetConstructorId();
void SetEditCurrentArgument( QToolButton* );
+ bool isValid();
+
+ void updateLinearAngles();
+
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator;
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
SUIT_SelectionFilter* myElementsFilter;
SUIT_SelectionFilter* myPathMeshFilter;
int myType;
+ QList<double> myAnglesList;
// widgets
QGroupBox* ConstructorsBox;
#include <SVTK_ViewModel.h>
#include <SVTK_ViewWindow.h>
+#include <SalomeApp_IntSpinBox.h>
+
// OCCT includes
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <QPushButton>
#include <QRadioButton>
#include <QCheckBox>
-#include <QSpinBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
- myFilterDlg( 0 )
+ myFilterDlg( 0 ),
+ mySelectedObject(SMESH::SMESH_IDSource::_nil())
{
QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
// 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);
if (mySMESHGUI->isActiveStudyLocked())
return false;
+ if (!isValid())
+ return false;
+
if (myNbOkElements) {
gp_XYZ aNormale(SpinBox_Vx->GetValue(),
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();
- if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
- SMESH::ListOfGroups_var groups =
- aMeshEditor->ExtrusionSweepMakeGroups(myElementsId.inout(), aVector, aNbSteps);
- else
- aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps);
+ if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
+ if( CheckBoxMesh->isChecked() ) {
+ if( GetConstructorId() == 0 )
+ SMESH::ListOfGroups_var groups =
+ aMeshEditor->ExtrusionSweepObject1DMakeGroups(mySelectedObject, aVector, aNbSteps);
+ else
+ SMESH::ListOfGroups_var groups =
+ aMeshEditor->ExtrusionSweepObject2DMakeGroups(mySelectedObject, aVector, aNbSteps);
+ }
+ else
+ SMESH::ListOfGroups_var groups =
+ aMeshEditor->ExtrusionSweepMakeGroups(myElementsId.inout(), aVector, aNbSteps);
+ }
+ else {
+ if( CheckBoxMesh->isChecked() ) {
+ if( GetConstructorId() == 0 )
+ aMeshEditor->ExtrusionSweepObject1D(mySelectedObject, aVector, aNbSteps);
+ else
+ aMeshEditor->ExtrusionSweepObject2D(mySelectedObject, aVector, aNbSteps);
+ }
+ else
+ aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps);
+ }
+
+ myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
} catch (...) {
}
mySMESHGUI->updateObjBrowser(true); // new groups may appear
Init(false);
ConstructorsClicked(GetConstructorId());
+ mySelectedObject = SMESH::SMESH_IDSource::_nil();
SelectionIntoArgument();
}
return true;
}
if (CheckBoxMesh->isChecked()) {
- SMESH::ElementType neededType = GetConstructorId() ? SMESH::FACE : SMESH::EDGE;
-
SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
- SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
-
- if (!mesh->_is_nil()) { //MESH
- // get elements from mesh
- myElementsId = mesh->GetElementsByType(neededType);
- aNbElements = myElementsId->length();
- } else {
- SMESH::SMESH_subMesh_var aSubMesh =
- SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
-
- if (!aSubMesh->_is_nil()) { //SUBMESH
- // get IDs from submesh
- myElementsId = aSubMesh->GetElementsByType(neededType);
- aNbElements = myElementsId->length();
- } else {
- SMESH::SMESH_GroupBase_var aGroup =
- SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
-
- if (!aGroup->_is_nil() && aGroup->GetType() == neededType) { // GROUP
- // get IDs from smesh group
- myElementsId = aGroup->GetListOfID();
- aNbElements = myElementsId->length();
- }
- }
- }
+ if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
+ mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
+ else
+ return;
} else {
// get indices of selcted elements
TColStd_IndexedMapOfInteger aMapIndex;
mySelector->GetIndex(IO,aMapIndex);
aNbElements = aMapIndex.Extent();
+ if (aNbElements < 1)
+ return;
+
myElementsId = new SMESH::long_array;
myElementsId->length( aNbElements );
aString = "";
aString += QString(" %1").arg( myElementsId[ i ] = aMapIndex( i+1 ) );
}
- if (aNbElements < 1)
- return;
-
myNbOkElements = true;
myBusy = true;
myFilterDlg->show();
}
+
+//=================================================================================
+// 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;
+}
class QLabel;
class QLineEdit;
class QCheckBox;
-class QSpinBox;
class QPushButton;
class SMESHGUI;
class SVTK_Selector;
class LightApp_SelectionMgr;
class SUIT_SelectionFilter;
+class SalomeApp_IntSpinBox;
//=================================================================================
// class : SMESHGUI_ExtrusionDlg
void keyPressEvent( QKeyEvent* );
int GetConstructorId();
+ bool isValid();
+
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator;
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
int myNbOkElements; /* to check when elements are defined */
SVTK_Selector* mySelector;
+ SMESH::SMESH_IDSource_var mySelectedObject;
+
bool myBusy;
SMESH::SMESH_Mesh_var myMesh;
SMESH::long_array_var myElementsId;
QLabel* TextLabelVz;
SMESHGUI_SpinBox* SpinBox_Vz;
QLabel* TextLabelNbSteps;
- QSpinBox* SpinBox_NbSteps;
+ SalomeApp_IntSpinBox* SpinBox_NbSteps;
QCheckBox* MakeGroupsCheck;
QGroupBox* GroupButtons;
#include <utilities.h>
// SALOME GUI includes
-#include <QtxIntSpinBox.h>
#include <SUIT_Session.h>
#include <SUIT_MessageBox.h>
#include <SUIT_ResourceMgr.h>
#include <LightApp_Application.h>
+#include <SalomeApp_IntSpinBox.h>
// Qt includes
#include <QFrame>
{
case QVariant::Int:
{
- QtxIntSpinBox* sb = new QtxIntSpinBox( GroupC1 );
+ SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
sb->setObjectName( (*anIt).myName );
attuneStdWidget( sb, i );
sb->setValue( (*anIt).myValue.toInt() );
break;
case QVariant::Double:
{
- QtxDoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
+ SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
sb->setObjectName( (*anIt).myName );
attuneStdWidget( sb, i );
sb->setValue( (*anIt).myValue.toDouble() );
break;
case QVariant::String:
{
- QLineEdit* le = new QLineEdit( GroupC1 );
- le->setObjectName( (*anIt).myName );
- attuneStdWidget( le, i );
- le->setText( (*anIt).myValue.toString() );
- connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
- w = le;
+ if((*anIt).isVariable) {
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ QString aVar = (*anIt).myValue.toString();
+ if(aStudy->IsInteger(aVar.toLatin1().constData())){
+ SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
+ sb->setObjectName( (*anIt).myName );
+ attuneStdWidget( sb, i );
+ sb->setText( aVar );
+ connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
+ w = sb;
+ }
+ else if(aStudy->IsReal(aVar.toLatin1().constData())){
+ SalomeApp_DoubleSpinBox* sb = new SalomeApp_DoubleSpinBox( GroupC1 );
+ sb->setObjectName( (*anIt).myName );
+ attuneStdWidget( sb, i );
+ sb->setText( aVar );
+ connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
+ w = sb;
+ }
+ }
+ else {
+ QLineEdit* le = new QLineEdit( GroupC1 );
+ le->setObjectName( (*anIt).myName );
+ attuneStdWidget( le, i );
+ le->setText( (*anIt).myValue.toString() );
+ connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
+ w = le;
+ }
}
break;
}
for( ; anIt!=aLast; anIt++ )
{
item.myName = (*anIt)->objectName();
- if( (*anIt)->inherits( "QtxIntSpinBox" ) )
+ if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
{
- QtxIntSpinBox* sb = ( QtxIntSpinBox* )( *anIt );
+ SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
item.myValue = sb->value();
params.append( item );
}
- else if( (*anIt)->inherits( "QtxDoubleSpinBox" ) )
+ else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
{
- QtxDoubleSpinBox* sb = ( QtxDoubleSpinBox* )( *anIt );
+ SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
item.myValue = sb->value();
params.append( item );
}
return res;
}
+
+QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const
+{
+ QStringList aResult;
+ ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
+ for( ; anIt!=aLast; anIt++ ) {
+ if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) ) {
+ SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
+ aResult.append(sb->text());
+ }
+ else if( (*anIt)->inherits( "QtxDoubleSpinBox" ) ) {
+ QtxDoubleSpinBox* sb = ( QtxDoubleSpinBox* )( *anIt );
+ aResult.append(sb->text());
+ }
+ }
+ return aResult;
+}
+
QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
{
QString valueStr = "";
return false;
}
+bool SMESHGUI_GenericHypothesisCreator::checkParams( QString& msg ) const
+{
+ bool ok = true;
+ ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
+ for( ; anIt!=aLast; anIt++ )
+ {
+ if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
+ {
+ SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
+ ok = sb->isValid( msg, true ) && ok;
+ }
+ else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
+ {
+ SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
+ ok = sb->isValid( msg, true ) && ok;
+ }
+ }
+ return ok;
+}
+
void SMESHGUI_GenericHypothesisCreator::onReject()
{
}
void SMESHGUI_HypothesisDlg::accept()
{
- if ( myCreator && !myCreator->checkParams() )
+ QString msg;
+ if ( myCreator && !myCreator->checkParams( msg ) )
+ {
+ QString str( tr( "SMESH_INCORRECT_INPUT" ) );
+ if ( !msg.isEmpty() )
+ str += "\n" + msg;
+ SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
return;
+ }
QtxDialog::accept();
}
const QString&, QWidget* );
void setInitParamsHypothesis(SMESH::SMESH_Hypothesis_ptr);
- virtual bool checkParams() const = 0;
+ virtual bool checkParams( QString& ) const;
virtual void onReject();
virtual QString helpPage() const;
bool isCreation() const;
protected:
- typedef struct
+ struct StdParam
{
QString myName;
QVariant myValue;
-
- } StdParam;
+ bool isVariable;
+ StdParam(){
+ isVariable = false;
+ }
+ };
typedef QList<StdParam> ListOfStdParams;
typedef QList<QWidget*> ListOfWidgets;
virtual QString storeParams() const = 0;
virtual bool stdParams( ListOfStdParams& ) const;
bool getStdParamFromDlg( ListOfStdParams& ) const;
+ virtual QStringList getVariablesFromDlg() const;
static QString stdParamValues( const ListOfStdParams& );
virtual void attuneStdWidget( QWidget*, const int ) const;
virtual QWidget* getCustomWidget( const StdParam&,
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;
}
}
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;
*/
//================================================================================
-bool SMESHGUI_MakeNodeAtPointOp::isValid()
+bool SMESHGUI_MakeNodeAtPointOp::isValid( QString& msg )
{
bool ok = true;
-
if ( myMeshActor &&
myDlg->myMoveRBtn->isDown() &&
!myDlg->myAutoSearchChkBox->isChecked() )
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;
}
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());
virtual void activateSelection();
- bool isValid();
+ bool isValid( QString& );
protected slots:
virtual bool onApply();
#include <LightApp_SelectionMgr.h>
#include <SalomeApp_Tools.h>
#include <LightApp_Application.h>
+#include <SalomeApp_IntSpinBox.h>
#include <SALOME_ListIO.hxx>
#include <QRadioButton>
#include <QCheckBox>
#include <QButtonGroup>
-#include <QSpinBox>
#include <QList>
#include <QDir>
#include <QFileDialog>
mySelEdit[ Ids ] = new QLineEdit( myRefineGrp );
QLabel* aNodeLbl = new QLabel( tr( "NODE_1" ), myRefineGrp );
- myNode1 = new QSpinBox( myRefineGrp );
+ myNode1 = new SalomeApp_IntSpinBox( myRefineGrp );
myNode2Lbl = new QLabel( tr( "NODE_2" ), myRefineGrp );
- myNode2 = new QSpinBox( myRefineGrp );
+ myNode2 = new SalomeApp_IntSpinBox( myRefineGrp );
myRefineGrpLayout->addWidget( mySelLbl[ Ids ], 0, 0 );
myRefineGrpLayout->addWidget( mySelBtn[ Ids ], 0, 1 );
//=======================================================================
bool SMESHGUI_MeshPatternDlg::isValid (const bool theMess)
{
+ if (isRefine())
+ {
+ QString msg;
+ bool ok = true;
+ ok = myNode1->isValid( msg, theMess ) && ok;
+ if (myType == Type_3d)
+ ok = myNode2->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;
+ }
+ }
+
QList<int> ids;
if ((isRefine() &&
(myMesh->_is_nil() || !getIds(ids) || getNode(false) < 0 ||
? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked())
: myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true));
+ QStringList aParameters;
+ aParameters << myNode1->text();
+ if(myType == Type_3d )
+ aParameters << myNode2->text();
+ myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
+
} else { // Applying a pattern to geometrical object
if (myType == Type_2d)
myPattern->ApplyToFace(myGeomObj[Object], myGeomObj[Vertex1], myReverseChk->isChecked());
void SMESHGUI_MeshPatternDlg::onNodeChanged (int value)
{
if (myType == Type_3d) {
- QSpinBox* first = (QSpinBox*)sender();
- QSpinBox* second = first == myNode1 ? myNode2 : myNode1;
+ SalomeApp_IntSpinBox* first = (SalomeApp_IntSpinBox*)sender();
+ SalomeApp_IntSpinBox* second = first == myNode1 ? myNode2 : myNode1;
int secondVal = second->value();
if (secondVal == value) {
secondVal = value == second->maximum() ? second->minimum() : value + 1;
class QCheckBox;
class QButtonGroup;
class QLabel;
-class QSpinBox;
+class SalomeApp_IntSpinBox;
class vtkUnstructuredGrid;
class SALOME_Actor;
class SVTK_Selector;
QCheckBox* myRefine;
QFrame* myRefineGrp;
- QSpinBox* myNode1;
- QSpinBox* myNode2;
+ SalomeApp_IntSpinBox* myNode1;
+ SalomeApp_IntSpinBox* myNode2;
QLabel* myNode2Lbl;
QFrame* myGeomGrp;
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;
}
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 (...) {
}
// 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)));
{
}
+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;
}
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();
virtual ~SMESHGUI_UnionOfTrianglesDlg();
protected:
+ virtual bool isValid( const bool );
virtual bool process( SMESH::SMESH_MeshEditor_ptr, const SMESH::long_array& );
private:
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() ) ) {
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
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;
+}
void hideEvent ( QHideEvent* );
void keyPressEvent( QKeyEvent* );
+ bool isValid();
+
QGroupBox* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupCoordinates;
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SalomeApp_Application.h>
+#include <SalomeApp_IntSpinBox.h>
#include <SVTK_ViewWindow.h>
#include <SVTK_Selector.h>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
-#include <QSpinBox>
#include <QKeyEvent>
#include <QMenu>
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
myVectorDefinition(NONE_SELECT),
- myFilterDlg( 0 )
+ myFilterDlg( 0 ),
+ mySelectedObject(SMESH::SMESH_IDSource::_nil())
{
mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox);
TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox);
- SpinBox_NbSteps = new QSpinBox(GroupAngleBox);
+ SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupAngleBox);
GroupAngleLayout->addWidget(RadioButton3, 0, 0);
GroupAngleLayout->addWidget(RadioButton4, 0, 1);
connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(CheckBoxPreview, SIGNAL(toggled(bool)), this, SLOT(onDisplaySimulation(bool)));
+ connect(SpinBox_Angle, SIGNAL(textChanged(const QString&)), this, SLOT(onAngleTextChange(const QString&)));
+
ConstructorsClicked(0);
SelectionIntoArgument();
}
// function : ClickOnApply()
// purpose :
//=================================================================================
-void SMESHGUI_RevolutionDlg::ClickOnApply()
+bool SMESHGUI_RevolutionDlg::ClickOnApply()
{
if (mySMESHGUI->isActiveStudyLocked())
- return;
+ return false;
+
+ if (!isValid())
+ return false;
if (myNbOkElements && IsAxisOk()) {
QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
if ( GroupAngle->checkedId() == 1 )
anAngle = anAngle/aNbSteps;
+ 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();
+ aParameters << SpinBox_NbSteps->text();
+ aParameters << SpinBox_Tolerance->text();
+
try {
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
- if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
- SMESH::ListOfGroups_var groups =
- aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
- anAngle, aNbSteps, aTolerance);
- else
- aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
+ if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
+ if( CheckBoxMesh->isChecked() ) {
+ if( GetConstructorId() == 0 )
+ SMESH::ListOfGroups_var groups =
+ aMeshEditor->RotationSweepObject1DMakeGroups(mySelectedObject, anAxis,
+ anAngle, aNbSteps, aTolerance);
+ else
+ SMESH::ListOfGroups_var groups =
+ aMeshEditor->RotationSweepObject2DMakeGroups(mySelectedObject, anAxis,
+ anAngle, aNbSteps, aTolerance);
+ }
+ else
+ SMESH::ListOfGroups_var groups =
+ aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
+ anAngle, aNbSteps, aTolerance);
+ }
+ else {
+ if( CheckBoxMesh->isChecked() ) {
+ if( GetConstructorId() == 0 )
+ aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
+ else
+ aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
+ }
+ else
+ aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
+ }
+
+ myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
} catch (...) {
}
mySMESHGUI->updateObjBrowser(true); // new groups may appear
Init(false);
ConstructorsClicked(GetConstructorId());
+ mySelectedObject = SMESH::SMESH_IDSource::_nil();
SelectionIntoArgument();
}
+
+ return true;
}
//=================================================================================
//=================================================================================
void SMESHGUI_RevolutionDlg::ClickOnOk()
{
- ClickOnApply();
- ClickOnCancel();
+ if( ClickOnApply() )
+ ClickOnCancel();
}
//=================================================================================
}
}
+//=======================================================================
+// function : onAngleTextChange()
+// purpose :
+//=======================================================================
+void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText)
+{
+ bool isNumber;
+ SpinBox_Angle->text().toDouble( &isNumber );
+ if( !isNumber )
+ RadioButton3->setChecked( true );
+ RadioButton4->setEnabled( isNumber );
+}
+
//=======================================================================
// function : onTextChange()
// purpose :
}
if (CheckBoxMesh->isChecked()) {
- int aConstructorId = GetConstructorId();
-
SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
- if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
- // get IDs from mesh
- SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
- if (!aSMDSMesh)
- return;
-
- if (aConstructorId == 0) {
- SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
-
- while (anIter->more()) {
- const SMDS_MeshEdge * edge = anIter->next();
- if (edge) {
- myElementsId += QString(" %1").arg(edge->GetID());
- aNbUnits++;
- }
- }
- } else if (aConstructorId == 1) {
- SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
- while (anIter->more()) {
- const SMDS_MeshFace * face = anIter->next();
- if (face) {
- myElementsId += QString(" %1").arg(face->GetID());
- aNbUnits++;
- }
- }
- }
- } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
- // get submesh
- SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
-
- // get IDs from submesh
- SMESH::long_array_var anElementsIds = new SMESH::long_array;
- if (aConstructorId == 0)
- anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE);
- else if (aConstructorId == 1)
- anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE);
-
- for (int i = 0; i < anElementsIds->length(); i++)
- myElementsId += QString(" %1").arg(anElementsIds[i]);
- aNbUnits = anElementsIds->length();
- } else { // GROUP
- // get smesh group
- SMESH::SMESH_GroupBase_var aGroup =
- SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
- if (aGroup->_is_nil())
- return;
-
- if ((aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) ||
- (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE))
- return;
-
- // get IDs from smesh group
- SMESH::long_array_var anElementsIds = new SMESH::long_array;
- anElementsIds = aGroup->GetListOfID();
- for (int i = 0; i < anElementsIds->length(); i++) {
- myElementsId += QString(" %1").arg(anElementsIds[i]);
- }
- aNbUnits = anElementsIds->length();
- }
+ if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
+ mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
+ else
+ return;
} else {
aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
myElementsId = aString;
+ if (aNbUnits < 1)
+ return;
}
-
- if (aNbUnits < 1)
- return;
-
myNbOkElements = true;
} else {
try {
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
- aMeshEditor->RotationSweep(anElementsId.inout(),
- anAxis,
- anAngle,
- aNbSteps,
- aTolerance);
+ if( CheckBoxMesh->isChecked() ) {
+ if( GetConstructorId() == 0 )
+ aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis,
+ anAngle, aNbSteps, aTolerance);
+ else
+ aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis,
+ anAngle, aNbSteps, aTolerance);
+ }
+ else
+ aMeshEditor->RotationSweep(anElementsId.inout(),
+ anAxis,
+ anAngle,
+ aNbSteps,
+ aTolerance);
SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
mySimulation->SetData(aMeshPreviewStruct._retn());
} catch (...) {}
myFilterDlg->show();
}
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool SMESHGUI_RevolutionDlg::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;
+ 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;
+ ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
+ ok = SpinBox_Tolerance->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;
+}
class QPushButton;
class QRadioButton;
class QCheckBox;
-class QSpinBox;
+class SalomeApp_IntSpinBox;
class SMESHGUI_IdValidator;
class SMESHGUI_SpinBox;
class SMESHGUI;
int GetConstructorId();
bool IsAxisOk();
+ bool isValid();
+
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator;
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
QWidget* myEditCurrentArgument; /* Current argument */
SVTK_Selector* mySelector;
+ SMESH::SMESH_IDSource_var mySelectedObject;
+
bool myBusy;
SMESH::SMESH_Mesh_var myMesh;
SMESH_Actor* myActor;
QLabel* TextLabelAngle;
SMESHGUI_SpinBox* SpinBox_Angle;
QLabel* TextLabelNbSteps;
- QSpinBox* SpinBox_NbSteps;
+ SalomeApp_IntSpinBox* SpinBox_NbSteps;
QLabel* TextLabelTolerance;
SMESHGUI_SpinBox* SpinBox_Tolerance;
void ConstructorsClicked( int );
void ClickOnOk();
void ClickOnCancel();
- void ClickOnApply();
+ bool ClickOnApply();
void ClickOnHelp();
void SetEditCurrentArgument();
void SelectionIntoArgument();
void DeactivateActiveDialog();
void ActivateThisDialog();
void onTextChange( const QString& );
+ void onAngleTextChange( const QString& );
void onSelectMesh( bool );
void onVectorChanged();
void toDisplaySimulation();
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
- myFilterDlg(0)
+ myFilterDlg(0),
+ mySelectedObject(SMESH::SMESH_IDSource::_nil())
{
QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_MESH_ROTATION")));
QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
// 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);
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 {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
switch ( actionButton ) {
case MOVE_ELEMS_BUTTON:
- aMeshEditor->Rotate(anElementsId, anAxis, anAngle, false);
+ if(CheckBoxMesh->isChecked())
+ aMeshEditor->RotateObject(mySelectedObject, anAxis, anAngle, false);
+ else
+ aMeshEditor->Rotate(anElementsId, anAxis, anAngle, false);
+ if( !myMesh->_is_nil())
+ myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
break;
case COPY_ELEMS_BUTTON:
- if ( makeGroups )
- SMESH::ListOfGroups_var groups =
- aMeshEditor->RotateMakeGroups(anElementsId, anAxis, anAngle);
- else
- aMeshEditor->Rotate(anElementsId, anAxis, anAngle, true);
+ if ( makeGroups ) {
+ SMESH::ListOfGroups_var groups;
+ if(CheckBoxMesh->isChecked())
+ groups = aMeshEditor->RotateObjectMakeGroups(mySelectedObject, anAxis, anAngle);
+ else
+ groups = aMeshEditor->RotateMakeGroups(anElementsId, anAxis, anAngle);
+ }
+ else {
+ if(CheckBoxMesh->isChecked())
+ aMeshEditor->RotateObject(mySelectedObject, anAxis, anAngle, true);
+ 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());
+ SMESH::SMESH_Mesh_var mesh;
+ if(CheckBoxMesh->isChecked())
+ mesh = aMeshEditor->RotateObjectMakeMesh(mySelectedObject, anAxis, anAngle, makeGroups,
+ LineEditNewMesh->text().toLatin1().data());
+ else
+ mesh = aMeshEditor->RotateMakeMesh(anElementsId, anAxis, anAngle, makeGroups,
+ LineEditNewMesh->text().toLatin1().data());
+ if( !mesh->_is_nil())
+ mesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
}
} catch (...) {
}
actionButton == MAKE_MESH_BUTTON )
mySMESHGUI->updateObjBrowser(true); // new groups may appear
Init(false);
+ mySelectedObject = SMESH::SMESH_IDSource::_nil();
SelectionIntoArgument();
}
+
+ return true;
}
//=================================================================================
//=================================================================================
void SMESHGUI_RotationDlg::ClickOnOk()
{
- ClickOnApply();
- ClickOnCancel();
+ if( ClickOnApply() )
+ ClickOnCancel();
}
//=================================================================================
if (CheckBoxMesh->isChecked()) {
SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
- if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
+ if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil()) { //MESH
+ mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
+ }
+ else
+ return;
// get IDs from mesh
- SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
- if (!aSMDSMesh)
+ /*
+ SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
+ if (!aSMDSMesh)
return;
- for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
+ for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
if (e) {
myElementsId += QString(" %1").arg(i);
}
}
} else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
- // get submesh
+ // get submesh
SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
-
+
// get IDs from submesh
SMESH::long_array_var anElementsIds = new SMESH::long_array;
anElementsIds = aSubMesh->GetElementsId();
for (int i = 0; i < anElementsIds->length(); i++) {
- myElementsId += QString(" %1").arg(anElementsIds[i]);
- }
+ myElementsId += QString(" %1").arg(anElementsIds[i]);
+ }
aNbUnits = anElementsIds->length();
} else { // GROUP
// get smesh group
SMESH::SMESH_GroupBase_var aGroup =
- SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
+ SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
if (aGroup->_is_nil())
- return;
+ return;
- // get IDs from smesh group
+ // get IDs from smesh group
SMESH::long_array_var anElementsIds = new SMESH::long_array;
anElementsIds = aGroup->GetListOfID();
for (int i = 0; i < anElementsIds->length(); i++) {
- myElementsId += QString(" %1").arg(anElementsIds[i]);
- }
+ myElementsId += QString(" %1").arg(anElementsIds[i]);
+ }
aNbUnits = anElementsIds->length();
- }
- } else {
+ }
+ */
+ } else {
aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
myElementsId = aString;
- }
-
- if (aNbUnits < 1)
- return;
+ if (aNbUnits < 1)
+ return;
+ }
myNbOkElements = true;
+
} else {
aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
if (aNbUnits != 1)
}
break;
}
+
}
myEditCurrentArgument->setFocus();
myFilterDlg->show();
}
+
+//=================================================================================
+// 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;
+}
bool IsAxisOk();
void setNewMeshName();
+ bool isValid();
+
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator;
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
SMESH::SMESH_Mesh_var myMesh;
SMESH_Actor* myActor;
SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter;
+ SMESH::SMESH_IDSource_var mySelectedObject;
QGroupBox* GroupConstructors;
QRadioButton* RadioButton1;
private slots:
void ClickOnOk();
void ClickOnCancel();
- void ClickOnApply();
+ bool ClickOnApply();
void ClickOnHelp();
void SetEditCurrentArgument();
void SelectionIntoArgument();
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
+#include <SalomeApp_IntSpinBox.h>
+
#include <SVTK_ViewModel.h>
#include <SVTK_Selector.h>
#include <SVTK_ViewWindow.h>
#include <QRadioButton>
#include <QComboBox>
#include <QCheckBox>
-#include <QSpinBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
- myFilterDlg(0)
+ myFilterDlg(0),
+ mySelectedObject(SMESH::SMESH_IDSource::_nil())
{
QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_SMOOTHING")));
QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
// 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);
// function : ClickOnApply()
// purpose : Called when user presses <Apply> 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);
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;
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
- if ( CheckBoxParametric->isChecked() )
- aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(),
- anIterationLimit, aMaxAspectRatio, aMethod);
- else
- aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(),
- anIterationLimit, aMaxAspectRatio, aMethod);
+ if ( CheckBoxParametric->isChecked() ) {
+ if(CheckBoxMesh->isChecked())
+ aResult = aMeshEditor->SmoothParametricObject(mySelectedObject, aNodesId.inout(),
+ anIterationLimit, aMaxAspectRatio, aMethod);
+ else
+ aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(),
+ anIterationLimit, aMaxAspectRatio, aMethod);
+ }
+ else {
+ if(CheckBoxMesh->isChecked())
+ aResult = aMeshEditor->SmoothObject(mySelectedObject, aNodesId.inout(),
+ anIterationLimit, aMaxAspectRatio, aMethod);
+ else
+ aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(),
+ anIterationLimit, aMaxAspectRatio, aMethod);
+ }
+
+ myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
+
} catch (...) {
}
mySelectionMgr->setSelectedObjects(aList, false);
SMESH::UpdateView();
Init();
+
+ mySelectedObject = SMESH::SMESH_IDSource::_nil();
}
}
+
+ return true;
}
//=================================================================================
//=================================================================================
void SMESHGUI_SmoothingDlg::ClickOnOk()
{
- ClickOnApply();
- ClickOnCancel();
+ if( ClickOnApply() )
+ ClickOnCancel();
}
//=================================================================================
if (CheckBoxMesh->isChecked()) {
SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
- if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
- // get IDs from mesh
- SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
- if (!aSMDSMesh)
- return;
-
- for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ ) {
- const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
- if (e) {
- myElementsId += QString(" %1").arg(i);
- aNbUnits++;
- }
- }
- } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
- // get submesh
- SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
-
- // get IDs from submesh
- SMESH::long_array_var anElementsIds = new SMESH::long_array;
- anElementsIds = aSubMesh->GetElementsId();
- for (int i = 0; i < anElementsIds->length(); i++) {
- myElementsId += QString(" %1").arg(anElementsIds[i]);
- }
- aNbUnits = anElementsIds->length();
- } else { // GROUP
- // get smesh group
- SMESH::SMESH_GroupBase_var aGroup =
- SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
- if (aGroup->_is_nil())
- return;
-
- // get IDs from smesh group
- SMESH::long_array_var anElementsIds = new SMESH::long_array;
- anElementsIds = aGroup->GetListOfID();
- for (int i = 0; i < anElementsIds->length(); i++) {
- myElementsId += QString(" %1").arg(anElementsIds[i]);
- }
- aNbUnits = anElementsIds->length();
- }
+ if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
+ mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
+ else
+ return;
} else {
aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
myElementsId = aString;
+ if (aNbUnits < 1)
+ return;
}
} else if (myEditCurrentArgument == LineEditNodes && !myMesh->_is_nil() && myActor) {
myNbOkNodes = 0;
} else {
}
- if (aNbUnits < 1)
- return;
-
myBusy = true;
myEditCurrentArgument->setText(aString);
myEditCurrentArgument->repaint();
{
setFilters( false );
}
+
+//=================================================================================
+// 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;
+}
class QRadioButton;
class QComboBox;
class QCheckBox;
-class QSpinBox;
class SMESHGUI;
+class SalomeApp_IntSpinBox;
class SMESHGUI_IdValidator;
class SMESHGUI_SpinBox;
class SMESHGUI_FilterDlg;
void keyPressEvent( QKeyEvent* );
void setFilters( const bool theIsElem );
+ bool isValid();
+
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator;
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
SVTK_Selector* mySelector;
+ SMESH::SMESH_IDSource_var mySelectedObject;
+
bool myBusy;
SMESH::SMESH_Mesh_var myMesh;
SMESH_Actor* myActor;
QLabel* TextLabelMethod;
QComboBox* ComboBoxMethod;
QLabel* TextLabelLimit;
- QSpinBox* SpinBox_IterationLimit;
+ SalomeApp_IntSpinBox* SpinBox_IterationLimit;
QLabel* TextLabelAspectRatio;
SMESHGUI_SpinBox* SpinBox_AspectRatio;
QCheckBox* CheckBoxParametric;
private slots:
void ClickOnOk();
void ClickOnCancel();
- void ClickOnApply();
+ bool ClickOnApply();
void ClickOnHelp();
void SetEditCurrentArgument();
void SelectionIntoArgument();
// purpose : constructor of specific widget accepting floats in double precision.
//=================================================================================
SMESHGUI_SpinBox::SMESHGUI_SpinBox( QWidget* parent )
- : QtxDoubleSpinBox( parent )
+ : SalomeApp_DoubleSpinBox( parent )
{
}
//=================================================================================
QLineEdit* SMESHGUI_SpinBox::editor() const
{
- return QtxDoubleSpinBox::lineEdit();
+ return SalomeApp_DoubleSpinBox::lineEdit();
}
//=================================================================================
setDecimals(32);
setRange(min, max);
setSingleStep( step );
+ setDefaultValue( min );
}
#include "SMESH_SMESHGUI.hxx"
// SALOME GUI includes
-#include <QtxDoubleSpinBox.h>
+#include <SalomeApp_DoubleSpinBox.h>
#define COORD_MIN -1e+15
#define COORD_MAX +1e+15
// class : SMESHGUI_SpinBox
// purpose : Derivated from QtxDoubleSpinBox class
//=================================================================================
-class SMESHGUI_EXPORT SMESHGUI_SpinBox : public QtxDoubleSpinBox
+class SMESHGUI_EXPORT SMESHGUI_SpinBox : public SalomeApp_DoubleSpinBox
{
Q_OBJECT
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
- myFilterDlg(0)
+ myFilterDlg(0),
+ mySelectedObject(SMESH::SMESH_IDSource::_nil())
{
QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_POINT")));
QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_AXIS")));
// 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);
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_var aMeshEditor = myMesh->GetMeshEditor();
switch ( actionButton ) {
- case MOVE_ELEMS_BUTTON:
- aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, false );
+ case MOVE_ELEMS_BUTTON: {
+ if(CheckBoxMesh->isChecked())
+ aMeshEditor->MirrorObject(mySelectedObject, aMirror, aMirrorType, false );
+ else
+ aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, false );
+
+ if( !myMesh->_is_nil())
+ myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
+ break;
+ }
+ case COPY_ELEMS_BUTTON: {
+ SMESH::ListOfGroups_var groups;
+ if ( makeGroups ) {
+ if(CheckBoxMesh->isChecked())
+ groups = aMeshEditor->MirrorObjectMakeGroups(mySelectedObject, aMirror, aMirrorType);
+ else
+ groups = aMeshEditor->MirrorMakeGroups(anElementsId, aMirror, aMirrorType);
+ }
+ else {
+ if(CheckBoxMesh->isChecked())
+ aMeshEditor->MirrorObject(mySelectedObject, aMirror, aMirrorType, true);
+ else
+ aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, true);
+ }
+ if( !myMesh->_is_nil())
+ myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
break;
- case COPY_ELEMS_BUTTON:
- if ( makeGroups )
- SMESH::ListOfGroups_var groups =
- aMeshEditor->MirrorMakeGroups(anElementsId, aMirror, aMirrorType);
+ }
+ case MAKE_MESH_BUTTON: {
+ SMESH::SMESH_Mesh_var mesh;
+ if(CheckBoxMesh->isChecked())
+ mesh = aMeshEditor->MirrorObjectMakeMesh(mySelectedObject, aMirror, aMirrorType, makeGroups,
+ LineEditNewMesh->text().toLatin1().data());
else
- aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, true);
+ mesh = aMeshEditor->MirrorMakeMesh(anElementsId, aMirror, aMirrorType, makeGroups,
+ LineEditNewMesh->text().toLatin1().data());
+ if( !mesh->_is_nil())
+ mesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
break;
- case MAKE_MESH_BUTTON:
- SMESH::SMESH_Mesh_var mesh =
- aMeshEditor->MirrorMakeMesh(anElementsId, aMirror, aMirrorType, makeGroups,
- LineEditNewMesh->text().toLatin1().data());
+ }
}
} catch (...) {
}
-
+
SMESH::UpdateView();
if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ||
actionButton == MAKE_MESH_BUTTON )
mySMESHGUI->updateObjBrowser(true); // new groups may appear
Init(false);
ConstructorsClicked(GetConstructorId());
+ mySelectedObject = SMESH::SMESH_IDSource::_nil();
SelectionIntoArgument();
}
+ return true;
}
//=================================================================================
//=================================================================================
void SMESHGUI_SymmetryDlg::ClickOnOk()
{
- ClickOnApply();
- ClickOnCancel();
+ if( ClickOnApply() )
+ ClickOnCancel();
}
//=================================================================================
if (CheckBoxMesh->isChecked()) {
SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
- if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
- // get IDs from mesh
+ if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil()) { //MESH
+ mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
+ }
+ else
+ return;
+ // get IDs from mesh
+ /*
SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
if (!aSMDSMesh)
return;
aNbUnits++;
}
}
+
} else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
// get submesh
SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
// get IDs from submesh
+ /*
SMESH::long_array_var anElementsIds = new SMESH::long_array;
anElementsIds = aSubMesh->GetElementsId();
for (int i = 0; i < anElementsIds->length(); i++) {
myElementsId += QString(" %1").arg(anElementsIds[i]);
}
aNbUnits = anElementsIds->length();
+
} else { // GROUP
// get smesh group
SMESH::SMESH_GroupBase_var aGroup =
}
aNbUnits = anElementsIds->length();
}
+ */
} else {
aNbUnits = SMESH::GetNameOfSelectedElements( mySelector, IO, aString);
myElementsId = aString;
+ if (aNbUnits < 1)
+ return;
}
-
- if (aNbUnits < 1)
- return;
-
+
myNbOkElements = true;
} else {
aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
myFilterDlg->show();
}
+
+//=================================================================================
+// 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;
+}
bool IsMirrorOk();
void setNewMeshName();
+ bool isValid();
+
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator;
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
QWidget* myEditCurrentArgument; /* Current LineEdit */
+ SMESH::SMESH_IDSource_var mySelectedObject;
+
bool myBusy;
SMESH::SMESH_Mesh_var myMesh;
SMESH_Actor* myActor;
void ConstructorsClicked( int );
void ClickOnOk();
void ClickOnCancel();
- void ClickOnApply();
+ bool ClickOnApply();
void ClickOnHelp();
void SetEditCurrentArgument();
void SelectionIntoArgument();
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
- myFilterDlg(0)
+ myFilterDlg(0),
+ mySelectedObject(SMESH::SMESH_IDSource::_nil())
{
QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_POINTS")));
QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_VECTOR")));
// function : ClickOnApply()
// purpose :
//=================================================================================
-void SMESHGUI_TranslationDlg::ClickOnApply()
+bool SMESHGUI_TranslationDlg::ClickOnApply()
{
if (mySMESHGUI->isActiveStudyLocked())
- return;
+ return false;
+
+ if( !isValid() )
+ return false;
if (myNbOkElements) {
QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
aVector.PS.z = SpinBox1_3->GetValue();
}
+ QStringList aParameters;
+ aParameters << SpinBox1_1->text();
+ if (GetConstructorId() == 0)
+ aParameters << SpinBox2_1->text();
+ aParameters << SpinBox1_2->text();
+ if (GetConstructorId() == 0)
+ aParameters << SpinBox2_2->text();
+ aParameters << SpinBox1_3->text();
+ if (GetConstructorId() == 0)
+ aParameters << SpinBox2_3->text();
+
int actionButton = ActionGroup->checkedId();
bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
try {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
switch ( actionButton ) {
case MOVE_ELEMS_BUTTON:
- aMeshEditor->Translate(anElementsId, aVector, false);
+ if(CheckBoxMesh->isChecked())
+ aMeshEditor->TranslateObject(mySelectedObject, aVector, false);
+ else
+ aMeshEditor->Translate(anElementsId, aVector, false);
+ if( !myMesh->_is_nil())
+ myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
break;
case COPY_ELEMS_BUTTON:
- if ( makeGroups )
- SMESH::ListOfGroups_var groups =
- aMeshEditor->TranslateMakeGroups(anElementsId, aVector);
- else
- aMeshEditor->Translate(anElementsId, aVector, true);
+ if ( makeGroups ) {
+ SMESH::ListOfGroups_var groups;
+ if(CheckBoxMesh->isChecked())
+ groups = aMeshEditor->TranslateObjectMakeGroups(mySelectedObject,aVector);
+ else
+ groups = aMeshEditor->TranslateMakeGroups(anElementsId, aVector);
+ }
+ else {
+ if(CheckBoxMesh->isChecked())
+ aMeshEditor->TranslateObject(mySelectedObject, aVector, true);
+ else
+ aMeshEditor->Translate(anElementsId, aVector, true);
+ }
+ if( !myMesh->_is_nil())
+ myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
break;
case MAKE_MESH_BUTTON:
- SMESH::SMESH_Mesh_var mesh =
- aMeshEditor->TranslateMakeMesh(anElementsId, aVector, makeGroups,
- LineEditNewMesh->text().toLatin1().data());
+ SMESH::SMESH_Mesh_var mesh;
+ if(CheckBoxMesh->isChecked())
+ mesh = aMeshEditor->TranslateObjectMakeMesh(mySelectedObject, aVector, makeGroups,
+ LineEditNewMesh->text().toLatin1().data());
+ else
+ mesh = aMeshEditor->TranslateMakeMesh(anElementsId, aVector, makeGroups,
+ LineEditNewMesh->text().toLatin1().data());
+ if( !mesh->_is_nil())
+ mesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
}
} catch (...) {
}
-
+
SMESH::UpdateView();
if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ||
actionButton == MAKE_MESH_BUTTON )
mySMESHGUI->updateObjBrowser(true); // new groups may appear
Init(false);
ConstructorsClicked(GetConstructorId());
+ mySelectedObject = SMESH::SMESH_IDSource::_nil();
SelectionIntoArgument();
}
+
+ return true;
}
//=================================================================================
//=================================================================================
void SMESHGUI_TranslationDlg::ClickOnOk()
{
- ClickOnApply();
- ClickOnCancel();
+ if( ClickOnApply() )
+ ClickOnCancel();
}
//=================================================================================
if (CheckBoxMesh->isChecked()) {
SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString );
- if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
+ if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil()) { //MESH, SUBMESH, OR GROUP
+ mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
+ }
+ else
+ return;
// get IDs from mesh
+ /*
SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
if (!aSMDSMesh)
return;
}
aNbUnits = anElementsIds->length();
}
+ */
} else {
aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
myElementsId = aString;
+ if (aNbUnits < 1)
+ return;
}
- if (aNbUnits < 1)
- return;
-
myNbOkElements = true;
} else {
aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
myFilterDlg->show();
}
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool SMESHGUI_TranslationDlg::isValid()
+{
+ bool ok = true;
+ QString msg;
+
+ ok = SpinBox1_1->isValid( msg, true ) && ok;
+ ok = SpinBox1_2->isValid( msg, true ) && ok;
+ ok = SpinBox1_3->isValid( msg, true ) && ok;
+ if (GetConstructorId() == 0) {
+ ok = SpinBox2_1->isValid( msg, true ) && ok;
+ ok = SpinBox2_2->isValid( msg, true ) && ok;
+ ok = SpinBox2_3->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;
+}
int GetConstructorId();
void setNewMeshName();
+ bool isValid();
+
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator;
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
SMESH_Actor* myActor;
SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter;
+ SMESH::SMESH_IDSource_var mySelectedObject;
+
QGroupBox* ConstructorsBox;
QButtonGroup* GroupConstructors;
QRadioButton* RadioButton1;
void ConstructorsClicked( int );
void ClickOnOk();
void ClickOnCancel();
- void ClickOnApply();
+ bool ClickOnApply();
void ClickOnHelp();
void SetEditCurrentArgument();
void SelectionIntoArgument();
<source>SMESH_ID_NODES</source>
<translation>Id Nodes</translation>
</message>
+ <message>
+ <source>SMESH_INCORRECT_INPUT</source>
+ <translation>Incorrect input data!</translation>
+ </message>
<message>
<source>SMESH_INFORMATION</source>
<translation>Information</translation>
SMESH_MEDSupport_i.hxx \
SMESH_Pattern_i.hxx \
SMESH_2smeshpy.hxx \
+ SMESH_NoteBook.hxx \
SMESH.hxx
# Scripts to be installed.
SMESH_Filter_i.cxx \
SMESH_Group_i.cxx \
SMESH_Pattern_i.cxx \
- SMESH_2smeshpy.cxx
+ SMESH_2smeshpy.cxx \
+ SMESH_NoteBook.cxx
# Executables targets
bin_PROGRAMS = SMESHEngine
#include "utilities.h"
#include "SMESH_PythonDump.hxx"
+#include "SMESH_NoteBook.hxx"
#include "Resource_DataMapOfAsciiStringAsciiString.hxx"
#include "SMESH_Gen_i.hxx"
theGen = new _pyGen( theEntry2AccessorMethod, theObjectNames );
// split theScript into separate commands
+
+ SMESH_NoteBook * aNoteBook = new SMESH_NoteBook();
+
int from = 1, end = theScript.Length(), to;
while ( from < end && ( to = theScript.Location( "\n", from, end )))
+ {
+ if ( to != from )
+ // cut out and store a command
+ aNoteBook->AddCommand( theScript.SubString( from, to - 1 ));
+ from = to + 1;
+ }
+
+ aNoteBook->ReplaceVariables();
+
+ TCollection_AsciiString aNoteScript = aNoteBook->GetResultScript();
+ delete aNoteBook;
+ aNoteBook = 0;
+
+ // split theScript into separate commands
+ from = 1, end = aNoteScript.Length();
+ while ( from < end && ( to = aNoteScript.Location( "\n", from, end )))
{
if ( to != from )
// cut out and store a command
- theGen->AddCommand( theScript.SubString( from, to - 1 ));
+ theGen->AddCommand( aNoteScript.SubString( from, to - 1 ));
from = to + 1;
}
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",
- "ExtrusionSweepObject","ExtrusionSweepObject1D","ExtrusionSweepObject2D","Mirror",
- "MirrorObject","Translate","TranslateObject","Rotate","RotateObject",
+ "RotationSweep","RotationSweepObject","RotationSweepObject1D","RotationSweepObject2D",
+ "ExtrusionSweep","AdvancedExtrusion","ExtrusionSweepObject","ExtrusionSweepObject1D","ExtrusionSweepObject2D",
+ "ExtrusionAlongPath","ExtrusionAlongPathObject","ExtrusionAlongPathObject1D","ExtrusionAlongPathObject2D",
+ "Mirror","MirrorObject","Translate","TranslateObject","Rotate","RotateObject",
"FindCoincidentNodes","FindCoincidentNodesOnPart","MergeNodes","FindEqualElements",
"MergeElements","MergeEqualElements","SewFreeBorders","SewConformFreeBorders",
"SewBorderToSide","SewSideElements","ChangeElemNodes","GetLastCreatedNodes",
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();
if ( pos < 1 ) // no index-th arg exist, append inexistent args
{
// find a closing parenthesis
- if ( int lastArgInd = GetNbArgs() ) {
+ if ( GetNbArgs() != 0 && index <= GetNbArgs() ) {
+ int lastArgInd = GetNbArgs();
pos = GetBegPos( ARG1_IND + lastArgInd - 1 ) + GetArg( lastArgInd ).Length();
while ( pos > 0 && pos <= Length() && myString.Value( pos ) != ')' )
++pos;
* \brief Find SObject for an algo
*/
SALOMEDS::SObject_ptr GetAlgoSO(const ::SMESH_Algo* algo);
+
+ void UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters);
+ char* GetParameters(CORBA::Object_ptr theObject);
+ char* ParseParameters(const char* theParameters);
+
private:
// Create hypothesis of given type
#ifdef _DEBUG_
static int MYDEBUG = 0;
+static int VARIABLE_DEBUG = 0;
#else
static int MYDEBUG = 0;
+static int VARIABLE_DEBUG = 0;
#endif
//=============================================================================
return true;
}
+//=======================================================================
+//function : UpdateParameters
+//purpose :
+//=======================================================================
+void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters)
+{
+
+ if(VARIABLE_DEBUG)
+ cout<<"UpdateParameters : "<<theParameters<<endl;
+ SALOMEDS::Study_ptr aStudy = GetCurrentStudy();
+ if(aStudy->_is_nil() || CORBA::is_nil(theObject))
+ return;
+
+ SALOMEDS::SObject_var aSObj = ObjectToSObject(aStudy,theObject);
+ if(aSObj->_is_nil())
+ return;
+
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+
+ SALOMEDS::GenericAttribute_var aFindAttr;
+ bool hasAttr = aSObj->FindAttribute(aFindAttr, "AttributeString");
+ if(VARIABLE_DEBUG)
+ cout<<"Find Attribute "<<hasAttr<<endl;
+
+ SALOMEDS::GenericAttribute_var anAttr;
+ anAttr = aStudyBuilder->FindOrCreateAttribute( aSObj, "AttributeString");
+ SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
+
+ TCollection_AsciiString aNewParams;
+ TCollection_AsciiString aOldParameters(aStringAttr->Value());
+ TCollection_AsciiString anInputParams(ParseParameters(theParameters));
+
+ if(!hasAttr)
+ aNewParams = anInputParams;
+ else
+ aNewParams = aOldParameters+"|"+anInputParams;
+
+ if(VARIABLE_DEBUG)
+ {
+ cout<<"Input Parameters : "<<anInputParams<<endl;
+ cout<<"Old Parameters : "<<aOldParameters<<endl;
+ cout<<"New Parameters : "<<aNewParams<<endl;
+ }
+
+
+ aStringAttr->SetValue( aNewParams.ToCString() );
+}
+
+//=======================================================================
+//function : ParseParameters
+//purpose :
+//=======================================================================
+char* SMESH_Gen_i::ParseParameters(const char* theParameters)
+{
+ const char* aParameters = CORBA::string_dup(theParameters);
+ TCollection_AsciiString anInputParams;
+ SALOMEDS::Study_ptr aStudy = GetCurrentStudy();
+ if( !aStudy->_is_nil() ) {
+ SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
+ for(int j=0;j<aSections->length();j++) {
+ SALOMEDS::ListOfStrings aVars= aSections[j];
+ for(int i=0;i<aVars.length();i++ ) {
+ anInputParams += aStudy->IsVariable(aVars[i].in()) ?
+ TCollection_AsciiString(aVars[i].in()) : TCollection_AsciiString("");
+ if(i != aVars.length()-1)
+ anInputParams+=":";
+ }
+ if(j!=aSections->length()-1)
+ anInputParams+="|";
+ }
+ }
+ return CORBA::string_dup(anInputParams.ToCString());
+}
+
+//=======================================================================
+//function : GetParameters
+//purpose :
+//=======================================================================
+char* SMESH_Gen_i::GetParameters(CORBA::Object_ptr theObject)
+{
+ TCollection_AsciiString aResult;
+
+ SALOMEDS::Study_ptr aStudy = GetCurrentStudy();
+ SALOMEDS::SObject_var aSObj = ObjectToSObject(aStudy,theObject);
+
+ if(!aStudy->_is_nil() &&
+ !CORBA::is_nil(theObject) &&
+ !aSObj->_is_nil()){
+
+ SALOMEDS::GenericAttribute_var anAttr;
+ if ( aSObj->FindAttribute(anAttr, "AttributeString")) {
+ aResult = TCollection_AsciiString(SALOMEDS::AttributeString::_narrow(anAttr)->Value());
+ }
+ }
+
+ return CORBA::string_dup( aResult.ToCString() );
+}
#include <iostream>
#include <sstream>
#include "SMESH_Hypothesis_i.hxx"
+#include "SMESH_Gen_i.hxx"
#include "utilities.h"
using namespace std;
return myBaseImpl->GetID();
}
+//=============================================================================
+/*!
+ * SMESH_Hypothesis_i::IsPublished()
+ *
+ */
+//=============================================================================
+bool SMESH_Hypothesis_i::IsPublished(){
+ bool res = false;
+ SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
+ if(gen){
+ SALOMEDS::SObject_var SO =
+ SMESH_Gen_i::ObjectToSObject(gen->GetCurrentStudy() , SMESH::SMESH_Hypothesis::_narrow(_this()));
+ res = !SO->_is_nil();
+ }
+ return res;
+}
+
+//=============================================================================
+/*!
+ * SMESH_Hypothesis_i::SetParameters()
+ *
+ */
+//=============================================================================
+void SMESH_Hypothesis_i::SetParameters(const char* theParameters)
+{
+ SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
+ char * aParameters = CORBA::string_dup(theParameters);
+ if(gen){
+ if(IsPublished()) {
+ SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Hypothesis::_narrow(_this()),aParameters);
+ }
+ else {
+ myBaseImpl->SetParameters(gen->ParseParameters(aParameters));
+ }
+ }
+}
+
+//=============================================================================
+/*!
+ * SMESH_Hypothesis_i::GetParameters()
+ *
+ */
+//=============================================================================
+char* SMESH_Hypothesis_i::GetParameters()
+{
+ SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
+ char* aResult;
+ if(IsPublished()) {
+ MESSAGE("SMESH_Hypothesis_i::GetParameters() : Get Parameters from SObject");
+ aResult = gen->GetParameters(SMESH::SMESH_Hypothesis::_narrow(_this()));
+ }
+ else {
+ MESSAGE("SMESH_Hypothesis_i::GetParameters() : Get local parameters");
+ aResult = myBaseImpl->GetParameters();
+ }
+ return CORBA::string_dup(aResult);
+}
+
+//=============================================================================
+/*!
+ * SMESH_Hypothesis_i::GetLastParameters()
+ *
+ */
+//=============================================================================
+SMESH::ListOfParameters* SMESH_Hypothesis_i::GetLastParameters()
+{
+ SMESH::ListOfParameters_var aResult = new SMESH::ListOfParameters();
+ SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
+ if(gen) {
+ char *aParameters;
+ if(IsPublished())
+ aParameters = GetParameters();
+ else
+ aParameters = myBaseImpl->GetLastParameters();
+
+ SALOMEDS::Study_ptr aStudy = gen->GetCurrentStudy();
+ if(!aStudy->_is_nil()) {
+ SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
+ if(aSections->length() > 0) {
+ SALOMEDS::ListOfStrings aVars = aSections[aSections->length()-1];
+ aResult->length(aVars.length());
+ for(int i = 0;i < aVars.length();i++)
+ aResult[i] = CORBA::string_dup( aVars[i]);
+ }
+ }
+ }
+ return aResult._retn();
+}
+
+//=============================================================================
+/*!
+ * SMESH_Hypothesis_i::SetLastParameters()
+ *
+ */
+//=============================================================================
+void SMESH_Hypothesis_i::SetLastParameters(const char* theParameters)
+{
+ if(!IsPublished()) {
+ myBaseImpl->SetLastParameters(theParameters);
+ }
+}
+//=============================================================================
+/*!
+ * SMESH_Hypothesis_i::ClearParameters()
+ *
+ */
+//=============================================================================
+void SMESH_Hypothesis_i::ClearParameters()
+{
+ if(!IsPublished()) {
+ myBaseImpl->ClearParameters();
+ }
+}
+
//=============================================================================
/*!
* SMESH_Hypothesis_i::GetImpl
// Get unique id of hypothesis
CORBA::Long GetId();
+
+ // Set list of parameters separated by ":" symbol, used for Hypothesis creation
+ void SetParameters (const char* theParameters);
+
+ // Return list of notebook variables used for Hypothesis creation separated by ":" symbol
+ char* GetParameters();
+
+ //Return list of last notebook variables used for Hypothesis creation.
+ SMESH::ListOfParameters* GetLastParameters();
+
+ //Set last parameters for not published hypothesis
+
+ void SetLastParameters(const char* theParameters);
+
+ // Clear parameters list
+ void ClearParameters();
+
+ //Return true if hypothesis was published in study
+ bool IsPublished();
// Get implementation
::SMESH_Hypothesis* GetImpl();
CORBA::Double theAngleInRadians,
CORBA::Long theNbOfSteps,
CORBA::Double theTolerance,
- const bool theMakeGroups)
+ const bool theMakeGroups,
+ const SMDSAbs_ElementType theElementType)
{
initData();
TIDSortedElemSet inElements, copyElements;
- arrayToSet(theIDsOfElements, GetMeshDS(), inElements);
+ arrayToSet(theIDsOfElements, GetMeshDS(), inElements, theElementType);
TIDSortedElemSet* workElements = & inElements;
TPreviewMesh tmpMesh( SMDSAbs_Face );
CORBA::Double theTolerance)
{
if ( !myPreviewMode ) {
- TPythonDump() << "axis = " << theAxis;
TPythonDump() << this << ".RotationSweep( "
- << theIDsOfElements
- << ", axis, "
+ << theIDsOfElements << ", "
+ << theAxis << ", "
<< theAngleInRadians << ", "
<< theNbOfSteps << ", "
<< theTolerance << " )";
theTolerance,
true);
if ( !myPreviewMode ) {
- TPythonDump()<< "axis = " << theAxis;
TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump<< this << ".RotationSweepMakeGroups( "
- << theIDsOfElements
- << ", axis, "
+ << theIDsOfElements << ", "
+ << theAxis << ", "
<< theAngleInRadians << ", "
<< theNbOfSteps << ", "
<< theTolerance << " )";
CORBA::Double theTolerance)
{
if ( !myPreviewMode ) {
- TPythonDump() << "axis = " << theAxis;
TPythonDump() << this << ".RotationSweepObject( "
- << theObject
- << ", axis, "
+ << theObject << ", "
+ << theAxis << ", "
<< theAngleInRadians << ", "
<< theNbOfSteps << ", "
<< theTolerance << " )";
false);
}
+//=======================================================================
+//function : RotationSweepObject1D
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::RotationSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::AxisStruct & theAxis,
+ CORBA::Double theAngleInRadians,
+ CORBA::Long theNbOfSteps,
+ CORBA::Double theTolerance)
+{
+ if ( !myPreviewMode ) {
+ TPythonDump() << this << ".RotationSweepObject1D( "
+ << theObject << ", "
+ << theAxis << ", "
+ << theAngleInRadians << ", "
+ << theNbOfSteps << ", "
+ << theTolerance << " )";
+ }
+ SMESH::long_array_var anElementsId = theObject->GetIDs();
+ rotationSweep(anElementsId,
+ theAxis,
+ theAngleInRadians,
+ theNbOfSteps,
+ theTolerance,
+ false,
+ SMDSAbs_Edge);
+}
+
+//=======================================================================
+//function : RotationSweepObject2D
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::RotationSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::AxisStruct & theAxis,
+ CORBA::Double theAngleInRadians,
+ CORBA::Long theNbOfSteps,
+ CORBA::Double theTolerance)
+{
+ if ( !myPreviewMode ) {
+ TPythonDump() << this << ".RotationSweepObject2D( "
+ << theObject << ", "
+ << theAxis << ", "
+ << theAngleInRadians << ", "
+ << theNbOfSteps << ", "
+ << theTolerance << " )";
+ }
+ SMESH::long_array_var anElementsId = theObject->GetIDs();
+ rotationSweep(anElementsId,
+ theAxis,
+ theAngleInRadians,
+ theNbOfSteps,
+ theTolerance,
+ false,
+ SMDSAbs_Face);
+}
+
//=======================================================================
//function : RotationSweepObjectMakeGroups
//purpose :
theTolerance,
true);
if ( !myPreviewMode ) {
- TPythonDump() << "axis = " << theAxis;
TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump<< this << ".RotationSweepObjectMakeGroups( "
- << theObject
- << ", axis, "
+ << theObject << ", "
+ << theAxis << ", "
+ << theAngleInRadians << ", "
+ << theNbOfSteps << ", "
+ << theTolerance << " )";
+ }
+ return aGroups;
+}
+
+//=======================================================================
+//function : RotationSweepObject1DMakeGroups
+//purpose :
+//=======================================================================
+
+SMESH::ListOfGroups*
+SMESH_MeshEditor_i::RotationSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::AxisStruct& theAxis,
+ CORBA::Double theAngleInRadians,
+ CORBA::Long theNbOfSteps,
+ CORBA::Double theTolerance)
+{
+ SMESH::long_array_var anElementsId = theObject->GetIDs();
+ SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
+ theAxis,
+ theAngleInRadians,
+ theNbOfSteps,
+ theTolerance,
+ true,
+ SMDSAbs_Edge);
+ if ( !myPreviewMode ) {
+ TPythonDump aPythonDump;
+ DumpGroupsList(aPythonDump,aGroups);
+ aPythonDump<< this << ".RotationSweepObject1DMakeGroups( "
+ << theObject << ", "
+ << theAxis << ", "
+ << theAngleInRadians << ", "
+ << theNbOfSteps << ", "
+ << theTolerance << " )";
+ }
+ return aGroups;
+}
+
+//=======================================================================
+//function : RotationSweepObject2DMakeGroups
+//purpose :
+//=======================================================================
+
+SMESH::ListOfGroups*
+SMESH_MeshEditor_i::RotationSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::AxisStruct& theAxis,
+ CORBA::Double theAngleInRadians,
+ CORBA::Long theNbOfSteps,
+ CORBA::Double theTolerance)
+{
+ SMESH::long_array_var anElementsId = theObject->GetIDs();
+ SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
+ theAxis,
+ theAngleInRadians,
+ theNbOfSteps,
+ theTolerance,
+ true,
+ SMDSAbs_Face);
+ if ( !myPreviewMode ) {
+ TPythonDump aPythonDump;
+ DumpGroupsList(aPythonDump,aGroups);
+ aPythonDump<< this << ".RotationSweepObject2DMakeGroups( "
+ << theObject << ", "
+ << theAxis << ", "
<< theAngleInRadians << ", "
<< theNbOfSteps << ", "
<< theTolerance << " )";
{
extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false );
if ( !myPreviewMode ) {
- TPythonDump() << "stepVector = " << theStepVector;
TPythonDump() << this << ".ExtrusionSweep( "
- << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )";
+ << theIDsOfElements << ", " << theStepVector <<", " << theNbOfSteps << " )";
}
}
SMESH::long_array_var anElementsId = theObject->GetIDs();
extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false );
if ( !myPreviewMode ) {
- TPythonDump() << "stepVector = " << theStepVector;
TPythonDump() << this << ".ExtrusionSweepObject( "
- << theObject << ", stepVector, " << theNbOfSteps << " )";
+ << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
}
}
SMESH::long_array_var anElementsId = theObject->GetIDs();
extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Edge );
if ( !myPreviewMode ) {
- TPythonDump() << "stepVector = " << theStepVector;
TPythonDump() << this << ".ExtrusionSweepObject1D( "
- << theObject << ", stepVector, " << theNbOfSteps << " )";
+ << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
}
}
SMESH::long_array_var anElementsId = theObject->GetIDs();
extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Face );
if ( !myPreviewMode ) {
- TPythonDump() << "stepVector = " << theStepVector;
TPythonDump() << this << ".ExtrusionSweepObject2D( "
- << theObject << ", stepVector, " << theNbOfSteps << " )";
+ << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
}
}
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;
}
SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true );
if ( !myPreviewMode ) {
- TPythonDump() << "stepVector = " << theStepVector;
TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump<< this << ".ExtrusionSweepObjectMakeGroups( "
- << theObject << ", stepVector, " << theNbOfSteps << " )";
+ << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
}
return aGroups;
}
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Edge );
if ( !myPreviewMode ) {
- TPythonDump() << "stepVector = " << theStepVector;
TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( "
- << theObject << ", stepVector, " << theNbOfSteps << " )";
+ << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
}
return aGroups;
}
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Face );
if ( !myPreviewMode ) {
- TPythonDump() << "stepVector = " << theStepVector;
TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( "
- << theObject << ", stepVector, " << theNbOfSteps << " )";
+ << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
}
return aGroups;
}
CORBA::Boolean theHasRefPoint,
const SMESH::PointStruct & theRefPoint,
const bool theMakeGroups,
- SMESH::SMESH_MeshEditor::Extrusion_Error & theError)
+ SMESH::SMESH_MeshEditor::Extrusion_Error & theError,
+ const SMDSAbs_ElementType theElementType)
{
initData();
}
TIDSortedElemSet elements;
- arrayToSet(theIDsOfElements, GetMeshDS(), elements);
+ arrayToSet(theIDsOfElements, GetMeshDS(), elements, theElementType);
list<double> angles;
for (int i = 0; i < theAngles.length(); i++) {
const SMESH::PointStruct & theRefPoint)
{
if ( !myPreviewMode ) {
- TPythonDump() << "rotAngles = " << theAngles;
-
- if ( theHasRefPoint )
- TPythonDump() << "refPoint = SMESH.PointStruct( "
- << theRefPoint.x << ", "
- << theRefPoint.y << ", "
- << theRefPoint.z << " )";
- else
- TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )";
-
TPythonDump() << "error = " << this << ".ExtrusionAlongPath( "
<< theIDsOfElements << ", "
<< thePathMesh << ", "
<< thePathShape << ", "
<< theNodeStart << ", "
<< theHasAngles << ", "
- << "rotAngles" << ", "
- << theHasRefPoint << ", refPoint )";
+ << theAngles << ", "
+ << theHasRefPoint << ", "
+ << "SMESH.PointStruct( "
+ << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
}
SMESH::SMESH_MeshEditor::Extrusion_Error anError;
extrusionAlongPath( theIDsOfElements,
const SMESH::PointStruct & theRefPoint)
{
if ( !myPreviewMode ) {
- TPythonDump() << "rotAngles = " << theAngles;
-
- if ( theHasRefPoint )
- TPythonDump() << "refPoint = SMESH.PointStruct( "
- << theRefPoint.x << ", "
- << theRefPoint.y << ", "
- << theRefPoint.z << " )";
- else
- TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )";
-
TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject( "
<< theObject << ", "
<< thePathMesh << ", "
<< thePathShape << ", "
<< theNodeStart << ", "
<< theHasAngles << ", "
- << "rotAngles" << ", "
- << theHasRefPoint << ", refPoint )";
+ << theAngles << ", "
+ << theHasRefPoint << ", "
+ << "SMESH.PointStruct( "
+ << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
}
SMESH::SMESH_MeshEditor::Extrusion_Error anError;
SMESH::long_array_var anElementsId = theObject->GetIDs();
return anError;
}
+//=======================================================================
+//function : ExtrusionAlongPathObject1D
+//purpose :
+//=======================================================================
+
+SMESH::SMESH_MeshEditor::Extrusion_Error
+SMESH_MeshEditor_i::ExtrusionAlongPathObject1D(SMESH::SMESH_IDSource_ptr theObject,
+ SMESH::SMESH_Mesh_ptr thePathMesh,
+ GEOM::GEOM_Object_ptr thePathShape,
+ CORBA::Long theNodeStart,
+ CORBA::Boolean theHasAngles,
+ const SMESH::double_array & theAngles,
+ CORBA::Boolean theHasRefPoint,
+ const SMESH::PointStruct & theRefPoint)
+{
+ if ( !myPreviewMode ) {
+ TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject1D( "
+ << theObject << ", "
+ << thePathMesh << ", "
+ << thePathShape << ", "
+ << theNodeStart << ", "
+ << theHasAngles << ", "
+ << theAngles << ", "
+ << theHasRefPoint << ", "
+ << "SMESH.PointStruct( "
+ << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
+ }
+ SMESH::SMESH_MeshEditor::Extrusion_Error anError;
+ SMESH::long_array_var anElementsId = theObject->GetIDs();
+ extrusionAlongPath( anElementsId,
+ thePathMesh,
+ thePathShape,
+ theNodeStart,
+ theHasAngles,
+ theAngles,
+ theHasRefPoint,
+ theRefPoint,
+ false,
+ anError,
+ SMDSAbs_Edge);
+ return anError;
+}
+
+//=======================================================================
+//function : ExtrusionAlongPathObject2D
+//purpose :
+//=======================================================================
+
+SMESH::SMESH_MeshEditor::Extrusion_Error
+SMESH_MeshEditor_i::ExtrusionAlongPathObject2D(SMESH::SMESH_IDSource_ptr theObject,
+ SMESH::SMESH_Mesh_ptr thePathMesh,
+ GEOM::GEOM_Object_ptr thePathShape,
+ CORBA::Long theNodeStart,
+ CORBA::Boolean theHasAngles,
+ const SMESH::double_array & theAngles,
+ CORBA::Boolean theHasRefPoint,
+ const SMESH::PointStruct & theRefPoint)
+{
+ if ( !myPreviewMode ) {
+ TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject2D( "
+ << theObject << ", "
+ << thePathMesh << ", "
+ << thePathShape << ", "
+ << theNodeStart << ", "
+ << theHasAngles << ", "
+ << theAngles << ", "
+ << theHasRefPoint << ", "
+ << "SMESH.PointStruct( "
+ << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
+ }
+ SMESH::SMESH_MeshEditor::Extrusion_Error anError;
+ SMESH::long_array_var anElementsId = theObject->GetIDs();
+ extrusionAlongPath( anElementsId,
+ thePathMesh,
+ thePathShape,
+ theNodeStart,
+ theHasAngles,
+ theAngles,
+ theHasRefPoint,
+ theRefPoint,
+ false,
+ anError,
+ SMDSAbs_Face);
+ return anError;
+}
+
//=======================================================================
//function : ExtrusionAlongPathMakeGroups
true,
Error);
if ( !myPreviewMode ) {
- TPythonDump() << "rotAngles = " << theAngles;
-
- if ( theHasRefPoint )
- TPythonDump() << "refPoint = SMESH.PointStruct( "
- << theRefPoint.x << ", "
- << theRefPoint.y << ", "
- << theRefPoint.z << " )";
- else
- TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )";
-
bool isDumpGroups = aGroups && aGroups->length() > 0;
TPythonDump aPythonDump;
if(isDumpGroups) {
<< thePathShape << ", "
<< theNodeStart << ", "
<< theHasAngles << ", "
- << "rotAngles" << ", "
- << theHasRefPoint << ", refPoint )";
+ << theAngles << ", "
+ << theHasRefPoint << ", "
+ << "SMESH.PointStruct( "
+ << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
}
return aGroups;
}
Error);
if ( !myPreviewMode ) {
- TPythonDump() << "rotAngles = " << theAngles;
+ bool isDumpGroups = aGroups && aGroups->length() > 0;
+ TPythonDump aPythonDump;
+ if(isDumpGroups) {
+ aPythonDump << "("<<aGroups;
+ }
+ if(isDumpGroups)
+ aPythonDump << ", error)";
+ else
+ aPythonDump <<"error";
+
+ aPythonDump << " = " << this << ".ExtrusionAlongPathObjectMakeGroups( "
+ << theObject << ", "
+ << thePathMesh << ", "
+ << thePathShape << ", "
+ << theNodeStart << ", "
+ << theHasAngles << ", "
+ << theAngles << ", "
+ << theHasRefPoint << ", "
+ << "SMESH.PointStruct( "
+ << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
+ }
+ return aGroups;
+}
- if ( theHasRefPoint )
- TPythonDump() << "refPoint = SMESH.PointStruct( "
- << theRefPoint.x << ", "
- << theRefPoint.y << ", "
- << theRefPoint.z << " )";
+//=======================================================================
+//function : ExtrusionAlongPathObject1DMakeGroups
+//purpose :
+//=======================================================================
+
+SMESH::ListOfGroups* SMESH_MeshEditor_i::
+ExtrusionAlongPathObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
+ SMESH::SMESH_Mesh_ptr thePathMesh,
+ GEOM::GEOM_Object_ptr thePathShape,
+ CORBA::Long theNodeStart,
+ CORBA::Boolean theHasAngles,
+ const SMESH::double_array& theAngles,
+ CORBA::Boolean theHasRefPoint,
+ const SMESH::PointStruct& theRefPoint,
+ SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
+{
+ SMESH::long_array_var anElementsId = theObject->GetIDs();
+ SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
+ thePathMesh,
+ thePathShape,
+ theNodeStart,
+ theHasAngles,
+ theAngles,
+ theHasRefPoint,
+ theRefPoint,
+ true,
+ Error,
+ SMDSAbs_Edge);
+
+ if ( !myPreviewMode ) {
+ bool isDumpGroups = aGroups && aGroups->length() > 0;
+ TPythonDump aPythonDump;
+ if(isDumpGroups) {
+ aPythonDump << "("<<aGroups;
+ }
+ if(isDumpGroups)
+ aPythonDump << ", error)";
else
- TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )";
-
+ aPythonDump <<"error";
+
+ aPythonDump << " = " << this << ".ExtrusionAlongPathObject1DMakeGroups( "
+ << theObject << ", "
+ << thePathMesh << ", "
+ << thePathShape << ", "
+ << theNodeStart << ", "
+ << theHasAngles << ", "
+ << theAngles << ", "
+ << theHasRefPoint << ", "
+ << "SMESH.PointStruct( "
+ << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
+ }
+ return aGroups;
+}
+
+//=======================================================================
+//function : ExtrusionAlongPathObject2DMakeGroups
+//purpose :
+//=======================================================================
+
+SMESH::ListOfGroups* SMESH_MeshEditor_i::
+ExtrusionAlongPathObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
+ SMESH::SMESH_Mesh_ptr thePathMesh,
+ GEOM::GEOM_Object_ptr thePathShape,
+ CORBA::Long theNodeStart,
+ CORBA::Boolean theHasAngles,
+ const SMESH::double_array& theAngles,
+ CORBA::Boolean theHasRefPoint,
+ const SMESH::PointStruct& theRefPoint,
+ SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
+{
+ SMESH::long_array_var anElementsId = theObject->GetIDs();
+ SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
+ thePathMesh,
+ thePathShape,
+ theNodeStart,
+ theHasAngles,
+ theAngles,
+ theHasRefPoint,
+ theRefPoint,
+ true,
+ Error,
+ SMDSAbs_Face);
+
+ if ( !myPreviewMode ) {
bool isDumpGroups = aGroups && aGroups->length() > 0;
TPythonDump aPythonDump;
if(isDumpGroups) {
else
aPythonDump <<"error";
- aPythonDump << " = " << this << ".ExtrusionAlongPathObjectMakeGroups( "
+ aPythonDump << " = " << this << ".ExtrusionAlongPathObject2DMakeGroups( "
<< theObject << ", "
<< thePathMesh << ", "
<< thePathShape << ", "
<< theNodeStart << ", "
<< theHasAngles << ", "
- << "rotAngles" << ", "
- << theHasRefPoint << ", refPoint )";
+ << theAngles << ", "
+ << theHasRefPoint << ", "
+ << "SMESH.PointStruct( "
+ << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
+ << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )";
}
return aGroups;
}
{
SMESH::ListOfGroups * aGroups = mirror(theIDsOfElements, theMirror, theMirrorType, true, true);
if ( !myPreviewMode ) {
- TPythonDump()<<"axis = "<<theMirror;
TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".MirrorMakeGroups( "
<< theIDsOfElements << ", "
- << "axis, "
+ << theMirror << ", "
<< mirrorTypeName(theMirrorType) << " )";
}
return aGroups;
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = mirror(anElementsId, theMirror, theMirrorType, true, true);
if ( !myPreviewMode ) {
- TPythonDump()<<"axis = "<<theMirror;
TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".MirrorObjectMakeGroups( "
<< theObject << ", "
- << "axis, "
+ << theMirror << ", "
<< mirrorTypeName(theMirrorType) << " )";
}
return aGroups;
CORBA::Boolean theCopy)
{
if ( !myPreviewMode ) {
- TPythonDump() << "vector = " << theVector;
TPythonDump() << this << ".Translate( "
- << theIDsOfElements
- << ", vector, "
+ << theIDsOfElements << ", "
+ << theVector << ", "
<< theCopy << " )";
}
translate(theIDsOfElements,
{
if ( !myPreviewMode ) {
TPythonDump() << this << ".TranslateObject( "
- << theObject
- << ", vector, "
+ << theObject << ", "
+ << theVector << ", "
<< theCopy << " )";
}
SMESH::long_array_var anElementsId = theObject->GetIDs();
{
SMESH::ListOfGroups * aGroups = translate(theIDsOfElements,theVector,true,true);
if ( !myPreviewMode ) {
- TPythonDump() << "vector = " << theVector;
TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".TranslateMakeGroups( "
- << theIDsOfElements
- << ", vector )";
+ << theIDsOfElements << ", "
+ << theVector << " )";
}
return aGroups;
}
if ( !myPreviewMode ) {
- TPythonDump() << "vector = " << theVector;
TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".TranslateObjectMakeGroups( "
- << theObject
- << ", vector )";
+ << theObject << ", "
+ << theVector << " )";
}
return aGroups;
}
CORBA::Boolean theCopy)
{
if ( !myPreviewMode ) {
- TPythonDump() << "axis = " << theAxis;
TPythonDump() << this << ".Rotate( "
- << theIDsOfElements
- << ", axis, "
+ << theIDsOfElements << ", "
+ << theAxis << ", "
<< theAngle << ", "
<< theCopy << " )";
}
CORBA::Boolean theCopy)
{
if ( !myPreviewMode ) {
- TPythonDump() << "axis = " << theAxis;
TPythonDump() << this << ".RotateObject( "
- << theObject
- << ", axis, "
+ << theObject << ", "
+ << theAxis << ", "
<< theAngle << ", "
<< theCopy << " )";
}
{
SMESH::ListOfGroups * aGroups = rotate(theIDsOfElements,theAxis,theAngle,true,true);
if ( !myPreviewMode ) {
- TPythonDump() << "axis = " << theAxis;
TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".RotateMakeGroups( "
- << theIDsOfElements
- << ", axis, "
+ << theIDsOfElements << ", "
+ << theAxis << ", "
<< theAngle << " )";
}
return aGroups;
SMESH::ListOfGroups * aGroups = rotate(anElementsId,theAxis,theAngle,true,true);
if ( !myPreviewMode ) {
- TPythonDump() << "axis = " << theAxis;
TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".RotateObjectMakeGroups( "
- << theObject
- << ", axis, "
- << theAngle << " )";
+ << theObject << ", "
+ << theAxis << ", "
+ << theAngle << " )";
}
return aGroups;
}
CORBA::Double AngleInRadians,
CORBA::Long NbOfSteps,
CORBA::Double Tolerance);
+ void RotationSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::AxisStruct & Axis,
+ CORBA::Double AngleInRadians,
+ CORBA::Long NbOfSteps,
+ CORBA::Double Tolerance);
+ void RotationSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
+ const SMESH::AxisStruct & Axis,
+ CORBA::Double AngleInRadians,
+ CORBA::Long NbOfSteps,
+ CORBA::Double Tolerance);
void ExtrusionSweep(const SMESH::long_array & IDsOfElements,
const SMESH::DirStruct & StepVector,
const SMESH::double_array & Angles,
CORBA::Boolean HasRefPoint,
const SMESH::PointStruct & RefPoint);
+ SMESH::SMESH_MeshEditor::Extrusion_Error
+ ExtrusionAlongPathObject1D(SMESH::SMESH_IDSource_ptr theObject,
+ SMESH::SMESH_Mesh_ptr PathMesh,
+ GEOM::GEOM_Object_ptr PathShape,
+ CORBA::Long NodeStart,
+ CORBA::Boolean HasAngles,
+ const SMESH::double_array & Angles,
+ CORBA::Boolean HasRefPoint,
+ const SMESH::PointStruct & RefPoint);
+ SMESH::SMESH_MeshEditor::Extrusion_Error
+ ExtrusionAlongPathObject2D(SMESH::SMESH_IDSource_ptr theObject,
+ SMESH::SMESH_Mesh_ptr PathMesh,
+ GEOM::GEOM_Object_ptr PathShape,
+ CORBA::Long NodeStart,
+ CORBA::Boolean HasAngles,
+ const SMESH::double_array & Angles,
+ CORBA::Boolean HasRefPoint,
+ const SMESH::PointStruct & RefPoint);
SMESH::double_array* LinearAnglesVariation(SMESH::SMESH_Mesh_ptr PathMesh,
GEOM::GEOM_Object_ptr PathShape,
CORBA::Double AngleInRadians,
CORBA::Long NbOfSteps,
CORBA::Double Tolerance);
+ SMESH::ListOfGroups* RotationSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr Object,
+ const SMESH::AxisStruct& Axix,
+ CORBA::Double AngleInRadians,
+ CORBA::Long NbOfSteps,
+ CORBA::Double Tolerance);
+ SMESH::ListOfGroups* RotationSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr Object,
+ const SMESH::AxisStruct& Axix,
+ CORBA::Double AngleInRadians,
+ CORBA::Long NbOfSteps,
+ CORBA::Double Tolerance);
SMESH::ListOfGroups* ExtrusionSweepMakeGroups(const SMESH::long_array& IDsOfElements,
const SMESH::DirStruct& StepVector,
CORBA::Long NbOfSteps);
CORBA::Boolean HasRefPoint,
const SMESH::PointStruct& RefPoint,
SMESH::SMESH_MeshEditor::Extrusion_Error& Error);
+ SMESH::ListOfGroups* ExtrusionAlongPathObject1DMakeGroups(SMESH::SMESH_IDSource_ptr Object,
+ SMESH::SMESH_Mesh_ptr PathMesh,
+ GEOM::GEOM_Object_ptr PathShape,
+ CORBA::Long NodeStart,
+ CORBA::Boolean HasAngles,
+ const SMESH::double_array& Angles,
+ CORBA::Boolean HasRefPoint,
+ const SMESH::PointStruct& RefPoint,
+ SMESH::SMESH_MeshEditor::Extrusion_Error& Error);
+ SMESH::ListOfGroups* ExtrusionAlongPathObject2DMakeGroups(SMESH::SMESH_IDSource_ptr Object,
+ SMESH::SMESH_Mesh_ptr PathMesh,
+ GEOM::GEOM_Object_ptr PathShape,
+ CORBA::Long NodeStart,
+ CORBA::Boolean HasAngles,
+ const SMESH::double_array& Angles,
+ CORBA::Boolean HasRefPoint,
+ const SMESH::PointStruct& RefPoint,
+ SMESH::SMESH_MeshEditor::Extrusion_Error& Error);
SMESH::ListOfGroups* MirrorMakeGroups(const SMESH::long_array& IDsOfElements,
const SMESH::AxisStruct& Mirror,
SMESH::SMESH_MeshEditor::MirrorType MirrorType);
CORBA::Double AngleInRadians,
CORBA::Long NbOfSteps,
CORBA::Double Tolerance,
- const bool MakeGroups);
+ const bool MakeGroups,
+ const SMDSAbs_ElementType ElementType=SMDSAbs_All);
SMESH::ListOfGroups* extrusionSweep(const SMESH::long_array & IDsOfElements,
const SMESH::DirStruct & StepVector,
CORBA::Long NbOfSteps,
CORBA::Boolean HasRefPoint,
const SMESH::PointStruct & RefPoint,
const bool MakeGroups,
- SMESH::SMESH_MeshEditor::Extrusion_Error & Error);
+ SMESH::SMESH_MeshEditor::Extrusion_Error & Error,
+ const SMDSAbs_ElementType ElementType=SMDSAbs_All);
SMESH::ListOfGroups* mirror(const SMESH::long_array & IDsOfElements,
const SMESH::AxisStruct & Axis,
SMESH::SMESH_MeshEditor::MirrorType MirrorType,
aGrp->SetName( guiName );
}
}
+
+//=============================================================================
+/*!
+ * \brief Sets list of notebook variables used for Mesh operations separated by ":" symbol
+ */
+//=============================================================================
+void SMESH_Mesh_i::SetParameters(const char* theParameters)
+{
+ SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Mesh::_narrow(_this()),
+ CORBA::string_dup(theParameters));
+}
+
+//=============================================================================
+/*!
+ * \brief Returns list of notebook variables used for Mesh operations separated by ":" symbol
+ */
+//=============================================================================
+char* SMESH_Mesh_i::GetParameters()
+{
+ SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
+ return CORBA::string_dup(gen->GetParameters(SMESH::SMESH_Mesh::_narrow(_this())));
+}
+
+//=============================================================================
+/*!
+ * \brief Returns list of notebook variables used for last Mesh operation
+ */
+//=============================================================================
+SMESH::string_array* SMESH_Mesh_i::GetLastParameters()
+{
+ SMESH::string_array_var aResult = new SMESH::string_array();
+ SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
+ if(gen) {
+ char *aParameters = GetParameters();
+ SALOMEDS::Study_ptr aStudy = gen->GetCurrentStudy();
+ if(!aStudy->_is_nil()) {
+ SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
+ if(aSections->length() > 0) {
+ SALOMEDS::ListOfStrings aVars = aSections[aSections->length()-1];
+ aResult->length(aVars.length());
+ for(int i = 0;i < aVars.length();i++)
+ aResult[i] = CORBA::string_dup( aVars[i]);
+ }
+ }
+ }
+ return aResult._retn();
+}
*/
virtual SALOME_MED::MedFileInfo* GetMEDFileInfo();
+ /*!
+ * Sets list of notebook variables used for Mesh operations separated by ":" symbol
+ */
+ void SetParameters (const char* theParameters);
+
+ /*!
+ * Returns list of notebook variables used for Mesh operations separated by ":" symbol
+ */
+ char* GetParameters();
+
+ /*!
+ * Returns list of notebook variables used for last Mesh operation
+ */
+ SMESH::string_array* GetLastParameters();
+
std::map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
std::map<int, ::SMESH_subMesh*> _mapSubMesh; //NRI
--- /dev/null
+// Copyright (C) 2008 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : SMESH_NoteBook.cxx
+// Author : Roman NIKOLAEV
+
+#include "SMESH_2smeshpy.hxx"
+#include "SMESH_NoteBook.hxx"
+#include "SMESH_Gen_i.hxx"
+#include "SMESH_PythonDump.hxx"
+
+#include <Resource_DataMapOfAsciiStringAsciiString.hxx>
+#include <TColStd_SequenceOfAsciiString.hxx>
+#include <TColStd_HSequenceOfInteger.hxx>
+
+#include <vector>
+#include <string>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+using namespace std;
+
+
+void SetVariable(Handle(_pyCommand) theCommand,const ObjectStates* theStates, int position, int theArgNb);
+
+//================================================================================
+/*!
+ * \brief Constructor
+ */
+//================================================================================
+ObjectStates::ObjectStates(TCollection_AsciiString theType)
+{
+ _type = theType;
+ _dumpstate = 0;
+}
+
+//================================================================================
+/*!
+ * \brief Destructor
+ */
+//================================================================================
+ObjectStates::~ObjectStates()
+{
+}
+
+//================================================================================
+/*!
+ * \brief Add new object state
+ * \param theState - Object state (vector of notebook variable)
+ */
+//================================================================================
+void ObjectStates::AddState(const TState &theState)
+{
+ _states.push_back(theState);
+}
+
+//================================================================================
+/*!
+ * \brief Return current object state
+ * \\retval state - Object state (vector of notebook variable)
+ */
+//================================================================================
+TState ObjectStates::GetCurrectState() const
+{
+ if(_states.size() > _dumpstate)
+ return _states[_dumpstate];
+ TState empty;
+ return empty;
+}
+
+
+//================================================================================
+/*!
+ *
+ */
+//================================================================================
+TAllStates ObjectStates::GetAllStates() const
+{
+ return _states;
+}
+
+//================================================================================
+/*!
+ *
+ */
+//================================================================================
+void ObjectStates::IncrementState()
+{
+ _dumpstate++;
+}
+
+//================================================================================
+/*!
+ *
+ */
+//================================================================================
+TCollection_AsciiString ObjectStates::GetObjectType() const{
+ return _type;
+}
+
+
+//================================================================================
+/*!
+ * \brief Constructor
+ */
+//================================================================================
+LayerDistributionStates::LayerDistributionStates():
+ ObjectStates("LayerDistribution")
+{
+}
+//================================================================================
+/*!
+ * \brief Destructor
+ */
+//================================================================================
+LayerDistributionStates::~LayerDistributionStates()
+{
+}
+
+
+//================================================================================
+/*!
+ * \brief AddDistribution
+ */
+//================================================================================
+void LayerDistributionStates::AddDistribution(const TCollection_AsciiString& theDistribution)
+{
+ _distributions.insert(pair<TCollection_AsciiString,TCollection_AsciiString>(theDistribution,""));
+}
+
+//================================================================================
+/*!
+ * \brief HasDistribution
+ */
+//================================================================================
+bool LayerDistributionStates::HasDistribution(const TCollection_AsciiString& theDistribution) const
+{
+ return _distributions.find(theDistribution) != _distributions.end();
+}
+
+//================================================================================
+/*!
+ * \brief SetDistributionType
+ */
+//================================================================================
+bool LayerDistributionStates::SetDistributionType(const TCollection_AsciiString& theDistribution,
+ const TCollection_AsciiString& theType)
+{
+ TDistributionMap::iterator it = _distributions.find(theDistribution);
+ if(it == _distributions.end())
+ return false;
+ (*it).second = theType;
+ return true;
+}
+
+//================================================================================
+/*!
+ * \brief GetDistributionType
+ */
+//================================================================================
+TCollection_AsciiString LayerDistributionStates::
+GetDistributionType(const TCollection_AsciiString& theDistribution) const
+{
+ TDistributionMap::const_iterator it = _distributions.find(theDistribution);
+ return (it == _distributions.end()) ? TCollection_AsciiString() : (*it).second;
+}
+
+//================================================================================
+/*!
+ * \brief Constructor
+ */
+//================================================================================
+SMESH_NoteBook::SMESH_NoteBook()
+{
+ InitObjectMap();
+}
+
+//================================================================================
+/*!
+ * \brief Destructor
+ */
+//================================================================================
+SMESH_NoteBook::~SMESH_NoteBook()
+{
+ TVariablesMap::const_iterator it = _objectMap.begin();
+ for(;it!=_objectMap.end();it++) {
+ if((*it).second)
+ delete (*it).second;
+ }
+}
+
+//================================================================================
+/*!
+ * \brief Replace parameters of the functions on the Salome NoteBook Variables
+ * \param theString - Input string
+ * \retval TCollection_AsciiString - Convertion result
+ */
+//================================================================================
+void SMESH_NoteBook::ReplaceVariables()
+{
+ for(int i=0;i<_commands.size();i++) {
+ Handle(_pyCommand) aCmd = _commands[i];
+ TCollection_AsciiString aMethod = aCmd->GetMethod();
+ TCollection_AsciiString aObject = aCmd->GetObject();
+ TCollection_AsciiString aResultValue = aCmd->GetResultValue();
+ if(MYDEBUG) {
+ cout<<"Command before : "<< aCmd->GetString()<<endl;
+ cout<<"Method : "<< aMethod<<endl;
+ cout<<"Object : "<< aObject<<endl;
+ cout<<"Result : "<< aResultValue<<endl;
+ }
+
+ // check if method modifies the object itself
+ TVariablesMap::const_iterator it = _objectMap.find(aObject);
+ if(it == _objectMap.end()) // check if method returns a new object
+ it = _objectMap.find(aResultValue);
+
+ if(it == _objectMap.end()) { // check if method modifies a mesh using mesh editor
+ TMeshEditorMap::const_iterator meIt = myMeshEditors.find(aObject);
+ if(meIt != myMeshEditors.end()) {
+ TCollection_AsciiString aMesh = (*meIt).second;
+ it = _objectMap.find(aMesh);
+ }
+ }
+
+ if(it == _objectMap.end()) { // additional check for pattern mapping
+ if(aMethod.IsEqual("ApplyToMeshFaces") ||
+ aMethod.IsEqual("ApplyToHexahedrons"))
+ it = _objectMap.find(aCmd->GetArg(1));
+ }
+
+ if(it != _objectMap.end()) {
+ if(MYDEBUG)
+ cout << "Found object : " << (*it).first << endl;
+ ObjectStates *aStates = (*it).second;
+ // Case for LocalLength hypothesis
+ if(aStates->GetObjectType().IsEqual("LocalLength") && aStates->GetCurrectState().size() >= 2) {
+ if(aMethod.IsEqual("SetLength")) {
+ if(!aStates->GetCurrectState().at(0).IsEmpty() )
+ aCmd->SetArg(1,aStates->GetCurrectState().at(0));
+ aStates->IncrementState();
+ }
+ else if(aMethod.IsEqual("SetPrecision")) {
+ if(!aStates->GetCurrectState().at(1).IsEmpty() )
+ aCmd->SetArg(1,aStates->GetCurrectState().at(1));
+ aStates->IncrementState();
+ }
+ }
+
+ // Case for SegmentLengthAroundVertex hypothesis
+ else if(aStates->GetObjectType().IsEqual("SegmentLengthAroundVertex")
+ && aStates->GetCurrectState().size() >= 1) {
+ if(aMethod == "SetLength") {
+ if(!aStates->GetCurrectState().at(0).IsEmpty() )
+ aCmd->SetArg(1,aStates->GetCurrectState().at(0));
+ aStates->IncrementState();
+ }
+ }
+
+ // Case for Arithmetic1D and StartEndLength hypothesis
+ else if(aStates->GetObjectType().IsEqual("Arithmetic1D") ||
+ aStates->GetObjectType().IsEqual("StartEndLength")) {
+ if(aMethod == "SetLength" &&
+ aStates->GetCurrectState().size() >= 2) {
+ if(aCmd->GetArg(2) == "1" && !aStates->GetCurrectState().at(0).IsEmpty())
+ aCmd->SetArg(1,aStates->GetCurrectState().at(0));
+ else if(!aStates->GetCurrectState().at(1).IsEmpty())
+ aCmd->SetArg(1,aStates->GetCurrectState().at(1));
+ aStates->IncrementState();
+ }
+ }
+
+ //Case for Deflection1D hypothesis
+ else if(aStates->GetObjectType().IsEqual("Deflection1D")){
+ if(aMethod == "SetDeflection" && aStates->GetCurrectState().size() >= 1) {
+ if(!aStates->GetCurrectState().at(0).IsEmpty() )
+ aCmd->SetArg(1,aStates->GetCurrectState().at(0));
+ aStates->IncrementState();
+ }
+ }
+
+ // Case for LayerDistribution hypothesis (not finished yet)
+ else if(aStates->GetObjectType() == "LayerDistribution") {
+ if(aMethod == "SetLayerDistribution"){
+ LayerDistributionStates* aLDStates = (LayerDistributionStates*)(aStates);
+ aLDStates->AddDistribution(aCmd->GetArg(1));
+ if(MYDEBUG)
+ cout<<"Add Distribution :"<<aCmd->GetArg(1)<<endl;
+ }
+ }
+
+ // Case for MaxElementArea hypothesis
+ else if(aStates->GetObjectType().IsEqual("MaxElementArea")){
+ if(aMethod == "SetMaxElementArea" && aStates->GetCurrectState().size() >= 1) {
+ if(!aStates->GetCurrectState().at(0).IsEmpty() )
+ aCmd->SetArg(1,aStates->GetCurrectState().at(0));
+ aStates->IncrementState();
+ }
+ }
+
+ // Case for MaxElementVolume hypothesis
+ else if(aStates->GetObjectType().IsEqual("MaxElementVolume")){
+ if(aMethod == "SetMaxElementVolume" && aStates->GetCurrectState().size() >= 1) {
+ if(!aStates->GetCurrectState().at(0).IsEmpty() )
+ aCmd->SetArg(1,aStates->GetCurrectState().at(0));
+ aStates->IncrementState();
+ }
+ }
+
+ // Case for NETGEN_Parameters_2D or NETGEN_Parameters_2D hypothesis
+ else if(aStates->GetObjectType().IsEqual("NETGEN_Parameters_2D") ||
+ aStates->GetObjectType().IsEqual("NETGEN_Parameters")){
+ if(aMethod == "SetMaxSize" && aStates->GetCurrectState().size() >= 1) {
+ if(!aStates->GetCurrectState().at(0).IsEmpty() )
+ aCmd->SetArg(1,aStates->GetCurrectState().at(0));
+ aStates->IncrementState();
+ }
+ else if(aMethod == "SetGrowthRate" && aStates->GetCurrectState().size() >= 2) {
+ if(!aStates->GetCurrectState().at(1).IsEmpty() )
+ aCmd->SetArg(1,aStates->GetCurrectState().at(1));
+ aStates->IncrementState();
+ }
+ else if(aMethod == "SetNbSegPerEdge" && aStates->GetCurrectState().size() >= 3) {
+ if(!aStates->GetCurrectState().at(2).IsEmpty() )
+ aCmd->SetArg(1,aStates->GetCurrectState().at(2));
+ aStates->IncrementState();
+ }
+ else if(aMethod == "SetNbSegPerRadius" && aStates->GetCurrectState().size() >= 4) {
+ if(!aStates->GetCurrectState().at(3).IsEmpty() )
+ aCmd->SetArg(1,aStates->GetCurrectState().at(3));
+ aStates->IncrementState();
+ }
+ }
+
+ // Case for NETGEN_SimpleParameters_3D or NETGEN_SimpleParameters_2D hypothesis
+ else if(aStates->GetObjectType().IsEqual("NETGEN_SimpleParameters_3D") ||
+ aStates->GetObjectType().IsEqual("NETGEN_SimpleParameters_2D")){
+
+ if((aMethod == "SetNumberOfSegments" || aMethod == "SetLocalLength") &&
+ aStates->GetCurrectState().size() >= 1) {
+ if(!aStates->GetCurrectState().at(0).IsEmpty() )
+ aCmd->SetArg(1,aStates->GetCurrectState().at(0));
+ aStates->IncrementState();
+ }
+ else if(aMethod == "SetMaxElementArea" && aStates->GetCurrectState().size() >= 2) {
+ if(!aStates->GetCurrectState().at(1).IsEmpty() )
+ aCmd->SetArg(1,aStates->GetCurrectState().at(1));
+ aStates->IncrementState();
+ }
+ else if(aMethod == "SetMaxElementVolume" && aStates->GetCurrectState().size() >= 3) {
+ if(!aStates->GetCurrectState().at(2).IsEmpty() )
+ aCmd->SetArg(1,aStates->GetCurrectState().at(2));
+ aStates->IncrementState();
+ }
+ else if(aMethod == "LengthFromEdges" || aMethod == "LengthFromFaces"){
+ aStates->IncrementState();
+ }
+ }
+
+ // Case for NumberOfLayers hypothesis
+ else if(aStates->GetObjectType().IsEqual("NumberOfLayers")){
+ if(aMethod == "SetNumberOfLayers" && aStates->GetCurrectState().size() >= 1) {
+ if(!aStates->GetCurrectState().at(0).IsEmpty() )
+ aCmd->SetArg(1,aStates->GetCurrectState().at(0));
+ aStates->IncrementState();
+ }
+ }
+
+ // Case for NumberOfSegments hypothesis
+ else if(aStates->GetObjectType().IsEqual("NumberOfSegments")){
+ if(aMethod == "SetNumberOfSegments" && aStates->GetCurrectState().size() >= 1) {
+ if(!aStates->GetCurrectState().at(0).IsEmpty() )
+ aCmd->SetArg(1,aStates->GetCurrectState().at(0));
+ if(aStates->GetCurrectState().size()==1)
+ aStates->IncrementState();
+ }
+ else if (aMethod == "SetScaleFactor" && aStates->GetCurrectState().size() >= 2) {
+ if(!aStates->GetCurrectState().at(1).IsEmpty() )
+ aCmd->SetArg(1,aStates->GetCurrectState().at(1));
+ aStates->IncrementState();
+ }
+ }
+
+ else if(aStates->GetObjectType().IsEqual("Mesh")) {
+ TState aCurrentState = aStates->GetCurrectState();
+ int aCurrentStateSize = aCurrentState.size();
+ if(aMethod.IsEqual("Translate") ||
+ aMethod.IsEqual("TranslateMakeGroups") ||
+ aMethod.IsEqual("TranslateMakeMesh") ||
+ aMethod.IsEqual("TranslateObject") ||
+ aMethod.IsEqual("TranslateObjectMakeGroups") ||
+ aMethod.IsEqual("TranslateObjectMakeMesh")) {
+ bool isVariableFound = 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) {
+ 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: limitation until operations on the variables will be introduced
+ /*
+ isVariableFound = true;
+ for(int j = 0; j < 3; j++) {
+ TCollection_AsciiString anArg = aCmd->GetArg(anArgIndex+j);
+ TCollection_AsciiString aValue1 = aCurrentState.at(2*j), aValue2 = aCurrentState.at(2*j+1);
+ bool aV1 = !aValue1.IsEmpty();
+ bool aV2 = !aValue2.IsEmpty();
+ double aValue, aCurrentValue = anArg.IsRealValue() ? anArg.RealValue() : 0;
+ if(aV1 && !aV2) {
+ if(!GetReal(aValue1, aValue))
+ aValue = 0;
+ aValue2 = TCollection_AsciiString( aValue + aCurrentValue );
+ }
+ else if(!aV1 && aV2) {
+ if(!GetReal(aValue2, aValue))
+ aValue = 0;
+ aValue1 = TCollection_AsciiString( aValue - aCurrentValue );
+ }
+ else if(!aV1 && !aV2) {
+ aValue1 = TCollection_AsciiString( 0 );
+ aValue2 = TCollection_AsciiString( aCurrentValue );
+ }
+ aCmd->SetArg(anArgIndex+j, aValue1 + ", " + aValue2 );
+ }
+ */
+ }
+ }
+ if(isVariableFound) {
+ TCollection_AsciiString aDim;
+ if(aCurrentStateSize == 6)
+ aDim = "6";
+ aCmd->SetArg(anArgIndex - 1, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr"+aDim);
+ aCmd->SetArg(anArgIndex - 2, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".DirStructStr");
+ }
+ aStates->IncrementState();
+ }
+ else if(aMethod.IsEqual("Rotate") ||
+ aMethod.IsEqual("RotateMakeGroups") ||
+ aMethod.IsEqual("RotateMakeMesh") ||
+ aMethod.IsEqual("RotateObject") ||
+ aMethod.IsEqual("RotateObjectMakeGroups") ||
+ aMethod.IsEqual("RotateObjectMakeMesh") ||
+ aMethod.IsEqual("RotationSweep") ||
+ aMethod.IsEqual("RotationSweepObject") ||
+ aMethod.IsEqual("RotationSweepObject1D") ||
+ aMethod.IsEqual("RotationSweepObject2D") ||
+ aMethod.IsEqual("RotationSweepMakeGroups") ||
+ aMethod.IsEqual("RotationSweepObjectMakeGroups") ||
+ aMethod.IsEqual("RotationSweepObject1DMakeGroups") ||
+ aMethod.IsEqual("RotationSweepObject2DMakeGroups") ||
+ aMethod.IsEqual("Mirror") ||
+ aMethod.IsEqual("MirrorMakeMesh") ||
+ aMethod.IsEqual("MirrorMakeGroups") ||
+ aMethod.IsEqual("MirrorObject") ||
+ aMethod.IsEqual("MirrorObjectMakeMesh") ||
+ aMethod.IsEqual("MirrorObjectMakeGroups")) {
+ 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) // 0-5 - axis struct, 6 - angle (rotation & sweep), 7-8 - nbSteps and tolerance (sweep)
+ 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("ExtrusionSweepObject") ||
+ aMethod.IsEqual("ExtrusionSweepObject1D") ||
+ aMethod.IsEqual("ExtrusionSweepObject2D") ||
+ aMethod.IsEqual("ExtrusionSweepMakeGroups") ||
+ aMethod.IsEqual("ExtrusionSweepObjectMakeGroups") ||
+ aMethod.IsEqual("ExtrusionSweepObject1DMakeGroups") ||
+ aMethod.IsEqual("ExtrusionSweepObject2DMakeGroups")) {
+ 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) // 0-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("ExtrusionAlongPath") ||
+ aMethod.IsEqual("ExtrusionAlongPathObject") ||
+ aMethod.IsEqual("ExtrusionAlongPathObject1D") ||
+ aMethod.IsEqual("ExtrusionAlongPathObject2D") ||
+ aMethod.IsEqual("ExtrusionAlongPathMakeGroups") ||
+ aMethod.IsEqual("ExtrusionAlongPathObjectMakeGroups") ||
+ aMethod.IsEqual("ExtrusionAlongPathObject1DMakeGroups") ||
+ aMethod.IsEqual("ExtrusionAlongPathObject2DMakeGroups") ||
+ /* workaround for a bug in the command parsing algorithm */
+ aCmd->GetString().Search("ExtrusionAlongPathMakeGroups") != -1 ||
+ aCmd->GetString().Search("ExtrusionAlongPathObjectMakeGroups") != -1 ||
+ aCmd->GetString().Search("ExtrusionAlongPathObject1DMakeGroups") != -1 ||
+ aCmd->GetString().Search("ExtrusionAlongPathObject2DMakeGroups") != -1 ) {
+ int aNbAngles = aCurrentStateSize-3; // State looks like "Angle1:...:AngleN:X:Y:Z"
+ 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-aNbAngles;
+ break;
+ }
+ }
+ if(anArgIndex > 0) {
+ int j = 0;
+ for(; j < aNbAngles; j++) {
+ if(!aCurrentState.at(j).IsEmpty()) {
+ aCmd->SetArg(anArgIndex+j-1, aCurrentState.at(j));
+ }
+ }
+ for(; j < aNbAngles+3; j++) {
+ if(!aCurrentState.at(j).IsEmpty()) {
+ isSubstitute = true;
+ aCmd->SetArg(anArgIndex+j+2, aCurrentState.at(j));
+ }
+ }
+ }
+ if(isSubstitute)
+ aCmd->SetArg(anArgIndex + aNbAngles + 1,
+ TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr");
+ 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("SmoothObject") ||
+ aMethod.IsEqual("SmoothParametric") ||
+ aMethod.IsEqual("SmoothParametricObject")) {
+ 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();
+ }
+ else if(aMethod.IsEqual("ApplyToMeshFaces") ||
+ aMethod.IsEqual("ApplyToHexahedrons")) {
+ int anArgIndex = aCmd->GetNbArgs()-1;
+ for(int j = 0; j < aCurrentStateSize; j++)
+ if(!aCurrentState.at(j).IsEmpty())
+ aCmd->SetArg(anArgIndex+j, aCurrentState.at(j));
+ aStates->IncrementState();
+ }
+ }
+ }
+ else {
+ if(MYDEBUG)
+ cout << "Object not found" << endl;
+ }
+ if(MYDEBUG) {
+ cout<<"Command after: "<< aCmd->GetString()<<endl;
+ }
+ }
+
+ ProcessLayerDistribution();
+}
+//================================================================================
+/*!
+ * \brief Private method
+ */
+//================================================================================
+void SMESH_NoteBook::InitObjectMap()
+{
+ SMESH_Gen_i *aGen = SMESH_Gen_i::GetSMESHGen();
+ if(!aGen)
+ return;
+
+ SALOMEDS::Study_ptr aStudy = aGen->GetCurrentStudy();
+ if(aStudy->_is_nil())
+ return;
+
+ SALOMEDS::SObject_var aSO = aStudy->FindComponent(aGen->ComponentDataType());
+ if(CORBA::is_nil(aSO))
+ return;
+
+ SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO);
+ char* aParameters;
+ for(Itr->InitEx(true); Itr->More(); Itr->Next()) {
+ SALOMEDS::SObject_var aSObject = Itr->Value();
+ SALOMEDS::GenericAttribute_var anAttr;
+ if ( aSObject->FindAttribute(anAttr, "AttributeString")) {
+ aParameters = SALOMEDS::AttributeString::_narrow(anAttr)->Value();
+ SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
+ if(MYDEBUG) {
+ cout<<"Entry : "<< aSObject->GetID()<<endl;
+ cout<<"aParameters : "<<aParameters<<endl;
+ }
+ TCollection_AsciiString anObjType;
+ CORBA::Object_var anObject = SMESH_Gen_i::SObjectToObject(aSObject);
+ SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow(anObject);
+ if(!aHyp->_is_nil()) {
+ anObjType = TCollection_AsciiString(aHyp->GetName());
+ }
+ else if(SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObject)) {
+ anObjType = TCollection_AsciiString("Mesh");
+ }
+ if(MYDEBUG)
+ cout<<"The object Type : "<<anObjType<<endl;
+ ObjectStates *aState = NULL;
+ if(anObjType == "LayerDistribution") {
+ aState = new LayerDistributionStates();
+ }
+ else
+ aState = new ObjectStates(anObjType);
+
+ for(int i = 0; i < aSections->length(); i++) {
+ TState aVars;
+ SALOMEDS::ListOfStrings aListOfVars = aSections[i];
+ for(int j = 0;j<aListOfVars.length();j++) {
+ TCollection_AsciiString aVar(aListOfVars[j].in());
+ if(!aVar.IsEmpty() && aStudy->IsVariable(aVar.ToCString())) {
+ aVar.InsertBefore(1,"\"");
+ aVar.InsertAfter(aVar.Length(),"\"");
+ }
+ aVars.push_back(aVar);
+ if(MYDEBUG) {
+ cout<<"Variable: '"<<aVar<<"'"<<endl;
+ }
+ }
+ aState->AddState(aVars);
+ }
+ _objectMap.insert(pair<TCollection_AsciiString,ObjectStates*>(TCollection_AsciiString(aSObject->GetID()),aState));
+ }
+ }
+}
+
+//================================================================================
+/*!
+ *
+ */
+//================================================================================
+void SMESH_NoteBook::AddCommand(const TCollection_AsciiString& theString)
+{
+ if(MYDEBUG)
+ cout<<theString<<endl;
+ Handle(_pyCommand) aCommand = new _pyCommand( theString, -1);
+ _commands.push_back(aCommand);
+
+ if ( aCommand->GetMethod() == "GetMeshEditor" ) { // MeshEditor creation
+ myMeshEditors.insert( make_pair( aCommand->GetResultValue(),
+ aCommand->GetObject() ) );
+ }
+}
+
+//================================================================================
+/*!
+ *
+ */
+//================================================================================
+void SMESH_NoteBook::ProcessLayerDistribution()
+{
+ // 1) Find all LayerDistribution states
+ vector<LayerDistributionStates*> aLDS;
+ TVariablesMap::const_iterator it = _objectMap.begin();
+ for(;it != _objectMap.end();it++) {
+ LayerDistributionStates* aLDStates = dynamic_cast<LayerDistributionStates*>(((*it).second));
+ if(aLDStates!=NULL) {
+ aLDS.push_back(aLDStates);
+ }
+ }
+
+ if(!aLDS.size())
+ return;
+
+ // 2) Initialize all type of 1D Distribution hypothesis
+ for(int i=0;i<_commands.size();i++){
+ for(int j =0;j < aLDS.size();j++){
+ TCollection_AsciiString aResultValue = _commands[i]->GetResultValue();
+ if(_commands[i]->GetMethod() == "CreateHypothesis" &&
+ aLDS[j]->HasDistribution(aResultValue)){
+ TCollection_AsciiString aType = _commands[i]->GetArg(1);
+ aType.RemoveAll('\'');
+ aLDS[j]->SetDistributionType(aResultValue,aType);
+ }
+ }
+ }
+ // 3) ... and replase variables ...
+
+ for(int i=0;i<_commands.size();i++){
+ for(int j =0;j < aLDS.size();j++){
+ TCollection_AsciiString anObject = _commands[i]->GetObject();
+
+ if(aLDS[j]->HasDistribution(anObject)) {
+ TCollection_AsciiString aType = aLDS[j]->GetDistributionType(anObject);
+ TCollection_AsciiString aMethod = _commands[i]->GetMethod();
+ if(aType == "LocalLength") {
+ if(aMethod == "SetLength") {
+ SetVariable(_commands[i], aLDS[j],0,1);
+ aLDS[j]->IncrementState();
+ }
+ else if(aMethod == "SetPrecision") {
+ SetVariable(_commands[i], aLDS[j],1,1);
+ aLDS[j]->IncrementState();
+ }
+ }
+
+ // Case for NumberOfSegments hypothesis
+ else if(aType == "NumberOfSegments"){
+ if(aMethod == "SetNumberOfSegments") {
+ SetVariable(_commands[i], aLDS[j],0,1);
+ if(aLDS[j]->GetCurrectState().size()==1)
+ aLDS[j]->IncrementState();
+ }
+ else if (aMethod == "SetScaleFactor") {
+ SetVariable(_commands[i], aLDS[j],1,1);
+ aLDS[j]->IncrementState();
+ }
+ }
+
+ else if( aType == "Deflection1D" ){
+ if(aMethod == "SetDeflection"){
+ SetVariable(_commands[i], aLDS[j],0,1);
+ aLDS[j]->IncrementState();
+ }
+ }
+ // Case for Arithmetic1D and StartEndLength hypothesis
+ else if(aType == "Arithmetic1D" || aType == "StartEndLength") {
+ if(aMethod == "SetLength") {
+ int anArgNb = (_commands[i]->GetArg(2) == "1") ? 0 : 1;
+ SetVariable(_commands[i], aLDS[j],anArgNb,1);
+ aLDS[j]->IncrementState();
+ }
+ }
+ }
+ }
+ }
+}
+//================================================================================
+/*!
+ * \brief Return result script
+ */
+//================================================================================
+TCollection_AsciiString SMESH_NoteBook::GetResultScript() const
+{
+ TCollection_AsciiString aResult;
+ for(int i=0;i<_commands.size();i++)
+ aResult+=_commands[i]->GetString()+"\n";
+ return aResult;
+}
+
+//================================================================================
+/*!
+ * \brief Return value of the variable
+ */
+//================================================================================
+bool SMESH_NoteBook::GetReal(const TCollection_AsciiString& theVarName, double& theValue)
+{
+ bool ok = false;
+
+ SMESH_Gen_i *aGen = SMESH_Gen_i::GetSMESHGen();
+ if(!aGen)
+ return ok;
+
+ SALOMEDS::Study_ptr aStudy = aGen->GetCurrentStudy();
+ if(aStudy->_is_nil())
+ return ok;
+
+ TCollection_AsciiString aVarName = theVarName;
+ aVarName.RemoveAll('\"');
+
+ if(aVarName.IsEmpty())
+ return ok;
+
+ const char* aName = aVarName.ToCString();
+ if(aStudy->IsVariable(aName) && (aStudy->IsReal(aName) || aStudy->IsInteger(aName))) {
+ theValue = aStudy->GetReal(aVarName.ToCString());
+ ok = true;
+ }
+
+ return ok;
+}
+
+
+/*!
+ * Set variable of the ObjectStates from position to the _pyCommand
+ * method as nbArg argument
+ */
+void SetVariable(Handle(_pyCommand) theCommand, const ObjectStates* theStates, int position, int theArgNb)
+{
+ if(theStates->GetCurrectState().size() > position)
+ if(!theStates->GetCurrectState().at(position).IsEmpty())
+ theCommand->SetArg(theArgNb,theStates->GetCurrectState().at(position));
+}
--- /dev/null
+// Copyright (C) 2008 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : SMESH_NoteBook.hxx
+// Author : Roman NIKOLAEV ()
+
+
+#ifndef SMESH_NoteBook_HeaderFile
+#define SMESH_NoteBook_HeaderFile
+
+#include <TCollection_AsciiString.hxx>
+#include <Resource_DataMapOfAsciiStringAsciiString.hxx>
+
+class _pyCommand;
+
+#include <vector>
+#include <string>
+
+typedef std::vector<TCollection_AsciiString> TState;
+typedef std::vector<TState> TAllStates;
+typedef TCollection_AsciiString _pyID;
+
+class ObjectStates{
+
+public:
+
+ ObjectStates(TCollection_AsciiString theType);
+ virtual ~ObjectStates();
+
+ void AddState(const TState &theState);
+
+ TState GetCurrectState() const;
+ TAllStates GetAllStates() const;
+ void IncrementState();
+ TCollection_AsciiString GetObjectType() const;
+
+
+
+private:
+ TCollection_AsciiString _type;
+ TAllStates _states;
+ int _dumpstate;
+};
+
+class LayerDistributionStates : public ObjectStates
+{
+public:
+ typedef std::map<TCollection_AsciiString,TCollection_AsciiString> TDistributionMap;
+ LayerDistributionStates();
+ virtual ~LayerDistributionStates();
+
+ void AddDistribution(const TCollection_AsciiString& theDistribution);
+ bool HasDistribution(const TCollection_AsciiString& theDistribution) const;
+
+ bool SetDistributionType(const TCollection_AsciiString& theDistribution,
+ const TCollection_AsciiString& theType);
+ TCollection_AsciiString GetDistributionType(const TCollection_AsciiString& theDistribution) const;
+
+private:
+
+ TDistributionMap _distributions;
+};
+
+
+class SMESH_NoteBook
+{
+public:
+ typedef std::map<TCollection_AsciiString,ObjectStates*> TVariablesMap;
+ typedef std::map<TCollection_AsciiString,TCollection_AsciiString> TMeshEditorMap;
+ SMESH_NoteBook();
+ ~SMESH_NoteBook();
+ void ReplaceVariables();
+
+ void AddCommand(const TCollection_AsciiString& theString);
+ TCollection_AsciiString GetResultScript() const;
+
+private:
+ void InitObjectMap();
+ void ProcessLayerDistribution();
+
+ bool GetReal(const TCollection_AsciiString& theVarName, double& theValue);
+
+private:
+
+ TVariablesMap _objectMap;
+ std::vector<Handle(_pyCommand)> _commands;
+ TMeshEditorMap myMeshEditors;
+};
+
+#endif //SMESH_NoteBook_HeaderFile
PrecisionConfusion = 1e-07
+## Converts an angle from degrees to radians
+def DegreesToRadians(AngleInDegrees):
+ from math import pi
+ return AngleInDegrees * pi / 180.0
+
+# Salome notebook variable separator
+var_separator = ":"
+
+# Parametrized substitute for PointStruct
+class PointStructStr:
+
+ x = 0
+ y = 0
+ z = 0
+ xStr = ""
+ yStr = ""
+ zStr = ""
+
+ def __init__(self, xStr, yStr, zStr):
+ self.xStr = xStr
+ self.yStr = yStr
+ self.zStr = zStr
+ 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
+
+# Parametrized substitute for PointStruct (with 6 parameters)
+class PointStructStr6:
+
+ x1 = 0
+ y1 = 0
+ z1 = 0
+ x2 = 0
+ y2 = 0
+ z2 = 0
+ xStr1 = ""
+ yStr1 = ""
+ zStr1 = ""
+ xStr2 = ""
+ yStr2 = ""
+ zStr2 = ""
+
+ def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
+ self.x1Str = x1Str
+ self.x2Str = x2Str
+ self.y1Str = y1Str
+ self.y2Str = y2Str
+ self.z1Str = z1Str
+ self.z2Str = z2Str
+ if isinstance(x1Str, str) and notebook.isVariable(x1Str):
+ self.x1 = notebook.get(x1Str)
+ else:
+ self.x1 = x1Str
+ if isinstance(x2Str, str) and notebook.isVariable(x2Str):
+ self.x2 = notebook.get(x2Str)
+ else:
+ self.x2 = x2Str
+ if isinstance(y1Str, str) and notebook.isVariable(y1Str):
+ self.y1 = notebook.get(y1Str)
+ else:
+ self.y1 = y1Str
+ if isinstance(y2Str, str) and notebook.isVariable(y2Str):
+ self.y2 = notebook.get(y2Str)
+ else:
+ self.y2 = y2Str
+ if isinstance(z1Str, str) and notebook.isVariable(z1Str):
+ self.z1 = notebook.get(z1Str)
+ else:
+ self.z1 = z1Str
+ if isinstance(z2Str, str) and notebook.isVariable(z2Str):
+ self.z2 = notebook.get(z2Str)
+ else:
+ self.z2 = z2Str
+
+# 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:
+
+ def __init__(self, pointStruct):
+ self.pointStruct = pointStruct
+
+# Returns list of variable values from salome notebook
+def ParsePointStruct(Point):
+ Parameters = 2*var_separator
+ if isinstance(Point, PointStructStr):
+ Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + 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 = 2*var_separator
+ if isinstance(Dir, DirStructStr):
+ pntStr = Dir.pointStruct
+ if isinstance(pntStr, PointStructStr6):
+ Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
+ Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
+ Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
+ Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
+ else:
+ Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + 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 = 5*var_separator
+ if isinstance(Axis, AxisStructStr):
+ Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
+ Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
+ Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
+ return Axis, Parameters
+
+## Return list of variable values from salome notebook
+def ParseAngles(list):
+ Result = []
+ Parameters = ""
+ for parameter in list:
+ if isinstance(parameter,str) and notebook.isVariable(parameter):
+ Result.append(DegreesToRadians(notebook.get(parameter)))
+ pass
+ else:
+ Result.append(parameter)
+ pass
+
+ Parameters = Parameters + str(parameter)
+ Parameters = Parameters + var_separator
+ pass
+ Parameters = Parameters[:len(Parameters)-1]
+ return Result, Parameters
+
def IsEqual(val1, val2, tol=PrecisionConfusion):
if abs(val1 - val2) < tol:
return True
print hypName, "was not assigned to",geomName,":", reason
pass
-## Converts an angle from degrees to radians
-def DegreesToRadians(AngleInDegrees):
- from math import pi
- return AngleInDegrees * pi / 180.0
-
# end of l1_auxiliary
## @}
def SetBoundaryBoxSegmentation(self, nbSegments):
SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
+ ## Concatenate the given meshes into one mesh.
+ # @return an instance of Mesh class
+ # @param meshes the meshes to combine into one mesh
+ # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
+ # @param mergeNodesAndElements if true, equal nodes and elements aremerged
+ # @param mergeTolerance tolerance for merging nodes
+ # @param allGroups forces creation of groups of all elements
+ def Concatenate( self, meshes, uniteIdenticalGroups,
+ mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
+ mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
+ if allGroups:
+ aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
+ self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
+ else:
+ aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
+ self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
+ aSmeshMesh.SetParameters(Parameters)
+ aMesh = Mesh(self, self.geompyD, aSmeshMesh)
+ return aMesh
# Filtering. Auxiliary functions:
# ------------------------------
# @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
# @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
# @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
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)
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)
## Generates new elements by rotation of the elements around the axis
# @param IDsOfElements the list of ids of elements to sweep
# @param Axis the axis of rotation, AxisStruct or line(geom object)
- # @param AngleInRadians the angle of Rotation
+ # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
# @param NbOfSteps the number of steps
# @param Tolerance tolerance
# @param MakeGroups forces the generation of new groups from existing ones
# @ingroup l2_modif_extrurev
def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
MakeGroups=False, TotalAngle=False):
+ flag = False
+ if isinstance(AngleInRadians,str):
+ flag = True
+ AngleInRadians,AngleParameters = 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)
if TotalAngle and NbOfSteps:
AngleInRadians /= NbOfSteps
+ NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
+ Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
+ self.mesh.SetParameters(Parameters)
if MakeGroups:
return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
AngleInRadians, NbOfSteps, Tolerance)
# @ingroup l2_modif_extrurev
def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
MakeGroups=False, TotalAngle=False):
+ flag = False
+ if isinstance(AngleInRadians,str):
+ flag = True
+ AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
+ if flag:
+ AngleInRadians = DegreesToRadians(AngleInRadians)
if ( isinstance( theObject, Mesh )):
theObject = theObject.GetMesh()
if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis)
+ Axis,AxisParameters = ParseAxisStruct(Axis)
if TotalAngle and NbOfSteps:
AngleInRadians /= NbOfSteps
+ NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
+ Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
+ self.mesh.SetParameters(Parameters)
if MakeGroups:
return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
NbOfSteps, Tolerance)
self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
return []
+ ## Generates new elements by rotation of the elements of object around the axis
+ # @param theObject object which elements should be sweeped
+ # @param Axis the axis of rotation, AxisStruct or line(geom object)
+ # @param AngleInRadians the angle of Rotation
+ # @param NbOfSteps number of steps
+ # @param Tolerance tolerance
+ # @param MakeGroups forces the generation of new groups from existing ones
+ # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
+ # of all steps, else - size of each step
+ # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
+ # @ingroup l2_modif_extrurev
+ def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
+ MakeGroups=False, TotalAngle=False):
+ flag = False
+ if isinstance(AngleInRadians,str):
+ flag = True
+ AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
+ if flag:
+ AngleInRadians = DegreesToRadians(AngleInRadians)
+ if ( isinstance( theObject, Mesh )):
+ theObject = theObject.GetMesh()
+ if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
+ Axis = self.smeshpyD.GetAxisStruct(Axis)
+ Axis,AxisParameters = ParseAxisStruct(Axis)
+ if TotalAngle and NbOfSteps:
+ AngleInRadians /= NbOfSteps
+ NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
+ Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
+ self.mesh.SetParameters(Parameters)
+ if MakeGroups:
+ return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
+ NbOfSteps, Tolerance)
+ self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
+ return []
+
+ ## Generates new elements by rotation of the elements of object around the axis
+ # @param theObject object which elements should be sweeped
+ # @param Axis the axis of rotation, AxisStruct or line(geom object)
+ # @param AngleInRadians the angle of Rotation
+ # @param NbOfSteps number of steps
+ # @param Tolerance tolerance
+ # @param MakeGroups forces the generation of new groups from existing ones
+ # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
+ # of all steps, else - size of each step
+ # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
+ # @ingroup l2_modif_extrurev
+ def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
+ MakeGroups=False, TotalAngle=False):
+ flag = False
+ if isinstance(AngleInRadians,str):
+ flag = True
+ AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
+ if flag:
+ AngleInRadians = DegreesToRadians(AngleInRadians)
+ if ( isinstance( theObject, Mesh )):
+ theObject = theObject.GetMesh()
+ if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
+ Axis = self.smeshpyD.GetAxisStruct(Axis)
+ Axis,AxisParameters = ParseAxisStruct(Axis)
+ if TotalAngle and NbOfSteps:
+ AngleInRadians /= NbOfSteps
+ NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
+ Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
+ self.mesh.SetParameters(Parameters)
+ if MakeGroups:
+ return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
+ NbOfSteps, Tolerance)
+ self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
+ return []
+
## Generates new elements by extrusion of the elements with given ids
# @param IDsOfElements the list of elements ids for extrusion
# @param StepVector vector, defining the direction and value of extrusion
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 + var_separator + Parameters
+ self.mesh.SetParameters(Parameters)
if MakeGroups:
return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
theObject = theObject.GetMesh()
if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
StepVector = self.smeshpyD.GetDirStruct(StepVector)
+ StepVector,StepVectorParameters = ParseDirStruct(StepVector)
+ NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
+ Parameters = StepVectorParameters + var_separator + Parameters
+ self.mesh.SetParameters(Parameters)
if MakeGroups:
return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
theObject = theObject.GetMesh()
if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
StepVector = self.smeshpyD.GetDirStruct(StepVector)
+ StepVector,StepVectorParameters = ParseDirStruct(StepVector)
+ NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
+ Parameters = StepVectorParameters + var_separator + Parameters
+ self.mesh.SetParameters(Parameters)
if MakeGroups:
return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
theObject = theObject.GetMesh()
if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
StepVector = self.smeshpyD.GetDirStruct(StepVector)
+ StepVector,StepVectorParameters = ParseDirStruct(StepVector)
+ NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
+ Parameters = StepVectorParameters + var_separator + Parameters
+ self.mesh.SetParameters(Parameters)
if MakeGroups:
return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
HasAngles, Angles, HasRefPoint, RefPoint,
MakeGroups=False, LinearVariation=False):
+ Angles,AnglesParameters = ParseAngles(Angles)
+ RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
if IDsOfElements == []:
IDsOfElements = self.GetElementsId()
if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
if HasAngles and Angles and LinearVariation:
Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
pass
+ Parameters = AnglesParameters + var_separator + RefPointParameters
+ self.mesh.SetParameters(Parameters)
if MakeGroups:
return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
PathShape, NodeStart, HasAngles,
def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
HasAngles, Angles, HasRefPoint, RefPoint,
MakeGroups=False, LinearVariation=False):
+ Angles,AnglesParameters = ParseAngles(Angles)
+ RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
if ( isinstance( theObject, Mesh )):
theObject = theObject.GetMesh()
if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
if HasAngles and Angles and LinearVariation:
Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
pass
+ Parameters = AnglesParameters + var_separator + RefPointParameters
+ self.mesh.SetParameters(Parameters)
if MakeGroups:
return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
PathShape, NodeStart, HasAngles,
NodeStart, HasAngles, Angles, HasRefPoint,
RefPoint)
+ ## Generates new elements by extrusion of the elements which belong to the object
+ # The path of extrusion must be a meshed edge.
+ # @param theObject the object which elements should be processed
+ # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
+ # @param PathShape shape(edge) defines the sub-mesh for the path
+ # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
+ # @param HasAngles allows the shape to be rotated around the path
+ # to get the resulting mesh in a helical fashion
+ # @param Angles list of angles
+ # @param HasRefPoint allows using the reference point
+ # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
+ # The User can specify any point as the Reference Point.
+ # @param MakeGroups forces the generation of new groups from existing ones
+ # @param LinearVariation forces the computation of rotation angles as linear
+ # variation of the given Angles along path steps
+ # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
+ # only SMESH::Extrusion_Error otherwise
+ # @ingroup l2_modif_extrurev
+ def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
+ HasAngles, Angles, HasRefPoint, RefPoint,
+ MakeGroups=False, LinearVariation=False):
+ Angles,AnglesParameters = ParseAngles(Angles)
+ RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
+ if ( isinstance( theObject, Mesh )):
+ theObject = theObject.GetMesh()
+ if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
+ RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
+ if ( isinstance( PathMesh, Mesh )):
+ PathMesh = PathMesh.GetMesh()
+ if HasAngles and Angles and LinearVariation:
+ Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
+ pass
+ Parameters = AnglesParameters + var_separator + RefPointParameters
+ self.mesh.SetParameters(Parameters)
+ if MakeGroups:
+ return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
+ PathShape, NodeStart, HasAngles,
+ Angles, HasRefPoint, RefPoint)
+ return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
+ NodeStart, HasAngles, Angles, HasRefPoint,
+ RefPoint)
+
+ ## Generates new elements by extrusion of the elements which belong to the object
+ # The path of extrusion must be a meshed edge.
+ # @param theObject the object which elements should be processed
+ # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
+ # @param PathShape shape(edge) defines the sub-mesh for the path
+ # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
+ # @param HasAngles allows the shape to be rotated around the path
+ # to get the resulting mesh in a helical fashion
+ # @param Angles list of angles
+ # @param HasRefPoint allows using the reference point
+ # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
+ # The User can specify any point as the Reference Point.
+ # @param MakeGroups forces the generation of new groups from existing ones
+ # @param LinearVariation forces the computation of rotation angles as linear
+ # variation of the given Angles along path steps
+ # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
+ # only SMESH::Extrusion_Error otherwise
+ # @ingroup l2_modif_extrurev
+ def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
+ HasAngles, Angles, HasRefPoint, RefPoint,
+ MakeGroups=False, LinearVariation=False):
+ Angles,AnglesParameters = ParseAngles(Angles)
+ RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
+ if ( isinstance( theObject, Mesh )):
+ theObject = theObject.GetMesh()
+ if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
+ RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
+ if ( isinstance( PathMesh, Mesh )):
+ PathMesh = PathMesh.GetMesh()
+ if HasAngles and Angles and LinearVariation:
+ Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
+ pass
+ Parameters = AnglesParameters + var_separator + RefPointParameters
+ self.mesh.SetParameters(Parameters)
+ if MakeGroups:
+ return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
+ PathShape, NodeStart, HasAngles,
+ Angles, HasRefPoint, RefPoint)
+ return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
+ NodeStart, HasAngles, Angles, HasRefPoint,
+ RefPoint)
+
## Creates a symmetrical copy of mesh elements
# @param IDsOfElements list of elements ids
# @param Mirror is AxisStruct or geom object(point, line, plane)
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)
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
theObject = theObject.GetMesh()
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.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
theObject = theObject.GetMesh()
if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
Mirror = self.smeshpyD.GetAxisStruct(Mirror)
+ Mirror,Parameters = ParseAxisStruct(Mirror)
mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
MakeGroups, NewMeshName)
+ mesh.SetParameters(Parameters)
return Mesh( self.smeshpyD,self.geompyD,mesh )
## Translates the elements
IDsOfElements = self.GetElementsId()
if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
Vector = self.smeshpyD.GetDirStruct(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)
IDsOfElements = self.GetElementsId()
if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
Vector = self.smeshpyD.GetDirStruct(Vector)
+ Vector,Parameters = ParseDirStruct(Vector)
mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
+ mesh.SetParameters(Parameters)
return Mesh ( self.smeshpyD, self.geompyD, mesh )
## Translates the object
theObject = theObject.GetMesh()
if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
Vector = self.smeshpyD.GetDirStruct(Vector)
+ Vector,Parameters = ParseDirStruct(Vector)
+ self.mesh.SetParameters(Parameters)
if Copy and MakeGroups:
return self.editor.TranslateObjectMakeGroups(theObject, Vector)
self.editor.TranslateObject(theObject, Vector, Copy)
theObject = theObject.GetMesh()
if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
Vector = self.smeshpyD.GetDirStruct(Vector)
+ Vector,Parameters = ParseDirStruct(Vector)
mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
+ mesh.SetParameters(Parameters)
return Mesh( self.smeshpyD, self.geompyD, 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 + var_separator + Parameters
+ self.mesh.SetParameters(Parameters)
if Copy and MakeGroups:
return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
## 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 + var_separator + Parameters
mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
MakeGroups, NewMeshName)
+ mesh.SetParameters(Parameters)
return Mesh( self.smeshpyD, self.geompyD, mesh )
## Rotates the object
# @param theObject the object to rotate( mesh, submesh, or group)
# @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 RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
+ flag = False
+ if isinstance(AngleInRadians,str):
+ flag = True
+ AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
+ if flag:
+ AngleInRadians = DegreesToRadians(AngleInRadians)
if (isinstance(theObject, Mesh)):
theObject = theObject.GetMesh()
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.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
## Creates a new mesh from the rotated object
# @param theObject the object to rotate (mesh, submesh, or group)
# @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 RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
+ flag = False
+ if isinstance(AngleInRadians,str):
+ flag = True
+ AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
+ if flag:
+ AngleInRadians = DegreesToRadians(AngleInRadians)
if (isinstance( theObject, Mesh )):
theObject = theObject.GetMesh()
if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis)
+ Axis,AxisParameters = ParseAxisStruct(Axis)
+ Parameters = AxisParameters + ":" + Parameters
mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
MakeGroups, NewMeshName)
+ mesh.SetParameters(Parameters)
return Mesh( self.smeshpyD, self.geompyD, mesh )
## Finds groups of ajacent nodes within Tolerance.
self.Create(mesh, geom, "UseExisting_1D")
else:
self.Create(mesh, geom, "UseExisting_2D")
+
+
+import salome_notebook
+notebook = salome_notebook.notebook
+
+##Return values of the notebook variables
+def ParseParameters(last, nbParams,nbParam, value):
+ result = None
+ strResult = ""
+ counter = 0
+ listSize = len(last)
+ for n in range(0,nbParams):
+ if n+1 != nbParam:
+ if counter < listSize:
+ strResult = strResult + last[counter]
+ else:
+ strResult = strResult + ""
+ else:
+ if isinstance(value, str):
+ if notebook.isVariable(value):
+ result = notebook.get(value)
+ strResult=strResult+value
+ else:
+ raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
+ else:
+ strResult=strResult+str(value)
+ result = value
+ if nbParams - 1 != counter:
+ strResult=strResult+var_separator #":"
+ counter = counter+1
+ return result, strResult
+
+#Wrapper class for StdMeshers_LocalLength hypothesis
+class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
+
+ ## Set Length parameter value
+ # @param length numerical value or name of variable from notebook
+ def SetLength(self, length):
+ length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
+ StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
+ StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
+
+ ## Set Precision parameter value
+ # @param precision numerical value or name of variable from notebook
+ def SetPrecision(self, precision):
+ precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
+ StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
+ StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
+
+#Registering the new proxy for LocalLength
+omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
+
+
+#Wrapper class for StdMeshers_LayerDistribution hypothesis
+class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
+
+ def SetLayerDistribution(self, hypo):
+ StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
+ hypo.ClearParameters();
+ StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
+
+#Registering the new proxy for LayerDistribution
+omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
+
+#Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
+class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
+
+ ## Set Length parameter value
+ # @param length numerical value or name of variable from notebook
+ def SetLength(self, length):
+ length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
+ StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
+ StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
+
+#Registering the new proxy for SegmentLengthAroundVertex
+omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
+
+
+#Wrapper class for StdMeshers_Arithmetic1D hypothesis
+class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
+
+ ## Set Length parameter value
+ # @param length numerical value or name of variable from notebook
+ # @param isStart true is length is Start Length, otherwise false
+ def SetLength(self, length, isStart):
+ nb = 2
+ if isStart:
+ nb = 1
+ length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
+ StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
+ StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
+
+#Registering the new proxy for Arithmetic1D
+omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
+
+#Wrapper class for StdMeshers_Deflection1D hypothesis
+class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
+
+ ## Set Deflection parameter value
+ # @param deflection numerical value or name of variable from notebook
+ def SetDeflection(self, deflection):
+ deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
+ StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
+ StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
+
+#Registering the new proxy for Deflection1D
+omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
+
+#Wrapper class for StdMeshers_StartEndLength hypothesis
+class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
+
+ ## Set Length parameter value
+ # @param length numerical value or name of variable from notebook
+ # @param isStart true is length is Start Length, otherwise false
+ def SetLength(self, length, isStart):
+ nb = 2
+ if isStart:
+ nb = 1
+ length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
+ StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
+ StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
+
+#Registering the new proxy for StartEndLength
+omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
+
+#Wrapper class for StdMeshers_MaxElementArea hypothesis
+class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
+
+ ## Set Max Element Area parameter value
+ # @param area numerical value or name of variable from notebook
+ def SetMaxElementArea(self, area):
+ area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
+ StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
+ StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
+
+#Registering the new proxy for MaxElementArea
+omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
+
+
+#Wrapper class for StdMeshers_MaxElementVolume hypothesis
+class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
+
+ ## Set Max Element Volume parameter value
+ # @param area numerical value or name of variable from notebook
+ def SetMaxElementVolume(self, volume):
+ volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
+ StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
+ StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
+
+#Registering the new proxy for MaxElementVolume
+omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
+
+
+#Wrapper class for StdMeshers_NumberOfLayers hypothesis
+class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
+
+ ## Set Number Of Layers parameter value
+ # @param nbLayers numerical value or name of variable from notebook
+ def SetNumberOfLayers(self, nbLayers):
+ nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
+ StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
+ StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
+
+#Registering the new proxy for NumberOfLayers
+omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
+
+#Wrapper class for StdMeshers_NumberOfSegments hypothesis
+class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
+
+ ## Set Number Of Segments parameter value
+ # @param nbSeg numerical value or name of variable from notebook
+ def SetNumberOfSegments(self, nbSeg):
+ lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
+ nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
+ StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
+ StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
+
+ ## Set Scale Factor parameter value
+ # @param factor numerical value or name of variable from notebook
+ def SetScaleFactor(self, factor):
+ factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
+ StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
+ StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
+
+#Registering the new proxy for NumberOfSegments
+omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
+
+
+#Wrapper class for NETGENPlugin_Hypothesis hypothesis
+class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
+
+ ## Set Max Size parameter value
+ # @param maxsize numerical value or name of variable from notebook
+ def SetMaxSize(self, maxsize):
+ lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
+ maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
+ NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
+ NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
+
+ ## Set Growth Rate parameter value
+ # @param value numerical value or name of variable from notebook
+ def SetGrowthRate(self, value):
+ lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
+ value, parameters = ParseParameters(lastParameters,4,2,value)
+ NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
+ NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
+
+ ## Set Number of Segments per Edge parameter value
+ # @param value numerical value or name of variable from notebook
+ def SetNbSegPerEdge(self, value):
+ lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
+ value, parameters = ParseParameters(lastParameters,4,3,value)
+ NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
+ NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
+
+ ## Set Number of Segments per Radius parameter value
+ # @param value numerical value or name of variable from notebook
+ def SetNbSegPerRadius(self, value):
+ lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
+ value, parameters = ParseParameters(lastParameters,4,4,value)
+ NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
+ NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
+
+#Registering the new proxy for NETGENPlugin_Hypothesis
+omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
+
+
+#Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
+class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
+ pass
+
+#Registering the new proxy for NETGENPlugin_Hypothesis_2D
+omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
+
+#Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
+class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
+
+ ## Set Number of Segments parameter value
+ # @param nbSeg numerical value or name of variable from notebook
+ def SetNumberOfSegments(self, nbSeg):
+ lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
+ nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
+ NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
+ NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
+
+ ## Set Local Length parameter value
+ # @param length numerical value or name of variable from notebook
+ def SetLocalLength(self, length):
+ lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
+ length, parameters = ParseParameters(lastParameters,2,1,length)
+ NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
+ NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
+
+ ## Set Max Element Area parameter value
+ # @param area numerical value or name of variable from notebook
+ def SetMaxElementArea(self, area):
+ lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
+ area, parameters = ParseParameters(lastParameters,2,2,area)
+ NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
+ NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
+
+ def LengthFromEdges(self):
+ lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
+ value = 0;
+ value, parameters = ParseParameters(lastParameters,2,2,value)
+ NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
+ NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
+
+#Registering the new proxy for NETGEN_SimpleParameters_2D
+omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
+
+
+#Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
+class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
+ ## Set Max Element Volume parameter value
+ # @param volume numerical value or name of variable from notebook
+ def SetMaxElementVolume(self, volume):
+ lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
+ volume, parameters = ParseParameters(lastParameters,3,3,volume)
+ NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
+ NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
+
+ def LengthFromFaces(self):
+ lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
+ value = 0;
+ value, parameters = ParseParameters(lastParameters,3,3,value)
+ NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
+ NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
+
+#Registering the new proxy for NETGEN_SimpleParameters_3D
+omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
+
+class Pattern(SMESH._objref_SMESH_Pattern):
+
+ def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
+ flag = False
+ if isinstance(theNodeIndexOnKeyPoint1,str):
+ flag = True
+ theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
+ if flag:
+ theNodeIndexOnKeyPoint1 -= 1
+ theMesh.SetParameters(Parameters)
+ return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
+
+ def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
+ flag0 = False
+ flag1 = False
+ if isinstance(theNode000Index,str):
+ flag0 = True
+ if isinstance(theNode001Index,str):
+ flag1 = True
+ theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
+ if flag0:
+ theNode000Index -= 1
+ if flag1:
+ theNode001Index -= 1
+ theMesh.SetParameters(Parameters)
+ return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
+
+#Registering the new proxy for Pattern
+omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)
#include "StdMeshersGUI_DistrTable.h"
#include "StdMeshersGUI_DistrPreview.h"
+#include <SMESHGUI.h>
#include <SMESHGUI_Utils.h>
#include <SMESHGUI_HypothesesUtils.h>
#include <SMESHGUI_SpinBox.h>
// SALOME GUI includes
#include <SalomeApp_Tools.h>
-#include <QtxIntSpinBox.h>
+#include <SalomeApp_IntSpinBox.h>
#include <QtxComboBox.h>
// Qt includes
{
}
-bool StdMeshersGUI_NbSegmentsCreator::checkParams() const
+bool StdMeshersGUI_NbSegmentsCreator::checkParams( QString& msg ) const
{
+ if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
+ return false;
NbSegmentsHypothesisData data_old, data_new;
readParamsFromHypo( data_old );
readParamsFromWidgets( data_new );
bool res = storeParamsToHypo( data_new );
storeParamsToHypo( data_old );
+ res = myNbSeg->isValid( msg, true ) && res;
+ res = myScale->isValid( msg, true ) && res;
return res;
}
// 1) number of segments
myGroupLayout->addWidget( new QLabel( tr( "SMESH_NB_SEGMENTS_PARAM" ), GroupC1 ), row, 0 );
- myNbSeg = new QtxIntSpinBox( GroupC1 );
+ myNbSeg = new SalomeApp_IntSpinBox( GroupC1 );
myNbSeg->setMinimum( 1 );
myNbSeg->setMaximum( 9999 );
myGroupLayout->addWidget( myNbSeg, row, 1 );
if( myName )
myName->setText( data.myName );
- myNbSeg->setValue( data.myNbSeg );
+ if(data.myNbSegVarName.isEmpty())
+ myNbSeg->setValue( data.myNbSeg );
+ else
+ myNbSeg->setText( data.myNbSegVarName );
+
myDistr->setCurrentIndex( data.myDistrType );
- myScale->setValue( data.myScale );
+ if(data.myScaleVarName.isEmpty())
+ myScale->setValue( data.myScale );
+ else
+ myScale->setText( data.myScaleVarName );
myConv->button( data.myConv )->setChecked( true );
myTable->setFuncMinValue(myConv->checkedId()==0 ? -1E20 : 0);
myTable->setData( data.myTable );
NbSegmentsHypothesisData data;
readParamsFromWidgets( data );
storeParamsToHypo( data );
-
+
QString valStr = QString::number( data.myNbSeg ) += "; ";
enum DistrType
case Regular :
valStr += tr("SMESH_DISTR_REGULAR");
break;
- case Scale :
- valStr += tr("SMESH_NB_SEGMENTS_SCALE_PARAM") + " = " + QString::number( data.myScale );
+ case Scale :
+ valStr += tr("SMESH_NB_SEGMENTS_SCALE_PARAM") + " = " + QString::number( data.myScale );\
break;
case TabFunc : {
//valStr += tr("SMESH_TAB_FUNC");
h_data.myName = hypName();
h_data.myNbSeg = (int) h->GetNumberOfSegments();
+
+ SMESH::ListOfParameters_var aParameters = h->GetLastParameters();
+
+ h_data.myNbSegVarName = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString("");
+
int distr = (int) h->GetDistrType();
h_data.myDistrType = distr;
h_data.myScale = distr==1 ? h->GetScaleFactor() : 1.0;
+
+ if(distr==1){
+ h_data.myScaleVarName = (aParameters->length() > 1) ? QString(aParameters[1].in()) : QString("");
+ }
+ else
+ h_data.myScaleVarName = QString("");
+
if( distr==2 )
{
SMESH::double_array* a = h->GetTableFunction();
if( isCreation() )
SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().data() );
+ QStringList aVariablesList;
+ aVariablesList.append(h_data.myNbSegVarName);
+
h->SetNumberOfSegments( h_data.myNbSeg );
int distr = h_data.myDistrType;
h->SetDistrType( distr );
-
- if( distr==1 )
+
+ if( distr==1 ) {
h->SetScaleFactor( h_data.myScale );
-
+ aVariablesList.append(h_data.myScaleVarName);
+ }
if( distr==2 || distr==3 )
h->SetConversionMode( h_data.myConv );
//setting of function must follow after setConversionMode, because otherwise
//the function will be checked with old conversion mode, so that it may occurs
//unexpected errors for user
+
+ h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
}
catch(const SALOME::SALOME_Exception& ex)
{
{
h_data.myName = myName ? myName->text() : "";
h_data.myNbSeg = myNbSeg->value();
+ h_data.myNbSegVarName = myNbSeg->text();
+ h_data.myScaleVarName = myScale->text();
h_data.myDistrType = myDistr->currentIndex();
h_data.myConv = myConv->checkedId();
h_data.myScale = myScale->value();
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
-class QtxIntSpinBox;
+class SalomeApp_IntSpinBox;
class QtxComboBox;
class SMESHGUI_SpinBox;
class StdMeshersGUI_DistrTableFrame;
double myScale;
SMESH::double_array myTable;
QString myName, myExpr;
+ QString myNbSegVarName, myScaleVarName;
} NbSegmentsHypothesisData;
StdMeshersGUI_NbSegmentsCreator();
virtual ~StdMeshersGUI_NbSegmentsCreator();
- virtual bool checkParams() const;
+ virtual bool checkParams( QString& ) const;
protected:
virtual QFrame* buildFrame();
bool storeParamsToHypo( const NbSegmentsHypothesisData& ) const;
private:
- QtxIntSpinBox* myNbSeg;
+ SalomeApp_IntSpinBox* myNbSeg;
QtxComboBox* myDistr;
SMESHGUI_SpinBox* myScale;
StdMeshersGUI_DistrTableFrame* myTable;
#include <SMESH_NumberFilter.hxx>
#include <StdMeshersGUI_ObjectReferenceParamWdg.h>
#include <StdMeshersGUI_LayerDistributionParamWdg.h>
+#include <SALOMEDSClient_Study.hxx>
// SALOME GUI includes
#include <SUIT_ResourceMgr.h>
*/
//================================================================================
-bool StdMeshersGUI_StdHypothesisCreator::checkParams() const
+bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
{
+ if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
+ return false;
+
// check if object reference parameter is set, as it has no default value
bool ok = true;
if ( hypType().startsWith("ProjectionSource" ))
}
QString valueStr = stdParamValues( params );
+ QStringList aVariablesList = getVariablesFromDlg();
if( res && !params.isEmpty() )
{
StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
h->SetLength( params[0].myValue.toDouble() );
+ h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
h->SetPrecision( params[1].myValue.toDouble() );
+ h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
}
else if( hypType()=="MaxLength" )
{
StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
h->SetLength( params[0].myValue.toDouble() );
+ h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
}
else if( hypType()=="Arithmetic1D" )
{
StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
h->SetLength( params[0].myValue.toDouble(), true );
+ h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
h->SetLength( params[1].myValue.toDouble(), false );
+ h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
}
else if( hypType()=="MaxElementArea" )
{
StdMeshers::StdMeshers_MaxElementArea_var h =
StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
-
+ h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
h->SetMaxElementArea( params[0].myValue.toDouble() );
}
else if( hypType()=="MaxElementVolume" )
StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
h->SetMaxElementVolume( params[0].myValue.toDouble() );
+ h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
}
else if( hypType()=="StartEndLength" )
{
StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
h->SetLength( params[0].myValue.toDouble(), true );
+ h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
h->SetLength( params[1].myValue.toDouble(), false );
+ h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
}
else if( hypType()=="Deflection1D" )
{
StdMeshers::StdMeshers_Deflection1D_var h =
StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
-
+ h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
h->SetDeflection( params[0].myValue.toDouble() );
}
else if( hypType()=="AutomaticLength" )
StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
h->SetNumberOfLayers( params[0].myValue.toInt() );
+ h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
}
else if( hypType()=="LayerDistribution" )
{
StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
StdMeshersGUI_LayerDistributionParamWdg* w =
widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
-
+
h->SetLayerDistribution( w->GetHypothesis() );
+ h->SetParameters(w->GetHypothesis()->GetParameters());
+ w->GetHypothesis()->ClearParameters();
}
else if( hypType()=="ProjectionSource1D" )
{
p.append( item );
customWidgets()->append(0);
}
-
+
SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
+ SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
if( hypType()=="LocalLength" )
{
StdMeshers::StdMeshers_LocalLength_var h =
StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
-
+
item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
- item.myValue = h->GetLength();
- p.append( item );
+ if(!initVariableName(aParameters,item,0))
+ item.myValue = h->GetLength();
+ p.append( item );
+
item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
- item.myValue = h->GetPrecision();
+ if(!initVariableName(aParameters,item,1))
+ item.myValue = h->GetPrecision();
p.append( item );
+
}
else if( hypType()=="MaxLength" )
{
StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
- item.myValue = h->GetLength();
+ if(!initVariableName(aParameters,item,0))
+ item.myValue = h->GetLength();
+
p.append( item );
}
else if( hypType()=="Arithmetic1D" )
StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
item.myName = tr( "SMESH_START_LENGTH_PARAM" );
- item.myValue = h->GetLength( true );
+ if(!initVariableName(aParameters,item,0))
+ item.myValue = h->GetLength( true );
p.append( item );
+
item.myName = tr( "SMESH_END_LENGTH_PARAM" );
- item.myValue = h->GetLength( false );
+ if(!initVariableName(aParameters,item,1))
+ item.myValue = h->GetLength( false );
p.append( item );
}
else if( hypType()=="MaxElementArea" )
StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
- item.myValue = h->GetMaxElementArea();
+ if(!initVariableName(aParameters,item,0))
+ item.myValue = h->GetMaxElementArea();
p.append( item );
+
}
else if( hypType()=="MaxElementVolume" )
{
StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
- item.myValue = h->GetMaxElementVolume();
+ if(!initVariableName(aParameters,item,0))
+ item.myValue = h->GetMaxElementVolume();
p.append( item );
}
else if( hypType()=="StartEndLength" )
StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
item.myName = tr( "SMESH_START_LENGTH_PARAM" );
- item.myValue = h->GetLength( true );
+
+ if(!initVariableName(aParameters,item,0))
+ item.myValue = h->GetLength( true );
p.append( item );
+
item.myName = tr( "SMESH_END_LENGTH_PARAM" );
- item.myValue = h->GetLength( false );
+ if(!initVariableName(aParameters,item,1))
+ item.myValue = h->GetLength( false );
p.append( item );
+
}
else if( hypType()=="Deflection1D" )
{
StdMeshers::StdMeshers_Deflection1D_var h =
StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
-
+
item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
- item.myValue = h->GetDeflection();
+ if(!initVariableName(aParameters,item,0))
+ item.myValue = h->GetDeflection();
p.append( item );
}
else if( hypType()=="AutomaticLength" )
StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
- item.myValue = (int) h->GetNumberOfLayers();
+ if(!initVariableName(aParameters,item,0))
+ item.myValue = (int) h->GetNumberOfLayers();
p.append( item );
}
else if( hypType()=="LayerDistribution" )
- {
- StdMeshers::StdMeshers_LayerDistribution_var h =
+ {
+ StdMeshers::StdMeshers_LayerDistribution_var h =
StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
+
+ //Set into not published hypo last variables
+ QStringList aLastVarsList;
+ for(int i = 0;i<aParameters->length();i++)
+ aLastVarsList.append(QString(aParameters[i].in()));
+
+ if(!aLastVarsList.isEmpty())
+ h->GetLayerDistribution()->SetLastParameters(SMESHGUI::JoinObjectParameters(aLastVarsList));
+
customWidgets()->append
( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
}
}
}
}
+
+//================================================================================
+/*!
+ *
+ */
+//================================================================================
+
+bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::ListOfParameters_var theParameters,
+ StdParam &theParams,
+ int order) const
+{
+ QString aVaribaleName = (theParameters->length() > order) ? QString(theParameters[order].in()) : QString("");
+ theParams.isVariable = !aVaribaleName.isEmpty();
+ if(theParams.isVariable)
+ theParams.myValue = aVaribaleName;
+
+ return theParams.isVariable;
+}
// SMESH includes
#include "SMESH_StdMeshersGUI.hxx"
-
#include <SMESHGUI_Hypotheses.h>
+
/*!
* \brief Class for creation of standard hypotheses
*/
StdMeshersGUI_StdHypothesisCreator( const QString& );
virtual ~StdMeshersGUI_StdHypothesisCreator();
- virtual bool checkParams() const;
+ virtual bool checkParams( QString& ) const;
protected:
virtual QFrame* buildFrame ();
virtual QWidget* getWidgetForParam( int paramIndex ) const;
virtual ListOfWidgets* customWidgets() const;
virtual void onReject();
+ virtual bool initVariableName(SMESH::ListOfParameters_var theParameters, StdParam& theParams, int order) const;
virtual void valueChanged( QWidget* );