27 #ifndef MLN_CORE_CONCEPT_IMAGE_HH
28 # define MLN_CORE_CONCEPT_IMAGE_HH
34 # include <mln/core/concept/site_set.hh>
35 # include <mln/core/concept/mesh.hh>
37 # include <mln/core/trait/all.hh>
38 # include <mln/core/macros.hh>
39 # include <mln/core/site_set/box.hh>
41 # include <mln/trait/concrete.hh>
42 # include <mln/trait/images.hh>
44 # include <mln/metal/abort.hh>
45 # include <mln/metal/is_a.hh>
46 # include <mln/metal/equal.hh>
48 # include <mln/tag/init.hh>
56 template <
typename E>
struct Image;
57 template <
typename E>
struct Literal;
58 template <
typename D,
typename W>
struct w_window;
131 template <
typename I,
typename D,
typename W>
139 template <
typename V,
unsigned S,
typename I>
144 # ifndef MLN_INCLUDE_ONLY
150 template <
typename values_browsing_trait,
typename E>
151 struct image_values_interface_check
153 static void run() { }
156 template <
typename E>
157 struct image_values_interface_check<
158 mln::trait::image::value_browsing::value_wise,
169 template <
typename E,
171 int check_init(
void (E::*)(A))
176 template <
typename E,
177 typename A1,
typename A2 >
178 int check_init(
void (E::*)(A1, A2))
183 template <
typename E,
184 typename A1,
typename A2,
typename A3 >
185 int check_init(
void (E::*)(A1, A2, A3))
193 template <
typename E>
194 template <
typename J>
203 mlc_abort(E)::check();
208 template <
typename E>
214 typedef mln_domain(E) domain_t;
215 typedef mln_site(E)
site;
216 typedef mln_psite(E)
psite;
218 typedef mln_piter(E) piter;
222 bool (E::*m1)(const psite&
p) const = & E::has;
229 bool (E::*m3)() const = & E::is_valid;
232 typedef typename E::t_eligible_values_set t_eligible_values_set;
234 const t_eligible_values_set& (E::*m4)() const = & E::values_eligible;
237 typedef typename E::t_values_space t_values_space;
239 const t_values_space& (E::*m5)() const = & E::values_space;
244 typedef mln_value(E)
value;
245 typedef mln_rvalue(E) rvalue;
246 typedef mln_lvalue(E) lvalue;
248 mlc_is_not_a(value, Literal)::check();
255 rvalue (E::*m6)(const psite&
p) const = & E::operator();
258 lvalue (E::*m7)(const psite&
p) = & E::operator();
261 const domain_t& (E::*m8)() const = & E::domain;
264 typedef typename E::skeleton skeleton;
268 internal::check_init(& E::
init_);
271 internal::image_values_interface_check<mln_trait_image_value_browsing(E),
276 template <typename I, typename D, typename W>
278 from_to_(const Image<I>& from_, w_window<D,W>& to)
280 mlc_converts_to(mln_deduce(I, psite,
delta), D)::check();
281 mlc_converts_to(mln_value(I), W)::check();
282 const I& ima =
exact(from_);
284 mln_value(I) zero = literal::zero;
285 mln_piter(I)
p(ima.domain());
288 to.insert(ima(
p),
convert::to<D>(p));
291 template <typename V,
unsigned S, typename I>
293 from_to_(const V (&values)[S], Image<I>& to_)
295 mlc_bool(S != 0)::check();
296 mlc_converts_to(V, mln_value(I))::check();
297 typedef mln_site(I) P;
299 s = mlc_root(d, S)::value };
300 metal::bool_<(mlc_pow_int(s, d) == S)>::check();
303 mln_precondition(! to.is_valid());
307 mln_fwd_piter(box<P>) p(b);
314 # endif // ! MLN_INCLUDE_ONLY
318 # include <mln/core/routine/initialize.hh>
321 #endif // ! MLN_CORE_CONCEPT_IMAGE_HH