MOAB: Mesh Oriented datABase
(version 5.4.1)
|
Iterate over the blocks of EntityHandles in an Range that are in the same EntitySequence. More...
#include <RangeSeqIntersectIter.hpp>
Public Member Functions | |
RangeSeqIntersectIter (SequenceManager *sequences) | |
ErrorCode | init (Range::const_iterator start, Range::const_iterator end) |
ErrorCode | step () |
bool | is_at_end () const |
Check if next call to step() will return MB_FAILURE. | |
EntitySequence * | get_sequence () const |
EntityHandle | get_start_handle () const |
EntityHandle | get_end_handle () const |
Private Member Functions | |
ErrorCode | update_entity_sequence () |
ErrorCode | find_invalid_range () |
Private Attributes | |
SequenceManager * | mSequenceManager |
THE EntitySequenceManager. | |
EntitySequence * | mSequence |
EntitySequence corresponding to current location. | |
Range::const_pair_iterator | rangeIter |
Current position in Range. | |
EntityHandle | mStartHandle |
EntityHandle | mEndHandle |
Subset of current EntitySequence. | |
EntityHandle | mLastHandle |
The last of the list of all handles in the Range. |
Iterate over the blocks of EntityHandles in an Range that are in the same EntitySequence.
Iterate over an Range, returning blocks of entities that are the largest ranges of contiguous handles that meet one of the following conditions:
The return type from init() or step() indicates whether or not the current range contains valid entities. If the handles are either all valid or all holes in an EntitySequence, that sequence can be obtained with get_sequence(). get_sequence() will return NULL if there is no corresponding EntitySequence for the block of handles.
This class keeps a data related to the 'current' EntitySequence and references to the Range pasesd to init(). Changing either of these while an instance of this class is in use would be bad.
Definition at line 55 of file RangeSeqIntersectIter.hpp.
moab::RangeSeqIntersectIter::RangeSeqIntersectIter | ( | SequenceManager * | sequences | ) | [inline] |
Definition at line 58 of file RangeSeqIntersectIter.hpp.
: mSequenceManager( sequences ), mSequence( 0 ), mStartHandle( 0 ), mEndHandle( 0 ), mLastHandle( 0 ) { }
ErrorCode moab::RangeSeqIntersectIter::find_invalid_range | ( | ) | [private] |
Handle error case where we encountered an EntityHandle w/out a corresponding EntitySequence. Trim mEndHandle such that it is before the next valid EntityHandle of the same type.
Definition at line 112 of file RangeSeqIntersectIter.cpp.
References moab::CREATE_HANDLE(), moab::TypeSequenceManager::end(), moab::SequenceManager::entity_map(), MB_END_ID, MB_ENTITY_NOT_FOUND, mEndHandle, mSequence, mSequenceManager, mStartHandle, moab::TYPE_FROM_HANDLE(), and moab::TypeSequenceManager::upper_bound().
Referenced by update_entity_sequence().
{ assert( !mSequence ); // no more entities in current range if( mStartHandle == mEndHandle ) return MB_ENTITY_NOT_FOUND; // Find the next EntitySequence EntityType type = TYPE_FROM_HANDLE( mStartHandle ); const TypeSequenceManager& map = mSequenceManager->entity_map( type ); TypeSequenceManager::const_iterator iter = map.upper_bound( mStartHandle ); // If no next sequence of the same type if( iter == map.end() ) { // If end type not the same as start type, split on type if( type != TYPE_FROM_HANDLE( mEndHandle ) ) { int junk; mEndHandle = CREATE_HANDLE( type, MB_END_ID, junk ); } } // otherwise invalid range ends at min(mEndHandle, sequence start handle - 1) else if( ( *iter )->start_handle() <= mEndHandle ) { mEndHandle = ( *iter )->start_handle() - 1; } return MB_ENTITY_NOT_FOUND; }
EntityHandle moab::RangeSeqIntersectIter::get_end_handle | ( | ) | const [inline] |
Get last handle in block
Definition at line 105 of file RangeSeqIntersectIter.hpp.
References mEndHandle.
Referenced by moab::get_tagged(), mb_range_seq_intersect_test(), moab::WriteDamsel::write_entities(), moab::WriteDamsel::write_sets(), and moab::WriteDamsel::write_vertices().
{ return mEndHandle; }
EntitySequence* moab::RangeSeqIntersectIter::get_sequence | ( | ) | const [inline] |
Get the EntitySequence for the current block. May be NULL for invaild handles.
Definition at line 93 of file RangeSeqIntersectIter.hpp.
References mSequence.
Referenced by moab::get_tagged(), moab::WriteDamsel::map_dense_tags(), mb_range_seq_intersect_test(), and moab::WriteDamsel::write_entities().
{ return mSequence; }
EntityHandle moab::RangeSeqIntersectIter::get_start_handle | ( | ) | const [inline] |
Get first handle in block
Definition at line 99 of file RangeSeqIntersectIter.hpp.
References mStartHandle.
Referenced by moab::get_tagged(), moab::WriteDamsel::map_dense_tags(), mb_range_seq_intersect_test(), moab::WriteDamsel::write_entities(), moab::WriteDamsel::write_sets(), moab::WriteDamsel::write_subrange(), and moab::WriteDamsel::write_vertices().
{ return mStartHandle; }
ErrorCode moab::RangeSeqIntersectIter::init | ( | Range::const_iterator | start, |
Range::const_iterator | end | ||
) |
Initialize iterator to first valid subset
Definition at line 29 of file RangeSeqIntersectIter.cpp.
References ErrorCode, mEndHandle, mLastHandle, mSequence, mStartHandle, rangeIter, and update_entity_sequence().
Referenced by moab::get_tagged(), mb_range_seq_intersect_test(), and moab::WriteDamsel::write_file().
{ mSequence = 0; rangeIter = start; // special case : nothing to iterate over if( start == end ) { mStartHandle = mEndHandle = mLastHandle = 0; return MB_FAILURE; } // normal case mStartHandle = *start; --end; mLastHandle = *end; mEndHandle = ( *rangeIter ).second; if( mEndHandle > mLastHandle ) mEndHandle = mLastHandle; #if MB_RANGE_SEQ_INTERSECT_ITER_STATS ErrorCode result = update_entity_sequence(); update_stats( mEndHandle - mStartHandle + 1 ); return result; #else return update_entity_sequence(); #endif }
bool moab::RangeSeqIntersectIter::is_at_end | ( | ) | const [inline] |
Check if next call to step() will return MB_FAILURE.
Check if the iterator cannot be advanced any further. If this method returns true, then the *next* call to step() will return MB_FAILURE.
Definition at line 85 of file RangeSeqIntersectIter.hpp.
References mEndHandle, and mLastHandle.
Referenced by mb_range_seq_intersect_test(), and step().
{ return mEndHandle == mLastHandle; }
Step iterator to next range.
Definition at line 57 of file RangeSeqIntersectIter.cpp.
References ErrorCode, is_at_end(), mEndHandle, mLastHandle, mStartHandle, rangeIter, and update_entity_sequence().
Referenced by moab::get_tagged(), mb_range_seq_intersect_test(), and moab::WriteDamsel::write_file().
{ // If at end, return MB_FAILURE if( is_at_end() ) return MB_FAILURE; // If the last block was at the end of the rangeIter pair, // then advance the iterator and set the next block else if( mEndHandle == ( *rangeIter ).second ) { ++rangeIter; mStartHandle = ( *rangeIter ).first; } // Otherwise start with next entity in the pair else { mStartHandle = mEndHandle + 1; } // Always take the remaining entities in the rangeIter pair. // will trim up the end of the range in update_entity_sequence(). mEndHandle = ( *rangeIter ).second; if( mEndHandle > mLastHandle ) mEndHandle = mLastHandle; // Now trim up the range (decrease mEndHandle) as necessary // for the corresponding EntitySquence #if MB_RANGE_SEQ_INTERSECT_ITER_STATS ErrorCode result = update_entity_sequence(); update_stats( mEndHandle - mStartHandle + 1 ); return result; #else return update_entity_sequence(); #endif }
ErrorCode moab::RangeSeqIntersectIter::update_entity_sequence | ( | ) | [private] |
Update entity sequence data (mSequence and freeIndex) for current mStartHandle. If mEndHandle is past end of sequence, trim it. Called by step() and init(). step() handles iterating over the pairs in the Range. This method handles iterating over the set of EntitySequences that intersect the pair.
Definition at line 89 of file RangeSeqIntersectIter.cpp.
References moab::EntitySequence::end_handle(), moab::SequenceManager::find(), find_invalid_range(), MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, MBMAXTYPE, mEndHandle, mSequence, mSequenceManager, mStartHandle, and moab::TYPE_FROM_HANDLE().
Referenced by init(), and step().
{ // mStartHandle to mEndHandle is a subset of the Range. // Update sequence data as necessary and trim that subset // (reduce mEndHandle) for the current EntitySequence. // Need to update the sequence pointer? if( !mSequence || mStartHandle > mSequence->end_handle() ) { // Check that the mStartHandle is valid if( TYPE_FROM_HANDLE( mStartHandle ) >= MBMAXTYPE ) return MB_TYPE_OUT_OF_RANGE; if( MB_SUCCESS != mSequenceManager->find( mStartHandle, mSequence ) ) return find_invalid_range(); } // if mEndHandle is past end of sequence or block of used // handles within sequence, shorten it. if( mEndHandle > mSequence->end_handle() ) mEndHandle = mSequence->end_handle(); return MB_SUCCESS; }
Subset of current EntitySequence.
Definition at line 136 of file RangeSeqIntersectIter.hpp.
Referenced by find_invalid_range(), get_end_handle(), init(), is_at_end(), step(), and update_entity_sequence().
The last of the list of all handles in the Range.
Definition at line 137 of file RangeSeqIntersectIter.hpp.
Referenced by init(), is_at_end(), and step().
EntitySequence corresponding to current location.
Definition at line 134 of file RangeSeqIntersectIter.hpp.
Referenced by find_invalid_range(), get_sequence(), init(), and update_entity_sequence().
THE EntitySequenceManager.
Definition at line 133 of file RangeSeqIntersectIter.hpp.
Referenced by find_invalid_range(), and update_entity_sequence().
Definition at line 136 of file RangeSeqIntersectIter.hpp.
Referenced by find_invalid_range(), get_start_handle(), init(), step(), and update_entity_sequence().
Current position in Range.
Definition at line 135 of file RangeSeqIntersectIter.hpp.