Salome HOME
0020743: EDF 1271 SMESH : Create a mesh from a group / FindElementByPoint() on groups
authoreap <eap@opencascade.com>
Tue, 14 Jun 2011 13:49:51 +0000 (13:49 +0000)
committereap <eap@opencascade.com>
Tue, 14 Jun 2011 13:49:51 +0000 (13:49 +0000)
+        int Tic() const { return myTic; }
+        int                                     myTic; // to track changes

src/SMDS/SMDS_MeshGroup.cxx
src/SMDS/SMDS_MeshGroup.hxx

index 053d917b7fccf4083a5578e93c885ed03db143d3..842e6c2845fef39e24f9a5b3bb33541b3f010e42 100644 (file)
@@ -41,7 +41,7 @@ using namespace std;
 
 SMDS_MeshGroup::SMDS_MeshGroup(const SMDS_Mesh * theMesh,
                                const SMDSAbs_ElementType theType)
-        :myMesh(theMesh),myType(theType), myParent(NULL)
+  :myMesh(theMesh),myType(theType), myParent(NULL), myTic(0)
 {
 }
 
@@ -112,8 +112,9 @@ bool SMDS_MeshGroup::RemoveFromParent()
 
 void SMDS_MeshGroup::Clear()
 {
-        myElements.clear();
-        myType = SMDSAbs_All;
+  myElements.clear();
+  myType = SMDSAbs_All;
+  ++myTic;
 }
 
 //=======================================================================
@@ -123,14 +124,15 @@ void SMDS_MeshGroup::Clear()
 
 void SMDS_MeshGroup::Add(const SMDS_MeshElement * theElem)
 {
-        // the type of the group is determined by the first element added
-        if (myElements.empty()) myType = theElem->GetType();
-        else if (theElem->GetType() != myType) {
-          MESSAGE("SMDS_MeshGroup::Add : Type Mismatch "<<theElem->GetType()<<"!="<<myType);
-          return;
-        }
+  // the type of the group is determined by the first element added
+  if (myElements.empty()) myType = theElem->GetType();
+  else if (theElem->GetType() != myType) {
+    MESSAGE("SMDS_MeshGroup::Add : Type Mismatch "<<theElem->GetType()<<"!="<<myType);
+    return;
+  }
         
-        myElements.insert(theElem);
+  myElements.insert(theElem);
+  ++myTic;
 }
 
 //=======================================================================
@@ -140,11 +142,11 @@ void SMDS_MeshGroup::Add(const SMDS_MeshElement * theElem)
 
 bool SMDS_MeshGroup::Remove(const SMDS_MeshElement * theElem)
 {
-  std::set<const SMDS_MeshElement *>::iterator found
-    = myElements.find(theElem);
+  set<const SMDS_MeshElement *>::iterator found = myElements.find(theElem);
   if ( found != myElements.end() ) {
     myElements.erase(found);
     if (myElements.empty()) myType = SMDSAbs_All;
+    ++myTic;
     return true;
   }
   return false;
index 9f4a5f4393105433ef94c4ff06eb941d5590b781..f6166a9effd99f2a909e437a6ff25601c540ee10 100644 (file)
@@ -50,6 +50,7 @@ class SMDS_EXPORT SMDS_MeshGroup:public SMDS_MeshObject
         bool Remove(const SMDS_MeshElement * theElem);
         bool IsEmpty() const { return myElements.empty(); }
         int Extent() const { return myElements.size(); }
+        int Tic() const { return myTic; }
 
         int SubGroupsNb() const { return myChildren.size(); }
 
@@ -87,5 +88,6 @@ class SMDS_EXPORT SMDS_MeshGroup:public SMDS_MeshObject
         std::list<const SMDS_MeshGroup*>        myChildren;
         TIterator                               myIterator;
         TGroupIterator                          myGroupIterator;
+        int                                     myTic; // to track changes
 };
 #endif