27 #ifndef MLN_DATA_FILL_HH
28 # define MLN_DATA_FILL_HH
36 # include <mln/core/concept/function.hh>
37 # include <mln/pw/image.hh>
38 # include <mln/convert/to_fun.hh>
40 # include <mln/data/fill_with_image.hh>
41 # include <mln/data/fill_with_value.hh>
60 template <
typename I,
typename D>
61 void fill(Image<I>& ima,
const D&
data);
65 # ifndef MLN_INCLUDE_ONLY
72 template <
typename I,
typename D>
74 void fill_tests(Image<I>& ima,
const D&)
80 mlc_is(mln_trait_image_value_io(I),
81 trait::image::value_io::read_write)::check();
82 mln_precondition(
exact(ima).is_valid());
89 void fill_dispatch_overload(I& ima,
const mln_value(I)& v)
94 template <
typename I,
typename J>
95 void fill_dispatch_overload(I& ima,
const Image<J>&
data)
100 template <
typename I,
typename F>
101 void fill_dispatch_overload(I& ima,
const Function<F>& f)
103 mlc_converts_to(mln_result(F), mln_value(I))::check();
105 exact(f) | ima.domain());
108 template <
typename I,
typename R,
typename A>
109 void fill_dispatch_overload(I& ima, R (*f)(A))
111 mlc_converts_to(R, mln_value(I))::check();
116 template <
typename I,
typename V,
unsigned N>
117 void fill_dispatch_overload(I& ima, V (&arr)[N])
119 mlc_converts_to(V, mln_value(I))::check();
120 mln_precondition(N == ima.nsites());
121 mln_fwd_piter(I)
p(ima.domain());
129 template <typename I, typename D>
130 void fill_dispatch(Image<I>& ima, const D&
data)
132 fill_dispatch_overload(
exact(ima),
exact(data));
140 template <
typename I,
typename D>
142 void fill(Image<I>& ima,
const D& data)
144 mln_trace(
"data::fill");
146 internal::fill_tests(ima, data);
147 internal::fill_dispatch(ima, data);
152 # endif // ! MLN_INCLUDE_ONLY
159 #endif // ! MLN_DATA_FILL_HH