From e9c5d169fa80c03360f79fa7e5acce89f098940c Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 17 Oct 2018 17:35:08 +0300 Subject: [PATCH] 23605: [EDF] HYDRO: parent mesh for Copy mesh with new geometry 23606: [EDF] HYDRO: Help for option Copy mesh with new geometry is absent --- doc/salome/gui/SMESH/input/copy_mesh.rst | 8 +++++- .../SMESH_TypeFilter.hxx | 1 + src/SMESHGUI/SMESHGUI_CopyMeshDlg.cxx | 19 +++++++++----- src/SMESHGUI/SMESH_msg_en.ts | 4 +++ src/SMESH_I/SMESH_Gen_i.cxx | 26 ++++++++++++++----- 5 files changed, 44 insertions(+), 14 deletions(-) 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 b7794c02d..838f344d8 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 @@ -508,7 +508,6 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply() anApp->browseObjects( anEntryList, toShowObjects ); Init(false); - mySelectedObject = SMESH::SMESH_IDSource::_nil(); SelectionIntoArgument(); return true; @@ -685,6 +684,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() ) { @@ -716,12 +725,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/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index d286d6c15..bdb5e21d7 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -8091,6 +8091,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 ffab1b056..6dface544 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -3158,8 +3158,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; } @@ -3563,9 +3567,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; @@ -3646,12 +3650,20 @@ 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 ); + const bool isElem = ( elemType != SMESH::NODE ); + CORBA::ULong iE = 0; + for ( ; iE < elemIDs->length(); ++iE ) // check if any element has been copied + if ( newMeshDS->GetElementType( elemIDs[ iE ], isElem ) != SMDSAbs_All ) + break; + if ( iE < elemIDs->length() ) + { + stdlGroup = theNewMesh->CreateGroup( elemType, name ); + stdlGroup->Add( elemIDs ); + newGroup = SMESH::SMESH_GroupBase::_narrow( stdlGroup ); + } } } else if ( !geomGroup->_is_nil() ) @@ -3766,7 +3778,7 @@ throw ( SALOME::SALOME_Exception ) SALOMEDS::SObject_wrap newSO = ObjectToSObject( 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(); -- 2.39.2