Salome HOME
PAL6825
authorsan <san@opencascade.com>
Mon, 7 Feb 2005 13:51:15 +0000 (13:51 +0000)
committersan <san@opencascade.com>
Mon, 7 Feb 2005 13:51:15 +0000 (13:51 +0000)
src/SMESHDS/SMESHDS_Group.cxx
src/SMESHDS/SMESHDS_GroupBase.cxx
src/SMESHDS/SMESHDS_GroupBase.hxx

index ecd6efb8ce998c2fc5c2048e21bb56e7bfd1a2d5..9c7dfa4a96e9ae2984f0e6d9dda4cc5dbee5aacd 100644 (file)
@@ -93,6 +93,7 @@ bool SMESHDS_Group::Add (const int theID)
     SetType( aElem->GetType() );
 
   myGroup.Add (aElem);
     SetType( aElem->GetType() );
 
   myGroup.Add (aElem);
+  resetIterator();
   return true;
 }
 
   return true;
 }
 
@@ -108,6 +109,7 @@ bool SMESHDS_Group::Remove (const int theID)
   if (!aElem || !myGroup.Contains(aElem))
     return false;
   myGroup.Remove (aElem);
   if (!aElem || !myGroup.Contains(aElem))
     return false;
   myGroup.Remove (aElem);
+  resetIterator();
   return true;
 }
 
   return true;
 }
 
@@ -119,6 +121,7 @@ bool SMESHDS_Group::Remove (const int theID)
 void SMESHDS_Group::Clear()
 {
   myGroup.Clear();
 void SMESHDS_Group::Clear()
 {
   myGroup.Clear();
+  resetIterator();
 }
 
 // =====================
 }
 
 // =====================
index c3fc31d7017c8df8c942e5fd963687665910caba..c4adcc53b6921a4ce7aeb6c6e789722b7cbfea1c 100644 (file)
@@ -41,7 +41,7 @@ SMESHDS_GroupBase::SMESHDS_GroupBase (const int                 theID,
                                       const SMESHDS_Mesh*       theMesh,
                                       const SMDSAbs_ElementType theType):
        myID(theID), myMesh(theMesh), myType(theType), myStoreName(""),
                                       const SMESHDS_Mesh*       theMesh,
                                       const SMDSAbs_ElementType theType):
        myID(theID), myMesh(theMesh), myType(theType), myStoreName(""),
-       myCurIndex(0), myCurID(0)
+       myCurIndex(0), myCurID(-1)
 {
 }
 
 {
 }
 
@@ -86,6 +86,18 @@ const SMDS_MeshElement* SMESHDS_GroupBase::findInMesh (const int theID) const
   return aElem;
 }
 
   return aElem;
 }
 
+//=============================================================================
+/*!
+ *  Internal method: resets cached iterator, should be called by ancestors
+ *  when they are modified (ex: Add() or Remove() )
+ */
+//=============================================================================
+void SMESHDS_GroupBase::resetIterator()
+{
+  myCurIndex = 0;
+  myCurID = -1;
+}
+
 //=======================================================================
 //function : Extent
 //purpose  : 
 //=======================================================================
 //function : Extent
 //purpose  : 
index fbb91414a1524bac956023953c97dda97244de43..a7aa87cedb79b4b3d21f578e9465617aeeb292a1 100644 (file)
@@ -68,6 +68,7 @@ class SMESHDS_GroupBase
 
  protected:
   const SMDS_MeshElement* findInMesh (const int theID) const;
 
  protected:
   const SMDS_MeshElement* findInMesh (const int theID) const;
+  void resetIterator();
 
  private:
   SMESHDS_GroupBase (const SMESHDS_GroupBase& theOther);
 
  private:
   SMESHDS_GroupBase (const SMESHDS_GroupBase& theOther);