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_DIR_STRUCT_ELT_INCR_UPDATE_HH
00027 # define MLN_CANVAS_BROWSING_DIR_STRUCT_ELT_INCR_UPDATE_HH
00028 
00032 
00033 # include <mln/core/concept/browsing.hh>
00034 # include <mln/core/concept/image.hh>
00035 
00036 
00037 namespace mln
00038 {
00039 
00040   namespace canvas
00041   {
00042 
00043     namespace browsing
00044     {
00045 
00047 
00086       struct dir_struct_elt_incr_update_t : public Browsing< dir_struct_elt_incr_update_t >
00087       {
00088         template <typename F>
00089         void operator()(F& f) const;
00090       };
00091 
00092       extern const dir_struct_elt_incr_update_t dir_struct_elt_incr_update;
00093 
00094 # ifndef MLN_INCLUDE_ONLY
00095 
00096       const dir_struct_elt_incr_update_t dir_struct_elt_incr_update;
00097 
00098       template <typename F>
00099       inline
00100       void
00101       dir_struct_elt_incr_update_t::operator()(F& f) const
00102       {
00103         trace::entering("canvas::browsing::dir_struct_elt_incr_update");
00104         mln_precondition(f.dir < f.dim);
00105         typedef typename F::I I;
00106 
00107         const mln_psite(I)
00108           pmin = f.input.domain().pmin(),
00109           pmax = f.input.domain().pmax();
00110 
00111         typedef mln_deduce(I, site, coord) C;
00112         const C
00113           pmin_dir = pmin[f.dir],
00114           pmax_dir = pmax[f.dir],
00115           pmin_dir_plus_half_length  = static_cast<C>(pmin_dir + f.length / 2),
00116           pmax_dir_minus_half_length = static_cast<C>(pmax_dir - f.length / 2);
00117 
00118         mln_psite(I) pt, pu;
00119 
00120         def::coord&
00121           ct = pt[f.dir],
00122           cu = pu[f.dir],
00123           p_dir = f.p[f.dir];
00124 
00125         f.p = pmin;
00126 
00127         f.init();
00128 
00129         do
00130         {
00131           pt = f.p;
00132           pu = f.p;
00133 
00134           f.init_line();
00135 
00136           
00137           std::cout << "init" << std::endl;
00138           for (ct = pmin_dir; ct < pmin_dir_plus_half_length; ++ ct)
00139             if (f.input.has(pt))
00140               {
00141                 std::cout << '+' << pt << ' ';
00142                 f.add_point(pt);
00143               }
00144 
00145           
00146           std::cout << "left" << std::endl;
00147           for (p_dir = pmin_dir; p_dir <= pmin_dir_plus_half_length; ++p_dir, ++ct)
00148           {
00149             if (f.input.has(pt))
00150               {
00151                 std::cout << '+' << pt << ' ';
00152                 f.add_point(pt);
00153               }
00154             f.next();
00155           }
00156 
00157           
00158           std::cout << "middle" << std::endl;
00159           cu = pmin_dir;
00160           for (; p_dir <= pmax_dir_minus_half_length; ++cu, ++p_dir, ++ct)
00161           {
00162             if (f.input.has(pt))
00163               {
00164                 std::cout << '+' << pt << ' ';
00165                 f.add_point(pt);
00166               }
00167             if (f.input.has(pu))
00168               {
00169                 std::cout << '-' << pu << ' ';
00170                 f.remove_point(pu);
00171               }
00172             f.next();
00173           }
00174 
00175           
00176           std::cout << "right" << std::endl;
00177           for (; p_dir <= pmax_dir; ++cu, ++p_dir)
00178           {
00179             if (f.input.has(pu))
00180               {
00181                 std::cout << '-' << pu << ' ';
00182                 f.remove_point(pu);
00183               }
00184             f.next();
00185           }
00186 
00187           p_dir = pmin_dir;
00188 
00189           for (int c = F::dim - 1; c >= 0; --c)
00190           {
00191             if (c == int(f.dir))
00192               continue;
00193             if (f.p[c] != pmax[c])
00194             {
00195               ++f.p[c];
00196               break;
00197             }
00198             f.p[c] = pmin[c];
00199           }
00200         } while (f.p != pmin);
00201 
00202         f.final();
00203         trace::exiting("canvas::browsing::dir_struct_elt_incr_update");
00204       }
00205 
00206 # endif // ! MLN_INCLUDE_ONLY
00207 
00208     } 
00209 
00210   } 
00211 
00212 } 
00213 
00214 #endif // ! MLN_CANVAS_BROWSING_DIR_STRUCT_ELT_INCR_UPDATE_HH