From: eap Date: Mon, 14 Mar 2011 10:28:54 +0000 (+0000) Subject: in createGroup(), make a unique name if no name is provided X-Git-Tag: StartingPortingMED3~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=c7177e7a38edb5c27392dbb03257a4701d79133b;p=modules%2Fsmesh.git in createGroup(), make a unique name if no name is provided --- diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index a088cce96..ad026374c 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -2070,6 +2070,18 @@ SMESH::SMESH_GroupBase_ptr SMESH_Mesh_i::createGroup (SMESH::ElementType theElem const char* theName, const TopoDS_Shape& theShape ) { + std::string newName; + if ( !theName || strlen( theName ) == 0 ) + { + std::set< std::string > presentNames; + std::map::const_iterator i_gr = _mapGroups.begin(); + for ( ; i_gr != _mapGroups.end(); ++i_gr ) + presentNames.insert( i_gr->second->GetName() ); + do { + newName = "noname_Group_" + SMESH_Comment( presentNames.size() + 1 ); + } while ( !presentNames.insert( newName ).second ); + theName = newName.c_str(); + } int anId; SMESH::SMESH_GroupBase_var aGroup; if ( _impl->AddGroup( (SMDSAbs_ElementType)theElemType, theName, anId, theShape )) {