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