X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH%2FSMESH_Mesh.cxx;h=c4b6c65d1a0059743c6e46266e2befb11c34247e;hp=c03eaa65029870ad03ce6f9d8e22856bb7161cb0;hb=09bc0414c91ebabb67c7fe200549044a1854e199;hpb=05bdaa6d2e34f8faf44db72a387557bfdfc52486 diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index c03eaa650..c4b6c65d1 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -521,11 +521,10 @@ int SMESH_Mesh::MEDToMesh(const char* theFileName, const char* theMeshName) // Reading groups (sub-meshes are out of scope of MED import functionality) std::list aGroupNames = myReader.GetGroupNamesAndTypes(); - int anId; std::list::iterator name_type = aGroupNames.begin(); for ( ; name_type != aGroupNames.end(); name_type++ ) { - SMESH_Group* aGroup = AddGroup( name_type->second, name_type->first.c_str(), anId ); + SMESH_Group* aGroup = AddGroup( name_type->second, name_type->first.c_str() ); if ( aGroup ) { SMESHDS_Group* aGroupDS = dynamic_cast( aGroup->GetGroupDS() ); if ( aGroupDS ) { @@ -2029,16 +2028,18 @@ bool SMESH_Mesh::IsMainShape(const TopoDS_Shape& theShape) const SMESH_Group* SMESH_Mesh::AddGroup (const SMDSAbs_ElementType theType, const char* theName, - int& theId, + const int theId, const TopoDS_Shape& theShape, const SMESH_PredicatePtr& thePredicate) { - if (_mapGroup.count(_groupId)) + if ( _mapGroup.count( theId )) return NULL; - theId = _groupId; - SMESH_Group* aGroup = new SMESH_Group (theId, this, theType, theName, theShape, thePredicate); + int id = ( theId < 0 ) ? _groupId : theId; + SMESH_Group* aGroup = new SMESH_Group ( id, this, theType, theName, theShape, thePredicate ); GetMeshDS()->AddGroup( aGroup->GetGroupDS() ); - _mapGroup[_groupId++] = aGroup; + _mapGroup[ id ] = aGroup; + while ( _mapGroup.count( _groupId )) + ++_groupId; return aGroup; } @@ -2065,7 +2066,8 @@ SMESH_Group* SMESH_Mesh::AddGroup (SMESHDS_GroupBase* groupDS) throw(SALOME_Exce _mapGroup[ groupDS->GetID() ] = aGroup; GetMeshDS()->AddGroup( aGroup->GetGroupDS() ); - _groupId = 1 + _mapGroup.rbegin()->first; + while ( _mapGroup.count( _groupId )) + ++_groupId; return aGroup; } @@ -2091,8 +2093,8 @@ bool SMESH_Mesh::SynchronizeGroups() if ( !_mapGroup.count( _groupId )) _mapGroup[_groupId] = new SMESH_Group( groupDS ); } - if ( !_mapGroup.empty() ) - _groupId = _mapGroup.rbegin()->first + 1; + while ( _mapGroup.count( _groupId )) + ++_groupId; return nbGroups < _mapGroup.size(); } @@ -2115,11 +2117,12 @@ SMESH_Mesh::GroupIteratorPtr SMESH_Mesh::GetGroups() const */ //============================================================================= -SMESH_Group* SMESH_Mesh::GetGroup (const int theGroupID) +SMESH_Group* SMESH_Mesh::GetGroup (const int theGroupID) const { - if (_mapGroup.find(theGroupID) == _mapGroup.end()) + std::map ::const_iterator id_grp = _mapGroup.find( theGroupID ); + if ( id_grp == _mapGroup.end() ) return NULL; - return _mapGroup[theGroupID]; + return id_grp->second; }