* tests/core/image/complex_image.hh: New.
* tests/core/image/Makefile.am (noinst_HEADERS): New.
Set to complex_image.hh.
---
milena/ChangeLog | 8 ++
milena/tests/core/image/Makefile.am | 2 +
milena/tests/core/image/complex_image.hh | 165 ++++++++++++++++++++++++++++++
3 files changed, 175 insertions(+), 0 deletions(-)
create mode 100644 milena/tests/core/image/complex_image.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 623b97b..e218828 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
2008-12-30 Roland Levillain <roland(a)lrde.epita.fr>
+ Start to factor code among tests on complex-based images.
+
+ * tests/core/image/complex_image.hh: New.
+ * tests/core/image/Makefile.am (noinst_HEADERS): New.
+ Set to complex_image.hh.
+
+2008-12-30 Roland Levillain <roland(a)lrde.epita.fr>
+
Add a test for apps/statues/test-mesh-max-curv.
* apps/statues/test-mesh-max-curv.in: New.
diff --git a/milena/tests/core/image/Makefile.am b/milena/tests/core/image/Makefile.am
index cfbba60..72f0c93 100644
--- a/milena/tests/core/image/Makefile.am
+++ b/milena/tests/core/image/Makefile.am
@@ -30,6 +30,8 @@ check_PROGRAMS = \
## tr_image
## value_enc_image
+noinst_HEADERS = complex_image.hh
+
##bgraph_image_SOURCES = bgraph_image.cc
cast_image_SOURCES = cast_image.cc
complex_image_SOURCES = complex_image.cc
diff --git a/milena/tests/core/image/complex_image.hh
b/milena/tests/core/image/complex_image.hh
new file mode 100644
index 0000000..5487d46
--- /dev/null
+++ b/milena/tests/core/image/complex_image.hh
@@ -0,0 +1,165 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/core/image/complex_image.hh
+/// \brief Shared code for tests on complex-based images.
+
+#ifndef TESTS_CORE_IMAGE_COMPLEX_IMAGE_HH
+# define TESTS_CORE_IMAGE_COMPLEX_IMAGE_HH
+
+# include <mln/core/image/complex_image.hh>
+# include <mln/core/alias/complex_image.hh>
+# include <mln/value/int_u8.hh>
+
+// FIXME: Keep this? (See below.)
+# include <mln/core/site_set/p_faces.hh>
+
+
+inline
+mln::int_u8_2complex_image2d
+make_test_complex_image()
+{
+ /*----------.
+ | Complex. |
+ `----------*/
+
+ /* A 2-d (simplicial) complex and its adjacency graph.
+
+ c 0 1 2 3
+ r .------------------------
+ | v0 e3 v3
+ 0 | o-----------o v0----e3----v3
+ | / \ ,-----. / / \ | /
+ | / . \ \ t1/ / / \ t1 /
+ 1 | e0 / / \ e1\ / / e4 e0. ,e1Ž `e4
+ | / /t0 \ \ ' / / t0 \ /
+ | / `-----' \ / / | \ /
+ 2 | o-----------o v1----e2----v2
+ | v1 e2 v2
+
+ v = vertex
+ e = edge
+ t = triangle
+ */
+
+
+ const unsigned D = 2;
+
+ mln::topo::complex<D> c;
+
+ // 0-faces (points).
+ mln::topo::n_face<0, D> v0 = c.add_face();
+ mln::topo::n_face<0, D> v1 = c.add_face();
+ mln::topo::n_face<0, D> v2 = c.add_face();
+ mln::topo::n_face<0, D> v3 = c.add_face();
+
+ // 1-faces (segments).
+ mln::topo::n_face<1, D> e0 = c.add_face(v0 + v1);
+ mln::topo::n_face<1, D> e1 = c.add_face(v0 + v2);
+ mln::topo::n_face<1, D> e2 = c.add_face(v1 + v2);
+ mln::topo::n_face<1, D> e3 = c.add_face(v0 + v3);
+ mln::topo::n_face<1, D> e4 = c.add_face(v2 + v3);
+
+ // 2-faces (triangles).
+ mln::topo::n_face<2, D> t0 = c.add_face(e0 + e1 + e2);
+ mln::topo::n_face<2, D> t1 = c.add_face(e1 + e3 + e4);
+
+
+ /*------------------------------.
+ | Complex geometry (location). |
+ `------------------------------*/
+
+ typedef mln::discrete_plane_2complex_geometry G;
+ G geom;
+ geom.add_location(mln::point2d(0,1)); // 0-face #0.
+ geom.add_location(mln::point2d(2,0)); // 0-face #1.
+ geom.add_location(mln::point2d(2,2)); // 0-face #2.
+ geom.add_location(mln::point2d(0,3)); // 0-face #3.
+
+
+ /*---------------------.
+ | Complex-based pset. |
+ `---------------------*/
+
+ // A pset.
+ mln::p_complex<D, G> pc(c, geom);
+ mln::topo::face<D> af(e0);
+ // An associated psite.
+ mln::complex_psite<D, G> cs(pc, af);
+
+
+ /*--------------------.
+ | Faces-based psets. |
+ `--------------------*/
+
+ /* FIXME: Not that p_faces have become less interesting since the
+ introduction of p_complex_faces_{fwd,bkd}_piter_. Keep this part
+ of the test? */
+
+ /* FIXME: Move this parts out of this function? (into an existing
+ test?) */
+
+ // Pset of 0-faces.
+ mln::p_faces<0, D, G> pf0(c);
+ // Pset of 1-faces.
+ mln::p_faces<1, D, G> pf1(c);
+ // Pset of 2-faces.
+ mln::p_faces<2, D, G> pf2(c);
+
+ // Some psites on faces.
+ mln::faces_psite<0, D, G> fs0(pf0, v0);
+ mln::faces_psite<1, D, G> fs1(pf1, e0);
+ mln::faces_psite<2, D, G> fs2(pf2, t0);
+
+
+ /*----------------------.
+ | Complex-based image. |
+ `----------------------*/
+
+ using mln::value::int_u8;
+
+ // An image type built on a 2-complex with mln::int_u8 values on
+ // each face.
+ typedef mln::complex_image<D, G, int_u8> ima_t;
+
+ // Values.
+ mln::metal::vec<D + 1, std::vector< int_u8 > > values;
+ // Assign 0 to 0-faces, 1 to 1-faces and 2 to 2-faces.
+ for (unsigned d = 0; d <= D; ++d)
+ for (unsigned n = 0; n < pc.cplx().nfaces(d); ++n)
+ values[d].push_back(d);
+
+ // Create and init an image based on PC.
+ ima_t ima(pc, values);
+
+ // Check the value associated to edge E0 (through complex psite CS).
+ mln_postcondition(ima(cs) == 1u);
+
+ return ima;
+}
+
+#endif // ! TESTS_CORE_IMAGE_COMPLEX_IMAGE_HH
--
1.6.0.4