0021275: EDF 1681 SMESH: Find the number of nodes of any group

+  virtual int GetTic() const;
This commit is contained in:
eap 2011-10-04 07:17:28 +00:00
parent 044576569d
commit af3090f59b
7 changed files with 44 additions and 1 deletions

View File

@ -161,6 +161,17 @@ SMDS_ElemIteratorPtr SMESHDS_Group::GetElements() const
return SMDS_ElemIteratorPtr( new MyGroupIterator ( myGroup )); return SMDS_ElemIteratorPtr( new MyGroupIterator ( myGroup ));
} }
//================================================================================
/*!
* \brief Return a value allowing to find out if a group has changed or not
*/
//================================================================================
int SMESHDS_Group::GetTic() const
{
return myGroup.Tic();
}
//======================================================================= //=======================================================================
//function : SetType //function : SetType
//purpose : //purpose :

View File

@ -56,6 +56,8 @@ class SMESHDS_EXPORT SMESHDS_Group : public SMESHDS_GroupBase
virtual SMDS_ElemIteratorPtr GetElements() const; virtual SMDS_ElemIteratorPtr GetElements() const;
virtual int GetTic() const;
bool Add (const int theID); bool Add (const int theID);
bool Remove (const int theID); bool Remove (const int theID);

View File

@ -71,6 +71,8 @@ class SMESHDS_EXPORT SMESHDS_GroupBase
virtual int GetID (const int theIndex); virtual int GetID (const int theIndex);
// use it for iterations 1..Extent() // use it for iterations 1..Extent()
virtual int GetTic() const = 0;
virtual ~SMESHDS_GroupBase() {} virtual ~SMESHDS_GroupBase() {}
void SetColor (const Quantity_Color& theColor) void SetColor (const Quantity_Color& theColor)

View File

@ -40,7 +40,7 @@ SMESHDS_GroupOnFilter::SMESHDS_GroupOnFilter (const int theID,
const SMESHDS_Mesh* theMesh, const SMESHDS_Mesh* theMesh,
const SMDSAbs_ElementType theType, const SMDSAbs_ElementType theType,
const SMESH_PredicatePtr& thePredicate) const SMESH_PredicatePtr& thePredicate)
: SMESHDS_GroupBase(theID,theMesh,theType), myMeshModifTime(0) : SMESHDS_GroupBase(theID,theMesh,theType), myMeshModifTime(0), myPredicateTic(0)
{ {
setChanged(); setChanged();
SetPredicate( thePredicate ); SetPredicate( thePredicate );
@ -55,6 +55,7 @@ SMESHDS_GroupOnFilter::SMESHDS_GroupOnFilter (const int theID,
void SMESHDS_GroupOnFilter::SetPredicate( const SMESH_PredicatePtr& thePredicate) void SMESHDS_GroupOnFilter::SetPredicate( const SMESH_PredicatePtr& thePredicate)
{ {
myPredicate = thePredicate; myPredicate = thePredicate;
++myPredicateTic;
setChanged(); setChanged();
if ( myPredicate ) if ( myPredicate )
myPredicate->SetMesh( GetMesh() ); myPredicate->SetMesh( GetMesh() );
@ -123,6 +124,17 @@ int SMESHDS_GroupOnFilter::GetID (const int theIndex)
return myElements[ theIndex-1 ]->GetID(); return myElements[ theIndex-1 ]->GetID();
} }
//================================================================================
/*!
* \brief Return a value allowing to find out if a group has changed or not
*/
//================================================================================
int SMESHDS_GroupOnFilter::GetTic() const
{
return myMeshModifTime * myPredicateTic;
}
//================================================================================ //================================================================================
/*! /*!
* \brief Updates myElements if necessary * \brief Updates myElements if necessary

View File

@ -56,6 +56,8 @@ class SMESHDS_EXPORT SMESHDS_GroupOnFilter: public SMESHDS_GroupBase
virtual int GetID (const int theIndex); virtual int GetID (const int theIndex);
virtual int GetTic() const;
private: private:
void update() const; void update() const;
@ -64,6 +66,7 @@ class SMESHDS_EXPORT SMESHDS_GroupOnFilter: public SMESHDS_GroupBase
SMESH_PredicatePtr myPredicate; SMESH_PredicatePtr myPredicate;
std::vector< const SMDS_MeshElement*> myElements; std::vector< const SMDS_MeshElement*> myElements;
unsigned long myMeshModifTime; // when myElements was filled unsigned long myMeshModifTime; // when myElements was filled
int myPredicateTic;
}; };
#endif #endif

View File

@ -128,3 +128,14 @@ bool SMESHDS_GroupOnGeom::Contains (const SMDS_MeshElement* elem)
return mySubMesh->Contains( elem ); return mySubMesh->Contains( elem );
} }
//================================================================================
/*!
* \brief Return a value allowing to find out if a group has changed or not
*/
//================================================================================
int SMESHDS_GroupOnGeom::GetTic() const
{
return GetMesh()->GetMTime();
}

View File

@ -53,6 +53,8 @@ class SMESHDS_EXPORT SMESHDS_GroupOnGeom: public SMESHDS_GroupBase
virtual SMDS_ElemIteratorPtr GetElements() const; virtual SMDS_ElemIteratorPtr GetElements() const;
virtual int GetTic() const;
private: private:
TopoDS_Shape myShape; TopoDS_Shape myShape;