26 #ifndef MLN_HISTO_POINT_FROM_VALUE_HH
27 # define MLN_HISTO_POINT_FROM_VALUE_HH
33 # include <mln/core/grids.hh>
34 # include <mln/core/point.hh>
35 # include <mln/fun/v2i/index_of_value.hh>
36 # include <mln/fun/v2v/component.hh>
37 # include <mln/trait/value/comp.hh>
40 # define mln_histo_point_type_from(T) typename mln::histo::point_type_from<T>::ret
51 struct point_type_from
54 enum { d = mln_dim(T) };
55 typedef mln_regular_grid_from_dim(d) G;
58 typedef mln::point<G, def::coord> ret;
63 struct point_from_value : Function_v2v< point_from_value<T> >
65 typedef mln_histo_point_type_from(T) result;
66 result operator()(const T& v) const;
70 mln_histo_point_type_from(T)
71 meta_point_from_value(const T& v);
74 # ifndef MLN_INCLUDE_ONLY
80 struct point_from_value;
83 struct point_from_value< 1 >
85 template <
typename T,
typename P>
86 static void run(
const T& v, P& p)
88 p[0] = fun::v2i::meta_index_of_value(v);
93 struct point_from_value< 2 >
95 template <
typename T,
typename P>
96 static void run(
const T& v, P& p)
98 p[0] = fun::v2i::meta_index_of_value( fun::v2v::component<T,0>()(v) );
99 p[1] = fun::v2i::meta_index_of_value( fun::v2v::component<T,1>()(v) );
104 struct point_from_value< 3 >
106 template <
typename T,
typename P>
107 static void run(
const T& v, P& p)
109 p[0] = fun::v2i::meta_index_of_value( fun::v2v::component<T,0>()(v) );
110 p[1] = fun::v2i::meta_index_of_value( fun::v2v::component<T,1>()(v) );
111 p[2] = fun::v2i::meta_index_of_value( fun::v2v::component<T,2>()(v) );
118 template <
typename T>
120 typename point_from_value<T>::result
121 point_from_value<T>::operator()(
const T& v)
const
123 mln_histo_point_type_from(T) p;
124 internal::point_from_value<mln_dim(T)>::run(v, p);
128 template <typename T>
129 mln_histo_point_type_from(T)
130 meta_point_from_value(const T& v)
132 point_from_value<T> f;
136 # endif // ! MLN_INCLUDE_ONLY
143 #endif // ! MLN_HISTO_POINT_FROM_VALUE_HH