cleanup-2008 2559: Fix a bug in the fill_with_value dispatch.

https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena Index: ChangeLog from Nicolas Ballas <ballas@lrde.epita.fr> Fix a bug in the fill_with_value dispatch. * tests/level/transform.cc: Add a test. * mln/level/transform.spe.hh: Inline the dispatch functions. * mln/level/fill_with_value.spe.hh, * mln/level/fill_with_value.hh: Fix... mln/level/fill_with_value.hh | 8 ++++---- mln/level/fill_with_value.spe.hh | 22 +++++++++++++++------- mln/level/transform.spe.hh | 10 ++++++++++ tests/level/transform.cc | 12 ++++++++++++ 4 files changed, 41 insertions(+), 11 deletions(-) Index: tests/level/transform.cc --- tests/level/transform.cc (revision 2559) +++ tests/level/transform.cc (working copy) @@ -97,6 +97,18 @@ } { + image2d<unsigned short> ima(size, size); + + (std::cout << "fill... ").flush(); + level::fill_with_value(ima, 51); + std::cout << "done" << std::endl; + + (std::cout << "transform... ").flush(); + level::transform(ima, mysqrt()); + std::cout << "done" << std::endl; + } + + { typedef image2d<unsigned short> I; typedef image_if<I, fun::p2b::chess_t> II; Index: mln/level/transform.spe.hh --- mln/level/transform.spe.hh (revision 2559) +++ mln/level/transform.spe.hh (working copy) @@ -220,6 +220,7 @@ /// Deal with image not updated template <typename I, typename F, typename O> + inline void transform_dispatch(mln::trait::undef, mln::trait::image::quant::any, const Image<I>& input, @@ -230,6 +231,7 @@ } template <typename I, typename F, typename O> + inline void transform_dispatch(mln::trait::image::vw_set::any, mln::trait::image::quant::any, const Image<I>& input, @@ -240,6 +242,7 @@ } template <typename I, typename F, typename O> + inline void transform_dispatch(mln::trait::image::vw_set::uni, mln::trait::image::quant::any, const Image<I>& input, @@ -251,6 +254,7 @@ template <typename I, typename F, typename O> + inline void transform_dispatch(mln::trait::image::vw_set::none, mln::trait::image::quant::low, const Image<I>& input, @@ -261,6 +265,7 @@ } template <typename I, typename F, typename O> + inline void transform_dispatch_oneblock(mln::trait::image::quant::any, const Image<I>& input, const Function_v2v<F>& f, @@ -270,6 +275,7 @@ } template <typename I, typename F, typename O> + inline void transform_dispatch_oneblock(mln::trait::image::quant::low, const Image<I>& input, const Function_v2v<F>& f, @@ -280,6 +286,7 @@ template <typename I, typename F, typename O> + inline void transform_dispatch(mln::trait::image::value_storage::any, mln::trait::image::value_storage::any, const Image<I>& input, @@ -292,6 +299,7 @@ } template <typename I, typename F, typename O> + inline void transform_dispatch(mln::trait::image::value_storage::singleton, mln::trait::image::value_storage::any, const Image<I>& input, @@ -302,6 +310,7 @@ } template <typename I, typename F, typename O> + inline void transform_dispatch(mln::trait::image::value_storage::one_block, mln::trait::image::value_storage::one_block, const Image<I>& input_, @@ -352,6 +361,7 @@ template <typename I, typename F, typename O> + inline void transform_dispatch(const Image<I>& input, const Function_v2v<F>& f, Image<O>& output) Index: mln/level/fill_with_value.spe.hh --- mln/level/fill_with_value.spe.hh (revision 2559) +++ mln/level/fill_with_value.spe.hh (working copy) @@ -80,6 +80,12 @@ I& ima = exact(ima_); internal::fill_with_value_tests(ima, val); + mln_precondition(((mlc_is(mln_trait_image_pw_io(I), + trait::image::pw_io::read_write)::value || + mlc_is(mln_trait_image_vw_io(I), + trait::image::vw_io::read_write)::value) && + mlc_is(mln_trait_image_value_access(I), + trait::image::value_access::direct)::value)); level::memset_(ima, ima.point_at_index(0), val, ima.nelements()); @@ -93,6 +99,7 @@ trace::entering("level::impl::fill_with_value_cell_wise"); I& ima = exact(ima_); + internal::fill_with_value_tests(ima, val); mln_viter(I) v(ima.cells()); @@ -109,7 +116,14 @@ trace::entering("level::impl::fill_with_value_singleton"); I& ima = exact(ima_); + internal::fill_with_value_tests(ima, val); + mln_precondition(((mlc_is(mln_trait_image_pw_io(I), + trait::image::pw_io::read_write)::value || + mlc_is(mln_trait_image_vw_io(I), + trait::image::vw_io::read_write)::value) && + mlc_is(mln_trait_image_value_access(I), + trait::image::value_access::direct)::value)); ima.val() = val; @@ -147,12 +161,6 @@ trait::image::vw_io::any, Image<I>& ima, const V& val) { - if ((mlc_is(mln_trait_image_pw_io(I), - trait::image::pw_io::read_write)::value || - mlc_is(mln_trait_image_vw_io(I), - trait::image::vw_io::read_write)::value) && - mlc_is(mln_trait_image_value_access(I), - trait::image::value_access::direct)::value) impl::fill_with_value_singleton(ima, val); } @@ -161,7 +169,7 @@ trait::image::vw_io::any, Image<I>& ima, const V& val) { - /// FIXME + impl::generic::fill_with_value(ima, val); } Index: mln/level/fill_with_value.hh --- mln/level/fill_with_value.hh (revision 2559) +++ mln/level/fill_with_value.hh (working copy) @@ -84,10 +84,6 @@ // is not defined. (void) ima; - // FIXME - //mlc_is(mln_trait_image_value_io(I), - //mln::trait::image::value_io::read_write)::check(); - mlc_converts_to(mln_exact(V), mln_value(I))::check(); mln_precondition(exact(ima).has_data()); } @@ -107,7 +103,11 @@ trace::entering("level::impl::generic::fill_with_value"); I& ima = exact(ima_); + internal::fill_with_value_tests(ima, val); + // FIXME: activate this test + //mlc_is(mln_trait_image_pw_io(I), + //trait::image::pw_io::read_write)::check(); mln_value(I) v = exact(val); mln_piter(I) p(ima.domain());
participants (1)
-
Nicolas Ballas