1398: Get rid of Generalized_Point, replaced by Point_Site.

https://svn.lrde.epita.fr/svn/oln/trunk/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Get rid of Generalized_Point, replaced by Point_Site. * mln/core/concept/point_iterator.hh: Change inheritance from Iterator to Point_Site. * mln/core/concept/doc/generalized_point.hh: Rename as... * mln/core/concept/doc/point_site.hh: ...this; update. Then update. * tests/rle_image.cc: Add todo. * mln/core/internal/point_iterator_base.hh (operator[]): New. * mln/core/rle_image.hh: Conform to style. * mln/core/concept/generalized_point.hh: Remove. * mln/core/concept/delta_point_site.hh: New. * mln/core/concept/point.hh (Point<void>): New. * mln/core/concept/dpoint.hh (Dpoint<void>): New. (operator): Remove all; obsolete. * mln/value/concept/built_in.hh: Add comment. * mln/core/dpoints_piter.hh, * mln/core/mesh_psite.hh, * mln/core/window.hh, * mln/core/dpoints_pixter.hh, * mln/core/mesh_p.hh, * mln/core/internal/piter_adaptor.hh, * mln/core/internal/run_pset.hh, * mln/core/internal/run_psite.hh, * mln/core/internal/check/image_fastest.hh, * mln/core/mesh_p_piter.hh, * mln/core/line_piter.hh, * mln/core/vec_p_piter.hh, * mln/core/box_piter.hh, * mln/core/concept/dpoint.hh, * mln/core/concept/value_iterator.hh, * mln/core/concept/point.hh, * mln/core/concept/point_set.hh, * mln/core/concept/point_site.hh, * mln/linear/local/convolve.hh, * mln/convert/to_window.hh, * mln/convert/to_set_p.hh, * mln/convert/to_dpoint.hh: Update. mln/convert/to_dpoint.hh | 12 - mln/convert/to_set_p.hh | 4 mln/convert/to_window.hh | 5 mln/core/box_piter.hh | 20 +- mln/core/concept/delta_point_site.hh | 218 +++++++++++++++++++++++ mln/core/concept/doc/point_site.hh | 32 +-- mln/core/concept/dpoint.hh | 151 +--------------- mln/core/concept/point.hh | 80 +++++--- mln/core/concept/point_iterator.hh | 40 +++- mln/core/concept/point_set.hh | 2 mln/core/concept/point_site.hh | 286 ++++++++++++++++++++++++++++--- mln/core/concept/value_iterator.hh | 2 mln/core/dpoints_piter.hh | 20 +- mln/core/dpoints_pixter.hh | 10 - mln/core/internal/check/image_fastest.hh | 7 mln/core/internal/piter_adaptor.hh | 10 - mln/core/internal/point_iterator_base.hh | 11 + mln/core/internal/run_pset.hh | 39 +++- mln/core/internal/run_psite.hh | 15 + mln/core/line_piter.hh | 10 - mln/core/mesh_p.hh | 2 mln/core/mesh_p_piter.hh | 19 -- mln/core/mesh_psite.hh | 26 +- mln/core/rle_image.hh | 3 mln/core/vec_p_piter.hh | 20 +- mln/core/window.hh | 5 mln/linear/local/convolve.hh | 14 - mln/value/concept/built_in.hh | 3 tests/rle_image.cc | 2 29 files changed, 750 insertions(+), 318 deletions(-) Index: tests/rle_image.cc --- tests/rle_image.cc (revision 1397) +++ tests/rle_image.cc (working copy) @@ -28,6 +28,8 @@ /*! \file tests/rle_image.cc * * \brief Tests on mln::rle_image. + * + * \todo Trouble with ctor/init since there is no ctor with arg! */ #include <mln/core/image2d.hh> Index: mln/core/dpoints_piter.hh --- mln/core/dpoints_piter.hh (revision 1397) +++ mln/core/dpoints_piter.hh (working copy) @@ -35,7 +35,7 @@ */ # include <mln/core/internal/point_iterator_base.hh> -# include <mln/core/concept/generalized_point.hh> +# include <mln/core/concept/point_site.hh> namespace mln @@ -58,13 +58,13 @@ */ template <typename Dps, typename Pref> dpoints_fwd_piter(const Dps& dps, // FIXME: explicitly set_of_<D>? - const Generalized_Point<Pref>& p_ref); + const Point_Site<Pref>& p_ref); /// Convertion to point. operator mln_point(D) () const; - /// Address of the point this iterator designates. - const mln_point(D)* pointer_() const; + /// Reference to the corresponding point. + const mln_point(D)& to_point() const; /// Test the iterator validity. bool is_valid() const; @@ -95,7 +95,7 @@ unsigned i_; mln_point(D) p_; // location of this iterator; p_ makes this iterator be - // itself a potential center point (Cf. the pointer_() method). + // itself a potential center point. }; @@ -110,9 +110,9 @@ template <typename D> template <typename Dps, typename Pref> dpoints_fwd_piter<D>::dpoints_fwd_piter(const Dps& dps, - const Generalized_Point<Pref>& p_ref) + const Point_Site<Pref>& p_ref) : dps_(exact(dps).vect()), - p_ref_(* internal::force_exact<Pref>(p_ref).pointer_()) + p_ref_(exact(p_ref).to_point()) { invalidate(); } @@ -125,10 +125,10 @@ } template <typename D> - const mln_point(D)* - dpoints_fwd_piter<D>::pointer_() const + const mln_point(D)& + dpoints_fwd_piter<D>::to_point() const { - return & p_; + return p_; } template <typename D> Index: mln/core/mesh_psite.hh --- mln/core/mesh_psite.hh (revision 1397) +++ mln/core/mesh_psite.hh (working copy) @@ -31,13 +31,19 @@ /*! \file mln/core/mesh_p.hh * * \brief Definition of a graph-based point site. + * + * \todo Clean-up! */ + namespace mln { + // Fwd decl. template<typename P> class mesh_p; + + // FIXME: Doc! template<typename P> struct mesh_psite : public Point_Site< mesh_psite<P> > { @@ -48,12 +54,15 @@ typedef mln_coord(P) coord; mesh_psite(unsigned i, mesh_p<P>* m_ptr); - P to_point() const; + operator P() const; - const point* pointer_() const; + + const point& to_point() const; + coord operator[](unsigned i) const; unsigned i_; + mesh_p<P>* m_ptr_; }; @@ -67,23 +76,16 @@ } template<typename P> - P - mesh_psite<P>::to_point() const - { - return m_ptr_->loc_[i_]; - } - - template<typename P> mesh_psite<P>::operator P() const { return m_ptr_->loc_[i_]; } template<typename P> - const P* - mesh_psite<P>::pointer_() const + const P& + mesh_psite<P>::to_point() const { - return 0; + return m_ptr_->loc_[i_]; } template<typename P> Index: mln/core/window.hh --- mln/core/window.hh (revision 1397) +++ mln/core/window.hh (working copy) @@ -37,7 +37,7 @@ */ # include <mln/core/concept/window.hh> -# include <mln/core/concept/generalized_point.hh> +# include <mln/core/concept/point_site.hh> # include <mln/core/internal/dpoints_base.hh> # include <mln/core/dpoint.hh> # include <mln/core/box.hh> @@ -132,7 +132,8 @@ template <typename D> window<D>::window() { - mln::metal::is_a<D, Dpoint>::check(); + // FIXME HERE: Was: mln::metal::is_a<D, Dpoint>::check(); + mln::metal::is_a<D, Delta_Point_Site>::check(); } template <typename D> Index: mln/core/dpoints_pixter.hh --- mln/core/dpoints_pixter.hh (revision 1397) +++ mln/core/dpoints_pixter.hh (working copy) @@ -38,7 +38,7 @@ # include <vector> # include <mln/core/concept/pixel_iterator.hh> -# include <mln/core/concept/generalized_pixel.hh> +# include <mln/core/concept/point_site.hh> # include <mln/core/internal/pixel_impl.hh> @@ -62,12 +62,12 @@ * * \param[in] image Image subject to iteration. * \param[in] dps Object that can provide a set of delta-points. - * \param[in] p_ref Center (generalized) point to iterate around. + * \param[in] p_ref Center point to iterate around. */ template <typename Dps, typename Pref> dpoints_fwd_pixter(I& image, const Dps& dps, - const Generalized_Point<Pref>& p_ref); + const Point_Site<Pref>& p_ref); /*! \brief Constructor. * @@ -129,11 +129,11 @@ template <typename Dps, typename Pref> dpoints_fwd_pixter<I>::dpoints_fwd_pixter(I& image, const Dps& dps, - const Generalized_Point<Pref>& p_ref) + const Point_Site<Pref>& p_ref) : super_(image) { mln_precondition(image.has_data()); - p_ref_ = internal::force_exact<Pref>(p_ref).pointer_(); + p_ref_ = & exact(p_ref).to_point(); value_ref_ = 0; init_(dps); } Index: mln/core/mesh_p.hh --- mln/core/mesh_p.hh (revision 1397) +++ mln/core/mesh_p.hh (working copy) @@ -28,7 +28,7 @@ #ifndef MLN_MESH_P_HH # define MLN_MESH_P_HH -# include <mln/core/concept/point.hh> +# include <mln/core/concept/point_site.hh> # include <mln/core/internal/point_set_base.hh> # include <mln/accu/bbox.hh> # include <mln/util/graph.hh> Index: mln/core/internal/point_iterator_base.hh --- mln/core/internal/point_iterator_base.hh (revision 1397) +++ mln/core/internal/point_iterator_base.hh (working copy) @@ -71,6 +71,9 @@ /// Coord associated type. typedef mln_coord(point) coord; + // Access to the i-th coordinate. + coord operator[](unsigned i) const; + protected: /// Constructor. point_iterator_base_(); @@ -85,6 +88,14 @@ mln::metal::is_a<P, Point_Site>::check(); } + template <typename P, typename E> + typename point_iterator_base_<P, E>::coord + point_iterator_base_<P, E>::operator[](unsigned i) const + { + mln_precondition(i < dim); + return exact(*this).to_point()[i]; + } + #endif // ! MLN_INCLUDE_ONLY } // end of namespace internal Index: mln/core/internal/piter_adaptor.hh --- mln/core/internal/piter_adaptor.hh (revision 1397) +++ mln/core/internal/piter_adaptor.hh (working copy) @@ -63,8 +63,8 @@ /// Convertion to point. operator mln_point(Pi) () const; - /// Address of the point. - const mln_point(Pi)* pointer_() const; + /// Reference to the corresponding point. + const mln_point(Pi)& to_point() const; /// Give the i-th coordinate. mln_coord(Pi) operator[](unsigned i) const; @@ -105,10 +105,10 @@ } template <typename Pi, typename E> - const mln_point(Pi)* - piter_adaptor_<Pi,E>::pointer_() const + const mln_point(Pi)& + piter_adaptor_<Pi,E>::to_point() const { - return piter_.pointer_(); + return piter_.to_point(); } template <typename Pi, typename E> Index: mln/core/internal/run_pset.hh --- mln/core/internal/run_pset.hh (revision 1397) +++ mln/core/internal/run_pset.hh (working copy) @@ -69,15 +69,19 @@ run_pset_(); + /// Test is \p p belongs to this point set. bool has(const run_psite<P>& p) const; + /// Give the exact bounding box. const box_<P>& bbox() const; + /// Give the number of points. typename std::size_t npoints() const; /// Insert a range, start at point \p p wit len \p len. void insert(const P& p, unsigned len); + /// Return the len of the range starting at point \p p. unsigned range_len_(const P& p) const; @@ -85,10 +89,13 @@ const std_container& con() const; protected: + /// Number of points. typename std::size_t npoints_; + /// Points container std_container con_; + /// Exact bounding box. accu::bbox<P> fb_; }; @@ -182,18 +189,24 @@ /// Convertion into a point-site. operator internal::run_psite<P> () const; + /// Convertion into a point. operator P () const; - /// Return a pointer of the current point. - const P* pointer_() const; + + /// Reference to the corresponding point. + const P& to_point() const; + /// Access to the current point coordinates. mln_coord(P) operator[](unsigned i) const; protected: + /// Current point. P p_; + /// Current site. internal::run_psite<P> site_; + /// Point set container. const std_container& con_; @@ -222,11 +235,11 @@ } template <typename P, typename E> - const P* - run_piter_<P, E>::pointer_() const + const P& + run_piter_<P, E>::to_point() const { mln_precondition(exact(this)->is_valid()); - return &p_; + return p_; } template <typename P, typename E> @@ -236,6 +249,7 @@ mln_precondition(exact(this)->is_valid()); return p_[i]; } + # endif // ! MLN_INCLUDE_ONLY @@ -253,17 +267,24 @@ /// Test the iterator validity. bool is_valid() const; + /// Invalidate the iterator. void invalidate(); + /// Start an iteration. void start(); + /// Go to the next point. void next_(); + protected: typename super::std_container::const_iterator it_; }; + + # ifndef MLN_INCLUDE_ONLY + template <typename P> run_fwd_piter_<P>::run_fwd_piter_(const run_pset_<P>& pset) : super(pset) @@ -318,6 +339,7 @@ # endif // ! MLN_INCLUDE_ONLY + /*! \brief Backward iterator on run_pset_ point set. * * Parameter \c P is the type of the point used in the point set. @@ -332,17 +354,24 @@ /// Test the iterator validity. bool is_valid() const; + /// Invalidate the iterator. void invalidate(); + /// Start an iteration. void start(); + /// Go to the next point. void next_(); + protected: typename super::std_container::const_reverse_iterator it_; }; + + # ifndef MLN_INCLUDE_ONLY + template <typename P> run_bkd_piter_<P>::run_bkd_piter_(const run_pset_<P>& pset) : super(pset) Index: mln/core/internal/run_psite.hh --- mln/core/internal/run_psite.hh (revision 1397) +++ mln/core/internal/run_psite.hh (working copy) @@ -80,13 +80,16 @@ /// Return the position of this psite in the current range. unsigned& index_(); - const P* pointer_() const; + /// Reference to the corresponding point. + const P& to_point() const; + + /// Give the i-th coordinate of the corresponding point. mln_coord(P) operator[](unsigned i) const; protected: /// Start of the psite range. - P point_; + P point_; // FIXME: Rename as p_ (like everywhere else!) /// Position in the psite range. unsigned range_index_; @@ -95,7 +98,9 @@ unsigned pset_position_; }; + # ifndef MLN_INCLUDE_ONLY + template <typename P> run_psite<P>::run_psite() { @@ -160,10 +165,10 @@ } template <typename P> - const P* - run_psite<P>::pointer_() const + const P& + run_psite<P>::to_point() const { - return & point_; + return point_; } template <typename P> Index: mln/core/internal/check/image_fastest.hh --- mln/core/internal/check/image_fastest.hh (revision 1397) +++ mln/core/internal/check/image_fastest.hh (working copy) @@ -34,6 +34,7 @@ * images. */ +# include <mln/core/internal/force_exact.hh> namespace mln @@ -62,7 +63,7 @@ */ template <typename P> unsigned - offset_at(const Generalized_Point<P>& p) const; + offset_at(const Point_Site<P>& p) const; protected: image_fastest_(); @@ -118,11 +119,11 @@ template <typename E, typename B> template <typename P> unsigned // FIXME: std::size_t? - image_fastest_<E,B>::offset_at(const Generalized_Point<P>& p_) const + image_fastest_<E,B>::offset_at(const Point_Site<P>& p_) const { // FIXME: check that P is mln_point(E) const E* this_ = & internal::force_exact<E>(*this); - const P& p = internal::force_exact<P>(p_); + const P& p = exact(p_); mln_precondition(this_->has_data()); mln_precondition(this_->owns_(p)); Index: mln/core/mesh_p_piter.hh --- mln/core/mesh_p_piter.hh (revision 1397) +++ mln/core/mesh_p_piter.hh (working copy) @@ -54,8 +54,8 @@ mesh_p_piter_(const mesh_p<P>& s); - /// Give a hook to the point address. - const P* pointer_() const; + /// Reference to the corresponding point. + const P& to_point() const; /// Read-only access to the \p i-th coordinate. mln_coord(P) operator[](unsigned i) const; @@ -81,6 +81,8 @@ P p_; }; + + # ifndef MLN_INCLUDE_ONLY template<typename P> @@ -90,15 +92,13 @@ invalidate(); } - template<typename P> - const P* - mesh_p_piter_<P>::pointer_() const + const P& + mesh_p_piter_<P>::to_point() const { - return & p_; + return p_; } - template<typename P> mln_coord(P) mesh_p_piter_<P>::operator[](unsigned i) const @@ -106,7 +106,6 @@ return p_[i]; } - template<typename P> bool mesh_p_piter_<P>::is_valid() const @@ -114,7 +113,6 @@ return i_ != loc_.size(); } - template<typename P> void mesh_p_piter_<P>::invalidate() @@ -122,7 +120,6 @@ i_ = loc_.size(); } - template<typename P> void mesh_p_piter_<P>::start() @@ -132,7 +129,6 @@ p_ = loc_[i_]; } - template<typename P> void mesh_p_piter_<P>::next_() @@ -142,7 +138,6 @@ p_ = loc_[i_]; } - template<typename P> mesh_p_piter_<P>::operator P() const { Index: mln/core/rle_image.hh --- mln/core/rle_image.hh (revision 1397) +++ mln/core/rle_image.hh (working copy) @@ -45,6 +45,7 @@ // Fwd decl. template <typename P, typename T> struct rle_image; + namespace internal { @@ -62,6 +63,8 @@ } // end of namespace mln::internal + + /*! \brief RLE image. * * Index: mln/core/line_piter.hh --- mln/core/line_piter.hh (revision 1397) +++ mln/core/line_piter.hh (working copy) @@ -64,8 +64,8 @@ /// Convertion to point. operator P() const; - /// Address of the point. - const P* pointer_() const; + /// Reference to the corresponding point. + const P& to_point() const; /// Give the i-th coordinate. mln_coord(P) operator[](unsigned i) const; @@ -115,10 +115,10 @@ } template <typename P> - const P* - line_piter_<P>::pointer_() const + const P& + line_piter_<P>::to_point() const { - return & p_; + return p_; } template <typename P> Index: mln/core/vec_p_piter.hh --- mln/core/vec_p_piter.hh (revision 1397) +++ mln/core/vec_p_piter.hh (working copy) @@ -56,8 +56,8 @@ template <typename S> vec_p_fwd_piter_(const Point_Set<S>& s); - /// Give a hook to the point address. - const P* pointer_() const; + /// Reference of the corresponding point. + const P& to_point() const; /// Read-only access to the \p i-th coordinate. mln_coord(P) operator[](unsigned i) const; @@ -102,8 +102,8 @@ template <typename S> vec_p_bkd_piter_(const Point_Set<S>& s); - /// Give a hook to the point address. - const P* pointer_() const; + /// Reference of the corresponding point. + const P& to_point() const; /// Read-only access to the \p i-th coordinate. mln_coord(P) operator[](unsigned i) const; @@ -144,10 +144,10 @@ } template <typename P> - const P* - vec_p_fwd_piter_<P>::pointer_() const + const P& + vec_p_fwd_piter_<P>::to_point() const { - return & p_; + return p_; } template <typename P> @@ -210,10 +210,10 @@ } template <typename P> - const P* - vec_p_bkd_piter_<P>::pointer_() const + const P& + vec_p_bkd_piter_<P>::to_point() const { - return & p_; + return p_; } template <typename P> Index: mln/core/box_piter.hh --- mln/core/box_piter.hh (revision 1397) +++ mln/core/box_piter.hh (working copy) @@ -65,8 +65,8 @@ /// Convertion to point. operator P() const; - /// Address of the point. - const P* pointer_() const; + /// Reference to the corresponding point. + const P& to_point() const; /// Give the i-th coordinate. mln_coord(P) operator[](unsigned i) const; @@ -115,8 +115,8 @@ /// Convertion to point. operator P() const; - /// Address of the point. - const P* pointer_() const; + /// Reference to the corresponding point. + const P& to_point() const; /// Give the i-th coordinate. mln_coord(P) operator[](unsigned i) const; @@ -162,10 +162,10 @@ } template <typename P> - const P* - box_fwd_piter_<P>::pointer_() const + const P& + box_fwd_piter_<P>::to_point() const { - return & p_; + return p_; } template <typename P> @@ -233,10 +233,10 @@ template <typename P> - const P* - box_bkd_piter_<P>::pointer_() const + const P& + box_bkd_piter_<P>::to_point() const { - return & p_; + return p_; } template <typename P> Index: mln/core/concept/value_iterator.hh --- mln/core/concept/value_iterator.hh (revision 1397) +++ mln/core/concept/value_iterator.hh (working copy) @@ -34,7 +34,7 @@ */ # include <mln/core/concept/iterator.hh> -# include <mln/core/concept/generalized_point.hh> +# include <mln/core/concept/point_site.hh> namespace mln Index: mln/core/concept/delta_point_site.hh --- mln/core/concept/delta_point_site.hh (revision 0) +++ mln/core/concept/delta_point_site.hh (revision 0) @@ -0,0 +1,218 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_CORE_CONCEPT_DELTA_POINT_SITE_HH +# define MLN_CORE_CONCEPT_DELTA_POINT_SITE_HH + +/*! \file mln/core/concept/delta_point_site.hh + * + * \brief Definition of the concept of mln::Delta_Point_Site. + */ + +# include <mln/core/concept/object.hh> +# include <mln/core/grids.hh> +# include <mln/trait/all.hh> + + +namespace mln +{ + + // Fwd decl. + template <typename E> struct Delta_Point_Site; + + + + namespace trait + { + + template < typename L, typename R > + struct set_binary_< op::plus, + mln::Delta_Point_Site, L, mln::Delta_Point_Site, R > + { + typedef mln_dpoint(L) ret; + }; + + template < typename L, typename R > + struct set_binary_< op::minus, + mln::Delta_Point_Site, L, mln::Delta_Point_Site, R > + { + typedef mln_dpoint(L) ret; + }; + + } // end of namespace mln::trait + + + + /// Delta point site category flag type. + template <> + struct Delta_Point_Site<void> + { + typedef Object<void> super; + }; + + + /*! \brief FIXME: Doc! + */ + template <typename E> + struct Delta_Point_Site : public Object<E> + { + typedef Delta_Point_Site<void> category; + + /* + enum { dim }; + typedef mesh; + + typedef point; + typedef dpoint; + typedef coord; + + const dpoint& to_dpoint() const; + coord operator[](unsigned i) const; + */ + + protected: + Delta_Point_Site(); + }; + + + + // Operators. + + template <typename D> + std::ostream& + operator<<(std::ostream& ostr, const Delta_Point_Site<D>& dp); + + + template <typename L, typename R> + bool + operator=(const Delta_Point_Site<L>& lhs, const Delta_Point_Site<R>& rhs); + + template <typename L, typename R> + bool + operator<(const Delta_Point_Site<L>& lhs, const Delta_Point_Site<R>& rhs); + + + template <typename L, typename R> + mln_dpoint(L) // FIXME: promote! + operator+(const Delta_Point_Site<L>& lhs, const Delta_Point_Site<R>& rhs); + + template <typename L, typename R> + mln_dpoint(L) // FIXME: promote! + operator-(const Delta_Point_Site<L>& lhs, const Delta_Point_Site<R>& rhs); + + + + +# ifndef MLN_INCLUDE_ONLY + + template <typename E> + Delta_Point_Site<E>::Delta_Point_Site() + { + int dim = E::dim; + mln_invariant(dim > 0); + dim = 0; + typedef mln_mesh(E) mesh; + typedef mln_point(E) point; + typedef mln_dpoint(E) dpoint; + typedef mln_coord(E) coord; + const dpoint& (E::*m1)() const = & E::to_dpoint; + m1 = 0; + coord (E::*m2)(unsigned i) const = & E::operator[]; + m2 = 0; + } + + + template <typename D> + std::ostream& operator<<(std::ostream& ostr, const Delta_Point_Site<D>& dp_) + { + const D& dp = exact(dp_); + ostr << '('; + for (unsigned i = 0; i < D::dim; ++i) + ostr << dp[i] << (i = D::dim - 1 ? ')' : ','); + return ostr; + } + + + template <typename L, typename R> + bool operator=(const Delta_Point_Site<L>& lhs_, const Delta_Point_Site<R>& rhs_) + { + mln::metal::bool_<(int(L::dim) = int(R::dim))>::check(); + const L& lhs = exact(lhs_); + const R& rhs = exact(rhs_); + for (unsigned i = 0; i < L::dim; ++i) + if (lhs[i] != rhs[i]) + return false; + return true; + } + + template <typename L, typename R> + bool operator<(const Delta_Point_Site<L>& lhs_, const Delta_Point_Site<R>& rhs_) + { + mln::metal::bool_<(int(L::dim) = int(R::dim))>::check(); + const L& lhs = exact(lhs_); + const R& rhs = exact(rhs_); + for (unsigned i = 0; i < L::dim; ++i) + { + if (lhs[i] = rhs[i]) + continue; + return lhs[i] < rhs[i]; + } + return false; + } + + template <typename L, typename R> + mln_dpoint(L) // FIXME: promote! + operator+(const Delta_Point_Site<L>& lhs_, const Delta_Point_Site<R>& rhs_) + { + mln::metal::bool_<(int(L::dim) = int(R::dim))>::check(); + const L& lhs = exact(lhs_); + const R& rhs = exact(rhs_); + mln_dpoint(L) tmp; + for (unsigned i = 0; i < L::dim; ++i) + tmp[i] = lhs[i] + rhs[i]; + return tmp; + } + + template <typename L, typename R> + mln_dpoint(L) // FIXME: promote! + operator-(const Delta_Point_Site<L>& lhs_, const Delta_Point_Site<R>& rhs_) + { + mln::metal::bool_<(int(L::dim) = int(R::dim))>::check(); + const L& lhs = exact(lhs_); + const R& rhs = exact(rhs_); + mln_dpoint(L) tmp; + for (unsigned i = 0; i < L::dim; ++i) + tmp[i] = lhs[i] - rhs[i]; + return tmp; + } + +# endif // ! MLN_INCLUDE_ONLY + +} // end of namespace mln + + +#endif // ! MLN_CORE_CONCEPT_DELTA_POINT_SITE_HH Index: mln/core/concept/point.hh --- mln/core/concept/point.hh (revision 1397) +++ mln/core/concept/point.hh (working copy) @@ -34,11 +34,24 @@ */ # include <mln/core/concept/point_site.hh> +# include <mln/core/concept/dpoint.hh> namespace mln { + // Fwd decl. + template <typename E> struct Point; + + + // Point category flag type. + template <> + struct Point<void> + { + typedef Point_Site<void> super; + }; + + /*! \brief Base class for implementation of point classes. * * A point is an element of a space. @@ -53,47 +66,43 @@ */ typedef P point; - /*! \brief The pointer is this point address. + /*! \brief It is a Point so it returns itself. */ - const P* pointer_() const; + const P& to_point() const; protected: Point(); }; - /*! \brief Add a delta-point \p rhs to a point \p lhs. + /*! \brief Shift a point \p by a delta-point \p dp. * - * \param[in,out] lhs The targeted point. - * \param[in] rhs A delta-point. + * \param[in,out] p The targeted point. + * \param[in] dp A delta-point. + * \return A reference to the point \p p once translated by \p dp. * - * \pre The type of \p rhs has to be the Dpoint type associated with - * the type of \p lhs; otherwise this test does not compile. - * - * \return A reference to the point \p lhs once translated by \p - * rhs. + * \pre The type of \p dp has to be compatible with the type of \p + * p. * * \relates mln::Point */ - template <typename P> - P& operator+=(Point<P>& lhs, const mln_dpoint(P)& rhs); + template <typename P, typename D> + P& operator+=(Point<P>& p, const Dpoint<D>& dp); - /*! \brief Remove a delta-point \p rhs to a point \p lhs. - * - * \param[in,out] lhs The targeted point. - * \param[in] rhs A delta-point. + /*! \brief Shift a point \p by the negate of a delta-point \p dp. * - * \pre The type of \p rhs has to be the Dpoint type associated with - * the type of \p lhs; otherwise this test does not compile. + * \param[in,out] p The targeted point. + * \param[in] dp A delta-point. + * \return A reference to the point \p p once translated by - \p dp. * - * \return A reference to the point \p lhs once translated by - \p - * rhs. + * \pre The type of \p dp has to be compatible with the type of \p + * p. * * \relates mln::Point */ - template <typename P> - P& operator-=(Point<P>& lhs, const mln_dpoint(P)& rhs); + template <typename P, typename D> + P& operator-=(Point<P>& p, const Dpoint<D>& dp); @@ -105,25 +114,32 @@ } template <typename P> - const P* Point<P>::pointer_() const + const P& + Point<P>::to_point() const { - return exact(this); + return exact(*this); } - template <typename P> - P& operator+=(Point<P>& lhs, const mln_dpoint(P)& rhs) + template <typename P, typename D> + P& operator+=(Point<P>& p_, const Dpoint<D>& dp_) { + P& p = exact(p_); + const D& dp = exact(dp_); + // FIXME: Use to_vec()! for (unsigned i = 0; i < P::dim; ++i) - exact(lhs)[i] += rhs[i]; - return lhs; + p[i] += dp[i]; + return p; } - template <typename P> - P& operator-=(Point<P>& lhs, const mln_dpoint(P)& rhs) + template <typename P, typename D> + P& operator-=(Point<P>& p_, const Dpoint<D>& dp_) { + P& p = exact(p_); + const D& dp = exact(dp_); + // FIXME: Use to_vec()! for (unsigned i = 0; i < P::dim; ++i) - exact(lhs)[i] -= rhs[i]; - return lhs; + p[i] -= dp[i]; + return p; } # endif // ! MLN_INCLUDE_ONLY Index: mln/core/concept/dpoint.hh --- mln/core/concept/dpoint.hh (revision 1397) +++ mln/core/concept/dpoint.hh (working copy) @@ -32,7 +32,7 @@ * \brief Definition of the concept of mln::Dpoint. */ -# include <mln/core/concept/object.hh> +# include <mln/core/concept/delta_point_site.hh> # include <mln/core/grids.hh> @@ -42,11 +42,12 @@ // Fwd decl. template <typename E> struct Dpoint; + // Dpoint category flag type. template <> struct Dpoint<void> { - typedef Object<void> super; + typedef Delta_Point_Site<void> super; }; @@ -61,160 +62,32 @@ * contents. */ template <typename E> - struct Dpoint : public Object<E> + struct Dpoint : public Delta_Point_Site<E> { typedef Dpoint<void> category; - /* - typedef point; - typedef coord; - enum { dim }; - coord operator[](unsigned i) const; - */ + typedef E dpoint; + + /// It is a Dpoint so it returns itself. + const E& to_dpoint() const; protected: Dpoint(); }; - /*! \brief Give the negate of the delta-point \p rhs. - * - * \param[in] rhs The targeted delta-point. - * - * \invariant For all delta-point dp, we have: -(-dp) = dp. - * - * \return A delta-point (temporary object). - * - * \relates mln::Dpoint - */ - template <typename D> - D operator-(const Dpoint<D>& rhs); - - - /*! \brief Add the couple of delta-points \p lhs and \p rhs. - * - * \param[in] lhs A delta-point. - * \param[in] rhs Another delta-point. - * - * \return A delta-point (temporary object). - * - * \relates mln::Dpoint - */ - template <typename D> - D operator+(const Dpoint<D>& lhs, const Dpoint<D>& rhs); - - - /*! \brief Equality comparison between a couple of delta-point \p lhs - * and \p rhs. - * - * \param[in] lhs A first delta-point. - * \param[in] rhs A second delta-point. - * - * \pre Both \p lhs and \p rhs have to be defined on the same - * topology; otherwise this test does not compile. - * - * \return True if both delta-points have the same coordinates, - * otherwise false. - * - * \relates mln::Dpoint - */ - template <typename Dl, typename Dr> - bool operator=(const Dpoint<Dl>& lhs, const Dpoint<Dr>& rhs); - - - /*! \brief Ordering "less than" comparison between a couple of - * delta-points \p lhs and \p rhs. - * - * \param[in] lhs A first delta-point. - * \param[in] rhs A second delta-point. - * - * \pre Both \p lhs and \p rhs have to be defined on the same - * topology; otherwise this test does not compile. - * - * \return True if both delta-points have the same coordinates, - * otherwise false. - * - * \relates mln::Dpoint - */ - template <typename Dl, typename Dr> - bool operator<(const Dpoint<Dl>& lhs, const Dpoint<Dr>& rhs); - - - /*! \brief Print a delta-point \p p into the output stream \p ostr. - * - * \param[in,out] ostr An output stream. - * \param[in] dp A delta-point. - * - * \return The modified output stream \p ostr. - * - * \relates mln::Dpoint - */ - template <typename D> - std::ostream& operator<<(std::ostream& ostr, const Dpoint<D>& dp); - - - # ifndef MLN_INCLUDE_ONLY template <typename E> Dpoint<E>::Dpoint() { - typedef mln_point(E) point; - typedef mln_coord(E) coord; - enum { dim = E::dim }; - coord (E::*m)(unsigned i) const = & E::operator[]; - m = 0; } - template <typename D> - D operator-(const Dpoint<D>& rhs) - { - D tmp; - for (unsigned i = 0; i < D::dim; ++i) - tmp[i] = - exact(rhs)[i]; - return tmp; - } - - template <typename D> - D operator+(const Dpoint<D>& lhs, const Dpoint<D>& rhs) - { - D tmp; - for (unsigned i = 0; i < D::dim; ++i) - tmp[i] = exact(lhs)[i] + exact(rhs)[i]; - return tmp; - } - - template <typename Dl, typename Dr> - bool operator=(const Dpoint<Dl>& lhs, const Dpoint<Dr>& rhs) - { - for (unsigned i = 0; i < Dl::dim; ++i) - if (exact(lhs)[i] != exact(rhs)[i]) - return false; - return true; - } - - template <typename Dl, typename Dr> - bool operator<(const Dpoint<Dl>& lhs, const Dpoint<Dr>& rhs) - { - for (unsigned i = 0; i < Dl::dim; ++i) - { - if (exact(lhs)[i] = exact(rhs)[i]) - continue; - return exact(lhs)[i] < exact(rhs)[i]; - } - return false; - } - - template <typename D> - std::ostream& operator<<(std::ostream& ostr, const Dpoint<D>& dp) - { - ostr << '('; - for (unsigned i = 0; i < D::dim; ++i) + template <typename E> + const E& + Dpoint<E>::to_dpoint() const { - ostr << exact(dp)[i] - << (i = D::dim - 1 ? ')' : ','); - } - return ostr; + return exact(*this); } # endif // ! MLN_INCLUDE_ONLY Index: mln/core/concept/point_iterator.hh --- mln/core/concept/point_iterator.hh (revision 1397) +++ mln/core/concept/point_iterator.hh (working copy) @@ -31,11 +31,12 @@ /*! \file mln/core/concept/point_iterator.hh * * \brief Definition of the concept of mln::Point_Iterator. + * + * \todo Fix mln/core/concept/doc/point_iterator.hh */ -# include <mln/core/concept/iterator.hh> -# include <mln/core/concept/generalized_point.hh> # include <mln/core/concept/point_site.hh> +# include <mln/core/concept/iterator.hh> // To fetch the macros. namespace mln @@ -51,22 +52,44 @@ * contents. */ template <typename E> - struct Point_Iterator : public Iterator<E>, - public Generalized_Point<E> + struct Point_Iterator : public Point_Site<E> { /* typedef psite; + bool is_valid() const; + void invalidate(); + void start(); + void next_(); operator psite() const; */ + /*! \brief Go to the next element. + * + * \warning This is a final method; iterator classes should not + * re-defined this method. The actual "next" operation has to be + * defined through the \em next_ method. + * + * \pre The iterator is valid. + */ + void next(); // final + protected: Point_Iterator(); }; + # ifndef MLN_INCLUDE_ONLY template <typename E> + void + Point_Iterator<E>::next() // final + { + assert(exact(this)->is_valid()); + exact(this)->next_(); + } + + template <typename E> Point_Iterator<E>::Point_Iterator() { typedef mln_psite(E) psite; @@ -74,6 +97,15 @@ psite (E::*m)() const = & E::operator psite; m = 0; + + bool (E::*m1)() const = & E::is_valid; + m1 = 0; + void (E::*m2)() = & E::invalidate; + m2 = 0; + void (E::*m3)() = & E::start; + m3 = 0; + void (E::*m4)() = & E::next_; + m4 = 0; } # endif // ! MLN_INCLUDE_ONLY Index: mln/core/concept/point_set.hh --- mln/core/concept/point_set.hh (revision 1397) +++ mln/core/concept/point_set.hh (working copy) @@ -38,7 +38,7 @@ * \todo Move out the ops. */ -# include <mln/core/concept/point.hh> +# include <mln/core/concept/point_site.hh> # include <mln/core/concept/point_iterator.hh> Index: mln/core/concept/doc/point_site.hh --- mln/core/concept/doc/point_site.hh (revision 1395) +++ mln/core/concept/doc/point_site.hh (working copy) @@ -25,8 +25,9 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file mln/core/concept/doc/generalized_point.hh - * \brief This file documents the concept of mln::Generalized_Point. +/*! \file mln/core/concept/doc/point_site.hh + * + * \brief This file documents the concept of mln::Point_Site. */ namespace mln @@ -35,12 +36,12 @@ namespace doc { - /*! \brief Documentation class for mln::Generalized_Point. + /*! \brief Documentation class for mln::Point_Site. * - * \see mln::Generalized_Point + * \see mln::Point_Site */ template <typename E> - struct Generalized_Point + struct Point_Site { /*! \var dim * \brief Dimension of the space. @@ -48,6 +49,11 @@ */ enum { dim }; + /*! \brief Mesh associated type. + * \invariant This type has to derive from mln::Mesh. + */ + typedef void mesh; + /*! \brief Point associated type. * \invariant This type has to derive from mln::Point. */ @@ -63,23 +69,13 @@ typedef void coord; - // FIXME: typedef void topo; - - - /*! \brief Either \c E is a point or an convertion operator into - * a point is defined. - * - * \return A point. - */ - operator point() const; - - /*! \brief Give a hook to the point address. + /*! \brief Give a reference to the corresponding point. * * This method allows for iterators to refer to a point. * - * \return A point address. + * \return A point constant reference. */ - const point* pointer_() const; + const point& to_point() const; /*! \brief Read-only access to the \p i-th coordinate value. * Index: mln/core/concept/point_site.hh --- mln/core/concept/point_site.hh (revision 1397) +++ mln/core/concept/point_site.hh (working copy) @@ -25,29 +25,61 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_CORE_CONCEPT_PSITE_HH -# define MLN_CORE_CONCEPT_PSITE_HH +#ifndef MLN_CORE_CONCEPT_POINT_SITE_HH +# define MLN_CORE_CONCEPT_POINT_SITE_HH /*! \file mln/core/concept/point_site.hh + * * \brief Definition of the concept of mln::Point_Site. */ -# include <mln/core/concept/generalized_point.hh> +# include <mln/core/concept/object.hh> +# include <mln/core/concept/delta_point_site.hh> +# include <mln/core/grids.hh> +# include <mln/trait/all.hh> + namespace mln { - // FIXME: Hack is "Point" instead of "Points_Site"; change it! + // Fwd decls. + template <typename E> struct Point_Site; + + + + namespace trait + { + template < typename P, typename D > + struct set_binary_< op::plus, + mln::Point_Site, P, mln::Delta_Point_Site, D > + { + typedef mln_point(P) ret; + }; - // Fwd decl. - template <typename E> struct Point; + template < typename P, typename D > + struct set_binary_< op::minus, + mln::Point_Site, P, mln::Delta_Point_Site, D > + { + typedef mln_point(P) ret; + }; + template < typename L, typename R > + struct set_binary_< op::minus, + mln::Point_Site, L, mln::Point_Site, R > + { + typedef mln_dpoint(L) ret; + }; - /// Point_Site category flag type. + } // end of namespace mln::trait + + + + + /// Point site category flag type. template <> - struct Point<void> + struct Point_Site<void> { typedef Object<void> super; }; @@ -58,13 +90,10 @@ * * A point site ("psite" for short) is an object that allows an * efficient access to data associated with a point. A point site - * is either a point or designates a point: regular points, deriving - * from mln::Point, are point sites, yet some point sites are not - * points.) A point site has the behavior expected from every - * point; see mln::Generalized_Point. + * is either a point or designates a point. * - * When a point site is not a point, it is automatically convertible - * to the point it designates. + * When a point site is not really a point, it is automatically + * convertible to the point it designates. * * * Let us take the example of a 2D image encoded as an array of runs @@ -76,16 +105,21 @@ * proper point site is a pair (index of run, index within the run). */ template <typename E> - struct Point_Site : public Object<E>, - public Generalized_Point<E> + struct Point_Site : public Object<E> { - typedef Point<void> category; // FIXME: This is a hack! Change the hierarchy... + typedef Point_Site<void> category; /* - const point* pointer_() const - { - return & (exact(this)->operator point()); - } + enum { dim }; + typedef mesh; + + typedef point; + typedef dpoint; + typedef coord; + + const point& to_point() const; + + coord operator[](unsigned i) const; */ protected: @@ -93,11 +127,219 @@ }; + /*! \brief Equality comparison between a couple of point site \p lhs + * and \p rhs. + * + * \param[in] lhs A first point site. + * \param[in] rhs A second point site. + * + * \pre Both \p lhs and \p rhs have to be defined on the same + * topology; otherwise this test does not compile. + * + * \return True if both point sites have the same + * coordinates, otherwise false. + * + * \relates mln::Point_Site + */ + template <typename L, typename R> + bool operator=(const Point_Site<L>& lhs, const Point_Site<R>& rhs); + + + /*! \brief Ordering "less than" comparison between a couple of + * point sites \p lhs and \p rhs. + * + * \param[in] lhs A first point site. + * \param[in] rhs A second point site. + * + * This test is based on a lexicographical ordering over coordinates. + * + * \warning In the general case this ordering relationship is \em + * not bound to the way of browsing a domain with a forward point + * iterator. + * + * \pre Both \p lhs and \p rhs have to be defined on the same + * topology; otherwise this test does not compile. + * + * \return True if \p lhs is before \p rhs in the sense of the + * coordinates lexicographic comparison, otherwise false. + * + * \relates mln::Point_Site + */ + template <typename L, typename R> + bool operator<(const Point_Site<L>& lhs, const Point_Site<R>& rhs); + + + /*! \brief Difference between a couple of point site \p lhs and \p + * rhs. + * + * \param[in] lhs A first point site. + * \param[in] rhs A second point site. + * + * \warning There is no type promotion in milena so the client + * has to make sure that both points are defined with the same + * type of coordinates. + * + * \pre Both \p lhs and \p rhs have to be defined on the same + * topology and with the same type of coordinates; otherwise this + * test does not compile. + * + * \post The result, \p dp, is such as \p lhs = \p rhs + \p dp. + * + * \return A delta point (temporary object). + * + * \relates mln::Point_Site + * \see mln::Delta_Point_Site + */ + template <typename L, typename R> + mln_dpoint(L) + operator-(const Point_Site<L>& lhs, const Point_Site<R>& rhs); + + + /*! \brief Add a delta-point \p rhs to a point site \p lhs. + * + * \param[in] p A point site. + * \param[in] dp A delta-point. + * + * The type of \p dp has to compatible with the type of \p p. + * + * \return A point (temporary object). + * + * \relates mln::Point_Site + * \see mln::Delta_Point_Site + */ + template <typename P, typename D> + mln_point(P) + operator+(const Point_Site<P>& p, const Delta_Point_Site<D>& dp); + + + /*! \brief Substract a delta-point \p rhs to a point site \p lhs. + * + * \param[in] p A point site. + * \param[in] dp A delta-point. + * + * The type of \p dp has to compatible with the type of \p p. + * + * \return A point (temporary object). + * + * \see mln::Dpoint + * \see mln::Delta_Point_Site + */ + template <typename P, typename D> + mln_point(P) + operator-(const Point_Site<P>& p, const Delta_Point_Site<D>& dp); + + + /*! \brief Print a point site \p p into the output stream \p ostr. + * + * \param[in,out] ostr An output stream. + * \param[in] p A point site. + * + * \return The modified output stream \p ostr. + * + * \relates mln::Point_Site + */ + template <typename P> + std::ostream& operator<<(std::ostream& ostr, const Point_Site<P>& p); + + + + # ifndef MLN_INCLUDE_ONLY template <typename E> Point_Site<E>::Point_Site() { + int dim = E::dim; + mln_invariant(dim > 0); + dim = 0; + typedef mln_mesh(E) mesh; + typedef mln_point(E) point; + typedef mln_dpoint(E) dpoint; + typedef mln_coord(E) coord; + const point& (E::*m1)() const = & E::to_point; + m1 = 0; + coord (E::*m2)(unsigned i) const = & E::operator[]; + m2 = 0; + } + + + // Operators. + + template <typename L, typename R> + bool operator=(const Point_Site<L>& lhs_, const Point_Site<R>& rhs_) + { + mln::metal::bool_<(int(L::dim) = int(R::dim))>::check(); + const L& lhs = exact(lhs_); + const R& rhs = exact(rhs_); + for (unsigned i = 0; i < L::dim; ++i) + if (lhs[i] != rhs[i]) + return false; + return true; + } + + template <typename L, typename R> + bool operator<(const Point_Site<L>& lhs_, const Point_Site<R>& rhs_) + { + mln::metal::bool_<(int(L::dim) = int(R::dim))>::check(); + const L& lhs = exact(lhs_); + const R& rhs = exact(rhs_); + for (unsigned i = 0; i < L::dim; ++i) + { + if (lhs[i] = rhs[i]) + continue; + return lhs[i] < rhs[i]; + } + return false; + } + + template <typename L, typename R> + mln_dpoint(L) // FIXME: promote! + operator-(const Point_Site<L>& lhs_, const Point_Site<R>& rhs_) + { + mln::metal::bool_<(int(L::dim) = int(R::dim))>::check(); + const L& lhs = exact(lhs_); + const R& rhs = exact(rhs_); + mln_dpoint(L) tmp; + for (unsigned i = 0; i < L::dim; ++i) + tmp[i] = lhs[i] - rhs[i]; + mln_postcondition(rhs_ + tmp = lhs_); + return tmp; + } + + template <typename P, typename D> + mln_point(P) // FIXME: promote! + operator+(const Point_Site<P>& p_, const Delta_Point_Site<D>& dp_) + { + mln::metal::bool_<(int(P::dim) = int(D::dim))>::check(); + const P& p = exact(p_); + const D& dp = exact(dp_); + mln_point(P) tmp; + for (unsigned i = 0; i < P::dim; ++i) + tmp[i] = p[i] + dp[i]; + return tmp; + } + + template <typename P, typename D> + mln_point(P) // FIXME: promote! + operator-(const Point_Site<P>& p_, const Delta_Point_Site<D>& dp_) + { + mln::metal::bool_<(int(P::dim) = int(D::dim))>::check(); + const P& p = exact(p_); + const D& dp = exact(dp_); + mln_point(P) tmp; + for (unsigned i = 0; i < P::dim; ++i) + tmp[i] = p[i] - dp[i]; + return tmp; + } + + template <typename P> + std::ostream& operator<<(std::ostream& ostr, const Point_Site<P>& p_) + { + const P& p = exact(p_); + ostr << '('; + for (unsigned i = 0; i < P::dim; ++i) + ostr << p[i] << (i = P::dim - 1 ? ')' : ','); + return ostr; } # endif // ! MLN_INCLUDE_ONLY @@ -105,4 +347,4 @@ } // end of namespace mln -#endif // ! MLN_CORE_CONCEPT_PSITE_HH +#endif // ! MLN_CORE_CONCEPT_POINT_SITE_HH Index: mln/linear/local/convolve.hh --- mln/linear/local/convolve.hh (revision 1397) +++ mln/linear/local/convolve.hh (working copy) @@ -34,7 +34,7 @@ */ # include <mln/core/concept/image.hh> -# include <mln/core/concept/generalized_point.hh> +# include <mln/core/concept/point_site.hh> # include <mln/core/concept/generalized_pixel.hh> # include <mln/core/concept/weighted_window.hh> # include <mln/metal/const.hh> @@ -61,7 +61,7 @@ */ template <typename I, typename P, typename W, typename R> void convolve(const Image<I>& input, - const Generalized_Point<P>& p, + const Point_Site<P>& p, const Weighted_Window<W>& w_win, R& result); @@ -88,11 +88,11 @@ template <typename I, typename P, typename W, typename R> void convolve(trait::image::speed::any, const I& input, - const Generalized_Point<P>& p_, + const Point_Site<P>& p_, const W& w_win, R& result) { - const P& p = internal::force_exact<P>(p_); + const P& p = exact(p_); R tmp = 0; // FIXME: zero? mln_qiter(W) q(w_win, p); @@ -103,11 +103,11 @@ template <typename I, typename P, typename W, typename R> void convolve(trait::image::speed::fastest, const I& input, - const Generalized_Point<P>& p_, + const Point_Site<P>& p_, const W& w_win, R& result) { - const P& p = internal::force_exact<P>(p_); + const P& p = exact(p_); mln_precondition(input.border() >= w_win.delta()); @@ -144,7 +144,7 @@ template <typename I, typename P, typename W, typename R> void convolve(const Image<I>& input, - const Generalized_Point<P>& p, + const Point_Site<P>& p, const Weighted_Window<W>& w_win, R& result) { Index: mln/value/concept/built_in.hh --- mln/value/concept/built_in.hh (revision 1397) +++ mln/value/concept/built_in.hh (working copy) @@ -42,7 +42,10 @@ namespace value { + // Fwd decl. template <typename B> struct Built_In; + + // Category flag type. template <> struct Built_In<void> // No inheritance here since this category is special (on the side). Index: mln/convert/to_window.hh --- mln/convert/to_window.hh (revision 1397) +++ mln/convert/to_window.hh (working copy) @@ -35,7 +35,7 @@ # include <set> -# include <mln/core/concept/dpoint.hh> +# include <mln/core/concept/delta_point_site.hh> # include <mln/core/concept/neighborhood.hh> # include <mln/core/window.hh> # include <mln/pw/image.hh> @@ -124,7 +124,8 @@ template <typename D> window<D> to_window(const std::set<D>& s) { - mln::metal::is_a<D, Dpoint>::check(); + // FIXME: Was: mln::metal::is_a<D, Dpoint>::check(); + mln::metal::is_a<D, Delta_Point_Site>::check(); window<D> win; for (typename std::set<D>::const_iterator i = s.begin(); i != s.end(); ++i) Index: mln/convert/to_set_p.hh --- mln/convert/to_set_p.hh (revision 1397) +++ mln/convert/to_set_p.hh (working copy) @@ -35,8 +35,8 @@ # include <set> -# include <mln/core/concept/dpoint.hh> # include <mln/core/concept/neighborhood.hh> +# include <mln/core/concept/point_site.hh> # include <mln/core/set_p.hh> # include <mln/pw/image.hh> # include <mln/pw/cst.hh> @@ -112,7 +112,7 @@ template <typename P> set_p<P> to_set_p(const std::set<P>& s) { - mln::metal::is_a<P, Point>::check(); + mln::metal::is_a<P, Point_Site>::check(); set_p<P> pset; for (typename std::set<P>::const_iterator i = s.begin(); i != s.end(); ++i) Index: mln/convert/to_dpoint.hh --- mln/convert/to_dpoint.hh (revision 1397) +++ mln/convert/to_dpoint.hh (working copy) @@ -33,7 +33,7 @@ * \brief Conversions to mln::Dpoint. */ -# include <mln/core/concept/generalized_point.hh> +# include <mln/core/concept/point_site.hh> namespace mln @@ -42,17 +42,19 @@ namespace convert { - /// Convert a generalized point \p p into a delta-point. + /// Convert a point site \p p into a delta-point. template <typename P> - mln_dpoint(P) to_dpoint(const Generalized_Point<P>& p); + mln_dpoint(P) to_dpoint(const Point_Site<P>& p); # ifndef MLN_INCLUDE_ONLY template <typename P> - mln_dpoint(P) to_dpoint(const Generalized_Point<P>& p_) + mln_dpoint(P) to_dpoint(const Point_Site<P>& p_) { - const P& p = internal::force_exact<P>(p_); + const P& p = exact(p_); + // FIXME HERE: Add ctors from vec in point_ and dpoint_. + // FIXME HERE: Then change to "return mln_dpoint(P)(p.to_vec());" mln_dpoint(P) dp; for (unsigned i = 0; i < P::dim; ++i) dp[i] = p[i];
participants (1)
-
Thierry Geraud