00001 #ifndef _BLIterator_H_ 00002 #define _BLIterator_H_ 00003 #include "BoxLayout.H" 00004 00005 ///Iterator for the BoxLayout class. Used to iterate through the Points in bit space associated with patches of the domain. 00006 /** 00007 Used to iterate through the Points in bit space associated with patches of the domain.\n\n 00008 Example usage: \n 00009 @code 00010 BoxLayout layout; 00011 // ... layout is constructed ... 00012 Point pi; Box bi; 00013 for (BLIterator iter(layout); iter != iter.end(); ++iter) { 00014 // access current Point: 00015 pi = (*iter); 00016 // access current Patch: 00017 bi = layout[*iter]; 00018 // ... do things ... 00019 } 00020 @endcode 00021 */ 00022 class BLIterator 00023 { 00024 public: 00025 /// Default Constructor 00026 BLIterator(); 00027 /// Create a BLIterator from a BoxLayout 00028 BLIterator(const BoxLayout& a_boxLayout); 00029 00030 ///Destructor 00031 ~BLIterator(); 00032 00033 /// Definition of increment operator 00034 BLIterator& operator++(); 00035 00036 /// Definition of "*" operator 00037 Point& operator*(); 00038 00039 /// Returns the linear index of the point in m_boxLayout associated with *this. 00040 int operator()(){return m_boxLayout.getPatchIndex(*(*this));}; 00041 00042 /// Equality test for BLIterator objects 00043 bool operator!=(BLIterator a_other); 00044 /// Returns a BLIterator pointing to the first Point in m_boxLayout. 00045 BLIterator begin(); 00046 00047 /// Returns a BLIterator pointing to a Point outside m_boxLayout. 00048 /** 00049 This method should only be used to check if we're done in a for-loop. 00050 */ 00051 BLIterator end(); 00052 00053 private: 00054 00055 /// Create a BLIterator from a BoxLayout starting from a user defined Point in bit-space. 00056 /** 00057 Only used internally by end(), and does not create a legitimate BLIterator. Possibly unnecessary. 00058 */ 00059 BLIterator(const BoxLayout& a_boxLayout, const Point& a_point); 00060 00061 BoxLayout m_boxLayout; ///< BoxLayout object associated with *this 00062 Point m_data; ///< Current iterant. Data is a Point in bit-space representing (the lowCorner of) a patch in the BoxLayout domain. 00063 std::vector<Point>::iterator m_vectorIterator; ///< An object used to iterate through a vector<Point> object. 00064 }; 00065 #endif // _BLIterator_H_