
* mln/convert/from_to.hxx: add forward declaration. * mln/core/alias/point2d.hh: add point2df alias. * mln/core/alias/point3d.hh: update comments. * mln/core/point.hh: add a new from_to_ overload. --- milena/ChangeLog | 12 ++++++++++++ milena/mln/convert/from_to.hxx | 5 +++++ milena/mln/core/alias/point2d.hh | 3 ++- milena/mln/core/alias/point3d.hh | 19 ++++++++----------- milena/mln/core/point.hh | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 12 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 6199774..acb63ae 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,15 @@ +2009-03-16 Guillaume Lazzara <lazzara@lrde.epita.fr> + + Add conversion from point<G,C1> to point<G,C2>. + + * mln/convert/from_to.hxx: add forward declaration. + + * mln/core/alias/point2d.hh: add point2df alias. + + * mln/core/alias/point3d.hh: update comments. + + * mln/core/point.hh: add a new from_to_ overload. + 2009-03-15 Thierry Geraud <thierry.geraud@lrde.epita.fr> Add an ''un-projection'' image morpher. diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx index d4ccc22..db38e36 100644 --- a/milena/mln/convert/from_to.hxx +++ b/milena/mln/convert/from_to.hxx @@ -145,6 +145,11 @@ namespace mln 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 -> Gpoint. template <unsigned n, typename T, typename P> diff --git a/milena/mln/core/alias/point2d.hh b/milena/mln/core/alias/point2d.hh index 8c141e1..3059169 100644 --- a/milena/mln/core/alias/point2d.hh +++ b/milena/mln/core/alias/point2d.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory // (LRDE) // // This file is part of the Olena Library. This library is free @@ -46,6 +46,7 @@ namespace mln /// integer coordinates. /// typedef point<grid::square, def::coord> point2d; + typedef point<grid::square, def::coordf> point2df; namespace internal diff --git a/milena/mln/core/alias/point3d.hh b/milena/mln/core/alias/point3d.hh index acbf721..ceff9c1 100644 --- a/milena/mln/core/alias/point3d.hh +++ b/milena/mln/core/alias/point3d.hh @@ -29,11 +29,10 @@ #ifndef MLN_CORE_ALIAS_POINT3D_HH # define MLN_CORE_ALIAS_POINT3D_HH -/*! \file mln/core/alias/point3d.hh - * - * \brief Definition of the mln::point3d alias and of its construction - * routine. - */ +/// \file mln/core/alias/point3d.hh +/// +/// Definition of the mln::point3d alias and of its construction +/// routine. # include <mln/core/point.hh> // For site_const_impl and site_mutable_impl: @@ -43,14 +42,12 @@ namespace mln { - /*! \brief Type alias for a point defined on the 3D square grid with - * integer coordinates. - */ + /// Type alias for a point defined on the 3D square grid with + /// integer coordinates. typedef point<grid::cube, def::coord> point3d; - /*! \brief Type alias for a point defined on the 3D square grid with - * floating-point coordinates. - */ + /// Type alias for a point defined on the 3D square grid with + /// floating-point coordinates. typedef point<grid::cube, def::coordf> point3df; namespace internal diff --git a/milena/mln/core/point.hh b/milena/mln/core/point.hh index 755f50c..54289fa 100644 --- a/milena/mln/core/point.hh +++ b/milena/mln/core/point.hh @@ -61,6 +61,21 @@ 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); + + } // end of namespace mln::convert::over_load + + } // end of namespace mln::convert + + + /// Generic point class. /// /// Parameters are \c n the dimension of the space and \c C the @@ -213,6 +228,26 @@ namespace mln # ifndef MLN_INCLUDE_ONLY + 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(); + to = point<G,C2>(from.to_vec()); + } + + } // 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 -- 1.5.6.5