0020743: EDF 1271 SMESH : Create a mesh from a group / FindElementByPoint() on groups

+        int Tic() const { return myTic; }
+        int                                     myTic; // to track changes
This commit is contained in:
eap 2011-06-14 13:49:51 +00:00
parent 6a77e2f847
commit c9ccfc74e0
2 changed files with 16 additions and 12 deletions

View File

@ -41,7 +41,7 @@ using namespace std;
SMDS_MeshGroup::SMDS_MeshGroup(const SMDS_Mesh * theMesh, SMDS_MeshGroup::SMDS_MeshGroup(const SMDS_Mesh * theMesh,
const SMDSAbs_ElementType theType) 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() void SMDS_MeshGroup::Clear()
{ {
myElements.clear(); myElements.clear();
myType = SMDSAbs_All; myType = SMDSAbs_All;
++myTic;
} }
//======================================================================= //=======================================================================
@ -123,14 +124,15 @@ void SMDS_MeshGroup::Clear()
void SMDS_MeshGroup::Add(const SMDS_MeshElement * theElem) void SMDS_MeshGroup::Add(const SMDS_MeshElement * theElem)
{ {
// the type of the group is determined by the first element added // the type of the group is determined by the first element added
if (myElements.empty()) myType = theElem->GetType(); if (myElements.empty()) myType = theElem->GetType();
else if (theElem->GetType() != myType) { else if (theElem->GetType() != myType) {
MESSAGE("SMDS_MeshGroup::Add : Type Mismatch "<<theElem->GetType()<<"!="<<myType); MESSAGE("SMDS_MeshGroup::Add : Type Mismatch "<<theElem->GetType()<<"!="<<myType);
return; 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) bool SMDS_MeshGroup::Remove(const SMDS_MeshElement * theElem)
{ {
std::set<const SMDS_MeshElement *>::iterator found set<const SMDS_MeshElement *>::iterator found = myElements.find(theElem);
= myElements.find(theElem);
if ( found != myElements.end() ) { if ( found != myElements.end() ) {
myElements.erase(found); myElements.erase(found);
if (myElements.empty()) myType = SMDSAbs_All; if (myElements.empty()) myType = SMDSAbs_All;
++myTic;
return true; return true;
} }
return false; return false;

View File

@ -50,6 +50,7 @@ class SMDS_EXPORT SMDS_MeshGroup:public SMDS_MeshObject
bool Remove(const SMDS_MeshElement * theElem); bool Remove(const SMDS_MeshElement * theElem);
bool IsEmpty() const { return myElements.empty(); } bool IsEmpty() const { return myElements.empty(); }
int Extent() const { return myElements.size(); } int Extent() const { return myElements.size(); }
int Tic() const { return myTic; }
int SubGroupsNb() const { return myChildren.size(); } int SubGroupsNb() const { return myChildren.size(); }
@ -87,5 +88,6 @@ class SMDS_EXPORT SMDS_MeshGroup:public SMDS_MeshObject
std::list<const SMDS_MeshGroup*> myChildren; std::list<const SMDS_MeshGroup*> myChildren;
TIterator myIterator; TIterator myIterator;
TGroupIterator myGroupIterator; TGroupIterator myGroupIterator;
int myTic; // to track changes
}; };
#endif #endif