moab
moab::VectorSetIterator Class Reference

#include <SetIterator.hpp>

Inheritance diagram for moab::VectorSetIterator:
moab::SetIterator

List of all members.

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

Detailed Description

Definition at line 136 of file SetIterator.hpp.


Constructor & Destructor Documentation

moab::VectorSetIterator::VectorSetIterator ( Core core,
EntityHandle  eset,
int  chunk_sz,
EntityType  ent_tp,
int  ent_dim,
bool  check_valid = false 
) [inline, protected]

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 163 of file SetIterator.hpp.

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

Member Function Documentation

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.

Parameters:
arrArray of entities returned.
atendReturns 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;
}

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;
}

Friends And Related Function Documentation

friend class Core [friend]

Reimplemented from moab::SetIterator.

Definition at line 139 of file SetIterator.hpp.


Member Data Documentation

Current iterator position, 0 if at beginning.

Definition at line 171 of file SetIterator.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines