* mln/accu/count_labels.hh,
* mln/convert/from_to.hxx,
* mln/convert/to.hh,
* mln/core/alias/point1d.hh,
* mln/core/alias/point2d.hh,
* mln/core/alias/point3d.hh,
* mln/core/dpoint.hh,
* mln/core/internal/neighborhood_base.hh,
* mln/core/point.hh,
* mln/core/site_set/p_centered.hh,
* mln/core/site_set/p_vaccess.hh,
* mln/fun/v2v/hsl_to_rgb.hh,
* mln/fun/v2v/rgb_to_hsl.hh,
* mln/io/magick/save.hh,
* mln/io/plot/save.hh,
* mln/labeling/blobs_and_compute.hh,
* mln/labeling/value_and_compute.hh,
* mln/make/w_window2d.hh,
* mln/win/multiple.hh,
* mln/win/multiple_size.hh,
* tests/accu/site_set/rectangularity.cc,
* tests/core/other/graph_elt_neighborhood.cc,
* tests/core/other/graph_elt_window.cc,
* tests/core/other/point_set_compatibility.cc,
* tests/draw/graph.cc: Update forward declarations and includes.
* mln/algebra/vec.hh,
* mln/convert/from_to.hh,
* mln/convert/impl/from_double_to_value.hh,
* mln/convert/impl/from_float_to_value.hh,
* mln/convert/impl/from_image_to_site_set.hh,
* mln/convert/impl/from_int_to_value.hh,
* mln/convert/impl/from_unsigned_to_value.hh,
* mln/convert/impl/from_value_to_value.hh,
* mln/core/alias/neighb2d.hh,
* mln/core/alias/neighb3d.hh,
* mln/core/alias/window1d.hh,
* mln/core/alias/window2d.hh,
* mln/core/alias/window3d.hh,
* mln/core/concept/accumulator.hh,
* mln/core/concept/gdpoint.hh,
* mln/core/concept/gpoint.hh,
* mln/core/concept/image.hh,
* mln/core/concept/proxy.hh,
* mln/core/concept/site_set.hh,
* mln/core/concept/window.hh,
* mln/core/image/graph_window_if_piter.hh,
* mln/core/image/image1d.hh,
* mln/core/mixed_neighb.hh,
* mln/core/neighb.hh,
* mln/core/site_set/operators.hh,
* mln/core/w_window.hh,
* mln/fun/i2v/array.hh,
* mln/util/object_id.hh,
* mln/value/hsl.hh,
* mln/value/int_u.hh,
* mln/value/label.hh,
* mln/value/qt/rgb32.hh,
* mln/value/rgb.hh,
* mln/histo/array.hh,
* mln/util/array.hh: Move from_to_ overloads in the same namespace
as their first argument.
Conflicts:
milena/ChangeLog
milena/mln/core/concept/accumulator.hh
milena/mln/core/concept/gdpoint.hh
milena/mln/core/concept/gpoint.hh
milena/mln/core/concept/image.hh
milena/mln/core/concept/proxy.hh
milena/mln/core/concept/site_set.hh
milena/mln/core/concept/window.hh
milena/mln/io/magick/save.hh
---
milena/ChangeLog | 67 +++
milena/mln/accu/count_labels.hh | 4 +-
milena/mln/algebra/vec.hh | 165 +++++++-
milena/mln/convert/from_to.hh | 133 ++++---
milena/mln/convert/from_to.hxx | 441 +-------------------
milena/mln/convert/impl/from_double_to_value.hh | 159 ++++----
milena/mln/convert/impl/from_float_to_value.hh | 179 ++++----
milena/mln/convert/impl/from_image_to_site_set.hh | 8 +-
milena/mln/convert/impl/from_int_to_value.hh | 101 ++---
milena/mln/convert/impl/from_unsigned_to_value.hh | 140 +++----
milena/mln/convert/impl/from_value_to_value.hh | 7 +-
milena/mln/convert/to.hh | 1 -
milena/mln/core/alias/neighb2d.hh | 75 ++--
milena/mln/core/alias/neighb3d.hh | 51 +--
milena/mln/core/alias/point1d.hh | 5 +-
milena/mln/core/alias/point2d.hh | 5 +-
milena/mln/core/alias/point3d.hh | 5 +-
milena/mln/core/alias/window1d.hh | 51 +--
milena/mln/core/alias/window2d.hh | 100 ++---
milena/mln/core/alias/window3d.hh | 56 +--
milena/mln/core/concept/accumulator.hh | 69 +--
milena/mln/core/concept/gdpoint.hh | 59 +--
milena/mln/core/concept/gpoint.hh | 123 ++----
milena/mln/core/concept/image.hh | 89 ++--
milena/mln/core/concept/proxy.hh | 62 +--
milena/mln/core/concept/site_set.hh | 112 +++---
milena/mln/core/concept/window.hh | 108 ++---
milena/mln/core/dpoint.hh | 1 -
milena/mln/core/image/graph_window_if_piter.hh | 4 +-
milena/mln/core/image/image1d.hh | 65 +---
milena/mln/core/internal/neighborhood_base.hh | 9 +-
milena/mln/core/mixed_neighb.hh | 72 ++--
milena/mln/core/neighb.hh | 76 ++---
milena/mln/core/point.hh | 172 ++-------
milena/mln/core/site_set/operators.hh | 13 +-
milena/mln/core/site_set/p_centered.hh | 5 +-
milena/mln/core/site_set/p_vaccess.hh | 4 +-
milena/mln/core/w_window.hh | 191 +++------
milena/mln/fun/i2v/array.hh | 154 +++----
milena/mln/fun/v2v/hsl_to_rgb.hh | 10 +-
milena/mln/fun/v2v/rgb_to_hsl.hh | 4 +-
milena/mln/histo/array.hh | 34 ++-
milena/mln/io/magick/save.hh | 8 +-
milena/mln/io/plot/save.hh | 5 +-
milena/mln/labeling/blobs_and_compute.hh | 5 +-
milena/mln/labeling/value_and_compute.hh | 5 +-
milena/mln/make/w_window2d.hh | 5 +-
milena/mln/util/array.hh | 138 ++++---
milena/mln/util/object_id.hh | 46 +--
milena/mln/value/hsl.hh | 104 +++---
milena/mln/value/int_u.hh | 168 ++++----
milena/mln/value/label.hh | 152 +++----
milena/mln/value/qt/rgb32.hh | 78 +---
milena/mln/value/rgb.hh | 196 ++++------
milena/mln/win/multiple.hh | 5 +-
milena/mln/win/multiple_size.hh | 3 +-
milena/tests/accu/site_set/rectangularity.cc | 4 +-
milena/tests/core/other/graph_elt_neighborhood.cc | 3 +-
milena/tests/core/other/graph_elt_window.cc | 5 +-
milena/tests/core/other/point_set_compatibility.cc | 4 +-
milena/tests/draw/graph.cc | 4 +-
61 files changed, 1632 insertions(+), 2495 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index b977679..987294b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,70 @@
+2012-05-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Rely on Argument-Dependent Lookup (ADL) in from_to_ overloads.
+
+ * mln/accu/count_labels.hh,
+ * mln/convert/from_to.hxx,
+ * mln/convert/to.hh,
+ * mln/core/alias/point1d.hh,
+ * mln/core/alias/point2d.hh,
+ * mln/core/alias/point3d.hh,
+ * mln/core/dpoint.hh,
+ * mln/core/internal/neighborhood_base.hh,
+ * mln/core/point.hh,
+ * mln/core/site_set/p_centered.hh,
+ * mln/core/site_set/p_vaccess.hh,
+ * mln/fun/v2v/hsl_to_rgb.hh,
+ * mln/fun/v2v/rgb_to_hsl.hh,
+ * mln/io/magick/save.hh,
+ * mln/io/plot/save.hh,
+ * mln/labeling/blobs_and_compute.hh,
+ * mln/labeling/value_and_compute.hh,
+ * mln/make/w_window2d.hh,
+ * mln/win/multiple.hh,
+ * mln/win/multiple_size.hh,
+ * tests/accu/site_set/rectangularity.cc,
+ * tests/core/other/graph_elt_neighborhood.cc,
+ * tests/core/other/graph_elt_window.cc,
+ * tests/core/other/point_set_compatibility.cc,
+ * tests/draw/graph.cc: Update forward declarations and includes.
+
+ * mln/algebra/vec.hh,
+ * mln/convert/from_to.hh,
+ * mln/convert/impl/from_double_to_value.hh,
+ * mln/convert/impl/from_float_to_value.hh,
+ * mln/convert/impl/from_image_to_site_set.hh,
+ * mln/convert/impl/from_int_to_value.hh,
+ * mln/convert/impl/from_unsigned_to_value.hh,
+ * mln/convert/impl/from_value_to_value.hh,
+ * mln/core/alias/neighb2d.hh,
+ * mln/core/alias/neighb3d.hh,
+ * mln/core/alias/window1d.hh,
+ * mln/core/alias/window2d.hh,
+ * mln/core/alias/window3d.hh,
+ * mln/core/concept/accumulator.hh,
+ * mln/core/concept/gdpoint.hh,
+ * mln/core/concept/gpoint.hh,
+ * mln/core/concept/image.hh,
+ * mln/core/concept/proxy.hh,
+ * mln/core/concept/site_set.hh,
+ * mln/core/concept/window.hh,
+ * mln/core/image/graph_window_if_piter.hh,
+ * mln/core/image/image1d.hh,
+ * mln/core/mixed_neighb.hh,
+ * mln/core/neighb.hh,
+ * mln/core/site_set/operators.hh,
+ * mln/core/w_window.hh,
+ * mln/fun/i2v/array.hh,
+ * mln/util/object_id.hh,
+ * mln/value/hsl.hh,
+ * mln/value/int_u.hh,
+ * mln/value/label.hh,
+ * mln/value/qt/rgb32.hh,
+ * mln/value/rgb.hh,
+ * mln/histo/array.hh,
+ * mln/util/array.hh: Move from_to_ overloads in the same namespace
+ as their first argument.
+
2011-11-29 Guillaume Lazzara <z(a)lrde.epita.fr>
Fix the initialization of all global constants (ticket #43)
diff --git a/milena/mln/accu/count_labels.hh b/milena/mln/accu/count_labels.hh
index 07c48b2..c81cc9c 100644
--- a/milena/mln/accu/count_labels.hh
+++ b/milena/mln/accu/count_labels.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -30,6 +31,7 @@
///
/// Define an accumulator that counts the number of different labels.
+# include <vector>
# include <mln/accu/internal/base.hh>
# include <mln/core/concept/meta_accumulator.hh>
# include <mln/metal/is_a.hh>
diff --git a/milena/mln/algebra/vec.hh b/milena/mln/algebra/vec.hh
index bbe23c8..772c46e 100644
--- a/milena/mln/algebra/vec.hh
+++ b/milena/mln/algebra/vec.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2006, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2006, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -69,6 +69,14 @@ namespace mln
mln_sum_product(C,C) l2(const algebra::vec<n,C>& vec);
}
+ namespace value {
+ template <unsigned n> struct rgb;
+ }
+
+ template <typename G, typename C> struct point;
+ template <typename E> struct Gpoint;
+ // end of forward declarations
+
namespace trait
{
@@ -261,6 +269,38 @@ namespace mln
vec& operator=(const mat<n, 1, U>& rhs);
};
+
+ /// \internal Conversion: vec -> rgb.
+ template <typename T, unsigned m>
+ void from_to_(const vec<3,T>& from, value::rgb<m>& to_);
+
+ /// \internal Conversion: vec<1,C1> -> point<G,C2>
+ template <typename C1, typename G, typename C2>
+ inline
+ void
+ from_to_(const vec<1,C1>& from, point<G,C2>& to);
+
+ /// \internal Conversion: vec<n,C1> -> point<G,C2>
+ template <unsigned n, typename C1, typename G, typename C2>
+ void
+ from_to_(const vec<n,C1>& from, point<G,C2>& to);
+
+ /// \internal Conversion: vec<1,C1> -> point<G,C1>
+ template <typename C1, typename G>
+ inline
+ void
+ from_to_(const vec<1,C1>& from, point<G,C1>& to);
+
+ /// \internal Conversion: vec<n,C1> -> point<G,C1>
+ template <unsigned n, typename C1, typename G>
+ void
+ from_to_(const vec<n,C1>& from, point<G,C1>& to);
+
+ /// \internal Conversion: vec -> gpoint
+ template <unsigned n, typename T, typename P>
+ void
+ from_to_(const vec<n,T>& from, Gpoint<P>& to);
+
} // end of namespace mln::algebra
@@ -434,6 +474,46 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
+ namespace internal
+ {
+
+ template <typename C, typename C2>
+ inline
+ C
+ convert_data_(metal::bool_<false>, const C2& v)
+ {
+ return static_cast<C>(v);
+ }
+
+ template <typename C, typename C2>
+ inline
+ C
+ convert_data_(metal::bool_<true>, const C2& v)
+ {
+ return static_cast<C>(round(v));
+ }
+
+ template <typename C, typename C2>
+ inline
+ C
+ convert_data(const C2& v)
+ {
+ // If (C != float && C != double) && (C2 == float || C2 == double)
+ // => We want to round the value.
+ // Otherwise we can just statically cast.
+ //
+ return convert_data_<C>(
+ typename mlc_and(
+ mlc_and(mlc_is_not(C,float),
+ mlc_is_not(C,double)),
+ mlc_or(mlc_is(C2,float),
+ mlc_is(C2, double)))::eval(), v);
+ }
+
+ } // end of namespace mln::internal
+
+
+
namespace algebra
{
@@ -733,6 +813,87 @@ namespace mln
}
+ // Conversions
+
+
+ template <typename T, unsigned m>
+ inline
+ void
+ from_to_(const vec<3,T>& from, value::rgb<m>& to)
+ {
+ algebra::vec<3, unsigned> tmp;
+ for (unsigned i = 0; i < 3; ++i)
+ tmp[i] = static_cast<unsigned>(from[i]); // FIXME: Use from_to_ instead of cast.
+
+ to = value::rgb<m>(tmp);
+ }
+
+ template <unsigned n, typename C1, typename G, typename C2>
+ inline
+ void
+ from_to_(const mln::algebra::vec<n,C1>& from, point<G,C2>& to)
+ {
+ mlc_converts_to(C1, C2)::check();
+ enum { dim = G::dim };
+ mlc_bool(G::dim == n)::check();
+
+ unsigned j = 0;
+ for (unsigned i = dim - 2; i < dim; ++i)
+ to[i] = mln::internal::convert_data<C2>(from[j++]);
+ for (unsigned i = 2; i < dim; ++i, ++j)
+ to[i-j] = mln::internal::convert_data<C2>(from[j]);
+ }
+
+ template <typename C1, typename G, typename C2>
+ inline
+ void
+ from_to_(const mln::algebra::vec<1,C1>& from, point<G,C2>& to)
+ {
+ mlc_converts_to(C1, C2)::check();
+ enum { dim = G::dim };
+ mlc_bool(G::dim == 1)::check();
+
+ to[0] = mln::internal::convert_data<C2>(from[0]);
+ }
+
+ template <unsigned n, typename C1, typename G>
+ inline
+ void
+ from_to_(const mln::algebra::vec<n,C1>& from, point<G,C1>& to)
+ {
+ enum { dim = G::dim };
+ mlc_bool(G::dim == n)::check();
+
+ unsigned j = 0;
+ for (unsigned i = dim - 2; i < dim; ++i)
+ to[i] = from[j++];
+ for (unsigned i = 2; i < dim; ++i, ++j)
+ to[i-j] = from[j];
+ }
+
+ template <typename C1, typename G>
+ inline
+ void
+ from_to_(const mln::algebra::vec<1,C1>& from, point<G,C1>& to)
+ {
+ enum { dim = G::dim };
+ mlc_bool(G::dim == 1)::check();
+
+ to[0] = from[0];
+ }
+
+ template <unsigned n, typename T, typename P>
+ inline
+ void
+ from_to_(const vec<n,T>& from, Gpoint<P>& to_)
+ {
+ mlc_bool(P::dim == n)::check();
+ P& to = exact(to_);
+ for (unsigned i = 0; i < n; ++i)
+ to[i] = static_cast< typename P::coord >(from[i]); // FIXME: cast -> best
effort...
+ }
+
+
} // end of namespace mln::algebra
diff --git a/milena/mln/convert/from_to.hh b/milena/mln/convert/from_to.hh
index 1b04847..93f0f69 100644
--- a/milena/mln/convert/from_to.hh
+++ b/milena/mln/convert/from_to.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2010, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -38,7 +38,6 @@
/// \todo Find a solution for g++-2.95 and '...'; see FIXME below.
# include <mln/convert/impl/all.hh>
-# include <mln/convert/from_to.hxx>
# include <mln/metal/abort.hh>
# include <mln/metal/converts_to.hh>
@@ -64,8 +63,62 @@ namespace mln
from_to(const F& from, T& to);
+ } // end of namespace mln::convert
+
+} // end of namespace mln
+
+
# ifndef MLN_INCLUDE_ONLY
+// Exact same type.
+template <typename T>
+inline
+void
+from_to_(const T& from, T& to)
+{
+ to = from;
+}
+
+
+// Default conversion.
+template <typename F, typename T>
+inline
+void
+from_to_(const F& from, T& to)
+{
+ to = mln::value::cast<T>(from);
+}
+
+
+namespace mln
+{
+
+ // Exact same type.
+ template <typename T>
+ inline
+ void
+ from_to_(const T& from, T& to)
+ {
+ to = from;
+ }
+
+ // Object -> Object (F not convertible towards T)
+ // No conversion exists!
+ template <typename F, typename T>
+ void
+ from_to_(const Object<F>&, Object<T>&)
+ {
+ // This particular from-to is not defined!
+ //
+ // Either this conversion is meaningless or an overload is
+ // missing.
+ mlc_abort(F)::check();
+ }
+
+
+ namespace convert
+ {
+
namespace internal
{
@@ -128,7 +181,7 @@ namespace mln
from_to_dispatch(metal::false_,
const Object<F>& from, Object<T>& to)
{
- over_load::from_to_(exact(from), exact(to));
+ from_to_(exact(from), exact(to));
}
@@ -146,6 +199,18 @@ namespace mln
exact(from), exact(to));
}
+ // Object -> Object
+ template <typename T>
+ inline
+ void
+ from_to_dispatch(const Object<T>& from, Object<T>& to)
+ {
+ // Here we do not write effective code in order to let the
+ // user specify its own conversion function. A default
+ // implementation is provided before in this file.
+ from_to_(exact(from), exact(to));
+ }
+
// Dispatch entry points.
@@ -158,7 +223,7 @@ namespace mln
from_to_dispatch(metal::false_, const F& from,
metal::false_, T& to)
{
- over_load::from_to_(from, to);
+ from_to_(from, to);
}
@@ -169,7 +234,7 @@ namespace mln
from_to_dispatch(metal::true_, const F& from,
metal::false_, T& to)
{
- over_load::from_to_(exact(from), to);
+ from_to_(exact(from), to);
}
@@ -180,7 +245,7 @@ namespace mln
from_to_dispatch(metal::false_, const F& from,
metal::true_, T& to)
{
- over_load::from_to_(from, exact(to));
+ from_to_(from, exact(to));
}
// Object -> Object
@@ -197,58 +262,6 @@ namespace mln
} // end of namespace mln::convert::internal
- namespace over_load
- {
-
-
- // Object -> Object (F not convertible towards T)
- // No conversion exists!
- template <typename F, typename T>
- void
- from_to_(const Object<F>&, Object<T>&)
- {
- // This particular from-to is not defined!
- //
- // Either this conversion is meaningless or an overload is
- // missing.
- mlc_abort(F)::check();
- }
-
-
- // Object -> Object
- template <typename T>
- inline
- void
- from_to_(const Object<T>& from, Object<T>& to)
- {
- exact(to) = exact(from);
- }
-
-
- // Exact same type.
- template <typename T>
- inline
- void
- from_to_(const T& from, T& to)
- {
- to = from;
- }
-
-
- // Default conversion.
- template <typename F, typename T>
- inline
- void
- from_to_(const F& from, T& to)
- {
- to = mln::value::cast<T>(from);
- }
-
-
- } // end of namespace mln::convert::over_load
-
-
-
// Facade
template <typename F, typename T>
@@ -263,11 +276,11 @@ namespace mln
}
-# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::convert
} // end of namespace mln
+# endif // ! MLN_INCLUDE_ONLY
+
#endif // ! MLN_CONVERT_FROM_TO_HH
diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx
index a0e22df..81bc108 100644
--- a/milena/mln/convert/from_to.hxx
+++ b/milena/mln/convert/from_to.hxx
@@ -1,5 +1,5 @@
-// Copyright (C) 2008, 2009, 2010, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2010, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -29,78 +29,9 @@
/// \internal \file mln/convert/from_to.hxx
-// All overloaded "convert::from_to" routines have to be declared in
-// the present file. It allows for *deferred* use of these routines.
-
-# include <mln/core/def/all.hh>
-# include <mln/core/grids.hh>
-# include <mln/util/couple.hh>
-
-//FIXME: have a forward declaration.
-# include <vector>
-# include <set>
-
-
namespace mln
{
-
- // Forward declarations.
-
- template <typename E> struct Accumulator;
- template <typename E> struct Gdpoint;
- template <typename E> struct Gpoint;
- template <typename E> struct Image;
- template <typename E> struct Object;
- template <typename E> struct Proxy;
- template <typename E> struct Site_Set;
- template <typename E> struct Value;
- template <typename E> struct Weighted_Window;
- template <typename E> struct Window;
-
- template <typename G, typename C> struct dpoint;
- template <typename G, typename C> struct point;
-
- template <typename D> class neighb;
- template <typename D> class window;
- template <typename D, typename W> struct w_window;
-
- template <typename T> struct image1d;
-
- namespace algebra {
- template <unsigned n, typename T> class vec;
- template <unsigned d, typename C> class h_vec;
- }
-
- namespace fun {
- namespace i2v {
- template <typename T> class array;
- }
- }
-
- namespace histo {
- template <typename T> struct array;
- }
-
- namespace util {
- template <typename T> class array;
- template <typename Tag, typename V> class object_id;
- }
-
- namespace value {
- namespace qt { struct rgb32; }
- template <unsigned n> struct rgb;
- template <typename H, typename S, typename L> class hsl_;
- template <unsigned n> struct int_u;
- template <unsigned n> struct label;
- }
-
- // end of Forward declarations.
-
-
-
- // convert::to
-
namespace convert
{
@@ -108,378 +39,10 @@ namespace mln
T
to(const O& from);
- } // end of namespace mln::convert
-
-
-
- // convert::from_to
-
- namespace convert
- {
-
- // Facade
-
template <typename F, typename T>
void
from_to(const F& from, T& to);
-
- namespace over_load
- {
-
- // Guard.
- template <typename F, typename T>
- void
- from_to_(const Object<F>&, Object<T>&);
- // end of Guard.
-
- // Object -> Object
- template <typename T>
- void
- from_to_(const Object<T>& from, Object<T>& to);
-
- // Object -> Object
- template <typename T>
- void
- from_to_(const T& from, T& to);
-
- // point -> point.
- template <typename G, typename C1, typename C2>
- inline
- void
- from_to_(const point<G,C1>& from, point<G,C2>& to);
-
- // algebra::vec -> point
- template <unsigned n, typename C1, typename G, typename C2>
- void
- from_to_(const algebra::vec<n,C1>& from, point<G,C2>& to);
-
- // algebra::vec -> point
- template <unsigned n, typename C1, typename G>
- void
- from_to_(const algebra::vec<n,C1>& from, point<G,C1>& to);
-
- // algebra::vec -> Gpoint.
- template <unsigned n, typename T, typename P>
- void
- from_to_(const algebra::vec<n,T>& from, Gpoint<P>& to_);
-
- // algebra::vec -> rgb.
- template <typename T, unsigned m>
- void
- from_to_(const algebra::vec<3,T>& from, value::rgb<m>& to);
-
-
- // bool -> rgb.
- template <unsigned m>
- void
- from_to_(bool from, value::rgb<m>& to);
-
- // rgb32 -> bool
- void
- from_to_(const value::qt::rgb32& from, bool& to);
-
- // bool -> rgb32
- void
- from_to_(const bool& from, value::qt::rgb32& to);
-
- // int_u -> rgb.
- template <unsigned m>
- void from_to_(const value::int_u<m>& from, value::rgb<m>& to);
-
- // int_u -> qt::rgb32.
- template <unsigned m>
- void from_to_(const value::int_u<m>& from, value::qt::rgb32& to);
-
- // int_u -> label
- template <unsigned n>
- void from_to_(const value::int_u<n>& from, value::label<n>&
to_);
-
- // int_u -> unsigned
- template <unsigned n>
- void from_to_(const value::int_u<n>& from, unsigned& to_);
-
- // int_u -> bool.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, bool& to_);
-
- // int_u -> float
- template <unsigned n>
- void from_to_(const value::int_u<n>& from, float& to_);
-
- // int_u -> double
- template <unsigned n>
- void from_to_(const value::int_u<n>& from, double& to_);
-
- // label -> int_u.
- template <unsigned n>
- void
- from_to_(const value::label<n>& from, value::int_u<n>& to_);
-
- // label -> bool
- template <unsigned n>
- void from_to_(const value::label<n>& from, bool& to_);
-
- // int_u<n> -> label<m> with n < m
- template <unsigned n, unsigned m>
- void
- from_to_(const value::int_u<n>& from, value::label<m>& to_);
-
- // hsl -> rgb8.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>&, value::rgb<8>& to);
-
- // hsl -> rgb16.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>&, value::rgb<16>& to);
-
- // hsl -> qt::rgb32.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>&, value::qt::rgb32& to);
-
- // rgb to hsl
- void
- from_to_(const value::rgb<16>& from,
value::hsl_<float,float,float>& to);
-
- // rgb to hsl
- void
- from_to_(const value::rgb<8>& from,
value::hsl_<float,float,float>& to);
-
- // rgb -> bool.
- template <unsigned m>
- void from_to_(const value::rgb<m>& from, bool& to);
-
-
- // C-array -> Image.
- template <typename V, unsigned S, typename I>
- void
- from_to_(const V (&values)[S], Image<I>& to);
-
- // C-array -> w_window
- template <typename V, unsigned S, typename D, typename W>
- void
- from_to_(const V (&weight)[S], w_window<D,W>& to);
-
-
- // C-array -> window2d
- template <unsigned S>
- void
- from_to_(const bool (&values)[S],
- window< dpoint<grid::square, def::coord> >& win);
-
- template <unsigned R, unsigned C>
- void
- from_to_(const bool (&values)[R][C],
- window< dpoint<grid::square, def::coord> >& win);
-
-
- // C-array -> window3d
- template <unsigned S>
- void
- from_to_(const bool (&values)[S],
- window< dpoint<grid::cube, def::coord> >& win);
-
-
- // C-array -> neighb2d
- template <unsigned S>
- void
- from_to_(const bool (&values)[S],
- neighb< window< dpoint<grid::square, def::coord> > >&
nbh);
-
- template <unsigned R, unsigned C>
- void
- from_to_(bool const (&values)[R][C],
- neighb< window< dpoint<grid::square, def::coord> > >&
nbh);
-
-
- // C-array -> neighb3d
- template <unsigned S>
- void
- from_to_(const bool (&values)[S],
- neighb< window< dpoint<grid::cube, def::coord> > >& nbh);
-
-
-
- // Gdpoint -> point
- template <typename D>
- void
- from_to_(const Gdpoint<D>& from, mln_site(D)& to);
-
-
- // Value -> Value
- template <typename F, typename T>
- void
- from_to_(const Value<F>& from, Value<T>& to);
-
- // double-> Value
- template <typename V>
- void
- from_to_(const double& from, Value<V>& to);
-
- // double-> unsigned
- void
- from_to_(const double& from, unsigned& to);
-
- // double-> int
- void
- from_to_(const double& from, int& to);
-
- // float -> Value
- template <typename V>
- void
- from_to_(const float& from, Value<V>& to);
-
- // float -> unsigned
- void
- from_to_(const float& from, unsigned& to);
-
- // float -> int
- void
- from_to_(const float& from, int& to);
-
- // int -> Value
- template <typename T>
- void
- from_to_(const int& from, Value<T>& to);
-
- // Proxy -> T
- template <typename P, typename T>
- void
- from_to_(const Proxy<P>& from, T& to);
-
-
- // Gpoint -> algebra::vec.
- template <typename P, unsigned n, typename T>
- void
- from_to_(const Gpoint<P>& from, algebra::vec<n,T>& to);
-
- // Gpoint -> delta-point
- template <typename P>
- void
- from_to_(const Gpoint<P>& from, mln_delta(P)& to);
-
-
- // Image -> Site_Set.
- template <typename I, typename S>
- void
- from_to_(const Image<I>& from, Site_Set<S>& to);
-
- // Image -> w_window
- template <typename I, typename D, typename W>
- void
- from_to_(const Image<I>& from, w_window<D,W>& to);
-
-
- // neighb<W> -> W
- template <typename W>
- void
- from_to_(const mln::neighb<W>& from, W& to);
-
- // W -> neighb<W>
- template <typename W>
- void
- from_to_(const W& from, mln::neighb<W>& to);
-
-
- // Window -> Image
- template <typename W, typename I>
- void
- from_to_(const Window<W>& from, Image<I>& to);
-
-
- // w_window -> Image
- template <typename D, typename W, typename I>
- void
- from_to_(const w_window<D,W>& from, Image<I>& to);
-
-
-
- // util::array<T> -> fun::i2v::array<T>
- template <typename T>
- void
- from_to_(const util::array<T>& from, fun::i2v::array<T>& to);
-
- // util::array<T> -> fun::i2v::array<U>
- template <typename T, typename U>
- void
- from_to_(const util::array<T>& from, fun::i2v::array<U>& to);
-
- // std::vector<T> -> fun::i2v::array<T>
- template <typename T>
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<T>& to);
-
- // std::vector<T> -> fun::i2v::array<U>
- template <typename T, typename U>
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<U>& to);
-
- // util::array<T1> -> util::array<T2>
- template <typename T1, typename T2>
- void
- from_to_(const util::array<T1>& from, util::array<T2>& to);
-
-
-
- // util::array<T1> -> util::array<T2>
- template <typename T1, typename T2>
- void
- from_to_(const util::array<T1>& from, util::array<T2>& to);
-
- // fun::i2v::array<T1> -> util::array<T2>
- template <typename T1, typename T2>
- void
- from_to_(const fun::i2v::array<T1>& from, util::array<T2>&
to);
-
-
- // Accumulator<A> -> mln_result(A)
- template <typename A>
- void
- from_to_(const Accumulator<A>& from, mln_result(A)& to);
-
-
-
- // Site_Set -> Image.
- template <typename S, typename I>
- void
- from_to_(const Site_Set<S>& from, Image<I>& to);
-
- // Site_Set -> std::set
- template <typename S, typename P, typename C_>
- void
- from_to_(const Site_Set<S>& from, std::set<P,C_>& to);
-
- // std::set -> Site_Set
- template <typename P, typename C_, typename S>
- void
- from_to_(const std::set<P,C_>& from, Site_Set<S>& to);
-
- // histo::array -> image1d
- template <typename V, typename T>
- void
- from_to_(const histo::array<V>& from, image1d<T>& to);
-
- // util::array -> image1d
- template <typename V, typename T>
- void
- from_to_(const util::array<V>& from, image1d<T>& to);
-
- // util::couple<T, U> -> util::couple<V, W>
- template <typename T, typename U, typename V, typename W>
- void
- from_to_(const util::couple<T, U>& from, util::couple<V, W>&
to)
- {
- from_to(from.first(), to.first());
- from_to(from.second(), to.second());
- }
-
- // util::object_id<Tag,V> -> V.
- template <typename Tag, typename V>
- void from_to_(const util::object_id<Tag,V>& from, V& to_);
-
- } // end of namespace mln::convert::over_load
-
} // end of namespace mln::convert
} // end of namespace mln
diff --git a/milena/mln/convert/impl/from_double_to_value.hh
b/milena/mln/convert/impl/from_double_to_value.hh
index fd2b32a..eaae734 100644
--- a/milena/mln/convert/impl/from_double_to_value.hh
+++ b/milena/mln/convert/impl/from_double_to_value.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+// Copyright (C) 2009, 2010, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -45,113 +45,106 @@
namespace mln
{
+ /// \internal Conversion: double-> Value
+ template <typename V>
+ void from_to_(const double& from, Value<V>& to);
+
+ /// \internal Conversion: double-> unsigned
+ void from_to_(const double& from, unsigned& to);
+
+ /// \internal Conversion: double-> int
+ void from_to_(const double& from, int& to);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
namespace convert
{
- /// Conversion of a double \p from towards a value \p to.
+ namespace impl
+ {
+
+ // Case 1:
+
template <typename V>
+ inline
void
- from_to(const double& from, Value<V>& to);
-
+ from_double_to_value(const double& from,
+ mln::value::Integer<V>& to)
+ {
+ exact(to) = math::round<V>()(from);
+ }
-# ifndef MLN_INCLUDE_ONLY
+ // Case 2:
- namespace impl
+ template <typename V>
+ inline
+ void
+ from_double_to_value(const double& from,
+ mln::value::Floating<V>& to)
{
+ exact(to) = from;
+ }
- // Case 1:
-
- template <typename V>
- inline
- void
- from_double_to_value(const double& from,
- mln::value::Integer<V>& to)
- {
- exact(to) = math::round<V>()(from);
- }
- // Case 2:
+ // Default: no conversion defined.
- template <typename V>
- inline
- void
- from_double_to_value(const double& from,
- mln::value::Floating<V>& to)
- {
- exact(to) = from;
- }
+ template <typename V>
+ inline
+ void
+ from_double_to_value(const double& from,
+ Value<V>& to)
+ {
+ (void) from;
+ (void) to;
+ mlc_abort(V)::check();
+ }
+ } // end of namespace mln::convert::impl
- // Default: no conversion defined.
- template <typename V>
- inline
- void
- from_double_to_value(const double& from,
- Value<V>& to)
- {
- (void) from;
- (void) to;
- mlc_abort(V)::check();
- }
+ namespace internal
+ {
- } // end of namespace mln::convert::impl
+ template <typename V>
+ inline
+ void
+ from_double_to_value_dispatch(const double& from, Value<V>& to)
+ {
+ impl::from_double_to_value(from, exact(to));
+ }
+ } // end of namespace mln::convert::internal
- namespace internal
- {
+ } // end of namespace mln::convert
- template <typename V>
- inline
- void
- from_double_to_value_dispatch(const double& from, Value<V>& to)
- {
- impl::from_double_to_value(from, exact(to));
- }
- } // end of namespace mln::convert::internal
+ template <typename V>
+ inline
+ void
+ from_to_(const double& from, Value<V>& to)
+ {
+ convert::internal::from_double_to_value_dispatch(from, to);
+ }
+ inline
+ void
+ from_to_(const double& from, unsigned& to)
+ {
+ mln_precondition(from >= 0);
+ to = math::round<unsigned>()(from);
+ }
- namespace over_load
- {
+ inline
+ void
+ from_to_(const double& from, int& to)
+ {
+ to = math::round<int>()(from);
+ }
- // Facades.
-
-
- // double-> Value
- template <typename V>
- inline
- void
- from_to_(const double& from, Value<V>& to)
- {
- internal::from_double_to_value_dispatch(from, to);
- }
-
- // double-> unsigned
- inline
- void
- from_to_(const double& from,
- unsigned& to)
- {
- mln_precondition(from >= 0);
- to = math::round<unsigned>()(from);
- }
-
- // double-> int
- inline
- void
- from_to_(const double& from,
- int& to)
- {
- to = math::round<int>()(from);
- }
-
- } // end of namespace mln::convert::over_load
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
-
} // end of namespace mln
diff --git a/milena/mln/convert/impl/from_float_to_value.hh
b/milena/mln/convert/impl/from_float_to_value.hh
index aa880d8..0a275ed 100644
--- a/milena/mln/convert/impl/from_float_to_value.hh
+++ b/milena/mln/convert/impl/from_float_to_value.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2008, 2009, 2010, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2010, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -45,123 +45,116 @@
namespace mln
{
+ /// \internal Conversion: float-> Value
+ template <typename V>
+ void from_to_(const float& from, Value<V>& to);
+
+ /// \internal Conversion: float-> unsigned
+ void from_to_(const float& from, unsigned& to);
+
+ /// \internal Conversion: float-> int
+ void from_to_(const float& from, int& to);
+
+ /// \internal Conversion: float-> short
+ void from_to_(const float& from, short& to);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
namespace convert
{
- /// Conversion of a float \p from towards a value \p to.
+ namespace impl
+ {
+
+ // Case 1:
+
template <typename V>
+ inline
void
- from_to(const float& from, Value<V>& to);
-
+ from_float_to_value(const float& from,
+ mln::value::Integer<V>& to)
+ {
+ exact(to) = math::round<V>()(from);
+ }
-# ifndef MLN_INCLUDE_ONLY
+ // Case 2:
- namespace impl
+ template <typename V>
+ inline
+ void
+ from_float_to_value(const float& from,
+ mln::value::Floating<V>& to)
{
+ exact(to) = from;
+ }
- // Case 1:
- template <typename V>
- inline
- void
- from_float_to_value(const float& from,
- mln::value::Integer<V>& to)
- {
- exact(to) = math::round<V>()(from);
- }
+ // Default: no conversion defined.
- // Case 2:
+ template <typename V>
+ inline
+ void
+ from_float_to_value(const float& from,
+ Value<V>& to)
+ {
+ (void) from;
+ (void) to;
+ mlc_abort(V)::check();
+ }
- template <typename V>
- inline
- void
- from_float_to_value(const float& from,
- mln::value::Floating<V>& to)
- {
- exact(to) = from;
- }
+ } // end of namespace mln::convert::impl
- // Default: no conversion defined.
+ namespace internal
+ {
- template <typename V>
- inline
- void
- from_float_to_value(const float& from,
- Value<V>& to)
- {
- (void) from;
- (void) to;
- mlc_abort(V)::check();
- }
+ template <typename V>
+ inline
+ void
+ from_float_to_value_dispatch(const float& from, Value<V>& to)
+ {
+ impl::from_float_to_value(from, exact(to));
+ }
- } // end of namespace mln::convert::impl
+ } // end of namespace mln::convert::internal
+ } // end of namespace mln::convert
- namespace internal
- {
- template <typename V>
- inline
- void
- from_float_to_value_dispatch(const float& from, Value<V>& to)
- {
- impl::from_float_to_value(from, exact(to));
- }
+ template <typename V>
+ inline
+ void
+ from_to_(const float& from, Value<V>& to)
+ {
+ convert::internal::from_float_to_value_dispatch(from, to);
+ }
- } // end of namespace mln::convert::internal
+ inline
+ void
+ from_to_(const float& from, unsigned& to)
+ {
+ mln_precondition(from >= 0);
+ to = math::round<unsigned>()(from);
+ }
+ inline
+ void
+ from_to_(const float& from, int& to)
+ {
+ to = math::round<int>()(from);
+ }
- namespace over_load
- {
+ inline
+ void
+ from_to_(const float& from, short& to)
+ {
+ to = math::round<short>()(from);
+ }
- // Facades.
-
-
- // float-> Value
- template <typename V>
- inline
- void
- from_to_(const float& from, Value<V>& to)
- {
- internal::from_float_to_value_dispatch(from, to);
- }
-
- // float-> unsigned
- inline
- void
- from_to_(const float& from,
- unsigned& to)
- {
- mln_precondition(from >= 0);
- to = math::round<unsigned>()(from);
- }
-
- // float-> int
- inline
- void
- from_to_(const float& from,
- int& to)
- {
- to = math::round<int>()(from);
- }
-
- // float-> short
- inline
- void
- from_to_(const float& from,
- short& to)
- {
- to = math::round<short>()(from);
- }
-
-
- } // end of namespace mln::convert::over_load
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
-
} // end of namespace mln
diff --git a/milena/mln/convert/impl/from_image_to_site_set.hh
b/milena/mln/convert/impl/from_image_to_site_set.hh
index 65873b6..e78538b 100644
--- a/milena/mln/convert/impl/from_image_to_site_set.hh
+++ b/milena/mln/convert/impl/from_image_to_site_set.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -94,8 +94,8 @@ namespace mln
p.next();
}
while (p.is_valid() && input(p) == true &&
- // p follows q in a run, i.e., "p == q + right":
- cut_(p.to_site()) == cut_(q) && p.last_coord() == q.last_coord() + 1);
+ // p follows q in a run, i.e., "p == q + right":
+ cut_(p.to_site()) == cut_(q) && p.last_coord() == q.last_coord() + 1);
s.insert(p_run<P>(start, q));
}
}
@@ -123,7 +123,7 @@ namespace mln
p.next();
}
while (p.is_valid() && input(p) == v &&
- cut_(p.to_site()) == cut_(q) && p.last_coord() == q.last_coord() + 1);
+ cut_(p.to_site()) == cut_(q) && p.last_coord() == q.last_coord() + 1);
s.insert(v, p_run<P>(start, q));
}
}
diff --git a/milena/mln/convert/impl/from_int_to_value.hh
b/milena/mln/convert/impl/from_int_to_value.hh
index c22dfb1..4074ed0 100644
--- a/milena/mln/convert/impl/from_int_to_value.hh
+++ b/milena/mln/convert/impl/from_int_to_value.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2010, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -44,79 +44,72 @@
namespace mln
{
- namespace convert
- {
-
- /// Conversion of a int \p from towards a value \p to.
- template <typename V>
- void
- from_to(const int& from, Value<V>& to);
+ /// \internal Conversion: int-> Value
+ template <typename V>
+ void from_to_(const int& from, Value<V>& to);
# ifndef MLN_INCLUDE_ONLY
- namespace impl
- {
+ namespace convert
+ {
- // Case 1:
+ namespace impl
+ {
- template <typename V>
- inline
- void
- from_int_to_value(const int& from,
- mln::value::Integer<V>& to)
- {
- exact(to) = from;
- }
+ // Case 1:
- // Default: no conversion defined.
+ template <typename V>
+ inline
+ void
+ from_int_to_value(const int& from,
+ mln::value::Integer<V>& to)
+ {
+ exact(to) = from;
+ }
- template <typename V>
- inline
- void
- from_int_to_value(const int& from,
- Value<V>& to)
- {
- (void) from;
- (void) to;
- mlc_abort(V)::check();
- }
+ // Default: no conversion defined.
- } // end of namespace mln::convert::impl
+ template <typename V>
+ inline
+ void
+ from_int_to_value(const int& from,
+ Value<V>& to)
+ {
+ (void) from;
+ (void) to;
+ mlc_abort(V)::check();
+ }
+ } // end of namespace mln::convert::impl
- namespace internal
- {
+ namespace internal
+ {
- template <typename V>
- inline
- void
- from_int_to_value_dispatch(const int& from, Value<V>& to)
- {
- impl::from_int_to_value(from, exact(to));
- }
+ template <typename V>
+ inline
+ void
+ from_int_to_value_dispatch(const int& from, Value<V>& to)
+ {
+ impl::from_int_to_value(from, exact(to));
+ }
- } // end of namespace mln::convert::internal
+ } // end of namespace mln::convert::internal
+ } // end of namespace mln::convert
- namespace over_load
- {
- // Facades.
- // int-> Value
- template <typename V>
- void
- from_to_(const int& from, Value<V>& to)
- {
- internal::from_int_to_value_dispatch(from, to);
- }
+ // Facades.
- } // end of namespace mln::convert::over_load
+ template <typename V>
+ void
+ from_to_(const int& from, Value<V>& to)
+ {
+ convert::internal::from_int_to_value_dispatch(from, to);
+ }
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
-
} // end of namespace mln
diff --git a/milena/mln/convert/impl/from_unsigned_to_value.hh
b/milena/mln/convert/impl/from_unsigned_to_value.hh
index 783b5e9..383f989 100644
--- a/milena/mln/convert/impl/from_unsigned_to_value.hh
+++ b/milena/mln/convert/impl/from_unsigned_to_value.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+// Copyright (C) 2009, 2010, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -45,102 +45,92 @@
namespace mln
{
- namespace convert
- {
- /// Conversion of an unsigned \p from towards a value \p to.
- template <typename V>
- void
- from_to(const unsigned& from, Value<V>& to);
+ /// \internal Conversion: unsigned-> Value
+ template <typename V>
+ void from_to_(const unsigned& from, Value<V>& to);
+
+ /// \internal Conversion: unsigned -> bool
+ void from_to_(const unsigned& from, bool& to);
+
- /// Conversion of an unsigned \p from towards a bool \p to.
- inline
- void
- from_to_(const unsigned& from, bool& to);
# ifndef MLN_INCLUDE_ONLY
- namespace impl
+ namespace convert
+ {
+
+ namespace impl
+ {
+
+ // Case 1:
+
+ template <typename V>
+ inline
+ void
+ from_unsigned_to_value(const unsigned& from,
+ mln::value::Integer<V>& to)
{
+ exact(to) = from;
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_unsigned_to_value(const unsigned& from,
+ mln::value::label<n>& to)
+ {
+ exact(to) = from;
+ }
+
+ // Default: no conversion defined.
- // Case 1:
-
- template <typename V>
- inline
- void
- from_unsigned_to_value(const unsigned& from,
- mln::value::Integer<V>& to)
- {
- exact(to) = from;
- }
-
- template <unsigned n>
- inline
- void
- from_unsigned_to_value(const unsigned& from,
- mln::value::label<n>& to)
- {
- exact(to) = from;
- }
-
- // Default: no conversion defined.
-
- template <typename V>
- inline
- void
- from_unsigned_to_value(const unsigned&,
- Value<V>&)
- {
- mlc_abort(V)::check();
- }
-
- } // end of namespace mln::convert::impl
-
-
- namespace internal
+ template <typename V>
+ inline
+ void
+ from_unsigned_to_value(const unsigned&,
+ Value<V>&)
{
+ mlc_abort(V)::check();
+ }
- template <typename V>
- inline
- void
- from_unsigned_to_value_dispatch(const unsigned& from, Value<V>& to)
- {
- impl::from_unsigned_to_value(from, exact(to));
- }
+ } // end of namespace mln::convert::impl
- } // end of namespace mln::convert::unsignedernal
+ namespace internal
+ {
- namespace over_load
+ template <typename V>
+ inline
+ void
+ from_unsigned_to_value_dispatch(const unsigned& from, Value<V>& to)
{
+ impl::from_unsigned_to_value(from, exact(to));
+ }
- // Facades.
- // unsigned-> Value
- template <typename V>
- void
- from_to_(const unsigned& from, Value<V>& to)
- {
- internal::from_unsigned_to_value_dispatch(from, to);
- }
+ } // end of namespace mln::convert::unsignedernal
+
+ } // end of namespace mln::convert
- // Facades.
- // unsigned-> bool
- inline
- void
- from_to_(const unsigned& from, bool& to)
- {
- to = (from != 0u);
- }
+ template <typename V>
+ void
+ from_to_(const unsigned& from, Value<V>& to)
+ {
+ convert::internal::from_unsigned_to_value_dispatch(from, to);
+ }
- } // end of namespace mln::convert::over_load
+ inline
+ void
+ from_to_(const unsigned& from, bool& to)
+ {
+ to = (from != 0u);
+ }
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
-
} // end of namespace mln
diff --git a/milena/mln/convert/impl/from_value_to_value.hh
b/milena/mln/convert/impl/from_value_to_value.hh
index 347338b..fea91a3 100644
--- a/milena/mln/convert/impl/from_value_to_value.hh
+++ b/milena/mln/convert/impl/from_value_to_value.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -41,8 +42,6 @@
# include <mln/core/site_set/p_run.hh>
# include <mln/metal/converts_to.hh>
-# include <mln/convert/from_to.hxx>
-
namespace mln
{
@@ -93,7 +92,7 @@ namespace mln
{
// No concept based conversion. Trying to find more specific
// conversion with other from_to overloads.
- convert::over_load::from_to_(exact(from), exact(to));
+ from_to_(exact(from), exact(to));
}
diff --git a/milena/mln/convert/to.hh b/milena/mln/convert/to.hh
index f88f621..5c46416 100644
--- a/milena/mln/convert/to.hh
+++ b/milena/mln/convert/to.hh
@@ -36,7 +36,6 @@
# include <mln/metal/equal.hh>
# include <mln/trace/all.hh>
# include <mln/convert/from_to.hh>
-# include <mln/convert/from_to.hxx>
namespace mln
diff --git a/milena/mln/core/alias/neighb2d.hh b/milena/mln/core/alias/neighb2d.hh
index ee86509..63fbc55 100644
--- a/milena/mln/core/alias/neighb2d.hh
+++ b/milena/mln/core/alias/neighb2d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -123,22 +124,13 @@ namespace mln
neighb< win::multiple<window2d, mln::fun::p2b::chess> > c6_2d();
+ /// \internal Conversion: bool[] -> neighb2d
+ template <unsigned S>
+ void from_to_(const bool (&values)[S], neighb2d& nbh);
- namespace convert
- {
-
- namespace over_load
- {
-
- template <unsigned S>
- void from_to_(const bool (&values)[S], neighb2d& nbh);
-
- template <unsigned R, unsigned C>
- void from_to_(bool const (&values)[R][C], neighb2d& nbh);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: bool[][] -> neighb2d
+ template <unsigned R, unsigned C>
+ void from_to_(bool const (&values)[R][C], neighb2d& nbh);
@@ -208,48 +200,39 @@ namespace mln
bool vert[] = { 1, 1, 0,
1, 0, 1,
0, 1, 1 };
-
+
bool hori[] = { 0, 1, 1,
1, 0, 1,
1, 1, 0 };
-
+
return make::double_neighb2d(fun::p2b::chess(),
vert,
hori);
}
- namespace convert
+ template <unsigned S>
+ void
+ from_to_(const bool (&values)[S], neighb2d& nbh)
{
+ enum { h = mlc_sqrt_int(S) / 2 };
+ mlc_bool((2 * h + 1) * (2 * h + 1) == S)::check();
+ window2d& win = nbh.hook_win_();
+ convert::from_to(values, win);
+ mln_postcondition(win.is_neighbable_());
+ }
- namespace over_load
- {
-
- template <unsigned S>
- void
- from_to_(const bool (&values)[S], neighb2d& nbh)
- {
- enum { h = mlc_sqrt_int(S) / 2 };
- mlc_bool((2 * h + 1) * (2 * h + 1) == S)::check();
- window2d& win = nbh.hook_win_();
- convert::from_to(values, win);
- mln_postcondition(win.is_neighbable_());
- }
-
- template <unsigned R, unsigned C>
- void
- from_to_(bool const (&values)[R][C], neighb2d& nbh)
- {
- mlc_bool(R % 2 == 1)::check();
- mlc_bool(C % 2 == 1)::check();
- window2d& win = nbh.hook_win_();
- convert::from_to(values, win);
- mln_postcondition(win.is_neighbable_());
- }
-
- } // end of namespace mln::convert::over_load
+ template <unsigned R, unsigned C>
+ void
+ from_to_(bool const (&values)[R][C], neighb2d& nbh)
+ {
+ mlc_bool(R % 2 == 1)::check();
+ mlc_bool(C % 2 == 1)::check();
+ window2d& win = nbh.hook_win_();
+ convert::from_to(values, win);
+ mln_postcondition(win.is_neighbable_());
+ }
- } // end of namespace mln::convert
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/alias/neighb3d.hh b/milena/mln/core/alias/neighb3d.hh
index a5dead7..cb2d809 100644
--- a/milena/mln/core/alias/neighb3d.hh
+++ b/milena/mln/core/alias/neighb3d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -203,21 +204,9 @@ namespace mln
const neighb3d& c26();
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <unsigned S>
- void from_to_(const bool (&values)[S], neighb3d& nbh);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
+ /// \internal Conversion: bool[] -> neighb3d
+ template <unsigned S>
+ void from_to_(const bool (&values)[S], neighb3d& nbh);
# ifndef MLN_INCLUDE_ONLY
@@ -325,29 +314,19 @@ namespace mln
}
- namespace convert
+ template <unsigned S>
+ void
+ from_to_(const bool (&values)[S], neighb3d& nbh)
{
-
- namespace over_load
- {
-
- template <unsigned S>
- void
- from_to_(const bool (&values)[S], neighb3d& nbh)
- {
# ifndef NDEBUG
- const int h = unsigned(std::pow(float(S), float(1. / 3.))) / 2;
- mln_precondition((2 * h + 1) * (2 * h + 1) * (2 * h + 1) == S);
+ const int h = unsigned(std::pow(float(S), float(1. / 3.))) / 2;
+ mln_precondition((2 * h + 1) * (2 * h + 1) * (2 * h + 1) == S);
# endif // ! NDEBUG
- window3d win;
- from_to_(values, win);
- mln_precondition(win.is_neighbable_());
- nbh.change_window(win);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ window3d win;
+ from_to_(values, win);
+ mln_precondition(win.is_neighbable_());
+ nbh.change_window(win);
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/alias/point1d.hh b/milena/mln/core/alias/point1d.hh
index 5cd9803..f3cde66 100644
--- a/milena/mln/core/alias/point1d.hh
+++ b/milena/mln/core/alias/point1d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,6 +32,8 @@
/// Definition of the mln::point1d and mln::point1df aliases and of
/// their construction routines.
+# include <mln/core/def/coord.hh>
+# include <mln/core/def/coordf.hh>
# include <mln/core/point.hh>
// For site_const_impl and site_mutable_impl.
# include <mln/core/concept/site_proxy.hh>
diff --git a/milena/mln/core/alias/point2d.hh b/milena/mln/core/alias/point2d.hh
index dd79faa..5a7ae65 100644
--- a/milena/mln/core/alias/point2d.hh
+++ b/milena/mln/core/alias/point2d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,6 +32,8 @@
/// Definition of the mln::point2d and mln::point2df aliases and of
/// their construction routines.
+# include <mln/core/def/coord.hh>
+# include <mln/core/def/coordf.hh>
# include <mln/core/point.hh>
// For site_const_impl and site_mutable_impl.
# include <mln/core/concept/site_proxy.hh>
diff --git a/milena/mln/core/alias/point3d.hh b/milena/mln/core/alias/point3d.hh
index 6aaede0..bfc6bee 100644
--- a/milena/mln/core/alias/point3d.hh
+++ b/milena/mln/core/alias/point3d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,6 +32,8 @@
/// Definition of the mln::point3d and mln::point3df aliases and of
/// their construction routines.
+# include <mln/core/def/coord.hh>
+# include <mln/core/def/coordf.hh>
# include <mln/core/point.hh>
// For site_const_impl and site_mutable_impl:
# include <mln/core/concept/site_proxy.hh>
diff --git a/milena/mln/core/alias/window1d.hh b/milena/mln/core/alias/window1d.hh
index 6564e43..dd2d4fc 100644
--- a/milena/mln/core/alias/window1d.hh
+++ b/milena/mln/core/alias/window1d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -47,45 +48,25 @@ namespace mln
typedef window<mln::dpoint1d> window1d;
- namespace convert
- {
-
- namespace over_load
- {
-
- template <unsigned M>
- void from_to_(const bool (&values)[M], window1d& win);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
+ /// \internal Conversion: bool[] -> window1d
+ template <unsigned M>
+ void from_to_(const bool (&values)[M], window1d& win);
# ifndef MLN_INCLUDE_ONLY
- namespace convert
+ template <unsigned M>
+ void
+ from_to_(bool const (&values)[M], window1d& win)
{
-
- namespace over_load
- {
-
- template <unsigned M>
- void
- from_to_(bool const (&values)[M], window1d& win)
- {
- mlc_bool(M % 2 == 1)::check();
- win.clear();
- const int h = int(M) / 2;
- unsigned i = 0;
- for (int ind = - h; ind <= h; ++ind)
- if (values[i++])
- win.insert(ind);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ mlc_bool(M % 2 == 1)::check();
+ win.clear();
+ const int h = int(M) / 2;
+ unsigned i = 0;
+ for (int ind = - h; ind <= h; ++ind)
+ if (values[i++])
+ win.insert(ind);
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/alias/window2d.hh b/milena/mln/core/alias/window2d.hh
index 5b8fe31..aa56837 100644
--- a/milena/mln/core/alias/window2d.hh
+++ b/milena/mln/core/alias/window2d.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -35,7 +35,6 @@
# include <mln/core/window.hh>
# include <mln/core/alias/dpoint2d.hh>
# include <mln/metal/math/sqrt.hh>
-# include <mln/convert/from_to.hxx>
namespace mln
@@ -81,22 +80,13 @@ namespace mln
const window2d& win_c8p();
- namespace convert
- {
-
- namespace over_load
- {
-
- template <unsigned S>
- void from_to_(const bool (&values)[S], window2d& win);
-
- template <unsigned R, unsigned C>
- void from_to_(const bool (&values)[R][C], window2d& win);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: bool[] -> window2d
+ template <unsigned S>
+ void from_to_(const bool (&values)[S], window2d& win);
+ /// \internal Conversion: bool[][] -> window2d
+ template <unsigned R, unsigned C>
+ void from_to_(const bool (&values)[R][C], window2d& win);
# ifndef MLN_INCLUDE_ONLY
@@ -138,50 +128,40 @@ namespace mln
}
- namespace convert
+ template <unsigned S>
+ void
+ from_to_(const bool (&values)[S], window2d& win)
{
+ enum { H = mlc_sqrt_int(S) / 2 };
+ mlc_bool((2 * H + 1) * (2 * H + 1) == S)::check();
+ win.clear();
+ unsigned i = 0;
+ const def::coord
+ h = static_cast<def::coord>(H),
+ _h = static_cast<def::coord>(-h);
+ for (def::coord row = _h; row <= h; ++row)
+ for (def::coord col = _h; col <= h; ++col)
+ if (values[i++])
+ win.insert(row, col);
+ }
- namespace over_load
- {
-
- template <unsigned S>
- void
- from_to_(const bool (&values)[S], window2d& win)
- {
- enum { H = mlc_sqrt_int(S) / 2 };
- mlc_bool((2 * H + 1) * (2 * H + 1) == S)::check();
- win.clear();
- unsigned i = 0;
- const def::coord
- h = static_cast<def::coord>(H),
- _h = static_cast<def::coord>(-h);
- for (def::coord row = _h; row <= h; ++row)
- for (def::coord col = _h; col <= h; ++col)
- if (values[i++])
- win.insert(row, col);
- }
-
- template <unsigned R, unsigned C>
- void
- from_to_(const bool (&values)[R][C], window2d& win)
- {
- mlc_bool(R % 2 == 1)::check();
- mlc_bool(C % 2 == 1)::check();
- win.clear();
- const def::coord
- drow = static_cast<def::coord>(R / 2),
- _drow = static_cast<def::coord>(- drow),
- dcol = static_cast<def::coord>(C / 2),
- _dcol = static_cast<def::coord>(- dcol);
- for (def::coord row = _drow; row <= drow; ++row)
- for (def::coord col = _dcol; col <= dcol; ++col)
- if (values[row + drow][col + dcol])
- win.insert(row, col);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ template <unsigned R, unsigned C>
+ void
+ from_to_(const bool (&values)[R][C], window2d& win)
+ {
+ mlc_bool(R % 2 == 1)::check();
+ mlc_bool(C % 2 == 1)::check();
+ win.clear();
+ const def::coord
+ drow = static_cast<def::coord>(R / 2),
+ _drow = static_cast<def::coord>(- drow),
+ dcol = static_cast<def::coord>(C / 2),
+ _dcol = static_cast<def::coord>(- dcol);
+ for (def::coord row = _drow; row <= drow; ++row)
+ for (def::coord col = _dcol; col <= dcol; ++col)
+ if (values[row + drow][col + dcol])
+ win.insert(row, col);
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/alias/window3d.hh b/milena/mln/core/alias/window3d.hh
index 108ea4e..6a29c06 100644
--- a/milena/mln/core/alias/window3d.hh
+++ b/milena/mln/core/alias/window3d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -97,19 +98,9 @@ namespace mln
const window3d& win_c8p_3d();
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <unsigned M>
- void from_to_(bool const (&values)[M], window3d& win);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: bool[] -> window3d
+ template <unsigned M>
+ void from_to_(bool const (&values)[M], window3d& win);
@@ -151,30 +142,23 @@ namespace mln
return it;
}
- namespace convert
- {
- namespace over_load
- {
+ // Conversion
- template <unsigned M>
- void
- from_to_(bool const (&values)[M], window3d& win)
- {
- const int h = unsigned(std::pow(float(M), float(1. / 3.))) / 2;
- mln_precondition((2 * h + 1) * (2 * h + 1) * (2 * h + 1) == M);
- win.clear();
- unsigned i = 0;
- for (int sli = - h; sli <= h; ++sli)
- for (int row = - h; row <= h; ++row)
- for (int col = - h; col <= h; ++col)
- if (values[i++])
- win.insert(sli, row, col);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ template <unsigned M>
+ void
+ from_to_(bool const (&values)[M], window3d& win)
+ {
+ const int h = unsigned(std::pow(float(M), float(1. / 3.))) / 2;
+ mln_precondition((2 * h + 1) * (2 * h + 1) * (2 * h + 1) == M);
+ win.clear();
+ unsigned i = 0;
+ for (int sli = - h; sli <= h; ++sli)
+ for (int row = - h; row <= h; ++row)
+ for (int col = - h; col <= h; ++col)
+ if (values[i++])
+ win.insert(sli, row, col);
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/concept/accumulator.hh
b/milena/mln/core/concept/accumulator.hh
index fc39314..2b68cbf 100644
--- a/milena/mln/core/concept/accumulator.hh
+++ b/milena/mln/core/concept/accumulator.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -39,25 +40,6 @@
namespace mln
{
- // Forward declaration.
- template <typename E> struct Accumulator;
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename A>
- void
- from_to_(const Accumulator<A>& from, mln_result(A)& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
// Accumulator category flag type.
template <>
struct Accumulator<void>
@@ -117,39 +99,19 @@ namespace mln
template <typename T>
void take_n_times_(unsigned n, const T& t);
-
+
protected:
Accumulator();
};
-# ifndef MLN_INCLUDE_ONLY
-
-
- // convert::from_to_
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename A>
- void
- from_to_(const Accumulator<A>& from_, mln_result(A)& to)
- {
- const A& from = exact(from_);
- if (from.is_valid())
- to = from.to_result();
- else
- to = mln_result(A)();
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: Accumulator -> mln_result(A)
+ template <typename A>
+ void
+ from_to_(const Accumulator<A>& from, mln_result(A)& to);
+# ifndef MLN_INCLUDE_ONLY
// Accumulator<E>
@@ -234,6 +196,21 @@ namespace mln
exact(this)->take(t);
}
+
+ // Conversions
+
+ template <typename A>
+ void
+ from_to_(const Accumulator<A>& from_, mln_result(A)& to)
+ {
+ const A& from = exact(from_);
+ if (from.is_valid())
+ to = from.to_result();
+ else
+ to = mln_result(A)();
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/core/concept/gdpoint.hh b/milena/mln/core/concept/gdpoint.hh
index c5b0bbd..b79af69 100644
--- a/milena/mln/core/concept/gdpoint.hh
+++ b/milena/mln/core/concept/gdpoint.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -133,28 +134,10 @@ namespace mln
operator*(const Gdpoint<D>& lhs, const value::Scalar<S>& rhs);
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename D>
- void
- from_to_(const Gdpoint<D>& from, mln_site(D)& to);
-
-// template <typename D, unsigned n, typename T>
-// void
-// from_to_(const Gdpoint<D>& from, algebra::vec<n,T>& to);
-
-// template <unsigned n, typename T, typename D>
-// void
-// from_to_(const algebra::vec<n,T>& from, Gdpoint<D>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: gdpoint -> mln_site
+ template <typename D>
+ void
+ from_to_(const Gdpoint<D>& from, mln_site(D)& to);
# ifndef MLN_INCLUDE_ONLY
@@ -219,26 +202,18 @@ namespace mln
}
- namespace convert
- {
+ // Conversions
- namespace over_load
- {
-
- template <typename D>
- inline
- void
- from_to_(const Gdpoint<D>& dp_, mln_site(D)& p)
- {
- enum { n = D::dim };
- const D& dp = exact(dp_);
- for (unsigned i = 0; i < n; ++i)
- p[i] = dp[i];
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ template <typename D>
+ inline
+ void
+ from_to_(const Gdpoint<D>& dp_, mln_site(D)& p)
+ {
+ enum { n = D::dim };
+ const D& dp = exact(dp_);
+ for (unsigned i = 0; i < n; ++i)
+ p[i] = dp[i];
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/concept/gpoint.hh b/milena/mln/core/concept/gpoint.hh
index f9bba11..d51b2f4 100644
--- a/milena/mln/core/concept/gpoint.hh
+++ b/milena/mln/core/concept/gpoint.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -127,30 +128,6 @@ namespace mln
};
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename P>
- void
- from_to_(const Gpoint<P>& from, mln_delta(P)& to);
-
- template <typename P, unsigned n, typename T>
- void
- from_to_(const Gpoint<P>& from, algebra::vec<n,T>& to);
-
- template <unsigned n, typename T, typename P>
- void
- from_to_(const algebra::vec<n,T>& from, Gpoint<P>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
/// Equality comparison between a couple of grid point \p lhs
/// and \p rhs.
/*!
@@ -288,6 +265,17 @@ namespace mln
// FIXME : add operators and traits?
+ /// \internal Conversion: gpoint -> mln_delta
+ template <typename P>
+ void
+ from_to_(const Gpoint<P>& from, mln_delta(P)& to);
+
+ /// \internal Conversion: gpoint -> algebra::vec
+ template <typename P, unsigned n, typename T>
+ void
+ from_to_(const Gpoint<P>& from, algebra::vec<n,T>& to);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -302,62 +290,9 @@ namespace mln
typedef mln_delta(E) delta;
typedef mln_vec(E) vec;
vec (E::*m)() const = & E::to_vec;
- m = 0;
+ (void) m;
}
-
- // convert::from_to_
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // Gpoint -> delta
- template <typename P>
- inline
- void
- from_to_(const Gpoint<P>& p_, mln_delta(P)& dp)
- {
- // Instead of "dp.to_vec() = exact(p).to_vec();" that
- // does not compile (cause to_vec returns const), we
- // have:
- enum { n = P::dim };
- const P& p = exact(p_);
- for (unsigned i = 0; i < n; ++i)
- dp[i] = p[i];
- }
-
- // Gpoint -> algebra::vec.
- template <typename P, unsigned n, typename T>
- inline
- void
- from_to_(const Gpoint<P>& from_, algebra::vec<n,T>& to)
- {
- mlc_bool(n == P::dim)::check();
- const P& from = exact(from_);
- for (unsigned i = 0; i < n; ++i)
- to[i] = static_cast< T >(from[i]); // FIXME: cast -> best effort...
- }
-
- // algebra::vec -> Gpoint.
- template <unsigned n, typename T, typename P>
- inline
- void
- from_to_(const algebra::vec<n,T>& from, Gpoint<P>& to_)
- {
- mlc_bool(P::dim == n)::check();
- P& to = exact(to_);
- for (unsigned i = 0; i < n; ++i)
- to[i] = static_cast< typename P::coord >(from[i]); // FIXME: cast -> best
effort...
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
// Operators.
template <typename L, typename R>
@@ -453,6 +388,36 @@ namespace mln
return tmp;
}
+
+
+ // Conversions
+
+ template <typename P>
+ inline
+ void
+ from_to_(const Gpoint<P>& p_, mln_delta(P)& dp)
+ {
+ // Instead of "dp.to_vec() = exact(p).to_vec();" that
+ // does not compile (cause to_vec returns const), we
+ // have:
+ enum { n = P::dim };
+ const P& p = exact(p_);
+ for (unsigned i = 0; i < n; ++i)
+ dp[i] = p[i];
+ }
+
+ template <typename P, unsigned n, typename T>
+ inline
+ void
+ from_to_(const Gpoint<P>& from_, algebra::vec<n,T>& to)
+ {
+ mlc_bool(n == P::dim)::check();
+ const P& from = exact(from_);
+ for (unsigned i = 0; i < n; ++i)
+ to[i] = static_cast< T >(from[i]); // FIXME: cast -> best effort...
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/core/concept/image.hh b/milena/mln/core/concept/image.hh
index 8c620bc..e1da969 100644
--- a/milena/mln/core/concept/image.hh
+++ b/milena/mln/core/concept/image.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -55,6 +55,7 @@ namespace mln
// Forward declarations.
template <typename E> struct Image;
template <typename E> struct Literal;
+ template <typename D, typename W> struct w_window;
// Image category flag type.
@@ -121,20 +122,15 @@ namespace mln
};
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename V, unsigned S, typename I>
- void
- from_to_(const V (&values)[S], Image<I>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: image -> w_window
+ template <typename I, typename D, typename W>
+ void
+ from_to_(const Image<I>& from, w_window<D,W>& to);
+ /// \internal Conversion: values[] -> image
+ template <typename V, unsigned S, typename I>
+ void
+ from_to_(const V (&values)[S], Image<I>& to);
# ifndef MLN_INCLUDE_ONLY
@@ -268,43 +264,48 @@ namespace mln
}
- namespace convert
+ template <typename I, typename D, typename W>
+ void
+ from_to_(const Image<I>& from_, w_window<D,W>& to)
{
+ mlc_converts_to(mln_deduce(I, psite, delta), D)::check();
+ mlc_converts_to(mln_value(I), W)::check();
+ const I& ima = exact(from_);
+ to.clear();
+ mln_value(I) zero = literal::zero;
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ if (ima(p) != zero)
+ to.insert(ima(p), convert::to<D>(p));
+ }
- namespace over_load
- {
-
- template <typename V, unsigned S, typename I>
- void
- from_to_(const V (&values)[S], Image<I>& to_)
- {
- mlc_bool(S != 0)::check();
- mlc_converts_to(V, mln_value(I))::check();
- typedef mln_site(I) P;
- enum { d = P::dim,
- s = mlc_root(d, S)::value };
- metal::bool_<(mlc_pow_int(s, d) == S)>::check();
-
- I& to = exact(to_);
- mln_precondition(! to.is_valid());
-
- box<P> b(all_to(0), all_to(s - 1));
- to.init_(b);
- mln_fwd_piter(box<P>) p(b);
- unsigned i = 0;
- for_all(p)
- to(p) = values[i++];
- }
-
- } // end of namespace mln::convert::over_load
+ template <typename V, unsigned S, typename I>
+ void
+ from_to_(const V (&values)[S], Image<I>& to_)
+ {
+ mlc_bool(S != 0)::check();
+ mlc_converts_to(V, mln_value(I))::check();
+ typedef mln_site(I) P;
+ enum { d = P::dim,
+ s = mlc_root(d, S)::value };
+ metal::bool_<(mlc_pow_int(s, d) == S)>::check();
+
+ I& to = exact(to_);
+ mln_precondition(! to.is_valid());
+
+ box<P> b(all_to(0), all_to(s - 1));
+ to.init_(b);
+ mln_fwd_piter(box<P>) p(b);
+ unsigned i = 0;
+ for_all(p)
+ to(p) = values[i++];
+ }
- } // end of namespace mln::convert
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
-
# include <mln/core/routine/initialize.hh>
diff --git a/milena/mln/core/concept/proxy.hh b/milena/mln/core/concept/proxy.hh
index f8cd9b4..43aed15 100644
--- a/milena/mln/core/concept/proxy.hh
+++ b/milena/mln/core/concept/proxy.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -143,16 +144,6 @@ namespace mln
template <typename E> struct Literal;
- namespace convert
- {
-
- template <typename F, typename T>
- void from_to(const F& from, T& to);
-
- }
-
-
-
namespace trait
{
@@ -195,7 +186,7 @@ namespace mln
// Disambiguate between (Proxy Op Object) and (Object Op Literal).
-
+
template < template <class, class> class Op,
typename P, typename L >
struct set_binary_< Op, mln::Proxy, P, mln::Literal, L >
@@ -238,27 +229,16 @@ namespace mln
typedef q_subject;
q_subject subj_();
*/
-
+
protected:
Proxy();
};
- // convert::from_to_
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename P, typename T>
- void
- from_to_(const Proxy<P>& from, T& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ /// \internal Conversion: proxy -> T
+ template <typename P, typename T>
+ void
+ from_to_(const Proxy<P>& from, T& to);
@@ -281,7 +261,7 @@ namespace mln
template <typename T>
typename mln::internal::unproxy_rec_<const T>::ret
unproxy_rec(const T& t);
-
+
// operator <<
@@ -331,29 +311,19 @@ namespace mln
typedef typename E::q_subject q_subject;
q_subject (E::*m_)() = & E::subj_;
- m_ = 0;
+ (void) m_;
}
- // convert::from_to_
+ // Conversion
- namespace convert
+ template <typename P, typename T>
+ void
+ from_to_(const Proxy<P>& from, T& to)
{
-
- namespace over_load
- {
-
- template <typename P, typename T>
- void
- from_to_(const Proxy<P>& from, T& to)
- {
- convert::from_to(exact(from).unproxy_(), to);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ convert::from_to(exact(from).unproxy_(), to);
+ }
// unproxy_rec
diff --git a/milena/mln/core/concept/site_set.hh b/milena/mln/core/concept/site_set.hh
index f0f2864..4979357 100644
--- a/milena/mln/core/concept/site_set.hh
+++ b/milena/mln/core/concept/site_set.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -86,26 +87,26 @@ namespace mln
};
+ /// \internal Conversion: site_set -> std::set
+ template <typename S, typename P, typename C_>
+ void
+ from_to_(const Site_Set<S>& from, std::set<P,C_>& to);
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename S, typename P, typename C_>
- void
- from_to_(const Site_Set<S>& from, std::set<P,C_>& to);
+} // end of namespace mln
- template <typename P, typename C_, typename S>
- void
- from_to_(const std::set<P,C_>& from, Site_Set<S>& to);
+namespace std
+{
- } // end of namespace mln::convert::over_load
+ /// \internal Conversion: std::set -> site_set
+ template <typename P, typename C_, typename S>
+ void
+ from_to_(const set<P,C_>& from, mln::Site_Set<S>& to);
- } // end of namespace mln::convert
+} // end of namespace std
+namespace mln
+{
namespace trait
{
@@ -124,49 +125,12 @@ namespace mln
} // end of namespace mln::trait
-
+} // end of namespace mln
# ifndef MLN_INCLUDE_ONLY
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename S, typename P, typename C_>
- inline
- void
- from_to_(const Site_Set<S>& from_, std::set<P,C_>& to)
- {
- mlc_converts_to(mln_psite(S), P)::check();
- const S& from = exact(from_);
- to.clear();
- mln_piter(S) p(from);
- for_all(p)
- to.insert(p);
- }
-
-
- template <typename P, typename C_, typename S>
- inline
- void
- from_to_(const std::set<P,C_>& from, Site_Set<S>& to_)
- {
- mlc_converts_to(P, mln_i_element(S))::check();
- S& to = exact(to_);
- to.clear();
- for (typename std::set<P>::const_iterator i = from.begin();
- i != from.end();
- ++i)
- to.insert(*i);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
+namespace mln
+{
namespace internal
{
@@ -292,10 +256,46 @@ namespace mln
internal::site_set_contents_check< mln_trait_site_set_contents(E), E >::run();
}
-# endif // ! MLN_INCLUDE_ONLY
+
+ // Conversion
+
+ template <typename S, typename P, typename C_>
+ inline
+ void
+ from_to_(const Site_Set<S>& from_, std::set<P,C_>& to)
+ {
+ mlc_converts_to(mln_psite(S), P)::check();
+ const S& from = exact(from_);
+ to.clear();
+ mln_piter(S) p(from);
+ for_all(p)
+ to.insert(p);
+ }
} // end of namespace mln
+namespace std
+{
+
+ template <typename P, typename C_, typename S>
+ inline
+ void
+ from_to_(const set<P,C_>& from, mln::Site_Set<S>& to_)
+ {
+ mlc_converts_to(P, mln_i_element(S))::check();
+ S& to = exact(to_);
+ to.clear();
+ for (typename set<P>::const_iterator i = from.begin();
+ i != from.end();
+ ++i)
+ to.insert(*i);
+ }
+
+} // end of namespace std
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
# include <mln/core/site_set/operators.hh>
# include <mln/core/routine/ops.hh>
diff --git a/milena/mln/core/concept/window.hh b/milena/mln/core/concept/window.hh
index cde8550..26f13e3 100644
--- a/milena/mln/core/concept/window.hh
+++ b/milena/mln/core/concept/window.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -39,8 +40,7 @@
# include <mln/trait/windows.hh>
# include <mln/core/site_set/p_array.hh>
-# include <mln/core/internal/geom_bbox.hh> // For use in convert::from_to.
-# include <mln/convert/from_to.hxx>
+# include <mln/core/internal/geom_bbox.hh> // For use in from_to_.
# include <mln/util/array.hh>
@@ -111,34 +111,24 @@ namespace mln
std::ostream& operator<<(std::ostream& ostr, const Window<W>&
win);
+ /// \internal Conversion: window -> image
+ template <typename W, typename I>
+ void
+ from_to_(const Window<W>& from, Image<I>& to);
+
+
// FIXME: Move as a method of Image?
template <typename I, typename W>
util::array<int>
offsets_wrt(const Image<I>& ima, const Window<W>& win);
-
+
template <typename I, typename W>
util::array<int>
positive_offsets_wrt(const Image<I>& ima, const Window<W>& win);
-
+
template <typename I, typename W>
util::array<int>
negative_offsets_wrt(const Image<I>& ima, const Window<W>& win);
-
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename W, typename I>
- void
- from_to_(const Window<W>& from, Image<I>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
@@ -304,7 +294,7 @@ namespace mln
}
ostr << " ]";
}
-
+
} // end of namespace mln::internal
template <typename W>
@@ -322,6 +312,35 @@ namespace mln
}
+ template <typename W, typename I>
+ void
+ from_to_(const Window<W>& win_, Image<I>& ima_)
+ {
+ mln_is_simple_window(W)::check();
+ typedef mln_psite(I) P;
+ mlc_converts_to(mln_dpsite(W), mln_delta(P))::check();
+ mlc_equal(mln_value(I), bool)::check();
+
+ const W& win = exact(win_);
+ I& ima = exact(ima_);
+
+ mln_precondition(win.is_valid());
+ mln_precondition(! ima.is_valid());
+
+ // Hack (below) to avoid circular dependency.
+ ima.init_(mln::internal::geom_bbox(win));
+ {
+ // data::fill(ima, false) is:
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ ima(p) = false;
+ }
+ unsigned n = win.size();
+ for (unsigned i = 0; i < n; ++i)
+ ima(convert::to<P>(win.dp(i))) = true;
+ }
+
+
template <typename I, typename W>
inline
util::array<int>
@@ -336,7 +355,7 @@ namespace mln
util::array<int> arr;
unsigned n = win.size();
-
+
for (unsigned i = 0; i < n; ++i)
arr.append(ima.delta_index(win.dp(i)));
@@ -358,7 +377,7 @@ namespace mln
util::array<int> arr;
unsigned n = win.size();
-
+
for (unsigned i = 0; i < n; ++i)
{
int offset = ima.delta_index(win.dp(i));
@@ -384,7 +403,7 @@ namespace mln
util::array<int> arr;
unsigned n = win.size();
-
+
for (unsigned i = 0; i < n; ++i)
{
int offset = ima.delta_index(win.dp(i));
@@ -395,45 +414,6 @@ namespace mln
return arr;
}
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename W, typename I>
- void
- from_to_(const Window<W>& win_, Image<I>& ima_)
- {
- mln_is_simple_window(W)::check();
- typedef mln_psite(I) P;
- mlc_converts_to(mln_dpsite(W), mln_delta(P))::check();
- mlc_equal(mln_value(I), bool)::check();
-
- const W& win = exact(win_);
- I& ima = exact(ima_);
-
- mln_precondition(win.is_valid());
- mln_precondition(! ima.is_valid());
-
- // Hack (below) to avoid circular dependency.
- ima.init_(mln::internal::geom_bbox(win));
- {
- // data::fill(ima, false) is:
- mln_piter(I) p(ima.domain());
- for_all(p)
- ima(p) = false;
- }
- unsigned n = win.size();
- for (unsigned i = 0; i < n; ++i)
- ima(convert::to<P>(win.dp(i))) = true;
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/core/dpoint.hh b/milena/mln/core/dpoint.hh
index f4d603e..0e5c0ef 100644
--- a/milena/mln/core/dpoint.hh
+++ b/milena/mln/core/dpoint.hh
@@ -33,7 +33,6 @@
# include <mln/core/def/coord.hh>
# include <mln/core/concept/gdpoint.hh>
# include <mln/core/internal/coord_impl.hh>
-# include <mln/fun/i2v/all.hh>
# include <mln/algebra/vec.hh>
# include <mln/metal/converts_to.hh>
diff --git a/milena/mln/core/image/graph_window_if_piter.hh
b/milena/mln/core/image/graph_window_if_piter.hh
index 068fbdb..1060f15 100644
--- a/milena/mln/core/image/graph_window_if_piter.hh
+++ b/milena/mln/core/image/graph_window_if_piter.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -30,6 +31,7 @@
///
/// \brief Definition of a site iterator on a custom graph window.
+# include <mln/core/concept/window.hh>
# include <mln/core/internal/is_masked_impl_selector.hh>
# include <mln/core/internal/site_relative_iterator_base.hh>
diff --git a/milena/mln/core/image/image1d.hh b/milena/mln/core/image/image1d.hh
index 6d10aa5..53e8611 100644
--- a/milena/mln/core/image/image1d.hh
+++ b/milena/mln/core/image/image1d.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -122,27 +122,6 @@ namespace mln
template <typename T> struct image1d;
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // histo::array -> image1d.
- template <typename V, typename T>
- void from_to_(const histo::array<V>& from, image1d<T>& to);
-
- // util::array -> image1d.
- template <typename V, typename T>
- void from_to_(const util::array<V>& from, image1d<T>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
/// Basic 1D image class.
///
/// The parameter \c T is the type of pixel values. This image class
@@ -578,46 +557,6 @@ namespace mln
namespace mln
{
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // histo::array -> image1d.
- template <typename V, typename T>
- inline
- void
- from_to_(const histo::array<V>& from, image1d<T>& to)
- {
- // FIXME: The code should looks like:
-
-// box1d b(point1d(mln_min(V)), point1d(mln_max(V)));
-// ima.init_(b, 0);
-// for_all(v)
-// from_to(h(v), ima.at_( index_of(v) ));
- to.init_(make::box1d(from.nvalues()));
- for (unsigned i = 0; i < from.nvalues(); ++i)
- from_to(from[i], to(point1d(i)));
- }
-
- // util::array -> image1d.
- template <typename V, typename T>
- inline
- void
- from_to_(const util::array<V>& from, image1d<T>& to)
- {
- to.init_(make::box1d(from.nelements()));
- for (unsigned i = 0; i < from.nelements(); ++i)
- from_to(from[i], to(point1d(i)));
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace trait
{
diff --git a/milena/mln/core/internal/neighborhood_base.hh
b/milena/mln/core/internal/neighborhood_base.hh
index f1765c9..f96b8f4 100644
--- a/milena/mln/core/internal/neighborhood_base.hh
+++ b/milena/mln/core/internal/neighborhood_base.hh
@@ -42,6 +42,7 @@ namespace mln
// Forward declaration.
+ template <typename W> class neighb;
namespace win
{
template <unsigned n, typename W, typename F>
@@ -66,25 +67,25 @@ namespace mln
/// Give the foreground neighborhood in the case of a dual
/// neighborhood. For instance, with (object:c4, background:c8),
/// the result is c4.
-
+
neighb<W> foreground() const
{
W win = internal::force_exact<E>(*this).win().window_(1); // True, so object.
neighb<W> nbh(win);
return nbh;
}
-
+
/// Give the background neighborhood in the case of a dual
/// neighborhood. For instance, with (object:c4, background:c8),
/// the result is c8.
-
+
neighb<W> background() const
{
W win = internal::force_exact<E>(*this).win().window_(0); // False, so
background.
neighb<W> nbh(win);
return nbh;
}
-
+
};
diff --git a/milena/mln/core/mixed_neighb.hh b/milena/mln/core/mixed_neighb.hh
index 7789aba..2c89131 100644
--- a/milena/mln/core/mixed_neighb.hh
+++ b/milena/mln/core/mixed_neighb.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -50,27 +51,6 @@ namespace mln
// Forward declarations.
template <typename W> class mixed_neighb_fwd_niter;
template <typename W> class mixed_neighb_bkd_niter;
- template <typename W> class mixed_neighb;
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename W>
- void
- from_to_(const mln::mixed_neighb<W>& from, W& to);
-
- template <typename W>
- void
- from_to_(const W& from, mln::mixed_neighb<W>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
/// Adapter class from window to neighborhood.
@@ -103,6 +83,18 @@ namespace mln
};
+ /// \internal Conversion: mixed_neighb<W> -> W
+ template <typename W>
+ void
+ from_to_(const mln::mixed_neighb<W>& from, W& to);
+
+ /// \internal Conversion: mixed_neighb<W> -> W
+ template <typename W>
+ void
+ from_to_(const W& from, mln::mixed_neighb<W>& to);
+
+
+
// mixed_neighb_fwd_niter<W>
template <typename W>
@@ -167,33 +159,21 @@ namespace mln
}
- // mln::convert::from_to
+ // Conversion
- namespace convert
+ template <typename W>
+ void
+ from_to_(const mln::mixed_neighb<W>& from, W& to)
{
+ to = from.win();
+ }
- namespace over_load
- {
-
- template <typename W>
- void
- from_to_(const mln::mixed_neighb<W>& from, W& to)
- {
- to = from.win();
- }
-
- template <typename W>
- void
- from_to_(const W& from, mln::mixed_neighb<W>& to)
- {
- to.change_window(from);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
+ template <typename W>
+ void
+ from_to_(const W& from, mln::mixed_neighb<W>& to)
+ {
+ to.change_window(from);
+ }
// mixed_neighb_fwd_niter<W>
diff --git a/milena/mln/core/neighb.hh b/milena/mln/core/neighb.hh
index db31bea..4f348b1 100644
--- a/milena/mln/core/neighb.hh
+++ b/milena/mln/core/neighb.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -47,26 +47,6 @@ namespace mln
// Forward declarations.
template <typename W> class neighb_fwd_niter;
template <typename W> class neighb_bkd_niter;
- template <typename W> class neighb;
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename W>
- void
- from_to_(const mln::neighb<W>& from, W& to);
-
- template <typename W>
- void
- from_to_(const W& from, mln::neighb<W>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
@@ -99,6 +79,17 @@ namespace mln
};
+ /// \internal Conversions: neighb<W> -> W
+ template <typename W>
+ void
+ from_to_(const mln::neighb<W>& from, W& to);
+
+ /// \internal Conversions: W -> neighb<W>
+ template <typename W>
+ void
+ from_to_(const W& from, mln::neighb<W>& to);
+
+
// neighb_fwd_niter<W>
template <typename W>
@@ -159,35 +150,6 @@ namespace mln
}
- // mln::convert::from_to
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename W>
- void
- from_to_(const mln::neighb<W>& from, W& to)
- {
- to = from.win();
- }
-
- template <typename W>
- void
- from_to_(const W& from, mln::neighb<W>& to)
- {
- to.change_window(from);
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
-
// neighb_fwd_niter<W>
template <typename W>
@@ -224,6 +186,20 @@ namespace mln
this->i_.init_(nbh.win(), c);
}
+ template <typename W>
+ void
+ from_to_(const neighb<W>& from, W& to)
+ {
+ to = from.win();
+ }
+
+ template <typename W>
+ void
+ from_to_(const W& from, neighb<W>& to)
+ {
+ to.change_window(from);
+ }
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/point.hh b/milena/mln/core/point.hh
index d415cf8..03afe57 100644
--- a/milena/mln/core/point.hh
+++ b/milena/mln/core/point.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 EPITA Research and
+// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 EPITA Research and
// Development Laboratory (LRDE)
//
// This file is part of Olena.
@@ -41,7 +41,6 @@
# include <mln/core/concept/proxy.hh>
# include <mln/core/concept/gpoint.hh>
# include <mln/core/internal/coord_impl.hh>
-# include <mln/fun/i2v/all_to.hh>
# include <mln/metal/bool.hh>
# include <mln/metal/is_not.hh>
@@ -65,29 +64,6 @@ namespace mln
/// \}
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename G, typename C1, typename C2>
- void from_to_(const point<G,C1>& from, point<G,C2>& to);
-
- template <unsigned n, typename C1, typename G, typename C2>
- void
- from_to_(const mln::algebra::vec<n,C1>& from, point<G,C2>&
to);
-
- template <unsigned n, typename C1, typename G>
- void
- from_to_(const mln::algebra::vec<n,C1>& from, point<G,C1>&
to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
namespace internal
{
// This is a hack so that g++-2.95 can compile the method
@@ -224,6 +200,12 @@ namespace mln
mln::algebra::vec<G::dim, C> coord_;
};
+
+ /// \internal Conversion: point -> point
+ template <typename G, typename C1, typename C2>
+ void from_to_(const point<G,C1>& from, point<G,C2>& to);
+
+
namespace internal
{
@@ -260,126 +242,6 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- namespace internal
- {
-
- template <typename C, typename C2>
- inline
- C
- convert_data_(metal::bool_<false>, const C2& v)
- {
- return static_cast<C>(v);
- }
-
- template <typename C, typename C2>
- inline
- C
- convert_data_(metal::bool_<true>, const C2& v)
- {
- return static_cast<C>(round(v));
- }
-
- template <typename C, typename C2>
- inline
- C
- convert_data(const C2& v)
- {
- // If (C != float && C != double) && (C2 == float || C2 == double)
- // => We want to round the value.
- // Otherwise we can just statically cast.
- //
- return convert_data_<C>(
- typename mlc_and(
- mlc_and(mlc_is_not(C,float),
- mlc_is_not(C,double)),
- mlc_or(mlc_is(C2,float),
- mlc_is(C2, double)))::eval(), v);
- }
-
-
-
- } // end of namespace mln::internal
-
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename G, typename C1, typename C2>
- inline
- void
- from_to_(const point<G,C1>& from, point<G,C2>& to)
- {
- mlc_converts_to(C1,C2)::check();
- enum { dim = G::dim };
-
- for (unsigned i = 0; i < dim; ++i)
- to[i] = mln::internal::convert_data<C2>(from[i]);
- }
-
-
- template <unsigned n, typename C1, typename G, typename C2>
- inline
- void
- from_to_(const mln::algebra::vec<n,C1>& from, point<G,C2>& to)
- {
- mlc_converts_to(C1, C2)::check();
- enum { dim = G::dim };
- mlc_bool(G::dim == n)::check();
-
- unsigned j = 0;
- for (unsigned i = dim - 2; i < dim; ++i)
- to[i] = mln::internal::convert_data<C2>(from[j++]);
- for (unsigned i = 2; i < dim; ++i, ++j)
- to[i-j] = mln::internal::convert_data<C2>(from[j]);
- }
-
- template <typename C1, typename G, typename C2>
- inline
- void
- from_to_(const mln::algebra::vec<1,C1>& from, point<G,C2>& to)
- {
- mlc_converts_to(C1, C2)::check();
- enum { dim = G::dim };
- mlc_bool(G::dim == 1)::check();
-
- to[0] = mln::internal::convert_data<C2>(from[0]);
- }
-
- template <unsigned n, typename C1, typename G>
- inline
- void
- from_to_(const mln::algebra::vec<n,C1>& from, point<G,C1>& to)
- {
- enum { dim = G::dim };
- mlc_bool(G::dim == n)::check();
-
- unsigned j = 0;
- for (unsigned i = dim - 2; i < dim; ++i)
- to[i] = from[j++];
- for (unsigned i = 2; i < dim; ++i, ++j)
- to[i-j] = from[j];
- }
-
- template <typename C1, typename G>
- inline
- void
- from_to_(const mln::algebra::vec<1,C1>& from, point<G,C1>& to)
- {
- enum { dim = G::dim };
- mlc_bool(G::dim == 1)::check();
-
- to[0] = from[0];
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
template <typename G, typename C>
inline
const C& point<G,C>::operator[](unsigned i) const
@@ -426,7 +288,7 @@ namespace mln
inline
point<G,C>::point(const mln::algebra::vec<dim,C2>& v)
{
- convert::over_load::from_to_(v, *this);
+ from_to_(v, *this);
}
@@ -434,7 +296,7 @@ namespace mln
inline
point<G,C>::point(const mln::algebra::vec<dim,C>& v)
{
- convert::over_load::from_to_(v, *this);
+ from_to_(v, *this);
}
@@ -638,6 +500,22 @@ namespace mln
return coord_;
}
+
+ // Conversions
+
+ template <typename G, typename C1, typename C2>
+ inline
+ void
+ from_to_(const point<G,C1>& from, point<G,C2>& to)
+ {
+ mlc_converts_to(C1,C2)::check();
+ enum { dim = G::dim };
+
+ for (unsigned i = 0; i < dim; ++i)
+ to[i] = mln::internal::convert_data<C2>(from[i]);
+ }
+
+
namespace internal
{
diff --git a/milena/mln/core/site_set/operators.hh
b/milena/mln/core/site_set/operators.hh
index 89637ad..9cf2509 100644
--- a/milena/mln/core/site_set/operators.hh
+++ b/milena/mln/core/site_set/operators.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -121,8 +122,8 @@ namespace mln
typedef mln_site(Sl) P;
mlc_converts_to(mln_psite(Sr), P)::check();
std::set< P, util::ord<P> > sl, sr, sd;
- convert::over_load::from_to_(lhs, sl);
- convert::over_load::from_to_(rhs, sr);
+ from_to_(lhs, sl);
+ from_to_(rhs, sr);
std::set_symmetric_difference(sl.begin(), sl.end(),
sr.begin(), sr.end(),
std::inserter(sd, sd.begin()),
@@ -136,7 +137,7 @@ namespace mln
to_std_set(const Site_Set<S>& s)
{
std::set< mln_site(S), util::ord<mln_site(S)> > std_s;
- convert::over_load::from_to_(s, std_s);
+ from_to_(s, std_s);
return std_s;
}
@@ -148,8 +149,8 @@ namespace mln
typedef mln_site(Sl) P;
mlc_converts_to(mln_psite(Sr), P)::check();
std::set< P, util::ord<P> > sl, sr;
- convert::over_load::from_to_(lhs, sl);
- convert::over_load::from_to_(rhs, sr);
+ from_to_(lhs, sl);
+ from_to_(rhs, sr);
return std::includes(sr.begin(), sr.end(),
sl.begin(), sl.end(),
util::ord<P>());
diff --git a/milena/mln/core/site_set/p_centered.hh
b/milena/mln/core/site_set/p_centered.hh
index 4c4efd9..cf2bd5c 100644
--- a/milena/mln/core/site_set/p_centered.hh
+++ b/milena/mln/core/site_set/p_centered.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -34,7 +35,7 @@
/// \todo Add the bkd iter.
/// \todo Code is_valid() and change_target() for the site set.
-
+# include <mln/core/concept/window.hh>
# include <mln/core/internal/site_set_base.hh>
# include <mln/core/internal/site_set_iterator_base.hh>
diff --git a/milena/mln/core/site_set/p_vaccess.hh
b/milena/mln/core/site_set/p_vaccess.hh
index 677ae2b..d7a753c 100644
--- a/milena/mln/core/site_set/p_vaccess.hh
+++ b/milena/mln/core/site_set/p_vaccess.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,6 +32,7 @@
/// \todo Fix the FIXMEs.
# include <utility>
+# include <vector>
# include <mln/core/concept/site_set.hh>
# include <mln/core/site_set/p_double.hh>
# include <mln/core/internal/site_set_base.hh>
diff --git a/milena/mln/core/w_window.hh b/milena/mln/core/w_window.hh
index d463697..1022dd5 100644
--- a/milena/mln/core/w_window.hh
+++ b/milena/mln/core/w_window.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -55,29 +56,6 @@ namespace mln
template <typename It, typename W> struct with_w_;
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename I, typename D, typename W>
- void
- from_to_(const Image<I>& from, w_window<D,W>& to);
-
- template <typename D, typename W, typename I>
- void
- from_to_(const w_window<D,W>& from, Image<I>& to);
-
- template <typename V, unsigned S, typename D, typename W>
- void
- from_to_(const V (&weight)[S], w_window<D,W>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace trait
{
@@ -164,6 +142,15 @@ namespace mln
bool operator==(const w_window<D,Wl>& lhs, const w_window<D,Wr>&
rhs);
+ /// \internal Conversions: w_window -> image
+ template <typename D, typename W, typename I>
+ void from_to_(const w_window<D,W>& from, Image<I>& to);
+
+ /// \internal Conversions: weight[] -> w_window
+ template <typename V, unsigned S, typename D, typename W>
+ void from_to_(const V (&weight)[S], w_window<D,W>& to);
+
+
/// Decorator to handle weights for iterators on window points.
template <typename It, typename W>
@@ -195,7 +182,7 @@ namespace mln
wei_(ds.weights())
{
}
-
+
template <typename It, typename W>
inline
W
@@ -312,107 +299,6 @@ namespace mln
}
- // convert::from_to_
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename I, typename D, typename W>
- void
- from_to_(const Image<I>& from_, w_window<D,W>& to)
- {
- mlc_converts_to(mln_deduce(I, psite, delta), D)::check();
- mlc_converts_to(mln_value(I), W)::check();
- const I& ima = exact(from_);
- to.clear();
- mln_value(I) zero = literal::zero;
- mln_piter(I) p(ima.domain());
- for_all(p)
- if (ima(p) != zero)
- to.insert(ima(p), convert::to<D>(p));
- }
-
- template <typename D, typename W, typename I>
- void
- from_to_(const w_window<D,W>& w_win, Image<I>& ima_)
- {
- typedef mln_site(I) P;
- mlc_converts_to(D, mln_delta(P))::check();
- mlc_converts_to(W, mln_value(I))::check();
-
- I& ima = exact(ima_);
- mln_precondition(! ima.is_valid());
- mln_precondition(w_win.is_valid());
-
- ima.init_(geom::bbox(w_win));
- {
- // data::fill(ima, literal::zero) is:
- mln_value(I) zero = literal::zero;
- mln_piter(I) p(ima.domain());
- for_all(p)
- ima(p) = zero;
- }
-
- unsigned n = w_win.size();
- for (unsigned i = 0; i < n; ++i)
- ima(convert::to<P>(w_win.dp(i))) = w_win.w(i);
- }
-
- // FIXME: Sample code (below) to generalize the code above:
-
-// template <typename W>
-// inline
-// mln_image_from(W, mln_weight(W)) to_image(const Weighted_Window<W>&
w_win_)
-// {
-// const W& w_win = exact(w_win_);
-// mln_precondition(! w_win.is_empty());
-
-// typedef mln_psite(W) P;
-// box<P> b = geom::bbox(w_win);
-// mln_image_from(W, mln_weight(W)) ima(b);
-// // Fill the image with zeros, as (weighted) windows are not
-// // necessarily box-shaped (there might be holes corresponding to
-// // null weights).
-// data::fill(ima, literal::zero);
-// P O = P::origin;
-// mln_qiter(W) q(w_win, O);
-// for_all(q)
-// ima(q) = q.w();
-// return ima;
-// }
-
- template <typename V, unsigned S, typename D, typename W>
- void
- from_to_(const V (&weight)[S], w_window<D,W>& to)
- {
- mlc_bool(S != 0)::check();
- mlc_converts_to(V, W)::check();
- enum { d = D::dim,
- s = mlc_root(d,S)::value / 2 };
- metal::bool_<(mlc_pow_int(2 * s + 1, d) == S)>::check();
- to.clear();
- typedef mln_site(D) P;
- box<P> b(all_to(-s), all_to(+s));
- mln_fwd_piter(box<P>) p(b);
- unsigned i = 0;
- V zero = literal::zero;
- for_all(p)
- {
- if (weight[i] != zero)
- to.insert(weight[i], convert::to<D>(p));
- ++i;
- }
-
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
// operators
template <typename D, typename W>
@@ -442,6 +328,59 @@ namespace mln
return true;
}
+
+ // Conversions
+
+ template <typename D, typename W, typename I>
+ void
+ from_to_(const w_window<D,W>& w_win, Image<I>& ima_)
+ {
+ typedef mln_site(I) P;
+ mlc_converts_to(D, mln_delta(P))::check();
+ mlc_converts_to(W, mln_value(I))::check();
+
+ I& ima = exact(ima_);
+ mln_precondition(! ima.is_valid());
+ mln_precondition(w_win.is_valid());
+
+ ima.init_(geom::bbox(w_win));
+ {
+ // data::fill(ima, literal::zero) is:
+ mln_value(I) zero = literal::zero;
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ ima(p) = zero;
+ }
+
+ unsigned n = w_win.size();
+ for (unsigned i = 0; i < n; ++i)
+ ima(convert::to<P>(w_win.dp(i))) = w_win.w(i);
+ }
+
+ template <typename V, unsigned S, typename D, typename W>
+ void
+ from_to_(const V (&weight)[S], w_window<D,W>& to)
+ {
+ mlc_bool(S != 0)::check();
+ mlc_converts_to(V, W)::check();
+ enum { d = D::dim,
+ s = mlc_root(d,S)::value / 2 };
+ metal::bool_<(mlc_pow_int(2 * s + 1, d) == S)>::check();
+ to.clear();
+ typedef mln_site(D) P;
+ box<P> b(all_to(-s), all_to(+s));
+ mln_fwd_piter(box<P>) p(b);
+ unsigned i = 0;
+ V zero = literal::zero;
+ for_all(p)
+ {
+ if (weight[i] != zero)
+ to.insert(weight[i], convert::to<D>(p));
+ ++i;
+ }
+
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh
index 21ddbac..a0e392a 100644
--- a/milena/mln/fun/i2v/array.hh
+++ b/milena/mln/fun/i2v/array.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -49,38 +50,9 @@ namespace mln
} // end of namespace mln::fun::i2v
} // end of namespace mln::fun
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename T>
- inline
- void
- from_to_(const util::array<T>& from, fun::i2v::array<T>& to);
-
- template <typename T, typename U>
- inline
- void
- from_to_(const util::array<T>& from, fun::i2v::array<U>& to);
-
- template <typename T>
- inline
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<T>& to);
-
- template <typename T, typename U>
- inline
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<U>& to);
-
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ namespace util {
+ template <typename T> class array;
+ }
namespace fun
@@ -158,14 +130,41 @@ namespace mln
const array<T>& a);
+ /// \internal Conversion: fun::i2v::array -> util::array
+ template <typename T1, typename T2>
+ void
+ from_to_(const fun::i2v::array<T1>& from, util::array<T2>&
to);
+
} // end of namespace mln::fun::i2v
} // end of namespace mln::fun
+} // end of namespace mln
+
+
+namespace std
+{
+
+ /// \internal Conversion: std::vectorfun::i2v::array<T> ->
fun::i2v::array<T>
+ template <typename T>
+ inline
+ void
+ from_to_(const vector<T>& from, mln::fun::i2v::array<T>& to);
+
+ /// \internal Conversion: std::vector<T> -> mln::fun::i2v::array<U>
+ template <typename T, typename U>
+ inline
+ void
+ from_to_(const vector<T>& from, mln::fun::i2v::array<U>& to);
+
+} // end of namespace std
# ifndef MLN_INCLUDE_ONLY
+namespace mln
+{
+
// Init.
template <typename T1, typename T2>
@@ -177,57 +176,6 @@ namespace mln
}
- // convert::from_to
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename T>
- inline
- void
- from_to_(const util::array<T>& from, fun::i2v::array<T>& to)
- {
- to = fun::i2v::array<T>(from);
- }
-
- template <typename T, typename U>
- inline
- void
- from_to_(const util::array<T>& from, fun::i2v::array<U>& to)
- {
- to.resize(from.nelements());
- for (unsigned i = 0; i < from.nelements(); ++i)
- to(i) = convert::to<U>(from[i]);
- }
-
- template <typename T>
- inline
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<T>& to)
- {
- to = fun::i2v::array<T>(from);
- }
-
- template <typename T, typename U>
- inline
- void
- from_to_(const std::vector<T>& from, fun::i2v::array<U>& to)
- {
- to.resize(from.nelements());
- for (unsigned i = 0; i < from.size(); ++i)
- to(i) = convert::to<U>(from[i]);
- }
-
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
/// fun::i2v::array
namespace fun
@@ -366,6 +314,18 @@ namespace mln
}
+ // Conversion
+
+ template <typename T1, typename T2>
+ void
+ from_to_(const array<T1>& from, util::array<T2>& to)
+ {
+ to.resize(from.size());
+
+ for (unsigned i = 0; i < from.size(); ++i)
+ to[i] = convert::to<T2>(from(i));
+ }
+
} // end of namespace mln::fun::i2v
} // end of namespace mln::fun
@@ -379,9 +339,31 @@ namespace mln
return tmp;
}
-# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln
+namespace std
+{
+
+ template <typename T>
+ inline
+ void
+ from_to_(const vector<T>& from, mln::fun::i2v::array<T>& to)
+ {
+ to = mln::fun::i2v::array<T>(from);
+ }
+
+ template <typename T, typename U>
+ inline
+ void
+ from_to_(const vector<T>& from, mln::fun::i2v::array<U>& to)
+ {
+ to.resize(from.nelements());
+ for (unsigned i = 0; i < from.size(); ++i)
+ to(i) = mln::convert::to<U>(from[i]);
+ }
+
+} // end of namespace std
+
+# endif // ! MLN_INCLUDE_ONLY
#endif // ! MLN_FUN_I2V_ARRAY_HH
diff --git a/milena/mln/fun/v2v/hsl_to_rgb.hh b/milena/mln/fun/v2v/hsl_to_rgb.hh
index dbedcf4..3a606d0 100644
--- a/milena/mln/fun/v2v/hsl_to_rgb.hh
+++ b/milena/mln/fun/v2v/hsl_to_rgb.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -48,14 +48,6 @@
namespace mln
{
- // Forward declarations
- namespace value
- {
- template <typename H, typename S, typename L> class hsl_;
- typedef hsl_<float, float, float> hsl_f;
- template <unsigned n> struct rgb;
- }
-
namespace fun
{
diff --git a/milena/mln/fun/v2v/rgb_to_hsl.hh b/milena/mln/fun/v2v/rgb_to_hsl.hh
index 7ec9b72..11339fd 100644
--- a/milena/mln/fun/v2v/rgb_to_hsl.hh
+++ b/milena/mln/fun/v2v/rgb_to_hsl.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -35,8 +35,6 @@
# include <mln/trait/value_.hh>
-# include <mln/value/rgb.hh>
-
namespace mln
{
diff --git a/milena/mln/histo/array.hh b/milena/mln/histo/array.hh
index 0f4ed77..b60bad3 100644
--- a/milena/mln/histo/array.hh
+++ b/milena/mln/histo/array.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -35,10 +36,17 @@
# include <mln/value/set.hh>
+// For conversion
+# include <mln/convert/from_to.hh>
+# include <mln/make/box1d.hh>
+
namespace mln
{
+ // Forward declaration
+ template <typename T> struct image1d;
+
namespace histo
{
@@ -76,8 +84,9 @@ namespace mln
template <typename T>
std::ostream& operator<<(std::ostream& ostr, const array<T>&
h);
-
-
+ /// \internal Conversion: histo::array -> image1d.
+ template <typename V, typename T>
+ void from_to_(const array<V>& from, image1d<T>& to);
# ifndef MLN_INCLUDE_ONLY
@@ -185,6 +194,25 @@ namespace mln
return ostr;
}
+
+ // Conversions
+
+ template <typename V, typename T>
+ inline
+ void
+ from_to_(const array<V>& from, image1d<T>& to)
+ {
+ // FIXME: The code should looks like:
+
+// box1d b(point1d(mln_min(V)), point1d(mln_max(V)));
+// ima.init_(b, 0);
+// for_all(v)
+// from_to(h(v), ima.at_( index_of(v) ));
+ to.init_(make::box1d(from.nvalues()));
+ for (unsigned i = 0; i < from.nvalues(); ++i)
+ convert::from_to(from[i], to(point1d(i)));
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::histo
diff --git a/milena/mln/io/magick/save.hh b/milena/mln/io/magick/save.hh
index f592059..e1acfe4 100644
--- a/milena/mln/io/magick/save.hh
+++ b/milena/mln/io/magick/save.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+// Copyright (C) 2009, 2010, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -42,12 +42,16 @@
# include <mln/metal/equal.hh>
-# include <mln/core/image/image2d.hh>
+# include <mln/core/alias/dpoint2d.hh>
+# include <mln/core/pixter2d.hh>
# include <mln/value/int_u8.hh>
# include <mln/value/rgb8.hh>
# include <mln/value/qt/rgb32.hh>
+# include <mln/geom/nrows.hh>
+# include <mln/geom/ncols.hh>
+
namespace mln
{
diff --git a/milena/mln/io/plot/save.hh b/milena/mln/io/plot/save.hh
index d217915..b16499b 100644
--- a/milena/mln/io/plot/save.hh
+++ b/milena/mln/io/plot/save.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2009, 2010, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -35,6 +35,7 @@
# include <fstream>
# include <mln/core/image/image1d.hh>
# include <mln/util/array.hh>
+# include <mln/histo/array.hh>
namespace mln
diff --git a/milena/mln/labeling/blobs_and_compute.hh
b/milena/mln/labeling/blobs_and_compute.hh
index e8f784c..744d411 100644
--- a/milena/mln/labeling/blobs_and_compute.hh
+++ b/milena/mln/labeling/blobs_and_compute.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2009, 2010, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -38,6 +38,7 @@
# include <mln/labeling/blobs.hh>
# include <mln/labeling/compute.hh>
+# include <mln/util/couple.hh>
namespace mln
{
diff --git a/milena/mln/labeling/value_and_compute.hh
b/milena/mln/labeling/value_and_compute.hh
index d93fce9..e82d8f4 100644
--- a/milena/mln/labeling/value_and_compute.hh
+++ b/milena/mln/labeling/value_and_compute.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -34,6 +35,8 @@
# include <mln/core/concept/neighborhood.hh>
# include <mln/canvas/labeling/video.hh>
# include <mln/data/fill.hh>
+# include <mln/util/array.hh>
+# include <mln/util/couple.hh>
diff --git a/milena/mln/make/w_window2d.hh b/milena/mln/make/w_window2d.hh
index 663f9ed..24e086d 100644
--- a/milena/mln/make/w_window2d.hh
+++ b/milena/mln/make/w_window2d.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -33,7 +34,7 @@
# include <mln/core/w_window.hh>
# include <mln/core/alias/dpoint2d.hh>
-# include <mln/convert/from_to.hxx>
+# include <mln/convert/from_to.hh>
namespace mln
diff --git a/milena/mln/util/array.hh b/milena/mln/util/array.hh
index c7febfe..76c05fe 100644
--- a/milena/mln/util/array.hh
+++ b/milena/mln/util/array.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -38,6 +38,7 @@
# include <iostream>
# include <algorithm>
+# include <mln/core/alias/box1d.hh>
# include <mln/core/concept/function.hh>
# include <mln/core/concept/proxy.hh>
# include <mln/core/concept/iterator.hh>
@@ -48,34 +49,14 @@
namespace mln
{
- namespace util
- {
-
- /// Forward declaration.
- template <typename T>
- class array;
-
- } // end of namespace mln::util
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename T1, typename T2>
- void
- from_to_(const util::array<T1>& from, util::array<T2>& to);
-
- template <typename T1, typename T2>
- void
- from_to_(const fun::i2v::array<T1>& from, util::array<T2>&
to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
+ // Forward declarations.
+ namespace fun {
+ namespace i2v {
+ template <typename T> class array;
+ }
+ }
+ template <typename V> struct image1d;
+ // End of forward declarations
namespace util
@@ -97,7 +78,7 @@ namespace mln
//
template <typename T>
class array
- : public fun::internal::selector_from_result_<T, array<T> >::ret
+ : public mln::fun::internal::selector_from_result_<T, array<T> >::ret
// public Function_v2v< mln::util::array<T> >
{
@@ -225,6 +206,28 @@ namespace mln
const array<T>& rhs);
+ /// \internal Conversion: array -> array
+ template <typename T1, typename T2>
+ void
+ from_to_(const array<T1>& from, array<T2>& to);
+
+ /// \internal Conversion: array<T> -> fun::i2v::array<T>
+ template <typename T>
+ inline
+ void
+ from_to_(const array<T>& from, fun::i2v::array<T>& to);
+
+ /// \internal Conversion: array<T> -> fun::i2v::array<U>
+ template <typename T, typename U>
+ inline
+ void
+ from_to_(const array<T>& from, fun::i2v::array<U>& to);
+
+ /// \internal Conversion: util::array -> image1d.
+ template <typename V, typename T>
+ void from_to_(const util::array<V>& from, image1d<T>& to);
+
+
// array_fwd_iter<T>
template <typename T>
@@ -382,40 +385,6 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- // convert::from_to_
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename T1, typename T2>
- void
- from_to_(const util::array<T1>& from, util::array<T2>& to)
- {
- to.resize(from.nelements());
-
- for (unsigned i = 0; i < from.nelements(); ++i)
- to[i] = convert::to<T2>(from[i]);
- }
-
- template <typename T1, typename T2>
- void
- from_to_(const fun::i2v::array<T1>& from, util::array<T2>& to)
- {
- to.resize(from.size());
-
- for (unsigned i = 0; i < from.size(); ++i)
- to[i] = convert::to<T2>(from(i));
- }
-
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace util
{
@@ -605,6 +574,47 @@ namespace mln
}
+ // Conversions
+
+ template <typename T1, typename T2>
+ void
+ from_to_(const array<T1>& from, array<T2>& to)
+ {
+ to.resize(from.nelements());
+
+ for (unsigned i = 0; i < from.nelements(); ++i)
+ to[i] = convert::to<T2>(from[i]);
+ }
+
+ template <typename T>
+ inline
+ void
+ from_to_(const array<T>& from, fun::i2v::array<T>& to)
+ {
+ to = fun::i2v::array<T>(from);
+ }
+
+ template <typename T, typename U>
+ inline
+ void
+ from_to_(const array<T>& from, fun::i2v::array<U>& to)
+ {
+ to.resize(from.nelements());
+ for (unsigned i = 0; i < from.nelements(); ++i)
+ to(i) = convert::to<U>(from[i]);
+ }
+
+ template <typename V, typename T>
+ inline
+ void
+ from_to_(const array<V>& from, image1d<T>& to)
+ {
+ to.init_(make::box1d(from.nelements()));
+ for (unsigned i = 0; i < from.nelements(); ++i)
+ from_to(from[i], to(point1d(i)));
+ }
+
+
// util::array_fwd_iter<T>
diff --git a/milena/mln/util/object_id.hh b/milena/mln/util/object_id.hh
index 525ff15..1d2b361 100644
--- a/milena/mln/util/object_id.hh
+++ b/milena/mln/util/object_id.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2009, 2011 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2009, 2011, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -39,24 +39,6 @@
namespace mln
{
- // Forward declaration
- namespace util { template <typename Tag, typename V> class object_id; }
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // object_id<Tag,V> -> V.
- template <typename Tag, typename V>
- void from_to_(const util::object_id<Tag,V>& from, V& to_);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace util
{
@@ -109,6 +91,10 @@ namespace mln
bool
operator<(const object_id<Tag,V>& lhs, const object_id<Tag,V>&
rhs);
+ /// \internal Conversion: object_id<Tag,V> -> V.
+ template <typename Tag, typename V>
+ void from_to_(const util::object_id<Tag,V>& from, V& to_);
+
} // end of namespace mln::util
# ifndef MLN_INCLUDE_ONLY
@@ -228,24 +214,16 @@ namespace mln
return lhs.value() < rhs.value();
}
- } // end of namespace mln::util
- namespace convert
- {
+ // Conversions
- namespace over_load
+ template <typename Tag, typename V>
+ void from_to_(const util::object_id<Tag,V>& from, V& to_)
{
+ to_ = from.value();
+ }
- // object_id<Tag,V> -> V.
- template <typename Tag, typename V>
- void from_to_(const util::object_id<Tag,V>& from, V& to_)
- {
- to_ = from.value();
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ } // end of namespace mln::util
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/value/hsl.hh b/milena/mln/value/hsl.hh
index 0901904..6f716f4 100644
--- a/milena/mln/value/hsl.hh
+++ b/milena/mln/value/hsl.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -32,43 +33,23 @@
#include <mln/value/int_u.hh>
#include <mln/algebra/vec.hh>
-// Used in from_to
-#include <mln/fun/v2v/rgb_to_hsl.hh>
-
namespace mln
{
// Forward declarations.
- namespace value
- {
-
- template <typename H, typename S, typename L>
- class hsl_;
-
+ namespace value {
+ namespace qt {
+ struct rgb32;
+ }
+ template <typename H, typename S, typename L> class hsl_;
}
+} // end of namespace mln
- namespace convert
- {
-
- namespace over_load
- {
-
- // rgb to hsl_
- void
- from_to_(const value::rgb<16>& from,
value::hsl_<float,float,float>& to);
-
- // rgb to hsl_
- void
- from_to_(const value::rgb<8>& from,
value::hsl_<float,float,float>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
+namespace mln
+{
namespace trait
{
@@ -251,6 +232,17 @@ namespace mln
operator==(const hsl_<H,S,L>& lhs, const hsl_<H,S,L>& rhs);
/// \}
+
+ // Conversions
+
+ /// \internal Conversion: hsl -> qt::rgb32.
+ template <typename H, typename S, typename L>
+ void from_to_(const hsl_<H,S,L>& from, qt::rgb32& to);
+
+ /// \internal Conversion: hsl -> rgb8.
+ template <typename H, typename S, typename L>
+ void from_to_(const value::hsl_<H,S,L>&, value::rgb<8>& to);
+
} // end of namespace mln::value
@@ -261,19 +253,31 @@ namespace mln
namespace v2v
{
- template <typename T_hsl>
- struct f_rgb_to_hsl_;
+ template <typename T_rgb>
+ struct f_hsl_to_rgb_;
- typedef f_rgb_to_hsl_<value::hsl_f> f_rgb_to_hsl_f_t;
+ typedef f_hsl_to_rgb_< value::rgb<8> > f_hsl_to_rgb_3x8_t;
+// typedef f_hsl_to_rgb_< value::rgb<16> > f_hsl_to_rgb_3x16_t;
- extern f_rgb_to_hsl_f_t f_rgb_to_hsl_f;
+ extern f_hsl_to_rgb_3x8_t f_hsl_to_rgb_3x8;
+// extern f_hsl_to_rgb_3x16_t f_hsl_to_rgb_3x16;
}
}
+} // end of namespace mln
+
+
+// Used in from_to
+# include <mln/value/rgb.hh>
+# include <mln/fun/v2v/hsl_to_rgb.hh>
+
+
# ifndef MLN_INCLUDE_ONLY
+namespace mln
+{
namespace value
{
@@ -380,32 +384,24 @@ namespace mln
&& lhs.lum() == rhs.lum();
}
- } // end of namespace mln::value
-
- namespace convert
- {
+ // Conversions
- namespace over_load
+ template <typename H, typename S, typename L>
+ void from_to_(const hsl_<H,S,L>& from, qt::rgb32& to)
{
+ rgb<8> v = fun::v2v::f_hsl_to_rgb_3x8(from);
+ to = v.to_equiv();
+ }
- inline
- void
- from_to_(const value::rgb<16>& from,
value::hsl_<float,float,float>& to)
- {
- to = fun::v2v::f_rgb_to_hsl_f(from);
- }
-
- inline
- void
- from_to_(const value::rgb<8>& from,
value::hsl_<float,float,float>& to)
- {
- to = fun::v2v::f_rgb_to_hsl_f(from);
- }
-
- } // end of namespace mln::convert::over_load
+ template <typename H, typename S, typename L>
+ void
+ from_to_(const hsl_<H,S,L>& from, rgb<8>& to)
+ {
+ to = fun::v2v::f_hsl_to_rgb_3x8(from);
+ }
- } // end of namespace mln::convert
+ } // end of namespace mln::value
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/value/int_u.hh b/milena/mln/value/int_u.hh
index f3786f9..d051c13 100644
--- a/milena/mln/value/int_u.hh
+++ b/milena/mln/value/int_u.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -31,8 +31,6 @@
///
/// Define a generic class for unsigned integers.
-# include <mln/trait/all.hh> // FIXME!
-
# include <mln/value/ops.hh>
# include <mln/metal/math/pow.hh>
@@ -48,19 +46,21 @@
namespace mln
{
- namespace value
- {
- // Forward declaration.
+ // Forward declarations.
+ namespace value {
+ namespace qt {
+ struct rgb32;
+ }
template <unsigned n> struct int_u;
+ template <unsigned n> struct rgb;
}
namespace literal
{
- // Forward declarations.
struct zero_t;
struct one_t;
}
-
+ // End of forward declarations
namespace trait
{
@@ -110,42 +110,6 @@ namespace mln
} // end of namespace mln::trait
- namespace convert
- {
-
- namespace over_load
- {
-
- // int_u -> unsigned.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, unsigned& to_);
-
-
- // int_u -> bool.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, bool& to_);
-
-
- // int_u -> float.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, float& to_);
-
-
- // int_u -> double.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, double& to_);
-
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
namespace value
{
@@ -216,57 +180,41 @@ namespace mln
template <unsigned n>
std::istream& operator>>(std::istream& istr, int_u<n>& i);
- } // end of namespace mln::value
-# ifndef MLN_INCLUDE_ONLY
- namespace convert
- {
+ // Conversions
- namespace over_load
- {
+ /// \internal Conversion: int_u -> unsigned.
+ template <unsigned n>
+ void from_to_(const int_u<n>& from, unsigned& to_);
- // int_u -> unsigned.
- template <unsigned n>
- inline
- void
- from_to_(const value::int_u<n>& from, unsigned& to_)
- {
- to_ = from;
- }
- // int_u -> bool.
- template <unsigned n>
- inline
- void
- from_to_(const value::int_u<n>& from, bool& to_)
- {
- to_ = (from != 0u);
- }
+ /// \internal Conversion: int_u -> bool.
+ template <unsigned n>
+ void from_to_(const int_u<n>& from, bool& to_);
- // int_u -> float.
- template <unsigned n>
- inline
- void
- from_to_(const value::int_u<n>& from, float& to_)
- {
- to_ = static_cast<float>(from);
- }
- // int_u -> double.
- template <unsigned n>
- inline
- void
- from_to_(const value::int_u<n>& from, double& to_)
- {
- to_ = static_cast<double>(from);
- }
+ /// \internal Conversion: int_u -> float.
+ template <unsigned n>
+ void from_to_(const int_u<n>& from, float& to_);
- } // end of namespace mln::convert::over_load
+ /// \internal Conversion: int_u -> double.
+ template <unsigned n>
+ void
+ from_to_(const int_u<n>& from, double& to_);
- } // end of namespace mln::convert
+ /// \internal Conversion: Conversion: int_u -> rgb.
+ template <unsigned m>
+ void from_to_(const int_u<m>& from, qt::rgb32& to);
+ /// \internal Conversion: int_u -> rgb.
+ template <unsigned m>
+ void from_to_(const int_u<m>& from, rgb<m>& to);
+
+ } // end of namespace mln::value
+
+# ifndef MLN_INCLUDE_ONLY
namespace value
{
@@ -367,6 +315,56 @@ namespace mln
return istr >> i.handle_();
}
+
+ // Conversions
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const int_u<n>& from, unsigned& to_)
+ {
+ to_ = from;
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const int_u<n>& from, bool& to_)
+ {
+ to_ = (from != 0u);
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const int_u<n>& from, float& to_)
+ {
+ to_ = static_cast<float>(from);
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const int_u<n>& from, double& to_)
+ {
+ to_ = static_cast<double>(from);
+ }
+
+ template <unsigned m>
+ void
+ from_to_(const int_u<m>& from, qt::rgb32& to)
+ {
+ mlc_bool(m <= 8)::check();
+ to = qt::rgb32(from, from, from);
+ }
+
+ template <unsigned m>
+ void
+ from_to_(const int_u<m>& from, rgb<m>& to)
+ {
+ to = rgb<m>(from, from, from);
+ }
+
} // end of namespace mln::value
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/value/label.hh b/milena/mln/value/label.hh
index 5c983e5..dd0f924 100644
--- a/milena/mln/value/label.hh
+++ b/milena/mln/value/label.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 EPITA Research and
+// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 EPITA Research and
// Development Laboratory (LRDE)
//
// This file is part of Olena.
@@ -91,43 +91,6 @@ namespace mln
} // end of namespace trait
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // int_u -> label.
- template <unsigned n>
- void
- from_to_(const value::int_u<n>& from, value::label<n>& to_);
-
- // label -> int_u.
- template <unsigned n>
- void
- from_to_(const value::label<n>& from, value::int_u<n>& to_);
-
-
- // int_u -> label.
- template <unsigned n, unsigned m>
- void
- from_to_(const value::int_u<n>& from, value::label<m>& to_);
-
- // label -> bool.
- template <unsigned n>
- void
- from_to_(const value::label<n>& from, bool& to_);
-
- // label -> unsigned.
- template <unsigned n>
- void
- from_to_(const value::label<n>& from, unsigned& to_);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
namespace value
{
@@ -197,70 +160,32 @@ namespace mln
std::ostream& operator<<(std::ostream& ostr, const label<n>&
l);
- } // end of namespace mln::value
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // int_u -> label.
- template <unsigned n>
- inline
- void
- from_to_(const value::int_u<n>& from, value::label<n>& to_)
- {
- to_ = from;
- }
+ /// \internal Conversion: int_u -> label.
+ template <unsigned n>
+ void from_to_(const value::int_u<n>& from, value::label<n>&
to_);
- // label -> int_u.
- template <unsigned n>
- void
- from_to_(const value::label<n>& from, value::int_u<n>& to_)
- {
- to_ = from;
- }
+ /// \internal Conversion: label -> int_u.
+ template <unsigned n>
+ void from_to_(const value::label<n>& from, value::int_u<n>&
to_);
- // int_u<n> -> label<m> with n < m.
- template <unsigned n, unsigned m>
- inline
- void
- from_to_(const value::int_u<n>& from, value::label<m>& to_)
- {
- enum { valid = n < m };
- metal::bool_<valid>::check();
- to_ = from;
- }
+ /// \internal Conversion: int_u -> label.
+ template <unsigned n, unsigned m>
+ void from_to_(const value::int_u<n>& from, value::label<m>&
to_);
- // int_u<n> -> bool
- template <unsigned n>
- inline
- void
- from_to_(const value::label<n>& from, bool& to_)
- {
- to_ = (from != 0u);
- }
+ /// \internal Conversion: label -> bool.
+ template <unsigned n>
+ void from_to_(const value::label<n>& from, bool& to_);
- // int_u<n> -> unsigned
- template <unsigned n>
- inline
- void
- from_to_(const value::label<n>& from, unsigned& to_)
- {
- to_ = from;
- }
+ /// \internal Conversion: label -> unsigned.
+ template <unsigned n>
+ void from_to_(const value::label<n>& from, unsigned& to_);
- } // end of namespace mln::convert::over_load
+ } // end of namespace mln::value
- } // end of namespace mln::convert
+# ifndef MLN_INCLUDE_ONLY
namespace value
@@ -355,6 +280,47 @@ namespace mln
return ostr << debug::format(i.to_equiv());
}
+ template <unsigned n>
+ inline
+ void
+ from_to_(const value::int_u<n>& from, value::label<n>& to_)
+ {
+ to_ = from;
+ }
+
+ template <unsigned n>
+ void
+ from_to_(const value::label<n>& from, value::int_u<n>& to_)
+ {
+ to_ = from;
+ }
+
+ template <unsigned n, unsigned m>
+ inline
+ void
+ from_to_(const value::int_u<n>& from, value::label<m>& to_)
+ {
+ enum { valid = n < m };
+ metal::bool_<valid>::check();
+ to_ = from;
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const value::label<n>& from, bool& to_)
+ {
+ to_ = (from != 0u);
+ }
+
+ template <unsigned n>
+ inline
+ void
+ from_to_(const value::label<n>& from, unsigned& to_)
+ {
+ to_ = from;
+ }
+
} // end of namespace mln::value
diff --git a/milena/mln/value/qt/rgb32.hh b/milena/mln/value/qt/rgb32.hh
index 511d6a7..67bf1eb 100644
--- a/milena/mln/value/qt/rgb32.hh
+++ b/milena/mln/value/qt/rgb32.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -75,34 +76,6 @@ namespace mln
/// \}
}
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // int_u -> rgb.
- template <unsigned m>
- void from_to_(const value::int_u<m>& from, value::qt::rgb32& to);
-
- // hsl -> rgb32.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>&, value::qt::rgb32& to);
-
- // rgb32 -> bool.
- void from_to_(const value::qt::rgb32& from, bool& to);
-
-
- // bool -> rgb32.
- void from_to_(const bool& from, value::qt::rgb32& to);
-
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace trait
{
template <>
@@ -350,14 +323,18 @@ namespace mln
/// \}
+ /// \internal Conversion: Conversion: #value::qt::rgb32 -> bool.
+ void from_to_(const rgb32& from, bool& to);
+
+ /// \internal Conversion: bool -> #value::qt::rgb32.
+ void from_to_(const bool& from, value::qt::rgb32& to);
+
} // end of namespace mln::value::qt
} // end of namespace mln::value
} // end of namespace mln
-
-
# ifndef MLN_INCLUDE_ONLY
namespace mln
@@ -752,45 +729,15 @@ namespace mln
return istr >> c.red() >> c.green() >> c.blue();
}
- } // end of namespace mln::value::qt
-
- } // end of namespace mln::value
-
-
- namespace convert
- {
-
- namespace over_load
- {
- // int_u -> qt::rgb32
- template <unsigned m>
- void
- from_to_(const value::int_u<m>& from, value::qt::rgb32& to)
- {
- mlc_bool(m <= 8)::check();
- to = value::qt::rgb32(from, from, from);
- }
+ // Conversions
-
- // hsl -> rgb8.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>& from, value::qt::rgb32& to)
- {
- value::rgb8 v = fun::v2v::f_hsl_to_rgb_3x8(from);
- to = v.to_equiv();
- }
-
-
- // qt::rgb32 -> bool
inline
- void from_to_(const value::qt::rgb32& from, bool& to)
+ void from_to_(const rgb32& from, bool& to)
{
to = ((from == literal::black) ? false : true);
}
-
- // bool -> qt::rgb32
inline
void from_to_(const bool& from, value::qt::rgb32& to)
{
@@ -800,10 +747,9 @@ namespace mln
to = literal::black;
}
+ } // end of namespace mln::value::qt
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
+ } // end of namespace mln::value
} // end of namespace mln
diff --git a/milena/mln/value/rgb.hh b/milena/mln/value/rgb.hh
index c9d2f53..1c812d7 100644
--- a/milena/mln/value/rgb.hh
+++ b/milena/mln/value/rgb.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -30,7 +30,6 @@
# include <mln/value/ops.hh>
-# include <mln/fun/v2v/hsl_to_rgb.hh>
# include <mln/value/concept/vectorial.hh>
# include <mln/value/int_u.hh>
# include <mln/algebra/vec.hh>
@@ -46,28 +45,18 @@ namespace mln
{
// Forward declaration.
- namespace value { template <unsigned n> struct rgb; }
+ namespace value {
+ template <unsigned n> struct rgb;
+ template <typename H, typename S, typename L> class hsl_;
-
-
- namespace fun
- {
-
- namespace v2v
- {
-
- template <typename T_rgb>
- struct f_hsl_to_rgb_;
-
- typedef f_hsl_to_rgb_< value::rgb<8> > f_hsl_to_rgb_3x8_t;
-// typedef f_hsl_to_rgb_< value::rgb<16> > f_hsl_to_rgb_3x16_t;
-
- extern f_hsl_to_rgb_3x8_t f_hsl_to_rgb_3x8;
-// extern f_hsl_to_rgb_3x16_t f_hsl_to_rgb_3x16;
-
- }
-
- }
+ }
+ namespace fun {
+ namespace v2v {
+ template <typename T_hsl> struct f_rgb_to_hsl_;
+ typedef f_rgb_to_hsl_<value::hsl_<float, float, float> >
f_rgb_to_hsl_f_t;
+ extern f_rgb_to_hsl_f_t f_rgb_to_hsl_f;
+ }
+ }
namespace literal
@@ -104,42 +93,6 @@ namespace mln
template <typename H, typename S, typename L> class hsl_;
}
-
- namespace convert
- {
-
- namespace over_load
- {
-
- // algebra::vec -> rgb.
- template <typename T, unsigned m>
- void from_to_(const algebra::vec<3,T>& from, value::rgb<m>&
to_);
-
- // bool -> rgb.
- template <unsigned m>
- void from_to_(bool from, value::rgb<m>& to);
-
- // int_u -> rgb.
- template <unsigned m>
- void from_to_(const value::int_u<m>& from, value::rgb<m>& to);
-
- // hsl -> rgb8.
- template <typename H, typename S, typename L>
- void from_to_(const value::hsl_<H,S,L>&, value::rgb<8>& to);
-
-// // hsl -> rgb16.
-// template <typename H, typename S, typename L>
-// void from_to_(const value::hsl_<H,S,L>&, value::rgb<16>&
to);
-
- // rgb -> bool.
- template <unsigned m>
- void from_to_(const value::rgb<m>& from, bool& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
namespace trait
{
template < unsigned n >
@@ -395,14 +348,38 @@ namespace mln
operator/(const rgb<n>& lhs, const mln::value::scalar_<S>& s);
/// \}
+ } // end of namespace mln::value
+
+
+ // Conversions
+
+ namespace value
+ {
+
+ /// \internal Conversion: rgb -> bool.
+ template <unsigned m>
+ void from_to_(const value::rgb<m>& from, bool& to);
+
+ /// \internal Conversion: rgb to hsl_
+ void
+ from_to_(const rgb<16>& from, hsl_<float,float,float>& to);
+
+ /// \internal Conversion: rgb to hsl_
+ void
+ from_to_(const rgb<8>& from, hsl_<float,float,float>& to);
+
+ /// \internal Conversion: bool -> rgb.
+ template <unsigned m>
+ void from_to_(bool from, value::rgb<m>& to);
} // end of namespace mln::value
} // end of namespace mln
-// // Needed by from_to_.
-// # include <mln/fun/v2v/rgb_to_hsl.hh>
+// Used in from_to
+# include <mln/value/hsl.hh>
+# include <mln/fun/v2v/rgb_to_hsl.hh>
# ifndef MLN_INCLUDE_ONLY
@@ -755,75 +732,46 @@ namespace mln
return istr >> c.red() >> c.green() >> c.blue();
}
- } // end of namespace mln::value
+ // Conversions
- namespace convert
- {
-
- namespace over_load
+ template <unsigned m>
+ void
+ from_to_(const rgb<m>& from, bool& to)
{
+ to = (from.red() != 0 && from.green() != 0 && from.blue() != 0);
+ }
- // algebra::vec -> rgb.
- template <typename T, unsigned m>
- inline
- void
- from_to_(const algebra::vec<3,T>& from, value::rgb<m>& to)
- {
- algebra::vec<3, unsigned> tmp;
- for (unsigned i = 0; i < 3; ++i)
- tmp[i] = static_cast<unsigned>(from[i]); // FIXME: Use from_to_ instead of
cast.
-
- to = value::rgb<m>(tmp);
- }
-
- // bool -> rgb.
- template <unsigned m>
- void
- from_to_(bool from, value::rgb<m>& to)
- {
- static literal::white_t* white_ = 0;
- static literal::black_t* black_ = 0;
- // We do not use literal::white (the object) so that we
- // do not introduce any coupling with the file where
- // literals are defined.
- if (from)
- to = *white_;
- else
- to = *black_;
- }
-
- template <unsigned m>
- void
- from_to_(const value::int_u<m>& from, value::rgb<m>& to)
- {
- to = value::rgb<m>(from, from, from);
- }
+ inline
+ void
+ from_to_(const rgb<16>& from, hsl_<float,float,float>& to)
+ {
+ to = fun::v2v::f_rgb_to_hsl_f(from);
+ }
- template <typename H, typename S, typename L>
- void
- from_to_(const value::hsl_<H,S,L>& from, value::rgb<8>& to)
- {
- to = fun::v2v::f_hsl_to_rgb_3x8(from);
- }
-
-// template <typename H, typename S, typename L>
-// void
-// from_to_(const value::hsl_<H,S,L>& from, value::rgb<16>&
to)
-// {
-// to = fun::v2v::f_hsl_to_rgb_3x16(from);
-// }
-
- template <unsigned m>
- void
- from_to_(const value::rgb<m>& from, bool& to)
- {
- to = (from.red() != 0 && from.green() != 0 && from.blue() != 0);
- }
+ inline
+ void
+ from_to_(const rgb<8>& from, hsl_<float,float,float>& to)
+ {
+ to = fun::v2v::f_rgb_to_hsl_f(from);
+ }
- } // end of namespace mln::convert::over_load
+ template <unsigned m>
+ void
+ from_to_(bool from, mln::value::rgb<m>& to)
+ {
+ static mln::literal::white_t* white_ = 0;
+ static mln::literal::black_t* black_ = 0;
+ // We do not use literal::white (the object) so that we
+ // do not introduce any coupling with the file where
+ // literals are defined.
+ if (from)
+ to = *white_;
+ else
+ to = *black_;
+ }
- } // end of namespace mln::convert
+ } // end of namespace mln::value
} // end of namespace mln
diff --git a/milena/mln/win/multiple.hh b/milena/mln/win/multiple.hh
index 18b65c8..869ad7c 100644
--- a/milena/mln/win/multiple.hh
+++ b/milena/mln/win/multiple.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -32,7 +33,7 @@
///
/// \todo Implementation of the bkd_qiter (see FIXME).
-# include <mln/core/internal/window_base.hh>
+# include <mln/core/window.hh>
# include <mln/core/internal/site_relative_iterator_base.hh>
# include <mln/util/array.hh>
diff --git a/milena/mln/win/multiple_size.hh b/milena/mln/win/multiple_size.hh
index 765e83d..43861f3 100644
--- a/milena/mln/win/multiple_size.hh
+++ b/milena/mln/win/multiple_size.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2011, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -49,6 +49,7 @@ namespace mln
template <unsigned n, typename W, typename F> class multiple_size;
template <unsigned n, typename W, typename F> class multiple_size_qiter;
}
+ template <typename D> class window;
diff --git a/milena/tests/accu/site_set/rectangularity.cc
b/milena/tests/accu/site_set/rectangularity.cc
index 8919494..7adbb60 100644
--- a/milena/tests/accu/site_set/rectangularity.cc
+++ b/milena/tests/accu/site_set/rectangularity.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2012 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -61,5 +62,6 @@ int main()
{
accu::site_set::rectangularity<point2d> a;
accu::site_set::rectangularity<point2d> b = exact(a);
+ (void) b;
}
}
diff --git a/milena/tests/core/other/graph_elt_neighborhood.cc
b/milena/tests/core/other/graph_elt_neighborhood.cc
index 7206d92..356fc4a 100644
--- a/milena/tests/core/other/graph_elt_neighborhood.cc
+++ b/milena/tests/core/other/graph_elt_neighborhood.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -31,6 +31,7 @@
#include <mln/core/alias/point2d.hh>
#include <mln/core/site_set/p_vertices.hh>
+#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
#include <mln/core/image/graph_elt_neighborhood.hh>
diff --git a/milena/tests/core/other/graph_elt_window.cc
b/milena/tests/core/other/graph_elt_window.cc
index 6e56a89..15a74d3 100644
--- a/milena/tests/core/other/graph_elt_window.cc
+++ b/milena/tests/core/other/graph_elt_window.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -30,7 +31,7 @@
#include <mln/core/alias/point2d.hh>
#include <mln/core/image/graph_elt_window.hh>
#include <mln/core/site_set/p_vertices.hh>
-
+#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
unsigned fwd_neighb[] = { 0, 2, 3 };
diff --git a/milena/tests/core/other/point_set_compatibility.cc
b/milena/tests/core/other/point_set_compatibility.cc
index 095ca46..ac73ab6 100644
--- a/milena/tests/core/other/point_set_compatibility.cc
+++ b/milena/tests/core/other/point_set_compatibility.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -25,6 +26,7 @@
#include <mln/core/alias/point2d.hh>
+#include <mln/fun/i2v/array.hh>
#include <mln/core/site_set/p_array.hh>
#include <mln/core/site_set/p_set.hh>
#include <mln/core/site_set/p_vertices.hh>
diff --git a/milena/tests/draw/graph.cc b/milena/tests/draw/graph.cc
index c15ab57..845d318 100644
--- a/milena/tests/draw/graph.cc
+++ b/milena/tests/draw/graph.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -26,6 +27,7 @@
#include <vector>
#include <utility>
+#include <mln/fun/i2v/array.hh>
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/point2d.hh>
#include <mln/debug/println.hh>
--
1.7.2.5