* mln/core/concept/function.hh: Add Function_vvvv2v concept.
* mln/world/k1/display_enlarged.hh,
* mln/world/k1/internal/face_dim.hh,
* mln/world/k1/is_0_face.hh,
* mln/world/k1/is_1_face.hh,
* mln/world/k1/is_1_face_horizontal.hh,
* mln/world/k1/is_1_face_vertical.hh,
* mln/world/k1/is_2_face.hh,
* mln/world/k1/is_primary_face.hh: Add overloads.
* mln/world/k1/fill_0_from_1_faces.hh,
* mln/world/k1/fill_0_from_2_faces.hh,
* mln/world/k1/fill_0_from_primary_faces.hh,
* mln/world/k1/fill_1_from_2_faces.hh,
* mln/world/k1/fill_1_from_aux_2_faces.hh,
* mln/world/k1/fill_2_from_1_faces.hh,
* mln/world/k1/immerse.hh,
* mln/world/k1/immerse_and_duplicate_2_to_0_1_faces.hh,
* mln/world/k1/immerse_and_duplicate_2_to_1_faces.hh: New.
* mln/world/k1/un_immerse.hh: Write it.
* tests/world/k1/Makefile.am,
* tests/world/k1/fill_0_from_1_faces.cc,
* tests/world/k1/fill_0_from_2_faces.cc,
* tests/world/k1/fill_0_from_primary_faces.cc,
* tests/world/k1/fill_1_from_2_faces.cc,
* tests/world/k1/fill_1_from_aux_2_faces.cc,
* tests/world/k1/fill_2_from_1_faces.cc,
* tests/world/k1/immerse_and_duplicate_2_to_0_1_faces.cc,
* tests/world/k1/immerse_and_duplicate_2_to_1_faces.cc,
* tests/world/k1/un_immerse.cc: New tests.
---
milena/ChangeLog | 90 ++++++++----
milena/mln/core/concept/function.hh | 41 +++++
milena/mln/world/k1/display_enlarged.hh | 8 +-
milena/mln/world/k1/fill_0_from_1_faces.hh | 127 ++++++++++++++++
milena/mln/world/k1/fill_0_from_2_faces.hh | 127 ++++++++++++++++
milena/mln/world/k1/fill_0_from_primary_faces.hh | 109 ++++++++++++++
milena/mln/world/k1/fill_1_from_2_faces.hh | 142 ++++++++++++++++++
milena/mln/world/k1/fill_1_from_aux_2_faces.hh | 155 ++++++++++++++++++++
milena/mln/world/k1/fill_2_from_1_faces.hh | 127 ++++++++++++++++
milena/mln/world/k1/immerse.hh | 18 +-
.../k1/immerse_and_duplicate_2_to_0_1_faces.hh | 125 ++++++++++++++++
.../world/k1/immerse_and_duplicate_2_to_1_faces.hh | 111 ++++++++++++++
milena/mln/world/k1/internal/face_dim.hh | 11 ++-
milena/mln/world/k1/is_0_face.hh | 12 ++-
milena/mln/world/k1/is_1_face.hh | 15 ++-
milena/mln/world/k1/is_1_face_horizontal.hh | 11 ++-
milena/mln/world/k1/is_1_face_vertical.hh | 15 ++-
milena/mln/world/k1/is_2_face.hh | 12 ++-
milena/mln/world/k1/is_primary_face.hh | 12 ++
milena/mln/world/k1/un_immerse.hh | 134 +++++++++++++++--
milena/tests/world/k1/Makefile.am | 18 ++-
milena/tests/world/k1/fill_0_from_1_faces.cc | 93 ++++++++++++
milena/tests/world/k1/fill_0_from_2_faces.cc | 93 ++++++++++++
milena/tests/world/k1/fill_0_from_primary_faces.cc | 93 ++++++++++++
milena/tests/world/k1/fill_1_from_2_faces.cc | 94 ++++++++++++
milena/tests/world/k1/fill_1_from_aux_2_faces.cc | 104 +++++++++++++
milena/tests/world/k1/fill_2_from_1_faces.cc | 94 ++++++++++++
.../k1/immerse_and_duplicate_2_to_0_1_faces.cc | 55 +++++++
.../world/k1/immerse_and_duplicate_2_to_1_faces.cc | 55 +++++++
milena/tests/world/k1/un_immerse.cc | 54 +++++++
30 files changed, 2093 insertions(+), 62 deletions(-)
create mode 100644 milena/mln/world/k1/fill_0_from_1_faces.hh
create mode 100644 milena/mln/world/k1/fill_0_from_2_faces.hh
create mode 100644 milena/mln/world/k1/fill_0_from_primary_faces.hh
create mode 100644 milena/mln/world/k1/fill_1_from_2_faces.hh
create mode 100644 milena/mln/world/k1/fill_1_from_aux_2_faces.hh
create mode 100644 milena/mln/world/k1/fill_2_from_1_faces.hh
create mode 100644 milena/mln/world/k1/immerse_and_duplicate_2_to_0_1_faces.hh
create mode 100644 milena/mln/world/k1/immerse_and_duplicate_2_to_1_faces.hh
create mode 100644 milena/tests/world/k1/fill_0_from_1_faces.cc
create mode 100644 milena/tests/world/k1/fill_0_from_2_faces.cc
create mode 100644 milena/tests/world/k1/fill_0_from_primary_faces.cc
create mode 100644 milena/tests/world/k1/fill_1_from_2_faces.cc
create mode 100644 milena/tests/world/k1/fill_1_from_aux_2_faces.cc
create mode 100644 milena/tests/world/k1/fill_2_from_1_faces.cc
create mode 100644 milena/tests/world/k1/immerse_and_duplicate_2_to_0_1_faces.cc
create mode 100644 milena/tests/world/k1/immerse_and_duplicate_2_to_1_faces.cc
create mode 100644 milena/tests/world/k1/un_immerse.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index cec8c97..dc3a807 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,33 +1,71 @@
2012-09-27 Guillaume Lazzara <z(a)lrde.epita.fr>
+ More routines working on images immersed in K1.
+
+ * mln/core/concept/function.hh: Add Function_vvvv2v concept.
+
+ * mln/world/k1/display_enlarged.hh,
+ * mln/world/k1/internal/face_dim.hh,
+ * mln/world/k1/is_0_face.hh,
+ * mln/world/k1/is_1_face.hh,
+ * mln/world/k1/is_1_face_horizontal.hh,
+ * mln/world/k1/is_1_face_vertical.hh,
+ * mln/world/k1/is_2_face.hh,
+ * mln/world/k1/is_primary_face.hh: Add overloads.
+
+ * mln/world/k1/fill_0_from_1_faces.hh,
+ * mln/world/k1/fill_0_from_2_faces.hh,
+ * mln/world/k1/fill_0_from_primary_faces.hh,
+ * mln/world/k1/fill_1_from_2_faces.hh,
+ * mln/world/k1/fill_1_from_aux_2_faces.hh,
+ * mln/world/k1/fill_2_from_1_faces.hh,
+ * mln/world/k1/immerse.hh,
+ * mln/world/k1/immerse_and_duplicate_2_to_0_1_faces.hh,
+ * mln/world/k1/immerse_and_duplicate_2_to_1_faces.hh: New.
+
+ * mln/world/k1/un_immerse.hh: Write it.
+
+ * tests/world/k1/Makefile.am,
+ * tests/world/k1/fill_0_from_1_faces.cc,
+ * tests/world/k1/fill_0_from_2_faces.cc,
+ * tests/world/k1/fill_0_from_primary_faces.cc,
+ * tests/world/k1/fill_1_from_2_faces.cc,
+ * tests/world/k1/fill_1_from_aux_2_faces.cc,
+ * tests/world/k1/fill_2_from_1_faces.cc,
+ * tests/world/k1/immerse_and_duplicate_2_to_0_1_faces.cc,
+ * tests/world/k1/immerse_and_duplicate_2_to_1_faces.cc,
+ * tests/world/k1/un_immerse.cc: New tests.
+
+2012-09-27 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Initial commit of tools to work in K1.
- * milena/mln/world/k1/display_enlarged.hh,
- * milena/mln/world/k1/immerse.hh,
- * milena/mln/world/k1/internal/face_dim.hh,
- * milena/mln/world/k1/is_0_face.hh,
- * milena/mln/world/k1/is_0_or_1_face.hh,
- * milena/mln/world/k1/is_1_face.hh,
- * milena/mln/world/k1/is_1_face_horizontal.hh,
- * milena/mln/world/k1/is_1_face_vertical.hh,
- * milena/mln/world/k1/is_2_face.hh,
- * milena/mln/world/k1/is_primary_face.hh,
- * milena/mln/world/k1/un_immerse.hh: New.
-
- * milena/tests/world/k1/Makefile.am,
- * milena/tests/world/k1/display_enlarged.cc,
- * milena/tests/world/k1/immerse.cc,
- * milena/tests/world/k1/is_0_face.cc,
- * milena/tests/world/k1/is_0_or_1_face.cc,
- * milena/tests/world/k1/is_1_face.cc,
- * milena/tests/world/k1/is_1_face_horizontal.cc,
- * milena/tests/world/k1/is_1_face_vertical.cc,
- * milena/tests/world/k1/is_2_face.cc,
- * milena/tests/world/k1/is_primary_face.cc: New tests.
-
- * milena/tests/world/Makefile.am: Add Subdir.
-
- * milena/mln/make/image.hh: Add overloads.
+ * mln/world/k1/display_enlarged.hh,
+ * mln/world/k1/immerse.hh,
+ * mln/world/k1/internal/face_dim.hh,
+ * mln/world/k1/is_0_face.hh,
+ * mln/world/k1/is_0_or_1_face.hh,
+ * mln/world/k1/is_1_face.hh,
+ * mln/world/k1/is_1_face_horizontal.hh,
+ * mln/world/k1/is_1_face_vertical.hh,
+ * mln/world/k1/is_2_face.hh,
+ * mln/world/k1/is_primary_face.hh,
+ * mln/world/k1/un_immerse.hh: New.
+
+ * tests/world/k1/Makefile.am,
+ * tests/world/k1/display_enlarged.cc,
+ * tests/world/k1/immerse.cc,
+ * tests/world/k1/is_0_face.cc,
+ * tests/world/k1/is_0_or_1_face.cc,
+ * tests/world/k1/is_1_face.cc,
+ * tests/world/k1/is_1_face_horizontal.cc,
+ * tests/world/k1/is_1_face_vertical.cc,
+ * tests/world/k1/is_2_face.cc,
+ * tests/world/k1/is_primary_face.cc: New tests.
+
+ * tests/world/Makefile.am: Add Subdir.
+
+ * mln/make/image.hh: Add overloads.
2011-11-29 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/milena/mln/core/concept/function.hh b/milena/mln/core/concept/function.hh
index 22e338e..4a6b241 100644
--- a/milena/mln/core/concept/function.hh
+++ b/milena/mln/core/concept/function.hh
@@ -43,6 +43,7 @@ namespace mln
template <typename E> struct Function_v2v;
template <typename E> struct Function_v2b;
template <typename E> struct Function_vv2v;
+ template <typename E> struct Function_vvvv2v;
template <typename E> struct Function_vv2b;
@@ -183,6 +184,31 @@ namespace mln
};
+ /*----------------------------------------.
+ | (Value, Value, Value, Value) -> Value. |
+ `----------------------------------------*/
+
+ template <>
+ struct Function_vvvv2v<void> { typedef Function<void> super; };
+
+
+ /// \brief Base class for implementation of function-objects from
+ /// four values to a value.
+ ///
+ /// The parameter \a E is the exact type.
+ ///
+ /// \ingroup modfun
+ //
+ template <typename E>
+ struct Function_vvvv2v : public Function<E>
+ {
+ typedef Function_vvvv2v<void> category;
+ protected:
+ Function_vvvv2v();
+ Function_vvvv2v(const Function_vvvv2v&);
+ };
+
+
/*--------------------------.
| (Value, Value) -> Boolean.|
`--------------------------*/
@@ -297,6 +323,21 @@ namespace mln
{
}
+ // Function_vvvv2v.
+
+ template <typename E>
+ inline
+ Function_vvvv2v<E>::Function_vvvv2v()
+ {
+ }
+
+ template <typename E>
+ inline
+ Function_vvvv2v<E>::Function_vvvv2v(const Function_vvvv2v<E>& rhs)
+ : Function<E>(rhs)
+ {
+ }
+
// Function_vv2b.
template <typename E>
diff --git a/milena/mln/world/k1/display_enlarged.hh
b/milena/mln/world/k1/display_enlarged.hh
index f3610c1..a247d38 100644
--- a/milena/mln/world/k1/display_enlarged.hh
+++ b/milena/mln/world/k1/display_enlarged.hh
@@ -114,21 +114,21 @@ namespace mln
{
for (mln::def::coord col = min_col; col <= max_col; ++col)
{
- if (is_0_face(point2d(row, col)))
+ if (is_0_face(row, col))
{
output.at_(row * shift, col * shift) = ima_k1.at_(row, col);
}
- else if (is_1_face_vertical(point2d(row, col)))
+ else if (is_1_face_vertical(row, col))
{
for (mln::def::coord j = -(shift - 1); j < (shift + 3); ++j)
output.at_(row * shift + j, col * shift) = ima_k1.at_(row, col);
}
- else if (is_1_face_horizontal(point2d(row, col)))
+ else if (is_1_face_horizontal(row, col))
{
for (mln::def::coord j = -(shift - 1); j < (shift + 3); ++j)
output.at_(row * shift, col * shift + j) = ima_k1.at_(row, col);
}
- else if (is_2_face(point2d(row, col)))
+ else if (is_2_face(row, col))
{
for (mln::def::coord i = -(shift - 1); i < (shift + 3); ++i)
for (mln::def::coord j = -(shift - 1); j < (shift + 3); ++j)
diff --git a/milena/mln/world/k1/fill_0_from_1_faces.hh
b/milena/mln/world/k1/fill_0_from_1_faces.hh
new file mode 100644
index 0000000..c56f407
--- /dev/null
+++ b/milena/mln/world/k1/fill_0_from_1_faces.hh
@@ -0,0 +1,127 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+///
+/// \brief Fill 1 faces in a K1 2D image using its 2 faces.
+
+#ifndef MLN_WORLD_K1_FILL_0_FROM_1_FACES_HH
+# define MLN_WORLD_K1_FILL_0_FROM_1_FACES_HH
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/is_0_face.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /*! \brief Fill 1 faces in a K1 2D image using its 2 faces.
+
+ \param[in,out] inout A 2D image immersed in K1.
+ \param[in,out] f A functor computing a result from four values.
+
+ This function use the following neighborhood:
+
+ \verbatim
+ |
+ -.-
+ |
+ \endverbatim
+
+
+ */
+ template <typename I, typename F>
+ void fill_0_from_1_faces(Image<I>& inout, Function_vvvv2v<F>&
f);
+
+ /// \overload
+ template <typename I, typename A>
+ void fill_0_from_1_faces(Image<I>& inout, const Accumulator<A>&
accu);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facade
+
+
+ template <typename I, typename F>
+ void fill_0_from_1_faces(Image<I>& inout_, Function_vvvv2v<F>&
f_)
+ {
+ trace::entering("mln::world::k1::fill_0_from_1_faces");
+
+ mln_precondition(exact(inout_).is_valid());
+ I& inout = exact(inout_);
+ F& f = exact(f_);
+
+ mln_piter(I) p(inout.domain());
+ for_all(p)
+ if (is_0_face(p))
+ inout(p) = f(inout(p + up), inout(p + left), inout(p + right), inout(p + down));
+
+ trace::exiting("mln::world::k1::fill_0_from_1_faces");
+ }
+
+
+ template <typename I, typename A>
+ void fill_0_from_1_faces(Image<I>& inout_, const
Accumulator<A>& accu_)
+ {
+ trace::entering("mln::world::k1::fill_0_from_1_faces");
+
+ mln_precondition(exact(inout_).is_valid());
+ I& inout = exact(inout_);
+ (void) accu_;
+
+ A accu = A();
+ mln_piter(I) p(inout.domain());
+ for_all(p)
+ if (is_0_face(p))
+ {
+ accu.init();
+ accu.take(inout(p + up));
+ accu.take(inout(p + left));
+ accu.take(inout(p + right));
+ accu.take(inout(p + down));
+ inout(p) = accu.to_result();
+ }
+
+ trace::exiting("mln::world::k1::fill_0_from_1_faces");
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_FILL_0_FROM_1_FACES_HH
diff --git a/milena/mln/world/k1/fill_0_from_2_faces.hh
b/milena/mln/world/k1/fill_0_from_2_faces.hh
new file mode 100644
index 0000000..7b3e57e
--- /dev/null
+++ b/milena/mln/world/k1/fill_0_from_2_faces.hh
@@ -0,0 +1,127 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+///
+/// \brief Fill 1 faces in a K1 2D image using its 2 faces.
+
+#ifndef MLN_WORLD_K1_FILL_0_FROM_2_FACES_HH
+# define MLN_WORLD_K1_FILL_0_FROM_2_FACES_HH
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/is_0_face.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /*! \brief Fill 0 faces in a K1 2D image using its 2 faces.
+
+ \param[in,out] inout A 2D image immersed in K1.
+ \param[in,out] f A functor computing a result from four values.
+
+ This function use the following neighborhood:
+
+ \verbatim
+ x x
+ .
+ x x
+ \endverbatim
+
+
+ */
+ template <typename I, typename F>
+ void fill_0_from_2_faces(Image<I>& inout, Function_vvvv2v<F>&
f);
+
+ /// \overload
+ template <typename I, typename A>
+ void fill_0_from_2_faces(Image<I>& inout, const Accumulator<A>&
accu);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facade
+
+
+ template <typename I, typename F>
+ void fill_0_from_2_faces(Image<I>& inout_, Function_vvvv2v<F>&
f_)
+ {
+ trace::entering("mln::world::k1::fill_0_from_2_faces");
+
+ mln_precondition(exact(inout_).is_valid());
+ I& inout = exact(inout_);
+ F& f = exact(f_);
+
+ mln_piter(I) p(inout.domain());
+ for_all(p)
+ if (is_0_face(p))
+ inout(p) = f(inout(p + up_left), inout(p + up_right), inout(p + down_left), inout(p
+ down_right));
+
+ trace::exiting("mln::world::k1::fill_0_from_2_faces");
+ }
+
+
+ template <typename I, typename A>
+ void fill_0_from_2_faces(Image<I>& inout_, const
Accumulator<A>& accu_)
+ {
+ trace::entering("mln::world::k1::fill_0_from_2_faces");
+
+ mln_precondition(exact(inout_).is_valid());
+ I& inout = exact(inout_);
+ (void) accu_;
+
+ A accu = A();
+ mln_piter(I) p(inout.domain());
+ for_all(p)
+ if (is_0_face(p))
+ {
+ accu.init();
+ accu.take(inout(p + up_left));
+ accu.take(inout(p + up_right));
+ accu.take(inout(p + down_left));
+ accu.take(inout(p + down_right));
+ inout(p) = accu.to_result();
+ }
+
+ trace::exiting("mln::world::k1::fill_0_from_2_faces");
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_FILL_0_FROM_2_FACES_HH
diff --git a/milena/mln/world/k1/fill_0_from_primary_faces.hh
b/milena/mln/world/k1/fill_0_from_primary_faces.hh
new file mode 100644
index 0000000..db3aed8
--- /dev/null
+++ b/milena/mln/world/k1/fill_0_from_primary_faces.hh
@@ -0,0 +1,109 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+///
+/// \brief Fill 1 faces in a K1 2D image using its primary faces.
+
+#ifndef MLN_WORLD_K1_FILL_0_FROM_PRIMARY_FACES_HH
+# define MLN_WORLD_K1_FILL_0_FROM_PRIMARY_FACES_HH
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/fill_0_from_2_faces.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /*! \brief Fill 0 faces in a K1 2D image using its primary faces.
+
+ \param[in,out] inout A 2D image immersed in K1.
+ \param[in,out] f A functor computing a result from four values.
+
+ This function use the following neighborhood:
+
+ \verbatim
+ x x
+ .
+ x x
+ \endverbatim
+
+
+ */
+ template <typename I, typename F>
+ void fill_0_from_primary_faces(Image<I>& inout,
Function_vvvv2v<F>& f);
+
+ /// \overload
+ template <typename I, typename A>
+ void fill_0_from_primary_faces(Image<I>& inout, const
Accumulator<A>& accu);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facade
+
+
+ template <typename I, typename F>
+ void fill_0_from_primary_faces(Image<I>& inout,
Function_vvvv2v<F>& f)
+ {
+ trace::entering("mln::world::k1::fill_0_from_primary_faces");
+
+ mln_precondition(exact(inout).is_valid());
+
+ fill_0_from_2_faces(inout, f);
+
+ trace::exiting("mln::world::k1::fill_0_from_primary_faces");
+ }
+
+
+ template <typename I, typename A>
+ void fill_0_from_primary_faces(Image<I>& inout, const
Accumulator<A>& accu)
+ {
+ trace::entering("mln::world::k1::fill_0_from_primary_faces");
+
+ mln_precondition(exact(inout).is_valid());
+
+ fill_0_from_2_faces(inout, accu);
+
+ trace::exiting("mln::world::k1::fill_0_from_primary_faces");
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_FILL_0_FROM_PRIMARY_FACES_HH
diff --git a/milena/mln/world/k1/fill_1_from_2_faces.hh
b/milena/mln/world/k1/fill_1_from_2_faces.hh
new file mode 100644
index 0000000..abec694
--- /dev/null
+++ b/milena/mln/world/k1/fill_1_from_2_faces.hh
@@ -0,0 +1,142 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+///
+/// \brief Fill 1 faces in a K1 2D image using its 2 faces.
+
+#ifndef MLN_WORLD_K1_FILL_1_FROM_2_FACES_HH
+# define MLN_WORLD_K1_FILL_1_FROM_2_FACES_HH
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/is_1_face_vertical.hh>
+# include <mln/world/k1/is_1_face_horizontal.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /*! \brief Fill 1 faces in a K1 2D image using its 2 faces.
+
+ \param[in,out] inout A 2D image immersed in K1.
+ \param[in,out] f A functor computing a result from two values.
+
+ This function use the following neighborhoods:
+
+ * In case of vertical 1 faces:
+
+ \verbatim
+ x | x
+ \endverbatim
+
+ * In case of horizontal 1 face:
+
+ \verbatim
+ x
+ -
+ x
+ \endverbatim
+
+ */
+ template <typename I, typename F>
+ void fill_1_from_2_faces(Image<I>& inout, Function_vv2v<F>&
f);
+
+ /// \overload
+ template <typename I, typename A>
+ void fill_1_from_2_faces(Image<I>& inout, const Accumulator<A>&
accu);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facade
+
+
+ template <typename I, typename F>
+ void fill_1_from_2_faces(Image<I>& inout_, Function_vv2v<F>&
f_)
+ {
+ trace::entering("mln::world::k1::fill_1_from_2_faces");
+
+ mln_precondition(exact(inout_).is_valid());
+ I& inout = exact(inout_);
+ F& f = exact(f_);
+
+ mln_piter(I) p(inout.domain());
+ for_all(p)
+ if (is_1_face_vertical(p))
+ inout(p) = f(inout(p + left), inout(p + right));
+ else if (is_1_face_horizontal(p))
+ inout(p) = f(inout(p + up), inout(p + down));
+
+ trace::exiting("mln::world::k1::fill_1_from_2_faces");
+ }
+
+
+ template <typename I, typename A>
+ void fill_1_from_2_faces(Image<I>& inout_, const
Accumulator<A>& accu_)
+ {
+ trace::entering("mln::world::k1::fill_1_from_2_faces");
+
+ mln_precondition(exact(inout_).is_valid());
+ I& inout = exact(inout_);
+ (void) accu_;
+
+ A accu = A();
+ mln_piter(I) p(inout.domain());
+ for_all(p)
+ if (is_1_face_vertical(p))
+ {
+ accu.init();
+ accu.take(inout(p + left));
+ accu.take(inout(p + right));
+ inout(p) = accu.to_result();
+ }
+ else if (is_1_face_horizontal(p))
+ {
+ accu.init();
+ accu.take(inout(p + up));
+ accu.take(inout(p + down));
+ inout(p) = accu.to_result();
+ }
+
+ trace::exiting("mln::world::k1::fill_1_from_2_faces");
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_FILL_1_FROM_2_FACES_HH
diff --git a/milena/mln/world/k1/fill_1_from_aux_2_faces.hh
b/milena/mln/world/k1/fill_1_from_aux_2_faces.hh
new file mode 100644
index 0000000..e8a7358
--- /dev/null
+++ b/milena/mln/world/k1/fill_1_from_aux_2_faces.hh
@@ -0,0 +1,155 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+///
+/// \brief Fill 1 faces in a K1 2D image using 2 faces from an
+/// auxiliary image.
+
+#ifndef MLN_WORLD_K1_FILL_1_FROM_AUX_2_FACES_HH
+# define MLN_WORLD_K1_FILL_1_FROM_AUX_2_FACES_HH
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/is_1_face_vertical.hh>
+# include <mln/world/k1/is_1_face_horizontal.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /*! \brief Fill 1 faces in a K1 2D image using 2 faces from an
+ auxiliary image.
+
+ \param[in,out] inout A 2D image immersed in K1.
+ \param[in] aux A 2D image with the same domain as \p inout.
+ \param[in,out] f A functor computing a result from two values.
+
+ This function use the following neighborhoods:
+
+ * In case of vertical 1 faces:
+
+ \verbatim
+ x | x
+ \endverbatim
+
+ * In case of horizontal 1 face:
+
+ \verbatim
+ x
+ -
+ x
+ \endverbatim
+
+ */
+ template <typename I, typename J, typename F>
+ void fill_1_from_aux_2_faces(Image<I>& inout, const Image<J>&
aux,
+ Function_vv2v<F>& f);
+
+ /// \overload
+ template <typename I, typename J, typename A>
+ void fill_1_from_aux_2_faces(Image<I>& inout, const Image<J>&
aux,
+ const Accumulator<A>& accu);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facade
+
+
+ template <typename I, typename J, typename F>
+ void fill_1_from_aux_2_faces(Image<I>& inout_, const Image<J>&
aux_,
+ Function_vv2v<F>& f_)
+ {
+ trace::entering("mln::world::k1::fill_1_from_aux_2_faces");
+
+ mln_precondition(exact(inout_).is_valid());
+ mln_precondition(exact(aux_).is_valid());
+ mln_precondition(exact(inout_).domain() == exact(aux_).domain());
+ I& inout = exact(inout_);
+ const J& aux = exact(aux_);
+ F& f = exact(f_);
+
+ mln_piter(I) p(inout.domain());
+ for_all(p)
+ if (is_1_face_vertical(p))
+ inout(p) = f(aux(p + left), aux(p + right));
+ else if (is_1_face_horizontal(p))
+ inout(p) = f(aux(p + up), aux(p + down));
+
+ trace::exiting("mln::world::k1::fill_1_from_aux_2_faces");
+ }
+
+
+ template <typename I, typename J, typename A>
+ void fill_1_from_aux_2_faces(Image<I>& inout_, const Image<J>&
aux_,
+ const Accumulator<A>& accu_)
+ {
+ trace::entering("mln::world::k1::fill_1_from_aux_2_faces");
+
+ mln_precondition(exact(inout_).is_valid());
+ mln_precondition(exact(aux_).is_valid());
+ mln_precondition(exact(inout_).domain() == exact(aux_).domain());
+ I& inout = exact(inout_);
+ const J& aux = exact(aux_);
+ (void) accu_;
+
+ A accu = A();
+ mln_piter(I) p(inout.domain());
+ for_all(p)
+ if (is_1_face_vertical(p))
+ {
+ accu.init();
+ accu.take(aux(p + left));
+ accu.take(aux(p + right));
+ inout(p) = accu.to_result();
+ }
+ else if (is_1_face_horizontal(p))
+ {
+ accu.init();
+ accu.take(aux(p + up));
+ accu.take(aux(p + down));
+ inout(p) = accu.to_result();
+ }
+
+ trace::exiting("mln::world::k1::fill_1_from_aux_2_faces");
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_FILL_1_FROM_AUX_2_FACES_HH
diff --git a/milena/mln/world/k1/fill_2_from_1_faces.hh
b/milena/mln/world/k1/fill_2_from_1_faces.hh
new file mode 100644
index 0000000..c539e30
--- /dev/null
+++ b/milena/mln/world/k1/fill_2_from_1_faces.hh
@@ -0,0 +1,127 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+///
+/// \brief Fill 2 faces in a K1 2D image using its 1 faces.
+
+#ifndef MLN_WORLD_K1_FILL_2_FROM_1_FACES_HH
+# define MLN_WORLD_K1_FILL_2_FROM_1_FACES_HH
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/is_2_face.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /*! \brief Fill 0 faces in a K1 2D image using its 2 faces.
+
+ \param[in,out] inout A 2D image immersed in K1.
+ \param[in,out] f A functor computing a result from four values.
+
+ This function use the following neighborhood:
+
+ \verbatim
+ -
+ |o|
+ -
+ \endverbatim
+
+
+ */
+ template <typename I, typename F>
+ void fill_2_from_1_faces(Image<I>& inout, Function_vvvv2v<F>&
f);
+
+ /// \overload
+ template <typename I, typename A>
+ void fill_2_from_1_faces(Image<I>& inout, const Accumulator<A>&
accu);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facade
+
+
+ template <typename I, typename F>
+ void fill_2_from_1_faces(Image<I>& inout_, Function_vvvv2v<F>&
f_)
+ {
+ trace::entering("mln::world::k1::fill_2_from_1_faces");
+
+ mln_precondition(exact(inout_).is_valid());
+ I& inout = exact(inout_);
+ F& f = exact(f_);
+
+ mln_piter(I) p(inout.domain());
+ for_all(p)
+ if (is_2_face(p))
+ inout(p) = f(inout(p + up), inout(p + left), inout(p + right), inout(p + down));
+
+ trace::exiting("mln::world::k1::fill_2_from_1_faces");
+ }
+
+
+ template <typename I, typename A>
+ void fill_2_from_1_faces(Image<I>& inout_, const
Accumulator<A>& accu_)
+ {
+ trace::entering("mln::world::k1::fill_2_from_1_faces");
+
+ mln_precondition(exact(inout_).is_valid());
+ I& inout = exact(inout_);
+ (void) accu_;
+
+ A accu = A();
+ mln_piter(I) p(inout.domain());
+ for_all(p)
+ if (is_2_face(p))
+ {
+ accu.init();
+ accu.take(inout(p + up));
+ accu.take(inout(p + left));
+ accu.take(inout(p + right));
+ accu.take(inout(p + down));
+ inout(p) = accu.to_result();
+ }
+
+ trace::exiting("mln::world::k1::fill_2_from_1_faces");
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_FILL_2_FROM_1_FACES_HH
diff --git a/milena/mln/world/k1/immerse.hh b/milena/mln/world/k1/immerse.hh
index 928012b..b9b58fb 100644
--- a/milena/mln/world/k1/immerse.hh
+++ b/milena/mln/world/k1/immerse.hh
@@ -66,6 +66,14 @@ namespace mln
namespace internal
{
+ /// Return the equivalent point in K1 from a point in K0.
+ inline
+ point2d immerse_point(const point2d& p)
+ {
+ point2d tmp(2 * p.row(), 2 * p.col());
+ return tmp;
+ }
+
/// \brief Return the equivalent domain in K1 from a domain in
/// K0.
template <typename B>
@@ -77,15 +85,7 @@ namespace mln
mln_deduce(B, site, delta) one;
one.set_all(1);
- return B(2 * b.pmin() - one, 2 * b.pmax() + one);
- }
-
- inline
- point2d
- immerse_point(const point2d& p)
- {
- point2d tmp(2 * p.row(), 2 * p.col());
- return tmp;
+ return B(immerse_point(b.pmin()) - one, immerse_point(b.pmax()) + one);
}
} // end of namespace mln::world::k1::internal
diff --git a/milena/mln/world/k1/immerse_and_duplicate_2_to_0_1_faces.hh
b/milena/mln/world/k1/immerse_and_duplicate_2_to_0_1_faces.hh
new file mode 100644
index 0000000..137f4a3
--- /dev/null
+++ b/milena/mln/world/k1/immerse_and_duplicate_2_to_0_1_faces.hh
@@ -0,0 +1,125 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+///
+/// \brief Immerse a 2D image into K1 and copy 2 faces data into 0 and
+/// 1 faces.
+
+#ifndef MLN_WORLD_K1_IMMERSE_AND_DUPLICATE_2_TO_0_1_FACES_HH
+# define MLN_WORLD_K1_IMMERSE_AND_DUPLICATE_2_TO_0_1_FACES_HH
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/box.hh>
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/immerse.hh>
+# include <mln/world/k1/is_1_face_vertical.hh>
+# include <mln/world/k1/is_1_face_horizontal.hh>
+# include <mln/world/k1/is_0_face.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /*! \brief Immerse a 2D image into K1 and copy 2 faces data into
+ * 0 and 1 faces.
+
+ Data is copied into 1 faces located at the bottom right of each
+ 2 faces.
+
+ -1 0 1 2 3
+ 0 1 -1 a a a d d
+ 0 a d 0 a a a d d
+ 1 b c -> 1 a a a d d
+ 2 b b b c c
+ 3 b b b c c
+
+ */
+ template <typename I>
+ mln_concrete(I)
+ immerse_and_duplicate_2_to_0_1_faces(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // Facade
+
+ template <typename I>
+ mln_concrete(I) immerse_and_duplicate_2_to_0_1_faces(const Image<I>&
ima_)
+ {
+ trace::entering("mln::world::k1::immerse_and_duplicate_2_to_0_1_faces");
+ mln_precondition(exact(ima_).is_valid());
+ const I& ima = exact(ima_);
+
+ mln_concrete(I) output = immerse(ima);
+
+ mln_piter(I) p(output.domain());
+ for_all(p)
+ if (is_1_face_vertical(p))
+ {
+ if (output.domain().has(p + left))
+ output(p) = output(p + left);
+ else // Handle left border
+ output(p) = output(p + right);
+ }
+ else if (is_1_face_horizontal(p))
+ {
+ if (output.domain().has(p + up))
+ output(p) = output(p + up);
+ else // Handle top border
+ output(p) = output(p + down);
+ }
+ else if (is_0_face(p))
+ {
+ if (output.domain().has(p + up_left))
+ output(p) = output(p + up_left);
+ else if (output.domain().has(p + up_right)) // Handle left border
+ output(p) = output(p + up_right);
+ else
+ output(p) = output(p + down_left); // Handle top border
+ }
+
+ // First top left corner pixel. (Special case)
+ output(output.domain().pmin()) = output(output.domain().pmin() + down_right);
+
+ trace::exiting("mln::world::k1::immerse_and_duplicate_2_to_0_1_faces");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_IMMERSE_AND_DUPLICATE_2_TO_0_1_FACES_HH
diff --git a/milena/mln/world/k1/immerse_and_duplicate_2_to_1_faces.hh
b/milena/mln/world/k1/immerse_and_duplicate_2_to_1_faces.hh
new file mode 100644
index 0000000..27c1eb9
--- /dev/null
+++ b/milena/mln/world/k1/immerse_and_duplicate_2_to_1_faces.hh
@@ -0,0 +1,111 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+///
+/// \brief Immerse a 2D image into K1 and copy 2 faces data into 1
+/// faces.
+
+#ifndef MLN_WORLD_K1_IMMERSE_AND_DUPLICATE_2_TO_1_FACES_HH
+# define MLN_WORLD_K1_IMMERSE_AND_DUPLICATE_2_TO_1_FACES_HH
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/box.hh>
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/immerse.hh>
+# include <mln/world/k1/is_1_face_vertical.hh>
+# include <mln/world/k1/is_1_face_horizontal.hh>
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /*! \brief Immerse a 2D image into K1 and copy 2 faces data into
+ * 1 faces.
+
+ Data is copied into 1 faces located at the bottom right of each
+ 2 faces.
+
+ -1 0 1 2 3
+ 0 1 -1 . a . d .
+ 0 a d 0 a a a d d
+ 1 b c -> 1 . a . d .
+ 2 b b b c c
+ 3 . b . c .
+
+ */
+ template <typename I>
+ mln_concrete(I)
+ immerse_and_duplicate_2_to_1_faces(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // Facade
+
+ template <typename I>
+ mln_concrete(I) immerse_and_duplicate_2_to_1_faces(const Image<I>& ima_)
+ {
+ trace::entering("mln::world::k1::immerse_and_duplicate_2_to_1_faces");
+ mln_precondition(exact(ima_).is_valid());
+ const I& ima = exact(ima_);
+
+ mln_concrete(I) output = immerse(ima);
+
+ mln_piter(I) p(output.domain());
+ for_all(p)
+ if (is_1_face_vertical(p))
+ {
+ if (output.domain().has(p + left))
+ output(p) = output(p + left);
+ else // Handle left border
+ output(p) = output(p + right);
+ }
+ else if (is_1_face_horizontal(p))
+ {
+ if (output.domain().has(p + up))
+ output(p) = output(p + up);
+ else // Handle top border
+ output(p) = output(p + down);
+ }
+
+ trace::exiting("mln::world::k1::immerse_and_duplicate_2_to_1_faces");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_IMMERSE_AND_DUPLICATE_2_TO_1_FACES_HH
diff --git a/milena/mln/world/k1/internal/face_dim.hh
b/milena/mln/world/k1/internal/face_dim.hh
index b933e86..34a0247 100644
--- a/milena/mln/world/k1/internal/face_dim.hh
+++ b/milena/mln/world/k1/internal/face_dim.hh
@@ -47,6 +47,9 @@ namespace mln
/// \brief Returns the dimension of site in K1.
unsigned face_dim(const point2d& p);
+ /// \overload
+ unsigned face_dim(const mln::def::coord& row, const mln::def::coord& col);
+
# ifndef MLN_INCLUDE_ONLY
@@ -56,7 +59,13 @@ namespace mln
inline
unsigned face_dim(const point2d& p)
{
- return (p[0] % 2 == 0) + (p[1] % 2 == 0);
+ return face_dim(p.row(), p.col());
+ }
+
+ inline
+ unsigned face_dim(const mln::def::coord& row, const mln::def::coord& col)
+ {
+ return (row % 2 == 0) + (col % 2 == 0);
}
diff --git a/milena/mln/world/k1/is_0_face.hh b/milena/mln/world/k1/is_0_face.hh
index c9d9b0e..01878d9 100644
--- a/milena/mln/world/k1/is_0_face.hh
+++ b/milena/mln/world/k1/is_0_face.hh
@@ -46,6 +46,10 @@ namespace mln
/// \brief Check if site is a 0 face
bool is_0_face(const point2d& p);
+ /// \overload
+ bool is_0_face(const mln::def::coord& row,
+ const mln::def::coord& col);
+
# ifndef MLN_INCLUDE_ONLY
@@ -55,9 +59,15 @@ namespace mln
inline
bool is_0_face(const point2d& p)
{
- return internal::face_dim(p) == 0;
+ return is_0_face(p.row(), p.col());
}
+ inline
+ bool is_0_face(const mln::def::coord& row,
+ const mln::def::coord& col)
+ {
+ return internal::face_dim(row, col) == 0;
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/world/k1/is_1_face.hh b/milena/mln/world/k1/is_1_face.hh
index aafa442..60e2fdf 100644
--- a/milena/mln/world/k1/is_1_face.hh
+++ b/milena/mln/world/k1/is_1_face.hh
@@ -47,6 +47,12 @@ namespace mln
bool is_1_face(const point2d& p);
+ /// \overload
+ inline
+ bool is_1_face(const mln::def::coord& row,
+ const mln::def::coord& col);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -55,7 +61,14 @@ namespace mln
inline
bool is_1_face(const point2d& p)
{
- return internal::face_dim(p) == 1;
+ return is_1_face(p.row(), p.col());
+ }
+
+ inline
+ bool is_1_face(const mln::def::coord& row,
+ const mln::def::coord& col)
+ {
+ return internal::face_dim(row, col) == 1;
}
diff --git a/milena/mln/world/k1/is_1_face_horizontal.hh
b/milena/mln/world/k1/is_1_face_horizontal.hh
index ff90b0c..e0e9cd8 100644
--- a/milena/mln/world/k1/is_1_face_horizontal.hh
+++ b/milena/mln/world/k1/is_1_face_horizontal.hh
@@ -47,6 +47,10 @@ namespace mln
bool is_1_face_horizontal(const point2d& p);
+ /// \overload
+ bool is_1_face_horizontal(const mln::def::coord& row,
+ const mln::def::coord& col);
+
# ifndef MLN_INCLUDE_ONLY
@@ -55,9 +59,14 @@ namespace mln
inline
bool is_1_face_horizontal(const point2d& p)
{
- return is_1_face(p) && p[1] % 2 == 0;
+ return is_1_face_horizontal(p.row(), p.col());
}
+ bool is_1_face_horizontal(const mln::def::coord& row,
+ const mln::def::coord& col)
+ {
+ return is_1_face(row, col) && col % 2 == 0;
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/world/k1/is_1_face_vertical.hh
b/milena/mln/world/k1/is_1_face_vertical.hh
index f10067d..b96bfe3 100644
--- a/milena/mln/world/k1/is_1_face_vertical.hh
+++ b/milena/mln/world/k1/is_1_face_vertical.hh
@@ -47,6 +47,11 @@ namespace mln
bool is_1_face_vertical(const point2d& p);
+ /// \overload
+ bool is_1_face_vertical(const mln::def::coord& row,
+ const mln::def::coord& col);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -55,7 +60,15 @@ namespace mln
inline
bool is_1_face_vertical(const point2d& p)
{
- return is_1_face(p) && p[0] % 2 == 0;
+ return is_1_face_vertical(p.row(), p.col());
+ }
+
+
+ inline
+ bool is_1_face_vertical(const mln::def::coord& row,
+ const mln::def::coord& col)
+ {
+ return is_1_face(row, col) && row % 2 == 0;
}
diff --git a/milena/mln/world/k1/is_2_face.hh b/milena/mln/world/k1/is_2_face.hh
index b3c8c98..4b40475 100644
--- a/milena/mln/world/k1/is_2_face.hh
+++ b/milena/mln/world/k1/is_2_face.hh
@@ -47,6 +47,11 @@ namespace mln
bool is_2_face(const point2d& p);
+ /// \overload
+ bool is_2_face(const mln::def::coord& row,
+ const mln::def::coord& col);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -55,9 +60,14 @@ namespace mln
inline
bool is_2_face(const point2d& p)
{
- return internal::face_dim(p) == 2;
+ return is_2_face(p.row(), p.col());
}
+ bool is_2_face(const mln::def::coord& row,
+ const mln::def::coord& col)
+ {
+ return internal::face_dim(row, col) == 2;
+ }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/world/k1/is_primary_face.hh
b/milena/mln/world/k1/is_primary_face.hh
index 572d25c..38639cc 100644
--- a/milena/mln/world/k1/is_primary_face.hh
+++ b/milena/mln/world/k1/is_primary_face.hh
@@ -47,6 +47,11 @@ namespace mln
bool is_primary_face(const point2d& p);
+ /// \overload
+ bool is_primary_face(const mln::def::coord& row,
+ const mln::def::coord& col);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -58,6 +63,13 @@ namespace mln
return is_2_face(p);
}
+ inline
+ bool is_primary_face(const mln::def::coord& row,
+ const mln::def::coord& col)
+ {
+ return is_2_face(row, col);
+ }
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/world/k1/un_immerse.hh b/milena/mln/world/k1/un_immerse.hh
index 7978be9..8506f56 100644
--- a/milena/mln/world/k1/un_immerse.hh
+++ b/milena/mln/world/k1/un_immerse.hh
@@ -1,21 +1,123 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+///
+/// \brief Un-immerse a 2D image from K1 to K0.
- inline
- point2d
- un_immerse(const point2d& p)
- {
- point2d tmp(p.row() / 2, p.col() / 2);
- return tmp;
- }
- struct is_2_face_t : Function_v2b< is_2_face_t >
- {
- typedef bool result;
- inline bool operator()(const point2d& p) const { return FIXME; } // p.row() % 2
&& p.col() % 2
- } is_2_face;
+#ifndef MLN_WORLD_K1_UN_IMMERSE_HH
+# define MLN_WORLD_K1_UN_IMMERSE_HH
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/box.hh>
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/is_2_face.hh>
+
+namespace mln
+{
- struct is_not_2_face_t : Function_v2b< is_not_2_face_t >
+ namespace world
{
- typedef bool result;
- inline bool operator()(const point2d& p) const { return FIXME; } // ! (p.row() %
2 && p.col() % 2)
- } is_not_2_face;
+
+ namespace k1
+ {
+
+ /*! \brief Un-immerse a 2D image from K1 to K0.
+
+ \verbatim
+
+ -1 0 1 2 3
+ -1 . - . - . 0 1
+ 0 | o | o | 0 o o
+ 1 . - . - . -> 1 o o
+ 2 | o | o |
+ 3 . - . - .
+
+ \endverbatim
+
+ */
+ template <typename I>
+ mln_concrete(I) un_immerse(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ /// Return the equivalent point in K1 from a point in K0.
+ inline
+ point2d un_immerse_point(const point2d& p)
+ {
+ point2d tmp(p.row() / 2, p.col() / 2);
+ return tmp;
+ }
+
+ /// \brief Return the equivalent domain in K0 from a domain in
+ /// K1.
+ template <typename B>
+ inline
+ B domain_K0_from_K1(const Box<B>& b_)
+ {
+ mln_precondition(exact(b_).is_valid());
+ const B& b = exact(b_);
+ return B(un_immerse_point(b.pmin()), un_immerse_point(b.pmax()));
+ }
+
+ } // end of namespace mln::world::k1::internal
+
+
+
+ // Facade
+
+ template <typename I>
+ mln_concrete(I) un_immerse(const Image<I>& ima_)
+ {
+ trace::entering("mln::world::k1::un_immerse");
+ mln_precondition(exact(ima_).is_valid());
+ const I& ima = exact(ima_);
+
+ mln_concrete(I) output(internal::domain_K0_from_K1(ima.domain()));
+
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ if (is_2_face(p))
+ output(internal::un_immerse_point(p)) = ima(p);
+
+ trace::exiting("mln::world::k1::un_immerse");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_UN_IMMERSE_HH
+
diff --git a/milena/tests/world/k1/Makefile.am b/milena/tests/world/k1/Makefile.am
index daa0d94..68866fb 100644
--- a/milena/tests/world/k1/Makefile.am
+++ b/milena/tests/world/k1/Makefile.am
@@ -18,19 +18,34 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
display_enlarged \
+ fill_0_from_1_faces \
+ fill_0_from_2_faces \
+ fill_0_from_primary_faces \
+ fill_1_from_2_faces \
+ fill_1_from_aux_2_faces \
+ fill_2_from_1_faces \
immerse \
immerse_and_duplicate_2_to_1_faces \
+ immerse_and_duplicate_2_to_0_1_faces \
is_0_face \
is_0_or_1_face \
is_1_face \
is_1_face_vertical \
is_1_face_horizontal \
is_2_face \
- is_primary_face
+ is_primary_face \
+ un_immerse
display_enlarged_SOURCES = display_enlarged.cc
+fill_0_from_1_faces_SOURCES = fill_0_from_1_faces.cc
+fill_0_from_2_faces_SOURCES = fill_0_from_2_faces.cc
+fill_0_from_primary_faces_SOURCES = fill_0_from_primary_faces.cc
+fill_1_from_2_faces_SOURCES = fill_1_from_2_faces.cc
+fill_1_from_aux_2_faces_SOURCES = fill_1_from_aux_2_faces.cc
+fill_2_from_1_faces_SOURCES = fill_2_from_1_faces.cc
immerse_SOURCES = immerse.cc
immerse_and_duplicate_2_to_1_faces_SOURCES = immerse_and_duplicate_2_to_1_faces.cc
+immerse_and_duplicate_2_to_0_1_faces_SOURCES = immerse_and_duplicate_2_to_0_1_faces.cc
is_0_face_SOURCES = is_0_face.cc
is_0_or_1_face_SOURCES = is_0_or_1_face.cc
is_1_face_SOURCES = is_1_face.cc
@@ -38,5 +53,6 @@ is_1_face_vertical_SOURCES = is_1_face_vertical.cc
is_1_face_horizontal_SOURCES = is_1_face_horizontal.cc
is_2_face_SOURCES = is_2_face.cc
is_primary_face_SOURCES = is_primary_face.cc
+un_immerse_SOURCES = un_immerse.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/world/k1/fill_0_from_1_faces.cc
b/milena/tests/world/k1/fill_0_from_1_faces.cc
new file mode 100644
index 0000000..b6c1db6
--- /dev/null
+++ b/milena/tests/world/k1/fill_0_from_1_faces.cc
@@ -0,0 +1,93 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+
+#include <mln/core/image/image2d.hh>
+#include <mln/make/box2d.hh>
+#include <mln/data/compare.hh>
+#include <mln/accu/math/sum.hh>
+#include <mln/world/k1/fill_0_from_1_faces.hh>
+#include <mln/border/fill.hh>
+
+
+namespace mln
+{
+
+ struct sum_t : Function_vvvv2v<sum_t>
+ {
+ typedef int result;
+
+ int operator()(const int& v1, const int& v2, const int& v3, const
int& v4) const
+ {
+ return v1 + v2 + v3 + v4;
+ }
+
+ };
+
+}
+
+
+
+int main()
+{
+ using namespace mln;
+
+ int refvals[5][5] = {
+ {2, 1, 3, 1, 2},
+ {1, 0, 1, 0, 1},
+ {3, 1, 4, 1, 3},
+ {1, 0, 1, 0, 1},
+ {2, 1, 3, 1, 2}
+ };
+ image2d<int> ref = make::image(refvals, point2d(-1, -1));
+
+ int vals[5][5] = {
+ {0, 1, 0, 1, 0 },
+ {1, 0, 1, 0, 1 },
+ {0, 1, 0, 1, 0 },
+ {1, 0, 1, 0, 1 },
+ {0, 1, 0, 1, 0 }
+ };
+ image2d<int> imak1 = make::image(vals, point2d(-1, -1));
+
+ /// Make sure the border is set to 0 to get deterministic results.
+ border::fill(imak1, 0);
+
+
+ // Overload with accumulator
+ {
+ accu::math::sum<int> accu;
+ world::k1::fill_0_from_1_faces(imak1, accu);
+ mln_assertion(ref == imak1);
+ }
+
+ // Overload with function
+ {
+ sum_t f;
+ world::k1::fill_0_from_1_faces(imak1, f);
+ mln_assertion(ref == imak1);
+ }
+}
diff --git a/milena/tests/world/k1/fill_0_from_2_faces.cc
b/milena/tests/world/k1/fill_0_from_2_faces.cc
new file mode 100644
index 0000000..c32a0f2
--- /dev/null
+++ b/milena/tests/world/k1/fill_0_from_2_faces.cc
@@ -0,0 +1,93 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+
+#include <mln/core/image/image2d.hh>
+#include <mln/make/box2d.hh>
+#include <mln/data/compare.hh>
+#include <mln/accu/math/sum.hh>
+#include <mln/world/k1/fill_0_from_2_faces.hh>
+#include <mln/border/fill.hh>
+
+
+namespace mln
+{
+
+ struct sum_t : Function_vvvv2v<sum_t>
+ {
+ typedef int result;
+
+ int operator()(const int& v1, const int& v2, const int& v3, const
int& v4) const
+ {
+ return v1 + v2 + v3 + v4;
+ }
+
+ };
+
+}
+
+
+
+int main()
+{
+ using namespace mln;
+
+ int refvals[5][5] = {
+ {1, 0, 2, 0, 1},
+ {0, 1, 0, 1, 0},
+ {2, 0, 4, 0, 2},
+ {0, 1, 0, 1, 0},
+ {1, 0, 2, 0, 1}
+ };
+ image2d<int> ref = make::image(refvals, point2d(-1, -1));
+
+ int vals[5][5] = {
+ {0, 0, 0, 0, 0 },
+ {0, 1, 0, 1, 0 },
+ {0, 0, 0, 0, 0 },
+ {0, 1, 0, 1, 0 },
+ {0, 0, 0, 0, 0 }
+ };
+ image2d<int> imak1 = make::image(vals, point2d(-1, -1));
+
+ /// Make sure the border is set to 0 to get deterministic results.
+ border::fill(imak1, 0);
+
+
+ // Overload with accumulator
+ {
+ accu::math::sum<int> accu;
+ world::k1::fill_0_from_2_faces(imak1, accu);
+ mln_assertion(ref == imak1);
+ }
+
+ // Overload with function
+ {
+ sum_t f;
+ world::k1::fill_0_from_2_faces(imak1, f);
+ mln_assertion(ref == imak1);
+ }
+}
diff --git a/milena/tests/world/k1/fill_0_from_primary_faces.cc
b/milena/tests/world/k1/fill_0_from_primary_faces.cc
new file mode 100644
index 0000000..70b9b1a
--- /dev/null
+++ b/milena/tests/world/k1/fill_0_from_primary_faces.cc
@@ -0,0 +1,93 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+
+#include <mln/core/image/image2d.hh>
+#include <mln/make/box2d.hh>
+#include <mln/data/compare.hh>
+#include <mln/accu/math/sum.hh>
+#include <mln/world/k1/fill_0_from_primary_faces.hh>
+#include <mln/border/fill.hh>
+
+
+namespace mln
+{
+
+ struct sum_t : Function_vvvv2v<sum_t>
+ {
+ typedef int result;
+
+ int operator()(const int& v1, const int& v2, const int& v3, const
int& v4) const
+ {
+ return v1 + v2 + v3 + v4;
+ }
+
+ };
+
+}
+
+
+
+int main()
+{
+ using namespace mln;
+
+ int refvals[5][5] = {
+ {1, 0, 2, 0, 1},
+ {0, 1, 0, 1, 0},
+ {2, 0, 4, 0, 2},
+ {0, 1, 0, 1, 0},
+ {1, 0, 2, 0, 1}
+ };
+ image2d<int> ref = make::image(refvals, point2d(-1, -1));
+
+ int vals[5][5] = {
+ {0, 0, 0, 0, 0 },
+ {0, 1, 0, 1, 0 },
+ {0, 0, 0, 0, 0 },
+ {0, 1, 0, 1, 0 },
+ {0, 0, 0, 0, 0 }
+ };
+ image2d<int> imak1 = make::image(vals, point2d(-1, -1));
+
+ /// Make sure the border is set to 0 to get deterministic results.
+ border::fill(imak1, 0);
+
+
+ // Overload with accumulator
+ {
+ accu::math::sum<int> accu;
+ world::k1::fill_0_from_primary_faces(imak1, accu);
+ mln_assertion(ref == imak1);
+ }
+
+ // Overload with function
+ {
+ sum_t f;
+ world::k1::fill_0_from_primary_faces(imak1, f);
+ mln_assertion(ref == imak1);
+ }
+}
diff --git a/milena/tests/world/k1/fill_1_from_2_faces.cc
b/milena/tests/world/k1/fill_1_from_2_faces.cc
new file mode 100644
index 0000000..8822e60
--- /dev/null
+++ b/milena/tests/world/k1/fill_1_from_2_faces.cc
@@ -0,0 +1,94 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+
+#include <mln/core/image/image2d.hh>
+#include <mln/make/box2d.hh>
+#include <mln/data/compare.hh>
+#include <mln/accu/math/sum.hh>
+#include <mln/world/k1/fill_1_from_2_faces.hh>
+#include <mln/border/fill.hh>
+
+
+namespace mln
+{
+
+ struct sum_t : Function_vv2v<sum_t>
+ {
+ typedef int result;
+
+ int operator()(const int& v1, const int& v2) const
+ {
+ return v1 + v2;
+ }
+
+ };
+
+}
+
+
+
+int main()
+{
+ using namespace mln;
+
+ int refvals[5][5] = {
+ {1, 3, 1, 3, 1},
+ {3, 3, 6, 3, 3},
+ {1, 6, 1, 6, 1},
+ {3, 3, 6, 3, 3},
+ {1, 3, 1, 3, 1}
+ };
+ image2d<int> ref = make::image(refvals, point2d(-1, -1));
+
+ int vals[5][5] = {
+ {1, 0, 1, 0, 1 },
+ {0, 3, 0, 3, 0 },
+ {1, 0, 1, 0, 1 },
+ {0, 3, 0, 3, 0 },
+ {1, 0, 1, 0, 1 }
+ };
+ image2d<int> imak1 = make::image(vals, point2d(-1, -1));
+
+ /// Make sure the border is set to 0 to get deterministic results.
+ border::fill(imak1, 0);
+
+
+ // Overload with accumulator
+ {
+ accu::math::sum<int> accu;
+ world::k1::fill_1_from_2_faces(imak1, accu);
+ mln_assertion(ref == imak1);
+ }
+
+ // Overload with function
+ {
+ sum_t f;
+ world::k1::fill_1_from_2_faces(imak1, f);
+ mln_assertion(ref == imak1);
+ }
+
+}
diff --git a/milena/tests/world/k1/fill_1_from_aux_2_faces.cc
b/milena/tests/world/k1/fill_1_from_aux_2_faces.cc
new file mode 100644
index 0000000..045f540
--- /dev/null
+++ b/milena/tests/world/k1/fill_1_from_aux_2_faces.cc
@@ -0,0 +1,104 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+
+#include <mln/core/image/image2d.hh>
+#include <mln/make/box2d.hh>
+#include <mln/data/compare.hh>
+#include <mln/accu/math/sum.hh>
+#include <mln/world/k1/fill_1_from_aux_2_faces.hh>
+#include <mln/border/fill.hh>
+
+
+namespace mln
+{
+
+ struct sum_t : Function_vv2v<sum_t>
+ {
+ typedef int result;
+
+ int operator()(const int& v1, const int& v2) const
+ {
+ return v1 + v2;
+ }
+
+ };
+
+}
+
+
+
+int main()
+{
+ using namespace mln;
+
+ int refvals[5][5] = {
+ {1, 1, 1, 4, 1},
+ {1, 3, 5, 3, 4},
+ {1, 5, 1, 5, 1},
+ {4, 3, 5, 3, 1},
+ {1, 4, 1, 1, 1}
+ };
+ image2d<int> ref = make::image(refvals, point2d(-1, -1));
+
+ int auxvals[5][5] = {
+ {0, 0, 0, 0, 0 },
+ {0, 1, 0, 4, 0 },
+ {0, 0, 0, 0, 0 },
+ {0, 4, 0, 1, 0 },
+ {0, 0, 0, 0, 1 }
+ };
+ image2d<int> aux = make::image(auxvals, point2d(-1, -1));
+
+
+ int vals[5][5] = {
+ {1, 0, 1, 0, 1 },
+ {0, 3, 0, 3, 0 },
+ {1, 0, 1, 0, 1 },
+ {0, 3, 0, 3, 0 },
+ {1, 0, 1, 0, 1 }
+ };
+ image2d<int> imak1 = make::image(vals, point2d(-1, -1));
+
+ /// Make sure the border is set to 0 to get deterministic results.
+ border::fill(imak1, 0);
+
+
+ // Overload with accumulator
+ {
+ accu::math::sum<int> accu;
+ world::k1::fill_1_from_aux_2_faces(imak1, aux, accu);
+ mln_assertion(ref == imak1);
+ }
+
+ // Overload with function
+ {
+ sum_t f;
+ world::k1::fill_1_from_aux_2_faces(imak1, aux, f);
+ mln_assertion(ref == imak1);
+ }
+
+}
diff --git a/milena/tests/world/k1/fill_2_from_1_faces.cc
b/milena/tests/world/k1/fill_2_from_1_faces.cc
new file mode 100644
index 0000000..6fb3e96
--- /dev/null
+++ b/milena/tests/world/k1/fill_2_from_1_faces.cc
@@ -0,0 +1,94 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+
+#include <mln/core/image/image2d.hh>
+#include <mln/make/box2d.hh>
+#include <mln/data/compare.hh>
+#include <mln/accu/math/sum.hh>
+#include <mln/world/k1/fill_2_from_1_faces.hh>
+#include <mln/border/fill.hh>
+
+
+namespace mln
+{
+
+ struct sum_t : Function_vvvv2v<sum_t>
+ {
+ typedef int result;
+
+ int operator()(const int& v1, const int& v2, const int& v3, const
int& v4) const
+ {
+ return v1 + v2 + v3 + v4;
+ }
+
+ };
+
+}
+
+
+
+int main()
+{
+ using namespace mln;
+
+ int refvals[5][5] = {
+ {0, 1, 0, 1, 0},
+ {1, 4, 1, 4, 1},
+ {0, 1, 0, 1, 0},
+ {1, 4, 1, 4, 1},
+ {0, 1, 0, 1, 0}
+ };
+ image2d<int> ref = make::image(refvals, point2d(-1, -1));
+
+ int vals[5][5] = {
+ {0, 1, 0, 1, 0 },
+ {1, 0, 1, 0, 1 },
+ {0, 1, 0, 1, 0 },
+ {1, 0, 1, 0, 1 },
+ {0, 1, 0, 1, 0 }
+ };
+ image2d<int> imak1 = make::image(vals, point2d(-1, -1));
+
+ /// Make sure the border is set to 0 to get deterministic results.
+ border::fill(imak1, 0);
+
+
+ // Overload with accumulator
+ {
+ accu::math::sum<int> accu;
+ world::k1::fill_2_from_1_faces(imak1, accu);
+ mln_assertion(ref == imak1);
+ }
+
+ // Overload with function
+ {
+ sum_t f;
+ world::k1::fill_2_from_1_faces(imak1, f);
+ mln_assertion(ref == imak1);
+ }
+
+}
diff --git a/milena/tests/world/k1/immerse_and_duplicate_2_to_0_1_faces.cc
b/milena/tests/world/k1/immerse_and_duplicate_2_to_0_1_faces.cc
new file mode 100644
index 0000000..f03f905
--- /dev/null
+++ b/milena/tests/world/k1/immerse_and_duplicate_2_to_0_1_faces.cc
@@ -0,0 +1,55 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+
+#include <mln/core/image/image2d.hh>
+#include <mln/world/k1/immerse_and_duplicate_2_to_0_1_faces.hh>
+#include <mln/make/box2d.hh>
+#include <mln/data/compare.hh>
+
+int main()
+{
+ using namespace mln;
+
+ int ref_vals[5][5] = {
+ {1, 1, 1, 2, 2 },
+ {1, 1, 1, 2, 2 },
+ {1, 1, 1, 2, 2 },
+ {3, 3, 3, 4, 4 },
+ {3, 3, 3, 4, 4 },
+ };
+ image2d<int> ref = make::image(ref_vals, point2d(-1, -1));
+
+ int vals[2][2] = {
+ {1, 2 },
+ {3, 4 }
+ };
+ image2d<int> ima = make::image(vals);
+
+ image2d<int> immersed = world::k1::immerse_and_duplicate_2_to_0_1_faces(ima);
+
+ mln_assertion(ref == immersed);
+}
diff --git a/milena/tests/world/k1/immerse_and_duplicate_2_to_1_faces.cc
b/milena/tests/world/k1/immerse_and_duplicate_2_to_1_faces.cc
new file mode 100644
index 0000000..cbcb68d
--- /dev/null
+++ b/milena/tests/world/k1/immerse_and_duplicate_2_to_1_faces.cc
@@ -0,0 +1,55 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+
+#include <mln/core/image/image2d.hh>
+#include <mln/world/k1/immerse_and_duplicate_2_to_1_faces.hh>
+#include <mln/make/box2d.hh>
+#include <mln/data/compare.hh>
+
+int main()
+{
+ using namespace mln;
+
+ int ref_vals[5][5] = {
+ {0, 1, 0, 2, 0 },
+ {1, 1, 1, 2, 2 },
+ {0, 1, 0, 2, 0 },
+ {3, 3, 3, 4, 4 },
+ {0, 3, 0, 4, 0 },
+ };
+ image2d<int> ref = make::image(ref_vals, point2d(-1, -1));
+
+ int vals[2][2] = {
+ {1, 2 },
+ {3, 4 }
+ };
+ image2d<int> ima = make::image(vals);
+
+ image2d<int> immersed = world::k1::immerse_and_duplicate_2_to_1_faces(ima);
+
+ mln_assertion(ref == immersed);
+}
diff --git a/milena/tests/world/k1/un_immerse.cc b/milena/tests/world/k1/un_immerse.cc
new file mode 100644
index 0000000..47e06e4
--- /dev/null
+++ b/milena/tests/world/k1/un_immerse.cc
@@ -0,0 +1,54 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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
+
+#include <mln/core/image/image2d.hh>
+#include <mln/world/k1/un_immerse.hh>
+#include <mln/make/box2d.hh>
+#include <mln/data/compare.hh>
+
+int main()
+{
+ using namespace mln;
+
+ int refvals[2][2] = {
+ {3, 3},
+ {3, 3}
+ };
+ image2d<int> ref = make::image(refvals);
+
+ int vals[5][5] = {
+ {1, 2, 1, 2, 1 },
+ {2, 3, 2, 3, 2 },
+ {1, 2, 1, 2, 1 },
+ {2, 3, 2, 3, 2 },
+ {1, 2, 1, 2, 1 }
+ };
+ image2d<int> imak1 = make::image(vals, point2d(-1, -1));
+
+ image2d<int> imak0 = world::k1::un_immerse(imak1);
+ mln_assertion(imak0 == ref);
+}
--
1.7.2.5