26 #ifndef MLN_TRANSFORM_INTERNAL_CLOSEST_POINT_FUNCTOR_HH
27 # define MLN_TRANSFORM_INTERNAL_CLOSEST_POINT_FUNCTOR_HH
33 # include <mln/core/site_set/p_array.hh>
34 # include <mln/core/macros.hh>
35 # include <mln/data/fill.hh>
36 # include <mln/trait/ch_value.hh>
53 struct closest_point_functor_with_indexes
55 typedef mln_value(I) V;
56 typedef mln_psite(I) P;
58 closest_point_functor_with_indexes(const p_array<P>& pset);
60 mln_ch_value(I,
unsigned) cp_ima;
61 const p_array<P>& pset_;
65 bool inqueue_p_wrt_input_p(const V& input_p);
66 void init_p(const P&);
67 bool inqueue_p_wrt_input_n(const V& input_n);
68 void process(const P&, const P&);
71 void init_(const I& input);
72 bool inqueue_p_wrt_input_p_(const V& input_p);
73 void init_p_(
unsigned);
74 bool inqueue_p_wrt_input_n_(const V& input_n);
75 void process_(
unsigned p,
unsigned n);
83 struct closest_point_functor_with_sites
85 typedef mln_value(I) V;
86 typedef mln_psite(I) P;
88 closest_point_functor_with_sites();
90 mln_ch_value(I,P) cp_ima;
94 bool inqueue_p_wrt_input_p(const V& input_p);
95 void init_p(const P&);
96 bool inqueue_p_wrt_input_n(const V& input_n);
97 void process(const P&, const P&);
100 void init_(const I& input);
101 bool inqueue_p_wrt_input_p_(const V& input_p);
102 void init_p_(
unsigned p);
103 bool inqueue_p_wrt_input_n_(const V& input_n);
104 void process_(
unsigned p,
unsigned n);
108 # ifndef MLN_INCLUDE_ONLY
110 template <
typename I>
112 closest_point_functor_with_indexes<I>::closest_point_functor_with_indexes(
113 const p_array<mln_psite(I)>& pset)
118 template <
typename I>
121 closest_point_functor_with_indexes<I>::init(
const I& input)
126 mln_piter(p_array<mln_psite(I)>) p(pset_);
128 cp_ima(p) = p.index();
131 template <typename I>
134 closest_point_functor_with_indexes<I>::inqueue_p_wrt_input_p(const V& input_p)
136 return input_p ==
true;
139 template <
typename I>
142 closest_point_functor_with_indexes<I>::init_p(
const P&)
146 template <
typename I>
149 closest_point_functor_with_indexes<I>::inqueue_p_wrt_input_n(
const V& input_n)
151 return input_n ==
false;
154 template <
typename I>
156 void closest_point_functor_with_indexes<I>::process(
const P& p,
const P& n)
158 cp_ima(n) = cp_ima(p);
163 template <
typename I>
166 closest_point_functor_with_indexes<I>::init_(
const I& input)
171 template <
typename I>
174 closest_point_functor_with_indexes<I>::inqueue_p_wrt_input_p_(
const V& input_p)
176 return input_p ==
true;
179 template <
typename I>
181 void closest_point_functor_with_indexes<I>::init_p_(
unsigned)
185 template <
typename I>
188 closest_point_functor_with_indexes<I>::inqueue_p_wrt_input_n_(
const V& input_n)
190 return input_n ==
false;
193 template <
typename I>
196 closest_point_functor_with_indexes<I>::process_(
unsigned p,
unsigned n)
198 cp_ima.element(n) = cp_ima.element(p);
207 template <
typename I>
209 closest_point_functor_with_sites<I>::closest_point_functor_with_sites()
213 template <
typename I>
216 closest_point_functor_with_sites<I>::init(
const I& input)
222 template <
typename I>
225 closest_point_functor_with_sites<I>::inqueue_p_wrt_input_p(
const V& input_p)
227 return input_p ==
true;
230 template <
typename I>
233 closest_point_functor_with_sites<I>::init_p(
const P& p)
238 template <
typename I>
241 closest_point_functor_with_sites<I>::inqueue_p_wrt_input_n(
const V& input_n)
243 return input_n ==
false;
246 template <
typename I>
249 closest_point_functor_with_sites<I>::process(
const P& p,
const P& n)
251 cp_ima(n) = cp_ima(p);
256 template <
typename I>
259 closest_point_functor_with_sites<I>::init_(
const I& input)
264 template <
typename I>
267 closest_point_functor_with_sites<I>::inqueue_p_wrt_input_p_(
const V& input_p)
269 return input_p ==
true;
272 template <
typename I>
274 void closest_point_functor_with_sites<I>::init_p_(
unsigned p)
276 cp_ima.element(p) = cp_ima.point_at_index(p);
279 template <
typename I>
282 closest_point_functor_with_sites<I>::inqueue_p_wrt_input_n_(
const V& input_n)
284 return input_n ==
false;
287 template <
typename I>
290 closest_point_functor_with_sites<I>::process_(
unsigned p,
unsigned n)
292 cp_ima.element(n) = cp_ima.element(p);
295 # endif // ! MLN_INCLUDE_ONLY
304 #endif // ! MLN_TRANSFORM_INTERNAL_CLOSEST_POINT_FUNCTOR_HH