moab
|
00001 /* 00002 * MOAB, a Mesh-Oriented datABase, is a software component for creating, 00003 * storing and accessing finite element mesh data. 00004 * 00005 * Copyright 2004 Sandia Corporation. Under the terms of Contract 00006 * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government 00007 * retains certain rights in this software. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 */ 00015 00022 #ifndef MB_RANGE_SEQ_INTERSECT_ITER_HPP 00023 #define MB_RANGE_SEQ_INTERSECT_ITER_HPP 00024 00025 #include "moab/Types.hpp" 00026 #include "moab/Range.hpp" 00027 00028 namespace moab { 00029 00030 class SequenceManager; 00031 class EntitySequence; 00032 00033 #define MB_RANGE_SEQ_INTERSECT_ITER_STATS 0 00034 00054 class RangeSeqIntersectIter { 00055 public: 00056 00057 RangeSeqIntersectIter( SequenceManager* sequences ) 00058 : mSequenceManager( sequences ), 00059 mSequence( 0 ), 00060 mStartHandle( 0 ), 00061 mEndHandle( 0 ), 00062 mLastHandle( 0 ) 00063 { } 00064 00070 ErrorCode init( Range::const_iterator start, Range::const_iterator end ); 00071 00077 ErrorCode step(); 00078 00085 bool is_at_end() const 00086 { return mEndHandle == mLastHandle; } 00087 00091 EntitySequence* get_sequence() const 00092 { return mSequence; } 00093 00095 EntityHandle get_start_handle() const 00096 { return mStartHandle; } 00097 00099 EntityHandle get_end_handle() const 00100 { return mEndHandle; } 00101 00102 #if MB_RANGE_SEQ_INTERSECT_ITER_STATS 00103 static double fragmentation() 00104 { return (doubleNumCalls + intNumCalls) / (doubleEntCount + intEntCount); } 00105 #endif 00106 00107 private: 00108 00115 ErrorCode update_entity_sequence(); 00116 00122 ErrorCode find_invalid_range(); 00123 00124 SequenceManager* mSequenceManager; 00125 EntitySequence* mSequence; 00126 Range::const_pair_iterator rangeIter; 00127 EntityHandle mStartHandle, mEndHandle; 00128 EntityHandle mLastHandle; 00129 00130 #if MB_RANGE_SEQ_INTERSECT_ITER_STATS 00131 static double doubleNumCalls, doubleEntCount; 00132 static unsigned long intNumCalls, intEntCount; 00133 static void update_stats( unsigned long num_ents); 00134 #endif 00135 }; 00136 00137 } // namespace moab 00138 00139 #endif 00140 00141