From: eap Date: Mon, 17 Sep 2018 19:24:36 +0000 (+0300) Subject: 23586: [EDF] HYDRO: Copy mesh to new geometry X-Git-Tag: V9_2_0a1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=6df8817c1a9827149025cc942249d7083f504d3d 23586: [EDF] HYDRO: Copy mesh to new geometry --- diff --git a/doc/salome/gui/SMESH/images/copy_mesh_dlg.png b/doc/salome/gui/SMESH/images/copy_mesh_dlg.png index c959e680f..97ca1cac7 100644 Binary files a/doc/salome/gui/SMESH/images/copy_mesh_dlg.png and b/doc/salome/gui/SMESH/images/copy_mesh_dlg.png differ diff --git a/doc/salome/gui/SMESH/input/copy_mesh.rst b/doc/salome/gui/SMESH/input/copy_mesh.rst index 7d49ed37b..501352a00 100644 --- a/doc/salome/gui/SMESH/input/copy_mesh.rst +++ b/doc/salome/gui/SMESH/input/copy_mesh.rst @@ -4,7 +4,10 @@ Copy Mesh ********* -A mesh can be created by copying a part of or the whole other mesh. +A mesh can be created by copying a part of or the whole other mesh. There are two modes of the operation: + +* copy mesh elements only; +* copy mesh definition to another geometry. This mode can be used only if the source mesh is based on geometry. It is supposed that the new geometry is a modified geometry of the source mesh. *To make a copy of a mesh:* @@ -20,6 +23,7 @@ The following dialog box will appear: In the dialog: +* select the mode of the operation. * specify the part of mesh to copy: * **Select whole mesh, sub-mesh or group** by mouse activating this checkbox; or @@ -28,12 +32,16 @@ In the dialog: * apply Filters. **Set filter** button allows to apply a filter to the selection of elements. See more about filters in the :ref:`selection_filter_library_page` page. * specify the **New Mesh Name**; +* select the **New Geometry**; * specify the conditions of copying: - * activate **Generate groups** checkbox to copy the groups of the source mesh to the newly created mesh. + * activate **Generate groups** check-box to copy the groups of the source mesh to the newly created mesh. In the mode of copying to new geometry, standalone groups are copied only if **Copy Mesh Elements** is activated. + * activate **Reuse hypotheses** check-box to use hypotheses applied to the source mesh in the new mesh. Hypotheses having parameters defined as sub-shapes will be copied independently of this check-box state. + * activate **Copy Mesh Element** to copy mesh elements of sub-shapes that are not modified. * Click **Apply** or **Apply and Close** button to confirm the operation. +When copying the mesh to the new geometry, it can happen that a sub-shape used to define a sub-mesh, group or hypotheses is not found in the new geometry. In this case a new object depending on the not found sub-shape is marked with red color in the Object Browser in order to allow identifying such objects and to fix them, either by modifying their definition or by removing. If a depending object is a group on geometry, a standalone group is created instead. You can't transform it to a group on geometry, it can only be removed and re-created anew. **See Also** a sample script of :ref:`tui_copy_mesh`. diff --git a/idl/SMESH_Gen.idl b/idl/SMESH_Gen.idl index 81e4a48cc..29158a831 100644 --- a/idl/SMESH_Gen.idl +++ b/idl/SMESH_Gen.idl @@ -280,6 +280,37 @@ module SMESH in boolean toKeepIDs) raises ( SALOME::SALOME_Exception ); + /*! + * Create a mesh by copying definitions of another mesh to a given geometry + * \param sourceMesh - a mesh to copy + * \param newGeometry - a new geometry + * \param meshName - a name of the new mesh + * \param toCopyGroups - to create groups in the new mesh + * \param toReuseHypotheses - if True, existing hypothesis will be used by the new mesh, + * otherwise new hypotheses with the same parameters will be created for the new mesh. + * \param toCopyElements - to copy mesh elements of same sub-shapes of the two geometries + * \param newMesh - return a new mesh + * \param newGroups - return new groups + * \param newSubmeshes - return new sub-meshes + * \param newHypotheses - return new algorithms and hypotheses + * \param invalidEntries - return study entries of objects whose + * counterparts are not found in the newGeometry, followed by entries + * of mesh sub-objects that are invalid because they depend on a not found + * preceeding sub-shape + */ + boolean CopyMeshWithGeom( in SMESH_Mesh sourceMesh, + in GEOM::GEOM_Object newGeometry, + in string meshName, + in boolean toCopyGroups, + in boolean toReuseHypotheses, + in boolean toCopyElements, + out SMESH_Mesh newMesh, + out ListOfGroups newGroups, + out submesh_array newSubmeshes, + out ListOfHypothesis newHypotheses, + out string_array invalidEntries) + raises ( SALOME::SALOME_Exception ); + /*! * Concatenate the given meshes or groups into one mesh. * Union groups with the same name and type if diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index ab8792bc1..3bd0b5e78 100755 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -196,6 +196,7 @@ SET(SMESH_RESOURCES_FILES mesh_tree_hypo_quadratic.png mesh_build_compound.png copy_mesh.png + copy_mesh_with_geom.png mesh_node_to_point.png mesh_tree_mesh_partial.png mesh_extractGroup.png diff --git a/resources/copy_mesh_with_geom.png b/resources/copy_mesh_with_geom.png new file mode 100644 index 000000000..87bfba814 Binary files /dev/null and b/resources/copy_mesh_with_geom.png differ diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index dcdb4f0ac..4ee7e09c0 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -1193,8 +1193,8 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h if ( !GetMeshDS()->IsUsedHypothesis( hyp )) return; - if (_callUp) - _callUp->HypothesisModified(); + if (_callUp && hyp) + _callUp->HypothesisModified( hyp->GetID() ); SMESH_Algo *algo; const SMESH_HypoFilter* compatibleHypoKind; diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index c52b5ef2e..dbe14fed8 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -334,7 +334,7 @@ class SMESH_EXPORT SMESH_Mesh struct TCallUp // callback from SMESH to SMESH_I level { virtual void RemoveGroup (const int theGroupID)=0; - virtual void HypothesisModified ()=0; + virtual void HypothesisModified (int theHypID)=0; virtual void Load ()=0; virtual ~TCallUp() {} }; diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index 7bab8d9e7..8ef0c8827 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -365,7 +365,7 @@ int SMESH_subMesh::computeCost() const */ //============================================================================= -const map < int, SMESH_subMesh * >& SMESH_subMesh::DependsOn() +const std::map < int, SMESH_subMesh * >& SMESH_subMesh::DependsOn() { if ( _dependenceAnalysed || !_father->HasShapeToMesh() ) return _mapDepend; diff --git a/src/SMESHGUI/SMESHGUI_CopyMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_CopyMeshDlg.cxx index 4dabf6c90..b7794c02d 100644 --- a/src/SMESHGUI/SMESHGUI_CopyMeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_CopyMeshDlg.cxx @@ -24,32 +24,34 @@ #include "SMESHGUI_CopyMeshDlg.h" #include "SMESHGUI.h" +#include "SMESHGUI_FilterDlg.h" +#include "SMESHGUI_GEOMGenUtils.h" +#include "SMESHGUI_IdValidator.h" +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_Selection.h" #include "SMESHGUI_SpinBox.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" -#include "SMESHGUI_MeshUtils.h" -#include "SMESHGUI_IdValidator.h" -#include "SMESHGUI_FilterDlg.h" #include #include #include // SALOME GUI includes +#include +#include +#include #include -#include -#include #include #include - -#include -#include - +#include +#include #include #include -#include +#include // SALOME KERNEL includes +#include #include // OCCT includes @@ -113,7 +115,8 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule ) myFilterDlg(0), myIsApplyAndClose( false ) { - QPixmap image (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_COPY_MESH"))); + QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_COPY_MESH"))); + QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_COPY_MESH_WG"))); setModal(false); setAttribute(Qt::WA_DeleteOnClose, true); @@ -126,18 +129,21 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule ) /***************************************************************/ ConstructorsBox = new QGroupBox(tr("SMESH_COPY_MESH_TITLE"), this); - QButtonGroup* GroupConstructors = new QButtonGroup(this); + GroupConstructors = new QButtonGroup(this); QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox); ConstructorsBoxLayout->setSpacing(SPACING); ConstructorsBoxLayout->setMargin(MARGIN); QRadioButton* RadioButton1= new QRadioButton(ConstructorsBox); - RadioButton1->setIcon(image); + RadioButton1->setIcon(image1); GroupConstructors->addButton(RadioButton1, 0); + QRadioButton* RadioButton2= new QRadioButton(ConstructorsBox); + RadioButton2->setIcon(image2); + GroupConstructors->addButton(RadioButton2, 1); ConstructorsBoxLayout->addWidget(RadioButton1); + ConstructorsBoxLayout->addWidget(RadioButton2); RadioButton1->setChecked(true); - GroupConstructors->addButton(RadioButton1, 0); /***************************************************************/ GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this); @@ -164,13 +170,26 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule ) // CheckBox for copying groups myCopyGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments); - myCopyGroupsCheck->setChecked(false); + myCopyGroupsCheck->setChecked(true); // CheckBox for keeping ids ( OBSOLETE ) myKeepIdsCheck = new QCheckBox(tr("SMESH_KEEP_IDS"), GroupArguments); myKeepIdsCheck->setChecked(true); myKeepIdsCheck->hide(); + // New geometry + myGeomLabel = new QLabel( tr("NEW_GEOM"), GroupArguments ); + myGeomNameEdit = new QLineEdit( GroupArguments ); + myGeomNameEdit->setReadOnly(true); + + // CheckBox to reuse hypotheses + myReuseHypCheck = new QCheckBox(tr("REUSE_HYPOTHESES"), GroupArguments); + myReuseHypCheck->setChecked(true); + + // CheckBox to copy mesh elements + myCopyElementsCheck = new QCheckBox(tr("COPY_ELEMENTS"), GroupArguments); + myCopyElementsCheck->setChecked(true); + // layout GroupArgumentsLayout->addWidget(myTextLabelElements, 0, 0); GroupArgumentsLayout->addWidget(myLineEditElements, 0, 1, 1, 5); @@ -178,8 +197,13 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule ) GroupArgumentsLayout->addWidget(myIdSourceCheck, 1, 0, 1, 6); GroupArgumentsLayout->addWidget(meshNameLabel, 2, 0); GroupArgumentsLayout->addWidget(myMeshNameEdit, 2, 1, 1, 5); - GroupArgumentsLayout->addWidget(myCopyGroupsCheck, 3, 0, 1, 6); - // GroupArgumentsLayout->addWidget(myKeepIdsCheck, 4, 0, 1, 6); + GroupArgumentsLayout->addWidget(myGeomLabel, 3, 0); + GroupArgumentsLayout->addWidget(myGeomNameEdit, 3, 1, 1, 5); + GroupArgumentsLayout->addWidget(myCopyGroupsCheck, 4, 0, 1, 6); + GroupArgumentsLayout->addWidget(myReuseHypCheck, 5, 0, 1, 6); + GroupArgumentsLayout->addWidget(myCopyElementsCheck, 6, 0, 1, 6); + // GroupArgumentsLayout->addWidget(myKeepIdsCheck, 7, 0, 1, 6); + GroupArgumentsLayout->setRowStretch( 6, 1 ); /***************************************************************/ GroupButtons = new QGroupBox(this); @@ -243,6 +267,9 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule ) this, SLOT (onTextChange(const QString&))); connect(myIdSourceCheck, SIGNAL(toggled(bool)), this, SLOT (onSelectIdSource(bool))); + connect(GroupConstructors, SIGNAL(buttonClicked(int)), + this, SLOT (onConstructor(int))); + SelectionIntoArgument(); } @@ -275,11 +302,12 @@ void SMESHGUI_CopyMeshDlg::Init (bool ResetControls) { myBusy = false; - myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh")); + if ( !isWithGeomMode() ) + myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh")); + if ( ResetControls ) { myLineEditElements->clear(); - //myElementsId = ""; myNbOkElements = 0; buttonOk->setEnabled(false); @@ -289,11 +317,98 @@ void SMESHGUI_CopyMeshDlg::Init (bool ResetControls) myMesh = SMESH::SMESH_Mesh::_nil(); myIdSourceCheck->setChecked(true); - myCopyGroupsCheck->setChecked(false); - myKeepIdsCheck->setChecked(false); - onSelectIdSource( myIdSourceCheck->isChecked() ); + onConstructor( 0 ); + } +} + +//======================================================================= +//function : onConstructor +//purpose : switch operation mode +//======================================================================= + +void SMESHGUI_CopyMeshDlg::onConstructor( int withGeom ) +{ + myGeomLabel ->setVisible( withGeom ); + myGeomNameEdit ->setVisible( withGeom ); + myReuseHypCheck ->setVisible( withGeom ); + myCopyElementsCheck->setVisible( withGeom ); + myFilterBtn ->setVisible( !withGeom ); + myIdSourceCheck ->setVisible( !withGeom ); + + if ( !withGeom ) + myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh")); + + onSelectIdSource( /*toSelectMesh=*/ myIdSourceCheck->isChecked() || withGeom ); +} + +//======================================================================= +//function : getErrorMsg +//purpose : Return an error message and entries of invalid smesh object +//======================================================================= + +QString SMESHGUI_CopyMeshDlg::getErrorMsg( SMESH::string_array_var theInvalidEntries, + QStringList & theEntriesToBrowse ) +{ + if ( theInvalidEntries->length() == 0 ) + return tr("SMESH_OPERATION_FAILED"); + + // theInvalidEntries - SObject's that hold geometry objects whose + // counterparts are not found in the newGeometry, followed by SObject's + // holding mesh sub-objects that are invalid because they depend on a not found + // preceeding sub-shape + + QString msg = tr("SUBSHAPES_NOT_FOUND_MSG") + "\n"; + + QString objString; + for ( CORBA::ULong i = 0; i < theInvalidEntries->length(); ++i ) + { + _PTR(SObject) so = SMESH::getStudy()->FindObjectID( theInvalidEntries[i].in() ); + + int objType = SMESHGUI_Selection::type( theInvalidEntries[i].in() ); + if ( objType < 0 ) // geom object + { + objString += "\n"; + if ( so ) + objString += so->GetName().c_str(); + else + objString += theInvalidEntries[i].in(); // it's something like "FACE #2" + } + else // smesh object + { + theEntriesToBrowse.push_back( theInvalidEntries[i].in() ); + + objString += "\n "; + switch ( objType ) { + case SMESH::MESH: + objString += tr("SMESH_MESH"); break; + case SMESH::HYPOTHESIS: + objString += tr("SMESH_HYPOTHESIS"); break; + case SMESH::ALGORITHM: + objString += tr("SMESH_ALGORITHM"); break; + case SMESH::SUBMESH_VERTEX: + case SMESH::SUBMESH_EDGE: + case SMESH::SUBMESH_FACE: + case SMESH::SUBMESH_SOLID: + case SMESH::SUBMESH_COMPOUND: + case SMESH::SUBMESH: + objString += tr("SMESH_SUBMESH"); break; + case SMESH::GROUP: + objString += tr("SMESH_GROUP"); break; + default:; + } + objString += " \""; + if ( so ) + objString += so->GetName().c_str(); + objString += "\" ("; + objString += theInvalidEntries[i].in(); + objString += ")"; + } } + if ( !objString.isEmpty() ) + msg += objString; + + return msg; } //================================================================================= @@ -303,13 +418,14 @@ void SMESHGUI_CopyMeshDlg::Init (bool ResetControls) bool SMESHGUI_CopyMeshDlg::ClickOnApply() { - if (SMESHGUI::isStudyLocked()) + if ( SMESHGUI::isStudyLocked() ) return false; if( !isValid() ) return false; QStringList anEntryList; + bool toShowObjects = isApplyAndClose(); try { SUIT_OverrideCursor aWaitCursor; @@ -333,16 +449,55 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply() } QByteArray meshName = myMeshNameEdit->text().toUtf8(); bool toCopyGroups = ( myCopyGroupsCheck->isChecked() ); + bool toReuseHyps = ( myReuseHypCheck->isChecked() ); + bool toCopyElems = ( myCopyElementsCheck->isChecked() ); bool toKeepIDs = ( myKeepIdsCheck->isChecked() ); SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGen(); - SMESH::SMESH_Mesh_var newMesh = - gen->CopyMesh(aPartToCopy, meshName.constData(), toCopyGroups, toKeepIDs); - if( !newMesh->_is_nil() ) - if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) ) + SMESH::SMESH_Mesh_var newMesh; + if ( isWithGeomMode() ) + { + SMESH::SMESH_Mesh_var srcMesh = mySelectedObject->GetMesh(); + SMESH::ListOfGroups_var newGroups; + SMESH::submesh_array_var newSubmeshes; + SMESH::ListOfHypothesis_var newHypotheses; + SMESH::string_array_var invalidEntries; + CORBA::Boolean ok = gen->CopyMeshWithGeom( srcMesh, myNewGeometry, + meshName.constData(), + toCopyGroups, toReuseHyps, toCopyElems, + newMesh.out(), + newGroups.out(), + newSubmeshes.out(), + newHypotheses.out(), + invalidEntries.out() ); + if ( !ok ) + { + if ( invalidEntries->length() > 0 ) + toShowObjects = true; + SUIT_MessageBox::warning( this, + tr("SMESH_WRN_WARNING"), + getErrorMsg( invalidEntries, anEntryList )); + } + } + else + { + newMesh = gen->CopyMesh(aPartToCopy, meshName.constData(), toCopyGroups, toKeepIDs); + } + if ( !newMesh->_is_nil() ) + if ( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) ) + { anEntryList.append( aSObject->GetID().c_str() ); + + if ( isWithGeomMode() ) + SMESH::SetName( aSObject, meshName ); + } } - catch (...) { + catch(const SALOME::SALOME_Exception & S_ex) + { + SalomeApp_Tools::QtCatchCorbaException(S_ex); + } + catch (...) + { } mySMESHGUI->updateObjBrowser(true); @@ -350,7 +505,7 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply() if( LightApp_Application* anApp = dynamic_cast( SUIT_Session::session()->activeApplication() ) ) - anApp->browseObjects( anEntryList, isApplyAndClose() ); + anApp->browseObjects( anEntryList, toShowObjects ); Init(false); mySelectedObject = SMESH::SMESH_IDSource::_nil(); @@ -503,13 +658,12 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument() myActor = 0; QString aString = ""; - myLineEditElements->setText(aString); myNbOkElements = 0; buttonOk->setEnabled(false); buttonApply->setEnabled(false); myFilterBtn->setEnabled(false); - // get selected mesh + // get selected mesh or geometry SALOME_ListIO aList; mySelectionMgr->selectedObjects(aList); int nbSel = aList.Extent(); @@ -517,19 +671,29 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument() return; Handle(SALOME_InteractiveObject) IO = aList.First(); - mySelectedObject = SMESH::IObjectToInterface( IO ); - if ( mySelectedObject->_is_nil() ) - return; - myMesh = SMESH::GetMeshByIO(IO); - if (myMesh->_is_nil()) - return; + SMESH::SMESH_Mesh_var mesh = SMESH::GetMeshByIO(IO); + GEOM::GEOM_Object_var geom = SMESH::GetGeom(IO); - myActor = SMESH::FindActorByEntry(IO->getEntry()); - if (!myActor) - myActor = SMESH::FindActorByObject(myMesh); + if ( !mesh->_is_nil() ) + { + myMesh = mesh; + myActor = SMESH::FindActorByEntry(IO->getEntry()); + if (!myActor) + myActor = SMESH::FindActorByObject(myMesh); + + mySelectedObject = SMESH::IObjectToInterface( IO ); + if ( mySelectedObject->_is_nil() ) + return; + } + else if ( !geom->_is_nil() ) + { + myNewGeometry = geom; + } + else + return; - if (myIdSourceCheck->isChecked()) + if (myIdSourceCheck->isChecked() || isWithGeomMode() ) { SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString ); if ( aString.isEmpty() ) aString = " "; @@ -541,8 +705,23 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument() myNbOkElements = aString.size(); myFilterBtn->setEnabled(true); } - myLineEditElements->setText( aString ); + bool ok = !aString.isEmpty(); + if ( !mesh->_is_nil() ) + { + myLineEditElements->setText( aString ); + if ( isWithGeomMode() ) + myMeshNameEdit->setText( aString ); + } + else if ( !geom->_is_nil() ) + { + myGeomNameEdit->setText( aString ); + ok = ok && !myLineEditElements->text().isEmpty(); + } + + if ( ok && isWithGeomMode() && !myMesh->_is_nil() ) + ok = myMesh->HasShapeToMesh(); + buttonOk->setEnabled(ok); buttonApply->setEnabled(ok); @@ -554,7 +733,9 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument() //======================================================================= void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh) { - if (toSelectMesh) + if ( isWithGeomMode() ) + myTextLabelElements->setText(tr("SMESH_MESH")); + else if ( toSelectMesh ) myTextLabelElements->setText(tr("OBJECT_NAME")); else myTextLabelElements->setText(tr("ELEM_IDS")); @@ -564,7 +745,8 @@ void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh) } mySelectionMgr->clearFilters(); - mySelectionMgr->installFilter(myIdSourceFilter); + if ( !isWithGeomMode() ) + mySelectionMgr->installFilter(myIdSourceFilter); SMESH::SetPointRepresentation(false); if (toSelectMesh) { @@ -592,10 +774,29 @@ void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh) bool SMESHGUI_CopyMeshDlg::isValid() { - if ( myIdSourceCheck->isChecked() ) - return !mySelectedObject->_is_nil(); + bool ok = false; + if ( myIdSourceCheck->isChecked() || isWithGeomMode() ) + { + ok = ( !mySelectedObject->_is_nil() ); + if ( isWithGeomMode() ) + ok = ok && ( !myNewGeometry->_is_nil() ); + } + else + { + ok = ( myNbOkElements > 0 ); + } + + return ok; +} - return myNbOkElements > 0; +//======================================================================= +//function : isWithGeomMode +//purpose : Return true if the mode is "with geometry" +//======================================================================= + +bool SMESHGUI_CopyMeshDlg::isWithGeomMode() +{ + return ( GroupConstructors->checkedId() == 1 ); } //================================================================================= diff --git a/src/SMESHGUI/SMESHGUI_CopyMeshDlg.h b/src/SMESHGUI/SMESHGUI_CopyMeshDlg.h index fe4a8f1a9..2566e7aa6 100644 --- a/src/SMESHGUI/SMESHGUI_CopyMeshDlg.h +++ b/src/SMESHGUI/SMESHGUI_CopyMeshDlg.h @@ -35,12 +35,14 @@ // IDL includes #include #include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SMESH_Gen) class QCheckBox; class QGroupBox; class QLabel; class QLineEdit; class QPushButton; +class QButtonGroup; class SMESHGUI; class SMESHGUI_IdValidator; @@ -56,10 +58,10 @@ class SUIT_SelectionFilter; //================================================================================= class SMESHGUI_EXPORT SMESHGUI_CopyMeshDlg : public QDialog -{ +{ Q_OBJECT -public: + public: SMESHGUI_CopyMeshDlg( SMESHGUI* ); ~SMESHGUI_CopyMeshDlg(); @@ -67,10 +69,12 @@ private: void Init( bool = true ); void enterEvent( QEvent* ); /* mouse enter the QWidget */ void keyPressEvent( QKeyEvent* ); - int GetConstructorId(); void setNewMeshName(); + QString getErrorMsg( SMESH::string_array_var invalidEntries, + QStringList & entriesToBrowse ); bool isValid(); + bool isWithGeomMode(); void setIsApplyAndClose( const bool theFlag ); bool isApplyAndClose() const; @@ -84,11 +88,14 @@ private: bool myBusy; SMESH::SMESH_Mesh_var myMesh; + GEOM::GEOM_Object_var myNewGeometry; SMESH_Actor* myActor; SUIT_SelectionFilter* myIdSourceFilter; SMESH::SMESH_IDSource_var mySelectedObject; + QButtonGroup* GroupConstructors; + QGroupBox* ConstructorsBox; QGroupBox* GroupArguments; QGroupBox* GroupButtons; @@ -99,10 +106,14 @@ private: QPushButton* buttonHelp; QLabel* myTextLabelElements; + QLabel* myGeomLabel; QLineEdit* myLineEditElements; QLineEdit* myMeshNameEdit; + QLineEdit* myGeomNameEdit; QCheckBox* myIdSourceCheck; QCheckBox* myCopyGroupsCheck; + QCheckBox* myReuseHypCheck; + QCheckBox* myCopyElementsCheck; QCheckBox* myKeepIdsCheck; QPushButton* myFilterBtn; @@ -122,6 +133,7 @@ private slots: void SelectionIntoArgument(); void DeactivateActiveDialog(); void ActivateThisDialog(); + void onConstructor( int ); void onTextChange( const QString& ); void onSelectIdSource( bool ); void setFilters(); diff --git a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx index 536742006..7a403902d 100644 --- a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx @@ -111,6 +111,17 @@ namespace SMESH return aMeshShape; } + GEOM::GEOM_Object_var GetGeom( Handle(SALOME_InteractiveObject) io ) + { + GEOM::GEOM_Object_var go; + if ( !io.IsNull() && io->hasEntry() ) + { + _PTR(SObject) so = SMESH::getStudy()->FindObjectID( io->getEntry() ); + go = GetGeom( so ); + } + return go._retn(); + } + SMESHGUI_EXPORT char* GetGeomName( _PTR(SObject) smeshSO ) { if (!smeshSO) diff --git a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h index f59609e07..33031215c 100644 --- a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h +++ b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h @@ -51,6 +51,8 @@ namespace SMESH SMESHGUI_EXPORT GEOM::GEOM_Object_var GetGeom( _PTR(SObject) ); + SMESHGUI_EXPORT GEOM::GEOM_Object_var GetGeom( Handle(SALOME_InteractiveObject) io ); + SMESHGUI_EXPORT char* GetGeomName( _PTR(SObject) smeshSO ); SMESHGUI_EXPORT GEOM::GEOM_Object_ptr GetSubShape( GEOM::GEOM_Object_ptr, long ); diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx index 7aff8c6ce..255d2f575 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx @@ -523,13 +523,15 @@ namespace SMESH if(MYDEBUG) MESSAGE("Loading client meshers plugin library ..."); #ifdef WIN32 #ifdef UNICODE - LPTSTR path = new TCHAR[aClientLibName.length() + 1]; - path[aClientLibName.toWCharArray(path)] = '\0'; + LPTSTR path = new TCHAR[aClientLibName.length() + 1]; + path[aClientLibName.toWCharArray(path)] = '\0'; #else - const char* path = aClientLibName.toUtf8().data(); + QByteArray baPath = aClientLibName.toUtf8(); + const char* path = baPath.data(); #endif #else - char* path = aClientLibName.toUtf8().data(); + QByteArray baPath = aClientLibName.toUtf8(); + char* path = baPath.data(); #endif LibHandle libHandle = LoadLib( path ); if (!libHandle) { diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.cxx b/src/SMESHGUI/SMESHGUI_MeshOp.cxx index 9378e4d40..9c690f378 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshOp.cxx @@ -92,6 +92,7 @@ SMESHGUI_MeshOp::SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh ) myShapeByMeshOp( 0 ), myToCreate( theToCreate ), myIsMesh( theIsMesh ), + myIsInvalidSubMesh( false ), myHypoSet( 0 ) { if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists @@ -152,7 +153,7 @@ bool SMESHGUI_MeshOp::onApply() QStringList anEntryList; if ( myToCreate && myIsMesh ) aResult = createMesh( aMess, anEntryList ); - if ( myToCreate && !myIsMesh ) + if (( myToCreate && !myIsMesh ) || myIsInvalidSubMesh ) aResult = createSubMesh( aMess, anEntryList ); else if ( !myToCreate ) aResult = editMeshOrSubMesh( aMess ); @@ -519,6 +520,7 @@ void SMESHGUI_MeshOp::selectionDone() try { myIsOnGeometry = true; + myIsInvalidSubMesh = false; //Check geometry for mesh QString anObjEntry = myDlg->selectedObject(SMESHGUI_MeshDlg::Obj); @@ -638,11 +640,21 @@ void SMESHGUI_MeshOp::selectionDone() SMESH::SMESH_subMesh_var submeshVar = SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() ); myIsMesh = submeshVar->_is_nil(); + myIsInvalidSubMesh = ( !myIsMesh && submeshVar->GetId() < 1 ); myDlg->setTitile( myToCreate, myIsMesh ); myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, !submeshVar->_is_nil() ); myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, true ); myDlg->objectWg( SMESHGUI_MeshDlg::Mesh, SMESHGUI_MeshDlg::Btn )->hide(); - myDlg->objectWg( SMESHGUI_MeshDlg::Geom, SMESHGUI_MeshDlg::Btn )->hide(); + if ( myIsInvalidSubMesh ) + { + // it is necessary to select a new geometry + myDlg->objectWg( SMESHGUI_MeshDlg::Geom, SMESHGUI_MeshDlg::Btn )->show(); + myDlg->activateObject( SMESHGUI_MeshDlg::Geom ); + } + else + { + myDlg->objectWg( SMESHGUI_MeshDlg::Geom, SMESHGUI_MeshDlg::Btn )->hide(); + } myDlg->updateGeometry(); myDlg->adjustSize(); readMesh(); @@ -1877,9 +1889,9 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess, QStringList& theEntryList ) //================================================================================ /*! * \brief Creates sub-mesh - * \param theMess - Output parameter intended for returning error message - * \param theEntryList - List of entries of published objects - * \retval bool - TRUE if sub-mesh is created, FALSE otherwise + * \param theMess - Output parameter intended for returning error message + * \param theEntryList - List of entries of published objects + * \retval bool - TRUE if sub-mesh is created, FALSE otherwise * * Creates sub-mesh */ @@ -1893,11 +1905,16 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList return false; // get mesh object - QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh ); - _PTR(SObject) pMesh = SMESH::getStudy()->FindObjectID( aMeshEntry.toUtf8().data() ); SMESH::SMESH_Mesh_var aMeshVar = - SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() ); - if (aMeshVar->_is_nil()) + SMESH::EntryToInterface( myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh )); + if ( aMeshVar->_is_nil() && myIsInvalidSubMesh ) + { + SMESH::SMESH_subMesh_var aSMVar = + SMESH::EntryToInterface( myDlg->selectedObject( SMESHGUI_MeshDlg::Obj )); + if ( !aSMVar->_is_nil() ) + aMeshVar = aSMVar->GetMesh(); + } + if ( aMeshVar->_is_nil() ) return false; // GEOM shape of the main mesh @@ -1971,8 +1988,14 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList SUIT_OverrideCursor aWaitCursor; + QString aNameOrID = aName; + if ( myIsInvalidSubMesh ) + // pass a sub-mesh entry to mesh->GetSubMesh() to replace the invalid sub-mesh + // by a valid one in an existing SO + aNameOrID = myDlg->selectedObject(SMESHGUI_MeshDlg::Obj); + // create sub-mesh - SMESH::SMESH_subMesh_var aSubMeshVar = aMeshVar->GetSubMesh( aGeomVar, aName.toUtf8().data() ); + SMESH::SMESH_subMesh_var aSubMeshVar = aMeshVar->GetSubMesh( aGeomVar, aNameOrID.toUtf8().data() ); _PTR(SObject) aSubMeshSO = SMESH::FindSObject( aSubMeshVar.in() ); if ( aSubMeshSO ) { SMESH::SetName( aSubMeshSO, aName.toUtf8().data() ); @@ -2249,10 +2272,13 @@ void SMESHGUI_MeshOp::readMesh() myHasConcurrentSubBefore = checkSubMeshConcurrency( aMeshVar, aSubMeshVar ); } - // Get name of geometry object - CORBA::String_var name = SMESH::GetGeomName( pObj ); - if ( name.in() ) - myDlg->setObjectText( SMESHGUI_MeshDlg::Geom, name.in() ); + if ( !myIsInvalidSubMesh ) + { + // Get name of geometry object + CORBA::String_var name = SMESH::GetGeomName( pObj ); + if ( name.in() ) + myDlg->setObjectText( SMESHGUI_MeshDlg::Geom, name.in() ); + } } // Get hypotheses and algorithms assigned to the mesh/sub-mesh diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.h b/src/SMESHGUI/SMESHGUI_MeshOp.h index 8ba4f8c40..48879d0f0 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.h +++ b/src/SMESHGUI/SMESHGUI_MeshOp.h @@ -153,8 +153,11 @@ private: SMESHGUI_ShapeByMeshOp* myShapeByMeshOp; bool myToCreate; bool myIsMesh; - bool myIsOnGeometry; //!< TRUE if edited mesh accotiated with geometrical object + bool myIsOnGeometry; //!< TRUE if edited mesh is based on geometry bool myHasConcurrentSubBefore; + bool myIsInvalidSubMesh; //!< "invalid sub-mesh" is edited + // The geometry of "invalid sub-mesh" is not a sub-shape of the main shape; + // it is created for the case where a valid sub-shape not found by CopyMeshWithGeom() TDim2Type2HypList myExistingHyps; //!< all hypothesis of SMESH module TDim2Type2HypList myObjHyps; //!< hypothesis assigned to the current diff --git a/src/SMESHGUI/SMESHGUI_Utils.cxx b/src/SMESHGUI/SMESHGUI_Utils.cxx index b8e679e67..5721e5301 100644 --- a/src/SMESHGUI/SMESHGUI_Utils.cxx +++ b/src/SMESHGUI/SMESHGUI_Utils.cxx @@ -226,6 +226,12 @@ namespace SMESH return app->orb()->string_to_object(theIOR.toLatin1().data()); } + CORBA::Object_var EntryToObject( const QString& theEntry ) + { + _PTR(SObject) anObj = getStudy()->FindObjectID( theEntry.toLatin1().data() ); + return SObjectToObject(anObj); + } + int GetNameOfSelectedIObjects(LightApp_SelectionMgr* theMgr, QString& theName) { if (!theMgr) diff --git a/src/SMESHGUI/SMESHGUI_Utils.h b/src/SMESHGUI/SMESHGUI_Utils.h index 6ff20e8a2..41d2e674e 100644 --- a/src/SMESHGUI/SMESHGUI_Utils.h +++ b/src/SMESHGUI/SMESHGUI_Utils.h @@ -152,6 +152,18 @@ SMESHGUI_EXPORT return TInterface::_nil(); } +SMESHGUI_EXPORT + CORBA::Object_var EntryToObject( const QString& ); + + template typename TInterface::_var_type + EntryToInterface( const QString& theEntry ) + { + CORBA::Object_var anObj = EntryToObject( theEntry ); + if ( !CORBA::is_nil( anObj ) ) + return TInterface::_narrow( anObj ); + return TInterface::_nil(); + } + SMESHGUI_EXPORT int GetNameOfSelectedIObjects( LightApp_SelectionMgr*, QString& ); diff --git a/src/SMESHGUI/SMESH_images.ts b/src/SMESHGUI/SMESH_images.ts index 629c0d107..9605001fb 100644 --- a/src/SMESHGUI/SMESH_images.ts +++ b/src/SMESHGUI/SMESH_images.ts @@ -35,6 +35,10 @@ ICON_COPY_MESH copy_mesh.png + + ICON_COPY_MESH_WG + copy_mesh_with_geom.png + ICON_COMPUTE mesh_compute.png diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index 75d649a72..bd20246ad 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -1938,6 +1938,14 @@ add the exported data to its contents? SMESH_HYPOTHESES Hypotheses + + SMESH_HYPOTHESIS + Hypothesis + + + SMESH_ALGORITHM + Algorithm + SMESH_HYP_1 Algorithm misses a hypothesis @@ -8070,6 +8078,25 @@ as they are of improper type: NEW_NAME New Mesh Name + + NEW_GEOM + New Geometry + + + REUSE_HYPOTHESES + Reuse Hypotheses + + + COPY_ELEMENTS + Copy Mesh Elements + + + SUBSHAPES_NOT_FOUND_MSG + +Some sub-shapes not found in the new geometry. They are listed +below along with dependent mesh objects that are marked with +with red in the Object Browser. + SMESHGUI_MeasureDlg diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index 6c1329704..cef6517ce 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -1006,10 +1006,10 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand ) AddObject( mesh ); return; } - if( method == "CreateMeshesFromMED" || - method == "CreateMeshesFromSAUV"|| - method == "CreateMeshesFromCGNS" || - method == "CreateMeshesFromGMF" ) // command result is ( [mesh1,mesh2], status ) + if ( method == "CreateMeshesFromMED" || + method == "CreateMeshesFromSAUV"|| + method == "CreateMeshesFromCGNS" || + method == "CreateMeshesFromGMF" ) // command result is ( [mesh1,mesh2], status ) { std::list< _pyID > meshIDs = theCommand->GetStudyEntries( theCommand->GetResultValue() ); std::list< _pyID >::iterator meshID = meshIDs.begin(); @@ -1027,6 +1027,12 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand ) theCommand->SetArg( 1, file ); } } + if ( method == "CopyMeshWithGeom" ) + { + std::list< _pyID > entries = theCommand->GetStudyEntries( theCommand->GetResultValue() ); + Handle(_pyMesh) mesh = new _pyMesh( theCommand, entries.front() ); + AddObject( mesh ); + } // CreateHypothesis() if ( method == "CreateHypothesis" ) diff --git a/src/SMESH_I/SMESH_Algo_i.cxx b/src/SMESH_I/SMESH_Algo_i.cxx index c878fe37b..1b66bb29f 100644 --- a/src/SMESH_I/SMESH_Algo_i.cxx +++ b/src/SMESH_I/SMESH_Algo_i.cxx @@ -81,3 +81,27 @@ SMESH::ListOfHypothesisName* SMESH_Algo_i::GetCompatibleHypothesis() } return listOfHypothesis._retn(); } + +//================================================================================ +/*! + * Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool SMESH_Algo_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const +{ + return false; +} + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool SMESH_Algo_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) +{ + return true; +} diff --git a/src/SMESH_I/SMESH_Algo_i.hxx b/src/SMESH_I/SMESH_Algo_i.hxx index 0d75eb5c2..9d4f6bf56 100644 --- a/src/SMESH_I/SMESH_Algo_i.hxx +++ b/src/SMESH_I/SMESH_Algo_i.hxx @@ -53,6 +53,15 @@ public: // Gets list of compatible hypotheses SMESH::ListOfHypothesisName* GetCompatibleHypothesis(); + + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const; + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ); }; #endif diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 75c9d2184..cd9c86098 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -103,6 +103,9 @@ #include "SMESH_PreMeshInfo.hxx" #include "SMESH_PythonDump.hxx" #include "SMESH_ControlsDef.hxx" + +// to pass CORBA exception through SMESH_TRY +#define SMY_OWN_CATCH catch( SALOME::SALOME_Exception& se ) { throw se; } #include "SMESH_TryCatch.hxx" // to include after OCC headers! #include CORBA_SERVER_HEADER(SMESH_Group) @@ -110,6 +113,7 @@ #include CORBA_SERVER_HEADER(SMESH_MeshEditor) +#include #include #include @@ -138,6 +142,7 @@ #include #include #include +#include using namespace std; using SMESH::TPythonDump; @@ -440,17 +445,17 @@ GenericHypothesisCreator_i* SMESH_Gen_i::getHypothesisCreator(const char* theHyp // load plugin library if(MYDEBUG) MESSAGE("Loading server meshers plugin library ..."); #ifdef WIN32 - #ifdef UNICODE - const wchar_t* path = Kernel_Utils::decode_s(aPlatformLibName); - #else - const char* path = aPlatformLibName.c_str(); - #endif +#ifdef UNICODE + const wchar_t* path = Kernel_Utils::decode_s(aPlatformLibName); +#else + const char* path = aPlatformLibName.c_str(); +#endif #else - const char* path = aPlatformLibName.c_str(); + const char* path = aPlatformLibName.c_str(); #endif LibHandle libHandle = LoadLib( path ); #if defined(WIN32) && defined(UNICODE) - delete path; + delete path; #endif if (!libHandle) { @@ -1938,7 +1943,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh, try { // get mesh servant - SMESH_Mesh_i* meshServant = dynamic_cast( GetServant( theMesh ).in() ); + SMESH_Mesh_i* meshServant = SMESH::DownCast( theMesh ); ASSERT( meshServant ); if ( meshServant ) { meshServant->Load(); @@ -1960,6 +1965,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh, meshServant->CreateGroupServants(); // algos can create groups (issue 0020918) myLocMesh.GetMeshDS()->Modified(); UpdateIcons( theMesh ); + HighLightInvalid( theMesh, /*isInvalid=*/!ok ); return ok; } } @@ -2724,10 +2730,12 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CopyMesh(SMESH::SMESH_IDSource_ptr meshPart, const char* meshName, CORBA::Boolean toCopyGroups, CORBA::Boolean toKeepIDs) + throw ( SALOME::SALOME_Exception ) { Unexpect aCatch(SALOME_SalomeException); TPythonDump* pyDump = new TPythonDump; // prevent dump from CreateMesh() + std::unique_ptr pyDumpDeleter( pyDump ); // 1. Get source mesh @@ -2930,7 +2938,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CopyMesh(SMESH::SMESH_IDSource_ptr meshPart, << toCopyGroups << ", " << toKeepIDs << ")"; - delete pyDump; pyDump = 0; // allow dump in GetGroups() + pyDumpDeleter.reset(); // allow dump in GetGroups() if ( nbNewGroups > 0 ) // dump created groups SMESH::ListOfGroups_var groups = newMesh->GetGroups(); @@ -2938,6 +2946,868 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CopyMesh(SMESH::SMESH_IDSource_ptr meshPart, return newMesh._retn(); } + +namespace // utils for CopyMeshWithGeom() +{ + typedef std::map< std::string, std::string > TStr2StrMap; + typedef std::map< std::string, std::set< std::string > > TStr2StrSetMap; + + //================================================================================ + /*! + * \brief Return a new sub-shape corresponding to an old one + */ + //================================================================================ + + struct ShapeMapper + { + SMESH_Mesh_i* mySrcMesh_i; + SMESH_Mesh_i* myNewMesh_i; + SMESH_Gen_i* myGen_i; + bool myToPublish; + bool myIsSameGeom; + + TStr2StrMap myOld2NewEntryMap; // map of study entries + + bool myGIPMapDone; + GEOM::ListOfListOfLong_var myGIPMap; // filled by GetInPlaceMap() + + // not directly relating to shape search + TStr2StrSetMap myInvalidMap; // blame shape -> invalid objects + + //================================================================================ + /*! + * \brief Constructor + */ + ShapeMapper( SMESH_Mesh_i* srcMesh_i, + SMESH_Mesh_i* newMesh_i, + SMESH_Gen_i* smeshGen_i ) + : mySrcMesh_i( srcMesh_i ), + myNewMesh_i( newMesh_i ), + myGen_i ( smeshGen_i ), + myToPublish( smeshGen_i->IsEnablePublish() ), + myGIPMapDone( false ) + { + // retrieve from the study shape mapping made thanks to + // "Set presentation parameters and sub-shapes from arguments" option + + GEOM::GEOM_Object_var mainShapeNew = myNewMesh_i->GetShapeToMesh(); + GEOM::GEOM_Object_var mainShapeOld = mySrcMesh_i->GetShapeToMesh(); + SALOMEDS::SObject_wrap oldSO = myGen_i->ObjectToSObject( mainShapeOld ); + SALOMEDS::SObject_wrap newSO = myGen_i->ObjectToSObject( mainShapeNew ); + if ( newSO->_is_nil() ) + { + myToPublish = false; + return; + } + if (( myIsSameGeom = mainShapeNew->_is_equivalent( mainShapeOld ))) + return; + CORBA::String_var oldEntry = oldSO->GetID(); + CORBA::String_var newEntry = newSO->GetID(); + myOld2NewEntryMap.insert( std::make_pair( std::string( oldEntry.in() ), + std::string( newEntry.in() ))); + + SALOMEDS::Study_var study = myGen_i->getStudyServant(); + GEOM::GEOM_Gen_var geomGen = myGen_i->GetGeomEngine(); + GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations(); + GEOM::ListOfGO_var subShapes = op->GetExistingSubObjects( mainShapeNew, + /*groupsOnly=*/false ); + for ( CORBA::ULong i = 0; i < subShapes->length(); ++i ) + { + newSO = myGen_i->ObjectToSObject( subShapes[ i ]); + SALOMEDS::ChildIterator_wrap anIter = study->NewChildIterator( newSO ); + for ( ; anIter->More(); anIter->Next() ) + { + SALOMEDS::SObject_wrap so = anIter->Value(); + if ( so->ReferencedObject( oldSO.inout() )) + { + oldEntry = oldSO->GetID(); + newEntry = newSO->GetID(); + myOld2NewEntryMap.insert( std::make_pair( std::string( oldEntry.in() ), + std::string( newEntry.in() ))); + } + } + } + } + + //================================================================================ + /*! + * \brief Find a new sub-shape corresponding to an old one + */ + GEOM::GEOM_Object_ptr FindNew( GEOM::GEOM_Object_ptr oldShape ) + { + if ( myIsSameGeom ) + return GEOM::GEOM_Object::_duplicate( oldShape ); + + GEOM::GEOM_Object_var newShape; + + if ( CORBA::is_nil( oldShape )) + return newShape._retn(); + + if ( !isChildOfOld( oldShape )) + return GEOM::GEOM_Object::_duplicate( oldShape ); // shape independent of the old shape + + GEOM::GEOM_Object_var mainShapeNew = myNewMesh_i->GetShapeToMesh(); + GEOM::GEOM_Gen_var geomGen = myGen_i->GetGeomEngine(); + + // try to find by entry + if ( myToPublish ) + { + CORBA::String_var oldEntry = oldShape->GetStudyEntry(); + TStr2StrMap::iterator o2nID = myOld2NewEntryMap.find( oldEntry.in() ); + if ( o2nID != myOld2NewEntryMap.end() ) + { + newShape = getShapeByEntry( o2nID->second ); + } + } + + if ( newShape->_is_nil() ) + { + // try to construct a new sub-shape using myGIPMap + buildGIPMap(); + std::vector< int > newIndices; + GEOM::ListOfLong_var oldIndices = oldShape->GetSubShapeIndices(); + for ( CORBA::ULong i = 0; i < oldIndices->length(); ++i ) + { + findNewIDs( oldIndices[i], newIndices ); + } + if ( !newIndices.empty() ) + { + try + { + if ( newIndices.size() > 1 || oldShape->GetType() == GEOM_GROUP ) + { + int groupType = getShapeType( myNewMesh_i, newIndices[0] ); + + GEOM::GEOM_IGroupOperations_wrap grOp = geomGen->GetIGroupOperations(); + newShape = grOp->CreateGroup( mainShapeNew, groupType ); + + GEOM::ListOfLong_var newIndicesList = new GEOM::ListOfLong(); + newIndicesList->length( newIndices.size() ); + for ( size_t i = 0; i < newIndices.size(); ++i ) + newIndicesList[ i ] = newIndices[ i ]; + grOp->UnionIDs( newShape, newIndicesList ); + } + else + { + GEOM::GEOM_IShapesOperations_wrap shOp = geomGen->GetIShapesOperations(); + newShape = shOp->GetSubShape( mainShapeNew, newIndices[0] ); + } + } + catch (...) + { + } + } + } + + if ( !newShape->_is_nil() && myToPublish ) + { + CORBA::String_var oldEntry, newEntry = newShape->GetStudyEntry(); + if ( !newEntry.in() || !newEntry.in()[0] ) + { + CORBA::String_var name = oldShape->GetName(); + SALOMEDS::SObject_wrap so = geomGen->AddInStudy( newShape, name, mainShapeNew ); + newEntry = newShape->GetStudyEntry(); + oldEntry = oldShape->GetStudyEntry(); + myOld2NewEntryMap.insert( std::make_pair( std::string( oldEntry.in() ), + std::string( newEntry.in() ))); + } + } + + return newShape._retn(); + } + + //================================================================================ + /*! + * \brief Return a study entry of a new shape by study entry of the old one + */ + std::string FindNew( const std::string & oldEntry ) + { + if ( myIsSameGeom ) + return oldEntry; + + TStr2StrMap::iterator o2nID = myOld2NewEntryMap.find( oldEntry ); + if ( o2nID != myOld2NewEntryMap.end() ) + return o2nID->second; + + GEOM::GEOM_Object_var oldShape = getShapeByEntry( oldEntry ); + if ( oldShape->_is_nil() || !isChildOfOld( oldShape )) + return oldEntry; + + GEOM::GEOM_Object_ptr newShape = FindNew( oldShape ); + if ( newShape->_is_nil() ) + return std::string(); + + CORBA::String_var newEntry = newShape->GetStudyEntry(); + return newEntry.in(); + } + + //================================================================================ + /*! + * \brief Return a sub-shape ID of a new shape by a sub-shape ID of the old one. + * Return zero if not found or there are more than one new ID + */ + int FindNew( int oldID ) + { + if ( myIsSameGeom ) + return oldID; + + buildGIPMap(); + + int newID = 0; + + if ( 0 < oldID && oldID < (int)myGIPMap->length() ) + { + if ( myGIPMap[ oldID ].length() == 1 ) + newID = myGIPMap[ oldID ][ 0 ]; + } + return newID; + } + + //================================================================================ + /*! + * \brief Return a sub-shape ID of a new shape by an old sub-mesh. + * Return zero if the old shape is not kept as is in the new shape. + */ + int FindNewNotChanged( SMESH_subMesh* oldSM ) + { + if ( myIsSameGeom ) + return oldSM->GetId(); + + int newID = FindNew( oldSM->GetId() ); + if ( !newID ) + return 0; + + SMESH_subMesh* newSM = myNewMesh_i->GetImpl().GetSubMeshContaining( newID ); + if ( !newSM ) + return 0; + + // consider a sub-shape as not changed if all its sub-shapes are mapped into + // one new sub-shape of the same type. + + if ( oldSM->DependsOn().size() != + newSM->DependsOn().size() ) + return 0; + + SMESH_subMeshIteratorPtr srcSMIt = oldSM->getDependsOnIterator( /*includeSelf=*/true ); + while ( srcSMIt->more() ) + { + oldSM = srcSMIt->next(); + int newSubID = FindNew( oldSM->GetId() ); + if ( getShapeType( myNewMesh_i, newSubID ) != + getShapeType( mySrcMesh_i, oldSM->GetId() )) + return 0; + } + return newID; + } + + //================================================================================ + /*! + * \brief Return shape by study entry + */ + GEOM::GEOM_Object_ptr getShapeByEntry( const std::string & entry ) + { + GEOM::GEOM_Object_var shape; + SALOMEDS::SObject_wrap so = myGen_i->getStudyServant()->FindObjectID( entry.c_str() ); + if ( !so->_is_nil() ) + { + CORBA::Object_var obj = so->GetObject(); + shape = GEOM::GEOM_Object::_narrow( obj ); + } + return shape._retn(); + } + + //================================================================================ + /*! + * \brief Fill myGIPMap by calling GetInPlaceMap() + */ + void buildGIPMap() + { + if ( !myGIPMapDone ) + { + myGIPMapDone = true; + + GEOM::GEOM_Object_var mainShapeNew = myNewMesh_i->GetShapeToMesh(); + GEOM::GEOM_Object_var mainShapeOld = mySrcMesh_i->GetShapeToMesh(); + GEOM::GEOM_Gen_var geomGen = myGen_i->GetGeomEngine(); + GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations(); + try + { + myGIPMap = op->GetInPlaceMap( mainShapeNew, mainShapeOld ); + } + catch( ... ) + { + myGIPMap = new GEOM::ListOfListOfLong(); + } + } + } + + //================================================================================ + /*! + * \brief Find a new sub-shape indices by an old one in myGIPMap. Return + * number of found IDs + */ + int findNewIDs( int oldID, std::vector< int >& newIDs ) + { + size_t prevNbIDs = newIDs.size(); + + if ( 0 < oldID && oldID < (int) myGIPMap->length() ) + { + for ( CORBA::ULong i = 0; i < myGIPMap[ oldID ].length(); ++i ) + newIDs.push_back( myGIPMap[ oldID ][ i ]); + } + return newIDs.size() - prevNbIDs; + } + + //================================================================================ + /*! + * \brief Check if an object relates to the old shape + */ + bool isChildOfOld( GEOM::GEOM_Object_ptr oldShape ) + { + if ( CORBA::is_nil( oldShape )) + return false; + GEOM::GEOM_Object_var mainShapeOld1 = mySrcMesh_i->GetShapeToMesh(); + GEOM::GEOM_Object_var mainShapeOld2 = oldShape->GetMainShape(); + return ( mainShapeOld1->_is_equivalent( mainShapeOld2 ) || + mainShapeOld1->_is_equivalent( oldShape )); + } + + //================================================================================ + /*! + * \brief Return shape type by shape ID + */ + TopAbs_ShapeEnum getShapeType( SMESH_Mesh_i* mesh_i, int shapeID ) + { + SMESHDS_Mesh* meshDS = mesh_i->GetImpl().GetMeshDS(); + const TopoDS_Shape& shape = meshDS->IndexToShape( shapeID ); + return shape.IsNull() ? TopAbs_SHAPE : shape.ShapeType(); + } + + //================================================================================ + /*! + * \brief Store a source sub-shape for which a counterpart not found and + * a smesh object invalid due to that + */ + void AddInvalid( GEOM::GEOM_Object_var srcShape, + SALOMEDS::SObject_wrap smeshSO ) + { + CORBA::String_var geomEntry = srcShape->GetStudyEntry(); + if ( geomEntry.in()[0] && !smeshSO->_is_nil() ) + { + CORBA::String_var smeshEntry = smeshSO->GetID(); + myInvalidMap[ geomEntry.in() ].insert( smeshEntry.in() ); + } + } + + //================================================================================ + /*! + * \brief Store a source sub-shape for which a counterpart not found and + * a smesh object invalid due to that + */ + void AddInvalid( std::string geomEntry, + SALOMEDS::SObject_wrap smeshSO ) + { + if ( !geomEntry.empty() ) + { + CORBA::String_var smeshEntry = smeshSO->GetID(); + myInvalidMap[ geomEntry ].insert( smeshEntry.in() ); + } + } + + //================================================================================ + /*! + * \brief Store a source sub-shape for which a counterpart not found and + * a smesh object invalid due to that + */ + void AddInvalid( int oldGeomID, + SALOMEDS::SObject_wrap smeshSO ) + { + int shapeType = getShapeType( mySrcMesh_i, oldGeomID ); + if ( shapeType < 0 || shapeType > TopAbs_SHAPE ) + return; + + const char* typeName[] = { "COMPOUND","COMPSOLID","SOLID","SHELL", + "FACE","WIRE","EDGE","VERTEX","SHAPE" }; + + SMESH_Comment geomName( typeName[ shapeType ]); + geomName << " #" << oldGeomID; + + CORBA::String_var smeshEntry = smeshSO->GetID(); + myInvalidMap[ geomName ].insert( smeshEntry.in() ); + } + + //================================================================================ + /*! + * \brief Return entries of a source sub-shape for which a counterpart not found and + * of smesh objects invalid due to that + */ + void GetInvalid( SMESH::string_array_out & theInvalidEntries, + std::vector< SALOMEDS::SObject_wrap > & theInvalidMeshSObjects) + { + int nbSO = 0; + TStr2StrSetMap::iterator entry2entrySet = myInvalidMap.begin(); + for ( ; entry2entrySet != myInvalidMap.end(); ++entry2entrySet ) + { + nbSO += 1 + entry2entrySet->second.size(); + } + int iSO = theInvalidMeshSObjects.size(), iEntry = 0; + theInvalidEntries->length ( nbSO ); + theInvalidMeshSObjects.resize( theInvalidMeshSObjects.size() + nbSO - myInvalidMap.size() ); + + entry2entrySet = myInvalidMap.begin(); + for ( ; entry2entrySet != myInvalidMap.end(); ++entry2entrySet ) + { + theInvalidEntries[ iEntry++ ] = entry2entrySet->first.c_str(); + + std::set< std::string > & entrySet = entry2entrySet->second; + std::set< std::string >::iterator entry = entrySet.begin(); + for ( ; entry != entrySet.end(); ++entry ) + { + theInvalidEntries[ iEntry++ ] = entry->c_str(); + + SALOMEDS::SObject_wrap so = myGen_i->getStudyServant()->FindObjectID( entry->c_str() ); + if ( !so->_is_nil() ) + theInvalidMeshSObjects[ iSO++ ] = so; + } + } + } + + }; // struct ShapeMapper + + //================================================================================ + /*! + * \brief Append an item to a CORBA sequence + */ + template < class CORBA_seq, class ITEM > + void append( CORBA_seq& seq, ITEM item ) + { + if ( !CORBA::is_nil( item )) + { + seq->length( 1 + seq->length() ); + seq[ seq->length() - 1 ] = item; + } + } +} + +//================================================================================ +/*! + * \brief Create a mesh by copying definitions of another mesh to a given geometry + * \param [in] sourceMesh - a mesh to copy + * \param [in] newGeometry - a new geometry + * \param [in] toCopyGroups - to create groups in the new mesh + * \param [in] toReuseHypotheses - if True, existing hypothesis will be used by the new mesh, + * otherwise new hypotheses with the same parameters will be created for the new mesh. + * \param [in] toCopyElements - to copy mesh elements of same sub-shapes of the two geometries + * \param [out] newMesh - return a new mesh + * \param [out] newGroups - return new groups + * \param [out] newSubmeshes - return new sub-meshes + * \param [out] newHypotheses - return new algorithms and hypotheses + * \param [out] invalidEntries - return study entries of objects whose + * counterparts are not found in the newGeometry, followed by entries + * of mesh sub-objects that are invalid because they depend on a not found + * preceeding sub-shape + * \return CORBA::Boolean - is a success + */ +//================================================================================ + +CORBA::Boolean SMESH_Gen_i::CopyMeshWithGeom( SMESH::SMESH_Mesh_ptr theSourceMesh, + GEOM::GEOM_Object_ptr theNewGeometry, + const char* theMeshName, + CORBA::Boolean theToCopyGroups, + CORBA::Boolean theToReuseHypotheses, + CORBA::Boolean theToCopyElements, + SMESH::SMESH_Mesh_out theNewMesh, + SMESH::ListOfGroups_out theNewGroups, + SMESH::submesh_array_out theNewSubmeshes, + SMESH::ListOfHypothesis_out theNewHypotheses, + SMESH::string_array_out theInvalidEntries) +throw ( SALOME::SALOME_Exception ) +{ + if ( CORBA::is_nil( theSourceMesh ) || + CORBA::is_nil( theNewGeometry )) + THROW_SALOME_CORBA_EXCEPTION( "NULL arguments", SALOME::BAD_PARAM ); + + if ( !theSourceMesh->HasShapeToMesh() ) + THROW_SALOME_CORBA_EXCEPTION( "Source mesh not on geometry", SALOME::BAD_PARAM ); + + bool ok = true; + SMESH_TRY; + + TPythonDump pyDump; // prevent dump from CreateMesh() + + theNewMesh = CreateMesh( theNewGeometry ); + theNewGroups = new SMESH::ListOfGroups(); + theNewSubmeshes = new SMESH::submesh_array(); + theNewHypotheses = new SMESH::ListOfHypothesis(); + theInvalidEntries = new SMESH::string_array(); + + std::vector< SALOMEDS::SObject_wrap > invalidSObjects; + + GEOM::GEOM_Object_var srcGeom = theSourceMesh->GetShapeToMesh(); + GEOM::GEOM_Object_var geom, newGeom; + SALOMEDS::SObject_wrap so; + + SMESH_Mesh_i* srcMesh_i = SMESH::DownCast( theSourceMesh ); + SMESH_Mesh_i* newMesh_i = SMESH::DownCast( theNewMesh ); + + ShapeMapper shapeMapper( srcMesh_i, newMesh_i, this ); + + // treat hypotheses of mesh and sub-meshes + SMESH::submesh_array_var smList = theSourceMesh->GetSubMeshes(); + for ( CORBA::ULong iSM = 0; iSM <= smList->length(); ++iSM ) + { + bool isSubMesh = ( iSM < smList->length() ); + if ( isSubMesh ) + { + // create a new sub-mesh + SMESH::SMESH_subMesh_var newSM; + geom = smList[iSM]->GetSubShape(); + so = ObjectToSObject( smList[iSM] ); + CORBA::String_var name; + if ( !so->_is_nil() ) + name = so->GetName(); + newGeom = shapeMapper.FindNew( geom ); + if ( newGeom->_is_nil() ) + { + newSM = createInvalidSubMesh( theNewMesh, geom, name.in() ); + shapeMapper.AddInvalid( geom, ObjectToSObject( newSM )); + ok = false; + } + else + { + newSM = theNewMesh->GetSubMesh( newGeom, name.in() ); + } + append( theNewSubmeshes, newSM ); + + if ( newGeom->_is_nil() ) + continue; // don't assign hypotheses + } + else + { + newGeom = GEOM::GEOM_Object::_duplicate( theNewGeometry ); + geom = srcGeom; + so = ObjectToSObject( theNewMesh ); + SetName( so, theMeshName, "Mesh" ); + } + + // assign hypotheses + SMESH::ListOfHypothesis_var hypList = theSourceMesh->GetHypothesisList( geom ); + for ( CORBA::ULong iHyp = 0; iHyp < hypList->length(); ++iHyp ) + { + SMESH::SMESH_Hypothesis_var hyp = hypList[ iHyp ]; + SMESH_Hypothesis_i* hyp_i = SMESH::DownCast< SMESH_Hypothesis_i* >( hyp ); + + // get geometry hyp depends on + std::vector< std::string > entryArray; + std::vector< int > subIDArray; + bool dependsOnGeom = hyp_i->getObjectsDependOn( entryArray, subIDArray ); + + if ( !theToReuseHypotheses || dependsOnGeom ) + { + // create a new hypothesis + CORBA::String_var type = hyp->GetName(); + CORBA::String_var lib = hyp->GetLibName(); + CORBA::String_var data = hyp_i->SaveTo(); + if ( data.in()[0] ) + { + hyp = CreateHypothesis( type, lib ); + hyp_i = SMESH::DownCast< SMESH_Hypothesis_i* >( hyp ); + hyp_i->LoadFrom( data.in() ); + append( theNewHypotheses, hyp ); + } + } + + // update geometry hyp depends on + if ( dependsOnGeom ) + { + for ( size_t iGeo = 0; iGeo < entryArray.size(); ++iGeo ) + { + if ( !entryArray[ iGeo ].empty() ) + { + std::string newEntry = shapeMapper.FindNew( entryArray[ iGeo ]); + if ( newEntry.empty() ) + { + ok = false; + shapeMapper.AddInvalid( entryArray[ iGeo ], ObjectToSObject( hyp )); + shapeMapper.AddInvalid( entryArray[ iGeo ], so ); // sub-mesh + } + entryArray[ iGeo ] = newEntry; + } + } + for ( size_t iGeo = 0; iGeo < subIDArray.size(); ++iGeo ) + { + if ( subIDArray[ iGeo ] > 0 ) + { + int newID = shapeMapper.FindNew( subIDArray[ iGeo ]); + if ( newID < 1 ) + { + ok = false; + shapeMapper.AddInvalid( subIDArray[ iGeo ], ObjectToSObject( hyp )); + shapeMapper.AddInvalid( subIDArray[ iGeo ], so ); // sub-mesh + } + subIDArray[ iGeo ] = newID; + } + } + if ( !hyp_i->setObjectsDependOn( entryArray, subIDArray )) + ok = false; + } + + CORBA::String_var errorText; + theNewMesh->AddHypothesis( newGeom, hyp, errorText.out() ); + if ( errorText.in()[0] ) + ok = false; + + } // loop on hypotheses + } // loop on sub-meshes and mesh + + + // copy mesh elements, keeping IDs + if ( theToCopyElements && theSourceMesh->NbNodes() > 0 ) + { + SMESHDS_Mesh* newMeshDS = newMesh_i->GetImpl().GetMeshDS(); + ::SMESH_MeshEditor editor( &newMesh_i->GetImpl() ); + ::SMESH_MeshEditor::ElemFeatures elemData; + + SMESH_subMesh* srcMainSM = srcMesh_i->GetImpl().GetSubMeshContaining( 1 ); + SMESH_subMeshIteratorPtr srcSMIt = srcMainSM->getDependsOnIterator( /*includeSelf=*/true, + /*vertexLast=*/false); + while ( srcSMIt->more() ) + { + SMESH_subMesh* srcSM = srcSMIt->next(); + if ( srcSM->IsEmpty() ) + continue; // not yet computed + int newID = shapeMapper.FindNewNotChanged( srcSM ); + if ( newID < 1 ) + continue; + + SMESHDS_SubMesh* srcSMDS = srcSM->GetSubMeshDS(); + SMDS_NodeIteratorPtr nIt = srcSMDS->GetNodes(); + while ( nIt->more() ) + { + SMESH_NodeXYZ node( nIt->next() ); + const SMDS_MeshNode* newNode = newMeshDS->AddNodeWithID( node.X(), node.Y(), node.Z(), + node->GetID() ); + const SMDS_PositionPtr pos = node->GetPosition(); + const double* uv = pos->GetParameters(); + switch ( pos->GetTypeOfPosition() ) + { + case SMDS_TOP_3DSPACE: newMeshDS->SetNodeInVolume( newNode, newID ); break; + case SMDS_TOP_FACE: newMeshDS->SetNodeOnFace ( newNode, newID, uv[0], uv[1] ); break; + case SMDS_TOP_EDGE: newMeshDS->SetNodeOnEdge ( newNode, newID, uv[0] ); break; + case SMDS_TOP_VERTEX: newMeshDS->SetNodeOnVertex( newNode, newID ); break; + default: ; + } + } + SMDS_ElemIteratorPtr eIt = srcSMDS->GetElements(); + while( eIt->more() ) + { + const SMDS_MeshElement* e = eIt->next(); + elemData.Init( e, /*basicOnly=*/false ); + elemData.SetID( e->GetID() ); + elemData.myNodes.resize( e->NbNodes() ); + SMDS_NodeIteratorPtr nnIt = e->nodeIterator(); + size_t iN; + for ( iN = 0; nnIt->more(); ++iN ) + { + const SMDS_MeshNode* srcNode = nnIt->next(); + elemData.myNodes[ iN ] = newMeshDS->FindNode( srcNode->GetID() ); + if ( !elemData.myNodes[ iN ]) + break; + } + if ( iN == elemData.myNodes.size() ) + if ( const SMDS_MeshElement * newElem = editor.AddElement( elemData.myNodes, elemData )) + newMeshDS->SetMeshElementOnShape( newElem, newID ); + } + if ( SMESH_subMesh* newSM = newMesh_i->GetImpl().GetSubMeshContaining( newID )) + newSM->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE ); + } + } + + + // treat groups + + TStr2StrMap old2newGroupMap; + + SALOME::GenericObj_wrap< SMESH::FilterManager > filterMgr = CreateFilterManager(); + + SMESH::ListOfGroups_var groups = theSourceMesh->GetGroups(); + CORBA::ULong nbGroups = groups->length(), nbAddedGroups = 0; + for ( CORBA::ULong i = 0; i < nbGroups + nbAddedGroups; ++i ) + { + SMESH::SMESH_Group_var stdlGroup = SMESH::SMESH_Group::_narrow ( groups[ i ]); + SMESH::SMESH_GroupOnGeom_var geomGroup = SMESH::SMESH_GroupOnGeom::_narrow ( groups[ i ]); + SMESH::SMESH_GroupOnFilter_var fltrGroup = SMESH::SMESH_GroupOnFilter::_narrow( groups[ i ]); + + CORBA::String_var name = groups[ i ]->GetName(); + SMESH::ElementType elemType = groups[ i ]->GetType(); + + SMESH::SMESH_GroupBase_var newGroup; + + if ( !stdlGroup->_is_nil() ) + { + if ( theToCopyElements ) + { + SMESH::long_array_var elemIDs = stdlGroup->GetIDs(); + stdlGroup = theNewMesh->CreateGroup( elemType, name ); + stdlGroup->Add( elemIDs ); + newGroup = SMESH::SMESH_GroupBase::_narrow( stdlGroup ); + } + } + else if ( !geomGroup->_is_nil() ) + { + GEOM::GEOM_Object_var geom = geomGroup->GetShape(); + GEOM::GEOM_Object_var newGeom = shapeMapper.FindNew( geom ); + if ( newGeom->_is_nil() ) + { + newGroup = theNewMesh->CreateGroup( elemType, name ); // just to notify the user + shapeMapper.AddInvalid( geom, ObjectToSObject( newGroup )); + ok = false; + } + else + { + newGroup = theNewMesh->CreateGroupFromGEOM( elemType, name, newGeom ); + } + } + else if ( !fltrGroup->_is_nil() ) + { + // replace geometry in a filter + SMESH::Filter_var filter = fltrGroup->GetFilter(); + SMESH::Filter::Criteria_var criteria; + filter->GetCriteria( criteria.out() ); + + bool isMissingGroup = false; + std::vector< std::string > badEntries; + + for ( CORBA::ULong iCr = 0; iCr < criteria->length(); ++iCr ) + { + const char* thresholdID = criteria[ iCr ].ThresholdID.in(); + switch ( criteria[ iCr ].Type ) + { + case SMESH::FT_BelongToMeshGroup: + { + SALOME::GenericObj_wrap< SMESH::BelongToMeshGroup > btgg = filterMgr->CreateBelongToMeshGroup(); + btgg->SetGroupID( thresholdID ); + SMESH::SMESH_GroupBase_ptr refGroup = btgg->GetGroup(); + SALOMEDS::SObject_wrap refGroupSO = ObjectToSObject( refGroup ); + if ( refGroupSO->_is_nil() ) + break; + CORBA::String_var refID = refGroupSO->GetID(); + TStr2StrMap::iterator o2nID = old2newGroupMap.find( refID.in() ); + if ( o2nID == old2newGroupMap.end() ) + { + isMissingGroup = true; // corresponding new group not yet created + break; + } + criteria[ iCr ].ThresholdID = o2nID->second.c_str(); + + if ( o2nID->second.empty() ) // new referred group is invalid + badEntries.push_back( refID.in() ); + break; + } + case SMESH::FT_BelongToGeom: + case SMESH::FT_BelongToPlane: + case SMESH::FT_BelongToCylinder: + case SMESH::FT_BelongToGenSurface: + case SMESH::FT_LyingOnGeom: + { + std::string newID = shapeMapper.FindNew( thresholdID ); + criteria[ iCr ].ThresholdID = newID.c_str(); + if ( newID.empty() ) + badEntries.push_back( thresholdID ); + break; + } + case SMESH::FT_ConnectedElements: + { + if ( thresholdID && thresholdID[0] ) + { + std::string newID = shapeMapper.FindNew( thresholdID ); + criteria[ iCr ].ThresholdID = newID.c_str(); + if ( newID.empty() ) + badEntries.push_back( thresholdID ); + } + break; + } + default:; + } + } // loop on criteria + + if ( isMissingGroup && i < nbGroups ) + { + // to treat the group again + append( groups, SMESH::SMESH_GroupBase::_duplicate( groups[ i ])); + ++nbAddedGroups; + continue; + } + SMESH::Filter_var newFilter = filterMgr->CreateFilter(); + newFilter->SetCriteria( criteria ); + + newGroup = theNewMesh->CreateGroupFromFilter( elemType, name, newFilter ); + newFilter->UnRegister(); + + SALOMEDS::SObject_wrap newSO = ObjectToSObject( newGroup ); + for ( size_t iEnt = 0; iEnt < badEntries.size(); ++iEnt ) + shapeMapper.AddInvalid( badEntries[ iEnt ], newSO ); + + if ( isMissingGroup ) // all groups treated but a referred groups still not found + { + invalidSObjects.push_back( ObjectToSObject( newGroup )); + ok = false; + } + if ( !badEntries.empty() ) + ok = false; + + } // treat a group on filter + + append( theNewGroups, newGroup ); + + // fill old2newGroupMap + SALOMEDS::SObject_wrap srcSO = ObjectToSObject( groups[i] ); + SALOMEDS::SObject_wrap newSO = ObjectToSObject( newGroup ); + if ( !srcSO->_is_nil() ) + { + CORBA::String_var srcID, newID; + srcID = srcSO->GetID(); + if ( !newSO->_is_nil() ) + newID = newSO->GetID(); + old2newGroupMap.insert( std::make_pair( std::string( srcID.in() ), + std::string( newID.in() ))); + } + + if ( newGroup->_is_nil() ) + ok = false; + + } // loop on groups + + // set mesh name + SALOMEDS::SObject_wrap soNew = ObjectToSObject( theNewMesh ); + SALOMEDS::SObject_wrap soOld = ObjectToSObject( theSourceMesh ); + CORBA::String_var oldName = soOld->GetName(); + SetName( soNew, oldName.in(), "Mesh" ); + + // mark invalid objects + shapeMapper.GetInvalid( theInvalidEntries, invalidSObjects ); + + for ( size_t i = 0; i < invalidSObjects.size(); ++i ) + highLightInvalid( invalidSObjects[i].in(), true ); + + pyDump << "ok, " + << theNewMesh << ", " + << theNewGroups << ", " + << *theNewSubmeshes.ptr() << ", " + << *theNewHypotheses.ptr() << ", " + << "invalidEntries = " << this << ".CopyMeshWithGeom( " + << theSourceMesh << ", " + << theNewGeometry << ", " + << "'" << theMeshName << "', " + << theToCopyGroups << ", " + << theToReuseHypotheses << ", " + << theToCopyElements << " )"; + + SMESH_CATCH( SMESH::throwCorbaException ); + + return ok; +} + //================================================================================ /*! * \brief Get version of MED format being used. diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index 21f55355e..1209ec7af 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -246,9 +246,24 @@ public: SMESH::SMESH_Mesh_ptr CopyMesh(SMESH::SMESH_IDSource_ptr meshPart, const char* meshName, CORBA::Boolean toCopyGroups, - CORBA::Boolean toKeepIDs); + CORBA::Boolean toKeepIDs) + throw ( SALOME::SALOME_Exception ); + + // Create a mesh by copying definitions of another mesh to a given geometry + CORBA::Boolean CopyMeshWithGeom( SMESH::SMESH_Mesh_ptr sourceMesh, + GEOM::GEOM_Object_ptr newGeometry, + const char* meshName, + CORBA::Boolean toCopyGroups, + CORBA::Boolean toReuseHypotheses, + CORBA::Boolean toCopyElements, + SMESH::SMESH_Mesh_out newMesh, + SMESH::ListOfGroups_out newGroups, + SMESH::submesh_array_out newSubmeshes, + SMESH::ListOfHypothesis_out newHypotheses, + SMESH::string_array_out invalidEntries) + throw ( SALOME::SALOME_Exception ); - // Compute mesh on a shape + // Compute mesh on a shape CORBA::Boolean Compute( SMESH::SMESH_Mesh_ptr theMesh, GEOM::GEOM_Object_ptr theShapeObject ) throw ( SALOME::SALOME_Exception ); @@ -504,6 +519,7 @@ public: GEOM::GEOM_Object_ptr theShapeObject, const char* theName = 0); void UpdateIcons(SMESH::SMESH_Mesh_ptr theMesh); + void HighLightInvalid(CORBA::Object_ptr theObject, bool isInvalid); bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr theMesh, GEOM::GEOM_Object_ptr theShapeObject, SMESH::SMESH_Hypothesis_ptr theHyp); @@ -608,6 +624,14 @@ private: SMESH::SMESH_Mesh_ptr createMesh() throw ( SALOME::SALOME_Exception ); + // Create a sub-mesh on a geometry that is not a sub-shape of the main shape + // for the case where a valid sub-shape not found by CopyMeshWithGeom() + SMESH::SMESH_subMesh_ptr createInvalidSubMesh( SMESH::SMESH_Mesh_ptr mesh, + GEOM::GEOM_Object_ptr strangerGeom, + const char* name ); + + void highLightInvalid( SALOMEDS::SObject_ptr theSObject, bool isInvalid ); + static void loadGeomData( SALOMEDS::SComponent_ptr theCompRoot ); SMESH::mesh_array* CreateMeshesFromMEDorSAUV( const char* theFileName, diff --git a/src/SMESH_I/SMESH_Gen_i_1.cxx b/src/SMESH_I/SMESH_Gen_i_1.cxx index 49e74979e..69a8f73b0 100644 --- a/src/SMESH_I/SMESH_Gen_i_1.cxx +++ b/src/SMESH_I/SMESH_Gen_i_1.cxx @@ -452,6 +452,9 @@ static void addReference (SALOMEDS::SObject_ptr theSObject, aStudyBuilder->Addreference( aReferenceSO, aToObjSO ); + // make the reference visible (invisible ref is created by createInvalidSubMesh()) + aStudyBuilder->RemoveAttribute( aReferenceSO, "AttributeDrawable" ); + // add reference to the use case tree // (to support tree representation customization and drag-n-drop) SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = aStudy->GetUseCaseBuilder(); @@ -689,6 +692,8 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SMESH::SMESH_Mesh_ptr theM if ( theMesh->_is_nil() || theSubMesh->_is_nil() || theShapeObject->_is_nil() ) return SALOMEDS::SObject::_nil(); + std::string newName( theName ? theName : "" ); + SALOMEDS::SObject_wrap aSubMeshSO = ObjectToSObject( theSubMesh ); if ( aSubMeshSO->_is_nil() ) { @@ -740,15 +745,37 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SMESH::SMESH_Mesh_ptr theM SetName( aRootSO, aRootName ); - // Add new submesh to corresponding sub-tree + // Add new sub-mesh to corresponding sub-tree + int tag = 0; // to use a new SObject + if ( theName && theName[0] == '0' ) + { + // theName can be an entry of an invalid sub-mesh which theSubMesh should replace + SALOMEDS::SObject_wrap aSObj = getStudyServant()->FindObjectID( theName ); + if ( aSObj ) + { + CORBA::String_var oldName = aSObj->GetName(); + newName = oldName.in(); + SALOMEDS::SObject_wrap aRootSO2 = aSObj->GetFather(); + if ( aRootSO->Tag() == aRootSO2->Tag() ) // same parent + tag = aSObj->Tag(); // to use the same SObject + else + { + CORBA::Object_var anObj = SObjectToObject( aSObj ); + SMESH::SMESH_subMesh_var sm = SMESH::SMESH_subMesh::_narrow( anObj ); + theMesh->RemoveSubMesh( sm ); + } + } + } SMESH::array_of_ElementType_var elemTypes = theSubMesh->GetTypes(); const int isEmpty = ( elemTypes->length() == 0 ); const char* pm[2] = { "ICON_SMESH_TREE_MESH", "ICON_SMESH_TREE_MESH_WARN" }; - aSubMeshSO = publish ( theSubMesh, aRootSO, 0, pm[isEmpty] ); + aSubMeshSO = publish ( theSubMesh, aRootSO, tag, pm[isEmpty] ); if ( aSubMeshSO->_is_nil() ) return aSubMeshSO._retn(); + + highLightInvalid( aSubMeshSO, false ); // now it is valid } - SetName( aSubMeshSO, theName, "SubMesh" ); + SetName( aSubMeshSO, newName.c_str(), "SubMesh" ); // Add reference to theShapeObject @@ -757,7 +784,8 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SMESH::SMESH_Mesh_ptr theM // Publish hypothesis SMESH::ListOfHypothesis_var hypList = theMesh->GetHypothesisList( theShapeObject ); - for ( CORBA::ULong i = 0; i < hypList->length(); i++ ) { + for ( CORBA::ULong i = 0; i < hypList->length(); i++ ) + { SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( hypList[ i ]); SALOMEDS::SObject_wrap so = PublishHypothesis( aHyp ); AddHypothesisToShape( theMesh, theShapeObject, aHyp ); @@ -965,6 +993,42 @@ void SMESH_Gen_i::UpdateIcons( SMESH::SMESH_Mesh_ptr theMesh ) } } +//======================================================================= +//function : HighLightInvalid +//purpose : change font color of a object in the Object Browser +//======================================================================= + +void SMESH_Gen_i::HighLightInvalid( CORBA::Object_ptr theObject, bool isInvalid ) +{ + SALOMEDS::SObject_wrap so = ObjectToSObject(theObject); + highLightInvalid( so.in(), isInvalid ); +} + +//======================================================================= +//function : highLightInvalid +//purpose : change font color of a object in the Object Browser +//======================================================================= + +void SMESH_Gen_i::highLightInvalid( SALOMEDS::SObject_ptr theSObject, bool isInvalid ) +{ + if ( !theSObject->_is_nil() ) + { + SALOMEDS::StudyBuilder_var studyBuilder = getStudyServant()->NewBuilder(); + if ( isInvalid ) + { + SALOMEDS::Color red = { 178,34,34 }; // to differ from reference color + SALOMEDS::GenericAttribute_wrap attr = + studyBuilder->FindOrCreateAttribute( theSObject, "AttributeTextColor" ); + SALOMEDS::AttributeTextColor_wrap colorAttr = attr; + colorAttr->SetTextColor( red ); + } + else + { + studyBuilder->RemoveAttribute( theSObject, "AttributeTextColor" ); + } + } +} + //======================================================================= //function : GetMeshOrSubmeshByShape //purpose : @@ -1339,6 +1403,50 @@ char* SMESH_Gen_i::GetParameters(CORBA::Object_ptr theObject) return aResult._retn(); } +//================================================================================ +/*! + * \brief Create a sub-mesh on a geometry that is not a sub-shape of the main shape + * for the case where a valid sub-shape not found by CopyMeshWithGeom(). + * The invalid sub-mesh has GetId() < 0. + */ +//================================================================================ + +SMESH::SMESH_subMesh_ptr +SMESH_Gen_i::createInvalidSubMesh(SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theStrangerGeom, + const char* theName) +{ + SMESH::SMESH_subMesh_var subMesh; + + try + { + SMESH_Mesh_i* mesh_i = SMESH::DownCast( theMesh ); + subMesh = mesh_i->createSubMesh( theStrangerGeom ); + + if ( !subMesh->_is_nil() && CanPublishInStudy( subMesh )) + { + SALOMEDS::SObject_wrap so = PublishSubMesh( theMesh, subMesh, theStrangerGeom, theName ); + + // hide a reference to geometry + if ( !so->_is_nil() ) + { + SALOMEDS::SObject_wrap refSO; + if ( so->FindSubObject( GetRefOnShapeTag(), refSO.inout() )) + { + SALOMEDS::StudyBuilder_var studyBuilder = getStudyServant()->NewBuilder(); + SALOMEDS::GenericAttribute_wrap attr = + studyBuilder->FindOrCreateAttribute( refSO, "AttributeDrawable" ); + SALOMEDS::AttributeDrawable_wrap ga = attr; + ga->SetDrawable( false ); + } + } + } + } + catch (...) { + } + + return subMesh._retn(); +} // ============== diff --git a/src/SMESH_I/SMESH_Group_i.cxx b/src/SMESH_I/SMESH_Group_i.cxx index 354a1daf0..1c8257ddb 100644 --- a/src/SMESH_I/SMESH_Group_i.cxx +++ b/src/SMESH_I/SMESH_Group_i.cxx @@ -838,7 +838,13 @@ void SMESH_GroupOnFilter_i::SetFilter(SMESH::Filter_ptr theFilter) Modified(); // notify dependent Filter with FT_BelongToMeshGroup criterion } - TPythonDump()<< SMESH::SMESH_GroupOnFilter_var(_this()) <<".SetFilter( "<GetGen()->HighLightInvalid( me, false ); + + + TPythonDump()<< me <<".SetFilter( "<< theFilter <<" )"; } //================================================================================ diff --git a/src/SMESH_I/SMESH_Hypothesis_i.hxx b/src/SMESH_I/SMESH_Hypothesis_i.hxx index f713bfd2d..8523c787a 100644 --- a/src/SMESH_I/SMESH_Hypothesis_i.hxx +++ b/src/SMESH_I/SMESH_Hypothesis_i.hxx @@ -40,6 +40,7 @@ #include #include +#include class TCollection_AsciiString; @@ -97,7 +98,18 @@ public: // Persistence virtual char* SaveTo(); virtual void LoadFrom( const char* theStream ); - virtual void UpdateAsMeshesRestored(); // for hyps needing full data restored + virtual void UpdateAsMeshesRestored(); // for hyps needing full study data restored + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const = 0; + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) = 0; protected: diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 8dc1b25b5..128dbed1c 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -2460,9 +2460,25 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Object_ptr theS if(MYDEBUG) MESSAGE( "createSubMesh" ); TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(theSubShapeObject); ::SMESH_subMesh * mySubMesh = _impl->GetSubMesh(myLocSubShape); - const int subMeshId = mySubMesh->GetId(); + int subMeshId = 0; + + SMESH_subMesh_i * subMeshServant; + if ( mySubMesh ) + { + subMeshId = mySubMesh->GetId(); + subMeshServant = new SMESH_subMesh_i(myPOA, _gen_i, this, subMeshId); + } + else // "invalid sub-mesh" + { + // The invalid sub-mesh is created for the case where a valid sub-shape not found + // by SMESH_Gen_i::CopyMeshWithGeom(). The invalid sub-mesh has GetId() < 0. + if ( _mapSubMesh.empty() ) + subMeshId = -1; + else + subMeshId = _mapSubMesh.begin()->first - 1; + subMeshServant = new SMESH_Invalid_subMesh_i(myPOA, _gen_i, this, subMeshId, theSubShapeObject); + } - SMESH_subMesh_i * subMeshServant = new SMESH_subMesh_i(myPOA, _gen_i, this, subMeshId); SMESH::SMESH_subMesh_var subMesh = subMeshServant->_this(); _mapSubMesh [subMeshId] = mySubMesh; @@ -2477,7 +2493,8 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Object_ptr theS else { nextId = 0; } // avoid "unused variable" warning // to track changes of GEOM groups - addGeomGroupData( theSubShapeObject, subMesh ); + if ( subMeshId > 0 ) + addGeomGroupData( theSubShapeObject, subMesh ); return subMesh._retn(); } @@ -2513,7 +2530,8 @@ bool SMESH_Mesh_i::removeSubMesh (SMESH::SMESH_subMesh_ptr theSubMesh, if ( theSubShapeObject->_is_nil() ) // not published shape (IPAL13617) { - if ( _mapSubMesh.find( subMeshId ) != _mapSubMesh.end()) + if ( _mapSubMesh.find( subMeshId ) != _mapSubMesh.end() && + _mapSubMesh[ subMeshId ]) { TopoDS_Shape S = _mapSubMesh[ subMeshId ]->GetSubShape(); if ( !S.IsNull() ) @@ -2735,7 +2753,7 @@ namespace SMESH_Mesh_i* _mesh; TCallUp_i(SMESH_Mesh_i* mesh):_mesh(mesh) {} virtual void RemoveGroup (const int theGroupID) { _mesh->removeGroup( theGroupID ); } - virtual void HypothesisModified () { _mesh->onHypothesisModified(); } + virtual void HypothesisModified (int theHypID) { _mesh->onHypothesisModified( theHypID ); } virtual void Load () { _mesh->Load(); } }; } @@ -2746,13 +2764,30 @@ namespace */ //================================================================================ -void SMESH_Mesh_i::onHypothesisModified() +void SMESH_Mesh_i::onHypothesisModified(int theHypID) { if ( _preMeshInfo ) _preMeshInfo->ForgetOrLoad(); SMESH::SMESH_Mesh_var mesh = _this(); _gen_i->UpdateIcons( mesh ); + + // mark a hypothesis as valid after edition + SALOMEDS::SComponent_wrap smeshComp = _gen_i->PublishComponent(); + SALOMEDS::SObject_wrap hypRoot; + if ( !smeshComp->_is_nil() && + smeshComp->FindSubObject( _gen_i->GetHypothesisRootTag(), hypRoot.inout() )) + { + SALOMEDS::ChildIterator_wrap anIter = _gen_i->getStudyServant()->NewChildIterator( hypRoot ); + for ( ; anIter->More(); anIter->Next() ) + { + SALOMEDS::SObject_wrap hypSO = anIter->Value(); + CORBA::Object_var obj = _gen_i->SObjectToObject( hypSO ); + SMESH::SMESH_Hypothesis_var hyp = SMESH::SMESH_Hypothesis::_narrow( obj ); + if ( !hyp->_is_nil() && hyp->GetId() == theHypID ) + _gen_i->HighLightInvalid( hyp, false ); + } + } } //============================================================================= diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index 867949a9d..7e612be13 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -439,7 +439,7 @@ public: const std::map& getGroups() { return _mapGroups; } // return existing group objects - void onHypothesisModified(); + void onHypothesisModified(int theHypID); // callback from _impl to forget not loaded mesh data (issue 0021208) void checkMeshLoaded(); diff --git a/src/SMESH_I/SMESH_PythonDump.cxx b/src/SMESH_I/SMESH_PythonDump.cxx index 7ffedf1d4..76a23315a 100644 --- a/src/SMESH_I/SMESH_PythonDump.cxx +++ b/src/SMESH_I/SMESH_PythonDump.cxx @@ -540,6 +540,16 @@ namespace SMESH DumpArray( theList, *this ); return *this; } + TPythonDump& TPythonDump::operator<<(const SMESH::submesh_array& theList) + { + DumpArray( theList, *this ); + return *this; + } + TPythonDump& TPythonDump::operator<<(const SMESH::ListOfHypothesis& theList) + { + DumpArray( theList, *this ); + return *this; + } TPythonDump& TPythonDump::operator<<(const SMESH::CoincidentFreeBorders& theCFB) { // dump CoincidentFreeBorders as a list of lists, each enclosed list diff --git a/src/SMESH_I/SMESH_PythonDump.hxx b/src/SMESH_I/SMESH_PythonDump.hxx index 793e4a4a1..37393b23f 100644 --- a/src/SMESH_I/SMESH_PythonDump.hxx +++ b/src/SMESH_I/SMESH_PythonDump.hxx @@ -227,6 +227,12 @@ namespace SMESH TPythonDump& operator<<(const SMESH::ListOfIDSources& theList); + TPythonDump& + operator<<(const SMESH::submesh_array& theList); + + TPythonDump& + operator<<(const SMESH::ListOfHypothesis& theList); + TPythonDump& operator<<(const SMESH::CoincidentFreeBorders& theCFB); diff --git a/src/SMESH_I/SMESH_subMesh_i.cxx b/src/SMESH_I/SMESH_subMesh_i.cxx index 4737a7b0e..92d6034e4 100644 --- a/src/SMESH_I/SMESH_subMesh_i.cxx +++ b/src/SMESH_I/SMESH_subMesh_i.cxx @@ -96,6 +96,8 @@ typedef list TListOfSubMeshes; bool getSubMeshes(::SMESH_subMesh* theSubMesh, TListOfSubMeshes& theSubMeshList) { + if ( !theSubMesh ) + return false; // "invalid sub-mesh" created by SMESH_Gen_i::CopyMeshWithGeom() size_t size = theSubMeshList.size(); // check all child sub-meshes of one complexity, @@ -582,3 +584,30 @@ SALOMEDS::TMPFile* SMESH_subMesh_i::GetVtkUgStream() SALOMEDS::TMPFile_var SeqFile; return SeqFile._retn(); } + +//======================================================================= +//function : SMESH_Invalid_subMesh_i +//purpose : constructor of "invalid sub-mesh" created by SMESH_Gen_i::CopyMeshWithGeom() +//======================================================================= + +SMESH_Invalid_subMesh_i::SMESH_Invalid_subMesh_i( PortableServer::POA_ptr thePOA, + SMESH_Gen_i* gen_i, + SMESH_Mesh_i* mesh_i, + int localId, + GEOM::GEOM_Object_ptr shape ) + : SALOME::GenericObj_i( thePOA ), + SMESH_subMesh_i( thePOA, gen_i, mesh_i, localId ) +{ + _geom = GEOM::GEOM_Object::_duplicate( shape ); +} + +//======================================================================= +//function : GetSubShape +//purpose : return geomtry which is not a sub-shape of the main shape +//======================================================================= + +GEOM::GEOM_Object_ptr SMESH_Invalid_subMesh_i::GetSubShape() + throw (SALOME::SALOME_Exception) +{ + return GEOM::GEOM_Object::_duplicate( _geom ); +} diff --git a/src/SMESH_I/SMESH_subMesh_i.hxx b/src/SMESH_I/SMESH_subMesh_i.hxx index b5a814080..cbdb796e0 100644 --- a/src/SMESH_I/SMESH_subMesh_i.hxx +++ b/src/SMESH_I/SMESH_subMesh_i.hxx @@ -130,4 +130,26 @@ protected: friend class SMESH_PreMeshInfo; }; + +class SMESH_I_EXPORT SMESH_Invalid_subMesh_i: + public virtual POA_SMESH::SMESH_subMesh, + public virtual SALOME::GenericObj_i, + public virtual SMESH_subMesh_i +{ + public: + SMESH_Invalid_subMesh_i( PortableServer::POA_ptr thePOA, + SMESH_Gen_i* gen_i, + SMESH_Mesh_i* mesh_i, + int localId, + GEOM::GEOM_Object_ptr shape); + + virtual GEOM::GEOM_Object_ptr GetSubShape() + throw (SALOME::SALOME_Exception); + + protected: + + GEOM::GEOM_Object_var _geom; + +}; + #endif diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index d0bb913c1..a93d9f732 100755 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -782,11 +782,46 @@ class smeshBuilder( SMESH._objref_SMESH_Gen, object ): an instance of class :class:`Mesh` """ - if (isinstance( meshPart, Mesh )): + if isinstance( meshPart, Mesh ): meshPart = meshPart.GetMesh() mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs ) return Mesh(self, self.geompyD, mesh) + def CopyMeshWithGeom( self, sourceMesh, newGeom, meshName="", toCopyGroups=True, + toReuseHypotheses=True, toCopyElements=True): + """ + Create a mesh by copying a mesh definition (hypotheses and groups) to a new geometry. + It is supposed that the new geometry is a modified geometry of *sourceMesh*. + To facilitate and speed up the operation, consider using + "Set presentation parameters and sub-shapes from arguments" option in + a dialog of geometrical operation used to create the new geometry. + + Parameters: + sourceMesh: the mesh to copy definition of. + newGeom: the new geomtry. + meshName: an optional name of the new mesh. If omitted, the mesh name is kept. + toCopyGroups: to create groups in the new mesh. + toReuseHypotheses: to reuse hypotheses of the *sourceMesh*. + toCopyElements: to copy mesh elements present on non-modified sub-shapes of + *sourceMesh*. + Returns: + tuple ( ok, newMesh, newGroups, newSubMeshes, newHypotheses, invalidEntries ) + *invalidEntries* are study entries of objects whose + counterparts are not found in the *newGeom*, followed by entries + of mesh sub-objects that are invalid because they depend on a not found + preceeding sub-shape + """ + if isinstance( sourceMesh, Mesh ): + sourceMesh = sourceMesh.GetMesh() + + ok, newMesh, newGroups, newSubMeshes, newHypotheses, invalidEntries = \ + SMESH._objref_SMESH_Gen.CopyMeshWithGeom( self, sourceMesh, newGeom, meshName, + toCopyGroups, + toReuseHypotheses, + toCopyElements) + return ( ok, Mesh(self, self.geompyD, newMesh), + newGroups, newSubMeshes, newHypotheses, invalidEntries ) + def GetSubShapesId( self, theMainObject, theListOfSubObjects ): """ Return IDs of sub-shapes @@ -6156,7 +6191,7 @@ class Mesh(metaclass = MeshMeta): Fill with 2D elements a hole defined by a SMESH.FreeBorder. Parameters: - FreeBorder: either a SMESH.FreeBorder or a list on node IDs. These nodes + holeNodes: either a SMESH.FreeBorder or a list on node IDs. These nodes must describe all sequential nodes of the hole border. The first and the last nodes must be the same. Use :meth:`FindFreeBorders` to get nodes of holes. groupName (string): name of a group to add new faces diff --git a/src/StdMeshers/StdMeshers_Arithmetic1D.cxx b/src/StdMeshers/StdMeshers_Arithmetic1D.cxx index 89cea269a..18f0da945 100644 --- a/src/StdMeshers/StdMeshers_Arithmetic1D.cxx +++ b/src/StdMeshers/StdMeshers_Arithmetic1D.cxx @@ -49,7 +49,7 @@ using namespace std; //============================================================================= StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, SMESH_Gen * gen) - :SMESH_Hypothesis(hypId, gen) + :StdMeshers_Reversible1D(hypId, gen) { _begLength = 1.; _endLength = 10.; @@ -105,21 +105,6 @@ double StdMeshers_Arithmetic1D::GetLength(bool isStartLength) const */ //============================================================================= -void StdMeshers_Arithmetic1D::SetReversedEdges( std::vector& ids ) -{ - if ( ids != _edgeIDs ) { - _edgeIDs = ids; - - NotifySubMeshesHypothesisModification(); - } -} - -//============================================================================= -/*! - * - */ -//============================================================================= - ostream & StdMeshers_Arithmetic1D::SaveTo(ostream & save) { int listSize = _edgeIDs.size(); @@ -165,28 +150,6 @@ istream & StdMeshers_Arithmetic1D::LoadFrom(istream & load) return load; } -//============================================================================= -/*! - * - */ -//============================================================================= - -ostream & operator <<(ostream & save, StdMeshers_Arithmetic1D & hyp) -{ - return hyp.SaveTo( save ); -} - -//============================================================================= -/*! - * - */ -//============================================================================= - -istream & operator >>(istream & load, StdMeshers_Arithmetic1D & hyp) -{ - return hyp.LoadFrom( load ); -} - //================================================================================ /*! * \brief Initialize start and end length by the mesh built on the geometry diff --git a/src/StdMeshers/StdMeshers_Arithmetic1D.hxx b/src/StdMeshers/StdMeshers_Arithmetic1D.hxx index e0b9cd9b7..eb1a8f437 100644 --- a/src/StdMeshers/StdMeshers_Arithmetic1D.hxx +++ b/src/StdMeshers/StdMeshers_Arithmetic1D.hxx @@ -32,13 +32,11 @@ #include "SMESH_StdMeshers.hxx" +#include "StdMeshers_Reversible1D.hxx" #include "SMESH_Hypothesis.hxx" #include "Utils_SALOME_Exception.hxx" -#include - -class STDMESHERS_EXPORT StdMeshers_Arithmetic1D: - public SMESH_Hypothesis +class STDMESHERS_EXPORT StdMeshers_Arithmetic1D: public StdMeshers_Reversible1D { public: StdMeshers_Arithmetic1D(int hypId, SMESH_Gen* gen); @@ -48,18 +46,8 @@ public: double GetLength(bool isStartLength) const; - void SetReversedEdges( std::vector& ids); - - void SetObjectEntry( const char* entry ) { _objEntry = entry; } - - const char* GetObjectEntry() { return _objEntry.c_str(); } - - const std::vector& GetReversedEdges() const { return _edgeIDs; } - virtual std::ostream & SaveTo(std::ostream & save); virtual std::istream & LoadFrom(std::istream & load); - friend std::ostream& operator << (std::ostream & save, StdMeshers_Arithmetic1D & hyp); - friend std::istream& operator >> (std::istream & load, StdMeshers_Arithmetic1D & hyp); /*! * \brief Initialize start and end length by the mesh built on the geometry @@ -77,8 +65,6 @@ public: protected: double _begLength, _endLength; - std::vector _edgeIDs; - std::string _objEntry; }; #endif diff --git a/src/StdMeshers/StdMeshers_FixedPoints1D.cxx b/src/StdMeshers/StdMeshers_FixedPoints1D.cxx index b5934045b..be0917ef2 100644 --- a/src/StdMeshers/StdMeshers_FixedPoints1D.cxx +++ b/src/StdMeshers/StdMeshers_FixedPoints1D.cxx @@ -35,9 +35,8 @@ using namespace std; */ //============================================================================= -StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId, - SMESH_Gen * gen) - :SMESH_Hypothesis(hypId, gen) +StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId, SMESH_Gen * gen) + :StdMeshers_Reversible1D(hypId, gen) { _name = "FixedPoints1D"; _param_algo_dim = 1; @@ -81,27 +80,6 @@ void StdMeshers_FixedPoints1D::SetNbSegments(std::vector& listNbSeg) NotifySubMeshesHypothesisModification(); } -//============================================================================= -/*! - * - */ -//============================================================================= - -void StdMeshers_FixedPoints1D::SetReversedEdges( std::vector& ids ) -{ - if ( ids != _edgeIDs ) { - _edgeIDs = ids; - - NotifySubMeshesHypothesisModification(); - } -} - -//============================================================================= -/*! - * - */ -//============================================================================= - ostream & StdMeshers_FixedPoints1D::SaveTo(ostream & save) { int listSize = _params.size(); diff --git a/src/StdMeshers/StdMeshers_FixedPoints1D.hxx b/src/StdMeshers/StdMeshers_FixedPoints1D.hxx index 05f903013..58b9be644 100644 --- a/src/StdMeshers/StdMeshers_FixedPoints1D.hxx +++ b/src/StdMeshers/StdMeshers_FixedPoints1D.hxx @@ -29,13 +29,13 @@ #include "SMESH_StdMeshers.hxx" +#include "StdMeshers_Reversible1D.hxx" #include "SMESH_Hypothesis.hxx" #include "Utils_SALOME_Exception.hxx" #include -class STDMESHERS_EXPORT StdMeshers_FixedPoints1D: - public SMESH_Hypothesis +class STDMESHERS_EXPORT StdMeshers_FixedPoints1D: public StdMeshers_Reversible1D { public: StdMeshers_FixedPoints1D(int hypId, SMESH_Gen* gen); @@ -51,14 +51,6 @@ public: const std::vector& GetNbSegments() const { return _nbsegs; } - void SetReversedEdges( std::vector& ids); - - void SetObjectEntry( const char* entry ) { _objEntry = entry; } - - const char* GetObjectEntry() { return _objEntry.c_str(); } - - const std::vector& GetReversedEdges() const { return _edgeIDs; } - virtual std::ostream & SaveTo(std::ostream & save); virtual std::istream & LoadFrom(std::istream & load); @@ -79,8 +71,6 @@ public: protected: std::vector _params; std::vector _nbsegs; - std::vector _edgeIDs; - std::string _objEntry; }; #endif diff --git a/src/StdMeshers/StdMeshers_NumberOfSegments.cxx b/src/StdMeshers/StdMeshers_NumberOfSegments.cxx index 5ba6e47d9..927613048 100644 --- a/src/StdMeshers/StdMeshers_NumberOfSegments.cxx +++ b/src/StdMeshers/StdMeshers_NumberOfSegments.cxx @@ -60,7 +60,7 @@ const double PRECISION = 1e-7; StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments(int hypId, SMESH_Gen * gen) - : SMESH_Hypothesis(hypId, gen), + : StdMeshers_Reversible1D(hypId, gen), _numberOfSegments(15),//issue 19923 _distrType(DT_Regular), _scaleFactor(1.), @@ -721,19 +721,3 @@ bool StdMeshers_NumberOfSegments::SetParametersByDefaults(const TDefaults& dflt { return (_numberOfSegments = dflts._nbSegments ); } - -//============================================================================= -/*! - * - */ -//============================================================================= - -void StdMeshers_NumberOfSegments::SetReversedEdges( std::vector& ids ) -{ - if ( ids != _edgeIDs ) { - _edgeIDs = ids; - - NotifySubMeshesHypothesisModification(); - } -} - diff --git a/src/StdMeshers/StdMeshers_NumberOfSegments.hxx b/src/StdMeshers/StdMeshers_NumberOfSegments.hxx index 6e9e59e3e..3a71f8e0d 100644 --- a/src/StdMeshers/StdMeshers_NumberOfSegments.hxx +++ b/src/StdMeshers/StdMeshers_NumberOfSegments.hxx @@ -29,10 +29,10 @@ #ifndef _SMESH_NUMBEROFSEGMENTS_HXX_ #define _SMESH_NUMBEROFSEGMENTS_HXX_ -#include "SMESH_StdMeshers.hxx" - +#include "StdMeshers_Reversible1D.hxx" #include "SMESH_Hypothesis.hxx" #include "Utils_SALOME_Exception.hxx" + #include /*! @@ -41,8 +41,7 @@ * It provides parameters for subdivision an edge by various * distribution types, considering the given number of resulting segments */ -class STDMESHERS_EXPORT StdMeshers_NumberOfSegments: - public SMESH_Hypothesis +class STDMESHERS_EXPORT StdMeshers_NumberOfSegments: public StdMeshers_Reversible1D { public: StdMeshers_NumberOfSegments(int hypId, SMESH_Gen* gen); @@ -171,14 +170,6 @@ public: int ConversionMode() const throw (SALOME_Exception); - void SetReversedEdges( std::vector& ids); - - void SetObjectEntry( const char* entry ) { _objEntry = entry; } - - const char* GetObjectEntry() { return _objEntry.c_str(); } - - const std::vector& GetReversedEdges() const { return _edgeIDs; } - /*! * \brief Initialize number of segments by the mesh built on the geometry * \param theMesh - the built mesh @@ -205,8 +196,6 @@ protected: std::vector _table, _distr; //!< the table for DT_TabFunc, a sequence of pairs of numbers std::string _func; //!< the expression of the function for DT_ExprFunc int _convMode; //!< flag of conversion mode: 0=exponent, 1=cut negative - std::vector _edgeIDs; //!< list of reversed edges ids - std::string _objEntry; //!< Entry of the main object to reverse edges }; #endif diff --git a/src/StdMeshers/StdMeshers_QuadrangleParams.hxx b/src/StdMeshers/StdMeshers_QuadrangleParams.hxx index 64247e0b6..392447eab 100644 --- a/src/StdMeshers/StdMeshers_QuadrangleParams.hxx +++ b/src/StdMeshers/StdMeshers_QuadrangleParams.hxx @@ -51,7 +51,7 @@ public: int GetTriaVertex() const { return _triaVertexID; } void SetObjectEntry (const char* entry) { _objEntry = entry; } - const char* GetObjectEntry() { return _objEntry.c_str(); } + const char* GetObjectEntry() const { return _objEntry.c_str(); } void SetQuadType (StdMeshers_QuadType type); StdMeshers_QuadType GetQuadType() const { return _quadType; } diff --git a/src/StdMeshers/StdMeshers_Reversible1D.hxx b/src/StdMeshers/StdMeshers_Reversible1D.hxx index 00d61a1da..e2651cd41 100644 --- a/src/StdMeshers/StdMeshers_Reversible1D.hxx +++ b/src/StdMeshers/StdMeshers_Reversible1D.hxx @@ -44,7 +44,7 @@ public: void SetObjectEntry( const char* entry ) { _objEntry = entry; } - const char* GetObjectEntry() { return _objEntry.c_str(); } + const char* GetObjectEntry() const { return _objEntry.c_str(); } const std::vector& GetReversedEdges() const { return _edgeIDs; } diff --git a/src/StdMeshers/StdMeshers_StartEndLength.cxx b/src/StdMeshers/StdMeshers_StartEndLength.cxx index a2bf0f7e1..b89af1677 100644 --- a/src/StdMeshers/StdMeshers_StartEndLength.cxx +++ b/src/StdMeshers/StdMeshers_StartEndLength.cxx @@ -47,9 +47,8 @@ using namespace std; */ //============================================================================= -StdMeshers_StartEndLength::StdMeshers_StartEndLength(int hypId, - SMESH_Gen * gen) - :SMESH_Hypothesis(hypId, gen) +StdMeshers_StartEndLength::StdMeshers_StartEndLength( int hypId, SMESH_Gen* gen ) + :StdMeshers_Reversible1D(hypId, gen) { _begLength = 1.; _endLength = 10.; @@ -105,21 +104,6 @@ double StdMeshers_StartEndLength::GetLength(bool isStartLength) const */ //============================================================================= -void StdMeshers_StartEndLength::SetReversedEdges( std::vector& ids ) -{ - if ( ids != _edgeIDs ) { - _edgeIDs = ids; - - NotifySubMeshesHypothesisModification(); - } -} - -//============================================================================= -/*! - * - */ -//============================================================================= - ostream & StdMeshers_StartEndLength::SaveTo(ostream & save) { int listSize = _edgeIDs.size(); @@ -166,28 +150,6 @@ istream & StdMeshers_StartEndLength::LoadFrom(istream & load) return load; } -//============================================================================= -/*! - * - */ -//============================================================================= - -ostream & operator <<(ostream & save, StdMeshers_StartEndLength & hyp) -{ - return hyp.SaveTo( save ); -} - -//============================================================================= -/*! - * - */ -//============================================================================= - -istream & operator >>(istream & load, StdMeshers_StartEndLength & hyp) -{ - return hyp.LoadFrom( load ); -} - //================================================================================ /*! * \brief Initialize start and end length by the mesh built on the geometry diff --git a/src/StdMeshers/StdMeshers_StartEndLength.hxx b/src/StdMeshers/StdMeshers_StartEndLength.hxx index 576d8e199..dbe7a501c 100644 --- a/src/StdMeshers/StdMeshers_StartEndLength.hxx +++ b/src/StdMeshers/StdMeshers_StartEndLength.hxx @@ -29,12 +29,13 @@ #include "SMESH_StdMeshers.hxx" +#include "StdMeshers_Reversible1D.hxx" #include "SMESH_Hypothesis.hxx" #include "Utils_SALOME_Exception.hxx" #include -class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis +class STDMESHERS_EXPORT StdMeshers_StartEndLength: public StdMeshers_Reversible1D { public: StdMeshers_StartEndLength(int hypId, SMESH_Gen * gen); @@ -44,19 +45,8 @@ class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis double GetLength(bool isStartLength) const; - void SetReversedEdges( std::vector& ids); - - const std::vector& GetReversedEdges() const { return _edgeIDs; } - - void SetObjectEntry( const char* entry ) { _objEntry = entry; } - - const char* GetObjectEntry() { return _objEntry.c_str(); } - virtual std::ostream & SaveTo(std::ostream & save); virtual std::istream & LoadFrom(std::istream & load); - friend std::ostream & operator <<(std::ostream & save, StdMeshers_StartEndLength & hyp); - friend std::istream & operator >>(std::istream & load, StdMeshers_StartEndLength & hyp); - /*! * \brief Initialize start and end length by the mesh built on the geometry @@ -74,8 +64,6 @@ class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis protected: double _begLength, _endLength; - std::vector _edgeIDs; - std::string _objEntry; }; #endif diff --git a/src/StdMeshers_I/StdMeshers_Adaptive1D_i.hxx b/src/StdMeshers_I/StdMeshers_Adaptive1D_i.hxx index 060b8b42a..b83fc0ba5 100644 --- a/src/StdMeshers_I/StdMeshers_Adaptive1D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_Adaptive1D_i.hxx @@ -83,6 +83,12 @@ class STDMESHERS_I_EXPORT StdMeshers_Adaptive1D_i: * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) */ CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + // Methods for copying mesh definition to other geometry + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return false; } + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } }; #endif diff --git a/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx b/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx index 9676549e2..a7cd08ead 100644 --- a/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx +++ b/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx @@ -48,7 +48,8 @@ using namespace std; StdMeshers_Arithmetic1D_i::StdMeshers_Arithmetic1D_i( PortableServer::POA_ptr thePOA, ::SMESH_Gen* theGenImpl ) : SALOME::GenericObj_i( thePOA ), - SMESH_Hypothesis_i( thePOA ) + SMESH_Hypothesis_i( thePOA ), + StdMeshers_Reversible1D_i( this ) { myBaseImpl = new ::StdMeshers_Arithmetic1D( theGenImpl->GetANewId(), theGenImpl ); @@ -131,98 +132,6 @@ CORBA::Double StdMeshers_Arithmetic1D_i::GetLength( CORBA::Boolean theIsStart) return this->GetImpl()->GetLength( theIsStart ); } -//============================================================================= -/*! - * StdMeshers_Arithmetic1D_i::SetReversedEdges - * - * Set edges to reverse - */ -//============================================================================= - -void StdMeshers_Arithmetic1D_i::SetReversedEdges( const SMESH::long_array& theIds ) -{ - ASSERT( myBaseImpl ); - try { - std::vector ids( theIds.length() ); - CORBA::Long iEnd = theIds.length(); - for ( CORBA::Long i = 0; i < iEnd; i++ ) - ids[ i ] = theIds[ i ]; - - this->GetImpl()->SetReversedEdges( ids ); - } - catch ( SALOME_Exception& S_ex ) { - THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), - SALOME::BAD_PARAM ); - } - - // Update Python script - SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )"; -} - -//============================================================================= -/*! - * StdMeshers_Arithmetic1D_i::SetObjectEntry - * - * Set the Entry for the Main Object - */ -//============================================================================= - -void StdMeshers_Arithmetic1D_i::SetObjectEntry( const char* theEntry ) -{ - ASSERT( myBaseImpl ); - string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping - try { - this->GetImpl()->SetObjectEntry( entry.c_str() ); - // Update Python script - SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )"; - } - catch ( SALOME_Exception& S_ex ) { - THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM ); - } -} - -//============================================================================= -/*! - * StdMeshers_Arithmetic1D_i::GetObjectEntry - * - * Set the Entry for the Main Object - */ -//============================================================================= - -char* StdMeshers_Arithmetic1D_i::GetObjectEntry() -{ - ASSERT( myBaseImpl ); - const char* entry; - try { - entry = this->GetImpl()->GetObjectEntry(); - } - catch ( SALOME_Exception& S_ex ) { - THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), - SALOME::BAD_PARAM ); - } - return CORBA::string_dup( entry ); -} - -//============================================================================= -/*! - * StdMeshers_Arithmetic1D_i::GetReversedEdges - * - * Get reversed edges - */ -//============================================================================= - -SMESH::long_array* StdMeshers_Arithmetic1D_i::GetReversedEdges() -{ - ASSERT( myBaseImpl ); - SMESH::long_array_var anArray = new SMESH::long_array; - std::vector ids = this->GetImpl()->GetReversedEdges(); - anArray->length( ids.size() ); - for ( CORBA::ULong i = 0; i < ids.size(); i++) - anArray [ i ] = ids [ i ]; - - return anArray._retn(); -} - //============================================================================= /*! * StdMeshers_Arithmetic1D_i::GetImpl @@ -261,3 +170,30 @@ std::string StdMeshers_Arithmetic1D_i::getMethodOfParameter(const int paramIndex { return paramIndex == 0 ? "SetStartLength" : "SetEndLength"; } + + +//================================================================================ +/*! + * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool +StdMeshers_Arithmetic1D_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const +{ + return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray ); +} + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool +StdMeshers_Arithmetic1D_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) +{ + return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray ); +} diff --git a/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.hxx b/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.hxx index f159f0c48..ad191a26a 100644 --- a/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.hxx @@ -33,7 +33,7 @@ #include #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) -#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_Reversible1D_i.hxx" #include "StdMeshers_Arithmetic1D.hxx" // ====================================================== @@ -41,7 +41,8 @@ // ====================================================== class STDMESHERS_I_EXPORT StdMeshers_Arithmetic1D_i: public virtual POA_StdMeshers::StdMeshers_Arithmetic1D, - public virtual SMESH_Hypothesis_i + public virtual SMESH_Hypothesis_i, + public virtual StdMeshers_Reversible1D_i { public: // Constructor @@ -64,24 +65,23 @@ public: // Get length CORBA::Double GetLength(CORBA::Boolean theIsStart); - //Set Reversed Edges - void SetReversedEdges( const SMESH::long_array& theIDs); - - //Get Reversed Edges - SMESH::long_array* GetReversedEdges(); - - //Set the Entry of the Object - void SetObjectEntry( const char* theEntry); - - //Get Object Entry - char* GetObjectEntry(); - // Get implementation ::StdMeshers_Arithmetic1D* GetImpl(); // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const; + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ); + protected: virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; }; diff --git a/src/StdMeshers_I/StdMeshers_AutomaticLength_i.hxx b/src/StdMeshers_I/StdMeshers_AutomaticLength_i.hxx index a2b4772e6..e7d4ae450 100644 --- a/src/StdMeshers_I/StdMeshers_AutomaticLength_i.hxx +++ b/src/StdMeshers_I/StdMeshers_AutomaticLength_i.hxx @@ -66,6 +66,12 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + // Methods for copying mesh definition to other geometry + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return false; } + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } }; #endif diff --git a/src/StdMeshers_I/StdMeshers_CartesianParameters3D_i.hxx b/src/StdMeshers_I/StdMeshers_CartesianParameters3D_i.hxx index d9f4d603a..4f37edc3a 100644 --- a/src/StdMeshers_I/StdMeshers_CartesianParameters3D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_CartesianParameters3D_i.hxx @@ -141,6 +141,13 @@ class STDMESHERS_I_EXPORT StdMeshers_CartesianParameters3D_i: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + + // Methods for copying mesh definition to other geometry + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return false; } + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } }; #endif diff --git a/src/StdMeshers_I/StdMeshers_Deflection1D_i.hxx b/src/StdMeshers_I/StdMeshers_Deflection1D_i.hxx index 9078455c6..71277100b 100644 --- a/src/StdMeshers_I/StdMeshers_Deflection1D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_Deflection1D_i.hxx @@ -65,6 +65,11 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + // Methods for copying mesh definition to other geometry + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return false; } + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } protected: virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; }; diff --git a/src/StdMeshers_I/StdMeshers_FixedPoints1D_i.cxx b/src/StdMeshers_I/StdMeshers_FixedPoints1D_i.cxx index 08829204e..7dc131acf 100644 --- a/src/StdMeshers_I/StdMeshers_FixedPoints1D_i.cxx +++ b/src/StdMeshers_I/StdMeshers_FixedPoints1D_i.cxx @@ -45,8 +45,9 @@ using namespace std; StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i( PortableServer::POA_ptr thePOA, ::SMESH_Gen* theGenImpl ) - : SALOME::GenericObj_i( thePOA ), - SMESH_Hypothesis_i( thePOA ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ), + StdMeshers_Reversible1D_i( this ) { myBaseImpl = new ::StdMeshers_FixedPoints1D(theGenImpl->GetANewId(), theGenImpl); @@ -156,98 +157,6 @@ SMESH::long_array* StdMeshers_FixedPoints1D_i::GetNbSegments() return anArray._retn(); } -//============================================================================= -/*! - * StdMeshers_FixedPoints1D_i::SetReversedEdges - * - * Set edges to reverse - */ -//============================================================================= - -void StdMeshers_FixedPoints1D_i::SetReversedEdges( const SMESH::long_array& theIds ) -{ - ASSERT( myBaseImpl ); - try { - std::vector ids( theIds.length() ); - CORBA::Long iEnd = theIds.length(); - for ( CORBA::Long i = 0; i < iEnd; i++ ) - ids[ i ] = theIds[ i ]; - - this->GetImpl()->SetReversedEdges( ids ); - } - catch ( SALOME_Exception& S_ex ) { - THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), - SALOME::BAD_PARAM ); - } - - // Update Python script - SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )"; -} - -//============================================================================= -/*! - * StdMeshers_FixedPoints1D_i::SetObjectEntry - * - * Set the Entry for the Main Object - */ -//============================================================================= - -void StdMeshers_FixedPoints1D_i::SetObjectEntry( const char* theEntry ) -{ - ASSERT( myBaseImpl ); - string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping - try { - this->GetImpl()->SetObjectEntry( entry.c_str() ); - // Update Python script - SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )"; - } - catch ( SALOME_Exception& S_ex ) { - THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM ); - } -} - -//============================================================================= -/*! - * StdMeshers_FixedPoints1D_i::GetObjectEntry - * - * Set the Entry for the Main Object - */ -//============================================================================= - -char* StdMeshers_FixedPoints1D_i::GetObjectEntry() -{ - ASSERT( myBaseImpl ); - const char* entry; - try { - entry = this->GetImpl()->GetObjectEntry(); - } - catch ( SALOME_Exception& S_ex ) { - THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), - SALOME::BAD_PARAM ); - } - return CORBA::string_dup( entry ); -} - -//============================================================================= -/*! - * StdMeshers_FixedPoints1D_i::GetReversedEdges - * - * Get reversed edges - */ -//============================================================================= - -SMESH::long_array* StdMeshers_FixedPoints1D_i::GetReversedEdges() -{ - ASSERT( myBaseImpl ); - SMESH::long_array_var anArray = new SMESH::long_array; - std::vector ids = this->GetImpl()->GetReversedEdges(); - anArray->length( ids.size() ); - for ( CORBA::ULong i = 0; i < ids.size(); i++) - anArray [ i ] = ids [ i ]; - - return anArray._retn(); -} - //============================================================================= /*! * StdMeshers_FixedPoints1D_i::GetImpl @@ -269,9 +178,34 @@ SMESH::long_array* StdMeshers_FixedPoints1D_i::GetReversedEdges() * * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) */ -//================================================================================ +//================================================================================ CORBA::Boolean StdMeshers_FixedPoints1D_i::IsDimSupported( SMESH::Dimension type ) { return type == SMESH::DIM_1D; } +//================================================================================ +/*! + * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool +StdMeshers_FixedPoints1D_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const +{ + return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray ); +} + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool +StdMeshers_FixedPoints1D_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) +{ + return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray ); +} diff --git a/src/StdMeshers_I/StdMeshers_FixedPoints1D_i.hxx b/src/StdMeshers_I/StdMeshers_FixedPoints1D_i.hxx index 98d1aff47..0a86129ac 100644 --- a/src/StdMeshers_I/StdMeshers_FixedPoints1D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_FixedPoints1D_i.hxx @@ -30,7 +30,7 @@ #include #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) -#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_Reversible1D_i.hxx" #include "StdMeshers_FixedPoints1D.hxx" // ====================================================== @@ -38,7 +38,8 @@ // ====================================================== class STDMESHERS_I_EXPORT StdMeshers_FixedPoints1D_i: public virtual POA_StdMeshers::StdMeshers_FixedPoints1D, - public virtual SMESH_Hypothesis_i + public virtual SMESH_Hypothesis_i, + public virtual StdMeshers_Reversible1D_i { public: // Constructor @@ -62,23 +63,22 @@ public: // Returns list of numbers of segments SMESH::long_array* GetNbSegments(); - //Set Reversed Edges - void SetReversedEdges( const SMESH::long_array& theIDs); - - //Get Reversed Edges - SMESH::long_array* GetReversedEdges(); - - //Set the Entry of the Object - void SetObjectEntry( const char* theEntry); - - //Get Object Entry - char* GetObjectEntry(); - // Get implementation ::StdMeshers_FixedPoints1D* GetImpl(); // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const; + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ); }; #endif diff --git a/src/StdMeshers_I/StdMeshers_Geometric1D_i.cxx b/src/StdMeshers_I/StdMeshers_Geometric1D_i.cxx index 1d213d975..2b5f241bc 100644 --- a/src/StdMeshers_I/StdMeshers_Geometric1D_i.cxx +++ b/src/StdMeshers_I/StdMeshers_Geometric1D_i.cxx @@ -127,15 +127,41 @@ CORBA::Double StdMeshers_Geometric1D_i::GetCommonRatio() //================================================================================ /*! - * \brief Verify whether hypothesis supports given entity type - * \param type - dimension (see SMESH::Dimension enumeration) - * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise - * + * \brief Verify whether hypothesis supports given entity type + * \param type - dimension (see SMESH::Dimension enumeration) + * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise + * * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) */ -//================================================================================ +//================================================================================ CORBA::Boolean StdMeshers_Geometric1D_i::IsDimSupported(::SMESH::Dimension type) { return type == SMESH::DIM_1D; } + +//================================================================================ +/*! + * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool +StdMeshers_Geometric1D_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const +{ + return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray ); +} + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool +StdMeshers_Geometric1D_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) +{ + return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray ); +} diff --git a/src/StdMeshers_I/StdMeshers_Geometric1D_i.hxx b/src/StdMeshers_I/StdMeshers_Geometric1D_i.hxx index 542e88e5e..6ccb5d70a 100644 --- a/src/StdMeshers_I/StdMeshers_Geometric1D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_Geometric1D_i.hxx @@ -59,6 +59,18 @@ class STDMESHERS_I_EXPORT StdMeshers_Geometric1D_i: // Get implementation ::StdMeshers_Geometric1D* GetImpl(); + + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const; + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ); }; #endif diff --git a/src/StdMeshers_I/StdMeshers_ImportSource1D_i.hxx b/src/StdMeshers_I/StdMeshers_ImportSource1D_i.hxx index 61d62654e..ab1e9bb6c 100644 --- a/src/StdMeshers_I/StdMeshers_ImportSource1D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_ImportSource1D_i.hxx @@ -64,6 +64,17 @@ class STDMESHERS_I_EXPORT StdMeshers_ImportSource1D_i: virtual void LoadFrom( const char* theStream ); virtual void UpdateAsMeshesRestored(); + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return 0; } + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } private: SMESH::string_array_var _groupEntries; std::vector< std::string > _groupIDs; diff --git a/src/StdMeshers_I/StdMeshers_ImportSource2D_i.hxx b/src/StdMeshers_I/StdMeshers_ImportSource2D_i.hxx index 8b346df67..f377bceb1 100644 --- a/src/StdMeshers_I/StdMeshers_ImportSource2D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_ImportSource2D_i.hxx @@ -64,6 +64,17 @@ class STDMESHERS_I_EXPORT StdMeshers_ImportSource2D_i: virtual void LoadFrom( const char* theStream ); virtual void UpdateAsMeshesRestored(); + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return 0; } + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } private: SMESH::string_array_var _groupEntries; std::vector< std::string > _groupIDs; diff --git a/src/StdMeshers_I/StdMeshers_LayerDistribution2D_i.hxx b/src/StdMeshers_I/StdMeshers_LayerDistribution2D_i.hxx index 2831138b9..9b9ba7a52 100644 --- a/src/StdMeshers_I/StdMeshers_LayerDistribution2D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_LayerDistribution2D_i.hxx @@ -54,6 +54,17 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return 0; } + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } }; #endif diff --git a/src/StdMeshers_I/StdMeshers_LayerDistribution_i.hxx b/src/StdMeshers_I/StdMeshers_LayerDistribution_i.hxx index 69050ee70..43942228c 100644 --- a/src/StdMeshers_I/StdMeshers_LayerDistribution_i.hxx +++ b/src/StdMeshers_I/StdMeshers_LayerDistribution_i.hxx @@ -77,6 +77,17 @@ public: virtual char* SaveTo(); virtual void LoadFrom( const char* theStream ); + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return 0; } + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } protected: // restore myMethod2VarParams by parameters stored in an old study virtual void setOldParameters (const char* theParameters); diff --git a/src/StdMeshers_I/StdMeshers_LengthFromEdges_i.hxx b/src/StdMeshers_I/StdMeshers_LengthFromEdges_i.hxx index 0318fd0e1..17cde7be8 100644 --- a/src/StdMeshers_I/StdMeshers_LengthFromEdges_i.hxx +++ b/src/StdMeshers_I/StdMeshers_LengthFromEdges_i.hxx @@ -66,6 +66,17 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return 0; } + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } }; #endif diff --git a/src/StdMeshers_I/StdMeshers_LocalLength_i.hxx b/src/StdMeshers_I/StdMeshers_LocalLength_i.hxx index 14a01b76d..0fcd0d089 100644 --- a/src/StdMeshers_I/StdMeshers_LocalLength_i.hxx +++ b/src/StdMeshers_I/StdMeshers_LocalLength_i.hxx @@ -71,6 +71,17 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return 0; } + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } protected: virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; }; diff --git a/src/StdMeshers_I/StdMeshers_MaxElementArea_i.hxx b/src/StdMeshers_I/StdMeshers_MaxElementArea_i.hxx index 7f7fe254f..0651ac899 100644 --- a/src/StdMeshers_I/StdMeshers_MaxElementArea_i.hxx +++ b/src/StdMeshers_I/StdMeshers_MaxElementArea_i.hxx @@ -63,6 +63,18 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return 0; } + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } + protected: virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; }; diff --git a/src/StdMeshers_I/StdMeshers_MaxElementVolume_i.hxx b/src/StdMeshers_I/StdMeshers_MaxElementVolume_i.hxx index d40369cb7..108b9804c 100644 --- a/src/StdMeshers_I/StdMeshers_MaxElementVolume_i.hxx +++ b/src/StdMeshers_I/StdMeshers_MaxElementVolume_i.hxx @@ -63,6 +63,17 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return 0; } + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } protected: virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; }; diff --git a/src/StdMeshers_I/StdMeshers_MaxLength_i.hxx b/src/StdMeshers_I/StdMeshers_MaxLength_i.hxx index b4b633231..bd1ea6334 100644 --- a/src/StdMeshers_I/StdMeshers_MaxLength_i.hxx +++ b/src/StdMeshers_I/StdMeshers_MaxLength_i.hxx @@ -77,6 +77,17 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return 0; } + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } protected: virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; }; diff --git a/src/StdMeshers_I/StdMeshers_NotConformAllowed_i.hxx b/src/StdMeshers_I/StdMeshers_NotConformAllowed_i.hxx index ee4107f10..510d0cf1a 100644 --- a/src/StdMeshers_I/StdMeshers_NotConformAllowed_i.hxx +++ b/src/StdMeshers_I/StdMeshers_NotConformAllowed_i.hxx @@ -50,6 +50,17 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return 0; } + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } protected: ::StdMeshers_NotConformAllowed* _impl; }; diff --git a/src/StdMeshers_I/StdMeshers_NumberOfLayers2D_i.hxx b/src/StdMeshers_I/StdMeshers_NumberOfLayers2D_i.hxx index 42672b838..4534245a9 100644 --- a/src/StdMeshers_I/StdMeshers_NumberOfLayers2D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_NumberOfLayers2D_i.hxx @@ -52,6 +52,17 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return 0; } + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } }; #endif diff --git a/src/StdMeshers_I/StdMeshers_NumberOfLayers_i.hxx b/src/StdMeshers_I/StdMeshers_NumberOfLayers_i.hxx index 77a619883..13649309f 100644 --- a/src/StdMeshers_I/StdMeshers_NumberOfLayers_i.hxx +++ b/src/StdMeshers_I/StdMeshers_NumberOfLayers_i.hxx @@ -68,6 +68,17 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return 0; } + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } protected: virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; }; diff --git a/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx b/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx index c61aa3785..1c5163385 100644 --- a/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx +++ b/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx @@ -36,7 +36,6 @@ #include -using namespace std; //============================================================================= /*! * StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i @@ -47,8 +46,9 @@ using namespace std; StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i( PortableServer::POA_ptr thePOA, ::SMESH_Gen* theGenImpl ) - : SALOME::GenericObj_i( thePOA ), - SMESH_Hypothesis_i( thePOA ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ), + StdMeshers_Reversible1D_i( this ) { myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(), theGenImpl ); @@ -159,100 +159,6 @@ CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments() return this->GetImpl()->GetNumberOfSegments(); } -//============================================================================= -/*! - * StdMeshers_NumberOfSegments_i::SetReversedEdges - * - * Set edges to reverse - */ -//============================================================================= - -void StdMeshers_NumberOfSegments_i::SetReversedEdges( const SMESH::long_array& theIds ) -{ - ASSERT( myBaseImpl ); - try { - std::vector ids( theIds.length() ); - CORBA::Long iEnd = theIds.length(); - for ( CORBA::Long i = 0; i < iEnd; i++ ) - ids[ i ] = theIds[ i ]; - - this->GetImpl()->SetReversedEdges( ids ); - } - catch ( SALOME_Exception& S_ex ) { - THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), - SALOME::BAD_PARAM ); - } - - // Update Python script - SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )"; -} - -//============================================================================= -/*! - * StdMeshers_NumberOfSegments_i::SetObjectEntry - * - * Set the Entry for the Main Object - */ -//============================================================================= - -void StdMeshers_NumberOfSegments_i::SetObjectEntry( const char* theEntry ) -{ - ASSERT( myBaseImpl ); - string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping - try { - this->GetImpl()->SetObjectEntry( entry.c_str() ); - } - catch ( SALOME_Exception& S_ex ) { - THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), - SALOME::BAD_PARAM ); - } - // Update Python script - SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )"; -} - -//============================================================================= -/*! - * StdMeshers_NumberOfSegments_i::GetObjectEntry - * - * Set the Entry for the Main Object - */ -//============================================================================= - -char* StdMeshers_NumberOfSegments_i::GetObjectEntry() -{ - ASSERT( myBaseImpl ); - - const char* entry; - try { - entry = this->GetImpl()->GetObjectEntry(); - } - catch ( SALOME_Exception& S_ex ) { - THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), - SALOME::BAD_PARAM ); - } - return CORBA::string_dup( entry ); -} - -//============================================================================= -/*! - * StdMeshers_NumberOfSegments_i::GetReversedEdges - * - * Get reversed edges - */ -//============================================================================= - -SMESH::long_array* StdMeshers_NumberOfSegments_i::GetReversedEdges() -{ - ASSERT( myBaseImpl ); - SMESH::long_array_var anArray = new SMESH::long_array; - std::vector ids = this->GetImpl()->GetReversedEdges(); - anArray->length( ids.size() ); - for ( size_t i = 0; i < ids.size(); i++) - anArray [ i ] = ids [ i ]; - - return anArray._retn(); -} - //============================================================================= /*! */ @@ -497,3 +403,30 @@ std::string StdMeshers_NumberOfSegments_i::getMethodOfParameter(const int paramI { return paramIndex == 0 ? "SetNumberOfSegments" : "SetScaleFactor"; } + + +//================================================================================ +/*! + * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool +StdMeshers_NumberOfSegments_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const +{ + return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray ); +} + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool +StdMeshers_NumberOfSegments_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) +{ + return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray ); +} diff --git a/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.hxx b/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.hxx index 09301653b..fc623af13 100644 --- a/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.hxx +++ b/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.hxx @@ -35,7 +35,7 @@ #include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) -#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_Reversible1D_i.hxx" #include "StdMeshers_NumberOfSegments.hxx" // ====================================================== @@ -43,7 +43,8 @@ // ====================================================== class STDMESHERS_I_EXPORT StdMeshers_NumberOfSegments_i: public virtual POA_StdMeshers::StdMeshers_NumberOfSegments, - public virtual SMESH_Hypothesis_i + public virtual SMESH_Hypothesis_i, + public virtual StdMeshers_Reversible1D_i { public: // Constructor @@ -104,18 +105,16 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); - //Set Reversed Edges - void SetReversedEdges( const SMESH::long_array& theIDs); - //Get Reversed Edges - SMESH::long_array* GetReversedEdges(); + // Methods for copying mesh definition to other geometry - //Set Object Entry - void SetObjectEntry( const char* entry); - - //Get Object Entry - char* GetObjectEntry(); + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const; + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ); protected: virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; }; diff --git a/src/StdMeshers_I/StdMeshers_ObjRefUlils.cxx b/src/StdMeshers_I/StdMeshers_ObjRefUlils.cxx index c7e3988b8..f9a2b7837 100644 --- a/src/StdMeshers_I/StdMeshers_ObjRefUlils.cxx +++ b/src/StdMeshers_I/StdMeshers_ObjRefUlils.cxx @@ -162,3 +162,21 @@ void StdMeshers_ObjRefUlils::SaveToStream( const std::string& studyEntry, else stream << " " << studyEntry; } + +//======================================================================= +//function : EntryToShape +//purpose : Return TopoDS_Shape by a study entry +//======================================================================= + +TopoDS_Shape StdMeshers_ObjRefUlils::EntryToShape(const std::string theEntry) +{ + TopoDS_Shape shape; + + if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) { + SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( theEntry.c_str() ); + CORBA::Object_var obj = gen->SObjectToObject( sobj ); + GEOM::GEOM_Object_var geom = GEOM::GEOM_Object::_narrow( obj ); + shape = gen->GeomObjectToShape( geom.in() ); + } + return shape; +} diff --git a/src/StdMeshers_I/StdMeshers_ObjRefUlils.hxx b/src/StdMeshers_I/StdMeshers_ObjRefUlils.hxx index fb2540c65..757cea482 100644 --- a/src/StdMeshers_I/StdMeshers_ObjRefUlils.hxx +++ b/src/StdMeshers_I/StdMeshers_ObjRefUlils.hxx @@ -65,6 +65,13 @@ public: return TopoDS_Shape(); } + /*! + * \brief Return TopoDS_Shape by a study entry + * \param theEntry - study entry + * \retval TopoDS_Shape - result TopoDS_Shape + */ + static TopoDS_Shape EntryToShape(const std::string theEntry); + /*! * \brief Return study entry of GEOM Object */ diff --git a/src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.cxx b/src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.cxx index 7b4048662..e0243b187 100644 --- a/src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.cxx +++ b/src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.cxx @@ -298,3 +298,46 @@ void StdMeshers_ProjectionSource1D_i::LoadFrom( const char* theStream ) str >> myShapeEntries[ i ]; } +//================================================================================ +/*! + * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool +StdMeshers_ProjectionSource1D_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const +{ + for ( int i = 0; i < NB_SHAPES; ++i ) + entryArray.push_back( myShapeEntries[ i ]); + + return true; +} + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool +StdMeshers_ProjectionSource1D_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) +{ + TopoDS_Shape shapes[ NB_SHAPES ]; + for ( int i = 0; i < NB_SHAPES; ++i ) + { + myShapeEntries[ i ] = entryArray[ i ]; + shapes[ i ] = StdMeshers_ObjRefUlils::EntryToShape( entryArray[ i ]); + } + + try { + GetImpl()->SetSourceEdge ( shapes[ SRC_EDGE ] ); + GetImpl()->SetVertexAssociation( shapes[ SRC_VERTEX ], + shapes[ TGT_VERTEX ]); + } + catch (...) { + return false; + } + return true; +} diff --git a/src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.hxx b/src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.hxx index 1b7c6981b..bbd1e5e58 100644 --- a/src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.hxx @@ -109,6 +109,15 @@ public: virtual char* SaveTo(); virtual void LoadFrom( const char* theStream ); + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const; + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ); private: // keep entries because the same shape can be published several times with // different names and in this case a correct name can't be restored by a TopoDS_Shape diff --git a/src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.cxx b/src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.cxx index ff0364603..5d3706d9f 100644 --- a/src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.cxx +++ b/src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.cxx @@ -311,3 +311,48 @@ void StdMeshers_ProjectionSource2D_i::LoadFrom( const char* theStream ) str >> myShapeEntries[ i ]; } +//================================================================================ +/*! + * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool +StdMeshers_ProjectionSource2D_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const +{ + for ( int i = 0; i < NB_SHAPES; ++i ) + entryArray.push_back( myShapeEntries[ i ]); + + return true; +} + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool +StdMeshers_ProjectionSource2D_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) +{ + TopoDS_Shape shapes[ NB_SHAPES ]; + for ( int i = 0; i < NB_SHAPES; ++i ) + { + myShapeEntries[ i ] = entryArray[ i ]; + shapes[ i ] = StdMeshers_ObjRefUlils::EntryToShape( entryArray[ i ]); + } + + try { + GetImpl()->SetSourceFace ( shapes[ SRC_FACE ] ); + GetImpl()->SetVertexAssociation( shapes[ SRC_VERTEX1 ], + shapes[ SRC_VERTEX2 ], + shapes[ TGT_VERTEX1 ], + shapes[ TGT_VERTEX2 ]); + } + catch (...) { + return false; + } + return true; +} diff --git a/src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.hxx b/src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.hxx index 2ba81dc0a..e8352df31 100644 --- a/src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.hxx @@ -113,6 +113,16 @@ public: virtual char* SaveTo(); virtual void LoadFrom( const char* theStream ); + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const; + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ); private: // keep entries because the same shape can be published several times with // different names and in this case a correct name can't be restored by a TopoDS_Shape diff --git a/src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.cxx b/src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.cxx index 062602d89..bbbf9e3cb 100644 --- a/src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.cxx +++ b/src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.cxx @@ -312,3 +312,48 @@ void StdMeshers_ProjectionSource3D_i::LoadFrom( const char* theStream ) str >> myShapeEntries[ i ]; } +//================================================================================ +/*! + * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool +StdMeshers_ProjectionSource3D_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const +{ + for ( int i = 0; i < NB_SHAPES; ++i ) + entryArray.push_back( myShapeEntries[ i ]); + + return true; +} + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool +StdMeshers_ProjectionSource3D_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) +{ + TopoDS_Shape shapes[ NB_SHAPES ]; + for ( int i = 0; i < NB_SHAPES; ++i ) + { + myShapeEntries[ i ] = entryArray[ i ]; + shapes[ i ] = StdMeshers_ObjRefUlils::EntryToShape( entryArray[ i ]); + } + + try { + GetImpl()->SetSource3DShape ( shapes[ SRC_SHAPE3D ] ); + GetImpl()->SetVertexAssociation( shapes[ SRC_VERTEX1 ], + shapes[ SRC_VERTEX2 ], + shapes[ TGT_VERTEX1 ], + shapes[ TGT_VERTEX2 ]); + } + catch (...) { + return false; + } + return true; +} diff --git a/src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.hxx b/src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.hxx index 5a25111cd..003181849 100644 --- a/src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.hxx @@ -114,6 +114,17 @@ public: virtual char* SaveTo(); virtual void LoadFrom( const char* theStream ); + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const; + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ); + private: // keep entries because the same shape can be published several times with // different names and in this case a correct name can't be restored by a TopoDS_Shape @@ -124,4 +135,3 @@ private: }; #endif - diff --git a/src/StdMeshers_I/StdMeshers_Propagation_i.hxx b/src/StdMeshers_I/StdMeshers_Propagation_i.hxx index 961f203d1..ae5819c31 100644 --- a/src/StdMeshers_I/StdMeshers_Propagation_i.hxx +++ b/src/StdMeshers_I/StdMeshers_Propagation_i.hxx @@ -52,6 +52,12 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + // Methods for copying mesh definition to other geometry + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return false; } + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } }; // ====================================================== @@ -69,6 +75,12 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + // Methods for copying mesh definition to other geometry + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return false; } + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } }; #endif diff --git a/src/StdMeshers_I/StdMeshers_QuadrangleParams_i.cxx b/src/StdMeshers_I/StdMeshers_QuadrangleParams_i.cxx index 78b2841e1..aa3f947dd 100644 --- a/src/StdMeshers_I/StdMeshers_QuadrangleParams_i.cxx +++ b/src/StdMeshers_I/StdMeshers_QuadrangleParams_i.cxx @@ -378,3 +378,54 @@ void StdMeshers_QuadrangleParams_i::LoadFrom( const char* theStream ) myBaseImpl->LoadFrom( is ); } + +//================================================================================ +/*! + * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool +StdMeshers_QuadrangleParams_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const +{ + const ::StdMeshers_QuadrangleParams* impl = + static_cast( myBaseImpl ); + + subIDArray.push_back( impl->GetTriaVertex() ); + + entryArray.push_back( impl->GetObjectEntry() ); + entryArray.insert( entryArray.end(), myShapeEntries.begin(), myShapeEntries.end() ); + + return true; +} + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool +StdMeshers_QuadrangleParams_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) +{ + if ( !subIDArray.empty() ) + GetImpl()->SetTriaVertex( subIDArray[0] ); + + GetImpl()->SetObjectEntry( entryArray[0].c_str() ); + + myShapeEntries.assign( ++entryArray.begin(), entryArray.end() ); + + std::vector< TopoDS_Shape > shapes; + std::vector< gp_Pnt > points; + this->GetImpl()->GetEnforcedNodes( shapes, points ); + + shapes.clear(); + for ( size_t i = 0; i < myShapeEntries.size(); ++i ) + shapes.push_back( StdMeshers_ObjRefUlils::EntryToShape( myShapeEntries[i] )); + + this->GetImpl()->SetEnforcedNodes( shapes, points ); + + return true; +} diff --git a/src/StdMeshers_I/StdMeshers_QuadrangleParams_i.hxx b/src/StdMeshers_I/StdMeshers_QuadrangleParams_i.hxx index 227dd86af..822b501e5 100644 --- a/src/StdMeshers_I/StdMeshers_QuadrangleParams_i.hxx +++ b/src/StdMeshers_I/StdMeshers_QuadrangleParams_i.hxx @@ -84,6 +84,16 @@ public: virtual char* SaveTo(); virtual void LoadFrom( const char* theStream ); + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const; + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ); protected: std::vector myShapeEntries; diff --git a/src/StdMeshers_I/StdMeshers_QuadranglePreference_i.hxx b/src/StdMeshers_I/StdMeshers_QuadranglePreference_i.hxx index e60f07329..5e0455ac0 100644 --- a/src/StdMeshers_I/StdMeshers_QuadranglePreference_i.hxx +++ b/src/StdMeshers_I/StdMeshers_QuadranglePreference_i.hxx @@ -58,6 +58,12 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + // Methods for copying mesh definition to other geometry + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return false; } + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } }; #endif diff --git a/src/StdMeshers_I/StdMeshers_QuadraticMesh_i.hxx b/src/StdMeshers_I/StdMeshers_QuadraticMesh_i.hxx index 71c17acad..433b73734 100644 --- a/src/StdMeshers_I/StdMeshers_QuadraticMesh_i.hxx +++ b/src/StdMeshers_I/StdMeshers_QuadraticMesh_i.hxx @@ -59,6 +59,12 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + // Methods for copying mesh definition to other geometry + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return false; } + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } }; #endif diff --git a/src/StdMeshers_I/StdMeshers_Reversible1D_i.cxx b/src/StdMeshers_I/StdMeshers_Reversible1D_i.cxx index 315f30b15..644aa7075 100644 --- a/src/StdMeshers_I/StdMeshers_Reversible1D_i.cxx +++ b/src/StdMeshers_I/StdMeshers_Reversible1D_i.cxx @@ -139,5 +139,46 @@ SMESH::long_array* StdMeshers_Reversible1D_i::GetReversedEdges() ::StdMeshers_Reversible1D* StdMeshers_Reversible1D_i::GetImpl() { - return ( ::StdMeshers_Reversible1D* )myHyp->GetImpl(); + return static_cast<::StdMeshers_Reversible1D* >( myHyp->GetImpl() ); +} + +//================================================================================ +/*! + * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool +StdMeshers_Reversible1D_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const +{ + const ::StdMeshers_Reversible1D* impl = ( const ::StdMeshers_Reversible1D* ) myHyp->GetImpl(); + subIDArray = impl->GetReversedEdges(); + entryArray.push_back( impl->GetObjectEntry() ); + + return true; +} + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool +StdMeshers_Reversible1D_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) +{ + std::vector< int > newIDs; + newIDs.reserve( subIDArray.size() ); + + for ( size_t i = 0; i < subIDArray.size(); ++i ) + if ( subIDArray[ i ] > 0 ) + newIDs.push_back( subIDArray[ i ]); + GetImpl()->SetReversedEdges( newIDs ); + + if ( !entryArray.empty() ) + GetImpl()->SetObjectEntry( entryArray[0].c_str() ); + + return true; } diff --git a/src/StdMeshers_I/StdMeshers_Reversible1D_i.hxx b/src/StdMeshers_I/StdMeshers_Reversible1D_i.hxx index 8e24f9102..e80041c88 100644 --- a/src/StdMeshers_I/StdMeshers_Reversible1D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_Reversible1D_i.hxx @@ -36,7 +36,7 @@ #include "StdMeshers_Reversible1D.hxx" // ====================================================== -// Common metrhods of Reversible 1D hypotheses +// Common methods of Reversible 1D hypotheses // ====================================================== class STDMESHERS_I_EXPORT StdMeshers_Reversible1D_i: public virtual POA_StdMeshers::Reversible1D @@ -59,8 +59,17 @@ class STDMESHERS_I_EXPORT StdMeshers_Reversible1D_i: // Get implementation ::StdMeshers_Reversible1D* GetImpl(); + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const; + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ); private: SMESH_Hypothesis_i* myHyp; }; - #endif diff --git a/src/StdMeshers_I/StdMeshers_SegmentLengthAroundVertex_i.hxx b/src/StdMeshers_I/StdMeshers_SegmentLengthAroundVertex_i.hxx index 30ee53023..c1491a4e1 100644 --- a/src/StdMeshers_I/StdMeshers_SegmentLengthAroundVertex_i.hxx +++ b/src/StdMeshers_I/StdMeshers_SegmentLengthAroundVertex_i.hxx @@ -63,6 +63,16 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const { return 0; } + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) { return true; } protected: virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; }; diff --git a/src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx b/src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx index aa38fc2ad..622474605 100644 --- a/src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx +++ b/src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx @@ -49,7 +49,8 @@ using namespace std; StdMeshers_StartEndLength_i::StdMeshers_StartEndLength_i( PortableServer::POA_ptr thePOA, ::SMESH_Gen* theGenImpl ) : SALOME::GenericObj_i( thePOA ), - SMESH_Hypothesis_i( thePOA ) + SMESH_Hypothesis_i( thePOA ), + StdMeshers_Reversible1D_i( this ) { myBaseImpl = new ::StdMeshers_StartEndLength( theGenImpl->GetANewId(), theGenImpl ); @@ -132,97 +133,6 @@ CORBA::Double StdMeshers_StartEndLength_i::GetLength( CORBA::Boolean theIsStart) return this->GetImpl()->GetLength( theIsStart ); } -//============================================================================= -/*! - * StdMeshers_StartEndLength_i::SetReversedEdges - * - * Set edges to reverse - */ -//============================================================================= - -void StdMeshers_StartEndLength_i::SetReversedEdges( const SMESH::long_array& theIds ) -{ - ASSERT( myBaseImpl ); - try { - std::vector ids( theIds.length() ); - CORBA::Long iEnd = theIds.length(); - for ( CORBA::Long i = 0; i < iEnd; i++ ) - ids[ i ] = theIds[ i ]; - - this->GetImpl()->SetReversedEdges( ids ); - } - catch ( SALOME_Exception& S_ex ) { - THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), - SALOME::BAD_PARAM ); - } - - // Update Python script - SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )"; -} - -//============================================================================= -/*! - * StdMeshers_StartEndLength_i::SetObjectEntry - * - * Set the Entry for the Main Object - */ -//============================================================================= - -void StdMeshers_StartEndLength_i::SetObjectEntry( const char* theEntry ) -{ - ASSERT( myBaseImpl ); - string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping - try { - this->GetImpl()->SetObjectEntry( entry.c_str() ); - // Update Python script - SMESH::TPythonDump() << _this() << ".SetObjectEntry( '" << entry.c_str() << "' )"; - } - catch ( SALOME_Exception& S_ex ) { - THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM ); - } -} - -//============================================================================= -/*! - * StdMeshers_StartEndLength_i::GetObjectEntry - * - * Set the Entry for the Main Object - */ -//============================================================================= - -char* StdMeshers_StartEndLength_i::GetObjectEntry() -{ - ASSERT( myBaseImpl ); - const char* entry; - try { - entry = this->GetImpl()->GetObjectEntry(); - } - catch ( SALOME_Exception& S_ex ) { - THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); - } - return CORBA::string_dup( entry ); -} - -//============================================================================= -/*! - * StdMeshers_StartEndLength_i::GetReversedEdges - * - * Get reversed edges - */ -//============================================================================= - -SMESH::long_array* StdMeshers_StartEndLength_i::GetReversedEdges() -{ - ASSERT( myBaseImpl ); - SMESH::long_array_var anArray = new SMESH::long_array; - std::vector ids = this->GetImpl()->GetReversedEdges(); - anArray->length( ids.size() ); - for ( CORBA::ULong i = 0; i < ids.size(); i++) - anArray [ i ] = ids [ i ]; - - return anArray._retn(); -} - //============================================================================= /*! * StdMeshers_StartEndLength_i::GetImpl @@ -261,3 +171,29 @@ std::string StdMeshers_StartEndLength_i::getMethodOfParameter(const int paramInd { return paramIndex == 0 ? "SetStartLength" : "SetEndLength"; } + +//================================================================================ +/*! + * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool +StdMeshers_StartEndLength_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const +{ + return StdMeshers_Reversible1D_i::getObjectsDependOn( entryArray, subIDArray ); +} + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool +StdMeshers_StartEndLength_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) +{ + return StdMeshers_Reversible1D_i::setObjectsDependOn( entryArray, subIDArray ); +} diff --git a/src/StdMeshers_I/StdMeshers_StartEndLength_i.hxx b/src/StdMeshers_I/StdMeshers_StartEndLength_i.hxx index 50e989105..24fdb86a7 100644 --- a/src/StdMeshers_I/StdMeshers_StartEndLength_i.hxx +++ b/src/StdMeshers_I/StdMeshers_StartEndLength_i.hxx @@ -34,7 +34,7 @@ #include #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) -#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_Reversible1D_i.hxx" #include "StdMeshers_StartEndLength.hxx" class SMESH_Gen; @@ -44,7 +44,8 @@ class SMESH_Gen; // ====================================================== class STDMESHERS_I_EXPORT StdMeshers_StartEndLength_i: public virtual POA_StdMeshers::StdMeshers_StartEndLength, - public virtual SMESH_Hypothesis_i + public virtual SMESH_Hypothesis_i, + public virtual StdMeshers_Reversible1D_i { public: // Constructor @@ -73,17 +74,16 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); - //Set Reversed Edges - void SetReversedEdges( const SMESH::long_array& theIDs); - //Get Reversed Edges - SMESH::long_array* GetReversedEdges(); + // Methods for copying mesh definition to other geometry - //Set Object Entry - void SetObjectEntry( const char* entry); + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const; - //Get Object Entry - char* GetObjectEntry(); + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ); protected: virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; diff --git a/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.cxx b/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.cxx index 638d03d95..c5877c77f 100644 --- a/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.cxx +++ b/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.cxx @@ -235,13 +235,13 @@ throw ( SALOME::SALOME_Exception ) //================================================================================ /*! - * \brief Verify whether hypothesis supports given entity type - * \param type - dimension (see SMESH::Dimension enumeration) - * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise - * + * \brief Verify whether hypothesis supports given entity type + * \param type - dimension (see SMESH::Dimension enumeration) + * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise + * * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) */ -//================================================================================ +//================================================================================ CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension type ) { @@ -251,7 +251,7 @@ CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension ty //================================================================================ /*! * \brief Sets sub-mesh event listeners to clear sub-meshes of edges - * shrinked by viscous layers + * shrinked by viscous layers */ //================================================================================ @@ -259,3 +259,43 @@ void StdMeshers_ViscousLayers2D_i::UpdateAsMeshesRestored() { GetImpl()->RestoreListeners(); } + +//================================================================================ +/*! + * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool +StdMeshers_ViscousLayers2D_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const +{ + const ::StdMeshers_ViscousLayers2D* impl = + static_cast( myBaseImpl ); + + subIDArray = impl->GetBndShapes(); + + return true; +} + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool +StdMeshers_ViscousLayers2D_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) +{ + std::vector< int > newIDs; + newIDs.reserve( subIDArray.size() ); + + for ( size_t i = 0; i < subIDArray.size(); ++i ) + if ( subIDArray[ i ] > 0 ) + newIDs.push_back( subIDArray[ i ]); + + GetImpl()->SetBndShapes( newIDs, GetIsToIgnoreEdges() ); + + return true; +} diff --git a/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.hxx b/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.hxx index 0b28e8597..2ca1310f5 100644 --- a/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.hxx @@ -73,6 +73,17 @@ class STDMESHERS_I_EXPORT StdMeshers_ViscousLayers2D_i: // Sets sub-mesh event listeners to clear sub-meshes of edges // shrinked by viscous layers virtual void UpdateAsMeshesRestored(); + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const; + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ); }; #endif diff --git a/src/StdMeshers_I/StdMeshers_ViscousLayers_i.cxx b/src/StdMeshers_I/StdMeshers_ViscousLayers_i.cxx index 6ae54c6e8..914d92260 100644 --- a/src/StdMeshers_I/StdMeshers_ViscousLayers_i.cxx +++ b/src/StdMeshers_I/StdMeshers_ViscousLayers_i.cxx @@ -295,3 +295,44 @@ std::string StdMeshers_ViscousLayers_i::getMethodOfParameter(const int paramInde } return ""; } + + +//================================================================================ +/*! + * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool +StdMeshers_ViscousLayers_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const +{ + const ::StdMeshers_ViscousLayers* impl = + static_cast( myBaseImpl ); + + subIDArray = impl->GetBndShapes(); + + return true; +} + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool +StdMeshers_ViscousLayers_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) +{ + std::vector< int > newIDs; + newIDs.reserve( subIDArray.size() ); + + for ( size_t i = 0; i < subIDArray.size(); ++i ) + if ( subIDArray[ i ] > 0 ) + newIDs.push_back( subIDArray[ i ]); + + GetImpl()->SetBndShapes( newIDs, GetIsToIgnoreFaces() ); + + return true; +} diff --git a/src/StdMeshers_I/StdMeshers_ViscousLayers_i.hxx b/src/StdMeshers_I/StdMeshers_ViscousLayers_i.hxx index 19f5835b0..246a91442 100644 --- a/src/StdMeshers_I/StdMeshers_ViscousLayers_i.hxx +++ b/src/StdMeshers_I/StdMeshers_ViscousLayers_i.hxx @@ -73,6 +73,15 @@ class STDMESHERS_I_EXPORT StdMeshers_ViscousLayers_i: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const; + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ); protected: virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; };