URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-10-01 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Add a generic snake browsing with some examples.
* mln/canvas/browsing/snake_generic.hh: New, generic snake. Works on
any dimension and follows the dimensions in any order.
* tests/canvas/browsing/snake_generic_2d_hori.cc: New,
* tests/canvas/browsing/snake_generic_2d_vert.cc: New,
* tests/canvas/browsing/snake_generic_3d_hori.cc: New,
* tests/canvas/browsing/snake_generic_3d_vert.cc: New, examples
* mln/canvas/browsing/directional.hh: Documentation.
---
mln/canvas/browsing/directional.hh | 15 ++
mln/canvas/browsing/snake_generic.hh | 163 +++++++++++++++++++++++++
tests/canvas/browsing/snake_generic_2d_hori.cc | 106 ++++++++++++++++
tests/canvas/browsing/snake_generic_2d_vert.cc | 106 ++++++++++++++++
tests/canvas/browsing/snake_generic_3d_hori.cc | 114 +++++++++++++++++
tests/canvas/browsing/snake_generic_3d_vert.cc | 114 +++++++++++++++++
6 files changed, 618 insertions(+)
Index: branches/cleanup-2008/milena/tests/canvas/browsing/snake_generic_2d_vert.cc
===================================================================
--- branches/cleanup-2008/milena/tests/canvas/browsing/snake_generic_2d_vert.cc (revision 0)
+++ branches/cleanup-2008/milena/tests/canvas/browsing/snake_generic_2d_vert.cc (revision 2463)
@@ -0,0 +1,106 @@
+// Copyright (C) 2007, 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.
+
+/*! \file tests/canvas/browsing/snake_generic_2d_vert.cc
+ *
+ * \brief Tests on mln::canvas::browsing::snake_generic.
+ */
+
+#include <mln/core/image/image2d.hh>
+#include <mln/canvas/browsing/snake_generic.hh>
+#include <mln/fun/p2v/iota.hh>
+#include <mln/debug/println.hh>
+
+template <typename I, typename F>
+struct assign_browsing_functor
+{
+ enum { dim = I::site::dim };
+
+ typedef assign_browsing_functor<I, F> self;
+ typedef mln_deduce(I, psite, delta) dpsite;
+ typedef void (assign_browsing_functor<I,F>::*move_fun)();
+
+ I input;
+ F f;
+ std::vector<move_fun> moves;
+ std::vector<dpsite> dps;
+
+ assign_browsing_functor(I& input, F f = F())
+ : input(input),
+ f(f),
+ moves(3),
+ dps(3)
+ {
+ dps[0] = dpsite(0, 1);
+ dps[1] = dpsite(1, 0);
+ dps[2] = dpsite(-1, 0);
+ moves[0] = &self::fwd;
+ moves[1] = &self::down;
+ moves[2] = &self::up;
+ }
+
+ mln_psite(I) p;
+
+ void init() {}
+ void final() {}
+ void next()
+ {
+ input(p) = f(p);
+ }
+ void fwd() { std::cout << "fwd" << std::endl; next(); }
+ void up() { std::cout << "up" << std::endl; next(); }
+ void down() { std::cout << "down" << std::endl; next(); }
+};
+
+namespace mln
+{
+
+ template <typename I, typename F, typename B>
+ void my_test(Image<I>& ima_,
+ const Function_p2v<F>& f_,
+ const Browsing<B>& browse_)
+ {
+ I& ima = exact(ima_);
+ const F& f = exact(f_);
+ const B& browse = exact(browse_);
+
+ assign_browsing_functor<I, F> fun(ima, f);
+ browse(fun);
+ }
+
+}
+
+
+int main()
+{
+ using namespace mln;
+ image2d<unsigned> ima2(3, 3);
+
+ std::cout << ima2.bbox() << std::endl;
+ my_test(ima2, fun::p2v::iota, canvas::browsing::snake_generic);
+ debug::println(ima2);
+}
Index: branches/cleanup-2008/milena/tests/canvas/browsing/snake_generic_2d_hori.cc
===================================================================
--- branches/cleanup-2008/milena/tests/canvas/browsing/snake_generic_2d_hori.cc (revision 0)
+++ branches/cleanup-2008/milena/tests/canvas/browsing/snake_generic_2d_hori.cc (revision 2463)
@@ -0,0 +1,106 @@
+// Copyright (C) 2007, 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.
+
+/*! \file tests/canvas/browsing/snake_generic_3d_hori.cc
+ *
+ * \brief Tests on mln::canvas::browsing::snake_generic.
+ */
+
+#include <mln/core/image/image2d.hh>
+#include <mln/canvas/browsing/snake_generic.hh>
+#include <mln/fun/p2v/iota.hh>
+#include <mln/debug/println.hh>
+
+template <typename I, typename F>
+struct assign_browsing_functor
+{
+ enum { dim = I::site::dim };
+
+ typedef assign_browsing_functor<I, F> self;
+ typedef mln_deduce(I, psite, delta) dpsite;
+ typedef void (assign_browsing_functor<I,F>::*move_fun)();
+
+ I input;
+ F f;
+ std::vector<move_fun> moves;
+ std::vector<dpsite> dps;
+
+ assign_browsing_functor(I& input, F f = F())
+ : input(input),
+ f(f),
+ moves(3),
+ dps(3)
+ {
+ dps[0] = dpsite(1, 0);
+ dps[1] = dpsite(0, 1);
+ dps[2] = dpsite(0, -1);
+ moves[0] = &self::down;
+ moves[1] = &self::fwd;
+ moves[2] = &self::bkd;
+ }
+
+ mln_psite(I) p;
+
+ void init() {}
+ void final() {}
+ void next()
+ {
+ input(p) = f(p);
+ }
+ void fwd() { std::cout << "fwd" << std::endl; next(); }
+ void bkd() { std::cout << "bkd" << std::endl; next(); }
+ void down() { std::cout << "down" << std::endl; next(); }
+};
+
+namespace mln
+{
+
+ template <typename I, typename F, typename B>
+ void my_test(Image<I>& ima_,
+ const Function_p2v<F>& f_,
+ const Browsing<B>& browse_)
+ {
+ I& ima = exact(ima_);
+ const F& f = exact(f_);
+ const B& browse = exact(browse_);
+
+ assign_browsing_functor<I, F> fun(ima, f);
+ browse(fun);
+ }
+
+}
+
+
+int main()
+{
+ using namespace mln;
+ image2d<unsigned> ima2(3, 3);
+
+ std::cout << ima2.bbox() << std::endl;
+ my_test(ima2, fun::p2v::iota, canvas::browsing::snake_generic);
+ debug::println(ima2);
+}
Index: branches/cleanup-2008/milena/tests/canvas/browsing/snake_generic_3d_vert.cc
===================================================================
--- branches/cleanup-2008/milena/tests/canvas/browsing/snake_generic_3d_vert.cc (revision 0)
+++ branches/cleanup-2008/milena/tests/canvas/browsing/snake_generic_3d_vert.cc (revision 2463)
@@ -0,0 +1,114 @@
+// Copyright (C) 2007, 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.
+
+/*! \file tests/canvas/browsing/snake_generic_3d_vert.cc
+ *
+ * \brief Tests on mln::canvas::browsing::snake_generic.
+ */
+
+#include <mln/core/image/image3d.hh>
+#include <mln/canvas/browsing/snake_generic.hh>
+#include <mln/fun/p2v/iota.hh>
+#include <mln/debug/println.hh>
+
+template <typename I, typename F>
+struct assign_browsing_functor
+{
+ enum { dim = I::site::dim };
+
+ typedef assign_browsing_functor<I, F> self;
+ typedef mln_deduce(I, psite, delta) dpsite;
+ typedef void (assign_browsing_functor<I,F>::*move_fun)();
+
+ I input;
+ F f;
+ std::vector<move_fun> moves;
+ std::vector<dpsite> dps;
+
+ assign_browsing_functor(I& input, F f = F())
+ : input(input),
+ f(f),
+ moves(5),
+ dps(5)
+ {
+ dps[0] = dpsite(0, 0, 1);
+ dps[1] = dpsite(0, 1, 0);
+ dps[2] = dpsite(0, -1, 0);
+ dps[3] = dpsite(1, 0, 0);
+ dps[4] = dpsite(-1, 0, 0);
+
+ moves[0] = &self::thr;
+ moves[1] = &self::down;
+ moves[2] = &self::up;
+ moves[3] = &self::fwd;
+ moves[4] = &self::bkd;
+ }
+
+ mln_psite(I) p;
+
+ void init() {}
+ void final() {}
+ void next()
+ {
+ input(p) = f(p);
+ }
+ void fwd() { std::cout << "fwd" << std::endl; next(); }
+ void bkd() { std::cout << "bkd" << std::endl; next(); }
+ void down() { std::cout << "down" << std::endl; next(); }
+ void up() { std::cout << "up" << std::endl; next(); }
+ void thr() { std::cout << "thr" << std::endl; next(); }
+};
+
+namespace mln
+{
+
+ template <typename I, typename F, typename B>
+ void my_test(Image<I>& ima_,
+ const Function_p2v<F>& f_,
+ const Browsing<B>& browse_)
+ {
+ I& ima = exact(ima_);
+ const F& f = exact(f_);
+ const B& browse = exact(browse_);
+
+ assign_browsing_functor<I, F> fun(ima, f);
+ browse(fun);
+ }
+
+}
+
+
+int main()
+{
+ using namespace mln;
+ image3d<unsigned> ima(3, 3, 3);
+
+ ima(point3d(0,0,0)) = 42;
+ std::cout << ima.bbox() << std::endl;
+ my_test(ima, fun::p2v::iota, canvas::browsing::snake_generic);
+ debug::println(ima);
+}
Index: branches/cleanup-2008/milena/tests/canvas/browsing/snake_generic_3d_hori.cc
===================================================================
--- branches/cleanup-2008/milena/tests/canvas/browsing/snake_generic_3d_hori.cc (revision 0)
+++ branches/cleanup-2008/milena/tests/canvas/browsing/snake_generic_3d_hori.cc (revision 2463)
@@ -0,0 +1,114 @@
+// Copyright (C) 2007, 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.
+
+/*! \file tests/canvas/browsing/snake_generic_3d_hori.cc
+ *
+ * \brief Tests on mln::canvas::browsing::snake_generic.
+ */
+
+#include <mln/core/image/image3d.hh>
+#include <mln/canvas/browsing/snake_generic.hh>
+#include <mln/fun/p2v/iota.hh>
+#include <mln/debug/println.hh>
+
+template <typename I, typename F>
+struct assign_browsing_functor
+{
+ enum { dim = I::site::dim };
+
+ typedef assign_browsing_functor<I, F> self;
+ typedef mln_deduce(I, psite, delta) dpsite;
+ typedef void (assign_browsing_functor<I,F>::*move_fun)();
+
+ I input;
+ F f;
+ std::vector<move_fun> moves;
+ std::vector<dpsite> dps;
+
+ assign_browsing_functor(I& input, F f = F())
+ : input(input),
+ f(f),
+ moves(5),
+ dps(5)
+ {
+ dps[0] = dpsite(1, 0, 0);
+ dps[1] = dpsite(0, 1, 0);
+ dps[2] = dpsite(0, -1, 0);
+ dps[3] = dpsite(0, 0, 1);
+ dps[4] = dpsite(0, 0, -1);
+
+ moves[0] = &self::thr;
+ moves[1] = &self::down;
+ moves[2] = &self::up;
+ moves[3] = &self::fwd;
+ moves[4] = &self::bkd;
+ }
+
+ mln_psite(I) p;
+
+ void init() {}
+ void final() {}
+ void next()
+ {
+ input(p) = f(p);
+ }
+ void fwd() { std::cout << "fwd" << std::endl; next(); }
+ void bkd() { std::cout << "bkd" << std::endl; next(); }
+ void down() { std::cout << "down" << std::endl; next(); }
+ void up() { std::cout << "up" << std::endl; next(); }
+ void thr() { std::cout << "thr" << std::endl; next(); }
+};
+
+namespace mln
+{
+
+ template <typename I, typename F, typename B>
+ void my_test(Image<I>& ima_,
+ const Function_p2v<F>& f_,
+ const Browsing<B>& browse_)
+ {
+ I& ima = exact(ima_);
+ const F& f = exact(f_);
+ const B& browse = exact(browse_);
+
+ assign_browsing_functor<I, F> fun(ima, f);
+ browse(fun);
+ }
+
+}
+
+
+int main()
+{
+ using namespace mln;
+ image3d<unsigned> ima(3, 3, 3);
+
+ ima(point3d(0,0,0)) = 42;
+ std::cout << ima.bbox() << std::endl;
+ my_test(ima, fun::p2v::iota, canvas::browsing::snake_generic);
+ debug::println(ima);
+}
Index: branches/cleanup-2008/milena/mln/canvas/browsing/directional.hh
===================================================================
--- branches/cleanup-2008/milena/mln/canvas/browsing/directional.hh (revision 2462)
+++ branches/cleanup-2008/milena/mln/canvas/browsing/directional.hh (revision 2463)
@@ -74,6 +74,21 @@
* void final(); \n
* } \n
*
+ * Example : \n
+ *
+ * 1 0 0
+ * 2 0 0
+ * 3 0 0
+ *
+ * 4 0 0
+ * 5 0 0
+ * 6 0 0
+ *
+ * 7 0 0
+ * 8 0 0
+ * 9 0 0
+ *
+ *
*/
struct directional_t : public Browsing< directional_t >
{
Index: branches/cleanup-2008/milena/mln/canvas/browsing/snake_generic.hh
===================================================================
--- branches/cleanup-2008/milena/mln/canvas/browsing/snake_generic.hh (revision 0)
+++ branches/cleanup-2008/milena/mln/canvas/browsing/snake_generic.hh (revision 2463)
@@ -0,0 +1,163 @@
+// 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_BROWSING_SNAKE_GENERIC_HH
+# define MLN_CANVAS_BROWSING_SNAKE_GENERIC_HH
+
+/*! \file mln/canvas/browsing/snake_generic.hh
+ *
+ * \brief Browsing in a snake-way, forward.
+ */
+
+# include <stack>
+# include <mln/core/concept/browsing.hh>
+
+namespace mln
+{
+
+ namespace canvas
+ {
+
+ namespace browsing
+ {
+
+ /*!
+ * \brief Multidimentional Browsing in a given-way.
+ *
+ * F shall feature: \n
+ * { \n
+ * --- as attributes: \n
+ * input; \n
+ * p; \n
+ * --- as methods: \n
+ * void init(); \n
+ * void *() moves[]; \n
+ * dpsite dps[]; \n
+ * } \n
+ *
+ * init is called before browsing
+ *
+ * The snake follow dimension using the delta point site of dps.
+ * dps[0] = delta psite following the global dimension (forward)
+ * dps[1] = delta psite following the 2nd dimension to follow (forward).
+ * dps[2] = delta psite following the 2nd dimension to follow (backward).
+ * dps[3] = delta psite following the 3nd dimension to follow (forward).
+ * dps[3] = delta psite following the 3nd dimension to follow (backward).
+ *
+ * moves contains pointer to f's members. These merbers will be call in each time
+ * the snake progress in the correct dimension :
+ *
+ * moves[i] is called at each move following the delta psite dps[i]
+ *
+ */
+
+ struct snake_generic_t : public Browsing< snake_generic_t >
+ {
+
+ template <typename F>
+ void operator()(F& f) const;
+ }
+
+ snake_generic;
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename F>
+ inline
+ void
+ snake_generic_t::operator()(F& f) const
+ {
+ trace::entering("canvas::browsing::snake_generic");
+ mln_precondition(f.input.has_data());
+
+ // p init
+ f.p = f.input.bbox().pmin();// - f.dps[0];
+
+ std::vector< int > directions(f.moves.size(), 0);
+ unsigned deph = 0;
+ unsigned total_deph = f.moves.size() / 2 + 1;
+
+ // initialization
+ trace::entering("canvas::browsing::snake_generic::init");
+ f.init();
+ trace::exiting("canvas::browsing::snake_generic::init");
+
+ bool first = true;
+ directions[deph] = 1;
+ deph = total_deph - 1;
+
+ // Call the move function (for the first point)
+ (f.*(f.moves[(deph - 1) * 2 - 1 + directions[deph - 1]])) ();
+ while (deph > 0) // If direction is empty, break
+ {
+ mln_assertion(deph <= total_deph);
+ mln_assertion(deph > 0);
+ // If f.p is near the border (we ended a direction) -> next child
+ if (!f.input.domain().has(f.p +
+ f.dps[(deph - 1) * 2 - 1 + directions[deph - 1]]))
+ {
+ // Go up the tree
+ deph--;
+ if (deph >= 1)
+ // Change directions
+ directions[deph] = directions[deph] == 1 ? 0 : 1;
+ continue;
+ }
+
+ if (!first)
+ {
+ // Move f.p
+ f.p += f.dps[(deph - 1) * 2 - 1 + directions[deph - 1]];
+ // Call the move function
+ (f.*(f.moves[(deph - 1) * 2 - 1 + directions[deph - 1]])) ();
+ }
+ else
+ first = false;
+
+ if (deph != total_deph)
+ {
+ // Go down the tree
+ deph++;
+ first = true;
+ }
+ }
+
+ trace::exiting("canvas::browsing::snake_generic");
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::canvas::browsing
+
+ } // end of namespace mln::canvas
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CANVAS_BROWSING_SNAKE_GENERIC_HH
* mln/core/image/complex_lower_neighborhood.hh,
* mln/core/image/complex_higher_neighborhood.hh:
New.
---
milena/ChangeLog | 8 ++
.../mln/core/image/complex_higher_neighborhood.hh | 117 ++++++++++++++++++++
.../mln/core/image/complex_lower_neighborhood.hh | 117 ++++++++++++++++++++
3 files changed, 242 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/core/image/complex_higher_neighborhood.hh
create mode 100644 milena/mln/core/image/complex_lower_neighborhood.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e44301f..be5fc43 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
2008-10-01 Roland Levillain <roland(a)lrde.epita.fr>
+ Add neighborhoods of lower- and higher-dimension adjacent faces.
+
+ * mln/core/image/complex_lower_neighborhood.hh,
+ * mln/core/image/complex_higher_neighborhood.hh:
+ New.
+
+2008-10-01 Roland Levillain <roland(a)lrde.epita.fr>
+
* tests/core/image/complex_image.cc: Alias mln::point2d to P.
2008-10-01 Roland Levillain <roland(a)lrde.epita.fr>
diff --git a/milena/mln/core/image/complex_higher_neighborhood.hh b/milena/mln/core/image/complex_higher_neighborhood.hh
new file mode 100644
index 0000000..2b52c5b
--- /dev/null
+++ b/milena/mln/core/image/complex_higher_neighborhood.hh
@@ -0,0 +1,117 @@
+// 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.
+
+#ifndef MLN_CORE_COMPLEX_HIGHER_NEIGHBORHOOD_HH
+# define MLN_CORE_COMPLEX_HIGHER_NEIGHBORHOOD_HH
+
+/// \file mln/core/complex_higher_neighborhood.hh
+/// \brief A neighborhood centered on a n-face of complex returning its
+/// adjacent (n+1)-faces.
+
+# include <mln/core/concept/neighborhood.hh>
+
+# include <mln/core/site_set/complex_psite.hh>
+
+# include <mln/topo/adj_higher_face_iter.hh>
+
+// FIXME: Factor with complex_lower_neighborhood.
+
+
+namespace mln
+{
+ // Fwd decls.
+ template <typename I, typename P, typename N>
+ class complex_neighborhood_fwd_piter;
+ template <typename I, typename P, typename N>
+ class complex_neighborhood_bkd_piter;
+
+
+ /// \brief Neighborhood centered on a n-face of complex returning its
+ /// adjacent (n-1)-faces.
+ template <unsigned D, typename P>
+ class complex_higher_neighborhood
+ : public Neighborhood< complex_higher_neighborhood<D, P> >
+ {
+ typedef complex_higher_neighborhood<D, P> self_;
+
+ // FIXME: The associated complex iterators.
+ public:
+ typedef topo::adj_higher_face_fwd_iter<D> complex_fwd_iter;
+ typedef topo::adj_higher_face_bkd_iter<D> complex_bkd_iter;
+
+ public:
+ /// Associated types.
+ /// \{
+ /// The type of psite corresponding to the neighborhood.
+ typedef complex_psite<D, P> psite;
+ /// The type of site corresponding to the neighborhood.
+ typedef mln_site(psite) site;
+
+ /// \brief Point_Iterator type to browse the psites of the neighborhood
+ /// w.r.t. the ordering of vertices.
+ typedef
+ complex_neighborhood_fwd_piter<complex_fwd_iter, P, self_> fwd_niter;
+
+ /// \brief Point_Iterator type to browse the psites of the neighborhood
+ /// w.r.t. the reverse ordering of vertices.
+ typedef
+ complex_neighborhood_bkd_piter<complex_bkd_iter, P, self_> bkd_niter;
+
+ /// The default niter type.
+ typedef fwd_niter niter;
+ /// \}
+
+ /// Conversions.
+ /// \{
+ /// The window type corresponding to this neighborhood.
+ // FIXME: Dummy.
+ typedef self_ window;
+ /// Create a window corresponding to this neighborhood.
+ const window& win() const;
+ /// \}
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // FIXME: Dummy.
+ template <unsigned D, typename P>
+ inline
+ // FIXME: Change (dummy) type.
+ const typename complex_higher_neighborhood<D, P>::window&
+ complex_higher_neighborhood<D, P>::win() const
+ {
+ // FIXME: Dummy.
+ return *this;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // ! MLN_CORE_COMPLEX_HIGHER_NEIGHBORHOOD_HH
diff --git a/milena/mln/core/image/complex_lower_neighborhood.hh b/milena/mln/core/image/complex_lower_neighborhood.hh
new file mode 100644
index 0000000..7eb8fc4
--- /dev/null
+++ b/milena/mln/core/image/complex_lower_neighborhood.hh
@@ -0,0 +1,117 @@
+// 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.
+
+#ifndef MLN_CORE_COMPLEX_LOWER_NEIGHBORHOOD_HH
+# define MLN_CORE_COMPLEX_LOWER_NEIGHBORHOOD_HH
+
+/// \file mln/core/complex_lower_neighborhood.hh
+/// \brief A neighborhood centered on a n-face of complex returning its
+/// adjacent (n-1)-faces.
+
+# include <mln/core/concept/neighborhood.hh>
+
+# include <mln/core/site_set/complex_psite.hh>
+
+# include <mln/topo/adj_lower_face_iter.hh>
+
+// FIXME: Factor with complex_higher_neighborhood.
+
+
+namespace mln
+{
+ // Fwd decls.
+ template <typename I, typename P, typename N>
+ class complex_neighborhood_fwd_piter;
+ template <typename I, typename P, typename N>
+ class complex_neighborhood_bkd_piter;
+
+
+ /// \brief Neighborhood centered on a n-face of complex returning its
+ /// adjacent (n-1)-faces.
+ template <unsigned D, typename P>
+ class complex_lower_neighborhood
+ : public Neighborhood< complex_lower_neighborhood<D, P> >
+ {
+ typedef complex_lower_neighborhood<D, P> self_;
+
+ // FIXME: The associated complex iterators.
+ public:
+ typedef topo::adj_lower_face_fwd_iter<D> complex_fwd_iter;
+ typedef topo::adj_lower_face_bkd_iter<D> complex_bkd_iter;
+
+ public:
+ /// Associated types.
+ /// \{
+ /// The type of psite corresponding to the neighborhood.
+ typedef complex_psite<D, P> psite;
+ /// The type of site corresponding to the neighborhood.
+ typedef mln_site(psite) site;
+
+ /// \brief Point_Iterator type to browse the psites of the neighborhood
+ /// w.r.t. the ordering of vertices.
+ typedef
+ complex_neighborhood_fwd_piter<complex_fwd_iter, P, self_> fwd_niter;
+
+ /// \brief Point_Iterator type to browse the psites of the neighborhood
+ /// w.r.t. the reverse ordering of vertices.
+ typedef
+ complex_neighborhood_bkd_piter<complex_bkd_iter, P, self_> bkd_niter;
+
+ /// The default niter type.
+ typedef fwd_niter niter;
+ /// \}
+
+ /// Conversions.
+ /// \{
+ /// The window type corresponding to this neighborhood.
+ // FIXME: Dummy.
+ typedef self_ window;
+ /// Create a window corresponding to this neighborhood.
+ const window& win() const;
+ /// \}
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // FIXME: Dummy.
+ template <unsigned D, typename P>
+ inline
+ // FIXME: Change (dummy) type.
+ const typename complex_lower_neighborhood<D, P>::window&
+ complex_lower_neighborhood<D, P>::win() const
+ {
+ // FIXME: Dummy.
+ return *this;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // ! MLN_CORE_COMPLEX_LOWER_NEIGHBORHOOD_HH
--
1.6.0.1
* mln/topo/internal/complex_relative_iterator_base.hh
(complex_relative_iterator_base<F, E>::to_face):
Remove.
(complex_relative_iterator_base<F, E>::operator face):
Turn into...
(complex_relative_iterator_base<F, E>::operator const face&):
..this.
Return a const reference to the held face instead of a copy, so
that its address can be safely taken.
Remove the precondition, as invalid iterators are allowed to give
access to the face they hold.
---
milena/ChangeLog | 16 ++++++++++++++++
.../internal/complex_relative_iterator_base.hh | 15 ++-------------
2 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index cf00b66..5107bb1 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,21 @@
2008-10-01 Roland Levillain <roland(a)lrde.epita.fr>
+ Overhaul conversions of complex_relative_iterator_base<F, E>.
+
+ * mln/topo/internal/complex_relative_iterator_base.hh
+ (complex_relative_iterator_base<F, E>::to_face):
+ Remove.
+ (complex_relative_iterator_base<F, E>::operator face):
+ Turn into...
+ (complex_relative_iterator_base<F, E>::operator const face&):
+ ..this.
+ Return a const reference to the held face instead of a copy, so
+ that its address can be safely taken.
+ Remove the precondition, as invalid iterators are allowed to give
+ access to the face they hold.
+
+2008-10-01 Roland Levillain <roland(a)lrde.epita.fr>
+
Delegate pretty-printing of complex_psite<D> to topo::face<D>.
* mln/core/site_set/complex_psite.hh
diff --git a/milena/mln/topo/internal/complex_relative_iterator_base.hh b/milena/mln/topo/internal/complex_relative_iterator_base.hh
index 599727a..43a38ae 100644
--- a/milena/mln/topo/internal/complex_relative_iterator_base.hh
+++ b/milena/mln/topo/internal/complex_relative_iterator_base.hh
@@ -110,10 +110,8 @@ namespace mln
/// Conversion and accessors.
/// \{
- /// Reference to the corresponding face handle.
- const face& to_face () const;
/// Convert the iterator into an face handle.
- operator face() const;
+ operator const face&() const;
/// \}
protected:
@@ -297,20 +295,11 @@ namespace mln
template <typename F, typename E>
inline
- const F&
- complex_relative_iterator_base<F, E>::to_face() const
+ complex_relative_iterator_base<F, E>::operator const F&() const
{
return f_;
}
- template <typename F, typename E>
- inline
- complex_relative_iterator_base<F, E>::operator F() const
- {
- mln_precondition(exact(this)->is_valid());
- return f_;
- }
-
template <typename F, typename E>
inline
--
1.6.0.1