]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
regression of grid test SMESH_TEST/Grids/smesh/imps/G0
authoreap <eap@opencascade.com>
Tue, 22 Nov 2011 08:15:52 +0000 (08:15 +0000)
committereap <eap@opencascade.com>
Tue, 22 Nov 2011 08:15:52 +0000 (08:15 +0000)
+  std::vector<SMESH_subMesh*> GetSourceSubMeshes(const SMESH_Mesh* srcMesh) const;

src/StdMeshers/StdMeshers_ImportSource.cxx
src/StdMeshers/StdMeshers_ImportSource.hxx

index 4af40d8d562af01613db22c77dc1966ea148c8e9..5e963a02d96401edf200001bed5df2819f07ccd8 100644 (file)
@@ -26,7 +26,7 @@
 //
 #include "StdMeshers_ImportSource.hxx"
 
-#include "SMESHDS_GroupBase.hxx"
+#include "SMESHDS_GroupOnGeom.hxx"
 #include "SMESHDS_Mesh.hxx"
 #include "SMESH_Algo.hxx"
 #include "SMESH_Gen.hxx"
@@ -258,6 +258,51 @@ std::vector<SMESH_Mesh*> StdMeshers_ImportSource1D::GetSourceMeshes() const
   return meshes;
 }
 
+//================================================================================
+/*!
+ * \brief Return submeshes whose events affect the target mesh
+ */
+//================================================================================
+
+std::vector<SMESH_subMesh*>
+StdMeshers_ImportSource1D::GetSourceSubMeshes(const SMESH_Mesh* srcMesh) const
+{
+  if ( !srcMesh->HasShapeToMesh() )
+    return vector<SMESH_subMesh*>(1, srcMesh->GetSubMeshContaining(1));
+
+  set<int> shapeIDs;
+  const vector<SMESH_Group*>& groups = GetGroups();
+  const SMESHDS_Mesh * srcMeshDS = srcMesh->GetMeshDS();
+  for ( size_t i = 0; i < groups.size(); ++i )
+  {
+    SMESHDS_GroupBase * grDS = groups[i]->GetGroupDS();
+    if ( grDS->GetMesh() != srcMeshDS )
+      continue;
+    if ( SMESHDS_GroupOnGeom* gog = dynamic_cast<SMESHDS_GroupOnGeom*>( grDS ))
+    {
+      shapeIDs.insert( srcMeshDS->ShapeToIndex( gog->GetShape() ));
+    }
+    else
+    {
+      SMDS_ElemIteratorPtr elIt = grDS->GetElements();
+      while ( elIt->more() )
+        shapeIDs.insert( elIt->next()->getshapeId() );
+    }
+  }
+  if ( !shapeIDs.empty() && *shapeIDs.begin() < 1 )
+  {
+    shapeIDs.erase( shapeIDs.begin() );
+    shapeIDs.insert( 1 );
+  }
+
+  vector<SMESH_subMesh*> smVec( shapeIDs.size());
+  set<int>::iterator sID = shapeIDs.begin();
+  for ( int i = 0; sID != shapeIDs.end(); ++sID, ++i )
+    smVec[i] = srcMesh->GetSubMeshContaining( *sID );
+
+  return smVec;
+}
+
 //=============================================================================
 /*!
  * Save _toCopyMesh and _toCopyGroups to a stream
index 61b3b1ed5d8fbf2ddc7c62d5c09414f5b6446fc9..1f87da44cd1e16e9eeea99f434fea19da4c82805 100644 (file)
@@ -37,6 +37,7 @@
 
 class SMESH_Group;
 class SMESHDS_Mesh;
+class SMESH_subMesh;
 
 //==============================================================================
 /*!
@@ -69,6 +70,7 @@ class STDMESHERS_EXPORT StdMeshers_ImportSource1D : public SMESH_Hypothesis
                                              const SMESHDS_Mesh& tgtMesh);
 
   std::vector<SMESH_Mesh*> GetSourceMeshes() const;
+  std::vector<SMESH_subMesh*> GetSourceSubMeshes(const SMESH_Mesh* srcMesh) const;
 
 private: