https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Partially check point sets compatibility.
* tests/core/point_set_compatibility.cc: New test.
* tests/core/Makefile.am (check_PROGRAMS): Add
point_set_compatibility.
(point_set_compatibility_SOURCES): New.
Makefile.am | 2 +
point_set_compatibility.cc | 89 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 91 insertions(+)
Index: tests/core/point_set_compatibility.cc
--- tests/core/point_set_compatibility.cc (revision 0)
+++ tests/core/point_set_compatibility.cc (revision 0)
@@ -0,0 +1,89 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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/core/point_set_compatibility.cc
+/// \brief Tests on the compatibility of some point sites with some
+/// point sets (and their iterators).
+
+#include <mln/core/point2d.hh>
+
+#include <mln/core/p_array.hh>
+#include <mln/core/graph_psite.hh>
+#include <mln/core/p_graph_piter.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ /*--------------------------------------------------------.
+ | Compatibility of mln::graph_psite with mln::p_array and |
+ | mln::p_array_piter. |
+ `--------------------------------------------------------*/
+
+ // Graph.
+
+ // Points associated to nodes.
+ std::vector<point2d> points;
+ points.push_back(make::point2d(0,0)); // Point associated to node 0.
+ points.push_back(make::point2d(2,2)); // Point associated to node 1.
+ points.push_back(make::point2d(0,4)); // Point associated to node 2.
+ points.push_back(make::point2d(4,3)); // Point associated to node 3.
+ points.push_back(make::point2d(4,4)); // Point associated to node 4.
+
+ // Edges.
+ util::graph<point2d> g;
+ // Populate the graph with nodes.
+ for (unsigned i = 0; i < points.size(); ++i)
+ g.add_node (points[i]);
+ // Populate the graph with edges.
+ g.add_edge(0, 1);
+ g.add_edge(1, 2);
+ g.add_edge(1, 3);
+ g.add_edge(3, 4);
+ g.add_edge(4, 2);
+
+
+ // Graph point set.
+ p_graph<point2d> pg(g);
+
+
+ // Array of graph point sites.
+ typedef graph_psite<point2d> gpsite_t;
+ p_array<gpsite_t> pa;
+
+
+ // Tests: copying all psites from PG to PA.
+ p_graph_fwd_piter_<point2d> p(pg);
+ for_all (p)
+ pa.append (p);
+
+ // Test: create and use an iterator over PA.
+ p_array_fwd_piter_<gpsite_t> p2(pa);
+ for_all (p2)
+ std::cout << p2 << std::endl;
+}
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 1772)
+++ tests/core/Makefile.am (working copy)
@@ -22,6 +22,7 @@
p_queue \
p_queue_fast \
p_runs \
+ point_set_compatibility \
rle_image \
sparse_image \
t_image \
@@ -46,6 +47,7 @@
p_queue_SOURCES = p_priority_queue_fast.cc
p_queue_fast_SOURCES = p_priority_queue_fast.cc
p_runs_SOURCES = p_runs.cc
+point_set_compatibility_SOURCES = point_set_compatibility.cc
rle_image_SOURCES = rle_image.cc
sparse_image_SOURCES = sparse_image.cc
t_image_SOURCES = t_image.cc
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Start a site/psite refactorization example.
* sandbox/ballas/refactorization: New.
* sandbox/ballas/refactorization/test: New.
* sandbox/ballas/refactorization/test/test.cc: New.
* sandbox/ballas/refactorization/metal: New.
* sandbox/ballas/refactorization/metal/equal.hh: New.
* sandbox/ballas/refactorization/metal/bool.hh: New.
* sandbox/ballas/refactorization/metal/bexpr.hh: New.
* sandbox/ballas/refactorization/exact.hh: New.
* sandbox/ballas/refactorization/concept.hh: New.
* sandbox/ballas/refactorization/internal: New.
* sandbox/ballas/refactorization/internal/exact.hh: New.
* sandbox/ballas/refactorization/internal/pset_base.hh: New.
* sandbox/ballas/refactorization/internal/image_base.hh: New.
* sandbox/ballas/refactorization/internal/piter_base.hh: New.
* sandbox/ballas/refactorization/internal/site_base.hh: New.
* sandbox/ballas/refactorization/internal/psite_base.hh: New.
concept.hh | 182 +++++++++++++++++++++++++++++++++++++++++++++++++
exact.hh | 95 +++++++++++++++++++++++++
internal/exact.hh | 124 +++++++++++++++++++++++++++++++++
internal/image_base.hh | 39 ++++++++++
internal/piter_base.hh | 74 +++++++++++++++++++
internal/pset_base.hh | 22 +++++
internal/psite_base.hh | 40 ++++++++++
internal/site_base.hh | 21 +++++
metal/bexpr.hh | 80 +++++++++++++++++++++
metal/bool.hh | 99 ++++++++++++++++++++++++++
metal/equal.hh | 63 ++++++++++++++++
test/test.cc | 7 +
12 files changed, 846 insertions(+)
Index: sandbox/ballas/refactorization/test/test.cc
--- sandbox/ballas/refactorization/test/test.cc (revision 0)
+++ sandbox/ballas/refactorization/test/test.cc (revision 0)
@@ -0,0 +1,7 @@
+#include <internal/image_base.hh>
+
+
+int main()
+{
+ return 0;
+}
Index: sandbox/ballas/refactorization/metal/equal.hh
--- sandbox/ballas/refactorization/metal/equal.hh (revision 0)
+++ sandbox/ballas/refactorization/metal/equal.hh (revision 0)
@@ -0,0 +1,63 @@
+// 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_METAL_EQUAL_HH
+# define MLN_METAL_EQUAL_HH
+
+/*!
+ * \file mln/metal/equal.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <metal/bool.hh>
+
+
+# define mlc_equal(T1, T2) mln::metal::equal< T1, T2 >
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <typename T1, typename T2>
+ struct equal : false_
+ {};
+
+ template <typename T>
+ struct equal< T, T > : true_
+ {};
+
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_METAL_EQUAL_HH
Index: sandbox/ballas/refactorization/metal/bool.hh
--- sandbox/ballas/refactorization/metal/bool.hh (revision 0)
+++ sandbox/ballas/refactorization/metal/bool.hh (revision 0)
@@ -0,0 +1,99 @@
+// 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_METAL_BOOL_HH
+# define MLN_METAL_BOOL_HH
+
+/*! \file mln/metal/bool.hh
+ *
+ * \brief Definition of a Boolean value type.
+ */
+
+# include <string>
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ // Fwd decl.
+ template <bool b> struct bool_;
+
+
+ /// "true" type.
+ template <>
+ struct bool_< true >
+ {
+ typedef bool_<true> check_t;
+ static const bool value = true;
+ typedef bool_<true> eval;
+ static void check();
+ std::string name() const { return "true"; }
+ };
+
+ typedef bool_<true> true_;
+
+
+ /// "false" type.
+ template <>
+ struct bool_< false >
+ {
+ typedef bool_<false> check_not_t;
+ static const bool value = false;
+ typedef bool_<false> eval;
+ static void check_not();
+ std::string name() const { return "false"; }
+ };
+
+ typedef bool_<false> false_;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ inline
+ void true_::check()
+ {
+ }
+
+ inline
+ void false_::check_not()
+ {
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+# include <metal/bexpr.hh>
+
+
+#endif // ! MLN_METAL_BOOL_HH
Index: sandbox/ballas/refactorization/metal/bexpr.hh
--- sandbox/ballas/refactorization/metal/bexpr.hh (revision 0)
+++ sandbox/ballas/refactorization/metal/bexpr.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_METAL_BEXPR_HH
+# define MLN_METAL_BEXPR_HH
+
+/*! \file mln/metal/bexpr.hh
+ *
+ * \brief Definition of types for static Boolean expressions.
+ */
+
+# include <metal/bool.hh>
+
+
+# define mlc_not( B ) mln::metal::not_< B >
+# define mlc_and( B1, B2 ) mln::metal::and_< B1, B2 >
+# define mlc_or( B1, B2 ) mln::metal::or_ < B1, B2 >
+# define mlc_xor( B1, B2 ) mln::metal::xor_< B1, B2 >
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ /// Negate type.
+ template <typename B>
+ struct not_ : bool_<( ! B::value )>
+ {};
+
+
+ /// And type.
+ template <typename L, typename R>
+ struct and_ : bool_<( L::value && R::value )>
+ {};
+
+
+ /// Or type.
+ template <typename L, typename R>
+ struct or_ : bool_<( L::value || R::value )>
+ {};
+
+
+ /// Xor type.
+ template <typename L, typename R>
+ struct xor_ : bool_<( L::value ^ R::value )>
+ {};
+
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_METAL_BOOL_HH
Index: sandbox/ballas/refactorization/exact.hh
--- sandbox/ballas/refactorization/exact.hh (revision 0)
+++ sandbox/ballas/refactorization/exact.hh (revision 0)
@@ -0,0 +1,95 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_EXACT_HH
+# define MLN_CORE_EXACT_HH
+
+/*! \file mln/core/exact.hh
+ * \brief Definition of the mln::exact downcast routines.
+ */
+
+#include <internal/exact.hh>
+
+
+/// FIXME: Doc!
+#define mln_exact(T) typename internal::exact_<T>::ret
+
+
+
+namespace mln
+{
+
+ /*! \brief Exact cast routine for mln objects.
+ *
+ * This set of routines can be used to downcast an object towards
+ * its exact type. The only argument, respectively \p ptr or \p
+ * ref, should be an mln::Object.
+ *
+ * \c The parameter E is the exact type of the object.
+ *
+ * \return The return follows the nature of the argument (either a
+ * pointer or a reference, const or not).
+ */
+ /// \{
+
+ template <typename T>
+ typename internal::exact_<T>::ret*
+ exact(T* ptr);
+
+ template <typename T>
+ typename internal::exact_<T>::ret&
+ exact(T& ref);
+
+ /// \}
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // exact
+
+ template <typename T>
+ inline
+ typename internal::exact_<T>::ret*
+ exact(T* ptr)
+ {
+ return internal::exact_<T>::run(ptr);
+ }
+
+ template <typename T>
+ inline
+ typename internal::exact_<T>::ret&
+ exact(T& ref)
+ {
+ return *exact(&ref);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_EXACT_HH
Index: sandbox/ballas/refactorization/concept.hh
--- sandbox/ballas/refactorization/concept.hh (revision 0)
+++ sandbox/ballas/refactorization/concept.hh (revision 0)
@@ -0,0 +1,182 @@
+#ifndef CORE_CONCEPT_HH_
+# define CORE_CONCEPT_HH_
+
+# include <cassert>
+
+/// This file describes all the concepts
+
+namespace mln
+{
+
+ /// Object
+ template <typename E>
+ struct Object
+ {
+ typedef E exact_t;
+ protected:
+ Object();
+ };
+
+ /// Site concept
+ template <typename E>
+ struct Site : public Object<E>
+ {
+ /*
+ typedef site
+ typedef dsite;
+
+ const psite& ref_();
+ */
+ protected:
+ Site();
+ };
+
+
+ /// Psite Concept
+ /// Do we need a concept for representing psite?
+ template <typename E>
+ struct Psite : public Object<E>
+ {
+ /*
+ // Site must be different from psite,
+ // if site = psite, then the psite has no sense.
+ typedef site;
+ typedef psite;
+
+ // Site conversion
+ const site& to_site() const;
+ operator point() const;
+
+
+ const psite& ref_();
+ */
+
+ protected:
+ Psite();
+ };
+
+ /// Piter concept
+ /// Psite iterator
+ /// use template specializaion for psite == site or psite != psite
+ /// to deal with the cast problem
+ template <typename E>
+ struct Piter : public Object<E>
+ {
+ /*
+ bool is_valid() const;
+ void start();
+ void next_();
+
+ typedef psite;
+ const psite& to_psite() const;
+ operator psite() const;
+
+ typedef site;
+ const site& to_site() const;
+ operator site() const;
+ */
+
+ void next();
+ protected:
+ Piter();
+ };
+
+ /// Pset
+ /// Psite set
+ template <typename E>
+ struct Pset : public Object<E>
+ {
+ /*
+ typedef psite;
+ typedef fwd_piter;
+ typedef bkd_piter;
+
+ bool has(const psite& p) const;
+ */
+ protected:
+ Pset();
+ };
+
+
+ ///FIXME values concepts:....
+
+ /// Image concept:
+ template <typename E>
+ struct Image : public Object<E>
+ {
+ /*
+ typedef values;
+ typedef rvalues;
+ typedef lvalues;
+ //typedef vset;
+ //const vset& destination() const;
+ // const vset& values() const;
+ bool is_ready();
+
+ typedef site;
+ typedef psite;
+ rvalue operator() (const psite&) const;
+ lvalue operator() (const psite);
+ bool owns_(const psite&) const;
+ bool has(const psite&) const;
+
+ typedef fwd_piter;
+ typedef bkd_piter;
+ */
+
+ protected:
+ Image();
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /// Object
+ template <typename E>
+ inline
+ Object<E>::Object()
+ {
+ }
+
+ /// Site
+ template <typename E>
+ inline
+ Site<E>::Site()
+ {
+ /// FIXME
+ }
+
+ /// Psite
+ template <typename E>
+ inline
+ Psite<E>::Psite()
+ {
+ }
+
+ /// Piter
+ template <typename E>
+ inline
+ Piter<E>::Piter()
+ {
+ }
+
+ template <typename E>
+ void
+ Piter<E>::next()
+ {
+ exact(this)->next_();
+ }
+
+ template <typename E>
+ Image<E>::Image()
+ {
+ /// FIXME
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+}
+
+
+
+#endif // ! CORE_CONCEPT_HH_
Index: sandbox/ballas/refactorization/internal/exact.hh
--- sandbox/ballas/refactorization/internal/exact.hh (revision 0)
+++ sandbox/ballas/refactorization/internal/exact.hh (revision 0)
@@ -0,0 +1,124 @@
+// 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_EXACT_HH
+# define MLN_CORE_INTERNAL_EXACT_HH
+
+/*! \file mln/core/internal/exact.hh
+ * \brief Meta-code for the mln::exact downcast routines.
+ */
+
+# include <concept.hh>
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ typedef char yes_;
+ struct no_ { char dummy[2]; };
+
+ template <typename T>
+ struct make_
+ {
+ static T* ptr();
+ };
+
+ template <unsigned id, typename T>
+ struct exact_ret_;
+
+ template <typename T>
+ struct exact_ret_< 1, T >
+ {
+ typedef typename T::exact_t ret;
+ };
+
+ template <typename T>
+ struct exact_ret_< 2, T >
+ {
+ typedef T ret;
+ };
+
+ template <typename E>
+ yes_ exact_selector_(Object<E>*);
+
+ no_ exact_selector_(void*);
+
+ template <typename E, typename T>
+ E* exact_run_(Object<E>* t, T*);
+
+ template <typename T>
+ T* exact_run_(void*, T* t);
+
+ template <typename T>
+ struct exact_
+ {
+ enum { id = sizeof(exact_selector_(make_<T>::ptr())) };
+ typedef typename exact_ret_<id, T>::ret ret;
+ static ret* run(T* t)
+ {
+ return exact_run_(t, t);
+ }
+ };
+
+ template <typename T>
+ struct exact_<const T>
+ {
+ enum { id = sizeof(exact_selector_(make_<T>::ptr())) };
+ typedef const typename exact_ret_<id, T>::ret ret;
+ static ret* run(const T* t)
+ {
+ return exact_run_((T*)t, (T*)t);
+ }
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E, typename T>
+ inline
+ E* exact_run_(Object<E>* t, T*)
+ {
+ return (E*)(void*)t;
+ }
+
+ template <typename T>
+ inline
+ T* exact_run_(void*, T* t)
+ {
+ return t;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_EXACT_HH
Index: sandbox/ballas/refactorization/internal/pset_base.hh
--- sandbox/ballas/refactorization/internal/pset_base.hh (revision 0)
+++ sandbox/ballas/refactorization/internal/pset_base.hh (revision 0)
@@ -0,0 +1,22 @@
+#ifndef INTERNAL_PSET_BASE_HH_
+# define INTERNAL_PSET_BASE_HH_
+
+
+namespace mln
+{
+ namespace internal
+ {
+ /// pset base class
+ /// P is the psite type
+ /// FIXME: psite = site => Do we declare a site
+ /// typedef in site_base class?
+ template <typename P, typename E>
+ struct pset_base_
+ {
+ typedef typename P::site site;
+ typedef P psite;
+ };
+ }
+}
+
+#endif // ! INTENAL_PSET_BASE_HH_
Index: sandbox/ballas/refactorization/internal/image_base.hh
--- sandbox/ballas/refactorization/internal/image_base.hh (revision 0)
+++ sandbox/ballas/refactorization/internal/image_base.hh (revision 0)
@@ -0,0 +1,39 @@
+#ifndef INTERNAL_IMAGE_BASE_HH_
+# define INTERNAL_IMAGE_BASE_HH_
+
+#include <concept.hh>
+
+namespace mln
+{
+ namespace internal
+ {
+ /// Image base
+ /// S is the point set type
+ template <typename S, typename E>
+ struct image_base_ : public Image<E>
+ {
+ typedef S pset;
+ typedef typename S::psite psite;
+ typedef typename S::site site;
+
+ typedef typename S::fwd_piter fwd_piter;
+ typedef typename S::bkd_piter bkd_piter;
+
+ protected:
+ image_base_();
+ };
+
+ ///FIXME: is_ready
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename S, typename E>
+ image_base_<S, E>::image_base_()
+ {
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+ }
+}
+
+#endif // ! INTERNAL_IMAGE_BASE_HH_
Index: sandbox/ballas/refactorization/internal/piter_base.hh
--- sandbox/ballas/refactorization/internal/piter_base.hh (revision 0)
+++ sandbox/ballas/refactorization/internal/piter_base.hh (revision 0)
@@ -0,0 +1,74 @@
+#ifndef INTERNAL_PITER_BASE_HH_
+# define INTERNAL_PITER_BASE_HH_
+
+# include <concept.hh>
+# include <exact.hh>
+# include <metal/bool.hh>
+# include <metal/equal.hh>
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ /// fwd declaration
+ template <typename E, typename B>
+ struct piter_base_site_cast;
+
+ /// Psite = Site
+ template <typename E>
+ struct piter_base_site_cast<E, metal::true_> : public Piter<E>
+ {
+ };
+
+ /// Psite != site
+ template <typename E>
+ struct piter_base_site_cast<E, metal::false_> : public Piter<E>
+ {
+ operator typename E::site() const;
+ };
+
+ /// Piter base
+ template <typename E>
+ struct piter_base_ :
+ public piter_base_site_cast<E,
+ typename mlc_equal(typename E::site,
+ typename E::psite)::eval>
+ {
+ operator typename E::psite() const;
+
+ protected:
+ piter_base_();
+
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E>
+ piter_base_site_cast<E, metal::false_>::operator typename E::site () const
+ {
+ return exact(this)->to_site();
+ }
+
+
+ template <typename E>
+ piter_base_<E>::operator typename E::psite () const
+ {
+ return exact(this)->to_site();
+ }
+
+
+ template <typename E>
+ piter_base_<E>::piter_base_()
+ {
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ }
+
+}
+
+
+#endif // !INTERNAL_PITER_BASE_HH_
Index: sandbox/ballas/refactorization/internal/site_base.hh
--- sandbox/ballas/refactorization/internal/site_base.hh (revision 0)
+++ sandbox/ballas/refactorization/internal/site_base.hh (revision 0)
@@ -0,0 +1,21 @@
+#ifndef INTERNAL_SITE_BASE_HH_
+# define INTERNAL_SITE_BASE_HH_
+
+# include <concept>
+
+namespace mln
+{
+ namespace internal
+ {
+
+ /// Site base class
+ template <typename S, typename E>
+ struct site_base_ : public site_base_<E>
+ {
+ typedef S site;
+ };
+ }
+}
+
+
+#endif // ! INTERNAL_SITE_BASE_HH_
Index: sandbox/ballas/refactorization/internal/psite_base.hh
--- sandbox/ballas/refactorization/internal/psite_base.hh (revision 0)
+++ sandbox/ballas/refactorization/internal/psite_base.hh (revision 0)
@@ -0,0 +1,40 @@
+#ifndef INTERNAL_PSITE_BASE_HH_
+# define INTERNAL_PSITE_BASE_HH_
+
+# include <concept.hh>
+# include <exact.hh>
+
+namespace mln
+{
+ namespace internal
+ {
+
+ template <typename E>
+ struct psite_base : public Psite<E>
+ /// FIXME Get implementation
+ {
+ operator typename E::psite () const;
+
+ protected:
+ psite_base();
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E>
+ psite_base<E>::operator typename E::psite () const
+ {
+ return exact(this)->to_site();
+ }
+
+ template <typename E>
+ psite_base<E>::psite_base()
+ {
+ }
+
+# endif // !MLN_INCLUDE_ONLY
+
+ }
+}
+
+#endif // ! INTERNAL_PSITE_BASE_HH_
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Subsampling. Draft icp.
* mln/subsampling: New.
* mln/subsampling/subsampling.hh: New.
* mln/subsampling/gaussian_subsampling.hh: gaussian blur + subsampling.
* mln/algebra: New.
* mln/algebra/vec.hh: Copy of metal::vec.
* sandbox/jardonnet/test/gaussian_subsampling.cc: New Test.
* sandbox/jardonnet/subsampling/subsampling_2d.hh: Remove.
* sandbox/jardonnet/subsampling/gaussian_subsampling.hh: New.
* sandbox/jardonnet/registration: New.
* sandbox/jardonnet/registration/icp.hh: Draft.
mln/algebra/vec.hh | 562 ++++++++++++++++++
mln/linear/gaussian.hh | 1
mln/subsampling/gaussian_subsampling.hh | 93 ++
mln/subsampling/subsampling.hh | 117 +++
sandbox/jardonnet/registration/icp.hh | 122 +++
sandbox/jardonnet/subsampling/gaussian_subsampling.hh | 93 ++
sandbox/jardonnet/test/Makefile | 12
sandbox/jardonnet/test/gaussian_subsampling.cc | 21
sandbox/jardonnet/test/subsampling.cc | 6
9 files changed, 1021 insertions(+), 6 deletions(-)
Index: mln/subsampling/subsampling.hh
--- mln/subsampling/subsampling.hh (revision 0)
+++ mln/subsampling/subsampling.hh (revision 0)
@@ -0,0 +1,117 @@
+// Copyright (C) 2008 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_SUBSAMPLING_SUBSAMPLING_HH
+# define MLN_SUBSAMPLING_SUBSAMPLING_HH
+
+/*! \file mln/binarization/threshold.hh
+ *
+ * \brief Produce a subsampled image
+ */
+
+# include <mln/geom/ncols.hh>
+# include <mln/geom/nrows.hh>
+
+
+namespace mln
+{
+
+ namespace subsampling
+ {
+
+ /*! Subsampling FIXME : doxy
+ *
+ *
+ */
+ template <typename I>
+ inline
+ mln_concrete(I)
+ subsampling(const Image<I>& input,
+ const mln_dpoint(I)& first_p,
+ const mln_coord(I)& gap);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ //FIXME : add version for every image types.
+
+ template <typename T>
+ inline
+ mln_concrete(image2d<T>)
+ subsampling_(const image2d<T>& input,
+ const mln_dpoint(image2d<T>)& first_p,
+ const mln_coord(image2d<T>)& gap)
+ {
+ trace::entering("subsampling::impl::subsampling_");
+ mln_concrete(image2d<T>) output(geom::nrows(input) / gap,
+ geom::ncols(input) / gap);
+
+ for (unsigned j = 0; j < geom::ncols(output); ++j)
+ for (unsigned i = 0; i < geom::nrows(output); ++i)
+ {
+ point2d p1(i, j);
+ point2d p2(first_p[0] + i * gap, first_p[1] + j * gap);
+
+ output(p1) = input(p2);
+ }
+
+ trace::exiting("subsampling::impl::subsampling_");
+ return output;
+ }
+
+ } // end of namespace mln::subsampling::impl
+
+
+ template <typename I>
+ inline
+ mln_concrete(I)
+ subsampling(const Image<I>& input,
+ const mln_dpoint(I)& first_p,
+ const mln_coord(I)& gap)
+ {
+ trace::entering("subsampling::subsampling");
+ mln_precondition(exact(input).has_data());
+
+ mln_concrete(I) output(geom::nrows(input) / gap,
+ geom::ncols(input) / gap); // FIXME: only 2d here
+
+ output = impl::subsampling_(exact(input), first_p, gap);
+
+ trace::exiting("subsampling::subsampling");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::subsampling
+
+} // end of namespace mln
+
+
+#endif // ! MLN_SUBSAMPLING_SUBSAMPLING_HH
Index: mln/subsampling/gaussian_subsampling.hh
--- mln/subsampling/gaussian_subsampling.hh (revision 0)
+++ mln/subsampling/gaussian_subsampling.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2008 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_SUBSAMPLING_GAUSSIAN_SUBSAMPLING_HH
+# define MLN_SUBSAMPLING_GAUSSIAN_SUBSAMPLING_HH
+
+/*! \file mln/binarization/threshold.hh
+ *
+ * \brief Produce a subsampled image
+ */
+
+# include <mln/geom/ncols.hh>
+# include <mln/geom/nrows.hh>
+
+
+# include <mln/linear/gaussian.hh>
+# include <mln/subsampling/subsampling.hh>
+
+
+
+namespace mln
+{
+
+ namespace subsampling
+ {
+
+ /*! Gaussian subsampling FIXME : doxy
+ *
+ *
+ */
+ template <typename I>
+ inline
+ mln_concrete(I)
+ gaussian_subsampling(const Image<I>& input, float sigma
+ const mln_dpoint(I)& first_p,
+ const mln_coord(I)& gap);
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I>
+ inline
+ mln_concrete(I)
+ gaussian_subsampling(const Image<I>& input, float sigma,
+ const mln_dpoint(I)& first_p,
+ const mln_coord(I)& gap)
+ {
+ trace::entering("subsampling::gaussian_subsampling");
+ mln_precondition(exact(input).has_data());
+
+ mln_concrete(I) temp(exact(input).domain());
+ mln_concrete(I) output(geom::nrows(input) / gap,
+ geom::ncols(input) / gap); //FIXME : image2d only
+
+ linear::gaussian(input, 0.1, temp);
+ output = impl::subsampling_(exact(temp), first_p, gap);
+
+ trace::exiting("subsampling::gaussian_subsampling");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::subsampling
+
+} // end of namespace mln
+
+
+#endif // ! MLN_SUBSAMPLING_GAUSSIAN_SUBSAMPLING_HH
Index: mln/linear/gaussian.hh
--- mln/linear/gaussian.hh (revision 1765)
+++ mln/linear/gaussian.hh (working copy)
@@ -1,3 +1,4 @@
+
// Copyright (C) 2001, 2002, 2003, 2004 EPITA Research and Development
// Laboratory
//
Index: mln/algebra/vec.hh
--- mln/algebra/vec.hh (revision 0)
+++ mln/algebra/vec.hh (revision 0)
@@ -0,0 +1,562 @@
+// Copyright (C) 2006 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_ALGEBRA_VEC_HH
+# define MLN_ALGEBRA_VEC_HH
+
+/*!
+ * \file mln/algebra/vec.hh
+ *
+ * \brief Definition of a generic vector class.
+ */
+
+# include <iostream>
+# include <cmath>
+
+# include <mln/core/concept/object.hh>
+
+# include <mln/trait/all.hh>
+# include <mln/trait/value_.hh>
+# include <mln/fun/i2v/all_to.hh>
+# include <mln/debug/format.hh>
+
+# include <mln/value/ops.hh>
+
+
+// FIXME: Document.
+
+
+namespace mln
+{
+
+ // Fwd decls.
+ namespace algebra {
+ template <unsigned n, typename T> class vec;
+ }
+ namespace literal {
+ struct zero_t;
+ }
+ template <unsigned d, typename C> struct h_vec;
+
+
+
+ namespace trait
+ {
+
+ template <unsigned n, typename T>
+ struct value_< mln::algebra::vec<n,T> >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = n * mln_nbits(T),
+ card = n * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef algebra::vec<n, mln_sum(T)> sum;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ namespace algebra
+ {
+
+ namespace internal
+ {
+
+ template <unsigned n, typename T>
+ class vec_base_ : public Object< vec<n,T> >
+ {
+ protected:
+ T data_[n];
+ };
+
+ template <typename T>
+ class vec_base_ <1, T> : public Object< vec<1,T> >
+ {
+ public:
+ void set(const T& val0)
+ {
+ data_[0] = val0;
+ }
+ protected:
+ T data_[1];
+ };
+
+ template <typename T>
+ class vec_base_ <2, T> : public Object< vec<2,T> >
+ {
+ public:
+ void set(const T& val0, const T& val1)
+ {
+ data_[0] = val0;
+ data_[1] = val1;
+ }
+ protected:
+ T data_[2];
+ };
+
+ template <typename T>
+ class vec_base_ <3, T> : public Object< vec<3,T> >
+ {
+ public:
+ void set(const T& val0, const T& val1, const T& val2)
+ {
+ data_[0] = val0;
+ data_[1] = val1;
+ data_[2] = val2;
+ }
+ protected:
+ T data_[3];
+ };
+
+ template <typename T>
+ class vec_base_ <4, T> : public Object< vec<4,T> >
+ {
+ public:
+ void set(const T& val0, const T& val1, const T& val2, const T& val3)
+ {
+ data_[0] = val0;
+ data_[1] = val1;
+ data_[2] = val2;
+ data_[3] = val3;
+ }
+ protected:
+ T data_[4];
+ };
+
+
+ } // end of namespace mln::algebra::internal
+
+
+
+ template <unsigned n, typename T>
+ class vec : public internal::vec_base_<n, T>
+ {
+ typedef internal::vec_base_<n, T> super_;
+
+ protected:
+ using super_::data_;
+
+ public:
+
+ typedef T equiv[n];
+ typedef T enc[n];
+
+ typedef T coord;
+ enum { dim = n };
+
+ vec();
+
+ /// \{ Constructors/assignments with literal zero.
+ vec(const literal::zero_t&);
+ vec& operator=(const literal::zero_t&);
+ /// \}
+
+ vec(const vec<n, T>& rhs);
+
+ template <typename U>
+ vec(const vec<n, U>& rhs);
+
+ template <typename U>
+ vec& operator=(const vec<n, U>& rhs);
+
+
+ // Immersion of the vector into its homogeneous space.
+ h_vec<n, T> to_h_vec() const;
+
+
+ const T& operator[](unsigned i) const;
+
+ T& operator[](unsigned i);
+
+ void set_all(const T& val);
+
+ unsigned size() const;
+
+ const vec<n, T>& normalize();
+
+ /// Constructor; coordinates are set by function \p f.
+ template <typename F>
+ vec(const Function_i2v<F>& f);
+
+ /// Zero value.
+ static const vec<n, T> zero;
+
+ /// Origin value.
+ static const vec<n, T> origin;
+ };
+
+ } // end of namespace mln::algebra
+
+
+ namespace trait
+ {
+
+ // For unary traits.
+
+ template < template <class> class Name,
+ unsigned n, typename T >
+ struct set_precise_unary_< Name, algebra::vec<n, T> >
+ {
+ typedef mln_trait_unary(Name, T) V;
+ typedef algebra::vec<n, V> ret;
+ };
+
+ // For binary traits.
+
+ template < template <class, class> class Name,
+ unsigned n, typename T,
+ typename U >
+ struct set_precise_binary_< Name,
+ algebra::vec<n, T>, algebra::vec<n, U> >
+ {
+ typedef mln_trait_binary(Name, T, U) V;
+ typedef algebra::vec<n, V> ret;
+ };
+
+ template < unsigned n, typename T,
+ typename U >
+ struct set_precise_binary_< op::times,
+ algebra::vec<n, T>, algebra::vec<n, U> >
+ {
+ typedef mln_sum_x(T,U) ret;
+ };
+
+ template < template <class, class> class Name,
+ unsigned n, typename T,
+ typename S >
+ struct set_precise_binary_< Name,
+ algebra::vec<n, T>, mln::value::scalar_<S> >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef algebra::vec<n, V> ret;
+ };
+
+ template < template<class, class> class Name,
+ unsigned n, typename T,
+ typename S >
+ struct set_binary_< Name,
+ mln::Object, algebra::vec<n, T>,
+ mln::value::Scalar, S >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef algebra::vec<n, V> ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ namespace algebra
+ {
+
+ // eq
+
+ template <unsigned n, typename T, typename U>
+ bool operator==(const vec<n,T>& lhs, const vec<n,U>& rhs);
+
+ // +
+
+ template <unsigned n, typename T, typename U>
+ vec<n, mln_trait_op_plus(T,U)>
+ operator+(const vec<n,T>& lhs, const vec<n,U>& rhs);
+
+ // -
+
+ template <unsigned n, typename T, typename U>
+ vec<n, mln_trait_op_minus(T,U)>
+ operator-(const vec<n,T>& lhs, const vec<n,U>& rhs);
+
+ // vec * vec
+
+ template <unsigned n, typename T, typename U>
+ mln_sum_x(T,U)
+ operator*(const vec<n,T>& lhs, const vec<n,U>& rhs);
+
+ // vec * s
+
+ template <unsigned n, typename T, typename S>
+ vec<n, mln_trait_op_times(T, S)>
+ operator*(const vec<n,T>& lhs, const mln::value::scalar_<S>& s);
+
+ // vec / s
+
+ template <unsigned n, typename T, typename S>
+ vec<n, mln_trait_op_div(T, S)>
+ operator/(const vec<n,T>& lhs, const mln::value::scalar_<S>& s);
+
+ // <<
+
+ template <unsigned n, typename T>
+ std::ostream&
+ operator<<(std::ostream& ostr, const vec<n,T>& v);
+
+ // vprod // FIXME: Generalize...
+
+ template <typename T, typename U>
+ vec<3, mln_trait_op_times(T,U)> // FIXME: Sum of product...
+ vprod(const vec<3, T>& lhs, const vec<3, U>& rhs);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned n, typename T>
+ inline
+ vec<n,T>::vec()
+ {
+ }
+
+ template <unsigned n, typename T>
+ inline
+ vec<n,T>::vec(const literal::zero_t&)
+ {
+ this->set_all(0);
+ }
+
+ template <unsigned n, typename T>
+ inline
+ vec<n,T>&
+ vec<n,T>::operator=(const literal::zero_t&)
+ {
+ this->set_all(0);
+ return *this;
+ }
+
+ template <unsigned n, typename T>
+ inline
+ vec<n,T>::vec(const vec<n,T>& rhs)
+ : super_()
+ {
+ for (unsigned i = 0; i < n; ++i)
+ data_[i] = rhs[i];
+ }
+
+ template <unsigned n, typename T>
+ template <typename U>
+ inline
+ vec<n,T>::vec(const vec<n, U>& rhs)
+ : super_()
+ {
+ for (unsigned i = 0; i < n; ++i)
+ data_[i] = rhs[i];
+ }
+
+ template <unsigned n, typename T>
+ template <typename U>
+ inline
+ vec<n,T>& vec<n,T>::operator=(const vec<n, U>& rhs)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ data_[i] = rhs[i];
+ return *this;
+ }
+
+ template <unsigned n, typename T>
+ inline
+ const T& vec<n,T>::operator[](unsigned i) const
+ {
+ mln_precondition(i < dim);
+ return data_[i];
+ }
+
+ template <unsigned n, typename T>
+ inline
+ T& vec<n,T>::operator[](unsigned i)
+ {
+ mln_precondition(i < dim);
+ return data_[i];
+ }
+
+ template <unsigned n, typename T>
+ inline
+ void vec<n,T>::set_all(const T& val)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ data_[i] = val;
+ }
+
+ template <unsigned n, typename T>
+ inline
+ unsigned vec<n,T>::size() const
+ {
+ return n;
+ }
+
+ template <unsigned n, typename T>
+ inline
+ const vec<n, T>& vec<n, T>::normalize()
+ {
+ float n_l2 = 0;
+ for (unsigned i = 0; i < n; ++i)
+ n_l2 += data_[i] * data_[i];
+ n_l2 = sqrt(n_l2);
+ for (unsigned i = 0; i < n; ++i)
+ data_[i] = T(data_[i] / n_l2);
+ return *this;
+ }
+
+ template <unsigned n, typename T>
+ template <typename F>
+ inline
+ vec<n, T>::vec(const Function_i2v<F>& f_)
+ {
+ mlc_converts_to(mln_result(F), T)::check();
+ const F& f = exact(f_);
+ for (unsigned i = 0; i < n; ++i)
+ data_[i] = f(i);
+ }
+
+
+ template <unsigned n, typename T>
+ const vec<n, T> vec<n, T>::zero = all_to(0);
+
+ template <unsigned n, typename T>
+ const vec<n, T> vec<n, T>::origin = all_to(0);
+
+
+ // Operators.
+
+
+ template <unsigned n, typename T, typename U>
+ inline
+ bool operator==(const vec<n,T>& lhs, const vec<n,U>& rhs)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ if (lhs[i] != rhs[i])
+ return false;
+ return true;
+ }
+
+
+ template <unsigned n, typename T, typename U>
+ inline
+ vec<n, mln_trait_op_plus(T,U)>
+ operator+(const vec<n,T>& lhs, const vec<n,U>& rhs)
+ {
+ vec<n, mln_trait_op_plus(T,U)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = lhs[i] + rhs[i];
+ return tmp;
+ }
+
+ template <unsigned n, typename T, typename U>
+ inline
+ vec<n, mln_trait_op_minus(T,U)>
+ operator-(const vec<n,T>& lhs, const vec<n,U>& rhs)
+ {
+ vec<n, mln_trait_op_minus(T,U)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = lhs[i] - rhs[i];
+ return tmp;
+ }
+
+ template <unsigned n, typename T, typename U>
+ inline
+ mln_sum_x(T,U)
+ operator*(const vec<n,T>& lhs, const vec<n,U>& rhs)
+ {
+ mln_sum_x(T,U) tmp(literal::zero);
+ for (unsigned i = 0; i < n; ++i)
+ tmp += lhs[i] * rhs[i];
+ return tmp;
+ }
+
+ template <unsigned n, typename T, typename S>
+ inline
+ vec<n, mln_trait_op_times(T, S)>
+ operator*(const vec<n,T>& lhs, const mln::value::scalar_<S>& s)
+ {
+ // FIXME: We made a choice here but is it correct?
+ // FIXME: We "un-scalar" s so that the scalar status do not propagate.
+
+ // Think of the case: vec<mat> v * scalar(vec w) s
+ // It gives: for all i, v[i] * w so the i-th mat * vec w -> vec
+ // The result is a vec<vec>
+
+ // If we really want to propage the "scalar" status then
+ // we shall allow for scalar(scalar(..)) !!! => FIXME
+
+ vec<n, mln_trait_op_times(T, S)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = lhs[i] * s.to_equiv();
+ return tmp;
+ }
+
+ template <unsigned n, typename T, typename S>
+ inline
+ vec<n, mln_trait_op_div(T, S)>
+ operator/(const vec<n,T>& lhs, const mln::value::scalar_<S>& s)
+ {
+ mln_precondition(value::equiv(s) != literal::zero);
+ vec<n, mln_trait_op_div(T, S)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = lhs[i] / s.to_equiv();
+ return tmp;
+ }
+
+
+ template <unsigned n, typename T>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr, const vec<n,T>& v)
+ {
+ ostr << '(';
+ for (unsigned i = 0; i < n; ++i)
+ ostr << debug::format(v[i]) << (i == n - 1 ? ")" : ", ");
+ return ostr;
+ }
+
+ // vprod
+
+ template <typename T, typename U>
+ inline
+ vec<3, mln_trait_op_times(T,U)> // FIXME: typename binary_arith_trait<T, U>::ret>
+ vprod(const vec<3, T>& lhs, const vec<3, U>& rhs)
+ {
+ vec<3, mln_trait_op_times(T,U)> tmp; // FIXME: Likewise.
+ tmp[0] = lhs[1] * rhs[2] - lhs[2] * rhs[1];
+ tmp[1] = lhs[2] * rhs[0] - lhs[0] * rhs[2];
+ tmp[2] = lhs[0] * rhs[1] - lhs[1] * rhs[0];
+ return tmp;
+ }
+
+# endif // MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::algebra
+
+} // end of namespace mln
+
+
+# include <mln/make/vec.hh>
+
+
+#endif // ! MLN_ALGEBRA_VEC_HH
Index: sandbox/jardonnet/test/gaussian_subsampling.cc
--- sandbox/jardonnet/test/gaussian_subsampling.cc (revision 0)
+++ sandbox/jardonnet/test/gaussian_subsampling.cc (revision 0)
@@ -0,0 +1,21 @@
+#include <mln/core/image2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <sandbox/jardonnet/subsampling/gaussian_subsampling.hh>
+
+
+int main(int argc, char*)
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> img;
+
+ io::pgm::load(img, "../../../img/lena.pgm");
+
+ image2d<int_u8> output = subsampling::gaussian_subsampling(img, make::dpoint2d(1,1), argc);
+
+ io::pgm::save(output, "gsub.pgm");
+}
Index: sandbox/jardonnet/test/subsampling.cc
--- sandbox/jardonnet/test/subsampling.cc (revision 1765)
+++ sandbox/jardonnet/test/subsampling.cc (working copy)
@@ -3,7 +3,7 @@
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
-#include <sandbox/jardonnet/subsampling/subsampling_2d.hh>
+#include <mln/subsampling/subsampling.hh>
int main(int argc, char*)
@@ -16,7 +16,7 @@
io::pgm::load(img, "../../../img/lena.pgm");
std::cout << geom::nrows(img) << geom::ncols(img) << std::endl;
- image2d<int_u8> output = subsampling::subsampling_2d(img, make::dpoint2d(1,1), argc);
+ image2d<int_u8> output = subsampling::subsampling(img, make::dpoint2d(1,1), argc);
- io::pgm::save(output, "out1.pgm");
+ io::pgm::save(output, "sub.pgm");
}
Index: sandbox/jardonnet/test/Makefile
--- sandbox/jardonnet/test/Makefile (revision 1765)
+++ sandbox/jardonnet/test/Makefile (working copy)
@@ -1,8 +1,14 @@
SOURCE=test.cc subsampling.cc
FLAG=-Wall -W -I../../.. -g
-all:
- g++ $(SOURCE) $(FLAG) -o '+a.out'
+all: sub gsub
+
sub:
- g++ subsampling.cc $(FLAG) -o '+a.out'
+ g++ subsampling.cc $(FLAG) -o '+sub.exe'
+
+gsub:
+ g++ gaussian_subsampling.cc $(FLAG) -o '+gsub.exe'
+
+run:
+ time ./+sub.exe . . ; time ./+gsub.exe . .
\ No newline at end of file
Index: sandbox/jardonnet/subsampling/gaussian_subsampling.hh
--- sandbox/jardonnet/subsampling/gaussian_subsampling.hh (revision 0)
+++ sandbox/jardonnet/subsampling/gaussian_subsampling.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2008 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_SUBSAMPLING_GAUSSIAN_SUBSAMPLING_HH
+# define MLN_SUBSAMPLING_GAUSSIAN_SUBSAMPLING_HH
+
+/*! \file mln/binarization/threshold.hh
+ *
+ * \brief Produce a subsampled image
+ */
+
+# include <mln/geom/ncols.hh>
+# include <mln/geom/nrows.hh>
+
+
+# include <mln/linear/gaussian.hh>
+# include <mln/subsampling/subsampling.hh>
+
+
+
+namespace mln
+{
+
+ namespace subsampling
+ {
+
+ /*! Subsampling FIXME : doxy
+ *
+ *
+ */
+ template <typename I>
+ inline
+ mln_concrete(I)
+ gaussian_subsampling(const Image<I>& input, float sigma
+ const mln_dpoint(I)& first_p,
+ const mln_coord(I)& gap);
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I>
+ inline
+ mln_concrete(I)
+ gaussian_subsampling(const Image<I>& input, float sigma,
+ const mln_dpoint(I)& first_p,
+ const mln_coord(I)& gap)
+ {
+ trace::entering("subsampling::gaussian_subsampling");
+ mln_precondition(exact(input).has_data());
+
+ mln_concrete(I) temp(exact(input).domain());
+ mln_concrete(I) output(geom::nrows(input) / gap,
+ geom::ncols(input) / gap); //FIXME : only for image2d.
+
+ linear::gaussian(input, 0.1, temp);
+ output = impl::subsampling_(exact(temp), first_p, gap);
+
+ trace::exiting("subsampling::gaussian_subsampling");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::subsampling
+
+} // end of namespace mln
+
+
+#endif // ! MLN_SUBSAMPLING_GAUSSIAN_SUBSAMPLING_HH
Index: sandbox/jardonnet/registration/icp.hh
--- sandbox/jardonnet/registration/icp.hh (revision 0)
+++ sandbox/jardonnet/registration/icp.hh (revision 0)
@@ -0,0 +1,122 @@
+// Copyright (C) 2008 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_REGISTRATION_REGISTRATION_HH
+# define MLN_REGISTRATION_REGISTRATION_HH
+
+/*! \file mln/binarization/threshold.hh
+ *
+ * \brief Produce a subsampled image
+ */
+
+# include <mln/value/quat.hh>
+# include <mln/algebra/vec.hh>
+
+namespace mln
+{
+
+ namespace registration
+ {
+
+ /*! Registration FIXME : doxy
+ *
+ *
+ */
+ template <typename I>
+ inline
+ void
+ icp(const Image<I>& cloud,
+ const Image<J>& surface);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ //FIXME : add version for every image types.
+
+ template <typename I, typename J>
+ inline
+ void
+ icp_(const I& P,
+ const J& X)
+ {
+ trace::entering("registration::impl::icp_");
+
+ mln_concrete(I) Pk(cloud.domain());
+
+ const float epsilon = 1e-3;
+ float err, err_bis;
+ quat old_qk, qk;
+ unsigned int k;
+
+
+ k = 0;
+ Pk = P;
+ do {
+ //projection
+
+ old_qk = qk;
+
+ //qk = match(P, mu_P, Xk, mu_Xk);
+
+ // error =
+
+ } while (k < 3 || (qk - old_qk).sqr_norm() > epsilon);
+
+
+ trace::exiting("registration::impl::icp_");
+ }
+
+ } // end of namespace mln::registration::impl
+
+
+ template <typename I, typename J>
+ inline
+ void
+ icp(const Image<I>& cloud,
+ const Image<J>& surface)
+ {
+ trace::entering("registration::icp");
+ mln_precondition(exact(cloud).has_data());
+ mln_precondition(exact(surface).has_data());
+
+ output = impl::icp_(exact(cloud), exact(surface));
+
+ trace::exiting("registration::icp");
+ }
+
+ //cloud == image ?
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::registration
+
+} // end of namespace mln
+
+
+#endif // ! MLN_REGISTRATION_ICP_HH
https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Augment tutorial on image types.
* milena/doc/tutorial/image_types.txt: Augment.
image_types.txt | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 128 insertions(+), 1 deletion(-)
Index: milena/doc/tutorial/image_types.txt
--- milena/doc/tutorial/image_types.txt (revision 1763)
+++ milena/doc/tutorial/image_types.txt (working copy)
@@ -59,6 +59,14 @@
for all v of ima.values
| print v.
+For such image types, we have several points (sites) associated with a
+single value cell. It is rather different from having couples (p,v);
+we actually have one value cell -> a set of points. Such data
+structure allows for compressing data because each value cell is
+shared by several points.
+
+*** Example 1
+
Consider for instance the following image:
+-----+
@@ -67,6 +75,8 @@
| 22 |
+-----+
+We have one value per run.
+
The value type is int_u2 (unsigned integer on 2 bit), that is, the
type of the interval [0,3] of N. The image is defined by a run-length
encoding with a single value per run. Precisely, this image is:
@@ -93,6 +103,115 @@
v v v
{ ((a,1),2), ((b,3),1), ((c,2),2) }
+**** A clue?
+
+***** part 1
+
+When we have value cells, it is usually related to the fact that the
+image is not point-wise writable. For instance, with the image type
+having one value per run, the operation "ima(p) := v" is not possible.
+Otherwise, that would mean that a run is split on such a write access,
+which is too slow (thus not allowed).
+
+Some rare image types can be both point-wise writable and value cell
+iterable. For instance:
+
+ image<int_u8> data;
+ map<int_u8, rgb_3x8> lut; // with i != j => lut[i] != lut[j]
+ map<rgb_3x8, int_u8> reverse_lut;
+
+The keys, resp. the values, of the lut are the values, resp. the keys,
+of the reverse_lut. With this structure, we can have a rather efficient
+point-wise writable image.
+
+ima(p) <- v {
+ it <- reverse_lut.find(v)
+ if (it is not found)
+ ++n
+ lut(n) <- v
+ reverse_lut(v) <- n
+ data(p) <- n
+ else
+ data(p) <- it.key
+}
+
+***** part 2
+
+When an image is value-wise writable, we can form:
+ ima.value(red) = blue;
+It means that we can quickly access to the cell (or the cells)
+having the value 'red'.
+
+When an image is value-cell writable, we can have:
+ for v in ima.values()
+ ima.cell(v) = v'
+In that case, a 'v' is a value cell, not a value.
+
+***** part 3
+
+Is the notion of value-wise readable relevant?
+ ima.value(red) // read-access
+gives:
+ - red, which is dummy!
+or - the corresponding point set, which can be great!
+
+This is another property...
+
+
+*** Example 2
+
+Consider this image type:
+
+{ data + +-----------+
+ | 0 2 1 0 2 |
+ | 0 0 3 2 1 |
+ | 2 1 2 2 0 |
+ +-----------+;
+ lut + +---+---------------+
+ | 0 | (255, 0, 0) | red (r)
+ | 1 | (127,127,127) | medium grey (m)
+ | 2 | ( 0, 0,255) | blue (b)
+ | 3 | (127,127,127) | medium grey (m) again
+ +---+---------------+
+}
+
+This image is defined with a look-up table; its external
+representation actually is:
+
+ +-----------+
+ | r b m r b |
+ | r r m b m |
+ | b m b b r |
+ +-----------+
+
+(conversely, the internal representation is the 'data' image.)
+
+We have I::value = rgb_3x8
+so the image appears to be highly quantized (24 bit).
+
+Yet the number of possible values is limited (here up to 4, even if
+two value cells are identical) and stored by the image in the look-up
+table.
+
+It leads to:
+ code A) rbmrbrrmbmbmbbr
+ code B) rmb
+ code C) rmbm
+
+ima.destination (browsed by code B) is an instance of
+value::subset<rgb_3x8>.
+
+FIXME: OR (?)
+
+It leads to:
+ code A) rbmrbrrmbmbmbbr
+ code B) impossible because 24bit data
+ code C) rmbm
+
+and I.destination gives value::set<rgb_3x8>.
+
** associated types
@@ -232,7 +351,15 @@
|
+ -- high
-****
+**** low
+
+I::value defines a set of possible values whose cardinality is less
+than or equal to 2^16.
+
+FIXME: OR (?)
+
+I.destination (same definition)
+
*** value
|