Salome HOME
23605: [EDF] HYDRO: parent mesh for Copy mesh with new geometry
authoreap <eap@opencascade.com>
Wed, 17 Oct 2018 14:35:08 +0000 (17:35 +0300)
committereap <eap@opencascade.com>
Wed, 17 Oct 2018 14:35:08 +0000 (17:35 +0300)
23606: [EDF] HYDRO: Help for option Copy mesh with new geometry is absent

doc/salome/gui/SMESH/input/copy_mesh.rst
src/SMESHFiltersSelection/SMESH_TypeFilter.hxx
src/SMESHGUI/SMESHGUI_CopyMeshDlg.cxx
src/SMESHGUI/SMESH_msg_en.ts
src/SMESH_I/SMESH_Gen_i.cxx

index 501352a005d23fef222af46aa4553c570679b882..1d1b975ebbc426015d6d3cb4effa910b6739cf8a 100644 (file)
@@ -41,7 +41,13 @@ In the dialog:
 
 * Click **Apply** or **Apply and Close** button to confirm the operation.
 
 
 * 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`.
 
 
 **See Also** a sample script of :ref:`tui_copy_mesh`.
 
index 85d99b6201cf7869a4c55649a6e3ce79c529d09c..f77372138f803ab260a89877ad44de0f64d4e66f 100644 (file)
@@ -39,6 +39,7 @@ public:
 
   virtual bool isOk (const SUIT_DataOwner*) const;
   SMESH::MeshObjectType type() const;
 
   virtual bool isOk (const SUIT_DataOwner*) const;
   SMESH::MeshObjectType type() const;
+  void setType( SMESH::MeshObjectType theType ) { myType = theType; }
 
 protected:
   SMESH::MeshObjectType myType;
 
 protected:
   SMESH::MeshObjectType myType;
index b7794c02d8d3a5b62bee922f6238e6e99cb88db7..838f344d8415dc6526c1e1f8bba1d033b3465a1a 100644 (file)
@@ -351,7 +351,7 @@ QString SMESHGUI_CopyMeshDlg::getErrorMsg( SMESH::string_array_var theInvalidEnt
                                            QStringList &           theEntriesToBrowse )
 {
   if ( theInvalidEntries->length() == 0 )
                                            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
 
   // 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);
     anApp->browseObjects( anEntryList, toShowObjects );
 
   Init(false);
-  mySelectedObject = SMESH::SMESH_IDSource::_nil();
   SelectionIntoArgument();
 
   return true;
   SelectionIntoArgument();
 
   return true;
@@ -685,6 +684,16 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
     mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
     if ( mySelectedObject->_is_nil() )
       return;
     mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( 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() )
   {
   }
   else if ( !geom->_is_nil() )
   {
@@ -716,12 +725,10 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
   else if ( !geom->_is_nil() )
   {
     myGeomNameEdit->setText( aString );
   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);
 
   buttonOk->setEnabled(ok);
   buttonApply->setEnabled(ok);
index d286d6c15b37ca131a114e764a1cc5ea35038fbd..bdb5e21d7d7a27ef6cebb02c938c0524097f7e64 100644 (file)
@@ -8091,6 +8091,10 @@ as they are of improper type:
         <source>COPY_ELEMENTS</source>
         <translation>Copy Mesh Elements</translation>
     </message>
         <source>COPY_ELEMENTS</source>
         <translation>Copy Mesh Elements</translation>
     </message>
+    <message>
+        <source>OPERATION_FAILED</source>
+        <translation>Not all mesh sub-objects have been copied</translation>
+    </message>
     <message>
         <source>SUBSHAPES_NOT_FOUND_MSG</source>
         <translation>
     <message>
         <source>SUBSHAPES_NOT_FOUND_MSG</source>
         <translation>
index ffab1b05646c38130011d64b642ac0fce86d2e11..6dface544a8a84bdfe28e4b37611b63b539d9b8a 100644 (file)
@@ -3158,8 +3158,12 @@ namespace // utils for CopyMeshWithGeom()
 
       if ( 0 < oldID && oldID < (int)myGIPMap->length() )
       {
 
       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 ];
           newID = myGIPMap[ oldID ][ 0 ];
+        }
       }
       return newID;
     }
       }
       return newID;
     }
@@ -3563,9 +3567,9 @@ throw ( SALOME::SALOME_Exception )
 
 
   // copy mesh elements, keeping IDs
 
 
   // copy mesh elements, keeping IDs
+  SMESHDS_Mesh* newMeshDS = newMesh_i->GetImpl().GetMeshDS();
   if ( theToCopyElements && theSourceMesh->NbNodes() > 0 )
   {
   if ( theToCopyElements && theSourceMesh->NbNodes() > 0 )
   {
-    SMESHDS_Mesh* newMeshDS = newMesh_i->GetImpl().GetMeshDS();
     ::SMESH_MeshEditor editor( &newMesh_i->GetImpl() );
     ::SMESH_MeshEditor::ElemFeatures elemData;
 
     ::SMESH_MeshEditor editor( &newMesh_i->GetImpl() );
     ::SMESH_MeshEditor::ElemFeatures elemData;
 
@@ -3646,12 +3650,20 @@ throw ( SALOME::SALOME_Exception )
 
     if ( !stdlGroup->_is_nil() )
     {
 
     if ( !stdlGroup->_is_nil() )
     {
-      if ( theToCopyElements )
+      if ( newMeshDS->GetMeshInfo().NbElements( SMDSAbs_ElementType( elemType )) > 0 )
       {
         SMESH::long_array_var elemIDs = stdlGroup->GetIDs();
       {
         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() )
       }
     }
     else if ( !geomGroup->_is_nil() )
@@ -3766,7 +3778,7 @@ throw ( SALOME::SALOME_Exception )
     SALOMEDS::SObject_wrap newSO = ObjectToSObject( newGroup );
     if ( !srcSO->_is_nil() )
     {
     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();
       srcID = srcSO->GetID();
       if ( !newSO->_is_nil() )
         newID = newSO->GetID();