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