26 #ifndef MLN_CORE_IMAGE_DMORPH_P2P_IMAGE_HH
27 # define MLN_CORE_IMAGE_DMORPH_P2P_IMAGE_HH
33 # include <mln/core/internal/image_domain_morpher.hh>
34 # include <mln/core/concept/function.hh>
35 # include <mln/accu/shape/bbox.hh>
42 template <
typename I,
typename F>
struct p2p_image;
49 template <
typename I,
typename F>
50 struct data< p2p_image<I,F> >
52 data(I& ima,
const F& f);
65 template <
typename I,
typename F>
66 struct image_< p2p_image<I,F> > : default_image_morpher< I,
70 typedef trait::image::category::domain_morpher category;
72 typedef trait::image::ext_domain::none ext_domain;
73 typedef trait::image::ext_value::irrelevant ext_value;
74 typedef trait::image::ext_io::irrelevant ext_io;
76 typedef trait::image::vw_io::none vw_io;
77 typedef trait::image::vw_set::none vw_set;
78 typedef trait::image::value_alignment::not_aligned value_alignment;
79 typedef trait::image::value_storage::disrupted value_storage;
89 template <
typename I,
typename F>
90 struct p2p_image :
public internal::image_domain_morpher< I,
103 void init_(I& ima,
const F& f);
106 const mln_domain(I)& domain()
const;
109 const F& fun()
const;
112 mln_rvalue(I) operator()(const mln_psite(I)& p) const;
115 mln_morpher_lvalue(I) operator()(const mln_psite(I)& p);
121 template <typename I, typename F>
126 template <typename I, typename F>
132 # ifndef MLN_INCLUDE_ONLY
136 template <
typename I,
typename F>
142 template <
typename I,
typename F,
typename J>
146 init_(tag::image, ima, exact(model));
148 init_(tag::function, f, exact(model));
149 target.init_(ima, f);
157 template <
typename I,
typename F>
163 accu::shape::bbox<mln_site(I)> a;
164 mln_domain(I) b = ima.
domain();
168 mln_invariant(b_.nsites() == b.nsites());
176 template <typename I, typename F>
182 template <
typename I,
typename F>
189 template <
typename I,
typename F>
194 mln_precondition(! this->is_valid());
195 this->data_ =
new internal::data< p2p_image<I,F> >(ima, f);
198 template <
typename I,
typename F>
203 mln_precondition(this->is_valid());
204 return this->data_->b_;
207 template <
typename I,
typename F>
212 mln_precondition(this->is_valid());
213 return this->data_->f_;
216 template <
typename I,
typename F>
221 mln_precondition(this->has(p));
222 mln_invariant(this->data_->ima_.has(this->data_->f_.inverse(p)));
223 return this->data_->ima_(this->data_->f_.inverse(p));
226 template <
typename I,
typename F>
228 mln_morpher_lvalue(I)
231 mln_precondition(this->has(p));
232 mln_invariant(this->data_->ima_.has(this->data_->f_.inverse(p)));
233 return this->data_->ima_(this->data_->f_.inverse(p));
239 template <
typename I,
typename F>
244 mlc_is_a(mln_domain(I),
Box)::check();
246 I& ima = exact(ima_);
247 mln_precondition(ima.is_valid());
253 template <
typename I,
typename F>
255 p2p_image<const I, F>
258 mlc_is_a(mln_domain(I),
Box)::check();
260 const I& ima = exact(ima_);
261 mln_precondition(ima.is_valid());
268 # endif // ! MLN_INCLUDE_ONLY
274 #endif // ! MLN_CORE_IMAGE_DMORPH_P2P_IMAGE_HH