moab
|
00001 #ifndef MB_SETITERATOR_HPP 00002 #define MB_SETITERATOR_HPP 00003 00004 #include "moab/Interface.hpp" 00005 00006 namespace moab { 00007 00008 class Core; 00009 00013 class SetIterator 00014 { 00015 public: 00016 00017 friend class Core; 00018 00020 virtual ~SetIterator(); 00021 00023 inline EntityHandle ent_set() const {return entSet;}; 00024 00026 inline unsigned int chunk_size() const {return chunkSize;}; 00027 00029 inline EntityType ent_type() const {return entType;}; 00030 00032 inline int ent_dimension() const {return entDimension;}; 00033 00039 virtual ErrorCode get_next_arr(std::vector<EntityHandle> &arr, 00040 bool &atend) = 0; 00041 00043 virtual ErrorCode reset() = 0; 00044 00045 protected: 00046 00054 inline SetIterator(Core *core, EntityHandle eset, unsigned int chunk_sz, 00055 EntityType ent_tp, int ent_dim, bool check_valid = false) 00056 : myCore(core), entSet(eset), chunkSize(chunk_sz), 00057 entType(ent_tp), entDimension(ent_dim), checkValid(check_valid) {}; 00058 00060 Core *myCore; 00061 00063 EntityHandle entSet; 00064 00066 unsigned int chunkSize; 00067 00069 EntityType entType; 00070 00072 int entDimension; 00073 00075 bool checkValid; 00076 00077 }; 00078 00082 class RangeSetIterator : public SetIterator 00083 { 00084 public: 00085 friend class Core; 00086 00089 virtual ~RangeSetIterator(); 00090 00096 virtual ErrorCode get_next_arr(std::vector<EntityHandle> &arr, 00097 bool &atend); 00098 00100 virtual ErrorCode reset(); 00101 00102 protected: 00110 RangeSetIterator(Core *core, EntityHandle ent_set, int chunk_size, 00111 EntityType ent_type, int ent_dimension, bool check_valid = false); 00112 00113 private: 00114 ErrorCode get_next_by_type(const EntityHandle *&ptr, int count, 00115 std::vector<EntityHandle> &arr, bool &atend); 00116 00117 ErrorCode get_next_by_dimension(const EntityHandle *&ptr, int count, 00118 std::vector<EntityHandle> &arr, bool &atend); 00119 00121 ErrorCode build_pair_vec(); 00122 00124 EntityHandle iterPos; 00125 00127 EntityHandle *pairPtr; 00128 00130 int numPairs; 00131 }; 00132 00136 class VectorSetIterator : public SetIterator 00137 { 00138 public: 00139 friend class Core; 00140 00146 virtual ErrorCode get_next_arr(std::vector<EntityHandle> &arr, 00147 bool &atend); 00148 00150 virtual ErrorCode reset(); 00151 00153 inline ErrorCode decrement(int num); 00154 00155 protected: 00163 inline VectorSetIterator(Core *core, EntityHandle eset, int chunk_sz, 00164 EntityType ent_tp, int ent_dim, bool check_valid = false) 00165 : SetIterator(core, eset, chunk_sz, ent_tp, ent_dim, check_valid), 00166 iterPos(0) 00167 {} 00168 00169 private: 00171 int iterPos; 00172 00173 }; 00174 00175 inline ErrorCode VectorSetIterator::decrement(int num) 00176 { 00177 iterPos -= num; 00178 return (iterPos < 0 ? MB_FAILURE : MB_SUCCESS); 00179 } 00180 00181 } // namespace moab 00182 00183 #endif