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 #ifndef MLN_CANVAS_BROWSING_SNAKE_VERT_HH
00028 # define MLN_CANVAS_BROWSING_SNAKE_VERT_HH
00029
00033
00034 # include <mln/core/concept/browsing.hh>
00035 # include <mln/geom/size2d.hh>
00036
00037
00038 namespace mln
00039 {
00040
00041 namespace canvas
00042 {
00043
00044 namespace browsing
00045 {
00046
00048
00084 struct snake_vert_t : public Browsing< snake_vert_t >
00085 {
00086
00087
00088 snake_vert_t();
00089
00090 template <typename F>
00091 void operator()(F& f) const;
00092 };
00093
00094 extern const snake_vert_t snake_vert;
00095
00096 # ifndef MLN_INCLUDE_ONLY
00097
00098 # ifndef MLN_WO_GLOBAL_VARS
00099
00100 const snake_vert_t snake_vert;
00101
00102 # endif // ! MLN_WO_GLOBAL_VARS
00103
00104 inline
00105 snake_vert_t::snake_vert_t()
00106 {
00107 }
00108
00109 template <typename F>
00110 inline
00111 void
00112 snake_vert_t::operator()(F& f) const
00113 {
00114
00115
00116
00117 trace::entering("canvas::browsing::snake_vert");
00118 mln_precondition(f.input.is_valid());
00119 int
00120 min_row = geom::min_row(f.input), max_row = geom::max_row(f.input),
00121 min_col = geom::min_col(f.input), max_col = geom::max_col(f.input);
00122
00123
00124 f.p = f.input.bbox().pmin();
00125 def::coord& row = f.p.row();
00126 def::coord& col = f.p.col();
00127
00128
00129 f.init();
00130
00131 bool down = true;
00132 for (col = min_col; col <= max_col; ++col)
00133
00134 {
00135
00136 f.fwd();
00137
00138 if (down)
00139
00140 while (row < max_row)
00141 {
00142 ++row;
00143 f.down();
00144 }
00145 else
00146
00147 while (row > min_row)
00148 {
00149 --row;
00150 f.up();
00151 }
00152
00153
00154 down = ! down;
00155 }
00156 trace::exiting("canvas::browsing::snake_vert");
00157 }
00158
00159 # endif // ! MLN_INCLUDE_ONLY
00160
00161 }
00162
00163 }
00164
00165 }
00166
00167
00168 #endif // ! MLN_CANVAS_BROWSING_SNAKE_VERT_HH