* apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc: New.
* apps/mesh-segm-skel/test-mesh-complex-max-curv-skel.in: New.
* apps/mesh-segm-skel/Makefile.am (bin_PROGRAMS):
Add mesh-complex-max-curv-skel.
(mesh_complex_max_curv_skel_SOURCES): New.
(TESTS): Add test-mesh-complex-max-curv-skel.
(CLEANFILES): Add socket-complex-max-curv-skel.off and
teapot-complex-max-curv-skel.off.
---
milena/ChangeLog | 13 ++++
milena/apps/mesh-segm-skel/Makefile.am | 7 ++
...mplex-skel.cc => mesh-complex-max-curv-skel.cc} | 65 +++++++++++++++++---
...-segm.in => test-mesh-complex-max-curv-skel.in} | 8 +-
4 files changed, 81 insertions(+), 12 deletions(-)
copy milena/apps/mesh-segm-skel/{mesh-complex-skel.cc =>
mesh-complex-max-curv-skel.cc} (76%)
copy milena/apps/mesh-segm-skel/{test-mesh-segm.in =>
test-mesh-complex-max-curv-skel.in} (66%)
mode change 100755 => 100644
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 8b45871..3de4207 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,16 @@
+2010-06-14 Roland Levillain <roland(a)lrde.epita.fr>
+
+ New application: mesh-complex-max-curv-skel.
+
+ * apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc: New.
+ * apps/mesh-segm-skel/test-mesh-complex-max-curv-skel.in: New.
+ * apps/mesh-segm-skel/Makefile.am (bin_PROGRAMS):
+ Add mesh-complex-max-curv-skel.
+ (mesh_complex_max_curv_skel_SOURCES): New.
+ (TESTS): Add test-mesh-complex-max-curv-skel.
+ (CLEANFILES): Add socket-complex-max-curv-skel.off and
+ teapot-complex-max-curv-skel.off.
+
2010-05-11 Roland Levillain <roland(a)lrde.epita.fr>
Clean up and new FIXMES in in apps/mesh-segm-skel.
diff --git a/milena/apps/mesh-segm-skel/Makefile.am
b/milena/apps/mesh-segm-skel/Makefile.am
index b702ccb..debed78 100644
--- a/milena/apps/mesh-segm-skel/Makefile.am
+++ b/milena/apps/mesh-segm-skel/Makefile.am
@@ -189,3 +189,10 @@ CLEANFILES += \
# FIXME: Implement `mesh-complex-{max,pinv}-curv-skel'.
# ...
+bin_PROGRAMS += mesh-complex-max-curv-skel
+mesh_complex_max_curv_skel_SOURCES = \
+ mesh-complex-max-curv-skel.cc save_bin_alt.hh
+TESTS += test-mesh-complex-max-curv-skel
+CLEANFILES += \
+ socket-complex-max-curv-skel.off \
+ teapot-complex-max-curv-skel.off
diff --git a/milena/apps/mesh-segm-skel/mesh-complex-skel.cc
b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc
similarity index 76%
copy from milena/apps/mesh-segm-skel/mesh-complex-skel.cc
copy to milena/apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc
index b7e1f1f..6265a25 100644
--- a/milena/apps/mesh-segm-skel/mesh-complex-skel.cc
+++ b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Milena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,9 +26,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file apps/mesh-segm-skel/mesh-complex-skel.cc
-/// \brief A program computing a skeleton of the surface of the
-/// (triangle) mesh of a statue (by thinning), using a complex-based
+/// \file apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc
+/// \brief A program computing the maximal curvature values from the
+/// surface of the (triangle) mesh of a statue, then computing a
+/// skeleton of this surface (by/ thinning), using a complex-based
/// image.
#include <iostream>
@@ -52,6 +54,8 @@
morphed mln::complex_image (i.e., seen through image_if). */
#include "save_bin_alt.hh"
+#include "trimesh/misc.hh"
+
int
main(int argc, char* argv[])
@@ -78,12 +82,57 @@ main(int argc, char* argv[])
// Geometry of the image.
typedef mln_geom_(ima_t) G;
- ima_t input;
- mln::io::off::load(input, input_filename);
+ mln::bin_2complex_image3df bin_input;
+ mln::io::off::load(bin_input, input_filename);
+ std::pair<ima_t, ima_t> curv = mln::geom::mesh_curvature(bin_input.domain());
+
+ // Compute the pseudo_inverse curvature at each vertex.
+ ima_t input(bin_input.domain());
+ mln::p_n_faces_fwd_piter<D, G> v(input.domain(), 0);
+ for_all(v)
+ {
+ // FIXME: The program should allow the user to choose the kind
+ // of measure.
+#if 0
+ float h = (curv.first(v) + curv.second(v)) / 2;
+ // Pseudo-inverse curvature.
+ float h_inv = 1 / pi * (atan(-h) + pi / 2);
+ input(v) = h_inv;
+#endif
+ // Max curvature.
+ input(v) = mln::math::max(mln::math::sqr(curv.first(v)),
+ mln::math::sqr(curv.second(v)));
+ }
+
+ // Values on triangles.
+ mln::p_n_faces_fwd_piter<D, G> t(input.domain(), 2);
+ // For each triangle (2-face) T, iterate on the the set of vertices
+ // (0-faces) transitively adjacent to T.
+ typedef mln::complex_m_face_neighborhood<D, G> adj_vertices_nbh_t;
+ adj_vertices_nbh_t adj_vertices_nbh;
+ mln_niter_(adj_vertices_nbh_t) adj_v(adj_vertices_nbh, t);
+ /* FIXME: We should be able to pass this value (m) either at the
+ construction of the neighborhood or at the construction of the
+ iterator. */
+ adj_v.iter().set_m(0);
+ // Iterate on triangles (2-faces).
+ for_all(t)
+ {
+ float s = 0.0f;
+ unsigned n = 0;
+ // Iterate on vertices (0-faces).
+ for_all(adj_v)
+ {
+ s += input(adj_v);
+ ++n;
+ }
+ input(t) = s / n;
+ // A triangle should be adjacent to exactly two vertices.
+ mln_invariant(n <= 3);
+ }
/* FIXME: Workaround: Set maximal values on vertices and edges to
exclude them from the set of minimal values. */
- mln::p_n_faces_fwd_piter<D, G> v(input.domain(), 0);
for_all(v)
input(v) = mln_max(float);
mln::p_n_faces_fwd_piter<D, G> e(input.domain(), 1);
@@ -126,7 +175,7 @@ main(int argc, char* argv[])
for_all(adj_t)
if (minima(adj_t) == mln::literal::zero)
{
- // If E is adjcent to a non-minimal triangle, then it must
+ // If E is adjacent to a non-minimal triangle, then it must
// not belong to a minima.
ref_adj_minimum = mln::literal::zero;
break;
diff --git a/milena/apps/mesh-segm-skel/test-mesh-segm.in
b/milena/apps/mesh-segm-skel/test-mesh-complex-max-curv-skel.in
old mode 100755
new mode 100644
similarity index 66%
copy from milena/apps/mesh-segm-skel/test-mesh-segm.in
copy to milena/apps/mesh-segm-skel/test-mesh-complex-max-curv-skel.in
index e70e63a..ea7f604
--- a/milena/apps/mesh-segm-skel/test-mesh-segm.in
+++ b/milena/apps/mesh-segm-skel/test-mesh-complex-max-curv-skel.in
@@ -1,6 +1,6 @@
#! /bin/sh
-# Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -20,7 +20,7 @@ set -ex
mesh_dir=@top_srcdir@/milena/mesh
-time ./mesh-segm $mesh_dir/socket.off 25 socket-segm.off
-time ./mesh-segm $mesh_dir/teapot.off 50 teapot-segm.off
+time ./mesh-complex-max-curv-skel $mesh_dir/socket.off 10
socket-complex-max-curv-skel.off
+time ./mesh-complex-max-curv-skel $mesh_dir/teapot.off 20
teapot-complex-max-curv-skel.off
# FIXME: Too long. Should be run with (future) target `check-full'.
-#time ./mesh-segm $mesh_dir/bunny-holefilled.off 500 bunny-holefilled-segm.off
+#time ./mesh-complex-max-curv-skel $mesh_dir/bunny-holefilled.off 50
bunny-holefilled-complex-max-curv-skel.off
--
1.5.6.5