moab
|
#include <SetIterator.hpp>
Public Member Functions | |
virtual ErrorCode | get_next_arr (std::vector< EntityHandle > &arr, bool &atend) |
get the next chunkSize entities Return the next chunkSize entities. | |
virtual ErrorCode | reset () |
reset the iterator to the beginning of the set | |
ErrorCode | decrement (int num) |
decrement the position by the specified number; returns MB_FAILURE if resulting index is < 0 | |
Protected Member Functions | |
VectorSetIterator (Core *core, EntityHandle eset, int chunk_sz, EntityType ent_tp, int ent_dim, bool check_valid=false) | |
Constructor. | |
Private Attributes | |
int | iterPos |
Current iterator position, 0 if at beginning. | |
Friends | |
class | Core |
Definition at line 136 of file SetIterator.hpp.
moab::VectorSetIterator::VectorSetIterator | ( | Core * | core, |
EntityHandle | eset, | ||
int | chunk_sz, | ||
EntityType | ent_tp, | ||
int | ent_dim, | ||
bool | check_valid = false |
||
) | [inline, protected] |
Constructor.
core | MOAB Core instance |
ent_set | EntitySet to which this iterator corresponds |
chunk_size | Chunk size of this iterator |
ent_type | Entity type for this iterator |
ent_dim | Entity dimension for this iterator |
Definition at line 163 of file SetIterator.hpp.
: SetIterator(core, eset, chunk_sz, ent_tp, ent_dim, check_valid), iterPos(0) {}
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 175 of file SetIterator.hpp.
{ iterPos -= num; return (iterPos < 0 ? MB_FAILURE : MB_SUCCESS); }
ErrorCode moab::VectorSetIterator::get_next_arr | ( | std::vector< EntityHandle > & | arr, |
bool & | atend | ||
) | [virtual] |
get the next chunkSize entities Return the next chunkSize entities.
arr | Array of entities returned. |
atend | Returns true if iterator is at the end of iterable values, otherwise false |
Implements moab::SetIterator.
Definition at line 218 of file SetIterator.cpp.
{ int count; const EntityHandle *ptr; WriteUtilIface *iface; Interface *mbImpl = dynamic_cast<Interface*>(myCore); ErrorCode rval = mbImpl->query_interface(iface); if (MB_SUCCESS != rval) return rval; rval = iface->get_entity_list_pointers( &entSet, 1, &ptr, WriteUtilIface::CONTENTS, &count); if (MB_SUCCESS != rval) return rval; mbImpl->release_interface(iface); if (!count || iterPos >= count) { atend = true; return MB_SUCCESS; } std::vector<EntityHandle> tmp_arr; std::vector<EntityHandle> *tmp_ptr = &arr; if (checkValid) tmp_ptr = &tmp_arr; // just get the next chunkSize entities, or as many as you can int this_ct = 0; while (this_ct < (int)chunkSize && iterPos < count) { if ((MBMAXTYPE == entType || TYPE_FROM_HANDLE(ptr[iterPos]) == entType) && (-1 == entDimension || CN::Dimension(TYPE_FROM_HANDLE(ptr[iterPos])) == entDimension)) { arr.push_back(ptr[iterPos]); this_ct++; } iterPos++; } atend = (iterPos == count); if (checkValid) { for (std::vector<EntityHandle>::iterator vit = tmp_ptr->begin(); vit != tmp_ptr->end(); vit++) { if (myCore->is_valid(*vit)) arr.push_back(*vit); } } // step along list, adding entities return MB_SUCCESS; }
ErrorCode moab::VectorSetIterator::reset | ( | ) | [virtual] |
reset the iterator to the beginning of the set
Implements moab::SetIterator.
Definition at line 264 of file SetIterator.cpp.
{ iterPos = 0; return MB_SUCCESS; }
friend class Core [friend] |
Reimplemented from moab::SetIterator.
Definition at line 139 of file SetIterator.hpp.
int moab::VectorSetIterator::iterPos [private] |
Current iterator position, 0 if at beginning.
Definition at line 171 of file SetIterator.hpp.