Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
moab::VectorSetIterator Class Reference

#include <SetIterator.hpp>

+ Inheritance diagram for moab::VectorSetIterator:
+ Collaboration diagram for moab::VectorSetIterator:

Public Member Functions

virtual ErrorCode get_next_arr (std::vector< EntityHandle > &arr, bool &atend)
 get the next chunkSize entities Return the next chunkSize entities. More...
 
virtual ErrorCode reset ()
 reset the iterator to the beginning of the set More...
 
ErrorCode decrement (int num)
 decrement the position by the specified number; returns MB_FAILURE if resulting index is < 0 More...
 
- Public Member Functions inherited from moab::SetIterator
virtual ~SetIterator ()
 destructor More...
 
EntityHandle ent_set () const
 get the ent set for this iterator More...
 
unsigned int chunk_size () const
 get the chunk size of this iterator More...
 
EntityType ent_type () const
 get the entity type for this iterator More...
 
int ent_dimension () const
 get the dimension for this iterator More...
 

Protected Member Functions

 VectorSetIterator (Core *core, EntityHandle eset, int chunk_sz, EntityType ent_tp, int ent_dim, bool check_valid=false)
 Constructor. More...
 
- Protected Member Functions inherited from moab::SetIterator
 SetIterator (Core *core, EntityHandle eset, unsigned int chunk_sz, EntityType ent_tp, int ent_dim, bool check_valid=false)
 Constructor. More...
 

Private Attributes

int iterPos
 Current iterator position, 0 if at beginning. More...
 

Friends

class Core
 

Additional Inherited Members

- Protected Attributes inherited from moab::SetIterator
CoremyCore
 Core instance. More...
 
EntityHandle entSet
 handle for entity set corresponding to this iterator More...
 
unsigned int chunkSize
 chunk size of this iterator More...
 
EntityType entType
 entity type this iterator iterates over More...
 
int entDimension
 dimension this iterator iterates over More...
 
bool checkValid
 check for entity validity before returning handles More...
 

Detailed Description

Definition at line 153 of file SetIterator.hpp.

Constructor & Destructor Documentation

◆ VectorSetIterator()

moab::VectorSetIterator::VectorSetIterator ( Core core,
EntityHandle  eset,
int  chunk_sz,
EntityType  ent_tp,
int  ent_dim,
bool  check_valid = false 
)
inlineprotected

Constructor.

Parameters
coreMOAB Core instance
ent_setEntitySet to which this iterator corresponds
chunk_sizeChunk size of this iterator
ent_typeEntity type for this iterator
ent_dimEntity dimension for this iterator

Definition at line 179 of file SetIterator.hpp.

185  : SetIterator( core, eset, chunk_sz, ent_tp, ent_dim, check_valid ), iterPos( 0 )
186  {
187  }

Member Function Documentation

◆ decrement()

ErrorCode moab::VectorSetIterator::decrement ( int  num)
inline

decrement the position by the specified number; returns MB_FAILURE if resulting index is < 0

Definition at line 194 of file SetIterator.hpp.

195 {
196  iterPos -= num;
197  return ( iterPos < 0 ? MB_FAILURE : MB_SUCCESS );
198 }

References iterPos, and MB_SUCCESS.

◆ get_next_arr()

ErrorCode moab::VectorSetIterator::get_next_arr ( std::vector< EntityHandle > &  arr,
bool &  atend 
)
virtual

get the next chunkSize entities Return the next chunkSize entities.

Parameters
arrArray of entities returned.
atendReturns true if iterator is at the end of iterable values, otherwise false

Implements moab::SetIterator.

Definition at line 235 of file SetIterator.cpp.

236 {
237  int count;
238  const EntityHandle* ptr;
239  WriteUtilIface* iface;
240  Interface* mbImpl = dynamic_cast< Interface* >( myCore );
241  ErrorCode rval = mbImpl->query_interface( iface );
242  if( MB_SUCCESS != rval ) return rval;
243 
244  rval = iface->get_entity_list_pointers( &entSet, 1, &ptr, WriteUtilIface::CONTENTS, &count );
245  if( MB_SUCCESS != rval ) return rval;
246  mbImpl->release_interface( iface );
247 
248  if( !count || iterPos >= count )
249  {
250  atend = true;
251  return MB_SUCCESS;
252  }
253 
254  std::vector< EntityHandle > tmp_arr;
255  std::vector< EntityHandle >* tmp_ptr = &arr;
256  if( checkValid ) tmp_ptr = &tmp_arr;
257 
258  // just get the next chunkSize entities, or as many as you can
259  int this_ct = 0;
260  while( this_ct < (int)chunkSize && iterPos < count )
261  {
262  if( ( MBMAXTYPE == entType || TYPE_FROM_HANDLE( ptr[iterPos] ) == entType ) &&
263  ( -1 == entDimension || CN::Dimension( TYPE_FROM_HANDLE( ptr[iterPos] ) ) == entDimension ) )
264  {
265  arr.push_back( ptr[iterPos] );
266  this_ct++;
267  }
268  iterPos++;
269  }
270 
271  atend = ( iterPos == count );
272 
273  if( checkValid )
274  {
275  for( std::vector< EntityHandle >::iterator vit = tmp_ptr->begin(); vit != tmp_ptr->end(); ++vit )
276  {
277  if( myCore->is_valid( *vit ) ) arr.push_back( *vit );
278  }
279  }
280 
281  // step along list, adding entities
282  return MB_SUCCESS;
283 }

References moab::SetIterator::checkValid, moab::SetIterator::chunkSize, moab::WriteUtilIface::CONTENTS, moab::CN::Dimension(), moab::SetIterator::entDimension, moab::SetIterator::entSet, moab::SetIterator::entType, ErrorCode, iface, moab::Core::is_valid(), iterPos, MB_SUCCESS, MBMAXTYPE, moab::SetIterator::myCore, moab::Interface::query_interface(), moab::Interface::release_interface(), and moab::TYPE_FROM_HANDLE().

◆ reset()

ErrorCode moab::VectorSetIterator::reset ( )
virtual

reset the iterator to the beginning of the set

Implements moab::SetIterator.

Definition at line 285 of file SetIterator.cpp.

286 {
287  iterPos = 0;
288  return MB_SUCCESS;
289 }

References iterPos, and MB_SUCCESS.

Friends And Related Function Documentation

◆ Core

friend class Core
friend

Definition at line 156 of file SetIterator.hpp.

Member Data Documentation

◆ iterPos

int moab::VectorSetIterator::iterPos
private

Current iterator position, 0 if at beginning.

Definition at line 191 of file SetIterator.hpp.

Referenced by decrement(), get_next_arr(), and reset().


The documentation for this class was generated from the following files: