26 #ifndef MLN_CORE_IMAGE_EDGE_IMAGE_HH
27 # define MLN_CORE_IMAGE_EDGE_IMAGE_HH
33 # include <mln/core/concept/graph.hh>
34 # include <mln/core/site_set/p_edges.hh>
35 # include <mln/core/image/graph_elt_window.hh>
36 # include <mln/core/image/graph_elt_neighborhood.hh>
37 # include <mln/pw/internal/image_base.hh>
38 # include <mln/fun/i2v/array.hh>
45 template <
typename P,
typename V,
typename G>
class edge_image;
46 namespace util {
class graph; }
54 template <
typename P,
typename V,
typename G>
56 : pw_image_<fun::i2v::array<V>,
57 p_edges<util::graph, fun::i2v::array<P> >,
70 template <
typename P,
typename V,
typename G>
73 typedef typename edge_image<P,V,G>::site_function_t site_function_t;
75 data(
const fun::i2v::array<V>& edge_values,
76 const p_edges<G,site_function_t>& pe);
78 fun::i2v::array<V> f_;
79 p_edges<G,site_function_t> domain_;
89 template <
typename V,
typename G,
typename P>
91 operator | (
const fun::i2v::array<V>& edge_values,
92 const p_edges<G,fun::i2v::array<P> >& pe);
100 template <
typename P,
typename G>
101 struct efsite_selector
103 typedef fun::i2v::array<P> site_function_t;
108 template <
typename G>
109 struct efsite_selector<void,G>
111 typedef util::internal::id2element< G,util::edge<G> > site_function_t;
122 template <
typename P,
typename V,
typename G = util::graph>
124 :
public pw::internal::image_base<fun::i2v::array<V>,
125 p_edges<G, typename internal::efsite_selector<P,G>::site_function_t >,
128 typedef pw::internal::image_base<fun::i2v::array<V>,
133 typedef typename super_::psite psite;
134 typedef typename super_::rvalue rvalue;
135 typedef typename super_::lvalue lvalue;
146 typedef typename internal::efsite_selector<P,G>::site_function_t
173 template <typename FP, typename FV>
178 template <typename FV>
185 rvalue operator()(
unsigned e_id) const;
186 lvalue operator()(
unsigned e_id);
190 rvalue operator()(const psite& p) const;
191 lvalue operator()(const psite& p);
196 template <typename P, typename V, typename G, typename J>
197 void init_(tag::image_t,
edge_image<P,V,G>& target, const
Image<J>& model);
200 # ifndef MLN_INCLUDE_ONLY
202 template <
typename P,
typename V,
typename G,
typename J>
205 fun::i2v::array<V> f;
206 init_(tag::function, f, exact(model));
208 init_(tag::domain, s, exact(model));
214 template <
typename V,
typename G,
typename P>
217 operator | (
const fun::i2v::array<V>& edge_values,
218 const p_edges<G,fun::i2v::array<P> >& pe)
231 template <
typename P,
typename V,
typename G>
234 const p_edges<G,site_function_t>& ps)
246 template <
typename P,
typename V,
typename G>
252 template <
typename P,
typename V,
typename G>
255 : super_(fun::i2v::array<V>(pe.nsites()), pe)
259 template <
typename P,
typename V,
typename G>
262 const Function_v2v< site_function_t >& edge_sites,
263 const Function_v2v< fun::i2v::array<V> >& edge_values)
264 : super_(exact(edge_values),
265 p_edges<G,site_function_t>(g, exact(edge_sites)))
269 template <
typename P,
typename V,
typename G>
272 const Function_v2v< fun::i2v::array<V> >& edge_values)
273 : super_(exact(edge_values), pe)
277 template <
typename P,
typename V,
typename G>
278 template <
typename FP,
typename FV>
281 const Function_v2v<FP>& edge_sites,
282 const Function_v2v<FV>& edge_values)
283 : super_(
convert::
to<fun::i2v::array<V> >(exact(edge_values)),
284 p_edges<G,site_function_t>(g, exact(edge_sites)))
286 mlc_equal(mln_result(FP),P)::check();
287 mlc_equal(mln_result(FV),V)::check();
290 template <
typename P,
typename V,
typename G>
291 template <
typename FV>
294 const Function_v2v<FV>& edge_values)
295 : super_(
convert::
to<fun::i2v::array<V> >(exact(edge_values)), pe)
297 mlc_equal(mln_result(FV),V)::check();
300 template <
typename P,
typename V,
typename G>
301 typename edge_image<P,V,G>::rvalue
304 return this->data_->f_(e_id);
307 template <
typename P,
typename V,
typename G>
308 typename edge_image<P,V,G>::lvalue
311 return this->data_->f_(e_id);
314 template <
typename P,
typename V,
typename G>
315 typename edge_image<P,V,G>::rvalue
318 return this->super_::operator()(p);
321 template <
typename P,
typename V,
typename G>
322 typename edge_image<P,V,G>::lvalue
325 return this->super_::operator()(p);
328 # endif // ! MLN_INCLUDE_ONLY
333 #endif // ! MLN_CORE_IMAGE_EDGE_IMAGE_HH