- if(MYDEBUG){
- MESSAGE("UNVToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
- MESSAGE("UNVToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
- MESSAGE("UNVToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
- MESSAGE("UNVToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
- }
- SMDS_MeshGroup* aGroup = (SMDS_MeshGroup*) myReader.GetGroup();
- if (aGroup != 0) {
- TGroupNamesMap aGroupNames = myReader.GetGroupNamesMap();
- //const TGroupIdMap& aGroupId = myReader.GetGroupIdMap();
- aGroup->InitSubGroupsIterator();
- while (aGroup->MoreSubGroups()) {
- SMDS_MeshGroup* aSubGroup = (SMDS_MeshGroup*) aGroup->NextSubGroup();
- string aName = aGroupNames[aSubGroup];
- int aId;
-
- SMESH_Group* aSMESHGroup = AddGroup( aSubGroup->GetType(), aName.c_str(), aId );
- if ( aSMESHGroup ) {
- if(MYDEBUG) MESSAGE("UNVToMesh - group added: "<<aName);
- SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aSMESHGroup->GetGroupDS() );
- if ( aGroupDS ) {
- aGroupDS->SetStoreName(aName.c_str());
- aSubGroup->InitIterator();
- const SMDS_MeshElement* aElement = 0;
- while (aSubGroup->More()) {
- aElement = aSubGroup->Next();
- if (aElement) {
- aGroupDS->SMDSGroup().Add(aElement);
- }
- }
- if (aElement)
- aGroupDS->SetType(aElement->GetType());
- }
- }
- }
+
+ TGroupNamesMap& aGroupNames = myReader.GetGroupNamesMap();
+ TGroupNamesMap::iterator gr2names;
+ int anId = 1 + ( _mapGroup.empty() ? 0 : _mapGroup.rbegin()->first );
+ for ( gr2names = aGroupNames.begin(); gr2names != aGroupNames.end(); ++gr2names )
+ {
+ SMDS_MeshGroup* aGroup = gr2names->first;
+ const std::string& aName = gr2names->second;
+ SMESHDS_Group* aGroupDS = new SMESHDS_Group( anId++, _myMeshDS, aGroup->GetType() );
+ aGroupDS->SMDSGroup() = std::move( *aGroup );
+ aGroupDS->SetStoreName( aName.c_str() );
+ AddGroup( aGroupDS );