00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef OLENA_TOPO_INTER_PIXEL_INTERNAL_DIR_ITER_HH
00029 # define OLENA_TOPO_INTER_PIXEL_INTERNAL_DIR_ITER_HH
00030
00031 # include <mlc/objs.hh>
00032 # include <oln/core/abstract/iter1d.hh>
00033 # include <oln/core/abstract/iter2d.hh>
00034 # include <oln/core/abstract/iter3d.hh>
00035 # include <oln/topo/inter-pixel/internal/dir.hh>
00036
00037 namespace oln {
00038
00039 namespace topo {
00040 namespace inter_pixel {
00041 namespace internal {
00042
00043 template<unsigned Dim, class Exact>
00044 class dir_iter_;
00045
00046 }
00047 }
00048 }
00049
00051 template<class Exact>
00052 struct iter_traits<topo::inter_pixel::internal::dir_iter_<1, Exact> >
00053 : public iter_traits<abstract::iter1d<Exact> >
00054 {
00055 typedef abstract::iter1d<Exact> super_type;
00056 typedef point1d point_type;
00057 typedef dpoint1d dpoint_type;
00058 };
00059
00061 template<class Exact>
00062 struct iter_traits<topo::inter_pixel::internal::dir_iter_<2, Exact> >
00063 : public iter_traits<abstract::iter2d<Exact> >
00064 {
00065 typedef abstract::iter2d<Exact> super_type;
00066 typedef point2d point_type;
00067 typedef dpoint2d dpoint_type;
00068 };
00069
00071 template<class Exact>
00072 struct iter_traits<topo::inter_pixel::internal::dir_iter_<3, Exact> >
00073 : public iter_traits<abstract::iter3d<Exact> >
00074 {
00075 typedef abstract::iter3d<Exact> super_type;
00076 typedef point3d point_type;
00077 typedef dpoint3d dpoint_type;
00078 };
00079
00080 namespace topo {
00081
00082 namespace inter_pixel {
00083
00084 namespace internal {
00085
00086 template<unsigned Dim, class Exact>
00087 class dir_iter_ : public iter_traits<dir_iter_<Dim, Exact> >::super_type
00088 {
00089 protected:
00090 typedef typename dir_traits<Dim>::ret dir_type;
00091 typedef typename iter_traits<dir_iter_<Dim, Exact> >::super_type super_type;
00092
00093 dir_iter_() : super_type(), cur_(this->exact().begin()), cnt_(0) {}
00094 dir_iter_(dir_type i) : super_type(), cur_(i), cnt_(0) {}
00095
00096 public:
00097 operator dir_type()
00098 {
00099 return cur_;
00100 }
00101
00102 dir_type
00103 to_dir() const
00104 {
00105 return cur_;
00106 }
00107
00108 void
00109 operator++()
00110 {
00111 precondition(cnt_ != Dim * 2);
00112 cur_ = this->exact().next();
00113 ++cnt_;
00114 }
00115
00116 bool
00117 operator==(mlc::end_type) const
00118 {
00119 return cnt_ == Dim * 2;
00120 }
00121 bool
00122 operator!=(mlc::end_type) const
00123 {
00124 return cnt_ != Dim * 2;
00125 }
00126
00127 mlc::begin_type
00128 operator=(mlc::begin_type b)
00129 {
00130 cur_ = this->exact().begin();
00131 cnt_ = 0;
00132 return b;
00133 }
00134 mlc::end_type
00135 operator=(mlc::end_type e)
00136 {
00137 cur_ = this->exact().begin();
00138 cnt_ = Dim * 2;
00139 return e;
00140 }
00141
00142 protected:
00143 dir_type cur_;
00144
00145 private:
00146 unsigned cnt_;
00147 };
00148
00149 }
00150
00151 }
00152
00153 }
00154
00155 }
00156
00157 template<unsigned Dim, class Exact>
00158 inline
00159 std::ostream&
00160 operator<<(std::ostream& o, const oln::topo::inter_pixel::internal::dir_iter_<Dim, Exact>& it)
00161 {
00162 return o << it.to_dir();
00163 }
00164
00165 #endif // ! OLENA_TOPO_INTER_PIXEL_INTERNAL_DIR_ITER_HH