Olena-patches
  Threads by month 
                
            - ----- 2025 -----
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2024 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2023 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2022 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2021 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2020 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2019 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2018 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2017 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2016 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2015 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2014 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2013 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2012 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2011 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2010 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2009 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2008 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2007 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2006 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2005 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2004 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 
July 2007
- 6 participants
 - 59 discussions
 
17 Jul '07
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from  Thierry Geraud  <thierry.geraud(a)lrde.epita.fr>
	Introduce accumulators and point-wise operations in mln.
	* tests/pw_value.cc: New.
	* mln/estim/mean.hh: New.
	* mln/fun/chess.hh (result): New.
	* mln/fun/ops.hh: New.
	* mln/fun/val.hh: New.
	* mln/fun/pw_value.hh: New.
	* mln/fun/var.hh: New.
	* mln/core/concept/doc/accumulator.hh: New.
	* mln/core/concept/accumulator.hh: New.
	* mln/core/concept/function.hh (Function_i2v): New.
	* mln/core/macros.hh (mln_result): New.
	* mln/arith: New.
	* mln/arith/plus.hh: New.
	* mln/level/apply.hh: New.
	* mln/level/transform.hh: New.
	* mln/accu/counter.hh: New.
	* mln/accu/mean.hh: New.
	* mln/value/kind.hh: New.
	* mln/value/props.hh (mln_kind, kind): New.
	* mln/estim/count.hh: Remove; useless.
	* mln/fun/all.hh (all): Change inheritance.
	* mln/core/point.hh (point_): Strenghten sigs.
	* mln/core/dpoint.hh (dpoint_): Likewise.
	* mln/accu/histo.hh: Add inheritance.
	* mln/accu/median.hh: Likewise.
 mln/accu/counter.hh                 |  109 ++++++++++++++++++++++++++
 mln/accu/histo.hh                   |    6 +
 mln/accu/mean.hh                    |  116 ++++++++++++++++++++++++++++
 mln/accu/median.hh                  |    8 +
 mln/arith/plus.hh                   |   82 ++++++++++++++++++++
 mln/core/concept/accumulator.hh     |   80 +++++++++++++++++++
 mln/core/concept/doc/accumulator.hh |   56 +++++++++++++
 mln/core/concept/function.hh        |   18 ++++
 mln/core/dpoint.hh                  |    4 
 mln/core/macros.hh                  |    3 
 mln/core/point.hh                   |    4 
 mln/estim/mean.hh                   |   55 ++++++-------
 mln/fun/all.hh                      |    3 
 mln/fun/chess.hh                    |    1 
 mln/fun/ops.hh                      |  147 ++++++++++++++++++++++++++++++++++++
 mln/fun/pw_value.hh                 |  130 +++++++++++++++++++++++++++++++
 mln/fun/val.hh                      |   97 +++++++++++++++++++++++
 mln/fun/var.hh                      |   98 ++++++++++++++++++++++++
 mln/level/apply.hh                  |  111 +++++++++++++++++++++++++++
 mln/level/transform.hh              |   85 ++++++++++++++++++++
 mln/value/kind.hh                   |   60 ++++++++++++++
 mln/value/props.hh                  |   20 ++++
 tests/pw_value.cc                   |   48 +++++++++++
 23 files changed, 1304 insertions(+), 37 deletions(-)
Index: tests/pw_value.cc
--- tests/pw_value.cc	(revision 0)
+++ tests/pw_value.cc	(revision 0)
@@ -0,0 +1,48 @@
+// 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.
+
+/*! \file tests/pw_value.cc
+ *
+ * \brief Test on mln::fun::pw_value_.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/fun/pw_value.hh>
+#include <mln/fun/ops.hh>
+#include <mln/fun/val.hh>
+
+
+int main()
+{
+  using namespace mln;
+
+  image2d_b<int> ima(3, 3);
+  point2d p = make::point2d(1, 1);
+  ima(p) = 51;
+
+  std::cout << (pw_value(ima) = val(51))(p) << std::endl;
+}
Index: mln/estim/mean.hh
--- mln/estim/mean.hh	(revision 1014)
+++ mln/estim/mean.hh	(working copy)
@@ -25,14 +25,17 @@
 // reasons why the executable file might be covered by the GNU General
 // Public License.
 
-#ifndef MLN_ESTIM_COUNT_HH
-# define MLN_ESTIM_COUNT_HH
+#ifndef MLN_ESTIM_MEAN_HH
+# define MLN_ESTIM_MEAN_HH
 
-/*! \file mln/estim/count.hh
+/*! \file mln/estim/mean.hh
  *
- * \brief Several routines to count the number of points.
+ * \brief Compute the mean pixel value.
  */
 
