• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

snake_vert.hh

00001 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
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         // Fixme: check the dimension of the input
00101 //      mlc_equal(mln_trait_image_dimension(I)(),
00102 //                trait::image::dimension::two_d)::check();
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         // p
00110         f.p = f.input.bbox().pmin();
00111         def::coord& row = f.p.row();
00112         def::coord& col = f.p.col();
00113 
00114         // initialization
00115         f.init();
00116 
00117         bool down = true;
00118         for (col = min_col; col <= max_col; ++col)
00119           // FIXME: Add "if (f.input.has(p))"?
00120           {
00121             // go fwd
00122             f.fwd();
00123 
00124             if (down)
00125               // browse col down.
00126               while (row < max_row)
00127                 {
00128                   ++row;
00129                   f.down();
00130                 }
00131             else
00132               // browse col up.
00133               while (row > min_row)
00134                 {
00135                   --row;
00136                   f.up();
00137                 }
00138 
00139             // change browsing
00140             down = ! down;
00141           }
00142         trace::exiting("canvas::browsing::snake_vert");
00143       }
00144 
00145 # endif // ! MLN_INCLUDE_ONLY
00146 
00147     } // end of namespace mln::canvas::browsing
00148 
00149   } // end of namespace mln::canvas
00150 
00151 } // end of namespace mln
00152 
00153 
00154 #endif // ! MLN_CANVAS_BROWSING_SNAKE_VERT_HH

Generated on Tue Oct 4 2011 15:24:28 for Milena (Olena) by  doxygen 1.7.1