const SMESHDS_Mesh* theMesh,
const SMDSAbs_ElementType theType,
const SMESH_PredicatePtr& thePredicate)
- : SMESHDS_GroupBase(theID,theMesh,theType), myMeshModifTime(0)
+ : SMESHDS_GroupBase(theID,theMesh,theType), myMeshModifTime(0), myPredicateTic(0)
{
setChanged();
SetPredicate( thePredicate );
void SMESHDS_GroupOnFilter::SetPredicate( const SMESH_PredicatePtr& thePredicate)
{
myPredicate = thePredicate;
+ ++myPredicateTic;
setChanged();
if ( myPredicate )
myPredicate->SetMesh( GetMesh() );
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 GetMesh()->GetMTime() * myPredicateTic;
+}
+
+//================================================================================
+/*!
+ * \brief Return false if update() is needed
+ */
+//================================================================================
+
+bool SMESHDS_GroupOnFilter::IsUpToDate() const
+{
+ return !( myMeshModifTime < GetMesh()->GetMTime() );
+}
+
//================================================================================
/*!
* \brief Updates myElements if necessary
void SMESHDS_GroupOnFilter::update() const
{
- if ( myMeshModifTime < GetMesh()->GetMTime() )
+ if ( !IsUpToDate() )
{
SMESHDS_GroupOnFilter* me = const_cast<SMESHDS_GroupOnFilter*>( this );
me->myElements.clear();
if ( myPredicate )
{
+ myPredicate->SetMesh( GetMesh() ); // hope myPredicate updates self here if necessary
me->myElements.reserve( GetMesh()->GetMeshInfo().NbElements(GetType()));
SMDS_ElemIteratorPtr elIt = GetMesh()->elementsIterator(GetType());
while ( elIt->more() )
if ( myPredicate->IsSatisfy( e->GetID() ))
me->myElements.push_back( e );
}
- me->myElements.resize( myElements.size() );
+ vector< const SMDS_MeshElement*> elems( me->myElements.begin(), me->myElements.end() );
+ me->myElements.swap( elems );
}
me->setChanged( false );
}