+# include <mln/core/concept/image.hh>
+# include <mln/accu/mean.hh>
+
 
 namespace mln
 {
@@ -41,39 +44,31 @@
   {
 
 
-    /// Compute the number FIXME minimum and maximum points when browsing with
-    /// iterator \p p.
-    template <typename S>
-    std::size_t count(const Point_Set<S>& pset);
+    /*! \brief Compute the mean value of the pixels of image \p input.
+     *
+     * Parameter \c S is the type of the mean value.
+     */
+    template <typename S, typename I>
+    S mean(const Image<I>& input);
 
 
 
 # ifndef MLN_INCLUDE_ONLY
 
-    template <typename I>
-    std::pair<mln_point(I), mln_point(I)>
-    count(const Piter<I>& p_)
+    template <typename S, typename I>
+    S
+    mean(const Image<I>& input_)
     {
-      const I& p = exact(p_);
+      const I& input = exact(input_);
+      mln_precondition(input.has_data());
+
+      accu::mean<mln_value(I), S> m;
 
-      typedef mln_point(I) P;
-      std::pair<P, P> tmp;
-      P& pmin = tmp.first;
-      P& pmax = tmp.second;
-
-      // init with first point
-      p.start();
-      pmin = pmax = p;
-
-      // update with remaining points
-      for_all_remaining(p)
-	for (unsigned i = 0; i < P::dim; ++i)
-	  if (p[i] < pmin[i])
-	    pmin()[i] = p[i];
-	  else if (p[i] > pmax[i])
-	    pmax[i] = p[i];
+      mln_piter(I) p(input.domain());
+      for_all(p)
+	m.take(input(p));
 
-      return tmp;
+      return m;
     }
 
 # endif // ! MLN_INCLUDE_ONLY
@@ -83,4 +78,4 @@
 } // end of namespace mln
 
 
-#endif // ! MLN_ESTIM_COUNT_HH
+#endif // ! MLN_ESTIM_MEAN_HH
Index: mln/fun/ops.hh
--- mln/fun/ops.hh	(revision 0)
+++ mln/fun/ops.hh	(revision 0)
@@ -0,0 +1,147 @@
+// 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_FUN_OPS_HH
+# define MLN_FUN_OPS_HH
+
+/*! \file mln/fun/ops.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+
+
+
+# define mln_decl_binary_expr_(In, Out, Name, Symbol)				\
+										\
+  namespace fun									\
+  {										\
+										\
+    template <typename L, typename R>						\
+    struct Name##_expr_ : public Function_##Out < Name##_expr_<L,R> >		\
+    {										\
+      typedef mln_result(L) result;						\
+										\
+      Name##_expr_(const L& l, const R& r)					\
+	: l_(l), r_(r)								\
+      {										\
+      }										\
+										\
+      template <typename P>							\
+      result operator()(const P& p) const					\
+      {										\
+	return l_(p) Symbol r_(p);						\
+      }										\
+										\
+    protected:									\
+      L l_;									\
+      R r_;									\
+    };										\
+										\
+  }										\
+										\
+  template <typename L, typename R>						\
+  fun::Name##_expr_<L,R>							\
+  operator Symbol (const Function_##In<L>& lhs, const Function_##In<R>& rhs)	\
+  {										\
+    fun::Name##_expr_<L,R> tmp(exact(lhs), exact(rhs));				\
+    return tmp;									\
+  }										\
+										\
+  struct dummy
+
+
+# define mln_decl_unary_expr_(In, Out, Name, Symbol)			\
+									\
+  namespace fun								\
+  {									\
+									\
+    template <typename F>						\
+    struct Name##_expr_ : public Function_##Out< Name##_expr_<F> >	\
+    {									\
+      typedef mln_result(F) result;					\
+									\
+      Name##_expr_(const F& f)						\
+	: f_(f)								\
+      {									\
+      }									\
+      									\
+      template <typename P>						\
+      result operator()(const P& p) const				\
+      {									\
+	return Symbol f_(p);						\
+      }									\
+									\
+    protected:								\
+      F f_;								\
+    };									\
+									\
+  }									\
+									\
+  template <typename F>							\
+  fun::Name##_expr_<F>							\
+  operator Symbol (const Function_##In<F>& f)				\
+  {									\
+    fun::Name##_expr_<F> tmp(exact(f));					\
+    return tmp;								\
+  }									\
+									\
+  struct dummy
+
+
+
+namespace mln
+{
+
+  mln_decl_binary_expr_(p2v, p2b, equal, =);
+  mln_decl_binary_expr_(p2v, p2b, not_equal, !=);
+
+  mln_decl_binary_expr_(p2v, p2b, less, <);
+  mln_decl_binary_expr_(p2v, p2b, less_or_equal, <=);
+  mln_decl_binary_expr_(p2v, p2b, greater_or_equal, >=);
+  mln_decl_binary_expr_(p2v, p2b, greater, >);
+
+  mln_decl_binary_expr_(p2b, p2b, and, &&);
+  mln_decl_binary_expr_(p2b, p2b, or, ||);
+  mln_decl_binary_expr_(p2b, p2b, xor, ^);
+
+  mln_decl_unary_expr_(p2b, p2b, not, !);
+
+  mln_decl_binary_expr_(p2v, p2v, plus, +);
+  mln_decl_binary_expr_(p2v, p2v, minus, -);
+  mln_decl_binary_expr_(p2v, p2v, times, *);
+  mln_decl_binary_expr_(p2v, p2v, div, /);
+  mln_decl_binary_expr_(p2v, p2v, mod, %);
+
+  mln_decl_unary_expr_(p2v, p2v, uplus, +);
+  mln_decl_unary_expr_(p2v, p2v, uminus, -);
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_OPS_HH
Index: mln/fun/val.hh
--- mln/fun/val.hh	(revision 0)
+++ mln/fun/val.hh	(revision 0)
@@ -0,0 +1,97 @@
+// 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_FUN_VAL_HH
+# define MLN_FUN_VAL_HH
+
+/*! \file mln/fun/val.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+  // FIXME: Doc!
+
+  namespace fun
+  {
+
+    template <typename T>
+    struct val_ : public Function_p2v< val_<T> >
+    {
+      typedef T result;
+      val_(T t);
+      template <typename P>
+      T operator()(const P&) const;
+    private:
+      T t_;
+    };
+
+  } // end of namespace mln::fun
+
+  template <typename T>
+  fun::val_<T> val(T t);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+  namespace fun
+  {
+
+    template <typename T>
+    val_<T>::val_(T t)
+      : t_(t)
+    {
+    }
+
+    template <typename T>
+    template <typename P>
+    T
+    val_<T>::operator()(const P&) const
+    {
+      return t_;
+    }
+
+  } // end of namespace mln::fun
+
+  template <typename T>
+  fun::val_<T> val(T t)
+  {
+    fun::val_<T> tmp(t);
+    return tmp;
+  }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_VAL_HH
Index: mln/fun/pw_value.hh
--- mln/fun/pw_value.hh	(revision 0)
+++ mln/fun/pw_value.hh	(revision 0)
@@ -0,0 +1,130 @@
+// 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_FUN_PW_VALUE_HH
+# define MLN_FUN_PW_VALUE_HH
+
+/*! \file mln/fun/pw_value.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/value/props.hh>
+
+
+
+namespace mln
+{
+
+  // Fwd decl.
+  namespace fun { template <typename I> struct pw_value; }
+
+
+
+  // FIXME: Doc!
+  
+  template <typename I>
+  fun::pw_value<I> pw_value(const Image<I>& ima);
+  
+
+
+  namespace fun
+  {
+
+    // FIXME: Move!
+
+    namespace internal
+    {
+
+      template <typename K, typename E>
+      struct function_ : Function_p2v<E>
+      {};
+
+      template <typename E>
+      struct function_< value::binary_kind, E > : Function_p2b<E>
+      {};
+
+    } // end of namespace mln::fun::internal
+
+
+    // FIXME: Doc!
+
+    template <typename I>
+    struct pw_value : public internal::function_< mln_kind(I), pw_value<I> >
+    {
+      typedef mln_value(I) result;
+      pw_value(const I& ima);
+      mln_rvalue(I) operator()(const mln_psite(I)& p) const;
+    protected:
+      const I& ima_;
+    };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    // fun::pw_value<I>
+
+    template <typename I>
+    pw_value<I>::pw_value(const I& ima)
+      : ima_(ima)
+    {
+    }
+
+    template <typename I>
+    mln_rvalue(I)
+      pw_value<I>::operator()(const mln_psite(I)& p) const
+    {
+      mln_precondition(ima_.owns_(p));
+      return ima_(p);
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+  // pw_value
+
+  template <typename I>
+  fun::pw_value<I>
+  pw_value(const Image<I>& ima)
+  {
+    mln_precondition(exact(ima).has_data());
+    fun::pw_value<I> tmp(exact(ima));
+    return tmp;
+  }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_PW_VALUE_HH
Index: mln/fun/chess.hh
--- mln/fun/chess.hh	(revision 1014)
+++ mln/fun/chess.hh	(working copy)
@@ -47,6 +47,7 @@
 
     struct chess_t : public Function_p2b< chess_t >
     {
+      typedef bool result;
       bool operator()(const point2d& p) const;
     }
 
Index: mln/fun/all.hh
--- mln/fun/all.hh	(revision 1014)
+++ mln/fun/all.hh	(working copy)
@@ -45,8 +45,9 @@
   {
 
     template <typename T>
-    struct all : public Function< all<T> >
+    struct all : public Function_i2v< all<T> >
     {
+      typedef T result;
       all(T t);
       template <typename U>
       T operator()(const U&) const;
Index: mln/fun/var.hh
--- mln/fun/var.hh	(revision 0)
+++ mln/fun/var.hh	(revision 0)
@@ -0,0 +1,98 @@
+// 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_FUN_VAR_HH
+# define MLN_FUN_VAR_HH
+
+/*! \file mln/fun/var.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+  // FIXME: Doc!
+
+  namespace fun
+  {
+
+    template <typename V>
+    struct var_ : public Function_p2v< var_<V> >
+    {
+      typedef V result;
+      var_(const V& v);
+      template <typename P>
+      const V& operator()(const P&) const;
+    private:
+      const V& v_;
+    };
+
+  } // end of namespace mln::fun
+
+
+  template <typename V>
+  fun::var_<V> var(const V& v);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+  namespace fun
+  {
+
+    template <typename V>
+    var_<V>::var_(const V& v)
+      : v_(v)
+    {
+    }
+
+    template <typename V>
+    template <typename P>
+    const V&
+    var_<V>::operator()(const P&) const
+    {
+      return v_;
+    }
+
+  } // end of namespace mln::fun
+
+  template <typename V>
+  fun::var_<V> var(const V& v)
+  {
+    fun::var_<V> tmp(v);
+    return tmp;
+  }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_VAR_HH
Index: mln/core/macros.hh
--- mln/core/macros.hh	(revision 1014)
+++ mln/core/macros.hh	(working copy)
@@ -138,6 +138,9 @@
 
 // r
 
+/// Shortcut to access the result type associated to T.
+# define mln_result(T)     typename T::result
+
 /// Shortcut to access the rvalue type associated to T.
 # define mln_rvalue(T)     typename T::rvalue
 
Index: mln/core/point.hh
--- mln/core/point.hh	(revision 1014)
+++ mln/core/point.hh	(working copy)
@@ -87,7 +87,7 @@
     /*! \brief Constructor; coordinates are set by function \p f.
      */
     template <typename F>
-    point_(const Function<F>& f);
+    point_(const Function_i2v<F>& f);
 
     /*! \brief Set all coordinates to the value \p c.
      */
@@ -124,7 +124,7 @@
 
   template <unsigned n, typename C>
   template <typename F>
-  point_<n,C>::point_(const Function<F>& f_)
+  point_<n,C>::point_(const Function_i2v<F>& f_)
   {
     const F& f = exact(f_);
     for (unsigned i = 0; i < n; ++i)
Index: mln/core/dpoint.hh
--- mln/core/dpoint.hh	(revision 1014)
+++ mln/core/dpoint.hh	(working copy)
@@ -87,7 +87,7 @@
     /*! \brief Constructor; coordinates are set by function \p f.
      */
     template <typename F>
-    dpoint_(const Function<F>& f);
+    dpoint_(const Function_i2v<F>& f);
 
     /*! \brief Set all coordinates to the value \p c.
      */
@@ -124,7 +124,7 @@
 
   template <unsigned n, typename C>
   template <typename F>
-  dpoint_<n,C>::dpoint_(const Function<F>& f_)
+  dpoint_<n,C>::dpoint_(const Function_i2v<F>& f_)
   {
     const F& f = exact(f_);
     for (unsigned i = 0; i < n; ++i)
Index: mln/core/concept/function.hh
--- mln/core/concept/function.hh	(revision 1014)
+++ mln/core/concept/function.hh	(working copy)
@@ -68,6 +68,18 @@
   };
 
 
+  // Index -> Value.
+
+  /// Base class for implementation of function-objects from index to
+  /// value.
+  template <typename E>
+  struct Function_i2v : public Function_v2v<E>
+  {
+  protected:
+    Function_i2v();
+  };
+
+
   // Point -> Value.
 
   /// Base class for implementation of function-objects from point to
@@ -110,6 +122,7 @@
   template <typename E>
   Function<E>::Function()
   {
+    typedef mln_result(E) result;
   }
 
   template <typename E>
@@ -118,6 +131,11 @@
   }
 
   template <typename E>
+  Function_i2v<E>::Function_i2v()
+  {
+  }
+
+  template <typename E>
   Function_p2v<E>::Function_p2v()
   {
   }
Index: mln/core/concept/doc/accumulator.hh
--- mln/core/concept/doc/accumulator.hh	(revision 0)
+++ mln/core/concept/doc/accumulator.hh	(revision 0)
@@ -0,0 +1,56 @@
+// 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.
+
+/*! \file mln/core/concept/doc/accumulator.hh
+ * \brief This file documents the concept of mln::Accumulator.
+ */
+
+namespace mln
+{
+
+  namespace doc
+  {
+
+    /*! \brief Documentation class for mln::Accumulator.
+     * \see mln::Accumulator
+     */
+    template <typename E>
+    struct Accumulator
+    {
+      /// The value type of elements to accumulate.
+      typedef void value;
+
+      /// Initialize the accumulator.
+      void init();
+
+      /// Take into account a value \p v (an element).
+      void take(const value& v);
+    };
+
+  } // end of namespace mln::doc
+
+} // end of namespace mln
Index: mln/core/concept/accumulator.hh
--- mln/core/concept/accumulator.hh	(revision 0)
+++ mln/core/concept/accumulator.hh	(revision 0)
@@ -0,0 +1,80 @@
+// 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_ACCUMULATOR_HH
+# define MLN_CORE_CONCEPT_ACCUMULATOR_HH
+
+/*! \file mln/core/concept/accumulator.hh
+ *
+ * \brief Definition of the concept of mln::Accumulator.
+ */
+
+# include <mln/core/concept/object.hh>
+
+
+namespace mln
+{
+
+
+  /*! \brief Base class for implementation of accumulators.
+   *
+   * The parameter \a E is the exact type.
+   *
+   * \see mln::doc::Accumulator for a complete documentation of this
+   * class contents.
+   */
+  template <typename E>
+  struct Accumulator : public Object<E>
+  {
+    /*
+      typedef value;
+      void init();
+      void take(const value& v);
+     */
+  protected:
+    Accumulator();
+  };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+  template <typename E>
+  Accumulator<E>::Accumulator()
+  {
+    typedef mln_value(E) value;
+    void (E::*m1)() = & E::init;
+    m1 = 0;
+    void (E::*m2)(const value&) = & E::take;
+    m2 = 0;
+  }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_CONCEPT_ACCUMULATOR_HH
Index: mln/arith/plus.hh
--- mln/arith/plus.hh	(revision 0)
+++ mln/arith/plus.hh	(revision 0)
@@ -0,0 +1,82 @@
+// 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_ARITH_PLUS_HH
+# define MLN_ARITH_PLUS_HH
+
+/*! \file mln/arith/plus.hh
+ *
+ * \brief Point-wise addition between images.
+ */
+
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+  namespace arith
+  {
+
+    /*! Point-wise addition of images \p lhs and \p rhs.
+     *
+     * \param[in] lhs First operand image.
+     * \param[in] rhs Second operand image.
+     * \param[out] output The result image.
+     *
+     * \pre \p output.domain = \p lhs.domain = \p rhs.domain
+     */
+    template <typename L, typename R, typename O>
+    void plus(const Image<L>& lhs, const Image<R>& rhs, Image<O>& output);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    template <typename L, typename R, typename O>
+    void plus(const Image<L>& lhs_, const Image<R>& rhs_, Image<O>& output_)
+    {
+      const L& lhs = exact(lhs_);
+      const R& rhs = exact(rhs_);
+      O& output = exact(output_);
+
+      mln_precondition(rhs.domain() = lhs.domain());
+      mln_precondition(output.domain() = lhs.domain());
+
+      mln_piter(I) p(output.domain());
+      for_all(p)
+	output(p) = lhs(p) + rhs(p);
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::arith
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ARITH_PLUS_HH
Index: mln/level/apply.hh
--- mln/level/apply.hh	(revision 0)
+++ mln/level/apply.hh	(revision 0)
@@ -0,0 +1,111 @@
+// 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_LEVEL_APPLY_HH
+# define MLN_LEVEL_APPLY_HH
+
+/*! \file mln/level/apply.hh
+ *
+ * \brief Apply some function-objects on an image.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/accumulator.hh>
+
+
+namespace mln
+{
+
+  namespace level
+  {
+
+    /*! Apply a function-object to the image \p input.
+     *
+     * \param[in] input The input image.
+     * \param[in] f The function-object.
+     * \result A copy of the function-object.
+     *
+     * This routine runs: \n
+     *   for all p of \p input, \p f( \p input(p) ) \n
+     *   return \p f
+     */
+    template <typename I, typename F>
+    F apply(const Image<I>& input, const Function<F>& f);
+
+
+    /*! Apply an accumulator to the image \p input.
+     *
+     * \param[in] input The input image.
+     * \param[in] a The accumulator.
+     * \result A copy of the accumulator.
+     *
+     * This routine runs: \n
+     *   a.init() \n
+     *   for all p of \p input, \p a.take( \p input(p) ) \n
+     *   return \p a
+     */
+    template <typename I, typename A>
+    A apply(const Image<I>& input, const Accumulator<A>& a);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    template <typename I, typename F>
+    F apply(const Image<I>& input_, const Function<F>& f_)
+    {
+      const I& input  = exact(input_);
+      F f = exact(f_);
+      mln_precondition(input.has_data());
+
+      mln_piter(I) p(input.domain());
+      for_all(p)
+	f(input(p));
+      return f;
+    }
+
+    template <typename I, typename A>
+    A apply(const Image<I>& input_, const Accumulator<A>& a_)
+    {
+      const I& input  = exact(input_);
+      A a = exact(a_);
+      mln_precondition(input.has_data());
+
+      a.init();
+      mln_piter(I) p(input.domain());
+      for_all(p)
+	a.take(input(p));
+      return a;
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::level
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LEVEL_APPLY_HH
Index: mln/level/transform.hh
--- mln/level/transform.hh	(revision 0)
+++ mln/level/transform.hh	(revision 0)
@@ -0,0 +1,85 @@
+// 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_LEVEL_TRANSFORM_HH
+# define MLN_LEVEL_TRANSFORM_HH
+
+/*! \file mln/level/transform.hh
+ *
+ * \brief Transform the contents of an image into another one.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+  namespace level
+  {
+
+    /*! Transform the image \p input through a function \p f to set
+     *  the \p output image.
+     *
+     * \param[in] input The input image.
+     * \param[in] f The function.
+     * \param[out] output The result image.
+     *
+     * This routine runs: \n
+     * for all p of \p input, \p output(p) = \p f( \p input(p) ).
+     *
+     * \pre \p output.domain >= \p input.domain
+     */
+    template <typename I, typename F, typename O>
+    void transform(const Image<I>& input, const Function_v2v<F>& f, Image<O>& output);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    template <typename I, typename F, typename O>
+    void transform(const Image<I>& input_, const Function_v2v<F>& f_, Image<O>& output_)
+    {
+      const I& input  = exact(input_);
+      const F& f      = exact(f_);
+            O& output = exact(output_);
+
+      mln_precondition(output.domain() >= input.domain());
+
+      mln_piter(I) p(input.domain());
+      for_all(p)
+	output(p) = f( input(p) );
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::level
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LEVEL_TRANSFORM_HH
Index: mln/accu/histo.hh
--- mln/accu/histo.hh	(revision 1014)
+++ mln/accu/histo.hh	(working copy)
@@ -37,6 +37,7 @@
 # include <algorithm>
 
 # include <mln/core/concept/value_set.hh>
+# include <mln/core/concept/accumulator.hh>
 # include <mln/value/set.hh>
 
 
@@ -50,7 +51,7 @@
     /*! Generic histogram class over a value set with type \c S.
      */
     template <typename S>
-    struct histo_on_set
+    struct histo_on_set : public Accumulator< histo_on_set<S> >
     {
       histo_on_set(const Value_Set<S>& s);
 
@@ -84,6 +85,9 @@
 
 
     /*! Generic histogram class over the set of values of type \c T.
+     *
+     * \todo Inheritance is badly formed since this concrete class
+     * derives from another concrete class.
      */
     template <typename T>
     struct histo_on_type : public histo_on_set< value::set_<T> >
Index: mln/accu/median.hh
--- mln/accu/median.hh	(revision 1014)
+++ mln/accu/median.hh	(working copy)
@@ -33,6 +33,7 @@
  * \brief Define FIXME
  */
 
+# include <mln/core/concept/accumulator.hh>
 # include <mln/accu/histo.hh>
 
 
@@ -47,7 +48,7 @@
      * with type \c S.
      */
     template <typename S>
-    struct median
+    struct median : public Accumulator< median<S> >
     {
       typedef mln_value(S) value;
 
@@ -91,6 +92,11 @@
     };
 
 
+    /*! Generic median class over the set of values of type \c T.
+     *
+     * \todo Inheritance is badly formed since this concrete class
+     * derives from another concrete class.
+     */
     template <typename T>
     struct median_on : public median< value::set_<T> >
     {
Index: mln/accu/counter.hh
--- mln/accu/counter.hh	(revision 0)
+++ mln/accu/counter.hh	(revision 0)
@@ -0,0 +1,109 @@
+// 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_ACCU_COUNTER_HH
+# define MLN_ACCU_COUNTER_HH
+
+/*! \file mln/accu/counter.hh
+ *
+ * \brief Define an accumulator that counts.
+ */
+
+# include <mln/core/concept/accumulator.hh>
+
+
+namespace mln
+{
+
+  namespace accu
+  {
+
+
+    /*! Generic counter accumulator class.
+     */
+    template <typename V>
+    struct counter : public Accumulator< counter<V> >
+    {
+      typedef V value;
+
+      counter();
+      void take(const value&);
+      void init();
+
+      operator std::size_t() const;
+      std::size_t to_value() const;
+      
+    protected:
+
+      std::size_t count_;
+    };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    template <typename V>
+    counter<V>::counter()
+    {
+      init();
+    }
+
+    template <typename V>
+    void
+    counter<V>::take(const value&)
+    {
+      ++count_;
+    }
+
+    template <typename V>
+    void
+    counter<V>::init()
+    {
+      count_ = 0;
+    }
+
+    template <typename V>
+    counter<V>::operator std::size_t() const
+    {
+      return to_value();
+    }
+
+    template <typename V>
+    std::size_t
+    counter<V>::to_value() const
+    {
+      return count_;
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_COUNTER_HH
Index: mln/accu/mean.hh
--- mln/accu/mean.hh	(revision 0)
+++ mln/accu/mean.hh	(revision 0)
@@ -0,0 +1,116 @@
+// 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_ACCU_MEAN_HH
+# define MLN_ACCU_MEAN_HH
+
+/*! \file mln/accu/mean.hh
+ *
+ * \brief Define an accumulator that computes a mean.
+ */
+
+# include <mln/core/concept/accumulator.hh>
+
+
+namespace mln
+{
+
+  namespace accu
+  {
+
+
+    /*! Generic mean accumulator class.
+     *
+     * Parameter \c V is the type of values that we sum.  Parameter \c
+     * S is the type to store the sum of values; the default type of
+     * \c S is \c V.  Parameter \c M is the type of the mean value;
+     * the default type of \c M is \c S.
+     */
+    template <typename V, typename S = V, typename M = S>
+    struct mean : public Accumulator< mean<V,S,M> >
+    {
+      typedef V value;
+
+      mean();
+      void take(const value& v);
+      void init();
+
+      operator M() const;
+      M to_value() const;
+      
+    protected:
+
+      std::size_t count_;
+      S sum_;
+    };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    template <typename V, typename S, typename M>
+    mean<V,S,M>::mean()
+    {
+      init();
+    }
+
+    template <typename V, typename S, typename M>
+    void mean<V,S,M>::take(const value& v)
+    {
+      ++count_;
+      sum_ += v;
+    }
+
+    template <typename V, typename S, typename M>
+    void
+    mean<V,S,M>::init()
+    {
+      count_ = 0;
+      sum_ = 0;
+    }
+
+    template <typename V, typename S, typename M>
+    mean<V,S,M>::operator M() const
+    {
+      return to_value;
+    }
+
+    template <typename V, typename S, typename M>
+    M
+    mean<V,S,M>::to_value() const
+    {
+      return sum_ / count_;
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_MEAN_HH
Index: mln/value/props.hh
--- mln/value/props.hh	(revision 1014)
+++ mln/value/props.hh	(working copy)
@@ -36,6 +36,9 @@
 # include <climits>
 # include <cfloat>
 
+# include <mln/core/macros.hh>
+# include <mln/value/kind.hh>
+
 
 /// Get the minimum value of type \c T.
 # define mln_min(T) mln::value::props<T>::min()
@@ -49,6 +52,11 @@
 # define mln_card(T) mln::value::props<T>::card()
 
 
+/// Get the kind of the value type of image \c I.
+# define mln_kind(I) typename mln::value::props< mln_value(I) >::kind
+
+
+
 
 namespace mln
 {
@@ -56,6 +64,7 @@
   namespace value
   {
 
+
     /*! Class that defines the properties of the value type \c T.
      */
     template <typename T>
@@ -80,6 +89,7 @@
       static bool min() { return false; }
       static bool max() { return true; }
       static std::size_t card() { return 2; }
+      typedef binary_kind kind;
     };
 
     // integers
@@ -90,6 +100,7 @@
       static unsigned char min() { return   0; }
       static unsigned char max() { return 255; }
       static std::size_t  card() { return 256; }
+      typedef data_kind kind;
     };
 
     template <>
@@ -98,6 +109,7 @@
       static signed char  min() { return -128; }
       static signed char  max() { return  127; }
       static std::size_t card() { return  256; }
+      typedef data_kind kind;
     };
 
     template <>
@@ -106,6 +118,7 @@
       static unsigned short min() { return     0; }
       static unsigned short max() { return 65535; }
       static std::size_t   card() { return 65536; }
+      typedef data_kind kind;
     };
 
     template <>
@@ -114,6 +127,7 @@
       static signed short min() { return -32768; }
       static signed short max() { return  32767; }
       static std::size_t card() { return 655356; }
+      typedef data_kind kind;
     };
 
     template <>
@@ -122,6 +136,7 @@
       static unsigned int min() { return 0; }
       static unsigned int max() { return UINT_MAX; }
       static std::size_t card() { return std::size_t(UINT_MAX) + 1; }
+      typedef data_kind kind;
     };
 
     template <>
@@ -130,6 +145,7 @@
       static signed int  min() { return INT_MIN; }
       static signed int  max() { return INT_MAX; }
       static std::size_t card() { return std::size_t(UINT_MAX) + 1; }
+      typedef data_kind kind;
     };
 
     template <>
@@ -137,6 +153,7 @@
     {
       static unsigned long int min() { return 0; }
       static unsigned long int max() { return ULONG_MAX; }
+      typedef data_kind kind;
     };
 
     template <>
@@ -144,6 +161,7 @@
     {
       static signed long int min() { return LONG_MIN; }
       static signed long int max() { return LONG_MAX; }
+      typedef data_kind kind;
     };
 
     // floating
@@ -153,6 +171,7 @@
     {
       static float min() { return FLT_MIN; }
       static float max() { return FLT_MAX; }
+      typedef data_kind kind;
     };
 
     template <>
@@ -160,6 +179,7 @@
     {
       static double min() { return DBL_MIN; }
       static double max() { return DBL_MAX; }
+      typedef data_kind kind;
     };
 
 # endif // ! MLN_INCLUDE_ONLY
Index: mln/value/kind.hh
--- mln/value/kind.hh	(revision 0)
+++ mln/value/kind.hh	(revision 0)
@@ -0,0 +1,60 @@
+// 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_VALUE_KIND_HH
+# define MLN_VALUE_KIND_HH
+
+/*! \file mln/value/tags.hh
+ *
+ * \brief Define the set of kinds of value.
+ */
+
+
+namespace mln
+{
+
+  namespace value
+  {
+
+    // FIXME: Doc!
+
+    struct kind
+    {
+    };
+
+    struct gray_level_kind : kind {};
+    struct color_kind  : kind {};
+    struct label_kind  : kind {};
+    struct binary_kind : kind {};
+    struct data_kind   : kind {};
+
+  } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_KIND_HH
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    13 Jul '07
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from  Thierry Geraud  <thierry.geraud(a)lrde.epita.fr>
	Fix make doc, handle todos, and pass tests with g++-2.95.
	* tests/safe_image.cc,
	* mln/core/concept/genpoint.hh,
	* mln/core/window.hh,
	* mln/core/internal/image_adaptor.hh,
	* mln/core/internal/set_of.hh,
	* mln/level/fill.hh,
	* mln/level/compare.hh,
	* mln/level/paste.hh,
	* mln/make/window2d.hh: Fix.
 mln/core/concept/genpoint.hh       |    3 ---
 mln/core/internal/image_adaptor.hh |    2 ++
 mln/core/internal/set_of.hh        |    9 ++++++---
 mln/core/window.hh                 |    2 --
 mln/level/compare.hh               |    9 ++++++---
 mln/level/fill.hh                  |   30 ++++++++++++------------------
 mln/level/paste.hh                 |   13 ++++++-------
 mln/make/window2d.hh               |    4 ++--
 tests/safe_image.cc                |    2 ++
 9 files changed, 36 insertions(+), 38 deletions(-)
Index: tests/safe_image.cc
--- tests/safe_image.cc	(revision 1013)
+++ tests/safe_image.cc	(working copy)
@@ -32,6 +32,7 @@
 
 #include <mln/core/image2d_b.hh>
 #include <mln/core/safe_image.hh>
+#include <mln/level/paste.hh>
 
 
 int main()
@@ -44,4 +45,5 @@
 
   point2d p = make::point2d(-5, -1);
   ima_(p) = 0;
+  level::paste(ima, ima_);
 }
Index: mln/core/concept/genpoint.hh
--- mln/core/concept/genpoint.hh	(revision 1013)
+++ mln/core/concept/genpoint.hh	(working copy)
@@ -185,9 +185,6 @@
    *
    * \see mln::Dpoint
    * \relates mln::GenPoint
-   *
-   * \todo Introduce the notion of "generalized dpoint" and
-   * add the more general extra operator-(GenPoint, GenDpoint).
    */
   template <typename P>
   mln_point(P)
Index: mln/core/window.hh
--- mln/core/window.hh	(revision 1013)
+++ mln/core/window.hh	(working copy)
@@ -94,8 +94,6 @@
     bool is_centered() const;
 
     /*! \brief Test if the window is symmetric.
-     *
-     * \todo Implementation!
      */
     bool is_symmetric() const;
 
Index: mln/core/internal/image_adaptor.hh
--- mln/core/internal/image_adaptor.hh	(revision 1013)
+++ mln/core/internal/image_adaptor.hh	(working copy)
@@ -103,6 +103,7 @@
     template <typename I, typename E, typename S>
     bool image_adaptor_<I,E,S>::owns_(const psite& p) const
     {
+      mln_precondition(exact(this)->has_data());
       return adaptee_.owns_(p);
     }
 
@@ -110,6 +111,7 @@
     const S&
     image_adaptor_<I,E,S>::domain() const
     {
+      mln_precondition(exact(this)->has_data());
       return adaptee_.domain();
     }
 
Index: mln/core/internal/set_of.hh
--- mln/core/internal/set_of.hh	(revision 1013)
+++ mln/core/internal/set_of.hh	(working copy)
@@ -37,6 +37,8 @@
 # include <set>
 # include <iterator>
 
+# include <mln/core/internal/force_exact.hh>
+
 
 namespace mln
 {
@@ -70,9 +72,9 @@
        *
        * If \p elt is already in the set, this method is a no-op.
        *
-       * \todo Returns exact(*this).
+       * \return The set itself after insertion.
        */
-      void insert(const E& elt);
+      set_of_<E>& insert(const E& elt);
 
 
       /*! \brief Return the i-th element of the set.
@@ -189,12 +191,13 @@
     }
 
     template <typename E>
-    void
+    set_of_<E>&
     set_of_<E>::insert(const E& elt)
     {
       s_.insert(elt);
       if (needs_update_ = false)
 	needs_update_ = true;
+      return internal::force_exact< set_of_<E> >(*this);
     }
 
     template <typename E>
Index: mln/level/fill.hh
--- mln/level/fill.hh	(revision 1013)
+++ mln/level/fill.hh	(working copy)
@@ -50,8 +50,7 @@
      * \pre \p ima has to be initialized.
      */
     template <typename I>
-    void fill(Image<I>& ima,
-	      const mln_value(I)& v);
+    void fill(Image<I>& ima, const mln_value(I)& v);
 
 
     /*! Fill the image \p ima by applying the function \p f.
@@ -65,8 +64,7 @@
      * \pre \p ima has to be initialized.
      */
     template <typename I>
-    void fill(Image<I>& ima,
-	      mln_value(I) (*f)(const mln_point(I)& p));
+    void fill(Image<I>& ima,  mln_value(I) (*f)(const mln_point(I)& p));
 
 
     /*! Fill the image \p ima with the values given by the array \p arr.
@@ -78,12 +76,10 @@
      * of image points, otherwise the program crashes.
      *
      * \pre \p ima has to be initialized.
-     *
-     * \todo Add as parameter the array size, then add a test.
+     * \pre N = \p ima.npoints
      */
-    template <typename I>
-    void fill(Image<I>& ima,
-	      const mln_value(I) arr[]);
+    template <typename I, unsigned N>
+    void fill(Image<I>& ima, mln_value(I) (&arr)[N]);
 
 
     /*! Fill the image \p ima with the values of the image \p data.
@@ -94,13 +90,10 @@
      * \warning The definition domain of \p ima has to be included in
      * the one of \p data.
      *
-     * \pre \p ima has to be initialized.
-     *
-     * \todo Test domain inclusion.
+     * \pre \p ima.domain <= \p data.domain.
      */
     template <typename I, typename J>
-    void fill(Image<I>& ima,
-	      const Image<J>& data);
+    void fill(Image<I>& ima, const Image<J>& data);
 
 
 
@@ -128,16 +121,17 @@
 	ima(p) = f(p);
     }
 
-    template <typename I>
+    template <typename I, unsigned N>
     void fill(Image<I>& ima_,
-	      const mln_value(I) array[])
+	      mln_value(I) (&arr)[N])
     {
       I& ima = exact(ima_);
       mln_precondition(ima.has_data());
+      mln_precondition(N = ima.npoints());
       mln_piter(I) p(ima.domain());
       unsigned i = 0;
       for_all(p)
-	ima(p) = array[i++];
+	ima(p) = arr[i++];
     }
 
     template <typename I, typename J>
@@ -146,7 +140,7 @@
     {
       I&        ima = exact(ima_);
       const J& data = exact(data_);
-      mln_precondition(ima.has_data() && data.has_data());
+      mln_precondition(ima.domain() <= data.domain());
 
       mln_piter(I) p(ima.domain());
       for_all(p)
Index: mln/level/compare.hh
--- mln/level/compare.hh	(revision 1013)
+++ mln/level/compare.hh	(working copy)
@@ -45,7 +45,7 @@
    * \param[in] lhs A first image.
    * \param[in] rhs A second image.
    *
-   * \todo Test domain equality.
+   * \pre lhs.domain = rhs.domain
    */
   template <typename L, typename R>
   bool operator = (const Image<L>& lhs, const Image<R>& rhs);
@@ -57,7 +57,7 @@
    * \param[in] lhs A first image.
    * \param[in] rhs A second image.
    *
-   * \todo Test domain equality.
+   * \pre lhs.domain = rhs.domain
    */
   template <typename L, typename R>
   bool operator < (const Image<L>& lhs, const Image<R>& rhs);
@@ -69,7 +69,7 @@
    * \param[in] lhs A first image.
    * \param[in] rhs A second image.
    *
-   * \todo Test domain equality.
+   * \pre lhs.domain = rhs.domain
    */
   template <typename L, typename R> // required!
   bool operator <= (const Image<L>& lhs, const Image<R>& rhs);
@@ -83,6 +83,7 @@
   {
     const L& lhs = exact(lhs_);
     const R& rhs = exact(rhs_);
+    mln_precondition(lhs.domain() = rhs.domain());
     mln_piter(L) p(lhs.domain());
     for_all(p)
       if (! (lhs(p) = rhs(p)))
@@ -95,6 +96,7 @@
   {
     const L& lhs = exact(lhs_);
     const R& rhs = exact(rhs_);
+    mln_precondition(lhs.domain() = rhs.domain());
     mln_piter(L) p(lhs.domain());
     for_all(p)
       if (! (lhs(p) < rhs(p)))
@@ -107,6 +109,7 @@
   {
     const L& lhs = exact(lhs_);
     const R& rhs = exact(rhs_);
+    mln_precondition(lhs.domain() = rhs.domain());
     mln_piter(L) p(lhs.domain());
     for_all(p)
       if (! (lhs(p) <= rhs(p)))
Index: mln/level/paste.hh
--- mln/level/paste.hh	(revision 1013)
+++ mln/level/paste.hh	(working copy)
@@ -52,12 +52,11 @@
      * This routine runs: \n
      * for all p of \p data, \p destination(p) = \p data(p).
      *
-     * \warning The definition domain of \p data has to be included
-     * in the one of \p destination.
+     * \warning The definition domain of \p data has to be included in
+     * the one of \p destination; so using mln::safe_image does not 
+     * make pasting outside the destination domain work.
      *
-     * \pre Both images have to be initialized.
-     *
-     * \todo Test domain inclusion.
+     * \pre \p data.domain <= \p destination.domain
      */
     template <typename I, typename J>
     void paste(const Image<I>& data, Image<J>& destination);
@@ -69,8 +68,8 @@
     void paste(const Image<I>& data_, Image<J>& destination_)
     {
       const I& data  = exact(data_);
-      I& destination = exact(destination_);
-      assert(ima.has_data() && destination.has_data());
+      J& destination = exact(destination_);
+      mln_precondition(data.domain() <= destination.domain());
 
       mln_piter(I) p(data.domain());
       for_all(p)
Index: mln/make/window2d.hh
--- mln/make/window2d.hh	(revision 1013)
+++ mln/make/window2d.hh	(working copy)
@@ -53,13 +53,13 @@
      * \return A 2D window.
      */
     template <unsigned M>
-    mln::window2d window2d(const bool (&values)[M]);
+    mln::window2d window2d(bool (&values)[M]);
 
 
 # ifndef MLN_INCLUDE_ONLY
 
     template <unsigned M>
-    mln::window2d window2d(const bool (&values)[M])
+    mln::window2d window2d(bool (&values)[M])
     {
       int h = unsigned(std::sqrt(float(M))) / 2;
       assert((2 * h + 1) * (2 * h + 1) = M);
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from  Thierry Geraud  <thierry.geraud(a)lrde.epita.fr>
	Add subimage in milena.
	* tests/subimage.cc: New.
	* mln/core/subimage.hh: New.
	* mln/debug/println.hh: Handle "not has" cases.
	* mln/core/concept/box.hh
	(operator=, operator<, operator<=): New.
	* mln/core/concept/point_set.hh: Likewise.
	* mln/core/internal/image_adaptor.hh: Add default parameter.
	* mln/core/internal/piter_adaptor.hh: .
	* mln/accu/histo.hh,
	* mln/accu/median.hh,
	* mln/accu/median_alt.hh,
	* mln/value/viter.hh,
	* mln/value/set.hh,
	* mln/make/dpoint2d.hh,
	* mln/make/point2d.hh: Fix doc.
 mln/accu/histo.hh                  |    2 
 mln/accu/median.hh                 |    2 
 mln/accu/median_alt.hh             |    4 -
 mln/core/concept/box.hh            |   76 +++++++++++++++++++++++
 mln/core/concept/point_set.hh      |   98 ++++++++++++++++++++++++++++++
 mln/core/internal/image_adaptor.hh |   44 +++++++------
 mln/core/internal/piter_adaptor.hh |    6 -
 mln/core/subimage.hh               |  118 +++++++++++++++++++++++++++++++++++++
 mln/debug/println.hh               |    7 +-
 mln/make/dpoint2d.hh               |    2 
 mln/make/point2d.hh                |    2 
 mln/value/set.hh                   |    2 
 mln/value/viter.hh                 |    4 -
 tests/subimage.cc                  |   47 ++++++++++++++
 14 files changed, 379 insertions(+), 35 deletions(-)
Index: tests/subimage.cc
--- tests/subimage.cc	(revision 0)
+++ tests/subimage.cc	(revision 0)
@@ -0,0 +1,47 @@
+// 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.
+
+/*! \file tests/subimage.cc
+ *
+ * \brief Tests on mln::subimage.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/core/subimage.hh>
+#include <mln/fun/chess.hh>
+#include <mln/debug/println.hh>
+
+
+int main()
+{
+  using namespace mln;
+
+  image2d_b<int> ima(8, 8);
+  debug::println(ima | fun::chess);
+
+  // mln_assertion((box_8x8 | fun::chess).npoints() = 32);
+}
Index: mln/debug/println.hh
--- mln/debug/println.hh	(revision 1012)
+++ mln/debug/println.hh	(working copy)
@@ -67,7 +67,7 @@
 	std::cout << std::endl;
       }
 
-      // "domain = box2d" version
+      // 2D version
       template <typename I>
       void println(const box2d& b, const I& input)
       {
@@ -79,7 +79,10 @@
 	for (row = b.min_row(); row <= max_row; ++row)
 	  {
 	    for (col = b.min_col(); col <= max_col; ++col)
+	      if (input.has(p))
 	      std::cout << format( input(p) ) << ' ';
+	      else
+		std::cout << "  ";
 	    std::cout << std::endl;
 	  }
 	std::cout << std::endl;
@@ -94,7 +97,7 @@
     template <typename I>
     void println(const Image<I>& input)
     {
-      impl::println(exact(input).domain(), exact(input));
+      impl::println(exact(input).bbox(), exact(input));
     }
 
 # endif // ! MLN_INCLUDE_ONLY
Index: mln/core/subimage.hh
--- mln/core/subimage.hh	(revision 0)
+++ mln/core/subimage.hh	(revision 0)
@@ -0,0 +1,118 @@
+// 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_SUBIMAGE_HH
+# define MLN_CORE_SUBIMAGE_HH
+
+/*! \file mln/core/subimage.hh
+ *
+ * \brief Definition of a base class for image adaptors.
+ */
+
+# include <mln/core/internal/image_adaptor.hh>
+# include <mln/core/psubset.hh>
+
+
+namespace mln
+{
+
+  /*! \brief A base class for image adaptors.
+   *
+   */
+  template <typename I, typename F>
+  struct subimage : public internal::image_adaptor_< I,
+						     subimage<I,F>,
+						     psubset<mln_pset(I),F>  >
+  {
+    /// Point_Set associated type.
+    typedef psubset<mln_pset(I), F> pset;
+
+    /// Constructor from an \p adaptee image.
+    subimage(I& adaptee, const F& f);
+
+    /// Test if a pixel value is accessible at \p p.
+    bool owns_(const mln_psite(I)& p) const;
+
+    /// Give the definition domain.
+    const pset& domain() const;
+
+    template <typename T>
+    struct change_value
+    {
+      typedef subimage<mln_ch_value(I,T), F> ret;
+    };
+
+  protected:
+
+    pset pset_;
+    F f_;
+
+    typedef subimage<I,F> self_;
+    typedef internal::image_adaptor_< I, self_, pset > super_;
+  };
+
+
+
+  template <typename I, typename F>
+  subimage<I, F>
+  operator | (Image<I>& ima, const Function_p2b<F>& f)
+  {
+    subimage<I, F> tmp(exact(ima), exact(f));
+    return tmp;
+  }
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+  template <typename I, typename F>
+  subimage<I,F>::subimage(I& adaptee, const F& f)
+    : super_(adaptee),
+      pset_(adaptee.domain() | f),
+      f_(f)
+  {
+  }
+
+  template <typename I, typename F>
+  bool
+  subimage<I,F>::owns_(const mln_psite(I)& p) const
+  {
+    return pset_.has(p);
+  }
+
+  template <typename I, typename F>
+  const psubset<mln_pset(I), F>&
+  subimage<I,F>::domain() const
+  {
+    return pset_;
+  }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_SUBIMAGE_HH
Index: mln/core/concept/box.hh
--- mln/core/concept/box.hh	(revision 1012)
+++ mln/core/concept/box.hh	(working copy)
@@ -85,8 +85,47 @@
   };
 
 
+
+  /*! \brief Equality test between boxes \p lhs and \p rhs.
+   *
+   * \param[in] lhs A box.
+   * \param[in] rhs Another box.
+   *
+   * \relates mln::Box
+   */
+  template <typename Bl, typename Br>
+  bool operator=(const Box<Bl>& lhs, const Box<Br>& rhs);
+
+
+
+  /*! \brief Inclusion test between boxes \p lhs and \p rhs.
+   *
+   * \param[in] lhs A box (included?).
+   * \param[in] rhs Another box (includor?).
+   *
+   * \relates mln::Box
+   */
+  template <typename Bl, typename Br>
+  bool operator<=(const Box<Bl>& lhs, const Box<Br>& rhs);
+
+
+  /*! \brief Strict inclusion test between boxes \p lhs and \p rhs.
+   *
+   * \param[in] lhs A box (strictly included?).
+   * \param[in] rhs Another box (includor?).
+   *
+   * \relates mln::Box
+   */
+  template <typename Bl, typename Br>
+  bool operator<(const Box<Bl>& lhs, const Box<Br>& rhs);
+
+
+
+
 # ifndef MLN_INCLUDE_ONLY
 
+  // Box<E>
+
   template <typename E>
   const E& Box<E>::bbox() const
   {
@@ -114,12 +153,47 @@
   Box<E>::npoints() const
   {
     std::size_t count = 1;
-    typedef typename E::point P; // helps g++-3.3.5
+    typedef mln_point(E) P; // helps g++-3.3.5
     for (unsigned i = 0; i < P::dim; ++i)
       count *= exact(this)->len(i);
     return count;
   }
 
+
+  // operators
+
+  template <typename Bl, typename Br>
+  bool operator=(const Box<Bl>& lhs_, const Box<Br>& rhs_)
+  {
+    // FIXME: Same grid!
+    const Bl& lhs = exact(lhs_);
+    const Br& rhs = exact(rhs_);
+    return lhs.pmin() = rhs.pmin() && lhs.pmax() = rhs.pmax();
+  }
+
+  template <typename Bl, typename Br>
+  bool operator<=(const Box<Bl>& lhs_, const Box<Br>& rhs_)
+  {
+    // FIXME: Same grid!
+    const Bl& lhs = exact(lhs_);
+    const Br& rhs = exact(rhs_);
+    typedef mln_point(Bl) P;
+    for (unsigned i = 0; i < P::dim; ++i)
+      if (lhs.pmin()[i] < rhs.pmin()[i] ||
+	  lhs.pmax()[i] > rhs.pmax()[i])
+	return false;
+    return true;
+  }
+
+  template <typename Bl, typename Br>
+  bool operator<(const Box<Bl>& lhs_, const Box<Br>& rhs_)
+  {
+    // FIXME: Same grid!
+    const Bl& lhs = exact(lhs_);
+    const Br& rhs = exact(rhs_);
+    return lhs <= rhs && ! lhs = rhs;
+  }
+
 # endif // ! MLN_INCLUDE_ONLY
 
 } // end of namespace mln
Index: mln/core/concept/point_set.hh
--- mln/core/concept/point_set.hh	(revision 1012)
+++ mln/core/concept/point_set.hh	(working copy)
@@ -64,6 +64,43 @@
   };
 
 
+  /*! \brief Equality test between point sets \p lhs and \p rhs.
+   *
+   * \param[in] lhs A point set.
+   * \param[in] rhs Another point set.
+   *
+   * \relates mln::Point_Set
+   */
+  template <typename Sl, typename Sr>
+  bool operator=(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
+
+
+
+  /*! \brief Inclusion test between point sets \p lhs and \p rhs.
+   *
+   * \param[in] lhs A point set (included?).
+   * \param[in] rhs Another point set (includer?).
+   *
+   * \relates mln::Point_Set
+   */
+  template <typename Sl, typename Sr>
+  bool operator<=(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
+
+
+
+  /*! \brief Strict inclusion test between point sets \p lhs and \p
+   *  rhs.
+   *
+   * \param[in] lhs A point set (strictly included?).
+   * \param[in] rhs Another point set (includer?).
+   *
+   * \relates mln::Point_Set
+   */
+  template <typename Sl, typename Sr>
+  bool operator<(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
+
+
+
   /*! \brief Print a point set \p pset into the output stream \p
    *  ostr.
    *
@@ -78,6 +115,7 @@
   std::ostream& operator<<(std::ostream& ostr, const Point_Set<S>& pset);
 
 
+
 # ifndef MLN_INCLUDE_ONLY
 
   // fwd decl
@@ -102,6 +140,66 @@
   }
 
 
+  // operators
+
+
+  template <typename Sl, typename Sr>
+  bool operator=(const Point_Set<Sl>& lhs_, const Point_Set<Sr>& rhs_)
+  {
+    // FIXME: Same grid!
+    const Sl& lhs = exact(lhs_);
+    const Sr& rhs = exact(rhs_);
+
+    // easy test:
+    if (lhs.npoints() != rhs.npoints())
+      return false;
+
+    // exhaustive test:
+    mln_fwd_piter(Sl) pl(lhs);
+    mln_fwd_piter(Sr) pr(rhs);
+    for (pl.start(),      pr.start();
+	 pl.is_valid() && pr.is_valid();
+	 pl.next(),       pr.next())
+      if (pl != pr)
+	return false; // difference found
+
+    // both sets are equal only if both browsings are completed
+    // at the same time:
+    return ! pl.is_valid() && ! pr.is_valid();
+  }
+
+
+  template <typename Sl, typename Sr>
+  bool operator<=(const Point_Set<Sl>& lhs_, const Point_Set<Sr>& rhs_)
+  {
+    // FIXME: Same grid!
+    const Sl& lhs = exact(lhs_);
+    const Sr& rhs = exact(rhs_);
+
+    // easy test:
+    if (lhs.npoints() > rhs.npoints())
+      return false;
+
+    // exhaustive test:
+    mln_piter(Sl) pl(lhs);
+    for_all(pl)
+      if (! rhs.has(pl))
+	return false;
+
+    return true;
+  }
+
+
+  template <typename Sl, typename Sr>
+  bool operator<(const Point_Set<Sl>& lhs_, const Point_Set<Sr>& rhs_)
+  {
+    // FIXME: Same grid!
+    const Sl& lhs = exact(lhs_);
+    const Sr& rhs = exact(rhs_);
+    return lhs <= rhs && lhs.npoints() != rhs.npoints();
+  }
+
+
   template <typename S>
   std::ostream& operator<<(std::ostream& ostr, const Point_Set<S>& pset_)
   {
Index: mln/core/internal/image_adaptor.hh
--- mln/core/internal/image_adaptor.hh	(revision 1012)
+++ mln/core/internal/image_adaptor.hh	(working copy)
@@ -46,14 +46,16 @@
      *
      * \internal
      */
-    template <typename I, typename E>
-    struct image_adaptor_ : public internal::image_base_< mln_pset(I), E >
+    template < typename I,
+	       typename E,
+	       typename S = mln_pset(I) >
+    struct image_adaptor_ : public internal::image_base_< S, E >
     {
       /// Psite associated type.
-      typedef mln_psite(I) psite;
+      typedef mln_psite(S) psite;
 
       /// Point_Set associated type.
-      typedef mln_pset(I)  pset;
+      typedef S pset;
 
       /// Value associated type.
       typedef mln_value(I)   value;
@@ -71,7 +73,7 @@
       bool owns_(const psite& p) const;
 
       /// Give the definition domain.
-      const pset& domain() const;
+      const S& domain() const;
 
       /// Read-only access of pixel value at point site \p p.
       rvalue operator()(const psite& p) const;
@@ -92,41 +94,43 @@
 
 # ifndef MLN_INCLUDE_ONLY
 
-    template <typename I, typename E>
-    bool image_adaptor_<I,E>::has_data() const
+    template <typename I, typename E, typename S>
+    bool image_adaptor_<I,E,S>::has_data() const
     {
       return adaptee_.has_data();
     }
 
-    template <typename I, typename E>
-    bool image_adaptor_<I,E>::owns_(const psite& p) const
+    template <typename I, typename E, typename S>
+    bool image_adaptor_<I,E,S>::owns_(const psite& p) const
     {
       return adaptee_.owns_(p);
     }
 
-    template <typename I, typename E>
-    const typename image_adaptor_<I,E>::pset&
-    image_adaptor_<I,E>::domain() const
+    template <typename I, typename E, typename S>
+    const S&
+    image_adaptor_<I,E,S>::domain() const
     {
       return adaptee_.domain();
     }
 
-    template <typename I, typename E>
-    typename image_adaptor_<I,E>::rvalue
-    image_adaptor_<I,E>::operator()(const psite& p) const
+    template <typename I, typename E, typename S>
+    typename image_adaptor_<I,E,S>::rvalue
+    image_adaptor_<I,E,S>::operator()(const psite& p) const
     {
+      mln_precondition(exact(this)->owns_(p));
       return adaptee_(p);
     }
 
-    template <typename I, typename E>
-    typename image_adaptor_<I,E>::lvalue
-    image_adaptor_<I,E>::operator()(const psite& p)
+    template <typename I, typename E, typename S>
+    typename image_adaptor_<I,E,S>::lvalue
+    image_adaptor_<I,E,S>::operator()(const psite& p)
     {
+      mln_precondition(exact(this)->owns_(p));
       return adaptee_(p);
     }
 
-    template <typename I, typename E>
-    image_adaptor_<I,E>::image_adaptor_(Image<I>& adaptee)
+    template <typename I, typename E, typename S>
+    image_adaptor_<I,E,S>::image_adaptor_(Image<I>& adaptee)
       : adaptee_(exact(adaptee))
     {
     }
Index: mln/core/internal/piter_adaptor.hh
--- mln/core/internal/piter_adaptor.hh	(revision 1012)
+++ mln/core/internal/piter_adaptor.hh	(working copy)
@@ -28,7 +28,7 @@
 #ifndef MLN_CORE_INTERNAL_PITER_ADAPTOR_HH
 # define MLN_CORE_INTERNAL_PITER_ADAPTOR_HH
 
-/*! \file mln/core/internal/piter_adaptor_.hh
+/*! \file mln/core/internal/piter_adaptor.hh
  *
  * \brief Definition of iterators on points of boxes.
  */
@@ -69,12 +69,12 @@
       typedef mln_coord(Pi) coord;
 
 
-      /// Constructor from a point iterator \p \piter.
+      /// Constructor from a point iterator \p piter.
       piter_adaptor_(const Pi& piter);
 
 
       /// Convertion to point.
-      operator point() const;
+      operator mln_point(Pi) () const;
 
       /// Address of the point.
       const point* pointer() const;
Index: mln/accu/histo.hh
--- mln/accu/histo.hh	(revision 1012)
+++ mln/accu/histo.hh	(working copy)
@@ -28,7 +28,7 @@
 #ifndef MLN_ACCU_HISTO_HH
 # define MLN_ACCU_HISTO_HH
 
-/*! \file mln/value/histo.hh
+/*! \file mln/accu/histo.hh
  *
  * \brief Define a couple of generic histogram classes.
  */
Index: mln/accu/median.hh
--- mln/accu/median.hh	(revision 1012)
+++ mln/accu/median.hh	(working copy)
@@ -59,7 +59,7 @@
 
       unsigned card() const { return h_.sum(); }
 
-      operator value() const;
+      operator mln_value(S) () const;
       value to_value() const;
 
       const histo_on_set<S>& histo() const;
Index: mln/accu/median_alt.hh
--- mln/accu/median_alt.hh	(revision 1012)
+++ mln/accu/median_alt.hh	(working copy)
@@ -57,7 +57,7 @@
       void untake(const value& v);
       void init();
 
-      operator value() const;
+      operator mln_value(S) () const;
       value to_value() const;
 
       // FIXME: remove
@@ -249,7 +249,7 @@
     }
 
     template <typename S>
-    median_alt<S>::operator typename median_alt<S>::value () const
+    median_alt<S>::operator mln_value(S) () const
     {
       return v_;
     }
Index: mln/value/viter.hh
--- mln/value/viter.hh	(revision 1012)
+++ mln/value/viter.hh	(working copy)
@@ -58,7 +58,7 @@
       fwd_viter_(const Value_Set<S>& s);
 
       /// Convertion into a value.
-      operator value() const;
+      operator mln_value(S) () const;
 
       /// Test if the iterator is valid.
       bool is_valid() const;
@@ -95,7 +95,7 @@
       bkd_viter_(const Value_Set<S>& s);
 
       /// Convertion into a value.
-      operator value() const;
+      operator mln_value(S) () const;
 
       /// Test if the iterator is valid.
       bool is_valid() const;
Index: mln/value/set.hh
--- mln/value/set.hh	(revision 1012)
+++ mln/value/set.hh	(working copy)
@@ -28,7 +28,7 @@
 #ifndef MLN_VALUE_SET_HH
 # define MLN_VALUE_SET_HH
 
-/*! \file mln/value/vset.hh
+/*! \file mln/value/set.hh
  *
  * \brief Define some basic sets of values from value types.
  */
Index: mln/make/dpoint2d.hh
--- mln/make/dpoint2d.hh	(revision 1012)
+++ mln/make/dpoint2d.hh	(working copy)
@@ -45,7 +45,7 @@
     /*! \brief Create an mln::dpoint2d.
      *
      * \param[in] row Row coordinate.
-     * \param[in] Col Column coordinate.
+     * \param[in] col Column coordinate.
      *
      * \return A 2D dpoint.
      */
Index: mln/make/point2d.hh
--- mln/make/point2d.hh	(revision 1012)
+++ mln/make/point2d.hh	(working copy)
@@ -45,7 +45,7 @@
     /*! \brief Create an mln::point2d.
      *
      * \param[in] row Row coordinate.
-     * \param[in] Col Column coordinate.
+     * \param[in] col Column coordinate.
      *
      * \return A 2D point.
      */
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from  Thierry Geraud  <thierry.geraud(a)lrde.epita.fr>
	Add a canvas to milena.
	* mln/level/median.hh (impl::median): Rename as...
	(impl::median_as_procedure): ...this.
	(impl::median_functor, impl::median): New.
	* mln/canvas: New.
	* mln/canvas/sbrowsing.hh: New.
 canvas/sbrowsing.hh |  110 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 level/median.hh     |   89 +++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 198 insertions(+), 1 deletion(-)
Index: mln/level/median.hh
--- mln/level/median.hh	(revision 1011)
+++ mln/level/median.hh	(working copy)
@@ -37,6 +37,8 @@
 # include <mln/core/window2d.hh>
 # include <mln/accu/median.hh>
 
+# include <mln/canvas/sbrowsing.hh>
+
 
 namespace mln
 {
@@ -65,7 +67,7 @@
     {
 
       template <typename I, typename W, typename O>
-      void median(const I& input,
+      void median_as_procedure(const I& input,
 		  const W& win,
 		  O& output)
       {
@@ -146,6 +148,91 @@
 	  }
       }
 
+
+      template <typename I, typename W, typename O>
+      struct median_functor
+      { 
+	// i/o
+
+	const I& input;
+	const W& win;
+	O& output;
+
+	// aux data
+
+	mln_point(I) p;
+	window2d     win_fp, win_fm, win_bp, win_bm, win_dp, win_dm;
+	mln_qiter(W)   q_fp,   q_fm,   q_bp,   q_bm,   q_dp,   q_dm;
+	accu::median_on<mln_value(I)> med;
+
+	// ctor
+
+	median_functor(I& input_, const W& win_, O& output_)
+	  :
+	  // i/o
+	  input(exact(input_)),
+	  win(exact(win_)),
+	  output(exact(output_)),
+	  // aux data
+	  p(),
+	  win_fp(win - (win + left)),   win_fm((win + left)  - win),
+	  win_bp(win - (win + right)),  win_bm((win + right) - win),
+	  win_dp(win - (win + up)),     win_dm((win + up)    - win),
+	  q_fp(win_fp, p),  q_fm(win_fm, p),
+	  q_bp(win_bp, p),  q_bm(win_bm, p),
+	  q_dp(win_dp, p),  q_dm(win_dm, p)
+	{
+	}
+
+	// parts
+
+	void init()
+	{
+	  med.init();
+	  mln_qiter(W) q(win, p);
+	  for_all(q) if (input.has(q))
+	    med.take(input(q));
+	}
+
+	void down()
+	{
+	  for_all(q_dm) if (input.has(q_dm))
+	    med.untake(input(q_dm));
+	  for_all(q_dp) if (input.has(q_dp))
+	    med.take(input(q_dp));
+	  output(p) = med;
+	}
+
+	void fwd()
+	{
+	  for_all(q_fm) if (input.has(q_fm))
+	    med.untake(input(q_fm));
+	  for_all(q_fp) if (input.has(q_fp))
+	    med.take(input(q_fp));
+	  output(p) = med;
+	}
+
+	void bkd()
+	{
+	  for_all(q_bm) if (input.has(q_bm))
+	    med.untake(input(q_bm));
+	  for_all(q_bp) if (input.has(q_bp))
+	    med.take(input(q_bp));
+	  output(p) = med;
+	}
+
+      }; // end of median_functor
+
+
+      template <typename I, typename W, typename O>
+      void median(I& input, const W& win, O& output)
+      {
+	// FIXME: resize border!
+	impl::median_functor<I,W,O> f(input, win, output);
+	canvas::sbrowsing(f);
+      }
+
+
     } // end of namespace mln::level::impl
 
 
Index: mln/canvas/sbrowsing.hh
--- mln/canvas/sbrowsing.hh	(revision 0)
+++ mln/canvas/sbrowsing.hh	(revision 0)
@@ -0,0 +1,110 @@
+// 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_CANVAS_SBROWSING_HH
+# define MLN_CANVAS_SBROWSING_HH
+
+/*! \file mln/canvas/sbrowsing.hh
+ *
+ * \brief Sbrowsing of an image.
+ */
+
+# include <mln/core/dpoint2d.hh> // for "up"
+
+
+namespace mln
+{
+
+  namespace canvas
+  {
+
+    /*! FIXME: Doc!
+     *
+     *
+     * F should be
+     * {
+     *   input;  p;  --- attributes
+     *   void init();
+     *   void down(); void fwd(); void bkd(); --- methods
+     * }
+     */
+    template <typename F>
+    void sbrowsing(F& f);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    template <typename F>
+    void sbrowsing(F& f)
+    {
+      mln_precondition(f.input.has_data());
+      int
+	min_row = f.input.min_row(), max_row = f.input.max_row(),
+	min_col = f.input.min_col(), max_col = f.input.max_col();
+
+      // p
+      f.p = f.input.domain().pmin() + up;
+      int& row = f.p.row();
+      int& col = f.p.col();
+
+      // initialization
+      f.init();
+
+      bool fwd = true;
+      for (row = min_row; row <= max_row; ++row)
+	{
+	  // go down
+	  f.down();
+
+	  if (fwd)
+	    // browse line fwd
+	    while (col < max_col)
+	      {
+		++col;
+		f.fwd();
+	      }
+	  else
+	    // browse line bkd
+	    while (col > min_col)
+	      {
+		--col;
+		f.bkd();
+	      }
+
+	  // change browsing
+	  fwd = ! fwd;
+	}
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::canvas
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CANVAS_SBROWSING_HH
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from  Thierry Geraud  <thierry.geraud(a)lrde.epita.fr>
	Add pixel in milena.
	* tests/pixel.cc: New.
	* mln/core/pixel.hh: New.
	* mln/core/concept/genpixel.hh: New.
	* mln/core/internal/force_exact.hh
	(mln_internal_add_force_exact_): Remove.
	(force_exact): New.
	* mln/convert/to_dpoint.hh,
	* mln/core/dpoints_piter.hh,
	* mln/core/concept/genpoint.hh,
	* mln/core/internal/coord_impl.hh,
	* mln/core/internal/box_impl.hh: Update.
 mln/convert/to_dpoint.hh         |    2 
 mln/core/concept/genpixel.hh     |  126 +++++++++++++++++++++++++++++++
 mln/core/concept/genpoint.hh     |   23 ++---
 mln/core/dpoints_piter.hh        |    2 
 mln/core/internal/box_impl.hh    |   20 +---
 mln/core/internal/coord_impl.hh  |   49 ++++--------
 mln/core/internal/force_exact.hh |   45 +++++++----
 mln/core/pixel.hh                |  158 +++++++++++++++++++++++++++++++++++++++
 tests/pixel.cc                   |   61 +++++++++++++++
 9 files changed, 415 insertions(+), 71 deletions(-)
Index: tests/pixel.cc
--- tests/pixel.cc	(revision 0)
+++ tests/pixel.cc	(revision 0)
@@ -0,0 +1,61 @@
+// 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.
+
+/*! \file tests/pixel.cc
+ *
+ * \brief Tests on mln::pixel.
+ */
+
+#include <mln/core/pixel.hh>
+#include <mln/core/image2d_b.hh>
+
+
+int main()
+{
+  using namespace mln;
+
+  typedef image2d_b<int> I;
+  I ima(3, 3);
+
+  {
+    pixel<I> pxl(ima);
+    pxl.site() = make::point2d(1, 1);
+    *pxl = 51;
+    mln_assertion(ima.at(1,1) = 51);
+  }
+
+  {
+    pixel<const I> pxl(ima);
+    pxl.site() = make::point2d(1, 1);
+    ima.at(1,1) = 51;
+    mln_assertion(*pxl = 51);
+
+    // hopefully the code below does not compile:
+    // *pxl = 0;
+    // assignment of read-only location
+  }
+}
Index: mln/convert/to_dpoint.hh
--- mln/convert/to_dpoint.hh	(revision 1010)
+++ mln/convert/to_dpoint.hh	(working copy)
@@ -52,7 +52,7 @@
     template <typename P>
     mln_dpoint(P) to_dpoint(const GenPoint<P>& p_)
     {
-      const P& p = p_.force_exact_();
+      const P& p = internal::force_exact<P>(p_);
       mln_dpoint(P) tmp;
       for (unsigned i = 0; i < P::dim; ++i)
 	tmp[i] = p[i];
Index: mln/core/pixel.hh
--- mln/core/pixel.hh	(revision 0)
+++ mln/core/pixel.hh	(revision 0)
@@ -0,0 +1,158 @@
+// 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_PIXEL_HH
+# define MLN_CORE_PIXEL_HH
+
+/*! \file mln/core/pixel.hh
+ *
+ * \brief Definition of the generic pixel class mln::pixel.
+ */
+
+# include <mln/core/concept/genpixel.hh>
+
+
+namespace mln
+{
+
+
+  template <typename I>
+  struct pixel_lvalue
+  {
+    typedef mln_lvalue(I) ret;
+  };
+
+  template <typename I>
+  struct pixel_lvalue< const I >
+  {
+    typedef mln_rvalue(I) ret;
+  };
+
+
+
+  /*! \brief Generic pixel class.
+   *
+   * The parameter is \c I the type of the image it belongs to.
+   */
+  template <typename I>
+  struct pixel : public Object< pixel<I> >,
+		 public GenPixel< pixel<I> >
+  {
+    typedef mln_psite(I) psite;
+    typedef mln_value(I) value;
+
+    pixel(I& ima);
+    pixel(I& ima, const psite& p);
+
+    const I& image() const;
+
+    const psite& site() const;
+    psite& site();
+
+    mln_rvalue(I) operator*() const;
+    typename pixel_lvalue<I>::ret operator*();
+
+    const value* address() const;
+    value* address();
+
+  protected:
+
+    I& ima_;
+    psite p_;
+  };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+  template <typename I>
+  pixel<I>::pixel(I& image)
+    : ima_(image)
+  {
+  }
+
+  template <typename I>
+  pixel<I>::pixel(I& image, const psite& p)
+    : ima_(image),
+      p_(p)
+  {
+  }
+
+  template <typename I>
+  const I&
+  pixel<I>::image() const
+  {
+    return ima_;
+  }
+
+  template <typename I>
+  const mln_psite(I)&
+  pixel<I>::site() const
+  {
+    return p_;
+  }
+
+  template <typename I>
+  mln_psite(I)&
+  pixel<I>::site()
+  {
+    return p_;
+  }
+
+  template <typename I>
+  mln_rvalue(I)
+  pixel<I>::operator*() const
+  {
+    return ima_(p_);
+  }
+
+  template <typename I>
+  typename pixel_lvalue<I>::ret
+  pixel<I>::operator*()
+  {
+    return ima_(p_);
+  }
+
+  template <typename I>
+  const mln_value(I)*
+  pixel<I>::address() const
+  {
+    return & ima_(p_);
+  }
+
+  template <typename I>
+  mln_value(I)*
+  pixel<I>::address()
+  {
+    return & ima_(p_);
+  }
+
+# endif // ! MLN_INCLUDE_ONLY
+  
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_PIXEL_HH
Index: mln/core/dpoints_piter.hh
--- mln/core/dpoints_piter.hh	(revision 1010)
+++ mln/core/dpoints_piter.hh	(working copy)
@@ -112,7 +112,7 @@
   dpoints_fwd_piter<D>::dpoints_fwd_piter(const Dps& dps,
 					  const GenPoint<Pref>& p_ref)
     : dps_(exact(dps).vec()),
-      p_ref_(* p_ref.force_exact_().pointer())
+      p_ref_(* internal::force_exact<Pref>(p_ref).pointer())
   {
     invalidate();
   }
Index: mln/core/concept/genpoint.hh
--- mln/core/concept/genpoint.hh	(revision 1010)
+++ mln/core/concept/genpoint.hh	(working copy)
@@ -77,8 +77,6 @@
       coord operator[](unsigned i) const;
     */
 
-    mln_internal_add_force_exact_(GenPoint<E>)
-
   protected:
     GenPoint();
 
@@ -210,8 +208,10 @@
   std::ostream& operator<<(std::ostream& ostr, const GenPoint<P>& p);
 
 
+
 # ifndef MLN_INCLUDE_ONLY
 
+
   template <typename E>
   GenPoint<E>::GenPoint()
   {
@@ -227,12 +227,13 @@
     m2 = 0;
   }
 
+
   template <typename Pl, typename Pr>
   bool operator=(const GenPoint<Pl>& lhs, const GenPoint<Pr>& rhs)
   {
     // FIXME: mlc::same_grid<Pl, Pr>::check();
-    const Pl& lhs_ = lhs.force_exact_();
-    const Pr& rhs_ = rhs.force_exact_();
+    const Pl& lhs_ = internal::force_exact<Pl>(lhs);
+    const Pr& rhs_ = internal::force_exact<Pr>(rhs);
     mlc::same_point<Pl, Pr>::check();
     for (unsigned i = 0; i < Pl::dim; ++i)
       if (lhs_[i] != rhs_[i])
@@ -244,8 +245,8 @@
   bool operator<(const GenPoint<Pl>& lhs, const GenPoint<Pr>& rhs)
   {
     // FIXME: mlc::same_grid<Pl, Pr>::check();
-    const Pl& lhs_ = lhs.force_exact_();
-    const Pr& rhs_ = rhs.force_exact_();
+    const Pl& lhs_ = internal::force_exact<Pl>(lhs);
+    const Pr& rhs_ = internal::force_exact<Pr>(rhs);
     for (unsigned i = 0; i < Pl::dim; ++i)
       {
 	if (lhs_[i] = rhs_[i])
@@ -262,8 +263,8 @@
     mlc::equal<mln_dpoint(Pl), mln_dpoint(Pr)>::check();
     // FIXME: mlc::same_grid<Pl, Pr>::check();
     mlc::same_coord<Pl, Pr>::check();
-    const Pl& lhs_ = lhs.force_exact_();
-    const Pr& rhs_ = rhs.force_exact_();
+    const Pl& lhs_ = internal::force_exact<Pl>(lhs);
+    const Pr& rhs_ = internal::force_exact<Pr>(rhs);
     mln_dpoint(Pl) tmp;
     for (unsigned i = 0; i < Pl::dim; ++i)
       tmp[i] = lhs_[i] - rhs_[i];
@@ -275,7 +276,7 @@
   mln_point(P)
   operator+(const GenPoint<P>& lhs, const mln_dpoint(P)& rhs)
   {
-    const P& lhs_ = lhs.force_exact_();
+    const P& lhs_ = internal::force_exact<P>(lhs);
     mln_point(P) tmp;
     for (unsigned i = 0; i < P::dim; ++i)
       tmp[i] = lhs_[i] + rhs[i];
@@ -286,7 +287,7 @@
   mln_point(P)
   operator-(const GenPoint<P>& lhs, const mln_dpoint(P)& rhs)
   {
-    const P& lhs_ = lhs.force_exact_();
+    const P& lhs_ = internal::force_exact<P>(lhs);
     mln_point(P) tmp;
     for (unsigned i = 0; i < P::dim; ++i)
       tmp[i] = lhs_[i] - rhs[i];
@@ -296,7 +297,7 @@
   template <typename P>
   std::ostream& operator<<(std::ostream& ostr, const GenPoint<P>& p)
   {
-    const P& p_ = p.force_exact_();
+    const P& p_ = internal::force_exact<P>(p);
 
     ostr << '(';
     for (unsigned i = 0; i < P::dim; ++i)
Index: mln/core/concept/genpixel.hh
--- mln/core/concept/genpixel.hh	(revision 0)
+++ mln/core/concept/genpixel.hh	(revision 0)
@@ -0,0 +1,126 @@
+// 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_GENPIXEL_HH
+# define MLN_CORE_CONCEPT_GENPIXEL_HH
+
+/*! \file mln/core/concept/genpixel.hh
+ * \brief Definition of the concept of mln::Genpixel.
+ */
+
+# include <mln/core/concept/object.hh>
+
+# include <mln/core/macros.hh>
+# include <mln/core/contract.hh>
+# include <mln/core/internal/force_exact.hh>
+
+
+namespace mln
+{
+
+  // FIXME: \class GenPixel GenPixel.hh "mln/core/concept/doc/GenPixel.hh"
+
+  /*! \brief Base class for implementation classes that are pixels or that
+   *  have the behavior of pixels.
+   *
+   * "GenPixel" is "Generalized Pixel" for short.
+   *
+   * \warning This class does \em not derive from mln::Object; it is
+   * for use as a parallel hierarchy.
+   * 
+   * \see mln::doc::GenPixel for a complete documentation of this
+   * class contents.
+   */
+  template <typename E>
+  struct GenPixel
+  {
+
+    /*
+      typedef image; // not const!
+      typedef psite;
+      typedef rvalue;
+
+      const image& image() const;
+      const psite& psite() const; // FIXME ou cpy
+
+      rvalue operator*() const;
+
+      const value* address() const;
+    */
+
+  protected:
+    GenPixel();
+
+  };
+
+  /*! \brief Print a generalized pixel \p p into the output stream \p
+   *  ostr.
+   *
+   * \param[in,out] ostr An output stream.
+   * \param[in] p A generalized pixel.
+   *
+   * \return The modified output stream \p ostr.
+   *
+   * \relates mln::GenPixel
+   */
+  template <typename P>
+  std::ostream& operator<<(std::ostream& ostr, const GenPixel<P>& p);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+  template <typename E>
+  GenPixel<E>::GenPixel()
+  {
+    // FIXME
+//     int dim = E::dim;
+//     mln_invariant(dim > 0);
+//     dim = 0;
+//     typedef  mln_point(E)  point;
+//     typedef mln_dpoint(E) dpoint;
+//     typedef mln_coord(E)  coord;
+//     const point* (E::*m1)() const = & E::pointer;
+//     m1 = 0;
+//     coord (E::*m2)(unsigned i) const = & E::operator[];
+//     m2 = 0;
+  }
+
+
+  template <typename P>
+  std::ostream& operator<<(std::ostream& ostr, const GenPixel<P>& pxl)
+  {
+    return ostr << pxl.psite() << '@' << & pxl.image();
+  }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_CONCEPT_GENPIXEL_HH
Index: mln/core/internal/force_exact.hh
--- mln/core/internal/force_exact.hh	(revision 1010)
+++ mln/core/internal/force_exact.hh	(working copy)
@@ -30,11 +30,20 @@
 
 /*! \file mln/core/internal/force_exact.hh
  *
- * \brief Definition of a macro for internal use only.
+ * \brief Definition of a violent cast for internal use only.
+ *
+ * \internal
  */
 
 
-/*! \brief Macro to add a violent exact cast method.
+
+namespace mln
+{
+
+  namespace internal
+  {
+
+    /*! \brief Violent cast.
  *
  * \internal
  *
@@ -45,18 +54,28 @@
  *
  * \see mln::exact
  */ 
-
-# define mln_internal_add_force_exact_(Type)		\
-							\
-    E& force_exact_() const				\
-    {							\
-	static const E* exact_obj;			\
-	static const Type& exact_obj_ref = *exact_obj;	\
-	static const int exact_offset =			\
-            (const char*)(void*)(&exact_obj_ref)	\
-	  - (const char*)(void*)( exact_obj);		\
-      return *(E*)((char*)(this) - exact_offset);	\
+    template <typename E, typename T>
+    E& force_exact(const T& ref)
+    {
+      /*
+	static const E exact_obj;
+	static const Type& exact_obj_ref = exact_obj;
+	static const int exact_offset +	(const char*)(void*)(&exact_obj_ref)
+	- (const char*)(void*)(&exact_obj);
+	return *(E*)((char*)(this_) - exact_offset);
+      */
+      static const E* exact_obj;
+      static const T& exact_obj_ref = *exact_obj;
+      static const int exact_offset +	(const char*)(void*)(&exact_obj_ref)
+	- (const char*)(void*)( exact_obj);
+      return *(E*)((char*)(&ref) - exact_offset);
     }
 
+  } // end of namespace mln::internal
+
+} // end of namespace mln
+
 
 #endif // ! MLN_CORE_INTERNAL_FORCE_EXACT_HH
Index: mln/core/internal/coord_impl.hh
--- mln/core/internal/coord_impl.hh	(revision 1010)
+++ mln/core/internal/coord_impl.hh	(working copy)
@@ -44,13 +44,6 @@
   namespace internal
   {
 
-    template <typename E>
-    struct coord_impl_base_
-    {
-      mln_internal_add_force_exact_(coord_impl_base_<E>)
-    };
-
-
     // coord_impl
 
     /*! \brief Implementation class to equip generalized points with
@@ -63,7 +56,6 @@
 
     template <typename C, typename E>
     struct coord_impl_<1, C, E>
-      : coord_impl_base_<E>
     {
       C ind() const;
     private:
@@ -73,7 +65,6 @@
 
     template <typename C, typename E>
     struct coord_impl_<2, C, E>
-      : coord_impl_base_<E>
     {
       C row() const;
       C col() const;
@@ -81,7 +72,6 @@
 
     template <typename C, typename E>
     struct coord_impl_<3, C, E>
-      : coord_impl_base_<E>
     {
       C sli() const;
       C row() const;
@@ -96,7 +86,6 @@
 
     template <typename C, typename E>
     struct mutable_coord_impl_<1, C, E>
-      : coord_impl_base_<E>
     {
       C  ind() const;
       C& ind();
@@ -104,7 +93,6 @@
 
     template <typename C, typename E>
     struct mutable_coord_impl_<2, C, E>
-      : coord_impl_base_<E>
     {
       C  row() const;
       C& row();
@@ -114,7 +102,6 @@
 
     template <typename C, typename E>
     struct mutable_coord_impl_<3, C, E>
-      : coord_impl_base_<E>
     {
       C  sli() const;
       C& sli();
@@ -134,7 +121,7 @@
     template <typename C, typename E>
     C coord_impl_<1, C, E>::ind() const
     {
-      return this->force_exact_()[0];
+      return internal::force_exact<E>(*this)[0];
     }
 
     // 2
@@ -142,13 +129,13 @@
     template <typename C, typename E>
     C coord_impl_<2, C, E>::row() const
     {
-      return this->force_exact_()[0];
+      return internal::force_exact<E>(*this)[0];
     }
 
     template <typename C, typename E>
     C coord_impl_<2, C, E>::col() const
     {
-      return this->force_exact_()[1];
+      return internal::force_exact<E>(*this)[1];
     }
 
     // 3
@@ -156,19 +143,19 @@
     template <typename C, typename E>
     C coord_impl_<3, C, E>::sli() const
     {
-      return this->force_exact_()[0];
+      return internal::force_exact<E>(*this)[0];
     }
 
     template <typename C, typename E>
     C coord_impl_<3, C, E>::row() const
     {
-      return this->force_exact_()[1];
+      return internal::force_exact<E>(*this)[1];
     }
 
     template <typename C, typename E>
     C coord_impl_<3, C, E>::col() const
     {
-      return this->force_exact_()[2];
+      return internal::force_exact<E>(*this)[2];
     }
 
 
@@ -179,13 +166,13 @@
     template <typename C, typename E>
     C  mutable_coord_impl_<1, C, E>::ind() const
     {
-      return this->force_exact_()[0];
+      return internal::force_exact<E>(*this)[0];
     }
 
     template <typename C, typename E>
     C& mutable_coord_impl_<1, C, E>::ind()
     {
-      return this->force_exact_()[0];
+      return internal::force_exact<E>(*this)[0];
     }
 
     // 2
@@ -193,25 +180,25 @@
     template <typename C, typename E>
     C  mutable_coord_impl_<2, C, E>::row() const
     {
-      return this->force_exact_()[0];
+      return internal::force_exact<E>(*this)[0];
     }
 
     template <typename C, typename E>
     C& mutable_coord_impl_<2, C, E>::row()
     {
-      return this->force_exact_()[0];
+      return internal::force_exact<E>(*this)[0];
     }
 
     template <typename C, typename E>
     C  mutable_coord_impl_<2, C, E>::col() const
     {
-      return this->force_exact_()[1];
+      return internal::force_exact<E>(*this)[1];
     }
 
     template <typename C, typename E>
     C& mutable_coord_impl_<2, C, E>::col()
     {
-      return this->force_exact_()[1];
+      return internal::force_exact<E>(*this)[1];
     }
 
     // 3
@@ -219,37 +206,37 @@
     template <typename C, typename E>
     C  mutable_coord_impl_<3, C, E>::sli() const
     {
-      return this->force_exact_()[0];
+      return internal::force_exact<E>(*this)[0];
     }
 
     template <typename C, typename E>
     C& mutable_coord_impl_<3, C, E>::sli()
     {
-      return this->force_exact_()[0];
+      return internal::force_exact<E>(*this)[0];
     }
 
     template <typename C, typename E>
     C  mutable_coord_impl_<3, C, E>::row() const
     {
-      return this->force_exact_()[1];
+      return internal::force_exact<E>(*this)[1];
     }
 
     template <typename C, typename E>
     C& mutable_coord_impl_<3, C, E>::row()
     {
-      return this->force_exact_()[1];
+      return internal::force_exact<E>(*this)[1];
     }
 
     template <typename C, typename E>
     C  mutable_coord_impl_<3, C, E>::col() const
     {
-      return this->force_exact_()[2];
+      return internal::force_exact<E>(*this)[2];
     }
 
     template <typename C, typename E>
     C& mutable_coord_impl_<3, C, E>::col()
     {
-      return this->force_exact_()[2];
+      return internal::force_exact<E>(*this)[2];
     }
 
 # endif // ! MLN_INCLUDE_ONLY
Index: mln/core/internal/box_impl.hh
--- mln/core/internal/box_impl.hh	(revision 1010)
+++ mln/core/internal/box_impl.hh	(working copy)
@@ -45,13 +45,6 @@
   namespace internal
   {
 
-    template <typename E>
-    struct box_impl_base_
-    {
-      mln_internal_add_force_exact_(box_impl_base_<E>)
-    };
-
-
     // box_impl
 
     /*! \brief Implementation class to equip objects having a bounding
@@ -64,7 +57,6 @@
 
     template <typename C, typename E> // FIXME: Add an extra param to replace 'unsigned'.
     struct box_impl_<2, C, E>
-      : box_impl_base_<E>
     {
       /// Give the number of rows.
       unsigned nrows() const;
@@ -95,37 +87,37 @@
     template <typename C, typename E>
     unsigned box_impl_<2, C, E>::nrows() const
     {
-      return this->force_exact_().bbox().len(0);
+      return internal::force_exact<E>(*this).bbox().len(0);
     }
 
     template <typename C, typename E>
     C box_impl_<2, C, E>::min_row() const
     {
-      return this->force_exact_().bbox().pmin()[0];
+      return internal::force_exact<E>(*this).bbox().pmin()[0];
     }
 
     template <typename C, typename E>
     C box_impl_<2, C, E>::max_row() const
     {
-      return this->force_exact_().bbox().pmax()[0];
+      return internal::force_exact<E>(*this).bbox().pmax()[0];
     }
 
     template <typename C, typename E>
     unsigned box_impl_<2, C, E>::ncols() const
     {
-      return this->force_exact_().bbox().len(1);
+      return internal::force_exact<E>(*this).bbox().len(1);
     }
 
     template <typename C, typename E>
     C box_impl_<2, C, E>::min_col() const
     {
-      return this->force_exact_().bbox().pmin()[1];
+      return internal::force_exact<E>(*this).bbox().pmin()[1];
     }
 
     template <typename C, typename E>
     C box_impl_<2, C, E>::max_col() const
     {
-      return this->force_exact_().bbox().pmax()[1];
+      return internal::force_exact<E>(*this).bbox().pmax()[1];
     }
 
 # endif // ! MLN_INCLUDE_ONLY
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from  Thierry Geraud  <thierry.geraud(a)lrde.epita.fr>
	Add subset notion in milena.
	Add materials.
	* mln/convert/to_image.hh: New.
	* mln/convert/to_window.hh: New.
	* mln/estim: New.
	* mln/estim/count.hh: New.
	* mln/debug/format.hh: New.
	* mln/geom: New.
	* mln/geom/pmin_pmax.hh: New.
	* mln/geom/bbox.hh: New.
	* mln/core/psubset.hh: New.
	* mln/core/psubset_piter.hh: New.
	* mln/core/concept/function.hh: New.
	* mln/core/internal/piter_adaptor.hh: New.
	* mln/fun/chess.hh: New.
	Add some tests.
	* tests/safe_image.cc: New.
	* tests/to_image.cc: New.
	* tests/psubset.cc: New.
	* tests/println.cc: New.
	Several improvements.
	* mln/debug/println.hh: Use debug::format.
	* mln/core/box.hh (len): Move...
	* mln/core/concept/box.hh: ...here.
	* mln/core/point.hh (zero): Turn into var.
	(point_): Bound ctor arg f.
	* mln/core/dpoint.hh: Likewise.
	* mln/core/neighb.hh (dpoint): New typedef.
	* mln/core/concept/image.hh: Remove obsolete commentary.
	* mln/core/concept/iterator.hh
	(for_all_remaining): New macro.
	* mln/core/concept/point_set.hh (operator<<): New.
	* mln/core/concept/neighborhood.hh
	(dpoint): Make it appear in commentary.
	* mln/core/concept/doc/neighborhood.hh (dpoint): New.
	* mln/core/concept/doc/box.hh: Cosmetics.
	* mln/core/window.hh (b_): New attribute.
	Update.
	* mln/core/image2d_b.hh (bbox): Remove; redundant.
	(at): New couple of methods.
	Update.
	* mln/core/internal/image_adaptor.hh: Fix.
	* mln/core/internal/image_base.hh: Add preconditions.
	* mln/core/internal/set_of.hh: Add a todo entry.
	* mln/core/safe_image.hh: Help g++-2.95.
	* mln/fun/all.hh: Add inheritance.
	Change mk_<object> into make::<object>.
	* mln/make: New directory.
	* mln/core/dpoint2d.hh (mk_dpoint2d): Move to...
	* mln/make/dpoint2d.hh: this new file.
	(mk_dpoint2d): Rename as...
	(dpoint2d): ...this.
	* mln/core/window2d.hh (mk_window2d): Move to...
	* mln/make/window2d.hh: this new file.
	(mk_window2d): Rename as...
	(window2d): ...this.
	* mln/core/box2d.hh (mk_box2d): Move to...
	* mln/make/box2d.hh: this new file.
	(mk_box2d): Rename as...
	(box2d): ...this.
	* mln/core/point2d.hh (mk_point2d): Move to...
	* mln/make/point2d.hh: this new file.
	(mk_point2d): Rename as...
	(point2d): ...this.
	* tests/window2d.cc,
	* tests/pixter_dpoint2d.cc,
	* tests/box2d.cc,
	* tests/point2d.cc,
	* tests/dpoint2d.cc,
	* tests/main.cc,
	* mln/core/neighb2d.hh,
	* mln/debug/println.hh,
	* mln/core/rectangle2d.hh,
	* mln/core/pixter2d_b.hh,
	* mln/io/save_pgm.hh,
	* mln/io/load_pgm.hh: Update.
 mln/convert/to_image.hh              |  109 +++++++++++++++++++
 mln/convert/to_window.hh             |   73 +++++++++++++
 mln/core/box.hh                      |   13 --
 mln/core/box2d.hh                    |   43 -------
 mln/core/concept/box.hh              |   19 ++-
 mln/core/concept/doc/box.hh          |    4 
 mln/core/concept/doc/neighborhood.hh |    3 
 mln/core/concept/function.hh         |  135 ++++++++++++++++++++++++
 mln/core/concept/image.hh            |    2 
 mln/core/concept/iterator.hh         |    8 +
 mln/core/concept/neighborhood.hh     |    3 
 mln/core/concept/point_set.hh        |   27 ++++
 mln/core/dpoint.hh                   |   15 +-
 mln/core/dpoint2d.hh                 |   33 +----
 mln/core/image2d_b.hh                |   44 +++++--
 mln/core/internal/image_adaptor.hh   |    2 
 mln/core/internal/image_base.hh      |    3 
 mln/core/internal/piter_adaptor.hh   |  171 ++++++++++++++++++++++++++++++
 mln/core/internal/set_of.hh          |    2 
 mln/core/neighb.hh                   |    3 
 mln/core/neighb2d.hh                 |   16 +-
 mln/core/pixter2d_b.hh               |    4 
 mln/core/point.hh                    |   15 +-
 mln/core/point2d.hh                  |   16 --
 mln/core/psubset.hh                  |  194 +++++++++++++++++++++++++++++++++++
 mln/core/psubset_piter.hh            |  118 +++++++++++++++++++++
 mln/core/rectangle2d.hh              |    2 
 mln/core/safe_image.hh               |   10 +
 mln/core/window.hh                   |   10 +
 mln/core/window2d.hh                 |   32 -----
 mln/debug/format.hh                  |   92 ++++++++++++++++
 mln/debug/println.hh                 |   20 ++-
 mln/estim/count.hh                   |   86 +++++++++++++++
 mln/fun/all.hh                       |    6 -
 mln/fun/chess.hh                     |   71 ++++++++++++
 mln/geom/bbox.hh                     |  113 ++++++++++++++++++++
 mln/geom/pmin_pmax.hh                |   90 ++++++++++++++++
 mln/io/load_pgm.hh                   |    2 
 mln/io/save_pgm.hh                   |    2 
 mln/make/box2d.hh                    |  101 ++++++++++++++++++
 mln/make/dpoint2d.hh                 |   72 ++++++++++++
 mln/make/point2d.hh                  |   72 ++++++++++++
 mln/make/window2d.hh                 |   82 ++++++++++++++
 tests/box2d.cc                       |    2 
 tests/dpoint2d.cc                    |    6 -
 tests/main.cc                        |    4 
 tests/pixter_dpoint2d.cc             |    8 -
 tests/point2d.cc                     |    2 
 tests/println.cc                     |   46 ++++++++
 tests/psubset.cc                     |   45 ++++++++
 tests/safe_image.cc                  |   47 ++++++++
 tests/to_image.cc                    |   65 +++++++++++
 tests/window2d.cc                    |    9 +
 53 files changed, 1974 insertions(+), 198 deletions(-)
Index: tests/window2d.cc
--- tests/window2d.cc	(revision 1009)
+++ tests/window2d.cc	(working copy)
@@ -31,6 +31,9 @@
  */
 
 #include <mln/core/window2d.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/convert/to_image.hh>
+#include <mln/debug/println.hh>
 
 
 
@@ -41,5 +44,9 @@
   window2d w;
   mln_assertion(w.is_centered() = false);
   mln_assertion(w.is_symmetric() = true);
-}
 
+  w.insert(make::dpoint2d(-1,-1));
+  w.insert(make::dpoint2d( 1, 1));
+  image2d_b<bool> ima = convert::to_image(w);
+  debug::println(ima);
+}
Index: tests/pixter_dpoint2d.cc
--- tests/pixter_dpoint2d.cc	(revision 1009)
+++ tests/pixter_dpoint2d.cc	(working copy)
@@ -17,10 +17,10 @@
   I::piter f(ima.domain());
   window_<I::dpoint> set;
 
-  set.insert(mk_dpoint2d(0, -1));
-  set.insert(mk_dpoint2d(0, -1));
-  set.insert(mk_dpoint2d(1, 0));
-  set.insert(mk_dpoint2d(1, 0));
+  set.insert(make::dpoint2d(0, -1));
+  set.insert(make::dpoint2d(0, -1));
+  set.insert(make::dpoint2d(1, 0));
+  set.insert(make::dpoint2d(1, 0));
 
   for_all(f)
   {
Index: tests/box2d.cc
--- tests/box2d.cc	(revision 1009)
+++ tests/box2d.cc	(working copy)
@@ -38,5 +38,5 @@
 {
   using namespace mln;
 
-  box2d b = mk_box2d(2, 3);
+  box2d b = make::box2d(2, 3);
 }
Index: tests/point2d.cc
--- tests/point2d.cc	(revision 1009)
+++ tests/point2d.cc	(working copy)
@@ -50,7 +50,7 @@
   mln_assertion(p.col() = 1 && p[1] = 1);
 
   // construction
-  q = mk_point2d(5, 1);
+  q = make::point2d(5, 1);
   mln_assertion(p = q);
   
   q.set_all(0);
Index: tests/safe_image.cc
--- tests/safe_image.cc	(revision 0)
+++ tests/safe_image.cc	(revision 0)
@@ -0,0 +1,47 @@
+// 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.
+
+/*! \file tests/safe_image.cc
+ *
+ * \brief Tests on mln::safe_image.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/core/safe_image.hh>
+
+
+int main()
+{
+  using namespace mln;
+
+  typedef image2d_b<int> I;
+  I ima(1, 1);
+  safe_image<I> ima_ = safe(ima);
+
+  point2d p = make::point2d(-5, -1);
+  ima_(p) = 0;
+}
Index: tests/dpoint2d.cc
--- tests/dpoint2d.cc	(revision 1009)
+++ tests/dpoint2d.cc	(working copy)
@@ -41,9 +41,9 @@
   point2d p, q;
   dpoint2d dp;
 
-  p  =  mk_point2d(1, 2);
-  q  =  mk_point2d(4, 7);
-  dp = mk_dpoint2d(3, 5);
+   p =  make::point2d(1, 2);
+   q =  make::point2d(4, 7);
+  dp = make::dpoint2d(3, 5);
 
   mln_assertion(dp = q - p);
   mln_assertion(q = p + dp);
Index: tests/to_image.cc
--- tests/to_image.cc	(revision 0)
+++ tests/to_image.cc	(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.
+
+/*! \file tests/to_image.cc
+ *
+ * \brief Tests on mln::convert::to_image.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/core/window2d.hh>
+#include <mln/core/psubset.hh>
+#include <mln/fun/chess.hh>
+#include <mln/level/compare.hh>
+
+#include <mln/convert/to_image.hh>
+
+
+#include <mln/debug/println.hh>
+
+
+
+int main()
+{
+  using namespace mln;
+
+  box2d box_3x3 = make::box2d(-1,+1, -1,+1);
+  //                          ^^^^^  ^^^^^
+  //                          rows   cols
+
+  //         center point
+  //              V
+  bool X[] = { 1, 0, 1,
+	       0, 1, 0,   // < center point
+	       1, 0, 1 };
+
+  image2d_b<bool> ima_X = convert::to_image(box_3x3 | fun::chess);
+  window2d win_X = make::window2d(X);
+  mln_assertion(convert::to_image(win_X) = ima_X);
+
+  // FIXME: nbh!
+}
Index: tests/main.cc
--- tests/main.cc	(revision 1009)
+++ tests/main.cc	(working copy)
@@ -60,7 +60,7 @@
 
 
 
-//   box2d b = mk_box2d(/* row = */ 1, 3,
+//   box2d b = make::box2d(/* row = */ 1, 3,
 // 		     /* col = */ 4, 6);
 //   std::cout << b << std::endl;
 
@@ -68,7 +68,7 @@
 //     { 0, 1, 0,
 //       0, 1, 0,
 //       1, 0, 0 };
-//   window2d win = mk_window2d(w);
+//   window2d win = make::window2d(w);
 //   std::cout << win << std::endl;
 //   std::cout << c8() << std::endl;
 
Index: tests/psubset.cc
--- tests/psubset.cc	(revision 0)
+++ tests/psubset.cc	(revision 0)
@@ -0,0 +1,45 @@
+// 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.
+
+/*! \file tests/psubset.cc
+ *
+ * \brief Tests on mln::psubset.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/core/psubset.hh>
+#include <mln/fun/chess.hh>
+#include <mln/convert/to_image.hh>
+
+
+int main()
+{
+  using namespace mln;
+
+  box2d box_8x8 = make::box2d(8, 8);
+  mln_assertion((box_8x8 | fun::chess).npoints() = 32);
+}
Index: tests/println.cc
--- tests/println.cc	(revision 0)
+++ tests/println.cc	(revision 0)
@@ -0,0 +1,46 @@
+// 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.
+
+/*! \file tests/println.cc
+ *
+ * \brief Test on mln::debug::println.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/level/fill.hh>
+#include <mln/debug/println.hh>
+
+
+using namespace mln;
+
+
+int main()
+{
+  image2d_b<bool> msk(3, 3);
+  msk.at(1, 1) = true;
+  debug::println(msk);
+}
Index: mln/convert/to_image.hh
--- mln/convert/to_image.hh	(revision 0)
+++ mln/convert/to_image.hh	(revision 0)
@@ -0,0 +1,109 @@
+// 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_CONVERT_TO_IMAGE_HH
+# define MLN_CONVERT_TO_IMAGE_HH
+
+/*! \file mln/convert/to_image.hh
+ *
+ * \brief Convertions to mln::Image.
+ */
+
+# include <mln/core/image2d_b.hh>
+
+# include <mln/core/concept/point_set.hh>
+# include <mln/core/concept/window.hh>
+# include <mln/core/concept/neighborhood.hh>
+
+# include <mln/convert/to_window.hh>
+# include <mln/geom/bbox.hh>
+# include <mln/level/fill.hh>
+
+
+namespace mln
+{
+
+  namespace convert
+  {
+
+    /// Convert a point set \p pset into a binary image.
+    template <typename S>
+    image2d_b<bool> to_image(const Point_Set<S>& pset);
+
+    /// Convert a window \p win into a binary image.
+    template <typename W>
+    image2d_b<bool> to_image(const Window<W>& win);
+
+    /// Convert a neighborhood \p nbh into a binary image.
+    template <typename N>
+    image2d_b<bool> to_image(const Neighborhood<N>& nbh);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    template <typename S>
+    image2d_b<bool> to_image(const Point_Set<S>& pset_)
+    {
+      const S& pset = exact(pset_);
+      image2d_b<bool> ima(pset.bbox());
+      level::fill(ima, false);
+      mln_piter(S) p(pset);
+      for_all(p)
+	ima(p) = true;
+      return ima;
+    }
+
+    template <typename W>
+    image2d_b<bool> to_image(const Window<W>& win_)
+    {
+      const W& win = exact(win_);
+      mln_precondition(! win.is_empty());
+
+      typedef mln_point(W) P;
+      box2d b = geom::bbox(win);
+      image2d_b<bool> ima(b);
+      level::fill(ima, false);
+      mln_qiter(W) q(win, P::zero);
+      for_all(q)
+	ima(q) = true;
+      return ima;
+    }
+
+    template <typename N>
+    image2d_b<bool> to_image(const Neighborhood<N>& nbh)
+    {
+      return to_image(convert::to_window(nbh));
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::convert
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CONVERT_TO_IMAGE_HH
Index: mln/convert/to_window.hh
--- mln/convert/to_window.hh	(revision 0)
+++ mln/convert/to_window.hh	(revision 0)
@@ -0,0 +1,73 @@
+// 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_CONVERT_TO_WINDOW_HH
+# define MLN_CONVERT_TO_WINDOW_HH
+
+/*! \file mln/convert/to_window.hh
+ *
+ * \brief Convertions to mln::Image.
+ */
+
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/window.hh>
+
+
+namespace mln
+{
+
+  namespace convert
+  {
+
+    /// Convert a neighborhood \p nbh into a window.
+    template <typename N>
+    window_<mln_dpoint(N)> to_window(const Neighborhood<N>& nbh);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    template <typename N>
+    window_<mln_dpoint(N)> to_window(const Neighborhood<N>& nbh_)
+    {
+      const N& nbh = exact(nbh_);
+      typedef mln_dpoint(N) D;
+      typedef mln_point(D) P;
+      window_<D> win;
+      mln_niter(N) n(nbh, P::zero);
+      for_all(n)
+	win.insert(n - P::zero);
+      return win;
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::convert
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CONVERT_TO_WINDOW_HH
Index: mln/estim/count.hh
--- mln/estim/count.hh	(revision 0)
+++ mln/estim/count.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_ESTIM_COUNT_HH
+# define MLN_ESTIM_COUNT_HH
+
+/*! \file mln/estim/count.hh
+ *
+ * \brief Several routines to count the number of points.
+ */
+
+
+namespace mln
+{
+
+  namespace estim
+  {
+
+
+    /// Compute the number FIXME minimum and maximum points when browsing with
+    /// iterator \p p.
+    template <typename S>
+    std::size_t count(const Point_Set<S>& pset);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    template <typename I>
+    std::pair<mln_point(I), mln_point(I)>
+    count(const Piter<I>& p_)
+    {
+      const I& p = exact(p_);
+
+      typedef mln_point(I) P;
+      std::pair<P, P> tmp;
+      P& pmin = tmp.first;
+      P& pmax = tmp.second;
+
+      // init with first point
+      p.start();
+      pmin = pmax = p;
+
+      // update with remaining points
+      for_all_remaining(p)
+	for (unsigned i = 0; i < P::dim; ++i)
+	  if (p[i] < pmin[i])
+	    pmin()[i] = p[i];
+	  else if (p[i] > pmax[i])
+	    pmax[i] = p[i];
+
+      return tmp;
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::estim
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ESTIM_COUNT_HH
Index: mln/debug/println.hh
--- mln/debug/println.hh	(revision 1009)
+++ mln/debug/println.hh	(working copy)
@@ -35,6 +35,8 @@
 
 # include <mln/core/concept/image.hh>
 # include <mln/core/concept/window.hh>
+# include <mln/debug/format.hh>
+
 # include <mln/core/box2d.hh>
 
 
@@ -54,24 +56,30 @@
     namespace impl
     {
 
+      // generic version
       template <typename S, typename I>
       void println(const S&, const Image<I>& input_)
       {
 	const I& input = exact(input_);
 	mln_piter(I) p(input.domain());
 	for_all(p)
-	  std::cout << input(p) << ' ';
+	  std::cout << format( input(p) ) << ' ';
 	std::cout << std::endl;
       }
 
+      // "domain = box2d" version
       template <typename I>
-      void println(const box2d& b,
-		   const I& input)
+      void println(const box2d& b, const I& input)
       {
-	for (int row = b.pmin().row(); row <= b.pmax().row(); ++row)
+	point2d p;
+	int& row = p.row();
+	int& col = p.col();
+	const int max_row = b.max_row(), max_col = b.max_col();
+
+	for (row = b.min_row(); row <= max_row; ++row)
 	  {
-	    for (int col = b.pmin().col(); col <= b.pmax().col(); ++col)
-	      std::cout << input(mk_point2d(row, col)) << ' ';
+	    for (col = b.min_col(); col <= max_col; ++col)
+	      std::cout << format( input(p) ) << ' ';
 	    std::cout << std::endl;
 	  }
 	std::cout << std::endl;
Index: mln/debug/format.hh
--- mln/debug/format.hh	(revision 0)
+++ mln/debug/format.hh	(revision 0)
@@ -0,0 +1,92 @@
+// 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_DEBUG_FORMAT_HH
+# define MLN_DEBUG_FORMAT_HH
+
+/*! \file mln/debug/format.hh
+ *
+ * \brief Routines that format a value to print it properly.
+ */
+
+
+namespace mln
+{
+
+  namespace debug
+  {
+
+    /// Default version for formatting a value is a no-op.
+    template <typename T>
+    const T& format(const T& v);
+
+    /// Format a Boolean to print it nicely: "|" for true and "-" for
+    /// false.
+    char format(bool v);
+
+    /// Format a signed char to print it properly, i.e., like an
+    /// integer value.
+    signed short format(signed char v);
+
+    /// Format an unsigned char to print it properly, i.e., like an
+    /// integer value.
+    unsigned short format(unsigned char v);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    template <typename T>
+    const T& format(const T& v)
+    {
+      return v;
+    }
+
+    char format(bool v)
+    {
+      return v ? '|' : '-';
+    }
+
+    signed short format(signed char v)
+    {
+      return v;
+    }
+
+    unsigned short format(unsigned char v)
+    {
+      return v;
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+  } // end of namespace mln::debug
+
+} // end of namespace mln
+
+
+#endif // ! MLN_DEBUG_FORMAT_HH
Index: mln/geom/pmin_pmax.hh
--- mln/geom/pmin_pmax.hh	(revision 0)
+++ mln/geom/pmin_pmax.hh	(revision 0)
@@ -0,0 +1,90 @@
+// 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_GEOM_PMIN_PMAX_HH
+# define MLN_GEOM_PMIN_PMAX_HH
+
+/*! \file mln/geom/pmin_pmax.hh
+ *
+ * \brief Several routines to compute the minimum point and/or maximum
+ * point.
+ */
+
+# include <utility>
+
+
+namespace mln
+{
+
+  namespace geom
+  {
+
+
+    /// Compute the minimum and maximum points when browsing with
+    /// iterator \p p.
+    template <typename I>
+    std::pair<mln_point(I), mln_point(I)>
+    pmin_pmax(const Piter<I>& p);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    template <typename I>
+    std::pair<mln_point(I), mln_point(I)>
+    pmin_pmax(Piter<I>& p_)
+    {
+      I& p = exact(p_);
+
+      typedef mln_point(I) P;
+      std::pair<P, P> tmp;
+      P& pmin = tmp.first;
+      P& pmax = tmp.second;
+
+      // init with first point
+      p.start();
+      pmin = pmax = p;
+
+      // update with remaining points
+      for_all_remaining(p)
+	for (unsigned i = 0; i < P::dim; ++i)
+	  if (p[i] < pmin[i])
+	    pmin[i] = p[i];
+	  else if (p[i] > pmax[i])
+	    pmax[i] = p[i];
+
+      return tmp;
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_PMIN_PMAX_HH
Index: mln/geom/bbox.hh
--- mln/geom/bbox.hh	(revision 0)
+++ mln/geom/bbox.hh	(revision 0)
@@ -0,0 +1,113 @@
+// 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_GEOM_BBOX_HH
+# define MLN_GEOM_BBOX_HH
+
+/*! \file mln/geom/bbox.hh
+ *
+ * \brief Several routines to compute the precise bounding box of some
+ * objects.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/point_set.hh>
+# include <mln/core/concept/window.hh>
+# include <mln/geom/pmin_pmax.hh>
+
+
+namespace mln
+{
+
+  namespace geom
+  {
+
+
+    /// Compute the precise bounding box of a window \p win centered
+    /// at the origin.
+    template <typename W>
+    box_<mln_point(W)> bbox(const Window<W>& win);
+
+
+    /// Compute the precise bounding box of a point set \p pset.
+    template <typename S>
+    box_<mln_point(S)> bbox(const Point_Set<S>& pset);
+
+
+    /// Compute the precise bounding box of an image \p ima.
+    template <typename I>
+    box_<mln_point(I)> bbox(const Image<I>& ima);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    template <typename W>
+    box_<mln_point(W)> bbox(const Window<W>& win_)
+    {
+      const W& win = exact(win_);
+      mln_precondition(! win.is_empty());
+
+      typedef mln_point(W) P;
+      mln_qiter(W) q(win, P::zero);
+      std::pair<P, P> pp = geom::pmin_pmax(q);
+
+      box_<P> tmp(pp.first, pp.second);
+      return tmp;
+    }
+
+    template <typename S>
+    box_<mln_point(S)> bbox(const Point_Set<S>& pset_)
+    {
+      const S& pset = exact(pset_);
+      mln_precondition(pset.npoints() != 0);
+
+      typedef mln_point(S) P;
+      mln_piter(S) p(pset);
+      std::pair<P, P> pp = geom::pmin_pmax(p);
+
+      box_<P> tmp(pp.first, pp.second);
+      // FIXME: mln_postcondition(tmp <= pset.bbox());
+      return tmp;
+    }
+
+    template <typename I>
+    box_<mln_point(I)> bbox(const Image<I>& ima_)
+    {
+      const I& ima = exact(ima_);
+      mln_precondition(ima.has_data());
+      return bbox(ima.domain());
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_BBOX_HH
Index: mln/core/neighb2d.hh
--- mln/core/neighb2d.hh	(revision 1009)
+++ mln/core/neighb2d.hh	(working copy)
@@ -101,8 +101,8 @@
     static neighb2d it;
     if (flower)
       {
-	it.insert(mk_dpoint2d(0, 1));
-	it.insert(mk_dpoint2d(1, 0));
+	it.insert(make::dpoint2d(0, 1));
+	it.insert(make::dpoint2d(1, 0));
 	flower = false;
       }
     return it;
@@ -114,10 +114,10 @@
     static neighb2d it;
     if (flower)
       {
-	it.insert(mk_dpoint2d(0, 1));
-	it.insert(mk_dpoint2d(1,-1));
-	it.insert(mk_dpoint2d(1, 0));
-	it.insert(mk_dpoint2d(1, 1));
+	it.insert(make::dpoint2d(0, 1));
+	it.insert(make::dpoint2d(1,-1));
+	it.insert(make::dpoint2d(1, 0));
+	it.insert(make::dpoint2d(1, 1));
 	flower = false;
       }
     return it;
@@ -129,7 +129,7 @@
     static neighb2d it;
     if (flower)
       {
-	it.insert(mk_dpoint2d(0, 1));
+	it.insert(make::dpoint2d(0, 1));
 	flower = false;
       }
     return it;
@@ -141,7 +141,7 @@
     static neighb2d it;
     if (flower)
       {
-	it.insert(mk_dpoint2d(1, 0));
+	it.insert(make::dpoint2d(1, 0));
 	flower = false;
       }
     return it;
Index: mln/core/dpoint2d.hh
--- mln/core/dpoint2d.hh	(revision 1009)
+++ mln/core/dpoint2d.hh	(working copy)
@@ -46,38 +46,23 @@
   typedef dpoint_<2,int> dpoint2d;
 
 
-  /*! \brief Create an mln::dpoint2d.
-   *
-   * \param[in] row Index of row.
-   * \param[in] col Index of column.
-   *
-   * \return A 2D delta-point.
-   */
-  dpoint2d mk_dpoint2d(int row, int col);
-
+} // end of namespace mln
 
-  const dpoint2d up    = mk_dpoint2d( -1,  0 );
-  const dpoint2d down  = mk_dpoint2d( +1,  0 );
-  const dpoint2d left  = mk_dpoint2d(  0, -1 );
-  const dpoint2d right = mk_dpoint2d(  0, +1 );
 
+# include <mln/make/dpoint2d.hh>
+# include <mln/core/point2d.hh>
 
-# ifndef MLN_INCLUDE_ONLY
 
-  dpoint2d mk_dpoint2d(int row, int col)
+namespace mln
   {
-    dpoint2d tmp;
-    tmp[0] = row;
-    tmp[1] = col;
-    return tmp;
-  }
 
-# endif // ! MLN_INCLUDE_ONLY
+  // FIXME: Doc!
+  const dpoint2d up    = make::dpoint2d( -1,  0 );
+  const dpoint2d down  = make::dpoint2d( +1,  0 );
+  const dpoint2d left  = make::dpoint2d(  0, -1 );
+  const dpoint2d right = make::dpoint2d(  0, +1 );
 
 } // end of namespace mln
 
 
-# include <mln/core/point2d.hh>
-
-
 #endif // ! MLN_CORE_DPOINT2D_HH
Index: mln/core/psubset.hh
--- mln/core/psubset.hh	(revision 0)
+++ mln/core/psubset.hh	(revision 0)
@@ -0,0 +1,194 @@
+// 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_PSUBSET_HH
+# define MLN_CORE_PSUBSET_HH
+
+/*! \file mln/core/psubset.hh
+ *
+ * \brief This file defines a generic class for subset of point set.
+ */
+
+# include <mln/core/concept/point_set.hh>
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+  // Fwd decls.
+  template <typename S, typename F> struct psubset;
+  template <typename S, typename F> struct psubset_fwd_piter_;
+  template <typename S, typename F> struct psubset_bkd_piter_;
+
+
+
+  /*! \brief Restrict a point set \p pset to points that verify \p f.
+   *
+   * \param[in] pset A point set.
+   * \param[in] f A function from point to Boolean.
+   * \return A subset of points.
+   */
+  template <typename S, typename F>
+  psubset<S, F>
+  operator | (const Point_Set<S>& pset, const Function_p2b<F>& f);
+
+
+
+  /*! \brief Generic subset class.
+   *
+   * Parameter \c S is a point set type; parameter F is a function
+   * from point to Boolean.
+   */
+  template <typename S, typename F>
+  struct psubset : public Point_Set< psubset<S,F> >
+  {
+    /// Psite associated type.
+    typedef mln_psite(S) psite;
+
+    /// Point associated type.
+    typedef mln_point(S) point;
+
+    
+    /// Forward Piter associated type.
+    typedef psubset_fwd_piter_<S,F> fwd_piter;
+
+    /// Backward Piter associated type.
+    typedef psubset_fwd_piter_<S,F> bkd_piter; // FIXME: bkd!!!
+
+    /// Piter associated type.
+    typedef fwd_piter piter;
+
+
+    /// Constructor without argument.
+    psubset(const S& pset, const F& f);
+
+
+    /// Test if \p p belongs to the subset. 
+    bool has(const psite& p) const;
+
+    /// Give a bounding box of the subset. 
+    const box_<point>& bbox() const;
+
+    /// Give the number of points of the subset.
+    std::size_t npoints() const;
+
+    /// Give the primary overset.
+    const S& overset() const;
+
+    /// Test predicate on point site \p p.
+    bool pred(const psite& p) const;
+
+  protected:
+
+    const S& pset_;
+    F f_;
+  };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+  template <typename S, typename F>
+  psubset<S, F>
+  operator | (const Point_Set<S>& pset, const Function_p2b<F>& f)
+  {
+    psubset<S, F> tmp(exact(pset), exact(f));
+    return tmp;
+  }
+
+
+  // psubset<S,F>
+
+  template <typename S, typename F>
+  bool
+  psubset<S,F>::has(const psite& p) const
+  {
+    return pset_.has(p) && f_(p);
+  }
+
+  template <typename S, typename F>
+  const box_<mln_point(S)>&
+  psubset<S,F>::bbox() const
+  {
+    return pset_.bbox();
+  }
+
+  template <typename S, typename F>
+  const S&
+  psubset<S,F>::overset() const
+  {
+    return pset_;
+  }
+
+  template <typename S, typename F>
+  bool
+  psubset<S,F>::pred(const psite& p) const
+  {
+    return f_(p);
+  }
+  
+  template <typename S, typename F>
+  psubset<S,F>::psubset(const S& pset, const F& f)
+    : pset_(pset),
+      f_(f)
+  {
+  }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+
+# include <mln/core/psubset_piter.hh>
+
+
+
+namespace mln
+{
+
+# ifndef MLN_INCLUDE_ONLY
+
+  template <typename S, typename F>
+  std::size_t
+  psubset<S,F>::npoints() const
+  {
+    std::size_t n = 0;
+    piter p(*this);
+    for_all(p)
+      ++n;
+    return n;
+  }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_PSUBSET_HH
Index: mln/core/psubset_piter.hh
--- mln/core/psubset_piter.hh	(revision 0)
+++ mln/core/psubset_piter.hh	(revision 0)
@@ -0,0 +1,118 @@
+// 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_PSUBSET_PITER_HH
+# define MLN_CORE_PSUBSET_PITER_HH
+
+/*! \file mln/core/psubset_piter.hh
+ *
+ * \brief Definition of iterators on points of psubsetes.
+ */
+
+# include <mln/core/concept/piter.hh>
+# include <mln/core/internal/piter_adaptor.hh>
+# include <mln/core/psubset.hh>
+
+
+namespace mln
+{
+
+  /*! \brief A generic forward iterator on points of subsets.
+   *
+   * Parameter \c S is a point set type; parameter F is a function
+   * from point to Boolean.
+   *
+   * \see mln::psubset
+   */
+  template <typename S, typename F>
+  class psubset_fwd_piter_ : public internal::piter_adaptor_< mln_fwd_piter(S),
+							      psubset_fwd_piter_<S,F> >
+  {
+    typedef mln_fwd_piter(S) adaptee_;
+    typedef psubset_fwd_piter_<S,F> self_;
+    typedef internal::piter_adaptor_<adaptee_, self_> super_;
+
+  public:
+
+    /// Constructor from a subset of points.
+    psubset_fwd_piter_(const psubset<S,F>& subset);
+
+    /// Start an iteration.
+    void start();
+
+    /// Go to the next point.
+    void next_();
+
+  private:
+
+    const psubset<S,F>& subset_;
+  };
+
+  // FIXME: psubset_bkd_piter_<S,F>
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+  // psubset_fwd_piter_<S,F>
+
+  template <typename S, typename F>
+  psubset_fwd_piter_<S,F>::psubset_fwd_piter_(const psubset<S,F>& subset)
+    : super_(adaptee_(subset.overset())),
+      subset_(subset)
+  {
+  }
+
+  template <typename S, typename F>
+  void
+  psubset_fwd_piter_<S,F>::start()
+  {
+    this->piter_.start();
+    while (this->piter_.is_valid() && ! subset_.pred(this->piter_))
+      this->piter_.next();
+  }
+
+  template <typename S, typename F>
+  void
+  psubset_fwd_piter_<S,F>::next_()
+  {
+    do
+      this->piter_.next();
+    while (this->piter_.is_valid() && ! subset_.pred(this->piter_));
+  }
+  
+
+  // FIXME: psubset_bkd_piter_<S,F>
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_PSUBSET_PITER_HH
Index: mln/core/box.hh
--- mln/core/box.hh	(revision 1009)
+++ mln/core/box.hh	(working copy)
@@ -90,11 +90,6 @@
      */
     P& pmax();
 
-    /*! \brief Give the length of the \p i-th side.
-     * \pre i < dim
-     */
-    unsigned len(unsigned i) const;
-
     /*! \brief Constructor without argument.
      */
     box_();
@@ -158,14 +153,6 @@
   }
 
   template <typename P>
-  unsigned
-  box_<P>::len(unsigned i) const
-  {
-    mln_precondition(i < P::dim);
-    return 1 + pmax_[i] - pmin_[i];    
-  }
-
-  template <typename P>
   box_<P>::box_()
   {
   }
Index: mln/core/point.hh
--- mln/core/point.hh	(revision 1009)
+++ mln/core/point.hh	(working copy)
@@ -87,14 +87,14 @@
     /*! \brief Constructor; coordinates are set by function \p f.
      */
     template <typename F>
-    point_(F f);
+    point_(const Function<F>& f);
 
     /*! \brief Set all coordinates to the value \p c.
      */
     void set_all(C c);
 
-    /// Give the origin (all coordinates are 0).
-    static const point_<n,C>& zero();
+    /// Origin point (all coordinates are 0).
+    static const point_<n,C> zero;
 
   protected:
     C coord_[n];
@@ -124,8 +124,9 @@
 
   template <unsigned n, typename C>
   template <typename F>
-  point_<n,C>::point_(F f)
+  point_<n,C>::point_(const Function<F>& f_)
   {
+    const F& f = exact(f_);
     for (unsigned i = 0; i < n; ++i)
       coord_[i] = f(i);
   }
@@ -138,11 +139,7 @@
   }
 
   template <unsigned n, typename C>
-  const point_<n,C>& point_<n,C>::zero()
-  {
-    static const point_<n,C> zero_(all(0));
-    return zero_;
-  }
+  const point_<n,C> point_<n,C>::zero = all(0);
 
 # endif // ! MLN_INCLUDE_ONLY
   
Index: mln/core/rectangle2d.hh
--- mln/core/rectangle2d.hh	(revision 1009)
+++ mln/core/rectangle2d.hh	(working copy)
@@ -139,7 +139,7 @@
     const int drow = half_height, dcol = half_width;
     for (int row = - drow; row <= drow; ++row)
       for (int col = - dcol; col <= dcol; ++col)
-	insert(mk_dpoint2d(row, col));
+	insert(make::dpoint2d(row, col));
   }
 
   bool rectangle2d::is_centered() const
Index: mln/core/neighb.hh
--- mln/core/neighb.hh	(revision 1009)
+++ mln/core/neighb.hh	(working copy)
@@ -55,6 +55,9 @@
   struct neighb_ : public Neighborhood< neighb_<D> >,
 		   public internal::set_of_<D>
   {
+    /// Dpoint associated type.
+    typedef D dpoint;
+
     /*! \brief Piter type to browse the points of a generic
      * neighborhood w.r.t. the ordering of delta-points.
      */
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh	(revision 1009)
+++ mln/core/concept/image.hh	(working copy)
@@ -55,7 +55,7 @@
 
       bool has_data() const;
 
-      bool owns_(const psite& p) const; // default is like "has(p)"
+      bool owns_(const psite& p) const;
       const pset& domain() const;
 
       rvalue operator()(const psite& p) const;
Index: mln/core/concept/function.hh
--- mln/core/concept/function.hh	(revision 0)
+++ mln/core/concept/function.hh	(revision 0)
@@ -0,0 +1,135 @@
+// 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_FUNCTION_HH
+# define MLN_CORE_CONCEPT_FUNCTION_HH
+
+/*! \file mln/core/concept/function.hh
+ *
+ * \brief Definition of several concepts of functions.
+ */
+
+# include <mln/core/concept/object.hh>
+
+
+namespace mln
+{
+
+
+  /*! \brief Base class for implementation of function-objects.
+   *
+   * The parameter \a E is the exact type.
+   */
+  template <typename E>
+  struct Function : public Object<E>
+  {
+    /*
+      An operator() has to be provided.  Its signature depends
+      on the particular function-object one considers.
+     */
+  protected:
+    Function();
+  };
+
+
+  // Value -> Value.
+
+  /// Base class for implementation of function-objects from value to
+  /// value.
+  template <typename E>
+  struct Function_v2v : public Function<E>
+  {
+  protected:
+    Function_v2v();
+  };
+
+
+  // Point -> Value.
+
+  /// Base class for implementation of function-objects from point to
+  /// value.
+  template <typename E>
+  struct Function_p2v : public Function_v2v<E>
+  {
+  protected:
+    Function_p2v();
+  };
+
+
+  // Point -> bool.
+
+  /// Base class for implementation of function-objects from point to
+  /// bool.
+  template <typename E>
+  struct Function_p2b : public Function_p2v<E>
+  {
+  protected:
+    Function_p2b();
+  };
+
+
+  // Point -> Point.
+
+  /// Base class for implementation of function-objects from point to
+  /// point.
+  template <typename E>
+  struct Function_p2p : public Function_p2v<E>
+  {
+  protected:
+    Function_p2p();
+  };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+  template <typename E>
+  Function<E>::Function()
+  {
+  }
+
+  template <typename E>
+  Function_v2v<E>::Function_v2v()
+  {
+  }
+
+  template <typename E>
+  Function_p2v<E>::Function_p2v()
+  {
+  }
+
+  template <typename E>
+  Function_p2b<E>::Function_p2b()
+  {
+  }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_CONCEPT_FUNCTION_HH
Index: mln/core/concept/box.hh
--- mln/core/concept/box.hh	(revision 1009)
+++ mln/core/concept/box.hh	(working copy)
@@ -52,10 +52,17 @@
     /*
       const point& pmin() const;
       const point& pmax() const;
-      unsigned len(unsigned i) const; // FIXME: Doc!
     */
 
-    /*! \brief Return the bounding box of this point set.
+    /*! \brief Give the length of the \p i-th side of the box.
+     *
+     * \pre i < point::dim
+     *
+     * \warning This method is final for all box classes.
+     */
+    unsigned len(unsigned i) const;
+
+    /*! \brief Give the bounding box of this point set.
      *
      * Return the bounding box of this point set, so that is itself.
      * This method is declared by the mln::Point_Set concept.
@@ -64,7 +71,7 @@
      */
     const E& bbox() const;
 
-    /*! \brief Return the number of points of this box.
+    /*! \brief Give the number of points of this box.
      *
      * Return the number of points of this box.  This method is
      * declared by the mln::Point_Set concept.
@@ -87,6 +94,12 @@
   }
 
   template <typename E>
+  unsigned Box<E>::len(unsigned i) const
+  {
+    return 1 + exact(this)->pmax()[i] - exact(this)->pmin()[i];
+  }
+
+  template <typename E>
   Box<E>::Box()
   {
     typedef mln_point(E) point;
Index: mln/core/concept/iterator.hh
--- mln/core/concept/iterator.hh	(revision 1009)
+++ mln/core/concept/iterator.hh	(working copy)
@@ -40,6 +40,14 @@
 # define for_all(x) for(x.start(); x.is_valid(); x.next())
 
 
+/*! \brief Loop to browse all the remaining elements targetted by the
+ * iterator \p x.
+ */
+# define for_all_remaining(x) \
+  if (! x.is_valid()) {} else while (x.next(), x.is_valid())
+
+
+
 namespace mln
 {
   /*! \brief Base class for implementation classes that are iterators.
Index: mln/core/concept/point_set.hh
--- mln/core/concept/point_set.hh	(revision 1009)
+++ mln/core/concept/point_set.hh	(working copy)
@@ -64,6 +64,20 @@
   };
 
 
+  /*! \brief Print a point set \p pset into the output stream \p
+   *  ostr.
+   *
+   * \param[in,out] ostr An output stream.
+   * \param[in] pset A point set.
+   *
+   * \return The modified output stream \p ostr.
+   *
+   * \relates mln::Point_Set
+   */
+  template <typename S>
+  std::ostream& operator<<(std::ostream& ostr, const Point_Set<S>& pset);
+
+
 # ifndef MLN_INCLUDE_ONLY
 
   // fwd decl
@@ -74,6 +88,7 @@
   {
     typedef mln_point(E) point;
     typedef mln_psite(E) psite;
+
     typedef mln_piter(E) piter;
     typedef mln_fwd_piter(E) fwd_piter;
     typedef mln_bkd_piter(E) bkd_piter;
@@ -86,6 +101,18 @@
     m3 = 0;
   }
 
+
+  template <typename S>
+  std::ostream& operator<<(std::ostream& ostr, const Point_Set<S>& pset_)
+  {
+    const S& pset = exact(pset_);
+    ostr << '{';
+    mln_piter(S) p(pset);
+    for_all(p)
+      ostr << p;
+    return ostr << '}';
+  }
+
 # endif // ! MLN_INCLUDE_ONLY
 
 } // end of namespace mln
Index: mln/core/concept/neighborhood.hh
--- mln/core/concept/neighborhood.hh	(revision 1009)
+++ mln/core/concept/neighborhood.hh	(working copy)
@@ -50,6 +50,8 @@
       typedef niter;
       typedef fwd_niter;
       typedef bkd_niter;
+
+      typedef dpoint;
     */
 
   protected:
@@ -65,6 +67,7 @@
     typedef mln_niter(E) niter;
     typedef mln_fwd_niter(E) fwd_niter;
     typedef mln_bkd_niter(E) bkd_niter;
+    typedef mln_dpoint(E) dpoint;
   }
 
 # endif // ! MLN_INCLUDE_ONLY
Index: mln/core/concept/doc/neighborhood.hh
--- mln/core/concept/doc/neighborhood.hh	(revision 1009)
+++ mln/core/concept/doc/neighborhood.hh	(working copy)
@@ -56,6 +56,9 @@
        * neighbors in a backward way.
        */
       typedef void bkd_niter;
+
+      /// Dpoint associated type.
+      typedef void dpoint;
     };
 
   } // end of namespace mln::doc
Index: mln/core/concept/doc/box.hh
--- mln/core/concept/doc/box.hh	(revision 1009)
+++ mln/core/concept/doc/box.hh	(working copy)
@@ -41,7 +41,7 @@
     template <typename E>
     struct Box : public Point_Set<E>
     {
-      /*! \brief Return the box "minimum" point.
+      /*! \brief Give the box "minimum" point.
        *
        * Return the "minimum" point w.r.t. the ordering between points.
        * For instance, with mln::box2d, this minimum is the top left
@@ -49,7 +49,7 @@
        */
       const point& pmin() const;
 
-      /*! \brief Return the box "maximum" point.
+      /*! \brief Give the box "maximum" point.
        *
        * Return the "maximum" point w.r.t. the ordering between points.
        * For instance, with mln::box2d, this maximum is the bottom
Index: mln/core/window2d.hh
--- mln/core/window2d.hh	(revision 1009)
+++ mln/core/window2d.hh	(working copy)
@@ -34,7 +34,6 @@
  * routine.
  */
 
-# include <cmath>
 # include <mln/core/window.hh>
 # include <mln/core/dpoint2d.hh>
 
@@ -48,37 +47,10 @@
   typedef window_<dpoint2d> window2d;
 
 
-  /*! \brief Create an mln::window2d.
-   *
-   * \param[in] values Array of Booleans.
-   *
-   * \pre The array size, \c M, has to be a square of an odd integer.
-   *
-   * \return A 2D window.
-   */
-  template <unsigned M>
-  window2d mk_window2d(const bool (&values)[M]);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-  template <unsigned M>
-  window2d mk_window2d(const bool (&values)[M])
-  {
-    int h = unsigned(std::sqrt(float(M))) / 2;
-    assert((2 * h + 1) * (2 * h + 1) = M);
-    window2d tmp;
-    unsigned i = 0;
-    for (int row = - h; row <= h; ++row)
-      for (int col = - h; col <= h; ++col)
-	if (values[i++])
-	  tmp.insert(mk_dpoint2d(row, col));
-    return tmp;
-  }
+} // end of namespace mln
 
-# endif // ! MLN_INCLUDE_ONLY
 
-} // end of namespace mln
+# include <mln/make/window2d.hh>
 
 
 #endif // ! MLN_CORE_WINDOW2D_HH
Index: mln/core/dpoint.hh
--- mln/core/dpoint.hh	(revision 1009)
+++ mln/core/dpoint.hh	(working copy)
@@ -87,14 +87,14 @@
     /*! \brief Constructor; coordinates are set by function \p f.
      */
     template <typename F>
-    dpoint_(F f); // FIXME: Bound parameter!
+    dpoint_(const Function<F>& f);
 
     /*! \brief Set all coordinates to the value \p c.
      */
     void set_all(C c);
 
-    /// Give the null delta-point (all coordinates are 0).
-    static const dpoint_<n,C>& zero();
+    /// Null delta-point (all coordinates are 0).
+    static const dpoint_<n,C> zero;
 
   protected:
     C coord_[n];
@@ -124,8 +124,9 @@
 
   template <unsigned n, typename C>
   template <typename F>
-  dpoint_<n,C>::dpoint_(F f)
+  dpoint_<n,C>::dpoint_(const Function<F>& f_)
   {
+    const F& f = exact(f_);
     for (unsigned i = 0; i < n; ++i)
       coord_[i] = f(i);
   }
@@ -138,11 +139,7 @@
   }
 
   template <unsigned n, typename C>
-  const dpoint_<n,C>& dpoint_<n,C>::zero()
-  {
-    static const dpoint_<n,C> zero_(all(0));
-    return zero_;
-  }
+  const dpoint_<n,C> dpoint_<n,C>::zero = all(0);
 
 # endif // ! MLN_INCLUDE_ONLY
   
Index: mln/core/pixter2d_b.hh
--- mln/core/pixter2d_b.hh	(revision 1009)
+++ mln/core/pixter2d_b.hh	(working copy)
@@ -79,7 +79,7 @@
 		+ 2 * border_size_ + 1)
   {
     this->start_ = &ima(ima.domain().pmin());
-    this->eor_ = &ima(mk_point2d(ima.domain().pmin()[0], ima.domain().pmax()[1])) + 1;
+    this->eor_ = &ima(make::point2d(ima.domain().pmin()[0], ima.domain().pmax()[1])) + 1;
     this->eoi_ = &ima(ima.domain().pmax()) + 1;
   }
 
@@ -88,7 +88,7 @@
   {
     ++(this->current_);
 
-    if (this->current_ = this->eor_ and this->current_ != this->eoi_)
+    if (this->current_ = this->eor_ && this->current_ != this->eoi_)
     {
       this->current_ += 2 * this->border_size_;
       this->eor_ += this->row_offset_;
Index: mln/core/window.hh
--- mln/core/window.hh	(revision 1009)
+++ mln/core/window.hh	(working copy)
@@ -37,6 +37,7 @@
 # include <mln/core/concept/genpoint.hh>
 # include <mln/core/internal/set_of.hh>
 # include <mln/core/dpoint.hh>
+# include <mln/core/box.hh>
 
 # include <mln/convert/to_dpoint.hh>
 # include <mln/fun/all.hh>
@@ -79,6 +80,7 @@
      */
     typedef fwd_qiter qiter;
 
+
     /*! \brief Constructor without argument.
      *
      * The constructed window is empty. 
@@ -99,6 +101,10 @@
 
     /// Give the symmetrical window.
     window_<D> sym_() const;
+
+  protected:
+    
+    box_<point> b_;
   };
 
 
@@ -159,7 +165,7 @@
   {
     typedef mln_point(W) P;
     window_<mln_dpoint(W)> tmp;
-    mln_qiter(W) q(win, P::zero());
+    mln_qiter(W) q(win, P::zero);
     for_all(q)
       tmp.insert(convert::to_dpoint(q) + dp);
     return tmp;
@@ -178,7 +184,7 @@
   {
     typedef mln_point(W) P;
     window_<mln_dpoint(W)> tmp;
-    mln_qiter(W) q(lhs, P::zero());
+    mln_qiter(W) q(lhs, P::zero);
     for_all(q)
       {
 	mln_dpoint(W) dp = convert::to_dpoint(q);
Index: mln/core/image2d_b.hh
--- mln/core/image2d_b.hh	(revision 1009)
+++ mln/core/image2d_b.hh	(working copy)
@@ -112,6 +112,9 @@
     /// Assignment operator.
     image2d_b& operator=(const image2d_b<T>& rhs);
 
+    /// Destructor.
+    ~image2d_b();
+
 
     /// Initialize an empty image.
     void init_with(int nrows, int ncols, unsigned bdr = border::thickness);
@@ -129,9 +132,6 @@
     /// Give the definition domain.
     const box2d& domain() const;
 
-    /// Give a bounding box.
-    const box2d& bbox() const;
-
     /// Give the border thickness.
     unsigned border() const;
 
@@ -144,11 +144,16 @@
     /// Read-write access to the image value located at \p p.
     T& operator()(const point2d& p);
 
-    /// Return an offset from a dpoints
+    /// Read-only access to the image value located at (\p row, \p col).
+    const T& at(int row, int col) const;
+
+    /// Read-write access to the image value located at (\p row, \p col).
+    T& at(int row, int col);
+
+
+    /// Return the offset corresponding to the dpoint \p dp.
     int offset(const dpoint2d& dp);
 
-    /// Destructor.
-    ~image2d_b();
 
   private:
 
@@ -167,6 +172,7 @@
   };
 
 
+
 # ifndef MLN_INCLUDE_ONLY
 
   // ctors
@@ -192,7 +198,7 @@
   image2d_b<T>::init_with(int nrows, int ncols, unsigned bdr)
   {
     mln_precondition(! this->has_data());
-    b_ = mk_box2d(nrows, ncols);
+    b_ = make::box2d(nrows, ncols);
     bdr_ = bdr;
     allocate_();
   }
@@ -265,14 +271,6 @@
   }
 
   template <typename T>
-  const box2d&
-  image2d_b<T>::bbox() const
-  {
-    mln_precondition(this->has_data());
-    return b_;
-  }
-
-  template <typename T>
   unsigned
   image2d_b<T>::border() const
   {
@@ -313,6 +311,22 @@
   }
 
   template <typename T>
+  const T&
+  image2d_b<T>::at(int row, int col) const
+  {
+    mln_precondition(this->owns_(make::point2d(row, col)));
+    return array_[row][col];
+  }
+
+  template <typename T>
+  T&
+  image2d_b<T>::at(int row, int col)
+  {
+    mln_precondition(this->owns_(make::point2d(row, col)));
+    return array_[row][col];
+  }
+
+  template <typename T>
   image2d_b<T>::~image2d_b()
   {
     deallocate_();
Index: mln/core/internal/image_adaptor.hh
--- mln/core/internal/image_adaptor.hh	(revision 1009)
+++ mln/core/internal/image_adaptor.hh	(working copy)
@@ -105,7 +105,7 @@
     }
 
     template <typename I, typename E>
-    const image_adaptor_<I,E>::pset&
+    const typename image_adaptor_<I,E>::pset&
     image_adaptor_<I,E>::domain() const
     {
       return adaptee_.domain();
Index: mln/core/internal/image_base.hh
--- mln/core/internal/image_base.hh	(revision 1009)
+++ mln/core/internal/image_base.hh	(working copy)
@@ -87,6 +87,7 @@
     bool
     image_base_<S,E>::has(const psite& p) const
     {
+      mln_precondition(exact(this)->has_data());
       return exact(this)->domain().has(p);
     }
 
@@ -94,6 +95,7 @@
     const box_<mln_point(S)>&
     image_base_<S,E>::bbox() const
     {
+      mln_precondition(exact(this)->has_data());
       return exact(this)->domain().bbox();
     }
 
@@ -101,6 +103,7 @@
     std::size_t
     image_base_<S,E>::npoints() const
     {
+      mln_precondition(exact(this)->has_data());
       return exact(this)->domain().npoints();      
     }
 
Index: mln/core/internal/piter_adaptor.hh
--- mln/core/internal/piter_adaptor.hh	(revision 0)
+++ mln/core/internal/piter_adaptor.hh	(revision 0)
@@ -0,0 +1,171 @@
+// 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_PITER_ADAPTOR_HH
+# define MLN_CORE_INTERNAL_PITER_ADAPTOR_HH
+
+/*! \file mln/core/internal/piter_adaptor_.hh
+ *
+ * \brief Definition of iterators on points of boxes.
+ */
+
+# include <mln/core/concept/piter.hh>
+# include <mln/core/concept/box.hh>
+
+
+namespace mln
+{
+
+  namespace internal
+  {
+
+    /*! \brief A base class for point iterator adaptors.
+     *
+     * Parameter \c Pi is the type of the point iterator adaptee;
+     * parameter E is the exact type.
+     */
+    template <typename Pi, typename E>
+    class piter_adaptor_ : public Piter<E>
+    {
+    public:
+
+      /// Space dimension.
+      enum { dim = Pi::dim };
+
+      /// Psite 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 point() const;
+
+      /// Address of the point.
+      const point* pointer() const;
+
+      /// Give the i-th coordinate.
+      coord operator[](unsigned i) const;
+
+      /// 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:
+
+      Pi piter_; // own copy
+    };
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+    template <typename Pi, typename E>
+    piter_adaptor_<Pi,E>::piter_adaptor_(const Pi& piter)
+      : piter_(piter)
+    {
+      invalidate();
+    }
+
+    template <typename Pi, typename E>
+    piter_adaptor_<Pi,E>::operator mln_point(Pi) () const
+    {
+      return piter_;
+    }
+
+    template <typename Pi, typename E>
+    const mln_point(Pi)*
+    piter_adaptor_<Pi,E>::pointer() const
+    {
+      return piter_.pointer();
+    }
+
+    template <typename Pi, typename E>
+    mln_coord(Pi)
+    piter_adaptor_<Pi,E>::operator[](unsigned i) const
+    {
+      assert(i < dim);
+      return piter_[i];
+    }
+
+    template <typename Pi, typename E>
+    bool
+    piter_adaptor_<Pi,E>::is_valid() const
+    {
+      return piter_.is_valid();
+    }
+
+    template <typename Pi, typename E>
+    void
+    piter_adaptor_<Pi,E>::invalidate()
+    {
+      piter_.invalidate();
+    }
+
+    template <typename Pi, typename E>
+    void
+    piter_adaptor_<Pi,E>::start()
+    {
+      piter_.start();
+    }
+
+    template <typename Pi, typename E>
+    void
+    piter_adaptor_<Pi,E>::next_()
+    {
+      piter_.next();
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_PITER_ADAPTOR_HH
Index: mln/core/internal/set_of.hh
--- mln/core/internal/set_of.hh	(revision 1009)
+++ mln/core/internal/set_of.hh	(working copy)
@@ -69,6 +69,8 @@
        * \param[in] elt The element to be inserted.
        *
        * If \p elt is already in the set, this method is a no-op.
+       *
+       * \todo Returns exact(*this).
        */
       void insert(const E& elt);
 
Index: mln/core/box2d.hh
--- mln/core/box2d.hh	(revision 1009)
+++ mln/core/box2d.hh	(working copy)
@@ -49,47 +49,10 @@
   typedef box_<point2d> box2d;
 
 
-  /*! \brief Create an mln::box2d.
-   *
-   * \param[in] nrows Number of rows.
-   * \param[in] ncols Number of columns.
-   *
-   * \pre \p nrows != 0 and \p ncols != 0.
-   *
-   * \return A 2D box.
-   */
-  box2d mk_box2d(unsigned nrows, unsigned ncols)
-  {
-    mln_precondition(nrows != 0 && ncols != 0);
-    box2d tmp(mk_point2d(0, 0),
-	      mk_point2d(nrows - 1, ncols - 1));
-    return tmp;
-  }
-
-
-  /*! \brief Create an mln::box2d.
-   *
-   * \overload
-   *
-   * \param[in] min_row Index of the top most row.
-   * \param[in] max_row Index of the botton most row.
-   * \param[in] min_col Index of the left most column.
-   * \param[in] max_col Index of the right most column.
-   *
-   * \pre \p max_row >= \p min_row and \p max_col >= \p min_col.
-   *
-   * \return A 2D box.
-   */
-  box2d mk_box2d(int min_row, int max_row,
-		 int min_col, int max_col)
-  {
-    mln_precondition(max_row >= min_row && max_col >= min_col);
-    box2d tmp(mk_point2d(min_row, min_col),
-	      mk_point2d(max_row, max_col));
-    return tmp;
-  }
-
 } // end of namespace mln
 
 
+# include <mln/make/box2d.hh>
+
+
 #endif // ! MLN_CORE_BOX2D_HH
Index: mln/core/point2d.hh
--- mln/core/point2d.hh	(revision 1009)
+++ mln/core/point2d.hh	(working copy)
@@ -46,24 +46,10 @@
   typedef point_<2,int> point2d;
 
 
-  /*! \brief Create an mln::point2d.
-   *
-   * \param[in] row Index of row.
-   * \param[in] col Index of column.
-   *
-   * \return A 2D point.
-   */
-  point2d mk_point2d(int row, int col)
-  {
-    point2d tmp;
-    tmp[0] = row;
-    tmp[1] = col;
-    return tmp;
-  }
-
 } // end of namespace mln
 
 
+# include <mln/make/point2d.hh>
 # include <mln/core/dpoint2d.hh>
 
 
Index: mln/core/safe_image.hh
--- mln/core/safe_image.hh	(revision 1009)
+++ mln/core/safe_image.hh	(working copy)
@@ -44,6 +44,12 @@
 
     mln_rvalue(I) operator()(const mln_psite(I)& p) const;
     mln_lvalue(I) operator()(const mln_psite(I)& p);
+
+    template <typename U>
+    struct change_value
+    {
+      typedef safe_image<mln_ch_value(I, U)> ret;
+    };
   };
 
 
@@ -67,7 +73,7 @@
   safe_image<I>::operator()(const mln_psite(I)& p) const
   {
     static mln_value(I) tmp;
-    if (not this->owns_(p))
+    if (! this->owns_(p))
       return tmp;
     return this->adaptee_(p);
   }
@@ -77,7 +83,7 @@
   safe_image<I>::operator()(const mln_psite(I)& p)
   {
     static mln_value(I) tmp;
-    if (not this->owns_(p))
+    if (! this->owns_(p))
       return tmp;
     return this->adaptee_(p);
   }
Index: mln/fun/chess.hh
--- mln/fun/chess.hh	(revision 0)
+++ mln/fun/chess.hh	(revision 0)
@@ -0,0 +1,71 @@
+// 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_FUN_CHESS_HH
+# define MLN_FUN_CHESS_HH
+
+/*! \file mln/fun/chess.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <mln/core/concept/function.hh>
+# include <mln/core/point2d.hh>
+
+
+namespace mln
+{
+
+  namespace fun
+  {
+
+    // FIXME: Doc!
+
+    struct chess_t : public Function_p2b< chess_t >
+    {
+      bool operator()(const point2d& p) const;
+    }
+
+    chess;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    bool
+    chess_t::operator()(const point2d& p) const
+    {
+      return (p.row() + p.col()) % 2 = 0;
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_CHESS_HH
Index: mln/fun/all.hh
--- mln/fun/all.hh	(revision 1009)
+++ mln/fun/all.hh	(working copy)
@@ -33,6 +33,10 @@
  * \brief FIXME.
  */
 
+# include <mln/core/concept/function.hh>
+
+
+// FIXME: Usually all.hh is the file to include all files in the current directory...
 
 namespace mln
 {
@@ -41,7 +45,7 @@
   {
 
     template <typename T>
-    struct all
+    struct all : public Function< all<T> >
     {
       all(T t);
       template <typename U>
Index: mln/io/save_pgm.hh
--- mln/io/save_pgm.hh	(revision 1009)
+++ mln/io/save_pgm.hh	(working copy)
@@ -55,7 +55,7 @@
       file << "# olena" << std::endl;
       file << ima.ncols() << ' ' << ima.nrows() << std::endl;
       file << "255" << std::endl;
-      point2d p = mk_point2d(ima.domain().pmin().row(),
+      point2d p = make::point2d(ima.domain().pmin().row(),
 			     ima.domain().pmin().col());
       size_t len = ima.ncols() * sizeof(unsigned char);
       for (;
Index: mln/io/load_pgm.hh
--- mln/io/load_pgm.hh	(revision 1009)
+++ mln/io/load_pgm.hh	(working copy)
@@ -134,7 +134,7 @@
       template <typename I>
       void load_pgm_raw_2d(std::ifstream& file, I& ima)
       {
-	point2d p = mk_point2d(0, ima.domain().pmin().col());
+	point2d p = make::point2d(0, ima.domain().pmin().col());
 	size_t len = ima.ncols() * sizeof(mln_value(I));
 	for (p.row()  = ima.domain().pmin().row();
 	     p.row() <= ima.domain().pmax().row();
Index: mln/make/dpoint2d.hh
--- mln/make/dpoint2d.hh	(revision 0)
+++ mln/make/dpoint2d.hh	(revision 0)
@@ -0,0 +1,72 @@
+// 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_MAKE_DPOINT2D_HH
+# define MLN_MAKE_DPOINT2D_HH
+
+/*! \file mln/make/dpoint2d.hh
+ *
+ * \brief Routine to construct an mln::dpoint2d.
+ */
+
+# include <mln/core/dpoint2d.hh>
+
+
+namespace mln
+{
+
+  namespace make
+  {
+
+    /*! \brief Create an mln::dpoint2d.
+     *
+     * \param[in] row Row coordinate.
+     * \param[in] Col Column coordinate.
+     *
+     * \return A 2D dpoint.
+     */
+    mln::dpoint2d dpoint2d(int row, int col);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    mln::dpoint2d dpoint2d(int row, int col)
+    {
+      mln::dpoint2d tmp;
+      tmp[0] = row;
+      tmp[1] = col;
+      return tmp;
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_DPOINT2D_HH
Index: mln/make/window2d.hh
--- mln/make/window2d.hh	(revision 0)
+++ mln/make/window2d.hh	(revision 0)
@@ -0,0 +1,82 @@
+// 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_MAKE_WINDOW2D_HH
+# define MLN_MAKE_WINDOW2D_HH
+
+/*! \file mln/make/window2d.hh
+ *
+ * \brief Routine to create an mln::window2d.
+ */
+
+# include <cmath>
+# include <mln/core/window2d.hh>
+# include <mln/make/dpoint2d.hh>
+
+
+namespace mln
+{
+
+  namespace make
+  {
+
+    /*! \brief Create an mln::window2d.
+     *
+     * \param[in] values Array of Booleans.
+     *
+     * \pre The array size, \c M, has to be a square of an odd integer.
+     *
+     * \return A 2D window.
+     */
+    template <unsigned M>
+    mln::window2d window2d(const bool (&values)[M]);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    template <unsigned M>
+    mln::window2d window2d(const bool (&values)[M])
+    {
+      int h = unsigned(std::sqrt(float(M))) / 2;
+      assert((2 * h + 1) * (2 * h + 1) = M);
+      mln::window2d tmp;
+      unsigned i = 0;
+      for (int row = - h; row <= h; ++row)
+	for (int col = - h; col <= h; ++col)
+	  if (values[i++])
+	    tmp.insert(make::dpoint2d(row, col));
+      return tmp;
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_WINDOW2D_HH
Index: mln/make/box2d.hh
--- mln/make/box2d.hh	(revision 0)
+++ mln/make/box2d.hh	(revision 0)
@@ -0,0 +1,101 @@
+// 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_MAKE_BOX2D_HH
+# define MLN_MAKE_BOX2D_HH
+
+/*! \file mln/make/box2d.hh
+ *
+ * \brief Routines to construct an mln::box2d.
+ */
+
+# include <mln/core/box2d.hh>
+# include <mln/make/point2d.hh>
+
+
+namespace mln
+{
+
+  namespace make
+  {
+
+    /*! \brief Create an mln::box2d.
+     *
+     * \param[in] nrows Number of rows.
+     * \param[in] ncols Number of columns.
+     *
+     * \pre \p nrows != 0 and \p ncols != 0.
+     *
+     * \return A 2D box.
+     */
+    mln::box2d box2d(unsigned nrows, unsigned ncols);
+
+
+    /*! \brief Create an mln::box2d.
+     *
+     * \overload
+     *
+     * \param[in] min_row Index of the top most row.
+     * \param[in] max_row Index of the botton most row.
+     * \param[in] min_col Index of the left most column.
+     * \param[in] max_col Index of the right most column.
+     *
+     * \pre \p max_row >= \p min_row and \p max_col >= \p min_col.
+     *
+     * \return A 2D box.
+     */
+    mln::box2d box2d(int min_row, int max_row,
+		     int min_col, int max_col);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    mln::box2d box2d(unsigned nrows, unsigned ncols)
+    {
+      mln_precondition(nrows != 0 && ncols != 0);
+      mln::box2d tmp(make::point2d(0, 0),
+		     make::point2d(nrows - 1, ncols - 1));
+      return tmp;
+    }
+
+    mln::box2d box2d(int min_row, int max_row,
+		     int min_col, int max_col)
+    {
+      mln_precondition(max_row >= min_row && max_col >= min_col);
+      mln::box2d tmp(make::point2d(min_row, min_col),
+		     make::point2d(max_row, max_col));
+      return tmp;
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_BOX2D_HH
Index: mln/make/point2d.hh
--- mln/make/point2d.hh	(revision 0)
+++ mln/make/point2d.hh	(revision 0)
@@ -0,0 +1,72 @@
+// 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_MAKE_POINT2D_HH
+# define MLN_MAKE_POINT2D_HH
+
+/*! \file mln/make/point2d.hh
+ *
+ * \brief Routine to construct an mln::point2d.
+ */
+
+# include <mln/core/point2d.hh>
+
+
+namespace mln
+{
+
+  namespace make
+  {
+
+    /*! \brief Create an mln::point2d.
+     *
+     * \param[in] row Row coordinate.
+     * \param[in] Col Column coordinate.
+     *
+     * \return A 2D point.
+     */
+    mln::point2d point2d(int row, int col);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+    mln::point2d point2d(int row, int col)
+    {
+      mln::point2d tmp;
+      tmp[0] = row;
+      tmp[1] = col;
+      return tmp;
+    }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_POINT2D_HH
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from  Nicolas Ballas  <ballas(a)lrde.epita.fr>
	Fix bug in pixter_dpoint2d.
	* tests/pixter_dpoint2d.cc: Update.
	* mln/core/dpoints_piter.hh: Update.
	* mln/core/concept/doc/fast_iterator.hh: New documentation.
	* mln/core/image2d_b.hh: Change offset method.
 mln/core/concept/doc/fast_iterator.hh |   57 ++++++++++++++++++++++++++++++++++
 mln/core/dpoints_piter.hh             |    2 -
 mln/core/image2d_b.hh                 |    4 +-
 tests/pixter_dpoint2d.cc              |   16 +++++----
 4 files changed, 70 insertions(+), 9 deletions(-)
Index: tests/pixter_dpoint2d.cc
--- tests/pixter_dpoint2d.cc	(revision 1008)
+++ tests/pixter_dpoint2d.cc	(working copy)
@@ -1,7 +1,7 @@
 #include <cassert>
 #include <iostream>
-#include <mln/core/image2d.hh>
-#include <mln/core/internal/set_of.hh>
+#include <mln/core/image2d_b.hh>
+#include <mln/core/window.hh>
 #include <mln/level/fill.hh>
 #include <mln/core/dpoints_pixter.hh>
 
@@ -9,27 +9,29 @@
 main()
 {
   using namespace mln;
-  typedef image2d<int> I;
+  typedef image2d_b<int> I;
 
 
   I ima(20, 20);
   level::fill(ima, 5);
   I::piter f(ima.domain());
-  internal::set_of_<I::dpoint> set;
+  window_<I::dpoint> set;
 
-  set.insert(mk_dpoint2d(-1, -1));
   set.insert(mk_dpoint2d(0, -1));
+  set.insert(mk_dpoint2d(0, -1));
+  set.insert(mk_dpoint2d(1, 0));
   set.insert(mk_dpoint2d(1, 0));
-  set.insert(mk_dpoint2d(1, 1));
 
   for_all(f)
   {
+    if (f[0] > 0 && f[1] > 0 && f[0] < 19 && f[1] < 19)
+    {
     I::qixter dit(set, f, ima);
 
-    if (f[0] > 0 && f[1] > 0 && f[0] < 19 && f[1] < 19)
       for_all(dit)
       {
       	assert(*dit == 5);
       }
   }
 }
+}
Index: mln/core/dpoints_piter.hh
--- mln/core/dpoints_piter.hh	(revision 1008)
+++ mln/core/dpoints_piter.hh	(working copy)
@@ -88,7 +88,7 @@
 
     /// Start an iteration.
     void start();
-xb
+
     /// Go to the next point.
     void next_();
 
Index: mln/core/concept/doc/fast_iterator.hh
--- mln/core/concept/doc/fast_iterator.hh	(revision 0)
+++ mln/core/concept/doc/fast_iterator.hh	(revision 0)
@@ -0,0 +1,57 @@
+// 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.
+
+/*! \file mln/core/concept/doc/fast_iterator.hh
+ * \brief This file documents the concept of mln::Fast_Iterator.
+ */
+
+namespace mln
+{
+
+  namespace doc
+  {
+    /*! \brief Documentation class for mln::Iterator.
+     * \see mln::Fast_Iterator
+     */
+    template <typename E>
+    struct Fast_Iterator : public Iterator<E>
+    {
+      /*! \brief Dereference operator.
+       * return the current pixel
+       */
+      rvalue operator* ();
+
+      /*! \brief Dereference operator.
+       * return the current pixel
+       */
+      lvalue operator* () const;
+    protected:
+      Fast_Iterator();
+    };
+  } // end of namespace doc
+
+} // end of namespace mln
Index: mln/core/image2d_b.hh
--- mln/core/image2d_b.hh	(revision 1008)
+++ mln/core/image2d_b.hh	(working copy)
@@ -61,6 +61,7 @@
     typedef box2d   pset;
     typedef point2d psite;
     typedef point2d point;
+    typedef dpoint2d dpoint;
     typedef mln_fwd_piter(box2d) fwd_piter;
     typedef mln_bkd_piter(box2d) bkd_piter;
     typedef fwd_piter piter;
@@ -72,6 +73,7 @@
     /// Foward pixel iterator on dpoints assoicated to image 2d
     typedef dpoints_pixter< image2d_b<T> > fwd_qixter;
 
+
     typedef fwd_pixter pixter;
     typedef fwd_qixter qixter;
 
@@ -368,7 +370,7 @@
   int
   image2d_b<T>::offset(const dpoint2d& dp)
   {
-    return dp[0] * vb_.pmax()[1] + dp[1];
+    return dp[0] * vb_.len(1) + dp[1];
   }
 
 # endif // ! MLN_INCLUDE_ONLY
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from  Nicolas Ballas  <ballas(a)lrde.epita.fr>
	Separate interface from implementation.
	* oln/core/gen/zero.hh,
	* oln/io/save_pgm.hh,
	* oln/io/load_pgm.hh,
	* oln/io/pnm.hh: Separte interface from implementation.
 core/gen/zero.hh |   16 ++++++++++++----
 io/load_pgm.hh   |   32 +++++++++++++++++++++++++++++++-
 io/pnm.hh        |   37 ++++++++++++++++++++++++++++++++++++-
 io/save_pgm.hh   |    5 +++++
 4 files changed, 84 insertions(+), 6 deletions(-)
Index: oln/core/gen/zero.hh
--- oln/core/gen/zero.hh	(revision 1007)
+++ oln/core/gen/zero.hh	(working copy)
@@ -36,18 +36,26 @@
 
   struct zero_t;
 
+  // Forward declartions
+  void assignment_(int&      i, const zero_t&);
+  void assignment_(unsigned& u, const zero_t&);
+  void assignment_(float&    f, const zero_t&);
+  void assignment_(double&   d, const zero_t&);
 
+  struct zero_t : public Literal< zero_t >
+  {
+  };
+
+#ifndef OLN_INCLUDE_ONLY
   void assignment_(int&      i, const zero_t&) { i = 0;   }
   void assignment_(unsigned& u, const zero_t&) { u = 0u;  }
   void assignment_(float&    f, const zero_t&) { f = 0.f; }
   void assignment_(double&   d, const zero_t&) { d = 0.;  }
 
 
-  struct zero_t : public Literal< zero_t >
-  {
-  }
+  struct zero_t zero;
+#endif // ! OLN_INCLUDE_ONLY
 
-  zero;
 
 
 
Index: oln/io/save_pgm.hh
--- oln/io/save_pgm.hh	(revision 1007)
+++ oln/io/save_pgm.hh	(working copy)
@@ -40,6 +40,9 @@
 
   namespace io
   {
+    void save_pgm(const image2d<unsigned char>& ima, const std::string& filename);
+
+#ifndef OLN_INCLUDE_ONLY
 
     void save_pgm(const image2d<unsigned char>& ima, const std::string& filename)
     {
@@ -60,6 +63,8 @@
 	file.write((char*)(&(ima.at(row, col))), len);
     }
 
+#endif // !OLN_INCLUDE_ONLY
+
   } // end of namespace oln::io
 
 } // end of namespace oln
Index: oln/io/load_pgm.hh
--- oln/io/load_pgm.hh	(revision 1007)
+++ oln/io/load_pgm.hh	(working copy)
@@ -42,6 +42,28 @@
 
     namespace internal {
 
+      // Forward declaration
+      void abort();
+
+      bool read_pnm_header(std::istream& istr,
+			   char& type,
+			   int& nrows, int& ncols,
+			   bool test = false);
+
+      void read_pnm_header(char ascii, char raw,
+			   std::istream& istr,
+			   char& type,
+			   int& nrows, int& ncols);
+
+      template <typename I>
+      void load_pgm_ascii(std::ifstream& file, I& ima);
+
+      template <typename I>
+      void load_pgm_raw_2d(std::ifstream& file, I& ima);
+
+
+#ifndef OLN_INCLUDE_ONLY
+
       void abort()
       {
 	std::cerr << " aborting." << std::endl;
@@ -51,7 +73,7 @@
       bool read_pnm_header(std::istream& istr,
 			   char& type,
 			   int& nrows, int& ncols,
-			   bool test = false)
+			   bool test)
       {
 	// check magic
 	if (istr.get() != 'P' )
@@ -136,10 +158,16 @@
 	  file.read((char*)(&(ima.at(row, col))), len);
       }
 
+#endif // ! OLN_INCLUDE_ONLY
+
 
     } // end of namespace oln::io::internal
 
 
+    image2d<unsigned char> load_pgm(const std::string& filename);
+
+#ifndef OLN_INCLUDE_ONLY
+
     image2d<unsigned char> load_pgm(const std::string& filename)
     {
       std::ifstream file(filename.c_str());
@@ -161,6 +189,8 @@
       return ima;
     }
 
+#endif // ! OLN_INCLUDE_ONLY
+
   } // end of namespace oln::io
 
 } // end of namespace oln
Index: oln/io/pnm.hh
--- oln/io/pnm.hh	(revision 1007)
+++ oln/io/pnm.hh	(working copy)
@@ -43,6 +43,31 @@
 
     namespace internal {
 
+      // forward declaration
+      void abort();
+
+      bool read_pnm_header(std::istream& istr,
+			   char& type,
+			   int& nrows, int& ncols,
+			   bool test = false);
+
+      void read_pnm_header(char ascii, char raw,
+			   std::istream& istr,
+			   char& type,
+			   int& nrows, int& ncols);
+
+      template <typename I>
+      void load_pbm_raw(std::ifstream& file, I& ima);
+
+      template <typename I>
+      void load_pbm_ascii(std::ifstream& file, I& ima);
+
+      template <typename I>
+      void load_pnm_raw_2d(std::ifstream& file, I& ima);
+
+
+#ifndef OLN_INCLUDE_ONLY
+
       void abort()
       {
 	std::cerr << " aborting." << std::endl;
@@ -52,7 +77,7 @@
       bool read_pnm_header(std::istream& istr,
 			   char& type,
 			   int& nrows, int& ncols,
-			   bool test = false)
+			   bool test)
       {
 	// check magic
 	if (istr.get() != 'P' )
@@ -170,10 +195,18 @@
 		    len * sizeof(oln_value(I)));
       }
 
+#endif // ! OLN_INCLUDE_ONLY
 
     } // end of namespace oln::io::internal
 
 
+    // Forward declaration
+    image2d<unsigned char> load_pgm(const std::string& filename);
+    image2d<bool> load_pbm(const std::string& filename);
+
+
+#ifndef OLN_INCLUDE_ONLY
+
     image2d<bool> load_pbm(const std::string& filename)
     {
       std::ifstream file(filename.c_str());
@@ -217,6 +250,8 @@
       return ima;
     }
 
+#endif // ! OLN_INCLUDE_ONLY
+
   } // end of namespace oln::io
 
 } // end of namespace oln
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                        
                            
                                
                            
                            982: change fiter name to pixter,	and index name to offset in Fast_image concept.
                        
                        
by Nicolas Ballas 12 Jul '07
                    by Nicolas Ballas 12 Jul '07
12 Jul '07
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from  Nicolas Ballas  <ballas(a)lrde.epita.fr>
	change fiter name to pixter, and index name to offset in Fast_image concept.
	* tests/core/fiter_point1d.cc,
	* tests/core/fiter_point2d.cc,
	* tests/core/fiter_point1d_b.cc,
	* tests/core/fiter_point3d.cc,
	* tests/core/fiter_point2d_b.cc,
	* tests/core/fiter_point3d_b.cc,
	* tests/core/fast_image2d.cc,
	* tests/core/fast_image2d_b.cc,
	* tests/core/fast_image3d.cc,
	* tests/core/fast_image3d_b.cc,
	* oln/core/1d/image1d.hh,
	* oln/core/1d/image1d_b.hh,
	* oln/core/2d/image2d.hh,
	* oln/core/2d/image2d_b.hh,
	* oln/core/equipment.hh,
	* oln/core/3d/image3d.hh,
	* oln/core/3d/image3d_b.hh,
	* oln/core/concept/image.hh,
	* oln/core/concept/image_identity.hh,
	* oln/core/internal/image_selectors.hh: Change types name.
 core/gen/zero.hh |   16 ++++++++++++----
 io/load_pgm.hh   |   32 +++++++++++++++++++++++++++++++-
 io/pnm.hh        |   37 ++++++++++++++++++++++++++++++++++++-
 io/save_pgm.hh   |    5 +++++
 4 files changed, 84 insertions(+), 6 deletions(-)
Index: oln/core/gen/zero.hh
--- oln/core/gen/zero.hh	(revision 1007)
+++ oln/core/gen/zero.hh	(working copy)
@@ -36,18 +36,26 @@
 
   struct zero_t;
 
+  // Forward declartions
+  void assignment_(int&      i, const zero_t&);
+  void assignment_(unsigned& u, const zero_t&);
+  void assignment_(float&    f, const zero_t&);
+  void assignment_(double&   d, const zero_t&);
 
+  struct zero_t : public Literal< zero_t >
+  {
+  };
+
+#ifndef OLN_INCLUDE_ONLY
   void assignment_(int&      i, const zero_t&) { i = 0;   }
   void assignment_(unsigned& u, const zero_t&) { u = 0u;  }
   void assignment_(float&    f, const zero_t&) { f = 0.f; }
   void assignment_(double&   d, const zero_t&) { d = 0.;  }
 
 
-  struct zero_t : public Literal< zero_t >
-  {
-  }
+  struct zero_t zero;
+#endif // ! OLN_INCLUDE_ONLY
 
-  zero;
 
 
 
Index: oln/io/save_pgm.hh
--- oln/io/save_pgm.hh	(revision 1007)
+++ oln/io/save_pgm.hh	(working copy)
@@ -40,6 +40,9 @@
 
   namespace io
   {
+    void save_pgm(const image2d<unsigned char>& ima, const std::string& filename);
+
+#ifndef OLN_INCLUDE_ONLY
 
     void save_pgm(const image2d<unsigned char>& ima, const std::string& filename)
     {
@@ -60,6 +63,8 @@
 	file.write((char*)(&(ima.at(row, col))), len);
     }
 
+#endif // !OLN_INCLUDE_ONLY
+
   } // end of namespace oln::io
 
 } // end of namespace oln
Index: oln/io/load_pgm.hh
--- oln/io/load_pgm.hh	(revision 1007)
+++ oln/io/load_pgm.hh	(working copy)
@@ -42,6 +42,28 @@
 
     namespace internal {
 
+      // Forward declaration
+      void abort();
+
+      bool read_pnm_header(std::istream& istr,
+			   char& type,
+			   int& nrows, int& ncols,
+			   bool test = false);
+
+      void read_pnm_header(char ascii, char raw,
+			   std::istream& istr,
+			   char& type,
+			   int& nrows, int& ncols);
+
+      template <typename I>
+      void load_pgm_ascii(std::ifstream& file, I& ima);
+
+      template <typename I>
+      void load_pgm_raw_2d(std::ifstream& file, I& ima);
+
+
+#ifndef OLN_INCLUDE_ONLY
+
       void abort()
       {
 	std::cerr << " aborting." << std::endl;
@@ -51,7 +73,7 @@
       bool read_pnm_header(std::istream& istr,
 			   char& type,
 			   int& nrows, int& ncols,
-			   bool test = false)
+			   bool test)
       {
 	// check magic
 	if (istr.get() != 'P' )
@@ -136,10 +158,16 @@
 	  file.read((char*)(&(ima.at(row, col))), len);
       }
 
+#endif // ! OLN_INCLUDE_ONLY
+
 
     } // end of namespace oln::io::internal
 
 
+    image2d<unsigned char> load_pgm(const std::string& filename);
+
+#ifndef OLN_INCLUDE_ONLY
+
     image2d<unsigned char> load_pgm(const std::string& filename)
     {
       std::ifstream file(filename.c_str());
@@ -161,6 +189,8 @@
       return ima;
     }
 
+#endif // ! OLN_INCLUDE_ONLY
+
   } // end of namespace oln::io
 
 } // end of namespace oln
Index: oln/io/pnm.hh
--- oln/io/pnm.hh	(revision 1007)
+++ oln/io/pnm.hh	(working copy)
@@ -43,6 +43,31 @@
 
     namespace internal {
 
+      // forward declaration
+      void abort();
+
+      bool read_pnm_header(std::istream& istr,
+			   char& type,
+			   int& nrows, int& ncols,
+			   bool test = false);
+
+      void read_pnm_header(char ascii, char raw,
+			   std::istream& istr,
+			   char& type,
+			   int& nrows, int& ncols);
+
+      template <typename I>
+      void load_pbm_raw(std::ifstream& file, I& ima);
+
+      template <typename I>
+      void load_pbm_ascii(std::ifstream& file, I& ima);
+
+      template <typename I>
+      void load_pnm_raw_2d(std::ifstream& file, I& ima);
+
+
+#ifndef OLN_INCLUDE_ONLY
+
       void abort()
       {
 	std::cerr << " aborting." << std::endl;
@@ -52,7 +77,7 @@
       bool read_pnm_header(std::istream& istr,
 			   char& type,
 			   int& nrows, int& ncols,
-			   bool test = false)
+			   bool test)
       {
 	// check magic
 	if (istr.get() != 'P' )
@@ -170,10 +195,18 @@
 		    len * sizeof(oln_value(I)));
       }
 
+#endif // ! OLN_INCLUDE_ONLY
 
     } // end of namespace oln::io::internal
 
 
+    // Forward declaration
+    image2d<unsigned char> load_pgm(const std::string& filename);
+    image2d<bool> load_pbm(const std::string& filename);
+
+
+#ifndef OLN_INCLUDE_ONLY
+
     image2d<bool> load_pbm(const std::string& filename)
     {
       std::ifstream file(filename.c_str());
@@ -217,6 +250,8 @@
       return ima;
     }
 
+#endif // ! OLN_INCLUDE_ONLY
+
   } // end of namespace oln::io
 
 } // end of namespace oln
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from  Nicolas Ballas  <ballas(a)lrde.epita.fr>
	Add pixel iterators to milena.
	* tests/pixter_dpoint2d.cc,
	* tests/pixter_point2d.cc: New tests.
	* mln/core/dpoints_piter.hh: Delete trailing whitespace.
	* mln/core/macros.hh: Add macro to get pixel iterator from an image.
	* mln/core/concept/image.hh,
	* mln/core/concept/doc/image.hh: Delte trailing whitespace.
	* mln/core/concept/fast_iterator.hh: New fast iterator concept.
	* mln/core/pixter2d_b.hh: New pixel iterator on image2d_b.
	* mln/core/image2d_b.hh: Add a method to get an offset from a dpoint.
	* mln/core/dpoints_pixter.hh: New pixel iterator.
 mln/core/concept/doc/image.hh           |    5 +
 mln/core/concept/fast_iterator.hh       |   79 +++++++++++++++++
 mln/core/dpoints_piter.hh               |    2 
 mln/core/dpoints_pixter.hh              |  145 ++++++++++++++++++++++++++++++++
 mln/core/image2d_b.hh                   |   21 ++++
 mln/core/internal/fast_iterator_base.hh |  138 ++++++++++++++++++++++++++++++
 mln/core/macros.hh                      |   16 +++
 mln/core/pixter2d_b.hh                  |  103 ++++++++++++++++++++++
 tests/pixter_dpoint2d.cc                |   35 +++++++
 tests/pixter_point2d.cc                 |   66 ++++++++++++++
 10 files changed, 608 insertions(+), 2 deletions(-)
Index: tests/pixter_dpoint2d.cc
--- tests/pixter_dpoint2d.cc	(revision 0)
+++ tests/pixter_dpoint2d.cc	(revision 0)
@@ -0,0 +1,35 @@
+#include <cassert>
+#include <iostream>
+#include <mln/core/image2d.hh>
+#include <mln/core/internal/set_of.hh>
+#include <mln/level/fill.hh>
+#include <mln/core/dpoints_pixter.hh>
+
+int
+main()
+{
+  using namespace mln;
+  typedef image2d<int> I;
+
+
+  I ima(20, 20);
+  level::fill(ima, 5);
+  I::piter f(ima.domain());
+  internal::set_of_<I::dpoint> set;
+
+  set.insert(mk_dpoint2d(-1, -1));
+  set.insert(mk_dpoint2d(0, -1));
+  set.insert(mk_dpoint2d(1, 0));
+  set.insert(mk_dpoint2d(1, 1));
+
+  for_all(f)
+  {
+    I::qixter dit(set, f, ima);
+
+    if (f[0] > 0 && f[1] > 0 && f[0] < 19 && f[1] < 19)
+      for_all(dit)
+      {
+      	assert(*dit == 5);
+      }
+  }
+}
Index: tests/pixter_point2d.cc
--- tests/pixter_point2d.cc	(revision 0)
+++ tests/pixter_point2d.cc	(revision 0)
@@ -0,0 +1,66 @@
+// 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.
+
+#include <cassert>
+#include <mln/core/image2d_b.hh>
+#include <iostream>
+
+
+int
+main()
+{
+  using namespace mln;
+
+  image2d_b<int> ima(2, 2);
+
+  image2d_b<int>::piter p(ima.domain());
+  image2d_b<int>::pixter f(ima);
+  int i = 0;
+
+  for_all(p)
+    {
+      ima(p) = i++;
+    }
+  i = 0;
+
+  for_all(f)
+    {
+      std::cout << *f << std::endl;
+      assert(*f == i ++);
+      *f = 5;
+    }
+
+  for_all(p)
+    {
+      assert(ima(p) == 5);
+    }
+
+  f.start();
+  assert(f.is_valid());
+  f.invalidate();
+  assert(!f.is_valid());
+}
Index: mln/core/dpoints_piter.hh
--- mln/core/dpoints_piter.hh	(revision 1006)
+++ mln/core/dpoints_piter.hh	(working copy)
@@ -88,7 +88,7 @@
 
     /// Start an iteration.
     void start();
-
+xb
     /// Go to the next point.
     void next_();
 
Index: mln/core/macros.hh
--- mln/core/macros.hh	(revision 1006)
+++ mln/core/macros.hh	(working copy)
@@ -81,13 +81,21 @@
 /// Shortcut to access the fwd_piter type associated to T.
 # define mln_fwd_piter(T)  typename T::fwd_piter
 
+/// Shortcut to access the fwd_pixter type associated to T.
+# define mln_fwd_pixter(T)  typename T::fwd_pixter
+
+/// Shortcut to access the bkd_piter type associated to T.
+# define mln_bkd_piter(T)  typename T::bkd_piter
+
 /// Shortcut to access the fwd_qiter type associated to T.
 # define mln_fwd_qiter(T)  typename T::fwd_qiter
 
+/// Shortcut to access the fwd_qixter type associated to T.
+# define mln_fwd_qixter(T)  typename T::fwd_qixter
+
 /// Shortcut to access the fwd_viter type associated to T.
 # define mln_fwd_viter(T)  typename T::fwd_viter
 
-
 // l
 
 
@@ -100,6 +108,9 @@
 /// Shortcut to access the piter type associated to T.
 # define mln_piter(T)      typename T::piter
 
+/// Shortcut to access the pixter type associated to T.
+# define mln_pixter(T)  typename T::pixter
+
 /// Shortcut to access the pset type associated to T.
 # define mln_pset(T)       typename T::pset
 
@@ -115,6 +126,9 @@
 /// Shortcut to access the qiter type associated to T.
 # define mln_qiter(T)      typename T::qiter
 
+// Shortcut to access to the qixter type associated to T
+# define mln_qixter(T)      typename T::qixter
+
 
 // n
 
Index: mln/core/concept/image.hh
Index: mln/core/concept/fast_iterator.hh
--- mln/core/concept/fast_iterator.hh	(revision 0)
+++ mln/core/concept/fast_iterator.hh	(revision 0)
@@ -0,0 +1,79 @@
+// 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_FAST_ITERATOR_HH
+# define MLN_CORE_CONCEPT_FAST_ITERATOR_HH
+
+/*! \file mln/core/concept/fast_iterator.hh
+ * \brief Definition of the concept of mln::Fast_Iterator.
+ */
+
+# include <mln/core/concept/iterator.hh>
+
+namespace mln
+{
+
+
+  template <typename E>
+  struct Fast_Iterator : public Iterator<E>
+  {
+    /*
+      typedef rvalue
+      typedef lvalue
+      rvalue operator* ();
+      lvalue operator* () const;
+    */
+  protected:
+    Fast_Iterator();
+  };
+
+#ifndef MLN_INCLUDE_ONLY
+
+  /*! \brief Fast Iterator concept class.
+   *
+   * \see FIXME
+   */
+  template <typename E>
+  Fast_Iterator<E>::Fast_Iterator()
+  {
+    typedef mln_value(E) value;
+    typedef mln_rvalue(E) rvalue;
+    typedef mln_lvalue(E) lvalue;
+
+    rvalue (E::*m1)() = &E::operator*;
+    m1 = 0;
+    lvalue (E::*m2)() const = &E::operator*;
+    m2 = 0;
+  }
+
+#endif // ! MLN_INCLUDE_ONLY
+
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_CONCEPT_FAST_ITERATOR_HH
Index: mln/core/concept/doc/image.hh
--- mln/core/concept/doc/image.hh	(revision 1006)
+++ mln/core/concept/doc/image.hh	(working copy)
@@ -162,6 +162,11 @@
       std::size_t npoints() const;
     };
 
+    template <typename E>
+    struct Fast_Image : public Image<E>
+    {
+    };
+
   } // end of namespace mln::doc
 
 } // end of namespace mln
Index: mln/core/pixter2d_b.hh
--- mln/core/pixter2d_b.hh	(revision 0)
+++ mln/core/pixter2d_b.hh	(revision 0)
@@ -0,0 +1,103 @@
+// 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_PIXTER2D_B_HH
+# define MLN_CORE_PIXTER2D_B_HH
+
+# include <mln/core/internal/fast_iterator_base.hh>
+# include <mln/core/point2d.hh>
+# include <iostream>
+
+
+//FIXME comment
+/*! \file mln/core/pixter2d_b.hh
+ *
+ * \brief Pixel iterator class on a image 2d with border.
+ */
+
+# include <mln/core/concept/fast_iterator.hh>
+
+
+namespace mln
+{
+
+  // Forward declaration
+  template <typename T> class image2d_b;
+
+  template <typename T>
+  class fwd_pixter2d_b :
+    public internal::fast_iterator_base_< fwd_pixter2d_b<T>, image2d_b<T> >
+  {
+  public:
+    /// Image pixel value type.
+    typedef mln_value(image2d_b<T>) value;
+
+    /*! \brief Constructor.
+     *
+     * \param[in] ima   Image to iterate.
+     */
+    fwd_pixter2d_b(image2d_b<T>& ima);
+    /// Move the iterator to the next elements
+    void next_();
+
+  private:
+    unsigned border_size_;
+    unsigned row_offset_;
+    value *eor_;
+  };
+
+#ifndef MLN_INCLUDE_ONLY
+
+  template <typename T>
+  fwd_pixter2d_b<T>::fwd_pixter2d_b(image2d_b<T>& ima) :
+    border_size_(ima.border()),
+    row_offset_((ima.domain().pmax()[1] - ima.domain().pmin()[1])
+		+ 2 * border_size_ + 1)
+  {
+    this->start_ = &ima(ima.domain().pmin());
+    this->eor_ = &ima(mk_point2d(ima.domain().pmin()[0], ima.domain().pmax()[1])) + 1;
+    this->eoi_ = &ima(ima.domain().pmax()) + 1;
+  }
+
+  template <typename T>
+  void fwd_pixter2d_b<T>::next_()
+  {
+    ++(this->current_);
+
+    if (this->current_ == this->eor_ and this->current_ != this->eoi_)
+    {
+      this->current_ += 2 * this->border_size_;
+      this->eor_ += this->row_offset_;
+    }
+  }
+
+#endif // ! MLN_INCLUDE_ONLY
+
+
+} // end of namespace mln
+
+#endif // ! MLN_CORE_PIXTER2D_B_HH
Index: mln/core/image2d_b.hh
--- mln/core/image2d_b.hh	(revision 1006)
+++ mln/core/image2d_b.hh	(working copy)
@@ -39,6 +39,8 @@
 
 # include <mln/border/thickness.hh>
 # include <mln/fun/all.hh>
+# include <mln/core/pixter2d_b.hh>
+# include <mln/core/dpoints_pixter.hh>
 
 
 namespace mln
@@ -64,6 +66,15 @@
     typedef fwd_piter piter;
     // end of warning
 
+    /// Forward pixel iterator associated to image2d
+    typedef fwd_pixter2d_b<T> fwd_pixter;
+
+    /// Foward pixel iterator on dpoints assoicated to image 2d
+    typedef dpoints_pixter< image2d_b<T> > fwd_qixter;
+
+    typedef fwd_pixter pixter;
+    typedef fwd_qixter qixter;
+
 
     /// Value associated type.
     typedef T         value;
@@ -131,6 +142,9 @@
     /// Read-write access to the image value located at \p p.
     T& operator()(const point2d& p);
 
+    /// Return an offset from a dpoints
+    int offset(const dpoint2d& dp);
+
     /// Destructor.
     ~image2d_b();
 
@@ -350,6 +364,13 @@
       }
   }
 
+  template <typename T>
+  int
+  image2d_b<T>::offset(const dpoint2d& dp)
+  {
+    return dp[0] * vb_.pmax()[1] + dp[1];
+  }
+
 # endif // ! MLN_INCLUDE_ONLY
 
 } // end of namespace mln
Index: mln/core/dpoints_pixter.hh
--- mln/core/dpoints_pixter.hh	(revision 0)
+++ mln/core/dpoints_pixter.hh	(revision 0)
@@ -0,0 +1,145 @@
+// 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_DPOINTS_PIXTER_HH
+# define MLN_CORE_DPOINTS_PIXTER_HH
+
+# include <cassert>
+# include <vector>
+# include <mln/core/concept/fast_iterator.hh>
+
+
+namespace mln
+{
+  /*! \brief A generic forward iterator on image pixel of a windows and of
+   *  neighborhoods.
+   *
+   * The parameter \c I is the image type.
+   */
+  template <typename I>
+  class dpoints_pixter : public Fast_Iterator< dpoints_pixter<I> >
+  {
+  public:
+    /// Image pixel value
+    typedef mln_value(I) value;
+    /// Image pixel rvalue
+    typedef mln_rvalue(I) rvalue;
+    /// Image pixel lvalue
+    typedef mln_lvalue(I) lvalue;
+
+    /*! \brief Constructo.
+     *
+     * \param[in] dps   Object that can provide an array of delta-points.
+     * \param[in] p_ref Center point to iterate around.
+     * \param[in] ima   Image to iterate.
+     */
+    template <typename Dps>
+    dpoints_pixter(const Dps& dps, const typename I::point& p_ref,I& ima);
+
+    /// Set the iterator at the start.
+    void start();
+    /// Go to the next pixel.
+    void next_();
+    /// Invalidate the iterator.
+    void invalidate();
+    ///  Is the iterator valid?
+    bool is_valid() const;
+
+    /// Get the iterator value
+    rvalue operator* ();
+    lvalue operator* () const;
+
+  private:
+    /// offset of each dpoints
+    std::vector<int> offset_;
+    /// current offset
+    std::vector<int>::iterator i_;
+    /// reference pixel in the image
+    value* pixref_;
+  };
+
+
+#ifndef MLN_INCLUDE_ONLY
+
+  template <typename I>
+  template <typename Dps>
+  dpoints_pixter<I>::dpoints_pixter(const Dps& dps, const typename I::point& ref, I& ima)
+  {
+    pixref_ = &ima(ref);
+    for (typename std::vector<typename I::dpoint>::const_iterator it = dps.vec().begin();
+	 it != dps.vec().end();
+	 ++it)
+      offset_.push_back(ima.offset(*it));
+  }
+
+
+  template <typename I>
+  void dpoints_pixter<I>::start()
+  {
+    i_ = offset_.begin();
+  }
+
+  template <typename I>
+  void dpoints_pixter<I>::next_()
+  {
+    ++i_;
+  }
+
+  template <typename I>
+  bool dpoints_pixter<I>::is_valid() const
+  {
+    return i_ != offset_.end();
+  }
+
+  template <typename I>
+  void dpoints_pixter<I>::invalidate()
+  {
+    i_ = offset_.end();
+  }
+
+  template <typename I>
+  typename dpoints_pixter<I>::rvalue
+  dpoints_pixter<I>::operator* ()
+  {
+    assert(this->is_valid());
+    return *(pixref_ + *i_);
+  }
+
+  template <typename I>
+  typename dpoints_pixter<I>::lvalue
+  dpoints_pixter<I>::operator* () const
+  {
+    assert(this->is_valid());
+    return *(pixref_ + *i_);
+  }
+
+#endif // ! MLN_INCLUDE_ONLY
+
+}
+
+
+#endif // MLN_CORE_DPOINTS_PIXTER_HH
Index: mln/core/internal/fast_iterator_base.hh
--- mln/core/internal/fast_iterator_base.hh	(revision 0)
+++ mln/core/internal/fast_iterator_base.hh	(revision 0)
@@ -0,0 +1,138 @@
+// 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_FAST_ITERATOR_BASE_HH
+# define MLN_CORE_INTERNAL_FAST_ITERATOR_BASE_HH
+
+/*! \file mln/core/internal/fast_iterator_base.hh
+ *
+ * \brief Base class for Fast_Iterator concept implementation.
+ *        Usefull for code factorisation
+ */
+
+# include <mln/core/concept/fast_iterator.hh>
+
+
+namespace mln
+{
+
+  namespace internal
+  {
+
+
+    /*! \brief fast_iterator_base_ class
+     */
+    template <typename Exact, typename Image>
+    class fast_iterator_base_ : public Fast_Iterator<Exact>
+    {
+    public:
+      /// Image pixel value type.
+      typedef mln_value(Image) value;
+      /// Image pixel rvalue type.
+      typedef mln_value(Image)& rvalue;
+      /// Image pixel lvalue type
+      typedef mln_value(Image) lvalue;
+
+      // Go to the beginning of the image.
+      void start();
+      // Go on the next element.
+      void next_();
+      // Invalidate the iterator.
+      void invalidate();
+      // Is the iterator referencing a correct position in the image?
+      bool is_valid() const;
+
+
+      // Return the current pixel.
+      rvalue operator* ();
+      lvalue operator* () const;
+
+    protected:
+      // beginning of the image
+      value* start_;
+      // end of the image
+      value* eoi_;
+      // current position in the image
+      value* current_;
+      // End of Factoriasable
+
+      fast_iterator_base_();
+    };
+
+#ifndef MLN_INCLUDE_ONLY
+
+    template <typename Exact, typename Image>
+    fast_iterator_base_<Exact, Image>::fast_iterator_base_()
+    {
+    }
+
+    template <typename Exact, typename Image>
+    void fast_iterator_base_<Exact, Image>::start()
+    {
+      current_ = start_;
+    }
+
+    template <typename Exact, typename Image>
+    void fast_iterator_base_<Exact, Image>::next_()
+    {
+      ++current_;
+    }
+
+    template <typename Exact, typename Image>
+    void fast_iterator_base_<Exact, Image>::invalidate()
+    {
+      current_ = eoi_;
+    }
+
+    template <typename Exact, typename Image>
+    bool fast_iterator_base_<Exact, Image>::is_valid() const
+    {
+      return (current_ != eoi_);
+    }
+
+    template <typename Exact, typename Image>
+    typename fast_iterator_base_<Exact, Image>::rvalue
+    fast_iterator_base_<Exact, Image>::operator*()
+    {
+      return *current_;
+    }
+
+
+    template <typename Exact, typename Image>
+    typename fast_iterator_base_<Exact, Image>::lvalue
+    fast_iterator_base_<Exact, Image>::operator*() const
+    {
+      return *current_;
+    }
+
+#endif // ! MLN_INCLUDE_ONLY
+  } // end of namespace internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_FAST_ITERATOR_BASE_HH
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0