Salome HOME
23627: [IMACS] Change group management to have group ID persistent
authoreap <eap@opencascade.com>
Thu, 17 Jan 2019 13:13:17 +0000 (16:13 +0300)
committereap <eap@opencascade.com>
Thu, 17 Jan 2019 13:13:17 +0000 (16:13 +0300)
src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx

index 9f91f0b714697b18962f2a9b54a1c06afb895535..80d5993f0e7aa46536f76142fdaf1a2fd145fe36 100644 (file)
@@ -211,8 +211,7 @@ static void addElemInMeshGroup(SMESH_Mesh*             theMesh,
   
   if (!groupDone)
   {
-    int groupId;
-    SMESH_Group* aGroup = theMesh->AddGroup(anElem->GetType(), groupName.c_str(), groupId);
+    SMESH_Group* aGroup = theMesh->AddGroup(anElem->GetType(), groupName.c_str());
     aGroup->SetName( groupName.c_str() );
     SMESHDS_Group* aGroupDS = static_cast<SMESHDS_Group*>( aGroup->GetGroupDS() );
     aGroupDS->SMDSGroup().Add(anElem);
@@ -303,13 +302,12 @@ static void makeDomainGroups( std::vector< std::vector< const SMDS_MeshElement*
     }
     // create and fill the groups
     size_t iElem = 0;
-    int groupID;
     do
     {
       SMESH_Group* group = groupOfType[ elems[ iElem ]->GetType() ];
       if ( !group )
         group = theHelper->GetMesh()->AddGroup( elems[ iElem ]->GetType(),
-                                                domainName.c_str(), groupID );
+                                                domainName.c_str() );
       SMDS_MeshGroup& groupDS =
         static_cast< SMESHDS_Group* >( group->GetGroupDS() )->SMDSGroup();
 
@@ -346,38 +344,54 @@ static bool readGMFFile(MG_HYBRID_API*                          MGOutput,
   // if imprinting, the original mesh faces are modified
   // => we clear all the faces to retrieve them from Hybrid output mesh.
   std::vector<int> facesWithImprinting;
-  if (theAlgo->getHyp()) 
+  if (theAlgo->getHyp())
     facesWithImprinting = theAlgo->getHyp()->GetFacesWithImprinting();
 
   if ( ! facesWithImprinting.empty() ) {
 #ifdef _DEBUG_
-      std::cout << "Imprinting => Clear original mesh" << std::endl;
+    std::cout << "Imprinting => Clear original mesh" << std::endl;
 #endif
-      SMDS_ElemIteratorPtr eIt = theMeshDS->elementsIterator();
-      while( eIt->more() )
-        theMeshDS->RemoveFreeElement( eIt->next(), /*sm=*/0 );
-      SMDS_NodeIteratorPtr nIt = theMeshDS->nodesIterator();
-      while ( nIt->more() )
-        theMeshDS->RemoveFreeNode( nIt->next(), /*sm=*/0 );
-
-      theNodeByHybridId.clear();
-      theFaceByHybridId.clear();
+    SMESH_subMesh* smOfSolid =
+      theHelper->GetMesh()->GetSubMesh( theHelper->GetSubShape() );
+    SMESH_subMeshIteratorPtr smIt =
+      smOfSolid->getDependsOnIterator(/*includeSelf=*/false, /*complexShapeFirst=*/true);
+    while ( smIt->more() )
+    {
+      SMESH_subMesh* sm = smIt->next();
+      if ( SMESHDS_SubMesh * smDS = sm->GetSubMeshDS() )
+      {
+        SMDS_ElemIteratorPtr eIt = smDS->GetElements();
+        while( eIt->more() )
+        {
+          theMeshDS->RemoveFreeElement( eIt->next(), smDS );
+        }
+        SMDS_NodeIteratorPtr nIt = smDS->GetNodes();
+        while ( nIt->more() )
+        {
+          const SMDS_MeshNode* n = nIt->next();
+          if ( n->NbInverseElements() == 0 )
+            theMeshDS->RemoveFreeNode( n, smDS );
+        }
+      }
+    }
+    theNodeByHybridId.clear();
+    theFaceByHybridId.clear();
   }
 
   int nbMeshNodes = theMeshDS->NbNodes();
   int nbInitialNodes = theNodeByHybridId.size();
 
-  const bool isQuadMesh = 
+  const bool isQuadMesh =
     theHelper->GetMesh()->NbEdges( ORDER_QUADRATIC ) ||
     theHelper->GetMesh()->NbFaces( ORDER_QUADRATIC ) ||
     theHelper->GetMesh()->NbVolumes( ORDER_QUADRATIC );
-    
+
 #ifdef _DEBUG_
   std::cout << "theNodeByHybridId.size(): " << nbInitialNodes << std::endl;
   std::cout << "theHelper->GetMesh()->NbNodes(): " << nbMeshNodes << std::endl;
   std::cout << "isQuadMesh: " << isQuadMesh << std::endl;
 #endif
-  
+
   // ---------------------------------
   // Read generated elements and nodes
   // ---------------------------------