Salome HOME
Update copyrights
[modules/smesh.git] / src / SMESHDS / SMESHDS_Group.cxx
index e6df602ff343532c4a4bda2185c1ee3ed681d323..dc222d204b71aa14b1f6051a7da92d0ab8867e29 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -105,15 +105,14 @@ bool SMESHDS_Group::Add (const int theID)
 
 bool SMESHDS_Group::Add (const SMDS_MeshElement* aElem )
 {
-  if (!aElem || myGroup.Contains(aElem))
-    return false;
-
-  if (myGroup.IsEmpty())
-    SetType( aElem->GetType() );
-
-  myGroup.Add (aElem);
-  resetIterator();
-  return true;
+  bool added = false;
+  if ( aElem )
+  {
+    added = myGroup.Add (aElem);
+    if ( added )
+      resetIterator();
+  }
+  return added;
 }
 
 //=============================================================================
@@ -124,12 +123,14 @@ bool SMESHDS_Group::Add (const SMDS_MeshElement* aElem )
 
 bool SMESHDS_Group::Remove (const int theID)
 {
-  const SMDS_MeshElement* aElem = findInMesh (theID);
-  if (!aElem || !myGroup.Contains(aElem))
-    return false;
-  myGroup.Remove (aElem);
-  resetIterator();
-  return true;
+  bool removed = false;
+  if ( const SMDS_MeshElement* aElem = findInMesh( theID ))
+  {
+    removed = myGroup.Remove (aElem);
+    if ( removed )
+      resetIterator();
+  }
+  return removed;
 }