Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
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.
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 153 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 179 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 194 of file SetIterator.hpp.

References iterPos, and MB_SUCCESS.

{
    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 235 of file SetIterator.cpp.

References moab::SetIterator::checkValid, moab::SetIterator::chunkSize, moab::WriteUtilIface::CONTENTS, moab::CN::Dimension(), moab::SetIterator::entDimension, moab::SetIterator::entSet, moab::SetIterator::entType, ErrorCode, moab::WriteUtilIface::get_entity_list_pointers(), 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().

{
    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 285 of file SetIterator.cpp.

References iterPos, and MB_SUCCESS.

{
    iterPos = 0;
    return MB_SUCCESS;
}

Friends And Related Function Documentation

friend class Core [friend]

Reimplemented from moab::SetIterator.

Definition at line 156 of file SetIterator.hpp.


Member Data Documentation

Current iterator position, 0 if at beginning.

Definition at line 191 of file SetIterator.hpp.

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

List of all members.


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