Salome HOME
23586: [EDF] HYDRO: Copy mesh to new geometry hydro/imps_2018 HYDRO_V2_0_0
authoreap <eap@opencascade.com>
Tue, 18 Sep 2018 14:32:59 +0000 (17:32 +0300)
committereap <eap@opencascade.com>
Tue, 18 Sep 2018 14:32:59 +0000 (17:32 +0300)
src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx
src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.hxx

index be443d14ee169936d706ddeff008e594504cd48b..ad5798596bfce9f2347ae8efdf7899f98fa06a89 100644 (file)
@@ -354,38 +354,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
   // ---------------------------------
index 609888385477ed0c4b88ce8969f7611440814b05..2f13187829a79046e86357a3e952245326359d21 100644 (file)
@@ -234,6 +234,11 @@ class HYBRIDPLUGIN_EXPORT HYBRIDPlugin_Hypothesis_i:
   // Verify whether hypothesis supports given entity type
   CORBA::Boolean IsDimSupported( SMESH::Dimension type );
   
+  // Methods for copying mesh definition to other geometry
+  virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
+                                   std::vector< int >         & subIDArray ) const { return false; }
+  virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
+                                   std::vector< int >         & subIDArray ) { return true; }
 };
 
 #endif