00001 #ifndef NMWR_GB_EDGE_ON_CELL2D_ITERATOR_H
00002 #define NMWR_GB_EDGE_ON_CELL2D_ITERATOR_H
00003
00004
00005
00006
00007
00008 #include "Utility/pre-post-conditions.h"
00009 #include "Gral/Grids/Complex2D/complex2d.h"
00010
00011 class EdgeOnCell2D_Iterator : public complex2d_types {
00012 friend class CellOnCell2D_Iterator;
00013 friend class Complex2D;
00014 friend class Cell2D;
00015 friend class Edge2D;
00016 friend class Edge2D_Iterator;
00017
00018 typedef EdgeOnCell2D_Iterator self;
00019 private:
00020
00021 Cell C;
00022 int lf;
00023
00024 public:
00025 typedef Cell anchor_type;
00026 typedef Edge element_type;
00027 typedef Edge value_type;
00028
00029
00030
00031 EdgeOnCell2D_Iterator()
00032 : C(), lf(0) {}
00033 explicit
00034 EdgeOnCell2D_Iterator(const Cell& CC)
00035 : C(CC), lf(0) {}
00036 EdgeOnCell2D_Iterator(int cnt, const Cell& CC)
00037 : C(CC), lf(cnt)
00038 {
00039 REQUIRE( (0 <= cnt),
00040 "EdgeOnCell2DIterator: invalid cnt = " << cnt << " specified!\n",1);
00041 }
00042 EdgeOnCell2D_Iterator(const Cell& CC, int cnt)
00043 : C(CC), lf(cnt)
00044 {
00045 REQUIRE( (0 <= cnt),
00046 "EdgeOnCell2DIterator: invalid cnt = " << cnt << " specified!\n",1);
00047 }
00048
00049
00050
00051
00052
00053
00054
00055 EdgeOnCell2D_Iterator(CellOnCell2D_Iterator const& nb);
00056
00057 ~EdgeOnCell2D_Iterator() {}
00058
00059
00060
00061 inline Edge operator*() const;
00062
00063 self& operator++() { ++lf; return (*this);}
00064 self& operator--() { --lf; return (*this);}
00065
00066
00067 inline self CyclicSucc() const;
00068 inline self CyclicPred() const;
00069
00070
00071
00072 bool IsDone() const {return ((lf < 0) || (lf >= TheCell().NumOfEdges()));}
00073 operator bool() const { return !IsDone();}
00074 int LocalNumber() const { return (lf+1);}
00075
00076 inline vertex_handle v1() const;
00077 inline vertex_handle v2() const;
00078
00079 inline cell_handle the_cell() const;
00080 inline cell_handle other_cell() const;
00081 inline Cell const& TheCell() const;
00082 inline Cell OtherCell() const;
00083
00084
00085
00086 anchor_type const& TheAnchor() const { return C;}
00087 Complex const& TheGrid() const { return C.TheGrid();}
00088
00089
00090
00091 friend bool operator==(const self& ls, const self& rs) {
00092 return ((ls.C == rs.C) && (ls.lf == rs.lf));
00093 }
00094 friend bool operator!=(const self& lhs, const self& rhs)
00095 { return !(lhs == rhs);}
00096
00097 void print(ostream& out) const;
00098 friend ostream& operator<<(ostream& out, const EdgeOnCell2D_Iterator& it)
00099 { it.print(out); return out; }
00100
00101 bool bound() const { return C.valid();}
00102 bool valid() const { return C.valid() && (0 <= lf) && (lf < C.NumOfEdges());}
00103 };
00104
00105
00106
00107 #endif
00108