From: eap Date: Wed, 17 Oct 2018 14:13:24 +0000 (+0300) Subject: 23605: [EDF] HYDRO: parent mesh for Copy mesh with new geometry X-Git-Tag: HYDRO_V2_0_0~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=515dcacf5797ad721b7f3a8c7cf0078eb3815d18;p=modules%2Fsmesh.git 23605: [EDF] HYDRO: parent mesh for Copy mesh with new geometry 23606: [EDF] HYDRO: Help for option Copy mesh with new geometry is absent --- diff --git a/doc/salome/examples/creating_meshes_ex08.py b/doc/salome/examples/creating_meshes_ex08.py index 0cb4b229f..049aff6dd 100644 --- a/doc/salome/examples/creating_meshes_ex08.py +++ b/doc/salome/examples/creating_meshes_ex08.py @@ -45,3 +45,12 @@ newMesh = smesh.CopyMesh( mesh.GetIDSource( nodeIds, SMESH.NODE), "some nodes co # 6. copy a sub-mesh newMesh = smesh.CopyMesh( subMesh, "sub-mesh copy" ) + + +# make a new mesh with same hypotheses on a modified geometry + +smallBox = geompy.MakeScaleAlongAxes( box, None, 1, 0.5, 0.5 ) +cutBox = geompy.MakeCut( box, smallBox, theName="box - smallBox" ) + +ok, newMesh, groups, submehses, hyps, invIDs = smesh.CopyMeshWithGeom( mesh, cutBox, "cutBox" ) +newMesh.Compute() 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 501352a00..1d1b975eb 100644 --- a/doc/salome/gui/SMESH/input/copy_mesh.rst +++ b/doc/salome/gui/SMESH/input/copy_mesh.rst @@ -41,7 +41,13 @@ In the dialog: * 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. +--------------------------------------------------- +Limitations of 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. + +Empty standalone groups are not constructed. **See Also** a sample script of :ref:`tui_copy_mesh`. diff --git a/src/SMESHFiltersSelection/SMESH_TypeFilter.hxx b/src/SMESHFiltersSelection/SMESH_TypeFilter.hxx index 85d99b620..f77372138 100644 --- a/src/SMESHFiltersSelection/SMESH_TypeFilter.hxx +++ b/src/SMESHFiltersSelection/SMESH_TypeFilter.hxx @@ -39,6 +39,7 @@ public: virtual bool isOk (const SUIT_DataOwner*) const; SMESH::MeshObjectType type() const; + void setType( SMESH::MeshObjectType theType ) { myType = theType; } protected: SMESH::MeshObjectType myType; diff --git a/src/SMESHGUI/SMESHGUI_CopyMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_CopyMeshDlg.cxx index 1e6c7396c..385c283dc 100644 --- a/src/SMESHGUI/SMESHGUI_CopyMeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_CopyMeshDlg.cxx @@ -351,7 +351,7 @@ QString SMESHGUI_CopyMeshDlg::getErrorMsg( SMESH::string_array_var theInvalidEnt QStringList & theEntriesToBrowse ) { if ( theInvalidEntries->length() == 0 ) - return tr("SMESH_OPERATION_FAILED"); + return tr("OPERATION_FAILED"); // theInvalidEntries - SObject's that hold geometry objects whose // counterparts are not found in the newGeometry, followed by SObject's @@ -509,7 +509,6 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply() anApp->browseObjects( anEntryList, toShowObjects ); Init(false); - mySelectedObject = SMESH::SMESH_IDSource::_nil(); SelectionIntoArgument(); return true; @@ -686,6 +685,16 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument() mySelectedObject = SMESH::IObjectToInterface( IO ); if ( mySelectedObject->_is_nil() ) return; + + if ( isWithGeomMode() ) // only mesh selection allowed + { + myMesh = SMESH::SMESH_Mesh::_narrow( mySelectedObject ); + if ( myMesh->_is_nil() ) + { + myLineEditElements->setText(""); + return; + } + } } else if ( !geom->_is_nil() ) { @@ -717,12 +726,10 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument() else if ( !geom->_is_nil() ) { myGeomNameEdit->setText( aString ); - ok = ok && !myLineEditElements->text().isEmpty(); } - if ( ok && isWithGeomMode() && !myMesh->_is_nil() ) - ok = myMesh->HasShapeToMesh(); - + if ( ok && isWithGeomMode() ) + ok = ( !myMesh->_is_nil() && myMesh->HasShapeToMesh() && !myNewGeometry->_is_nil() ); buttonOk->setEnabled(ok); buttonApply->setEnabled(ok); diff --git a/src/SMESHGUI/SMESHGUI_CopyMeshDlg.h b/src/SMESHGUI/SMESHGUI_CopyMeshDlg.h index 2566e7aa6..6939b1b13 100644 --- a/src/SMESHGUI/SMESHGUI_CopyMeshDlg.h +++ b/src/SMESHGUI/SMESHGUI_CopyMeshDlg.h @@ -44,13 +44,13 @@ class QLineEdit; class QPushButton; class QButtonGroup; +class LightApp_SelectionMgr; class SMESHGUI; -class SMESHGUI_IdValidator; class SMESHGUI_FilterDlg; +class SMESHGUI_IdValidator; class SMESH_Actor; +class SMESH_TypeFilter; class SVTK_Selector; -class LightApp_SelectionMgr; -class SUIT_SelectionFilter; //================================================================================= // class : SMESHGUI_CopyMeshDlg @@ -90,7 +90,7 @@ private: SMESH::SMESH_Mesh_var myMesh; GEOM::GEOM_Object_var myNewGeometry; SMESH_Actor* myActor; - SUIT_SelectionFilter* myIdSourceFilter; + SMESH_TypeFilter* myIdSourceFilter; SMESH::SMESH_IDSource_var mySelectedObject; diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index ab98955dd..29d0401f0 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -8089,6 +8089,10 @@ as they are of improper type: COPY_ELEMENTS Copy Mesh Elements + + OPERATION_FAILED + Not all mesh sub-objects have been copied + SUBSHAPES_NOT_FOUND_MSG diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 2e3753f73..fa2034183 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -3160,8 +3160,12 @@ namespace // utils for CopyMeshWithGeom() if ( 0 < oldID && oldID < (int)myGIPMap->length() ) { - if ( myGIPMap[ oldID ].length() == 1 ) + if (( myGIPMap[ oldID ].length() == 1 ) || + ( myGIPMap[ oldID ].length() > 1 && + getShapeType( mySrcMesh_i, oldID ) == TopAbs_VERTEX )) + { newID = myGIPMap[ oldID ][ 0 ]; + } } return newID; } @@ -3573,9 +3577,9 @@ throw ( SALOME::SALOME_Exception ) // copy mesh elements, keeping IDs + SMESHDS_Mesh* newMeshDS = newMesh_i->GetImpl().GetMeshDS(); if ( theToCopyElements && theSourceMesh->NbNodes() > 0 ) { - SMESHDS_Mesh* newMeshDS = newMesh_i->GetImpl().GetMeshDS(); ::SMESH_MeshEditor editor( &newMesh_i->GetImpl() ); ::SMESH_MeshEditor::ElemFeatures elemData; @@ -3656,12 +3660,19 @@ throw ( SALOME::SALOME_Exception ) if ( !stdlGroup->_is_nil() ) { - if ( theToCopyElements ) + if ( newMeshDS->GetMeshInfo().NbElements( SMDSAbs_ElementType( elemType )) > 0 ) { SMESH::long_array_var elemIDs = stdlGroup->GetIDs(); - stdlGroup = theNewMesh->CreateGroup( elemType, name ); - stdlGroup->Add( elemIDs ); - newGroup = SMESH::SMESH_GroupBase::_narrow( stdlGroup ); + CORBA::ULong iE = 0; + for ( ; iE < elemIDs->length(); ++iE ) // check if elements have been copied + if ( newMeshDS->GetElementType( elemIDs[ iE ], elemType != SMESH::NODE )) + break; + if ( iE < elemIDs->length() ) + { + stdlGroup = theNewMesh->CreateGroup( elemType, name ); + stdlGroup->Add( elemIDs ); + newGroup = SMESH::SMESH_GroupBase::_narrow( stdlGroup ); + } } } else if ( !geomGroup->_is_nil() ) @@ -3776,7 +3787,7 @@ throw ( SALOME::SALOME_Exception ) SALOMEDS::SObject_wrap newSO = ObjectToSObject( study, newGroup ); if ( !srcSO->_is_nil() ) { - CORBA::String_var srcID, newID; + CORBA::String_var srcID, newID(""); srcID = srcSO->GetID(); if ( !newSO->_is_nil() ) newID = newSO->GetID();