Salome HOME
bos #20256: [CEA 18523] Porting SMESH to int 64 bits
[modules/smesh.git] / src / SMESHDS / SMESHDS_Group.cxx
index e6df602ff343532c4a4bda2185c1ee3ed681d323..f1df7c324f605227279fd8d071f268754505b820 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  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
@@ -45,7 +45,7 @@ SMESHDS_Group::SMESHDS_Group (const int                 theID,
 //purpose  : 
 //=======================================================================
 
-int SMESHDS_Group::Extent() const
+smIdType SMESHDS_Group::Extent() const
 {
   return myGroup.Extent();
 }
@@ -66,7 +66,7 @@ bool SMESHDS_Group::IsEmpty()
  */
 //=============================================================================
 
-bool SMESHDS_Group::Contains (const int theID)
+bool SMESHDS_Group::Contains (const smIdType theID)
 {
   const SMDS_MeshElement* aElem = findInMesh (theID);
   if (aElem)
@@ -92,7 +92,7 @@ bool SMESHDS_Group::Contains (const SMDS_MeshElement* elem)
  */
 //=============================================================================
 
-bool SMESHDS_Group::Add (const int theID)
+bool SMESHDS_Group::Add (const smIdType theID)
 {
   return Add( findInMesh( theID ));
 }
@@ -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;
 }
 
 //=============================================================================
@@ -122,14 +121,16 @@ bool SMESHDS_Group::Add (const SMDS_MeshElement* aElem )
  */
 //=============================================================================
 
-bool SMESHDS_Group::Remove (const int theID)
+bool SMESHDS_Group::Remove (const smIdType 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;
 }