
https://svn.lrde.epita.fr/svn/oln/trunk/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Add mesh and factor some code. New files. * mln/core/internal/point_iterator_base.hh: New. * mln/core/internal/point_set_base.hh: New. * mln/core/concept/mesh.hh: New. * mln/core/concept/regular_grid.hh: New. * mln/core/grids.hh: New. Update to take into account the notion of mesh. * doc/Doxyfile.in, * mln/pw/image.hh, * mln/core/dpoint1d.hh, * mln/core/dpoint2d.hh, * mln/core/dpoints_piter.hh, * mln/core/dpoint3d.hh, * mln/core/macros.hh, * mln/core/box.hh, * mln/core/point.hh, * mln/core/internal/piter_adaptor.hh, * mln/core/internal/run_pset.hh, * mln/core/internal/run_psite.hh, * mln/core/internal/image_base.hh, * mln/core/point1d.hh, * mln/core/point2d.hh, * mln/core/point3d.hh, * mln/core/line_piter.hh, * mln/core/vec_p_piter.hh, * mln/core/line2d.hh, * mln/core/box_piter.hh, * mln/core/cast_image.hh, * mln/core/queue_p.hh, * mln/core/pset_if.hh, * mln/core/vec_p.hh, * mln/core/concept/image.hh, * mln/core/concept/dpoint.hh, * mln/core/concept/point_iterator.hh, * mln/core/concept/generalized_point.hh, * mln/core/concept/point_set.hh, * mln/core/concept/object.hh, * mln/core/dpoint.hh, * mln/core/set_p.hh, * mln/metal/is_a.hh: Update. doc/Doxyfile.in | 1 mln/core/box.hh | 36 +++++------ mln/core/box_piter.hh | 40 +------------ mln/core/cast_image.hh | 11 +-- mln/core/concept/dpoint.hh | 1 mln/core/concept/generalized_point.hh | 7 +- mln/core/concept/image.hh | 7 ++ mln/core/concept/mesh.hh | 74 ++++++++++++++++++++++++ mln/core/concept/object.hh | 1 mln/core/concept/point_iterator.hh | 3 mln/core/concept/point_set.hh | 4 + mln/core/concept/regular_grid.hh | 65 +++++++++++++++++++++ mln/core/dpoint.hh | 68 ++++++++++------------ mln/core/dpoint1d.hh | 2 mln/core/dpoint2d.hh | 2 mln/core/dpoint3d.hh | 2 mln/core/dpoints_piter.hh | 29 ++------- mln/core/grids.hh | 83 +++++++++++++++++++++++++++ mln/core/internal/image_base.hh | 8 ++ mln/core/internal/piter_adaptor.hh | 26 +------- mln/core/internal/point_iterator_base.hh | 95 +++++++++++++++++++++++++++++++ mln/core/internal/point_set_base.hh | 86 ++++++++++++++++++++++++++++ mln/core/internal/run_pset.hh | 33 ++++------ mln/core/internal/run_psite.hh | 31 +++++++++- mln/core/line2d.hh | 10 --- mln/core/line_piter.hh | 21 ------ mln/core/macros.hh | 7 ++ mln/core/point.hh | 78 ++++++++++++------------- mln/core/point1d.hh | 2 mln/core/point2d.hh | 2 mln/core/point3d.hh | 2 mln/core/pset_if.hh | 15 ++-- mln/core/queue_p.hh | 10 --- mln/core/set_p.hh | 12 --- mln/core/vec_p.hh | 13 ---- mln/core/vec_p_piter.hh | 34 +---------- mln/metal/is_a.hh | 2 mln/pw/image.hh | 11 +-- 38 files changed, 628 insertions(+), 306 deletions(-) Index: doc/Doxyfile.in --- doc/Doxyfile.in (revision 1122) +++ doc/Doxyfile.in (working copy) @@ -1064,6 +1064,7 @@ "mln_vset(T)=typename T::vset" \ "mln_rvalue(T)=typename T::rvalue" \ "mln_lvalue(T)=typename T::lvalue" \ + "mln_mesh(T)=typename T::mesh" \ "mln_coord(T)=typename T::coord" \ "mln_point(T)=typename T::point" \ "mln_dpoint(T)=typename T::dpoint" Index: mln/pw/image.hh --- mln/pw/image.hh (revision 1122) +++ mln/pw/image.hh (working copy) @@ -62,13 +62,14 @@ * */ template <typename F, typename S> - struct image : public internal::image_base_< S, image<F,S> > + class image : public internal::image_base_< S, image<F,S> > { - /// Point_Site associated type. - typedef mln_psite(S) psite; + typedef internal::image_base_< S, image<F,S> > super_; + public: + + // From super class. + typedef mln_psite(super_) psite; - /// Point_Set associated type. - typedef S pset; /// Value associated type. typedef mln_result(F) value; Index: mln/core/dpoint1d.hh --- mln/core/dpoint1d.hh (revision 1122) +++ mln/core/dpoint1d.hh (working copy) @@ -43,7 +43,7 @@ /*! \brief Type alias for a delta-point defined on the 1D square * grid with integer coordinates. */ - typedef dpoint_<1,int> dpoint1d; + typedef dpoint_<grid::tick, int> dpoint1d; } // end of namespace mln Index: mln/core/dpoint2d.hh --- mln/core/dpoint2d.hh (revision 1122) +++ mln/core/dpoint2d.hh (working copy) @@ -43,7 +43,7 @@ /*! \brief Type alias for a delta-point defined on the 2D square * grid with integer coordinates. */ - typedef dpoint_<2,int> dpoint2d; + typedef dpoint_<grid::square, int> dpoint2d; } // end of namespace mln Index: mln/core/dpoints_piter.hh --- mln/core/dpoints_piter.hh (revision 1122) +++ mln/core/dpoints_piter.hh (working copy) @@ -33,7 +33,7 @@ * \brief Definition of mln::dpoints_fwd_piter and mln::dpoints_bkd_piter. */ -# include <mln/core/concept/point_iterator.hh> +# include <mln/core/internal/point_iterator_base.hh> # include <mln/core/concept/generalized_point.hh> @@ -46,25 +46,10 @@ * The parameter \c D is the type of delta-points. */ template <typename D> - class dpoints_fwd_piter : public Point_Iterator< dpoints_fwd_piter<D> > + class dpoints_fwd_piter : public internal::point_iterator_base_< mln_point(D), dpoints_fwd_piter<D> > { public: - /// Space dimension. - enum { dim = D::dim }; - - /// Dpoint associated type. - typedef D dpoint; - - /// Point associated type. - typedef mln_point(D) point; - - /// Point_Site associated type. - typedef point psite; - - /// Coordinate associated type. - typedef mln_coord(D) coord; - /*! \brief Constructor. * * \param[in] dps Object that can provide an array of delta-points. @@ -78,7 +63,7 @@ operator mln_point(D) () const; /// Address of the point this iterator designates. - const point* pointer_() const; + const mln_point(D)* pointer_() const; /// Test the iterator validity. bool is_valid() const; @@ -93,10 +78,10 @@ void next_(); /// Give the i-th coordinate. - coord operator[](unsigned i) const; + mln_coord(D) operator[](unsigned i) const; /// The point around which this iterator moves. - const point& center_point() const; + const mln_point(D)& center_point() const; /// Force this iterator to update its location to take into /// account that its center point may have moved. @@ -105,10 +90,10 @@ protected: const std::vector<D>& dps_; - const point& p_ref_; // reference point (or "center point") + const mln_point(D)& p_ref_; // reference point (or "center point") unsigned i_; - point p_; // location of this iterator; p_ makes this iterator be + mln_point(D) p_; // location of this iterator; p_ makes this iterator be // itself a potential center point (Cf. the pointer_() method). }; Index: mln/core/dpoint3d.hh --- mln/core/dpoint3d.hh (revision 1122) +++ mln/core/dpoint3d.hh (working copy) @@ -43,7 +43,7 @@ /*! \brief Type alias for a delta-point defined on the 3D square * grid with integer coordinates. */ - typedef dpoint_<3,int> dpoint3d; + typedef dpoint_<grid::cube, int> dpoint3d; } // end of namespace mln Index: mln/core/macros.hh --- mln/core/macros.hh (revision 1122) +++ mln/core/macros.hh (working copy) @@ -104,6 +104,13 @@ # define mln_lvalue(T) typename T::lvalue +// m + + +/// Shortcut to access the mesh type associated to T. +# define mln_mesh(T) typename T::mesh + + // p /// Shortcut to access the type of point iterator (piter) associated to T. Index: mln/core/box.hh --- mln/core/box.hh (revision 1122) +++ mln/core/box.hh (working copy) @@ -54,44 +54,40 @@ struct box_ : public Box< box_<P> >, public internal::box_impl_< P::dim, mln_coord(P), box_<P> > { - /*! \brief Point_Site associated type. - */ + /// Mesh associated type. + typedef mln_mesh(P) mesh; + + /// Point_Site associated type. typedef P psite; - /*! \brief Point associated type. - */ + /// Point associated type. typedef P point; - /*! \brief Forward Point_Iterator associated type. - */ + /// Dpoint associated type. + typedef mln_dpoint(P) dpoint; + + /// Forward Point_Iterator associated type. typedef box_fwd_piter_<P> fwd_piter; - /*! \brief Backward Point_Iterator associated type. - */ + /// Backward Point_Iterator associated type. typedef box_bkd_piter_<P> bkd_piter; - /*! \brief Minimum point. - */ + /// Minimum point. P pmin() const; - /*! \brief Reference to the minimum point. - */ + /// Reference to the minimum point. P& pmin(); - /*! \brief Maximum point. - */ + /// Maximum point. P pmax() const; - /*! \brief Reference to the maximum point. - */ + /// Reference to the maximum point. P& pmax(); - /*! \brief Constructor without argument. - */ + /// Constructor without argument. box_(); - /*! \brief Constructor of a box going from \p pmin to \p pmax. - */ + /// Constructor of a box going from \p pmin to \p pmax. box_(const point& pmin, const point& pmax); /*! \brief Test if \p p belongs to the box. Index: mln/core/point.hh --- mln/core/point.hh (revision 1122) +++ mln/core/point.hh (working copy) @@ -42,7 +42,7 @@ { // fwd decl - template <unsigned n, typename C> struct dpoint_; + template <typename M, typename C> struct dpoint_; /*! \brief Generic point class. @@ -50,22 +50,23 @@ * Parameters are \c n the dimension of the space and \c C the * coordinate type in this space. */ - template <unsigned n, typename C> - struct point_ : public Point< point_<n,C> >, - public internal::mutable_coord_impl_< n, C, point_<n,C> > + template <typename M, typename C> + struct point_ : public Point< point_<M,C> >, + public internal::mutable_coord_impl_< M::dim, C, point_<M,C> > { /*! \var dim * \brief Dimension of the space. * \invariant dim > 0 */ - enum { dim = n }; + enum { dim = M::dim }; - /*! \brief Dpoint associated type. - */ - typedef dpoint_<n,C> dpoint; + /// Mesh associated type. + typedef M mesh; - /*! \brief Coordinate associated type. - */ + /// Dpoint associated type. + typedef dpoint_<M,C> dpoint; + + /// Coordinate associated type. typedef C coord; /*! \brief Read-only access to the \p i-th coordinate value. @@ -80,81 +81,78 @@ */ C& operator[](unsigned i); - /*! \brief Constructor without argument. - */ + /// Constructor without argument. point_(); - /*! \brief Constructor; coordinates are set by function \p f. - */ + /// Constructor; coordinates are set by function \p f. template <typename F> point_(const Function_i2v<F>& f); - /*! \brief Set all coordinates to the value \p c. - */ + /// Set all coordinates to the value \p c. void set_all(C c); /// Origin point (all coordinates are 0). - static const point_<n,C> zero; + static const point_<M,C> zero; /// Shifting by \p dp. - point_<n, C>& operator+=(const dpoint& dp); + point_<M,C>& operator+=(const dpoint& dp); /// Type of the array of coordinates. - typedef const C (&vec_t)[n]; + typedef const C (&vec_t)[dim]; /// Hook to coordinates. vec_t to_vec() const { return coord_; } protected: - C coord_[n]; + C coord_[dim]; }; # ifndef MLN_INCLUDE_ONLY - template <unsigned n, typename C> - C point_<n,C>::operator[](unsigned i) const + template <typename M, typename C> + C point_<M,C>::operator[](unsigned i) const { - assert(i < n); + assert(i < dim); return this->coord_[i]; } - template <unsigned n, typename C> - C& point_<n,C>::operator[](unsigned i) + template <typename M, typename C> + C& point_<M,C>::operator[](unsigned i) { - assert(i < n); + assert(i < dim); return this->coord_[i]; } - template <unsigned n, typename C> - point_<n,C>::point_() + template <typename M, typename C> + point_<M,C>::point_() { } - template <unsigned n, typename C> + template <typename M, typename C> template <typename F> - point_<n,C>::point_(const Function_i2v<F>& f_) + point_<M,C>::point_(const Function_i2v<F>& f_) { const F& f = exact(f_); - for (unsigned i = 0; i < n; ++i) + for (unsigned i = 0; i < dim; ++i) coord_[i] = f(i); } - template <unsigned n, typename C> - void point_<n,C>::set_all(C c) + template <typename M, typename C> + void point_<M,C>::set_all(C c) { - for (unsigned i = 0; i < n; ++i) + for (unsigned i = 0; i < dim; ++i) coord_[i] = c; } - template <unsigned n, typename C> - const point_<n,C> point_<n,C>::zero = all(0); + template <typename M, typename C> + const point_<M,C> point_<M,C>::zero = all(0); - template <unsigned n, typename C> - point_<n, C>& - point_<n,C>::operator+=(const dpoint& dp) + template <typename M, typename C> + point_<M,C>& + point_<M,C>::operator+=(const dpoint& dp) { - for (unsigned i = 0; i < n; ++i) + for (unsigned i = 0; i < dim; ++i) coord_[i] += dp[i]; return *this; } Index: mln/core/internal/point_iterator_base.hh --- mln/core/internal/point_iterator_base.hh (revision 0) +++ mln/core/internal/point_iterator_base.hh (revision 0) @@ -0,0 +1,95 @@ +// 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_INTERNAL_POINT_ITERATOR_BASE_HH +# define MLN_CORE_INTERNAL_POINT_ITERATOR_BASE_HH + +/*! \file mln/core/internal/point_iterator_base.hh + * + * \brief Base class to factor code for point iterator classes. + */ + +# include <mln/core/concept/point_iterator.hh> +# include <mln/core/concept/point_site.hh> + + +namespace mln +{ + + namespace internal + { + + + /*! \brief A base class for point iterators. + * + * Parameter \c P is a point site type. + * + * \internal + */ + template <typename P, typename E> + struct point_iterator_base_ : public Point_Iterator<E> + { + /// Psite associated type. + typedef P psite; + + /// Mesh associated type. + typedef mln_mesh(P) mesh; + + /// Dim value. + enum { dim = mesh::dim }; + + /// Point associated type. + typedef mln_point(P) point; + + /// Dpoint associated type. + typedef mln_dpoint(P) dpoint; + + /// Coord associated type. + typedef mln_coord(point) coord; + + protected: + /// Constructor. + point_iterator_base_(); + }; + + +#ifndef MLN_INCLUDE_ONLY + + template <typename P, typename E> + point_iterator_base_<P, E>::point_iterator_base_() + { + mln::metal::is_a<P, Point_Site>::check(); + } + +#endif // ! MLN_INCLUDE_ONLY + + } // end of namespace internal + +} // end of namespace mln + + +#endif // ! MLN_CORE_INTERNAL_POINT_ITERATOR_BASE_HH Index: mln/core/internal/piter_adaptor.hh --- mln/core/internal/piter_adaptor.hh (revision 1122) +++ mln/core/internal/piter_adaptor.hh (working copy) @@ -33,7 +33,7 @@ * \brief Definition of iterators on points of boxes. */ -# include <mln/core/concept/point_iterator.hh> +# include <mln/core/internal/point_iterator_base.hh> # include <mln/core/concept/box.hh> @@ -49,38 +49,21 @@ * parameter E is the exact type. */ template <typename Pi, typename E> - class piter_adaptor_ : public Point_Iterator<E> + class piter_adaptor_ : public internal::point_iterator_base_< mln_psite(Pi), E > { public: - /// Space dimension. - enum { dim = Pi::dim }; - - /// Point_Site associated type. - typedef mln_psite(Pi) psite; - - /// Point associated type. - typedef mln_point(Pi) point; - - /// Dpoint associated type. - typedef mln_dpoint(Pi) dpoint; - - /// Coordinate associated type. - typedef mln_coord(Pi) coord; - - /// Constructor from a point iterator \p piter. piter_adaptor_(const Pi& piter); - /// Convertion to point. operator mln_point(Pi) () const; /// Address of the point. - const point* pointer_() const; + const mln_point(Pi)* pointer_() const; /// Give the i-th coordinate. - coord operator[](unsigned i) const; + mln_coord(Pi) operator[](unsigned i) const; /// Test the iterator validity. bool is_valid() const; @@ -104,7 +87,6 @@ # ifndef MLN_INCLUDE_ONLY - template <typename Pi, typename E> piter_adaptor_<Pi,E>::piter_adaptor_(const Pi& piter) : piter_(piter) Index: mln/core/internal/point_set_base.hh --- mln/core/internal/point_set_base.hh (revision 0) +++ mln/core/internal/point_set_base.hh (revision 0) @@ -0,0 +1,86 @@ +// 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_INTERNAL_POINT_SET_BASE_HH +# define MLN_CORE_INTERNAL_POINT_SET_BASE_HH + +/*! \file mln/core/internal/point_set_base.hh + * + * \brief Definition of a base class for point set classes. + */ + +# include <mln/core/concept/point_set.hh> +# include <mln/core/grids.hh> + + +namespace mln +{ + + namespace internal + { + + /*! \brief A base class for point set classes. + * + * \p P is a point site type. + * + * \internal + */ + template <typename P, typename E> + struct point_set_base_ : public Point_Set<E> + { + /// Point_Site associated type. + typedef P psite; + + /// Mesh associated type. + typedef mln_mesh(P) mesh; + + /// Point associated type. + typedef mln_point(P) point; + + /// Dpoint associated type. + typedef mln_dpoint(point) dpoint; + + protected: + point_set_base_(); + }; + + +# ifndef MLN_INCLUDE_ONLY + + template <typename S, typename E> + point_set_base_<S,E>::point_set_base_() + { + } + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::internal + +} // end of namespace mln + + +#endif // ! MLN_CORE_INTERNAL_POINT_SET_BASE_HH Index: mln/core/internal/run_pset.hh --- mln/core/internal/run_pset.hh (revision 1122) +++ mln/core/internal/run_pset.hh (working copy) @@ -34,8 +34,8 @@ * (for internal use only). */ -# include <mln/core/concept/point_set.hh> -# include <mln/core/concept/point_iterator.hh> +# include <mln/core/internal/point_set_base.hh> +# include <mln/core/internal/point_iterator_base.hh> # include <mln/core/internal/run_psite.hh> # include <mln/accu/bbox.hh> @@ -59,19 +59,18 @@ * Parameter \c P is the type of the image point. */ template <typename P> - class run_pset_ : public Point_Set<run_pset_<P> > + class run_pset_ : public internal::point_set_base_< run_psite<P>, run_pset_<P> > { public: - typedef P point; - typedef internal::run_psite<point> psite; - typedef std::vector<std::pair<point, unsigned> > std_container; + + typedef std::vector<std::pair<P, unsigned> > std_container; typedef run_fwd_piter_<P> fwd_piter; typedef run_bkd_piter_<P> bkd_piter; run_pset_(); /// Test is \p p belongs to this point set. - bool has(const psite& p) const; + bool has(const run_psite<P>& p) const; /// Give the exact bounding box. const box_<P>& bbox() const; /// Give the number of points. @@ -104,7 +103,7 @@ template <typename P> bool - run_pset_<P>::has(const typename run_pset_<P>::psite& p) const + run_pset_<P>::has(const run_psite<P>& p) const { for (unsigned i = 0; i < con_.size(); ++i) { @@ -132,7 +131,7 @@ void run_pset_<P>::insert(const P& p, unsigned len) { - point run_pend; + P run_pend; typename std_container::value_type elt (p, len); con_.push_back(elt); @@ -176,31 +175,25 @@ * Parameter \c E is the exact type of the iterator */ template <typename P, typename E> - class run_piter_ : public Point_Iterator<E> + class run_piter_ : public internal::point_iterator_base_< internal::run_psite<P>, E > { public: typedef typename run_pset_<P>::std_container std_container; - typedef P point; - typedef mln_dpoint(P) dpoint; - typedef mln_coord(P) coord; - typedef internal::run_psite<P> psite; - - enum { dim = P::dim }; /// Convertion into a point-site. - operator psite () const; + operator internal::run_psite<P> () const; /// Convertion into a point. operator P () const; /// Return a pointer of the current point. const P* pointer_() const; /// Access to the current point coordinates. - coord operator[](unsigned i) const; + mln_coord(P) operator[](unsigned i) const; protected: /// Current point. P p_; /// Current site. - psite site_; + internal::run_psite<P> site_; /// Point set container. const std_container& con_; @@ -237,7 +230,7 @@ } template <typename P, typename E> - typename run_piter_<P, E>::coord + mln_coord(P) run_piter_<P, E>::operator[] (unsigned i) const { mln_precondition(exact(this)->is_valid()); Index: mln/core/internal/run_psite.hh --- mln/core/internal/run_psite.hh (revision 1122) +++ mln/core/internal/run_psite.hh (working copy) @@ -33,6 +33,9 @@ * \brief Definition of class mln::internal::run_psite_ for internal use only */ +# include <mln/core/concept/point_site.hh> + + namespace mln { @@ -44,9 +47,16 @@ * Parameter \c P is the type of the image point. */ template <typename P> - class run_psite + class run_psite : public Point_Site< run_psite<P> > { public: + + typedef mln_mesh(P) mesh; + enum { dim = P::dim }; + typedef P point; + typedef mln_dpoint(P) dpoint; + typedef mln_coord(P) coord; + run_psite(); run_psite(P point, unsigned index, unsigned pset_pos); @@ -64,6 +74,9 @@ /// Return the position of this psite in the current range. unsigned& index_(); + const P* pointer_() const; + mln_coord(P) operator[](unsigned i) const; + protected: /// Start of the psite range. P point_; @@ -136,6 +149,22 @@ { return range_index_; } + + template <typename P> + const P* + run_psite<P>::pointer_() const + { + return & point_; + } + + template <typename P> + mln_coord(P) + run_psite<P>::operator[](unsigned i) const + { + mln_precondition(i < dim); + return point_[i]; + } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace internal Index: mln/core/internal/image_base.hh --- mln/core/internal/image_base.hh (revision 1122) +++ mln/core/internal/image_base.hh (working copy) @@ -34,6 +34,7 @@ */ # include <mln/core/concept/image.hh> +# include <mln/core/grids.hh> namespace mln @@ -82,6 +83,8 @@ /*! \brief A base class for images. * + * Parameter \p S is a point set type. + * * \internal */ template <typename S, typename E> @@ -93,13 +96,16 @@ /// Point_Set associated type. typedef S pset; + + /// Mesh associated type. + typedef mln_mesh(S) mesh; + /// Point_Site associated type. typedef mln_psite(S) psite; /// Point associated type. typedef mln_point(S) point; - /// Dpoint associated type. typedef mln_dpoint(point) dpoint; Index: mln/core/point1d.hh --- mln/core/point1d.hh (revision 1122) +++ mln/core/point1d.hh (working copy) @@ -43,7 +43,7 @@ /*! \brief Type alias for a point defined on the 1D square grid with * integer coordinates. */ - typedef point_<1,int> point1d; + typedef point_<grid::tick, int> point1d; } // end of namespace mln Index: mln/core/point2d.hh --- mln/core/point2d.hh (revision 1122) +++ mln/core/point2d.hh (working copy) @@ -43,7 +43,7 @@ /*! \brief Type alias for a point defined on the 2D square grid with * integer coordinates. */ - typedef point_<2,int> point2d; + typedef point_<grid::square, int> point2d; } // end of namespace mln Index: mln/core/point3d.hh --- mln/core/point3d.hh (revision 1122) +++ mln/core/point3d.hh (working copy) @@ -43,7 +43,7 @@ /*! \brief Type alias for a point defined on the 3D square grid with * integer coordinates. */ - typedef point_<3,int> point3d; + typedef point_<grid::cube, int> point3d; } // end of namespace mln Index: mln/core/line_piter.hh --- mln/core/line_piter.hh (revision 1122) +++ mln/core/line_piter.hh (working copy) @@ -33,7 +33,7 @@ * \brief Definition of iterators on points by lines. */ -# include <mln/core/concept/point_iterator.hh> +# include <mln/core/internal/point_iterator_base.hh> namespace mln @@ -44,25 +44,10 @@ * The parameter \c P is the type of points. */ template <typename P> - class line_piter_ : public Point_Iterator< line_piter_<P> > + class line_piter_ : public internal::point_iterator_base_< P, line_piter_<P> > { public: - /// Space dimension. - enum { dim = P::dim }; - - /// Point_Site associated type. - typedef P psite; - - /// Point associated type. - typedef P point; - - /// Dpoint associated type. - typedef mln_dpoint(P) dpoint; - - /// Coordinate associated type. - typedef mln_coord(P) coord; - /*! \brief Constructor. * * \param[in] b A box. @@ -76,7 +61,7 @@ const P* pointer_() const; /// Give the i-th coordinate. - coord operator[](unsigned i) const; + mln_coord(P) operator[](unsigned i) const; /// Test the iterator validity. bool is_valid() const; Index: mln/core/vec_p_piter.hh --- mln/core/vec_p_piter.hh (revision 1122) +++ mln/core/vec_p_piter.hh (working copy) @@ -43,21 +43,8 @@ * */ template <typename P> - struct vec_p_fwd_piter_ : public Point_Iterator< vec_p_fwd_piter_<P> > + struct vec_p_fwd_piter_ : public internal::point_iterator_base_< P, vec_p_fwd_piter_<P> > { - enum { dim = P::dim }; - - /// Point_Site associated type. - typedef P psite; - - /// Point associated type. - typedef P point; - - /// Dpoint associated type. - typedef mln_dpoint(P) dpoint; - - /// Coordinate associated type. - typedef mln_coord(P) coord; /// Coordinate associated type. template <typename S> @@ -67,7 +54,7 @@ const P* pointer_() const; /// Read-only access to the \p i-th coordinate. - coord operator[](unsigned i) const; + mln_coord(P) operator[](unsigned i) const; /// Test if the iterator is valid. bool is_valid() const; @@ -96,21 +83,8 @@ * */ template <typename P> - struct vec_p_bkd_piter_ : public Point_Iterator< vec_p_bkd_piter_<P> > + struct vec_p_bkd_piter_ : public internal::point_iterator_base_< P, vec_p_bkd_piter_<P> > { - enum { dim = P::dim }; - - /// Point_Site associated type. - typedef P psite; - - /// Point associated type. - typedef P point; - - /// Dpoint associated type. - typedef mln_dpoint(P) dpoint; - - /// Coordinate associated type. - typedef mln_coord(P) coord; /// Coordinate associated type. template <typename S> @@ -120,7 +94,7 @@ const P* pointer_() const; /// Read-only access to the \p i-th coordinate. - coord operator[](unsigned i) const; + mln_coord(P) operator[](unsigned i) const; /// Test if the iterator is valid. bool is_valid() const; Index: mln/core/line2d.hh --- mln/core/line2d.hh (revision 1122) +++ mln/core/line2d.hh (working copy) @@ -35,7 +35,7 @@ # include <vector> -# include <mln/core/concept/point_set.hh> +# include <mln/core/internal/point_set_base.hh> # include <mln/core/vec_p_piter.hh> # include <mln/core/box2d.hh> # include <mln/math/all.hh> @@ -47,16 +47,10 @@ /*! \brief 2D line point set class. */ - class line2d : public Point_Set< line2d > + class line2d : public internal::point_set_base_< point2d, line2d > { public: - /// Point associated type. - typedef point2d point; - - /// Point_Site associated type. - typedef point2d psite; - /// Forward Point_Iterator associated type. typedef vec_p_fwd_piter_<point2d> fwd_piter; Index: mln/core/box_piter.hh --- mln/core/box_piter.hh (revision 1122) +++ mln/core/box_piter.hh (working copy) @@ -33,7 +33,7 @@ * \brief Definition of iterators on points of boxes. */ -# include <mln/core/concept/point_iterator.hh> +# include <mln/core/internal/point_iterator_base.hh> # include <mln/core/concept/box.hh> @@ -47,25 +47,10 @@ * \see mln::box_ */ template <typename P> - class box_fwd_piter_ : public Point_Iterator< box_fwd_piter_<P> > + class box_fwd_piter_ : public internal::point_iterator_base_< P, box_fwd_piter_<P> > { public: - /// Space dimension. - enum { dim = P::dim }; - - /// Point_Site associated type. - typedef P psite; - - /// Point associated type. - typedef P point; - - /// Dpoint associated type. - typedef mln_dpoint(P) dpoint; - - /// Coordinate associated type. - typedef mln_coord(P) coord; - /*! \brief Constructor. * * \param[in] b A box. @@ -79,7 +64,7 @@ const P* pointer_() const; /// Give the i-th coordinate. - coord operator[](unsigned i) const; + mln_coord(P) operator[](unsigned i) const; /// Test the iterator validity. bool is_valid() const; @@ -107,25 +92,10 @@ * \see mln::box_ */ template <typename P> - class box_bkd_piter_ : public Point_Iterator< box_bkd_piter_<P> > + class box_bkd_piter_ : public internal::point_iterator_base_< P, box_bkd_piter_<P> > { public: - /// Space dimension. - enum { dim = P::dim }; - - /// Point_Site associated type. - typedef P psite; - - /// Point associated type. - typedef P point; - - /// Dpoint associated type. - typedef mln_dpoint(P) dpoint; - - /// Coordinate associated type. - typedef mln_coord(P) coord; - /*! \brief Constructor. * * \param[in] b A box. @@ -139,7 +109,7 @@ const P* pointer_() const; /// Give the i-th coordinate. - coord operator[](unsigned i) const; + mln_coord(P) operator[](unsigned i) const; /// Test the iterator validity. bool is_valid() const; Index: mln/core/cast_image.hh --- mln/core/cast_image.hh (revision 1122) +++ mln/core/cast_image.hh (working copy) @@ -45,13 +45,14 @@ * */ template <typename T, typename I> - struct cast_image_ : public mln::internal::image_base_< mln_pset(I), cast_image_<T,I> > + class cast_image_ : public mln::internal::image_base_< mln_pset(I), cast_image_<T,I> > { - /// Point_Site associated type. - typedef mln_psite(I) psite; + typedef cast_image_<T,I> self_; + typedef mln::internal::image_base_<mln_pset(I), self_> super_; + public: + + typedef mln_psite(super_) psite; - /// Point_Set associated type. - typedef mln_pset(I) pset; /// Value associated type. typedef T value; Index: mln/core/queue_p.hh --- mln/core/queue_p.hh (revision 1122) +++ mln/core/queue_p.hh (working copy) @@ -38,7 +38,7 @@ # include <algorithm> # include <iterator> -# include <mln/core/concept/point_set.hh> +# include <mln/core/internal/point_set_base.hh> # include <mln/core/vec_p_piter.hh> # include <mln/accu/bbox.hh> @@ -63,16 +63,10 @@ * a call to npoints() when this container is multiple. */ template <typename P> - class queue_p : public Point_Set< queue_p<P> > + class queue_p : public internal::point_set_base_< P, queue_p<P> > { public: - /// Point associated type. - typedef P point; - - /// Point_Site associated type. - typedef P psite; - /// Forward Point_Iterator associated type. typedef vec_p_fwd_piter_<P> fwd_piter; Index: mln/core/pset_if.hh --- mln/core/pset_if.hh (revision 1122) +++ mln/core/pset_if.hh (working copy) @@ -33,7 +33,7 @@ * \brief Definition of the restriction of a point set w.r.t. a predicate. */ -# include <mln/core/concept/point_set.hh> +# include <mln/core/internal/point_set_base.hh> # include <mln/core/concept/function.hh> @@ -65,14 +65,13 @@ * from point to Boolean. */ template <typename S, typename F> - struct pset_if : public Point_Set< pset_if<S,F> > + class pset_if : public internal::point_set_base_< mln_psite(S), pset_if<S,F> > { - /// Point_Site associated type. - typedef mln_psite(S) psite; - - /// Point associated type. - typedef mln_point(S) point; + typedef pset_if<S,F> self_; + typedef internal::point_set_base_<mln_psite(S), self_> super_; + public: + typedef mln_psite(super_) psite; /// Forward Point_Iterator associated type. typedef pset_if_fwd_piter_<S,F> fwd_piter; @@ -89,7 +88,7 @@ bool has(const psite& p) const; /// Give a bounding box of the subset. - const box_<point>& bbox() const; + const box_<mln_point(S)>& bbox() const; /// Give the number of points of the subset. std::size_t npoints() const; Index: mln/core/vec_p.hh --- mln/core/vec_p.hh (revision 1122) +++ mln/core/vec_p.hh (working copy) @@ -35,7 +35,7 @@ # include <vector> -# include <mln/core/concept/point_set.hh> +# include <mln/core/internal/point_set_base.hh> # include <mln/accu/bbox.hh> @@ -57,19 +57,10 @@ * \todo Make it work with P being a Point_Site. */ template <typename P> - class vec_p : public Point_Set< vec_p<P> > + class vec_p : public internal::point_set_base_< P, vec_p<P> > { public: - /// Point associated type. - typedef P point; - - /// Dpoint associated type. - typedef mln_dpoint(P) dpoint; - - /// Point_Site associated type. - typedef P psite; - /// Forward Point_Iterator associated type. typedef vec_p_fwd_piter_<P> fwd_piter; Index: mln/core/concept/image.hh --- mln/core/concept/image.hh (revision 1122) +++ mln/core/concept/image.hh (working copy) @@ -33,7 +33,9 @@ */ # include <mln/core/concept/point_set.hh> +# include <mln/core/concept/mesh.hh> # include <mln/core/trait/all.hh> +# include <mln/metal/is_a.hh> namespace mln @@ -50,6 +52,8 @@ /* // to be provided in concrete image classes: + typedef mesh; + typedef value; typedef rvalue; typedef lvalue; @@ -117,6 +121,9 @@ // to be provided in concrete image classes: + typedef mln_mesh(E) mesh; + metal::is_a<mesh, Mesh>::check(); // FIXME: Add other checks. + typedef mln_value(E) value; typedef mln_rvalue(E) rvalue; typedef mln_lvalue(E) lvalue; Index: mln/core/concept/mesh.hh --- mln/core/concept/mesh.hh (revision 0) +++ mln/core/concept/mesh.hh (revision 0) @@ -0,0 +1,74 @@ +// 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_MESH_HH +# define MLN_CORE_CONCEPT_MESH_HH + +/*! \file mln/core/concept/mesh.hh + * \brief Definition of the concept of mln::Mesh. + */ + +# include <mln/core/concept/object.hh> + + +namespace mln +{ + + /*! \brief Base class for implementation classes of meshes. + * + * \see mln::doc::Mesh for a complete documentation of this class + * contents. + */ + template <typename E> + struct Mesh : public Object<E> + { + /* + typedef regular; + typedef aligned; + enum { dim }; // FIXME: of the underlying space (?) + */ + + protected: + Mesh(); + }; + + + +# ifndef MLN_INCLUDE_ONLY + + template <typename E> + Mesh<E>::Mesh() + { + // FIXME: Check for typedefs. + } + +# endif // ! MLN_INCLUDE_ONLY + +} // end of namespace mln + + +#endif // ! MLN_CORE_CONCEPT_MESH_HH Index: mln/core/concept/dpoint.hh --- mln/core/concept/dpoint.hh (revision 1122) +++ mln/core/concept/dpoint.hh (working copy) @@ -33,6 +33,7 @@ */ # include <mln/core/concept/object.hh> +# include <mln/core/grids.hh> namespace mln Index: mln/core/concept/point_iterator.hh --- mln/core/concept/point_iterator.hh (revision 1122) +++ mln/core/concept/point_iterator.hh (working copy) @@ -35,6 +35,7 @@ # include <mln/core/concept/iterator.hh> # include <mln/core/concept/generalized_point.hh> +# include <mln/core/concept/point_site.hh> namespace mln @@ -69,6 +70,8 @@ Point_Iterator<E>::Point_Iterator() { typedef mln_psite(E) psite; + mln::metal::is_a<psite, Point_Site>::check(); + psite (E::*m)() const = & E::operator psite; m = 0; } Index: mln/core/concept/generalized_point.hh --- mln/core/concept/generalized_point.hh (revision 1122) +++ mln/core/concept/generalized_point.hh (working copy) @@ -36,6 +36,7 @@ # include <mln/metal/same_coord.hh> # include <mln/core/concept/object.hh> +# include <mln/core/grids.hh> # include <mln/core/internal/force_exact.hh> @@ -62,10 +63,11 @@ /* enum { dim }; + typedef mesh; + typedef point; typedef dpoint; typedef coord; - typedef topo; // FIXME either Point or operator point() const; @@ -205,13 +207,13 @@ # ifndef MLN_INCLUDE_ONLY - template <typename E> Generalized_Point<E>::Generalized_Point() { 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; @@ -221,6 +223,7 @@ m2 = 0; } + // Operators. template <typename Pl, typename Pr> bool operator=(const Generalized_Point<Pl>& lhs, const Generalized_Point<Pr>& rhs) Index: mln/core/concept/point_set.hh --- mln/core/concept/point_set.hh (revision 1122) +++ mln/core/concept/point_set.hh (working copy) @@ -49,6 +49,8 @@ struct Point_Set : public Object<E> { /* + typedef mesh; + typedef point; typedef psite; @@ -125,6 +127,8 @@ template <typename E> Point_Set<E>::Point_Set() { + typedef mln_mesh(E) mesh; + typedef mln_point(E) point; typedef mln_psite(E) psite; Index: mln/core/concept/object.hh --- mln/core/concept/object.hh (revision 1122) +++ mln/core/concept/object.hh (working copy) @@ -39,6 +39,7 @@ # include <mln/core/macros.hh> # include <mln/core/contract.hh> # include <mln/core/internal/fixme.hh> +# include <mln/metal/is_a.hh> /*! \namespace mln Index: mln/core/concept/regular_grid.hh --- mln/core/concept/regular_grid.hh (revision 0) +++ mln/core/concept/regular_grid.hh (revision 0) @@ -0,0 +1,65 @@ +// 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_REGULAR_GRID_HH +# define MLN_CORE_CONCEPT_REGULAR_GRID_HH + +/*! \file mln/core/concept/regular_grid.hh + * \brief Definition of the concept of mln::Regular_Grid. + */ + +# include <mln/core/concept/mesh.hh> +# include <mln/metal/bool.hh> + + +namespace mln +{ + + /// Base class for implementation classes of regular grids. + template <typename E> + struct Regular_Grid : public Mesh<E> + { + typedef metal::true_ regular; + protected: + Regular_Grid(); + }; + + + +# ifndef MLN_INCLUDE_ONLY + + template <typename E> + Regular_Grid<E>::Regular_Grid() + { + } + +# endif // ! MLN_INCLUDE_ONLY + +} // end of namespace mln + + +#endif // ! MLN_CORE_CONCEPT_REGULAR_GRID_HH Index: mln/core/dpoint.hh --- mln/core/dpoint.hh (revision 1122) +++ mln/core/dpoint.hh (working copy) @@ -42,7 +42,7 @@ { // fwd decl - template <unsigned n, typename C> struct point_; + template <typename M, typename C> struct point_; /*! \brief Generic delta-point class. @@ -50,22 +50,23 @@ * Parameters are \c n the dimension of the space and \c C the * coordinate type in this space. */ - template <unsigned n, typename C> - struct dpoint_ : public Dpoint< dpoint_<n,C> >, - public internal::mutable_coord_impl_< n, C, dpoint_<n,C> > + template <typename M, typename C> + struct dpoint_ : public Dpoint< dpoint_<M,C> >, + public internal::mutable_coord_impl_< M::dim, C, dpoint_<M,C> > { /*! \var dim * \brief Dimension of the space. * \invariant dim > 0 */ - enum { dim = n }; + enum { dim = M::dim }; - /*! \brief Point associated type. - */ - typedef point_<n,C> point; + /// Mesh associated type. + typedef M mesh; - /*! \brief Coordinate associated type. - */ + /// Point associated type. + typedef point_<M,C> point; + + /// Coordinate associated type. typedef C coord; /*! \brief Read-only access to the \p i-th coordinate value. @@ -80,74 +81,71 @@ */ C& operator[](unsigned i); - /*! \brief Constructor without argument. - */ + /// Constructor without argument. dpoint_(); - /*! \brief Constructor; coordinates are set by function \p f. - */ + /// Constructor; coordinates are set by function \p f. template <typename F> dpoint_(const Function_i2v<F>& f); - /*! \brief Set all coordinates to the value \p c. - */ + /// Set all coordinates to the value \p c. void set_all(C c); /// Null delta-point (all coordinates are 0). - static const dpoint_<n,C> zero; + static const dpoint_<M,C> zero; const C* coords_() const { return coord_; } /// Type of the array of coordinates. - typedef const C (&vec_t)[n]; + typedef const C (&vec_t)[dim]; /// Hook to coordinates. vec_t to_vec() const { return coord_; } protected: - C coord_[n]; + C coord_[dim]; }; # ifndef MLN_INCLUDE_ONLY - template <unsigned n, typename C> - C dpoint_<n,C>::operator[](unsigned i) const + template <typename M, typename C> + C dpoint_<M,C>::operator[](unsigned i) const { - assert(i < n); + assert(i < dim); return coord_[i]; } - template <unsigned n, typename C> - C& dpoint_<n,C>::operator[](unsigned i) + template <typename M, typename C> + C& dpoint_<M,C>::operator[](unsigned i) { - assert(i < n); + assert(i < dim); return coord_[i]; } - template <unsigned n, typename C> - dpoint_<n,C>::dpoint_() + template <typename M, typename C> + dpoint_<M,C>::dpoint_() { } - template <unsigned n, typename C> + template <typename M, typename C> template <typename F> - dpoint_<n,C>::dpoint_(const Function_i2v<F>& f_) + dpoint_<M,C>::dpoint_(const Function_i2v<F>& f_) { const F& f = exact(f_); - for (unsigned i = 0; i < n; ++i) + for (unsigned i = 0; i < dim; ++i) coord_[i] = f(i); } - template <unsigned n, typename C> - void dpoint_<n,C>::set_all(C c) + template <typename M, typename C> + void dpoint_<M,C>::set_all(C c) { - for (unsigned i = 0; i < n; ++i) + for (unsigned i = 0; i < dim; ++i) coord_[i] = c; } - template <unsigned n, typename C> - const dpoint_<n,C> dpoint_<n,C>::zero = all(0); + template <typename M, typename C> + const dpoint_<M,C> dpoint_<M,C>::zero = all(0); # endif // ! MLN_INCLUDE_ONLY Index: mln/core/grids.hh --- mln/core/grids.hh (revision 0) +++ mln/core/grids.hh (revision 0) @@ -0,0 +1,83 @@ +// 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_GRIDS_HH +# define MLN_CORE_GRIDS_HH + +/*! \file mln/core/grids.hh + * + * \brief This file defines some grid classes. + */ + +# include <mln/core/concept/regular_grid.hh> +# include <mln/metal/bool.hh> + + +namespace mln +{ + + // Grids. + + namespace grid + { + + struct tick : public Regular_Grid< tick > + { + typedef metal::true_ aligned; + enum { dim = 1 }; + }; + + struct square : public Regular_Grid< square > + { + typedef metal::true_ aligned; + enum { dim = 2 }; + }; + + struct cube : public Regular_Grid< cube > + { + typedef metal::true_ aligned; + enum { dim = 3 }; + }; + + } // end of namespace mln::grid + + + // Function: dim -> regular grid. + + template <unsigned dim> struct regular_grid_from_dim_; + + template <> struct regular_grid_from_dim_<1> { typedef grid::tick ret; }; + template <> struct regular_grid_from_dim_<2> { typedef grid::square ret; }; + template <> struct regular_grid_from_dim_<3> { typedef grid::cube ret; }; + +} // end of namespace mln + + +# define mln_regular_grid_from_dim(N) typename mln::regular_grid_from_dim_< N >::ret + + +#endif // ! MLN_CORE_GRIDS_HH Index: mln/core/set_p.hh --- mln/core/set_p.hh (revision 1122) +++ mln/core/set_p.hh (working copy) @@ -33,7 +33,7 @@ * \brief Definition of a point set class based on std::set. */ -# include <mln/core/concept/point_set.hh> +# include <mln/core/internal/point_set_base.hh> # include <mln/core/internal/set_of.hh> # include <mln/accu/bbox.hh> # include <mln/core/vec_p.hh> @@ -50,19 +50,13 @@ * \todo Test if \p P being a Point_Site is ok. */ template <typename P> - class set_p : public Point_Set< set_p<P> >, + class set_p : public internal::point_set_base_< P, set_p<P> >, private internal::set_of_<P> { typedef internal::set_of_<P> super_; public: - /// Point associated type. - typedef mln_point(P) point; - - /// Point_Site associated type. - typedef P psite; - /// Forward Point_Iterator associated type. typedef vec_p_fwd_piter_<P> fwd_piter; @@ -91,7 +85,7 @@ void clear(); /// Give the exact bounding box. - const box_<point>& bbox() const; + const box_<mln_point(P)>& bbox() const; protected: Index: mln/metal/is_a.hh --- mln/metal/is_a.hh (revision 1122) +++ mln/metal/is_a.hh (working copy) @@ -33,6 +33,8 @@ * \brief Definition of a type that means "is_a". */ +# include <mln/metal/bool.hh> + # define mlc_is_a(T, U) mln::metal::is_a< T, U >