From f1c147c62924b6c1032d635dcb917b72e437e9ef Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 22 Nov 2011 08:15:52 +0000 Subject: [PATCH] regression of grid test SMESH_TEST/Grids/smesh/imps/G0 + std::vector GetSourceSubMeshes(const SMESH_Mesh* srcMesh) const; --- src/StdMeshers/StdMeshers_ImportSource.cxx | 47 +++++++++++++++++++++- src/StdMeshers/StdMeshers_ImportSource.hxx | 2 + 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/StdMeshers/StdMeshers_ImportSource.cxx b/src/StdMeshers/StdMeshers_ImportSource.cxx index 4af40d8d5..5e963a02d 100644 --- a/src/StdMeshers/StdMeshers_ImportSource.cxx +++ b/src/StdMeshers/StdMeshers_ImportSource.cxx @@ -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 StdMeshers_ImportSource1D::GetSourceMeshes() const return meshes; } +//================================================================================ +/*! + * \brief Return submeshes whose events affect the target mesh + */ +//================================================================================ + +std::vector +StdMeshers_ImportSource1D::GetSourceSubMeshes(const SMESH_Mesh* srcMesh) const +{ + if ( !srcMesh->HasShapeToMesh() ) + return vector(1, srcMesh->GetSubMeshContaining(1)); + + set shapeIDs; + const vector& 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( 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 smVec( shapeIDs.size()); + set::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 diff --git a/src/StdMeshers/StdMeshers_ImportSource.hxx b/src/StdMeshers/StdMeshers_ImportSource.hxx index 61b3b1ed5..1f87da44c 100644 --- a/src/StdMeshers/StdMeshers_ImportSource.hxx +++ b/src/StdMeshers/StdMeshers_ImportSource.hxx @@ -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 GetSourceMeshes() const; + std::vector GetSourceSubMeshes(const SMESH_Mesh* srcMesh) const; private: -- 2.39.2