- {
- // start from elem with max ID to avoid filling the pool of IDs
- bool rev = true;
- SMDS_ElemIteratorPtr ite = subMeshDS->GetElements( rev );
- const SMDS_MeshElement * lastElem = ite->next();
- rev = ( lastElem->GetID() == meshDS->MaxElementID() );
- if ( !rev )
- ite = subMeshDS->GetElements( rev );
- else
- meshDS->RemoveFreeElement( lastElem, subMeshDS );
- while (ite->more()) {
- const SMDS_MeshElement * elt = ite->next();
- meshDS->RemoveFreeElement( elt, subMeshDS );
- }
- }
+ for ( SMDS_ElemIteratorPtr ite = subMeshDS->GetElements(); ite->more(); )
+ meshDS->RemoveFreeElement( ite->next(), subMeshDS );
+