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 #include <mln/core/image/image2d.hh>
00027 #include <mln/canvas/browsing/snake_fwd.hh>
00028 #include <mln/fun/p2v/iota.hh>
00029 #include <mln/debug/println.hh>
00030 
00031 
00032 template <typename I, typename F>
00033 struct assign_browsing_functor
00034 {
00035   typedef mln_site(I) S;
00036   enum { dim = S::dim };
00037 
00038   I input;
00039   F f;
00040 
00041   assign_browsing_functor(I& input, F f = F())
00042     : input(input),
00043       f(f)
00044   {}
00045 
00046   mln_psite(I) p;
00047 
00048   void init()  {}
00049   void final() {}
00050   void next()
00051   {
00052     input(p) = f(p);
00053     mln_assertion(input(p) - 1 == p[0] * input.domain().ncols()
00054                   + ( (p[0] % 2) ? input.domain().ncols() - 1 - p[1] : p[1]));
00055   }
00056   void fwd()  { next(); }
00057   void bkd()  { next(); }
00058   void down() { next(); }
00059 };
00060 
00061 namespace mln
00062 {
00063 
00064   template <typename I, typename F, typename B>
00065   void my_test(Image<I>& ima_,
00066                const Function_v2v<F>& f_,
00067                const Browsing<B>& browse_)
00068   {
00069     I& ima = exact(ima_);
00070     const F& f = exact(f_);
00071     const B& browse = exact(browse_);
00072 
00073     assign_browsing_functor<I, F> fun(ima, f);
00074     browse(fun);
00075   }
00076 
00077 }
00078 
00079 
00080 int main()
00081 {
00082   using namespace mln;
00083   image2d<unsigned> ima2(3, 3);
00084 
00085   my_test(ima2, fun::p2v::iota(), canvas::browsing::snake_fwd);
00086 }