Salome HOME
IMP19942 - Convert group on geometry into group of elements
[modules/smesh.git] / src / SMESH_I / SMESH_Group_i.cxx
index 66113ca185f8f21543b12474e0c4e89f5c151717..254c38751fe2581af117403162120fe6821bff7f 100644 (file)
@@ -61,14 +61,14 @@ SMESH_Group_i::SMESH_Group_i( PortableServer::POA_ptr thePOA, SMESH_Mesh_i* theM
      : SALOME::GenericObj_i( thePOA ),
        SMESH_GroupBase_i( thePOA, theMeshServant, theLocalID )
 {
-  MESSAGE("SMESH_Group_i; this = "<<this );
+  //MESSAGE("SMESH_Group_i; this = "<<this );
 }
 
 SMESH_GroupOnGeom_i::SMESH_GroupOnGeom_i( PortableServer::POA_ptr thePOA, SMESH_Mesh_i* theMeshServant, const int theLocalID )
      : SALOME::GenericObj_i( thePOA ),
        SMESH_GroupBase_i( thePOA, theMeshServant, theLocalID )
 {
-  MESSAGE("SMESH_GroupOnGeom_i; this = "<<this );
+  //MESSAGE("SMESH_GroupOnGeom_i; this = "<<this );
 }
 
 //=============================================================================
@@ -80,9 +80,8 @@ SMESH_GroupOnGeom_i::SMESH_GroupOnGeom_i( PortableServer::POA_ptr thePOA, SMESH_
 SMESH_GroupBase_i::~SMESH_GroupBase_i()
 {
   MESSAGE("~SMESH_GroupBase_i; this = "<<this );
-  // akl: removeGroup() is called from SMESH_Mesh_i() destructor
-  // if ( myMeshServant )
-  //   myMeshServant->removeGroup(myLocalID);
+  if ( myMeshServant )
+    myMeshServant->removeGroup(myLocalID);
 }
 
 //=======================================================================
@@ -120,20 +119,24 @@ SMESHDS_GroupBase* SMESH_GroupBase_i::GetGroupDS() const
 
 void SMESH_GroupBase_i::SetName( const char* theName )
 {
-  // Update Python script
-  TPythonDump() <<  _this() << ".SetName( '" << theName << "' )";
-
   // Perform renaming
   ::SMESH_Group* aGroup = GetSmeshGroup();
-  if (aGroup) {
-    aGroup->SetName(theName);
-
-    // Update group name in a study
-    SMESH_Gen_i* aGen = myMeshServant->GetGen();
-    aGen->SetName( aGen->ObjectToSObject( aGen->GetCurrentStudy(), _this() ), theName );
+  if (!aGroup) {
+    MESSAGE("can't set name of a vague group");
     return;
   }
-  MESSAGE("can't set name of a vague group");
+
+  if ( aGroup->GetName() && !strcmp( aGroup->GetName(), theName ) )
+    return; // nothing to rename
+
+  aGroup->SetName(theName);
+
+  // Update group name in a study
+  SMESH_Gen_i* aGen = myMeshServant->GetGen();
+  aGen->SetName( aGen->ObjectToSObject( aGen->GetCurrentStudy(), _this() ), theName );
+  
+  // Update Python script
+  TPythonDump() <<  _this() << ".SetName( '" << theName << "' )";
 }
 
 //=============================================================================