]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Managing group during reload mesh asozinov/40654 40/head
authorasozinov <alexey.sozinov@opencascade.com>
Thu, 17 Oct 2024 14:40:19 +0000 (15:40 +0100)
committerasozinov <alexey.sozinov@opencascade.com>
Fri, 18 Oct 2024 14:22:50 +0000 (15:22 +0100)
src/SMESHGUI/SMESHGUI.cxx
src/SMESH_I/SMESH_Gen_i.cxx

index aff8bf130ab1a0f5dcb4e390978b9fff1669bfa1..88551499bc7032f5cb642663b487e999b94796e2 100644 (file)
@@ -1115,12 +1115,28 @@ namespace
       }
 
       SMESH::SMESH_Mesh_var aMeshByIO = SMESH::GetMeshByIO(anIObject);
-
       SMESH::SelectionProxy aMesh = SMESH::SelectionProxy(aMeshItem);
       SMESH::MedInfo anInfo = aMesh.medFileInfo();
       if (!anInfo.isValid())
         continue;
 
+      SMESH::ListOfGroups aGroups = *aMeshByIO->GetGroups();
+      for (int i = 0; i < aGroups.length(); ++i)
+      {
+        auto X = aGroups[i];
+        _PTR(SObject) aGroupSObject = SMESH::FindSObject(X);
+        SMESH_Actor* anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str());
+        SMESH::smIdType_array aMeshInfo = *X->GetMeshInfo();
+        
+        if (anActor)
+        {
+          vtkTypeBool isVisib = anActor->GetVisibility();
+          SMESH::UpdateView(!isVisib ? SMESH::eDisplay : SMESH::eErase, aGroupSObject->GetID().c_str());
+        }
+        else
+          SMESH::UpdateView(SMESH::eErase, aGroupSObject->GetID().c_str());
+      }
+
       SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
       {
         // re-import mesh
@@ -1138,7 +1154,7 @@ namespace
           anApp->browseObjects(anEntryList);
       }
 
-      SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(aMeshItem);\
+      SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(aMeshItem);
       QString aMeshName = anIObject->getName();
       aMeshList.append(QPair< SMESH::SMESH_IDSource_var, QString >(aMeshItem, aMeshName));
 
index 57d4b1c17fb9526c1159a6d538426ee5b71cdc88..83d3438003c494fcb6632d647ad423947066b175 100644 (file)
@@ -1603,6 +1603,7 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char*
 
 SMESH::mesh_array* SMESH_Gen_i::ReloadMeshesFromMED(const char* theFileName, SMESH::SMESH_Mesh_ptr sourceMesh, SMESH::DriverMED_ReadStatus& theStatus)
 {
+  SMESH::ListOfGroups anOldGroups = *sourceMesh->GetGroups();
   checkFileReadable(theFileName);
 
 #ifdef WIN32
@@ -1663,7 +1664,13 @@ SMESH::mesh_array* SMESH_Gen_i::ReloadMeshesFromMED(const char* theFileName, SME
         if (status1 > theStatus)
           theStatus = status1;
 
+        for (int i = 0; i < anOldGroups.length(); ++i)
+        {
+          //auto X = anOldGroups[i];
+          sourceMesh->RemoveGroup(anOldGroups[i]);
+        }
         aResult[i++] = SMESH::SMESH_Mesh::_duplicate(sourceMesh);
+
         meshServant->GetImpl().GetMeshDS()->Modified();
       }
       if (!aStudyBuilder->_is_nil())