milena r3749: Add overload for creating 2D neighborhood with a functor

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2009-05-04 Fabien Freling <fabien.freling@lrde.epita.fr> Add overload for creating 2D neighborhood with a functor. * mln/make/double_neighb2d.hh: Add overload with a functor. * mln/world/inter_pixel/neighb2d.hh: Fix types, now passing a functor instead of a C function. --- make/double_neighb2d.hh | 20 ++++++++++++++++++++ world/inter_pixel/neighb2d.hh | 7 ++++--- 2 files changed, 24 insertions(+), 3 deletions(-) Index: trunk/milena/mln/world/inter_pixel/neighb2d.hh =================================================================== --- trunk/milena/mln/world/inter_pixel/neighb2d.hh (revision 3748) +++ trunk/milena/mln/world/inter_pixel/neighb2d.hh (revision 3749) @@ -34,6 +34,7 @@ # include <mln/core/alias/neighb2d.hh> # include <mln/make/double_neighb2d.hh> +# include <mln/world/inter_pixel/dim2/is_row_odd.hh> namespace mln { @@ -44,7 +45,7 @@ namespace inter_pixel { - typedef neighb< win::multiple<window2d, bool(*)(const point2d&)> > dbl_neighb2d; + typedef neighb< win::multiple<window2d, dim2::is_row_odd> > dbl_neighb2d; const dbl_neighb2d& e2c() { @@ -54,7 +55,7 @@ static bool e2c_v[] = { 0, 0, 0, 1, 0, 1, 0, 0, 0 }; - static dbl_neighb2d nbh = make::double_neighb2d(is_row_odd, e2c_h, e2c_v); + static dbl_neighb2d nbh = make::double_neighb2d(dim2::is_row_odd(), e2c_h, e2c_v); return nbh; } @@ -70,7 +71,7 @@ 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0 }; - static dbl_neighb2d nbh = make::double_neighb2d(is_row_odd, e2e_h, e2e_v); + static dbl_neighb2d nbh = make::double_neighb2d(dim2::is_row_odd(), e2e_h, e2e_v); return nbh; } Index: trunk/milena/mln/make/double_neighb2d.hh =================================================================== --- trunk/milena/mln/make/double_neighb2d.hh (revision 3748) +++ trunk/milena/mln/make/double_neighb2d.hh (revision 3749) @@ -52,6 +52,11 @@ bool const (&when_true) [St], bool const (&when_false)[Sf]); + template <typename F, unsigned St, unsigned Sf> + neighb< win::multiple<window2d, F> > + double_neighb2d(F test, + bool const (&when_true) [St], + bool const (&when_false)[Sf]); # ifndef MLN_INCLUDE_ONLY @@ -71,6 +76,21 @@ return tmp; } + template <typename F, unsigned St, unsigned Sf> + inline + neighb< win::multiple<window2d, F> > + double_neighb2d(F test, + bool const (&when_true) [St], + bool const (&when_false)[Sf]) + { + typedef win::multiple<window2d, F> W; + W wm(test); + wm.set_window(false, convert::to<window2d>(when_false)); // 0 + wm.set_window(true, convert::to<window2d>(when_true) ); // 1 + neighb<W> tmp(wm); + return tmp; + } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln::make
participants (1)
-
Fabien Freling