From: asozinov Date: Thu, 17 Oct 2024 14:40:19 +0000 (+0100) Subject: Managing group during reload mesh X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f8ea158a339874b450d687c3d30eff3ace7ef643;p=modules%2Fsmesh.git Managing group during reload mesh --- diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index aff8bf130..88551499b 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -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)); diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 57d4b1c17..83d343800 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -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())