X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHDS%2FSMESHDS_GroupOnFilter.cxx;h=32bd8c7f3485553f1dcb7cc7e7bfd4bba304db29;hp=8a984c2755cfd544bcaa3f3a944b4888f6a94ce4;hb=d4a710ce52f6e76786a7b3845e2f7975dc9a00b1;hpb=ec36250a0d659f848132377cd4deae8f4e38a8fd diff --git a/src/SMESHDS/SMESHDS_GroupOnFilter.cxx b/src/SMESHDS/SMESHDS_GroupOnFilter.cxx index 8a984c275..32bd8c7f3 100644 --- a/src/SMESHDS/SMESHDS_GroupOnFilter.cxx +++ b/src/SMESHDS/SMESHDS_GroupOnFilter.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -40,7 +40,7 @@ SMESHDS_GroupOnFilter::SMESHDS_GroupOnFilter (const int theID, 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 ); @@ -55,6 +55,7 @@ SMESHDS_GroupOnFilter::SMESHDS_GroupOnFilter (const int theID, void SMESHDS_GroupOnFilter::SetPredicate( const SMESH_PredicatePtr& thePredicate) { myPredicate = thePredicate; + ++myPredicateTic; setChanged(); if ( myPredicate ) myPredicate->SetMesh( GetMesh() ); @@ -66,7 +67,7 @@ void SMESHDS_GroupOnFilter::SetPredicate( const SMESH_PredicatePtr& thePredicate */ //================================================================================ -int SMESHDS_GroupOnFilter::Extent() +int SMESHDS_GroupOnFilter::Extent() const { update(); return myElements.size(); @@ -123,6 +124,28 @@ int SMESHDS_GroupOnFilter::GetID (const int theIndex) 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 @@ -131,12 +154,13 @@ int SMESHDS_GroupOnFilter::GetID (const int theIndex) void SMESHDS_GroupOnFilter::update() const { - if ( myMeshModifTime < GetMesh()->GetMTime() ) + if ( !IsUpToDate() ) { SMESHDS_GroupOnFilter* me = const_cast( 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() ) @@ -145,7 +169,8 @@ void SMESHDS_GroupOnFilter::update() const 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 ); }