* 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 3db410c..d778238 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.
2012-09-28 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
* 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.
---
milena/ChangeLog | 31 +++++
milena/mln/make/image.hh | 59 ++++++++--
milena/mln/world/k1/display_enlarged.hh | 154 +++++++++++++++++++++++++
milena/mln/world/k1/immerse.hh | 122 +++++++++++++++++++
milena/mln/world/k1/internal/face_dim.hh | 75 ++++++++++++
milena/mln/world/k1/is_0_face.hh | 70 +++++++++++
milena/mln/world/k1/is_0_or_1_face.hh | 71 +++++++++++
milena/mln/world/k1/is_1_face.hh | 70 +++++++++++
milena/mln/world/k1/is_1_face_horizontal.hh | 70 +++++++++++
milena/mln/world/k1/is_1_face_vertical.hh | 70 +++++++++++
milena/mln/world/k1/is_2_face.hh | 70 +++++++++++
milena/mln/world/k1/is_primary_face.hh | 70 +++++++++++
milena/mln/world/k1/un_immerse.hh | 21 ++++
milena/tests/world/Makefile.am | 6 +-
milena/tests/world/k1/Makefile.am | 42 +++++++
milena/tests/world/k1/display_enlarged.cc | 98 ++++++++++++++++
milena/tests/world/k1/immerse.cc | 53 +++++++++
milena/tests/world/k1/is_0_face.cc | 40 +++++++
milena/tests/world/k1/is_0_or_1_face.cc | 40 +++++++
milena/tests/world/k1/is_1_face.cc | 39 ++++++
milena/tests/world/k1/is_1_face_horizontal.cc | 41 +++++++
milena/tests/world/k1/is_1_face_vertical.cc | 41 +++++++
milena/tests/world/k1/is_2_face.cc | 39 ++++++
milena/tests/world/k1/is_primary_face.cc | 39 ++++++
24 files changed, 1418 insertions(+), 13 deletions(-)
create mode 100644 milena/mln/world/k1/display_enlarged.hh
create mode 100644 milena/mln/world/k1/immerse.hh
create mode 100644 milena/mln/world/k1/internal/face_dim.hh
create mode 100644 milena/mln/world/k1/is_0_face.hh
create mode 100644 milena/mln/world/k1/is_0_or_1_face.hh
create mode 100644 milena/mln/world/k1/is_1_face.hh
create mode 100644 milena/mln/world/k1/is_1_face_horizontal.hh
create mode 100644 milena/mln/world/k1/is_1_face_vertical.hh
create mode 100644 milena/mln/world/k1/is_2_face.hh
create mode 100644 milena/mln/world/k1/is_primary_face.hh
create mode 100644 milena/mln/world/k1/un_immerse.hh
create mode 100644 milena/tests/world/k1/Makefile.am
create mode 100644 milena/tests/world/k1/display_enlarged.cc
create mode 100644 milena/tests/world/k1/immerse.cc
create mode 100644 milena/tests/world/k1/is_0_face.cc
create mode 100644 milena/tests/world/k1/is_0_or_1_face.cc
create mode 100644 milena/tests/world/k1/is_1_face.cc
create mode 100644 milena/tests/world/k1/is_1_face_horizontal.cc
create mode 100644 milena/tests/world/k1/is_1_face_vertical.cc
create mode 100644 milena/tests/world/k1/is_2_face.cc
create mode 100644 milena/tests/world/k1/is_primary_face.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index fdc8bd7..3db410c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,34 @@
+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.
+
2012-09-28 Guillaume Lazzara <z(a)lrde.epita.fr>
* mln/debug/draw_graph.hh: Add a new overload and fix comments.
diff --git a/milena/mln/make/image.hh b/milena/mln/make/image.hh
index ef80c57..5208293 100644
--- a/milena/mln/make/image.hh
+++ b/milena/mln/make/image.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 EPITA Research and
+// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 EPITA Research and
// Development Laboratory (LRDE)
//
// This file is part of Olena.
@@ -37,6 +37,9 @@
# include <mln/core/image/image1d.hh>
# include <mln/core/image/image2d.hh>
# include <mln/core/image/image3d.hh>
+# include <mln/make/box1d.hh>
+# include <mln/make/box2d.hh>
+# include <mln/make/box3d.hh>
# include <mln/opt/at.hh>
@@ -54,8 +57,11 @@ namespace mln
/// \return A 1D image.
///
template <typename V, unsigned L>
- mln::image1d<V> image(V (&values)[L]);
+ mln::image1d<V> image(V (&values)[L], const point1d& pmin);
+ /// \overload pmin = (0)
+ template <typename V, unsigned L>
+ mln::image1d<V> image(V (&values)[L]);
/// Create an image2d from an 2D array of values.
///
@@ -64,6 +70,10 @@ namespace mln
/// \return A 2D image.
///
template <typename V, unsigned R, unsigned C>
+ mln::image2d<V> image(V (&values)[R][C], const point2d& pmin);
+
+ /// \overload pmin = (0,0)
+ template <typename V, unsigned R, unsigned C>
mln::image2d<V> image(V (&values)[R][C]);
@@ -74,6 +84,10 @@ namespace mln
/// \return A 3D image.
///
template <typename V, unsigned S, unsigned R, unsigned C>
+ mln::image3d<V> image(V (&values)[S][R][C], const point3d& pmin);
+
+ /// \overload pmin = (0,0,0)
+ template <typename V, unsigned S, unsigned R, unsigned C>
mln::image3d<V> image(V (&values)[S][R][C]);
@@ -82,37 +96,53 @@ namespace mln
template <typename V, unsigned L>
mln::image1d<V>
- image(V (&values)[L])
+ image(V (&values)[L], const point1d& pmin)
{
mlc_bool(L != 0)::check();
- mln::image1d<V> tmp(L);
+ mln::image1d<V> tmp(make::box1d(pmin.ind(), pmin.ind() + L - 1));
const def::coord ninds = static_cast<def::coord>(L);
for (def::coord ind = 0; ind < ninds; ++ind)
- tmp(point1d(ind)) = values[ind];
+ tmp(point1d(pmin.ind() + ind)) = values[ind];
return tmp;
}
+ template <typename V, unsigned L>
+ mln::image1d<V>
+ image(V (&values)[L])
+ {
+ return image(values, point1d(0));
+ }
+
template <typename V, unsigned R, unsigned C>
mln::image2d<V>
- image(V (&values)[R][C])
+ image(V (&values)[R][C], const point2d& pmin)
{
mlc_bool(R != 0 && C != 0)::check();
- mln::image2d<V> tmp(R, C);
+ mln::image2d<V> tmp(make::box2d(pmin.row(), pmin.col(),
+ pmin.row() + R - 1, pmin.col() + C - 1));
const def::coord
nrows = static_cast<def::coord>(R),
ncols = static_cast<def::coord>(C);
for (def::coord row = 0; row < nrows; ++row)
for (def::coord col = 0; col < ncols; ++col)
- opt::at(tmp, row, col) = values[row][col];
+ opt::at(tmp, pmin.row() + row, pmin.col() + col) = values[row][col];
return tmp;
}
+ template <typename V, unsigned R, unsigned C>
+ mln::image2d<V>
+ image(V (&values)[R][C])
+ {
+ return image(values, point2d(0, 0));
+ }
+
template <typename V, unsigned S, unsigned R, unsigned C>
mln::image3d<V>
- image(V (&values)[S][R][C])
+ image(V (&values)[S][R][C], const point3d& pmin)
{
mlc_bool(S != 0 && R != 0 && C != 0)::check();
- mln::image3d<V> tmp(S, R, C);
+ mln::image3d<V> tmp(make::box3d(pmin.sli(), pmin.row(), pmin.col(),
+ pmin.sli() + S - 1, pmin.row() + R - 1, pmin.col() + C - 1));
const def::coord
nslis = static_cast<def::coord>(S),
nrows = static_cast<def::coord>(R),
@@ -120,10 +150,17 @@ namespace mln
for (def::coord sli = 0; sli < nslis; ++sli)
for (def::coord row = 0; row < nrows; ++row)
for (def::coord col = 0; col < ncols; ++col)
- opt::at(tmp, sli, row, col) = values[sli][row][col];
+ opt::at(tmp, pmin.sli() + sli, pmin.row() + row, pmin.col() + col) = values[sli][row][col];
return tmp;
}
+ template <typename V, unsigned S, unsigned R, unsigned C>
+ mln::image3d<V>
+ image(V (&values)[S][R][C])
+ {
+ return image(values, point3d(0, 0, 0));
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::make
diff --git a/milena/mln/world/k1/display_enlarged.hh b/milena/mln/world/k1/display_enlarged.hh
new file mode 100644
index 0000000..f3610c1
--- /dev/null
+++ b/milena/mln/world/k1/display_enlarged.hh
@@ -0,0 +1,154 @@
+// 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 Create a new image where 2 faces are enlarged for better
+/// visualization.
+
+#ifndef MLN_WORLD_K1_DISPLAY_ENLARGED_HH
+# define MLN_WORLD_K1_DISPLAY_ENLARGED_HH
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/is_0_face.hh>
+# include <mln/world/k1/is_1_face_vertical.hh>
+# include <mln/world/k1/is_1_face_horizontal.hh>
+# include <mln/world/k1/is_2_face.hh>
+# include <mln/geom/all.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /*! \brief Create a new image where 2 faces are enlarged for better
+ visualization.
+
+ Exemple with zoom = 3:
+ \verbatim
+ . - . - . . - - - . - - - .
+ | o | o | | o o o | o o o |
+ . - . - . -> | o o o | o o o |
+ | o | o | | o o o | o o o |
+ . - . - . . - - - . - - - .
+ | o o o | o o o |
+ | o o o | o o o |
+ | o o o | o o o |
+ . - - - . - - - .
+ \endverbatim
+
+ \param[in] ima_k1 A 2D image immersed in K1.
+ \param[in] zoom The number of times 2 faces must be duplicated
+ (must be odd).
+
+
+ This function is useful for debugging to distinguish 2 faces
+ from others.
+
+ */
+ template <typename I>
+ mln_concrete(I)
+ display_enlarged(const Image<I>& ima_k1, unsigned zoom);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facade
+
+ template <typename I>
+ mln_concrete(I)
+ display_enlarged(const Image<I>& ima_k1_, unsigned zoom_)
+ {
+ trace::entering("mln::world::k1::display_enlarged");
+
+ mln_precondition(exact(ima_k1_).is_valid());
+ mln_assertion(zoom_ % 2);
+
+ const I& ima_k1 = exact(ima_k1_);
+ int shift = zoom_ - 1;
+
+ // No zoom: return original image.
+ if (zoom_ == 1)
+ return ima_k1;
+
+ mln_concrete(I) output(make::box2d(ima_k1.domain().pmin().row() * shift,
+ ima_k1.domain().pmin().col() * shift,
+ ima_k1.domain().pmax().row() * shift,
+ ima_k1.domain().pmax().col() * shift));
+
+ const mln::def::coord
+ min_row = geom::min_row(ima_k1),
+ max_row = geom::max_row(ima_k1),
+ min_col = geom::min_col(ima_k1),
+ max_col = geom::max_col(ima_k1);
+
+ for (mln::def::coord row = min_row; row <= max_row; ++row)
+ {
+ for (mln::def::coord col = min_col; col <= max_col; ++col)
+ {
+ if (is_0_face(point2d(row, col)))
+ {
+ output.at_(row * shift, col * shift) = ima_k1.at_(row, col);
+ }
+ else if (is_1_face_vertical(point2d(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)))
+ {
+ 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)))
+ {
+ for (mln::def::coord i = -(shift - 1); i < (shift + 3); ++i)
+ for (mln::def::coord j = -(shift - 1); j < (shift + 3); ++j)
+ output.at_(row * shift + i, col * shift + j) = ima_k1.at_(row, col);
+ }
+ }
+ }
+
+ trace::exiting("mln::world::k1::display_enlarged");
+ 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_DISPLAY_ENLARGED_HH
+
diff --git a/milena/mln/world/k1/immerse.hh b/milena/mln/world/k1/immerse.hh
new file mode 100644
index 0000000..928012b
--- /dev/null
+++ b/milena/mln/world/k1/immerse.hh
@@ -0,0 +1,122 @@
+// 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.
+
+#ifndef MLN_WORLD_K1_IMMERSE_HH
+# define MLN_WORLD_K1_IMMERSE_HH
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/box.hh>
+# include <mln/core/alias/point2d.hh>
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /*! \brief Immerse a 2D image into K1.
+
+ \verbatim
+
+ -1 0 1 2 3
+ 0 1 -1 . - . - .
+ 0 o o 0 | o | o |
+ 1 o o -> 1 . - . - .
+ 2 | o | o |
+ 3 . - . - .
+
+ \endverbatim
+
+ */
+ template <typename I>
+ mln_concrete(I) immerse(const Image<I>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ /// \brief Return the equivalent domain in K1 from a domain in
+ /// K0.
+ template <typename B>
+ inline
+ B domain_from_K0(const Box<B>& b_)
+ {
+ mln_precondition(exact(b_).is_valid());
+ const B& b = exact(b_);
+
+ 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;
+ }
+
+ } // end of namespace mln::world::k1::internal
+
+
+
+ // Facade
+
+ template <typename I>
+ mln_concrete(I) immerse(const Image<I>& ima_)
+ {
+ trace::entering("mln::world::k1::immerse");
+ mln_precondition(exact(ima_).is_valid());
+ const I& ima = exact(ima_);
+
+ mln_concrete(I) output(internal::domain_from_K0(ima.domain()));
+
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ output(internal::immerse_point(p)) = ima(p);
+
+ trace::exiting("mln::world::k1::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_IMMERSE_HH
diff --git a/milena/mln/world/k1/internal/face_dim.hh b/milena/mln/world/k1/internal/face_dim.hh
new file mode 100644
index 0000000..b933e86
--- /dev/null
+++ b/milena/mln/world/k1/internal/face_dim.hh
@@ -0,0 +1,75 @@
+// 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 Returns the dimension of site in K1.
+
+#ifndef MLN_WORLD_K1_FACE_DIM_HH
+# define MLN_WORLD_K1_FACE_DIM_HH
+
+# include <mln/core/alias/point2d.hh>
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ namespace internal
+ {
+
+ /// \brief Returns the dimension of site in K1.
+ unsigned face_dim(const point2d& p);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facade
+
+ inline
+ unsigned face_dim(const point2d& p)
+ {
+ return (p[0] % 2 == 0) + (p[1] % 2 == 0);
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::work::k1::internal
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_FACE_DIM_HH
+
+
diff --git a/milena/mln/world/k1/is_0_face.hh b/milena/mln/world/k1/is_0_face.hh
new file mode 100644
index 0000000..c9d9b0e
--- /dev/null
+++ b/milena/mln/world/k1/is_0_face.hh
@@ -0,0 +1,70 @@
+// 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 Check if site is a 0 face.
+
+#ifndef MLN_WORLD_K1_IS_0_FACE_HH
+# define MLN_WORLD_K1_IS_0_FACE_HH
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/internal/face_dim.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /// \brief Check if site is a 0 face
+ bool is_0_face(const point2d& p);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facade
+
+ inline
+ bool is_0_face(const point2d& p)
+ {
+ return internal::face_dim(p) == 0;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_IS_0_FACE_HH
diff --git a/milena/mln/world/k1/is_0_or_1_face.hh b/milena/mln/world/k1/is_0_or_1_face.hh
new file mode 100644
index 0000000..6f3f47a
--- /dev/null
+++ b/milena/mln/world/k1/is_0_or_1_face.hh
@@ -0,0 +1,71 @@
+// 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 Check if site is a 1 face.
+
+#ifndef MLN_WORLD_K1_IS_0_OR_1_FACE_HH
+# define MLN_WORLD_K1_IS_0_OR_1_FACE_HH
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/internal/face_dim.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /// \brief Check if site is a 1 face
+ bool is_0_or_1_face(const point2d& p);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facade
+
+ inline
+ bool is_0_or_1_face(const point2d& p)
+ {
+ unsigned dim = internal::face_dim(p);
+ return dim == 0 || dim == 1;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_IS_0_OR_1_FACE_HH
diff --git a/milena/mln/world/k1/is_1_face.hh b/milena/mln/world/k1/is_1_face.hh
new file mode 100644
index 0000000..aafa442
--- /dev/null
+++ b/milena/mln/world/k1/is_1_face.hh
@@ -0,0 +1,70 @@
+// 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 Check if site is a 1 face.
+
+#ifndef MLN_WORLD_K1_IS_1_FACE_HH
+# define MLN_WORLD_K1_IS_1_FACE_HH
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/internal/face_dim.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /// \brief Check if site is a 1 face
+ bool is_1_face(const point2d& p);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facade
+
+ inline
+ bool is_1_face(const point2d& p)
+ {
+ return internal::face_dim(p) == 1;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_IS_1_FACE_HH
diff --git a/milena/mln/world/k1/is_1_face_horizontal.hh b/milena/mln/world/k1/is_1_face_horizontal.hh
new file mode 100644
index 0000000..ff90b0c
--- /dev/null
+++ b/milena/mln/world/k1/is_1_face_horizontal.hh
@@ -0,0 +1,70 @@
+// 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 Check if site is a 1 face.
+
+#ifndef MLN_WORLD_K1_IS_1_FACE_HORIZONTAL_HH
+# define MLN_WORLD_K1_IS_1_FACE_HORIZONTAL_HH
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/is_1_face.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /// \brief Check if site is a 1 face
+ bool is_1_face_horizontal(const point2d& p);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facade
+
+ inline
+ bool is_1_face_horizontal(const point2d& p)
+ {
+ return is_1_face(p) && p[1] % 2 == 0;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_IS_1_FACE_HORIZONTAL_HH
diff --git a/milena/mln/world/k1/is_1_face_vertical.hh b/milena/mln/world/k1/is_1_face_vertical.hh
new file mode 100644
index 0000000..f10067d
--- /dev/null
+++ b/milena/mln/world/k1/is_1_face_vertical.hh
@@ -0,0 +1,70 @@
+// 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 Check if site is a 1 face.
+
+#ifndef MLN_WORLD_K1_IS_1_FACE_VERTICAL_HH
+# define MLN_WORLD_K1_IS_1_FACE_VERTICAL_HH
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/is_1_face.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /// \brief Check if site is a 1 face
+ bool is_1_face_vertical(const point2d& p);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facade
+
+ inline
+ bool is_1_face_vertical(const point2d& p)
+ {
+ return is_1_face(p) && p[0] % 2 == 0;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_IS_1_FACE_VERTICAL_HH
diff --git a/milena/mln/world/k1/is_2_face.hh b/milena/mln/world/k1/is_2_face.hh
new file mode 100644
index 0000000..b3c8c98
--- /dev/null
+++ b/milena/mln/world/k1/is_2_face.hh
@@ -0,0 +1,70 @@
+// 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 Check if site is a 2 face.
+
+#ifndef MLN_WORLD_K1_IS_2_FACE_HH
+# define MLN_WORLD_K1_IS_2_FACE_HH
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/internal/face_dim.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /// \brief Check if site is a 2 face
+ bool is_2_face(const point2d& p);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facade
+
+ inline
+ bool is_2_face(const point2d& p)
+ {
+ return internal::face_dim(p) == 2;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_IS_2_FACE_HH
diff --git a/milena/mln/world/k1/is_primary_face.hh b/milena/mln/world/k1/is_primary_face.hh
new file mode 100644
index 0000000..572d25c
--- /dev/null
+++ b/milena/mln/world/k1/is_primary_face.hh
@@ -0,0 +1,70 @@
+// 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 Check if site is a primary face.
+
+#ifndef MLN_WORLD_K1_IS_PRIMARY_FACE_HH
+# define MLN_WORLD_K1_IS_PRIMARY_FACE_HH
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/world/k1/is_2_face.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace k1
+ {
+
+ /// \brief Check if site is a primary face
+ bool is_primary_face(const point2d& p);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facade
+
+ inline
+ bool is_primary_face(const point2d& p)
+ {
+ return is_2_face(p);
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::k1
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_K1_IS_PRIMARY_FACE_HH
diff --git a/milena/mln/world/k1/un_immerse.hh b/milena/mln/world/k1/un_immerse.hh
new file mode 100644
index 0000000..7978be9
--- /dev/null
+++ b/milena/mln/world/k1/un_immerse.hh
@@ -0,0 +1,21 @@
+
+
+ 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;
+
+ struct is_not_2_face_t : Function_v2b< is_not_2_face_t >
+ {
+ typedef bool result;
+ inline bool operator()(const point2d& p) const { return FIXME; } // ! (p.row() % 2 && p.col() % 2)
+ } is_not_2_face;
diff --git a/milena/tests/world/Makefile.am b/milena/tests/world/Makefile.am
index 3bae089..494271c 100644
--- a/milena/tests/world/Makefile.am
+++ b/milena/tests/world/Makefile.am
@@ -1,4 +1,5 @@
-# Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2009, 2012 EPITA Research and Development Laboratory
+# (LRDE).
#
# This file is part of Olena.
#
@@ -18,4 +19,5 @@ include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = \
binary_2d \
- inter_pixel
+ inter_pixel \
+ k1
diff --git a/milena/tests/world/k1/Makefile.am b/milena/tests/world/k1/Makefile.am
new file mode 100644
index 0000000..daa0d94
--- /dev/null
+++ b/milena/tests/world/k1/Makefile.am
@@ -0,0 +1,42 @@
+# 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/>.
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ display_enlarged \
+ immerse \
+ immerse_and_duplicate_2_to_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
+
+display_enlarged_SOURCES = display_enlarged.cc
+immerse_SOURCES = immerse.cc
+immerse_and_duplicate_2_to_1_faces_SOURCES = immerse_and_duplicate_2_to_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
+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
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/world/k1/display_enlarged.cc b/milena/tests/world/k1/display_enlarged.cc
new file mode 100644
index 0000000..3365fbe
--- /dev/null
+++ b/milena/tests/world/k1/display_enlarged.cc
@@ -0,0 +1,98 @@
+// 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/display_enlarged.hh>
+#include <mln/world/k1/immerse.hh>
+#include <mln/make/box2d.hh>
+#include <mln/data/compare.hh>
+
+#include <mln/debug/println.hh>
+
+int main()
+{
+ using namespace mln;
+
+ 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 }
+ };
+
+ int vals3[9][9] = {
+ {1, 2, 2, 2, 1, 2, 2, 2, 1},
+ {2, 3, 3, 3, 2, 3, 3, 3, 2},
+ {2, 3, 3, 3, 2, 3, 3, 3, 2},
+ {2, 3, 3, 3, 2, 3, 3, 3, 2},
+ {1, 2, 2, 2, 1, 2, 2, 2, 1},
+ {2, 3, 3, 3, 2, 3, 3, 3, 2},
+ {2, 3, 3, 3, 2, 3, 3, 3, 2},
+ {2, 3, 3, 3, 2, 3, 3, 3, 2},
+ {1, 2, 2, 2, 1, 2, 2, 2, 1}
+ };
+
+ int vals5[17][17] = {
+ {1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1},
+ {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2},
+ {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2},
+ {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2},
+ {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2},
+ {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2},
+ {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2},
+ {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2},
+ {1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1},
+ {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2},
+ {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2},
+ {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2},
+ {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2},
+ {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2},
+ {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2},
+ {2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 2},
+ {1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1}
+ };
+
+ image2d<int> ima = make::image(vals, point2d(-1, -1));
+
+ {
+ image2d<int> enlarged = world::k1::display_enlarged(ima, 1);
+ mln_assertion(ima == enlarged);
+ }
+
+ {
+ image2d<int> ref3 = make::image(vals3, point2d(-2, -2));
+ image2d<int> enlarged = world::k1::display_enlarged(ima, 3);
+ mln_assertion(ref3 == enlarged);
+ }
+
+ {
+ image2d<int> ref5 = make::image(vals5, point2d(-4, -4));
+ image2d<int> enlarged = world::k1::display_enlarged(ima, 5);
+ mln_assertion(ref5 == enlarged);
+ }
+}
diff --git a/milena/tests/world/k1/immerse.cc b/milena/tests/world/k1/immerse.cc
new file mode 100644
index 0000000..8a17056
--- /dev/null
+++ b/milena/tests/world/k1/immerse.cc
@@ -0,0 +1,53 @@
+// 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.hh>
+#include <mln/make/box2d.hh>
+
+int main()
+{
+ using namespace mln;
+
+
+ int vals[2][2] = {
+ {1, 2 },
+ {3, 4 }
+ };
+ image2d<int> ima = make::image(vals);
+
+ image2d<int> immersed = world::k1::immerse(ima);
+
+ // Check domain
+ mln_assertion(immersed.domain() == make::box2d(-1, -1, 3, 3));
+
+ // Check values
+ mln_assertion(immersed(point2d(0, 0)) == 1);
+ mln_assertion(immersed(point2d(2, 0)) == 3);
+ mln_assertion(immersed(point2d(0, 2)) == 2);
+ mln_assertion(immersed(point2d(2, 2)) == 4);
+}
diff --git a/milena/tests/world/k1/is_0_face.cc b/milena/tests/world/k1/is_0_face.cc
new file mode 100644
index 0000000..6033af6
--- /dev/null
+++ b/milena/tests/world/k1/is_0_face.cc
@@ -0,0 +1,40 @@
+// 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/alias/point2d.hh>
+#include <mln/world/k1/is_0_face.hh>
+
+int main()
+{
+ using namespace mln;
+
+ mln_assertion(world::k1::is_0_face(point2d(-1, -1)));
+ mln_assertion(!world::k1::is_0_face(point2d(-1, 0)));
+ mln_assertion(!world::k1::is_0_face(point2d(0, -1)));
+ mln_assertion(!world::k1::is_0_face(point2d(0, 0)));
+ mln_assertion(world::k1::is_0_face(point2d(1, 1)));
+}
diff --git a/milena/tests/world/k1/is_0_or_1_face.cc b/milena/tests/world/k1/is_0_or_1_face.cc
new file mode 100644
index 0000000..f977566
--- /dev/null
+++ b/milena/tests/world/k1/is_0_or_1_face.cc
@@ -0,0 +1,40 @@
+// 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/alias/point2d.hh>
+#include <mln/world/k1/is_0_or_1_face.hh>
+
+int main()
+{
+ using namespace mln;
+
+ mln_assertion(world::k1::is_0_or_1_face(point2d(-1, -1)));
+ mln_assertion(world::k1::is_0_or_1_face(point2d(-1, 0)));
+ mln_assertion(world::k1::is_0_or_1_face(point2d(0, -1)));
+ mln_assertion(!world::k1::is_0_or_1_face(point2d(0, 0)));
+ mln_assertion(world::k1::is_0_or_1_face(point2d(1, 1)));
+}
diff --git a/milena/tests/world/k1/is_1_face.cc b/milena/tests/world/k1/is_1_face.cc
new file mode 100644
index 0000000..bd50f84
--- /dev/null
+++ b/milena/tests/world/k1/is_1_face.cc
@@ -0,0 +1,39 @@
+// 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/alias/point2d.hh>
+#include <mln/world/k1/is_1_face.hh>
+
+int main()
+{
+ using namespace mln;
+
+ mln_assertion(!world::k1::is_1_face(point2d(-1, -1)));
+ mln_assertion(world::k1::is_1_face(point2d(-1, 0)));
+ mln_assertion(world::k1::is_1_face(point2d(0, -1)));
+ mln_assertion(!world::k1::is_1_face(point2d(0, 0)));
+}
diff --git a/milena/tests/world/k1/is_1_face_horizontal.cc b/milena/tests/world/k1/is_1_face_horizontal.cc
new file mode 100644
index 0000000..4f6e406
--- /dev/null
+++ b/milena/tests/world/k1/is_1_face_horizontal.cc
@@ -0,0 +1,41 @@
+// 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/alias/point2d.hh>
+#include <mln/world/k1/is_1_face_horizontal.hh>
+
+int main()
+{
+ using namespace mln;
+
+ mln_assertion(!world::k1::is_1_face_horizontal(point2d(-1, -1)));
+ mln_assertion(world::k1::is_1_face_horizontal(point2d(-1, 0)));
+ mln_assertion(world::k1::is_1_face_horizontal(point2d(1, 0)));
+ mln_assertion(!world::k1::is_1_face_horizontal(point2d(0, -1)));
+ mln_assertion(!world::k1::is_1_face_horizontal(point2d(0, 1)));
+ mln_assertion(!world::k1::is_1_face_horizontal(point2d(0, 0)));
+}
diff --git a/milena/tests/world/k1/is_1_face_vertical.cc b/milena/tests/world/k1/is_1_face_vertical.cc
new file mode 100644
index 0000000..e204f97
--- /dev/null
+++ b/milena/tests/world/k1/is_1_face_vertical.cc
@@ -0,0 +1,41 @@
+// 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/alias/point2d.hh>
+#include <mln/world/k1/is_1_face_vertical.hh>
+
+int main()
+{
+ using namespace mln;
+
+ mln_assertion(!world::k1::is_1_face_vertical(point2d(-1, -1)));
+ mln_assertion(!world::k1::is_1_face_vertical(point2d(-1, 0)));
+ mln_assertion(!world::k1::is_1_face_vertical(point2d(1, 0)));
+ mln_assertion(world::k1::is_1_face_vertical(point2d(0, -1)));
+ mln_assertion(world::k1::is_1_face_vertical(point2d(0, 1)));
+ mln_assertion(!world::k1::is_1_face_vertical(point2d(0, 0)));
+}
diff --git a/milena/tests/world/k1/is_2_face.cc b/milena/tests/world/k1/is_2_face.cc
new file mode 100644
index 0000000..912567d
--- /dev/null
+++ b/milena/tests/world/k1/is_2_face.cc
@@ -0,0 +1,39 @@
+// 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/alias/point2d.hh>
+#include <mln/world/k1/is_2_face.hh>
+
+int main()
+{
+ using namespace mln;
+
+ mln_assertion(!world::k1::is_2_face(point2d(-1, -1)));
+ mln_assertion(!world::k1::is_2_face(point2d(-1, 0)));
+ mln_assertion(!world::k1::is_2_face(point2d(0, -1)));
+ mln_assertion(world::k1::is_2_face(point2d(0, 0)));
+}
diff --git a/milena/tests/world/k1/is_primary_face.cc b/milena/tests/world/k1/is_primary_face.cc
new file mode 100644
index 0000000..32eb871
--- /dev/null
+++ b/milena/tests/world/k1/is_primary_face.cc
@@ -0,0 +1,39 @@
+// 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/alias/point2d.hh>
+#include <mln/world/k1/is_primary_face.hh>
+
+int main()
+{
+ using namespace mln;
+
+ mln_assertion(!world::k1::is_primary_face(point2d(-1, -1)));
+ mln_assertion(!world::k1::is_primary_face(point2d(-1, 0)));
+ mln_assertion(!world::k1::is_primary_face(point2d(0, -1)));
+ mln_assertion(world::k1::is_primary_face(point2d(0, 0)));
+}
--
1.7.2.5
* demo/viewer/main.cc: Move call to setLocale...
* scribo/text/recognition.hh: ... Here.
---
scribo/ChangeLog | 7 +++++++
scribo/demo/viewer/main.cc | 14 --------------
scribo/scribo/text/recognition.hh | 14 ++++++++++++++
3 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 48c1b84..a3e6e7e 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,10 @@
+2011-12-06 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Ensure current locale is C while calling Tesseract.
+
+ * demo/viewer/main.cc: Move call to setLocale...
+ * scribo/text/recognition.hh: ... Here.
+
2011-11-16 Guillaume Lazzara <z(a)lrde.epita.fr>
* scribo/text/recognition.hh: Fix code for Tesseract 3.01
diff --git a/scribo/demo/viewer/main.cc b/scribo/demo/viewer/main.cc
index 704dfe7..0c50c7b 100644
--- a/scribo/demo/viewer/main.cc
+++ b/scribo/demo/viewer/main.cc
@@ -18,10 +18,6 @@
#include <QtGui>
#include <iostream>
-# ifdef HAVE_TESSERACT_2
-#include <clocale>
-# endif // ! HAVE_TESSERACT_2
-
#undef MLN_WO_GLOBAL_VARS
#include "viewer.hh"
#include <mln/labeling/colorize.hh>
@@ -49,15 +45,5 @@ int main(int argc, char** argv)
if (!viewer)
return -1;
-
-# ifdef HAVE_TESSERACT_2
- // Tesseract 2.x is known to have issues while reading training data
- // depending on the current locales in use. Training data files use
- // float data and the decimal separator can be either '.' or ','
- // causing errors.
- // Setting locale to "C" fix that issue.
- setlocale(LC_ALL, "C");
-# endif // ! HAVE_TESSERACT_2
-
return viewer->exec();
}
diff --git a/scribo/scribo/text/recognition.hh b/scribo/scribo/text/recognition.hh
index fe2c94a..22d31f6 100644
--- a/scribo/scribo/text/recognition.hh
+++ b/scribo/scribo/text/recognition.hh
@@ -40,6 +40,7 @@
# include <ostream>
+# include <clocale>
# include <mln/core/image/dmorph/image_if.hh>
# include <mln/core/concept/neighborhood.hh>
@@ -113,6 +114,12 @@ namespace scribo
{
trace::entering("scribo::text::recognition");
+ // Tesseract is known to have issues while reading training data
+ // depending on the current locales in use. Training data files use
+ // float data and the decimal separator can be either '.' or ','
+ // causing errors.
+ // Setting locale to "C" fix that issue.
+ setlocale(LC_ALL, "C");
// Initialize Tesseract.
TessBaseAPI::InitWithLanguage(NULL, NULL, language, NULL, false, 0, NULL);
@@ -201,6 +208,13 @@ namespace scribo
const I& line = exact(line_);
mln_precondition(line.is_valid());
+ // Tesseract is known to have issues while reading training data
+ // depending on the current locales in use. Training data files use
+ // float data and the decimal separator can be either '.' or ','
+ // causing errors.
+ // Setting locale to "C" fix that issue.
+ setlocale(LC_ALL, "C");
+
// Initialize Tesseract.
TessBaseAPI::InitWithLanguage(NULL, NULL, language, NULL, false, 0, NULL);
--
1.7.2.5
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch unstable/scribo has been updated
via f46deddccad811cc836aca7917a6cfbd6a5d12cc (commit)
via 6412c07f5e375f1bc8a22ae3d42288e601b3471d (commit)
via ba481b8ad2a28420b170e8e5f8a4890b2f6bd9cf (commit)
via 2ac2f4b257f2c7cdf521a100c047a828b39f39f4 (commit)
from 39c49007646f0a4b5ca021af14ee039220865935 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
No new revisions were added by this update.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 5 +++++
scribo/ChangeLog | 16 ++++++++++++++++
scribo/demo/viewer/main.cc | 14 --------------
scribo/scribo/text/recognition.hh | 21 ++++++++++++++++++++-
4 files changed, 41 insertions(+), 15 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform