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

backdiagonal2d.hh

00001 // Copyright (C) 2007, 2008, 2009, 2010 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_BACKDIAGONAL2D_HH
00028 # define MLN_CANVAS_BROWSING_BACKDIAGONAL2D_HH
00029 
00033 
00034 # include <mln/core/concept/browsing.hh>
00035 # include <mln/core/concept/image.hh>
00036 
00037 
00038 namespace mln
00039 {
00040 
00041   namespace canvas
00042   {
00043 
00044     namespace browsing
00045     {
00046 
00048 
00083       struct backdiagonal2d_t : public Browsing< backdiagonal2d_t >
00084       {
00085         template <typename F>
00086         void operator()(F& f) const;
00087       };
00088 
00089       extern const backdiagonal2d_t backdiagonal2d;
00090 
00091 
00092 
00093 # ifndef MLN_INCLUDE_ONLY
00094 
00095 
00096 #  ifndef MLN_WO_GLOBAL_VARS
00097 
00098       const backdiagonal2d_t backdiagonal2d;
00099 
00100 #  endif // ! MLN_WO_GLOBAL_VARS
00101 
00102 
00103       template <typename F>
00104       inline
00105       void
00106       backdiagonal2d_t::operator()(F& f) const
00107       {
00108         trace::entering("canvas::browsing::backdiagonal2d");
00109 
00110         typedef typename F::I I;
00111         typedef mln_deduce(I, psite, delta) dpsite;
00112         typedef mln_psite(I) psite;
00113 
00114         // Directions
00115         dpsite dp_first(-1, 0);
00116         dpsite dp_second(0, 1);
00117         dpsite dp_diag(1, 1);
00118 
00119         mln_deduce(I, psite, delta) diag;
00120 
00121         psite
00122           pmin = f.input.domain().pmin(),
00123           pmax = f.input.domain().pmax();
00124 
00125         // Start at the bottom left corner.
00126         f.p[0] = pmax[0];
00127         f.p[1] = pmin[1];
00128 
00129         f.init();
00130 
00131         while (f.input.domain().has(f.p))
00132         {
00133           psite start_diag = f.p;
00134           // Browse one diag.
00135           f.init_diag();
00136           while (f.input.domain().has(f.p))
00137           {
00138             f.next();
00139             f.p = f.p + dp_diag;
00140           }
00141 
00142           // Goto next diag start.
00143           f.p = start_diag + dp_first;
00144         }
00145         f.p = f.p - dp_first;
00146 
00147         f.p = f.p + dp_second;
00148         while (f.input.domain().has(f.p))
00149         {
00150           psite start_diag = f.p;
00151 
00152           // Browse one diag.
00153           f.init_diag();
00154           while (f.input.domain().has(f.p))
00155           {
00156             f.next();
00157             f.p = f.p + dp_diag;
00158           }
00159           f.p = f.p - dp_diag;
00160 
00161           // Goto next diag start.
00162           f.p = start_diag + dp_second;
00163         }
00164 
00165         f.final();
00166         trace::exiting("canvas::browsing::backdiagonal2d");
00167       }
00168 
00169 # endif // ! MLN_INCLUDE_ONLY
00170 
00171     } // end of namespace mln::canvas::browsing
00172 
00173   } // end of namespace mln::canvas
00174 
00175 } // end of namespace mln
00176 
00177 #endif // ! MLN_CANVAS_BROWSING_BACKDIAGONAL2D_HH

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