Olena-patches
Threads by month
- ----- 2025 -----
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
April 2011
- 4 participants
- 107 discussions
* mln/accu/line.hh: Use def::coord.
* mln/algebra/vec.hh,
* mln/convert/from_to.hxx,
* mln/core/image/dmorph/sub_image.hh,
* mln/core/internal/site_set_iterator_base.hh,
* mln/core/site_set/box.hh,
* mln/core/site_set/p_array.hh,
* mln/core/site_set/p_edges.hh,
* mln/core/site_set/p_vertices.hh: Make forward declaration
consistent with declaration.
* mln/value/builtin/carrays.hh: Explicitly convert to char *.
* mln/convert/impl/from_double_to_value.hh,
* mln/convert/impl/from_int_to_value.hh,
* mln/core/point.hh,
* mln/opt/element.hh: Avoid unused variable warning.
* mln/convert/impl/from_image_to_site_set.hh: Remove useless local variable.
---
milena/ChangeLog | 25 ++++++++++++++++++++
milena/mln/accu/line.hh | 17 +++++++------
milena/mln/algebra/vec.hh | 5 ++-
milena/mln/convert/from_to.hxx | 5 ++-
milena/mln/convert/impl/from_double_to_value.hh | 5 +++-
milena/mln/convert/impl/from_image_to_site_set.hh | 4 +-
milena/mln/convert/impl/from_int_to_value.hh | 2 +
milena/mln/core/image/dmorph/sub_image.hh | 5 ++-
milena/mln/core/internal/site_set_iterator_base.hh | 6 +++-
milena/mln/core/point.hh | 5 ++-
milena/mln/core/site_set/box.hh | 8 +++---
milena/mln/core/site_set/p_array.hh | 7 +++--
milena/mln/core/site_set/p_edges.hh | 5 ++-
milena/mln/core/site_set/p_vertices.hh | 4 +-
milena/mln/opt/element.hh | 4 ++-
milena/mln/value/builtin/carrays.hh | 5 ++-
16 files changed, 77 insertions(+), 35 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 77e5cc3..8226e1b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,28 @@
+2011-04-28 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Fix warnings with clang 1.1
+
+ * mln/accu/line.hh: Use def::coord.
+
+ * mln/algebra/vec.hh,
+ * mln/convert/from_to.hxx,
+ * mln/core/image/dmorph/sub_image.hh,
+ * mln/core/internal/site_set_iterator_base.hh,
+ * mln/core/site_set/box.hh,
+ * mln/core/site_set/p_array.hh,
+ * mln/core/site_set/p_edges.hh,
+ * mln/core/site_set/p_vertices.hh: Make forward declaration
+ consistent with declaration.
+
+ * mln/value/builtin/carrays.hh: Explicitly convert to char *.
+
+ * mln/convert/impl/from_double_to_value.hh,
+ * mln/convert/impl/from_int_to_value.hh,
+ * mln/core/point.hh,
+ * mln/opt/element.hh: Avoid unused variable warning.
+
+ * mln/convert/impl/from_image_to_site_set.hh: Remove useless local variable.
+
2010-12-10 Roland Levillain <roland(a)lrde.epita.fr>
Ensure non implemented reconstructions on sets abort at run time.
diff --git a/milena/mln/accu/line.hh b/milena/mln/accu/line.hh
index c6022ef..75be6b3 100644
--- a/milena/mln/accu/line.hh
+++ b/milena/mln/accu/line.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -63,8 +64,8 @@ namespace mln
typename I, typename O>
void
line(const Image<I>& input,
- const mln_site(I)& p_start, unsigned len,
- unsigned half_length,
+ const mln_site(I)& p_start, def::coord len,
+ def::coord half_length,
Image<O>& output);
@@ -98,7 +99,7 @@ namespace mln
mln_precondition(input.is_valid());
mln_precondition(output.is_valid());
}
-
+
} // end of namespace mln::accu::internal
@@ -107,7 +108,7 @@ namespace mln
namespace generic
{
-
+
template <typename Meta_Accu, unsigned Dir,
typename I, typename O>
void
@@ -212,8 +213,8 @@ namespace mln
typename I, typename O>
void
line_fastest(const Image<I>& input_,
- const mln_site(I)& p_start, unsigned len,
- unsigned half_length,
+ const mln_site(I)& p_start, def::coord len,
+ def::coord half_length,
Image<O>& output_)
{
typedef mln_site(I) P;
@@ -371,7 +372,7 @@ namespace mln
half_length,
output);
}
-
+
} // end of namespace mln::accu::internal
diff --git a/milena/mln/algebra/vec.hh b/milena/mln/algebra/vec.hh
index 22ebc02..dc526ec 100644
--- a/milena/mln/algebra/vec.hh
+++ b/milena/mln/algebra/vec.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2006, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2006, 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -55,7 +56,7 @@ namespace mln
// Forward declarations.
namespace algebra {
template <unsigned n, typename T> class vec;
- template <unsigned d, typename C> class h_vec;
+ template <unsigned d, typename C> struct h_vec;
template <unsigned n, unsigned m, typename T> class mat;
}
diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx
index f4f690d..95c35a8 100644
--- a/milena/mln/convert/from_to.hxx
+++ b/milena/mln/convert/from_to.hxx
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -68,7 +69,7 @@ namespace mln
namespace algebra {
template <unsigned n, typename T> class vec;
- template <unsigned d, typename C> class h_vec;
+ template <unsigned d, typename C> struct h_vec;
}
namespace fun {
diff --git a/milena/mln/convert/impl/from_double_to_value.hh b/milena/mln/convert/impl/from_double_to_value.hh
index de766df..fa72059 100644
--- a/milena/mln/convert/impl/from_double_to_value.hh
+++ b/milena/mln/convert/impl/from_double_to_value.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2011 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -89,6 +90,8 @@ namespace mln
from_double_to_value(const double& from,
Value<V>& to)
{
+ (void) from;
+ (void) to;
mlc_abort(V)::check();
}
diff --git a/milena/mln/convert/impl/from_image_to_site_set.hh b/milena/mln/convert/impl/from_image_to_site_set.hh
index 2bdbcff..65873b6 100644
--- a/milena/mln/convert/impl/from_image_to_site_set.hh
+++ b/milena/mln/convert/impl/from_image_to_site_set.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -107,7 +108,6 @@ namespace mln
const std::pair< mln_value(I), p_run<P> >&)
{
s.clear();
- mln_value(I) O = literal::zero;
mln_fwd_piter(I) p(input.domain());
p.start();
for (;;)
diff --git a/milena/mln/convert/impl/from_int_to_value.hh b/milena/mln/convert/impl/from_int_to_value.hh
index 30840b3..bc83bf4 100644
--- a/milena/mln/convert/impl/from_int_to_value.hh
+++ b/milena/mln/convert/impl/from_int_to_value.hh
@@ -76,6 +76,8 @@ namespace mln
from_int_to_value(const int& from,
Value<V>& to)
{
+ (void) from;
+ (void) to;
mlc_abort(V)::check();
}
diff --git a/milena/mln/core/image/dmorph/sub_image.hh b/milena/mln/core/image/dmorph/sub_image.hh
index 9155b09..6256880 100644
--- a/milena/mln/core/image/dmorph/sub_image.hh
+++ b/milena/mln/core/image/dmorph/sub_image.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -43,7 +44,7 @@ namespace mln
// Forward declaration.
- template <typename I, typename S> class sub_image;
+ template <typename I, typename S> struct sub_image;
namespace internal
diff --git a/milena/mln/core/internal/site_set_iterator_base.hh b/milena/mln/core/internal/site_set_iterator_base.hh
index 66c94d5..71c3fe3 100644
--- a/milena/mln/core/internal/site_set_iterator_base.hh
+++ b/milena/mln/core/internal/site_set_iterator_base.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -114,8 +115,9 @@ namespace mln
template <typename S, typename E>
inline
void
- site_set_iterator_base<S, E>::change_target_(const S& /* s */)
+ site_set_iterator_base<S, E>::change_target_(const S& s)
{
+ (void) s;
// Empty by default.
}
diff --git a/milena/mln/core/point.hh b/milena/mln/core/point.hh
index df1fc2c..c4d1a73 100644
--- a/milena/mln/core/point.hh
+++ b/milena/mln/core/point.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010, 2011 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -669,6 +669,7 @@ namespace mln
const util::yes&
cut_(const point<grid::tick,C>& p)
{
+ (void) p;
util::yes* the_;
return *the_;
}
diff --git a/milena/mln/core/site_set/box.hh b/milena/mln/core/site_set/box.hh
index c061321..11715b9 100644
--- a/milena/mln/core/site_set/box.hh
+++ b/milena/mln/core/site_set/box.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010, 2011 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -44,8 +44,8 @@ namespace mln
// Fwd decls.
template <typename P> struct box;
- template <typename P> struct box_fwd_piter_;
- template <typename P> struct box_bkd_piter_;
+ template <typename P> class box_fwd_piter_;
+ template <typename P> class box_bkd_piter_;
namespace trait
diff --git a/milena/mln/core/site_set/p_array.hh b/milena/mln/core/site_set/p_array.hh
index 218a95a..36129f9 100644
--- a/milena/mln/core/site_set/p_array.hh
+++ b/milena/mln/core/site_set/p_array.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -52,8 +53,8 @@ namespace mln
template <typename P> class p_array;
template <typename S> class p_indexed_psite;
- template <typename S> struct p_indexed_fwd_piter;
- template <typename S> struct p_indexed_bkd_piter;
+ template <typename S> class p_indexed_fwd_piter;
+ template <typename S> class p_indexed_bkd_piter;
diff --git a/milena/mln/core/site_set/p_edges.hh b/milena/mln/core/site_set/p_edges.hh
index 4c58696..b4f1d27 100644
--- a/milena/mln/core/site_set/p_edges.hh
+++ b/milena/mln/core/site_set/p_edges.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -45,7 +46,7 @@ namespace mln
{
// Forward declaration.
- template <typename G, typename F> struct p_edges;
+ template <typename G, typename F> class p_edges;
namespace trait
diff --git a/milena/mln/core/site_set/p_vertices.hh b/milena/mln/core/site_set/p_vertices.hh
index c8497c0..6efa1a9 100644
--- a/milena/mln/core/site_set/p_vertices.hh
+++ b/milena/mln/core/site_set/p_vertices.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009, 2011 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of Olena.
@@ -44,7 +44,7 @@ namespace mln
{
// Forward declaration.
- template <typename G, typename F> struct p_vertices;
+ template <typename G, typename F> class p_vertices;
namespace trait
diff --git a/milena/mln/opt/element.hh b/milena/mln/opt/element.hh
index cec8ebe..f572349 100644
--- a/milena/mln/opt/element.hh
+++ b/milena/mln/opt/element.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2011 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -84,6 +85,7 @@ namespace mln
mln_lvalue(I) element_impl(trait::image::category::domain_morpher,
Image<I>& ima, unsigned index)
{
+ (void) index;
return element(*exact(ima).delegatee_());
}
diff --git a/milena/mln/value/builtin/carrays.hh b/milena/mln/value/builtin/carrays.hh
index a245683..3ad2721 100644
--- a/milena/mln/value/builtin/carrays.hh
+++ b/milena/mln/value/builtin/carrays.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2011 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -69,7 +70,7 @@ namespace mln
{
std::ostringstream s;
s << value_<T>::name() << '[' << n << ']';
- return s.str();
+ return s.str().c_str();
}
};
--
1.5.6.5
1
0

last-svn-commit-250-g5946ef3 Configure milena/apps/generic-skel/Makefile.
by Roland Levillain 12 Apr '11
by Roland Levillain 12 Apr '11
12 Apr '11
---
ChangeLog | 4 ++++
configure.ac | 1 +
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f3ef8a4..3b568b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-08-20 Roland Levillain <roland(a)lrde.epita.fr>
+
+ * configure.ac: Configure milena/apps/generic-skel/Makefile.
+
2010-06-24 Roland Levillain <roland(a)lrde.epita.fr>
* configure.ac: Configure milena/tests/io/vtk/Makefile.
diff --git a/configure.ac b/configure.ac
index 6fc5465..c75afff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -493,6 +493,7 @@ AM_CONDITIONAL([ENABLE_APPS], [test "x$enable_apps" = "xyes"])
AC_CONFIG_FILES([
milena/apps/Makefile
milena/apps/constrained-connectivity/Makefile
+ milena/apps/generic-skel/Makefile
milena/apps/graph-morpho/Makefile
milena/apps/mesh-segm-skel/Makefile
milena/apps/papers/Makefile
--
1.5.6.5
1
0

12 Apr '11
* apps/generic-skel/image2d-skel-unconstrained.cc,
* apps/generic-skel/image2d-skel-with-end-points.cc,
* apps/generic-skel/image2d-skel.hh:
New.
* apps/generic-skel/test-image2d-skel-unconstrained.in,
* apps/generic-skel/test-image2d-skel-with-end-points.in:
New tests.
* apps/generic-skel/Makefile.am: New.
* apps/Makefile.am (SUBDIRS): Add generic-skel.
---
milena/ChangeLog | 14 ++
milena/apps/Makefile.am | 6 +-
milena/apps/generic-skel/Makefile.am | 54 ++++++
.../image2d-skel-unconstrained.cc} | 53 +++++--
.../image2d-skel-with-end-points.cc} | 52 +++++--
milena/apps/generic-skel/image2d-skel.hh | 174 ++++++++++++++++++++
.../test-image2d-skel-unconstrained.in} | 7 +-
.../test-image2d-skel-with-end-points.in} | 7 +-
8 files changed, 330 insertions(+), 37 deletions(-)
create mode 100644 milena/apps/generic-skel/Makefile.am
copy milena/apps/{mesh-segm-skel/off-to-vtk-bin.cc => generic-skel/image2d-skel-unconstrained.cc} (53%)
copy milena/apps/{mesh-segm-skel/off-to-vtk-bin.cc => generic-skel/image2d-skel-with-end-points.cc} (53%)
create mode 100644 milena/apps/generic-skel/image2d-skel.hh
copy milena/apps/{mesh-segm-skel/test-mesh-complex-2-collapse.in => generic-skel/test-image2d-skel-unconstrained.in} (71%)
copy milena/apps/{mesh-segm-skel/test-mesh-complex-2-collapse.in => generic-skel/test-image2d-skel-with-end-points.in} (70%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index f567ea8..16b07b7 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,17 @@
+2010-08-20 Roland Levillain <roland(a)lrde.epita.fr>
+
+ New apps on generic skeletonization.
+
+ * apps/generic-skel/image2d-skel-unconstrained.cc,
+ * apps/generic-skel/image2d-skel-with-end-points.cc,
+ * apps/generic-skel/image2d-skel.hh:
+ New.
+ * apps/generic-skel/test-image2d-skel-unconstrained.in,
+ * apps/generic-skel/test-image2d-skel-with-end-points.in:
+ New tests.
+ * apps/generic-skel/Makefile.am: New.
+ * apps/Makefile.am (SUBDIRS): Add generic-skel.
+
2011-04-12 Roland Levillain <roland(a)lrde.epita.fr>
apps/graph-morpho: Catch up with current mln::topo::is_n_face.
diff --git a/milena/apps/Makefile.am b/milena/apps/Makefile.am
index c42ffd7..c15569b 100644
--- a/milena/apps/Makefile.am
+++ b/milena/apps/Makefile.am
@@ -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 Olena.
#
@@ -13,10 +14,9 @@
#
# You should have received a copy of the GNU General Public License
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
-#
# Applied examples of Milena.
-SUBDIRS = mesh-segm-skel graph-morpho constrained-connectivity
+SUBDIRS = mesh-segm-skel generic-skel graph-morpho constrained-connectivity
# Examples from papers.
SUBDIRS += papers
diff --git a/milena/apps/generic-skel/Makefile.am b/milena/apps/generic-skel/Makefile.am
new file mode 100644
index 0000000..5ae65f5
--- /dev/null
+++ b/milena/apps/generic-skel/Makefile.am
@@ -0,0 +1,54 @@
+# Copyright (C) 2010 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/>.
+
+# Find Milena and trimesh headers.
+AM_CPPFLAGS = -I$(top_srcdir)/milena
+# Produce fast code.
+APPS_CXXFLAGS = @APPS_CXXFLAGS@
+AM_CXXFLAGS = $(APPS_CXXFLAGS)
+
+
+bin_PROGRAMS = image2d-skel-unconstrained image2d-skel-with-end-points
+image2d_skel_unconstrained_SOURCES = image2d-skel-unconstrained.cc image2d-skel.hh
+image2d_skel_with_end_points_SOURCES = image2d-skel-with-end-points.cc image2d-skel.hh
+
+EXTRA_DIST = test-image2d-skel-unconstrained.in test-image2d-skel-with-end-points.in
+
+# Use Make to generate Doxyfile instead of `configure', as advised by
+# Autoconf's manual (see section ``Installation Directory
+# Variables'').
+edit = sed -e 's|@top_srcdir[@]|$(top_srcdir)|g'
+
+test-image2d-skel-unconstrained test-image2d-skel-with-end-points: Makefile
+ rm -f $@ $@.tmp
+ srcdir=''; \
+ test -f ./$@.in || srcdir=$(srcdir)/; \
+ $(edit) $${srcdir}$@.in >$@.tmp
+ chmod +x $@.tmp
+ chmod a-w $@.tmp
+ mv $@.tmp $@
+
+test-image2d-skel-unconstrained: $(srcdir)/test-image2d-skel-unconstrained.in
+test-image2d-skel-with-end-points: $(srcdir)/test-image2d-skel-with-end-points.in
+
+TESTS = test-image2d-skel-unconstrained test-image2d-skel-with-end-points
+CLEANFILES = test-image2d-skel-unconstrained test-image2d-skel-with-end-points
+
+MOSTLYCLEANFILES = \
+ picasso-skel-unconstrained.pbm \
+ picasso-skel-with-end-points.pbm \
+ tiny-skel-unconstrained.pbm \
+ tiny-skel-with-end-points.pbm
diff --git a/milena/apps/mesh-segm-skel/off-to-vtk-bin.cc b/milena/apps/generic-skel/image2d-skel-unconstrained.cc
similarity index 53%
copy from milena/apps/mesh-segm-skel/off-to-vtk-bin.cc
copy to milena/apps/generic-skel/image2d-skel-unconstrained.cc
index 926da7d..4459ba4 100644
--- a/milena/apps/mesh-segm-skel/off-to-vtk-bin.cc
+++ b/milena/apps/generic-skel/image2d-skel-unconstrained.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 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
@@ -26,22 +26,26 @@
// Public License.
/// \file
+/// \brief A program computing an unconstrained skeleton of a 2D image.
-/// \brief A program converting a binary OFF file (e.g. no value
-/// attached to faces) into a VTK file.
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
-#include <iostream>
+#include <mln/topo/skeleton/breadth_first_thinning.hh>
-#include <mln/io/off/load.hh>
-#include <mln/io/vtk/save.hh>
+#include <mln/io/pbm/all.hh>
+
+#include "image2d-skel.hh"
int
main(int argc, char* argv[])
{
+ using namespace mln;
+
if (argc != 3)
{
- std::cerr << "usage: " << argv[0] << " input.off output.vtk"
+ std::cerr << "usage: " << argv[0] << " input.pbm output.pbm"
<< std::endl;
std::exit(1);
}
@@ -49,12 +53,33 @@ main(int argc, char* argv[])
std::string input_filename = argv[1];
std::string output_filename = argv[2];
- typedef mln::bin_2complex_image3df ima_t;
- ima_t ima;
+ typedef image2d<bool> I;
+ typedef neighb2d N;
+
+ // Add a border of (at least) 1 pixel, to a guarantee a meaningful
+ // result of the computation of connectivity numbers (called within
+ // is_simple_2d); indeed, this computation always expects each pixel
+ // to have 8 neighboring sites.
+ border::thickness = 1;
+
+ I input = io::pbm::load(input_filename);
+
+ // FIXME: Use a dual neighborhood instead?
+
+ // Foreground neighborhood.
+ neighb2d nbh_fg = c4();
+ // Background neighborhood.
+ neighb2d nbh_bg = c8();
+
+ // Simplicity criterion functor.
+ ::is_simple_2d<I, N> is_simple(nbh_fg, nbh_bg);
+ // Detach procedure.
+ ::detach<I> detach;
+ // (Lack of) constraint.
+ fun::p2b::tautology constraint;
- // FIXME: Converting bunny-holefilled.off to VTK took 30 sec, which
- // is awfully slow. Time the load and save operations and find
- // where is (are) the issue(s).
- mln::io::off::load(ima, input_filename);
- mln::io::vtk::save(ima, output_filename);
+ I output = topo::skeleton::breadth_first_thinning(input, nbh_fg,
+ is_simple, detach,
+ constraint);
+ io::pbm::save(output, output_filename);
}
diff --git a/milena/apps/mesh-segm-skel/off-to-vtk-bin.cc b/milena/apps/generic-skel/image2d-skel-with-end-points.cc
similarity index 53%
copy from milena/apps/mesh-segm-skel/off-to-vtk-bin.cc
copy to milena/apps/generic-skel/image2d-skel-with-end-points.cc
index 926da7d..604b065 100644
--- a/milena/apps/mesh-segm-skel/off-to-vtk-bin.cc
+++ b/milena/apps/generic-skel/image2d-skel-with-end-points.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 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
@@ -26,22 +26,27 @@
// Public License.
/// \file
+/// \brief A program computing a skeleton of a 2D image, preserving
+/// end points.
-/// \brief A program converting a binary OFF file (e.g. no value
-/// attached to faces) into a VTK file.
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
-#include <iostream>
+#include <mln/topo/skeleton/breadth_first_thinning.hh>
-#include <mln/io/off/load.hh>
-#include <mln/io/vtk/save.hh>
+#include <mln/io/pbm/all.hh>
+
+#include "image2d-skel.hh"
int
main(int argc, char* argv[])
{
+ using namespace mln;
+
if (argc != 3)
{
- std::cerr << "usage: " << argv[0] << " input.off output.vtk"
+ std::cerr << "usage: " << argv[0] << " input.pbm output.pbm"
<< std::endl;
std::exit(1);
}
@@ -49,12 +54,31 @@ main(int argc, char* argv[])
std::string input_filename = argv[1];
std::string output_filename = argv[2];
- typedef mln::bin_2complex_image3df ima_t;
- ima_t ima;
+ typedef image2d<bool> I;
+ typedef neighb2d N;
+
+ // Add a border of (at least) 1 pixel, to a guarantee a meaningful
+ // result of the computation of connectivity numbers (called within
+ // is_simple_2d); indeed, this computation always expects each pixel
+ // to have 8 neighboring sites.
+ border::thickness = 1;
+
+ I input = io::pbm::load(input_filename);
+
+ // Foreground neighborhood.
+ neighb2d nbh_fg = c4();
+ // Background neighborhood.
+ neighb2d nbh_bg = c8();
+
+ // Simplicity criterion functor.
+ ::is_simple_2d<I, N> is_simple(nbh_fg, nbh_bg);
+ // Detach procedure.
+ ::detach<I> detach;
+ // Constraint: do not remove end points.
+ is_not_end_point<I, N> constraint(nbh_fg, input);
- // FIXME: Converting bunny-holefilled.off to VTK took 30 sec, which
- // is awfully slow. Time the load and save operations and find
- // where is (are) the issue(s).
- mln::io::off::load(ima, input_filename);
- mln::io::vtk::save(ima, output_filename);
+ I output = topo::skeleton::breadth_first_thinning(input, nbh_fg,
+ is_simple, detach,
+ constraint);
+ io::pbm::save(output, output_filename);
}
diff --git a/milena/apps/generic-skel/image2d-skel.hh b/milena/apps/generic-skel/image2d-skel.hh
new file mode 100644
index 0000000..6cd8c50
--- /dev/null
+++ b/milena/apps/generic-skel/image2d-skel.hh
@@ -0,0 +1,174 @@
+// Copyright (C) 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef APPS_GENERIC_SKEL_IMAGE2D_SKEL_HH
+# define APPS_GENERIC_SKEL_IMAGE2D_SKEL_HH
+
+/// \file
+/// \brief Definitions for a simplicity criterion and a constraint
+/// to be used in the breadth-first thinning of a 2D regular image.
+
+# include <mln/topo/is_simple_2d.hh>
+
+
+// FIXME: Split this file?
+
+
+/** \brief An equivalent (for mln::image2d) of the
+ mln::topo::is_simple_cell functor, based on the mask-based
+ criterion mln::topo::is_simple_2d.
+
+ This functor acts as an adapter, since mln::topo::is_simple_2d
+ does not fit (yet) in the canvas of
+ mln::topo::skeleton::breadth_first_thinning. Moreover, this code
+ is a bit easier to read since it does not make use of a dual
+ neighborhood (having a long and complex type). */
+template <typename I, typename N>
+class is_simple_2d : public mln::Function_v2b< is_simple_2d<I, N> >
+{
+public:
+ /// Result type of the functor.
+ typedef bool result;
+
+ /// Build a functor.
+ ///
+ /// \param nbh_fg The foreground neighborhood.
+ /// \param nbh_bg The background neighborhood.
+ is_simple_2d(const mln::Neighborhood<N>& nbh_fg,
+ const mln::Neighborhood<N>& nbh_bg)
+ : nbh_fg_(mln::exact(nbh_fg)), nbh_bg_(mln::exact(nbh_bg)),
+ ima_(0)
+ {
+ }
+
+ /// Build a functor, and assign an image to it.
+ ///
+ /// \param nbh_fg The foreground neighborhood.
+ /// \param nbh_bg The background neighborhood.
+ /// \apram ima The image.
+ is_simple_2d(const mln::Neighborhood<N>& nbh_fg,
+ const mln::Neighborhood<N>& nbh_bg,
+ const mln::Image<I>& ima)
+ : nbh_fg_(mln::exact(nbh_fg)), nbh_bg_(mln::exact(nbh_bg)),
+ ima_(mln::exact(&ima))
+ {
+ }
+
+ /// Set the underlying image.
+ void set_image(const mln::Image<I>& ima)
+ {
+ ima_ = mln::exact(&ima);
+ }
+
+ /// Based on connectivity numbers.
+ bool operator()(const mln_psite(I)& p) const
+ {
+ return
+ mln::connectivity_number_2d(*ima_, nbh_fg_, p, true ) == 1 &&
+ mln::connectivity_number_2d(*ima_, nbh_bg_, p, false) == 1;
+ }
+
+private:
+ /// The foreground neighborhood.
+ const N& nbh_fg_;
+ /// The background neighborhood.
+ const N& nbh_bg_;
+ /// The image.
+ const I* ima_;
+};
+
+
+template <typename I>
+class detach
+{
+public:
+ /// Build a functor.
+ detach()
+ : ima_(0)
+ {
+ }
+
+ /// Build a functor, and assign an image to it.
+ ///
+ /// \apram ima The image.
+ detach(mln::Image<I>& ima)
+ : ima_(mln::exact(&ima))
+ {
+ }
+
+ /// Set the underlying image.
+ void set_image(mln::Image<I>& ima)
+ {
+ ima_ = mln::exact(&ima);
+ }
+
+ void operator()(const mln_psite(I)& p) const
+ {
+ (*ima_)(p) = false;
+ }
+
+private:
+ /// The image.
+ I* ima_;
+};
+
+
+template <typename I, typename N>
+struct is_not_end_point : public mln::Function_v2b< is_not_end_point<I, N> >
+{
+ /// Build a functor, and assign an image to it.
+ ///
+ /// \param nbh_fg The foreground neighborhood.
+ /// \apram ima The image.
+ is_not_end_point(const mln::Neighborhood<N>& nbh,
+ const mln::Image<I>& ima)
+ : nbh_(mln::exact(nbh)),
+ ima_(mln::exact(ima))
+ {
+ }
+
+ // Is \a p not a end point?
+ bool operator()(const mln_psite(I)& p) const
+ {
+ // Number of foreground neighbors pixels.
+ unsigned nneighbs = 0;
+ mln_niter(N) n(nbh_, p);
+ for_all(n)
+ if (ima_.has(n) && ima_(n))
+ ++nneighbs;
+ return nneighbs != 1;
+ }
+
+private:
+ /// The foreground neighborhood.
+ const N& nbh_;
+ /// The image.
+ const I& ima_;
+};
+
+
+#endif // ! APPS_GENERIC_SKEL_IMAGE2D_SKEL_HH
diff --git a/milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in b/milena/apps/generic-skel/test-image2d-skel-unconstrained.in
similarity index 71%
copy from milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in
copy to milena/apps/generic-skel/test-image2d-skel-unconstrained.in
index d2a286b..b9f6b44 100644
--- a/milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in
+++ b/milena/apps/generic-skel/test-image2d-skel-unconstrained.in
@@ -1,6 +1,6 @@
#! /bin/sh
-# Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -18,6 +18,7 @@
set -ex
-mesh_dir=@top_srcdir@/milena/mesh
+img_dir=@top_srcdir@/milena/img
-time ./mesh-complex-2-collapse $mesh_dir/pseudo-manifold.vtk pseudo-manifold-2-collapse.vtk
+./image2d-skel-unconstrained $img_dir/tiny.pbm tiny-skel-unconstrained.pbm
+./image2d-skel-unconstrained $img_dir/picasso.pbm picasso-skel-unconstrained.pbm
diff --git a/milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in b/milena/apps/generic-skel/test-image2d-skel-with-end-points.in
similarity index 70%
copy from milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in
copy to milena/apps/generic-skel/test-image2d-skel-with-end-points.in
index d2a286b..946e8fd 100644
--- a/milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in
+++ b/milena/apps/generic-skel/test-image2d-skel-with-end-points.in
@@ -1,6 +1,6 @@
#! /bin/sh
-# Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -18,6 +18,7 @@
set -ex
-mesh_dir=@top_srcdir@/milena/mesh
+img_dir=@top_srcdir@/milena/img
-time ./mesh-complex-2-collapse $mesh_dir/pseudo-manifold.vtk pseudo-manifold-2-collapse.vtk
+./image2d-skel-with-end-points $img_dir/tiny.pbm tiny-skel-with-end-points.pbm
+./image2d-skel-with-end-points $img_dir/picasso.pbm picasso-skel-with-end-points.pbm
--
1.5.6.5
1
0
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 skeletons has been deleted
was a087bc4d5c23b64db8ca8a3fe40c73387419ec70
-----------------------------------------------------------------------
a087bc4d5c23b64db8ca8a3fe40c73387419ec70 Catch up with the renaming to detach_cell.
-----------------------------------------------------------------------
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0

12 Apr '11
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 more-generic-skel has been deleted
was 8cbc0864835adb146da03fde34e7f3328bc580a8
-----------------------------------------------------------------------
8cbc0864835adb146da03fde34e7f3328bc580a8 Use mln::data::paste to simplify mesh skeleton applications.
-----------------------------------------------------------------------
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0

last-svn-commit-247-g8ac5e61 Use priority-driven thinning in collapse-based thinnings apps.
by Roland Levillain 12 Apr '11
by Roland Levillain 12 Apr '11
12 Apr '11
* apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc,
* apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc:
Here.
---
milena/ChangeLog | 8 ++++++++
.../mesh-complex-max-curv-1-collapse.cc | 18 +++++++++++++-----
.../mesh-complex-max-curv-2-collapse.cc | 13 ++++++++++---
3 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 8c32c8b..c34431a 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
2011-03-20 Roland Levillain <roland(a)lrde.epita.fr>
+ Use priority-driven thinning in collapse-based thinnings apps.
+
+ * apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc,
+ * apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc:
+ Here.
+
+2011-03-20 Roland Levillain <roland(a)lrde.epita.fr>
+
Simplify curvature-based thinnings using 2- and 1-collapses apps.
* apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc,
diff --git a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc
index 8b12030..4716a42 100644
--- a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc
+++ b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc
@@ -54,7 +54,9 @@
#include <mln/topo/is_n_face.hh>
#include <mln/topo/is_simple_pair.hh>
#include <mln/topo/detach_pair.hh>
-#include <mln/topo/skeleton/breadth_first_thinning.hh>
+#include <mln/topo/skeleton/priority_driven_thinning.hh>
+
+#include <mln/arith/revert.hh>
#include <mln/io/vtk/load.hh>
#include <mln/io/vtk/save.hh>
@@ -288,14 +290,19 @@ main(int argc, char* argv[])
// Thinning by 2-collapse. //
// ------------------------ //
+ // Create a priority function (actually, an image) using the inverse
+ // of the curvature image.
+ ima_t priority = mln::arith::revert(closed_ima);
+
mln_concrete_(bin_ima_t) surface_2_collapse;
mln::initialize(surface_2_collapse, surface);
mln::data::paste
- (mln::topo::skeleton::breadth_first_thinning
+ (mln::topo::skeleton::priority_driven_thinning
(mln::mutable_extend((surface | is_a_triangle).rw(), surface),
nbh,
is_simple_triangle,
- detach_triangle)
+ detach_triangle,
+ priority)
/* Before pasting the result of the computation into
SURFACE_2_COLLAPSE, re-expand its domain to the initial site
set, to ensure data from all faces (i.e., both the 2-faces,
@@ -347,12 +354,13 @@ main(int argc, char* argv[])
mln_concrete_(bin_ima_t) surface_1_collapse;
mln::initialize(surface_1_collapse, surface_2_collapse);
mln::data::paste
- (mln::topo::skeleton::breadth_first_thinning
+ (mln::topo::skeleton::priority_driven_thinning
(mln::mutable_extend((surface_2_collapse | is_an_edge).rw(),
surface_2_collapse),
nbh,
is_simple_edge,
- detach_edge)
+ detach_edge,
+ priority)
/* Likewise, before pasting the result of the computation into
SURFACE_1_COLLAPSE, re-expand its domain to the initial site
set, to ensure data from all faces (i.e., both the 1-faces,
diff --git a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc
index c88f10d..7df256e 100644
--- a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc
+++ b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc
@@ -54,7 +54,9 @@
#include <mln/topo/is_n_face.hh>
#include <mln/topo/is_simple_pair.hh>
#include <mln/topo/detach_pair.hh>
-#include <mln/topo/skeleton/breadth_first_thinning.hh>
+#include <mln/topo/skeleton/priority_driven_thinning.hh>
+
+#include <mln/arith/revert.hh>
#include <mln/io/vtk/load.hh>
#include <mln/io/vtk/save.hh>
@@ -288,14 +290,19 @@ main(int argc, char* argv[])
// Thinning by 2-collapse. //
// ------------------------ //
+ // Create a priority function (actually, an image) using the inverse
+ // of the curvature image.
+ ima_t priority = mln::arith::revert(closed_ima);
+
mln_concrete_(bin_ima_t) surface_2_collapse;
mln::initialize(surface_2_collapse, surface);
mln::data::paste
- (mln::topo::skeleton::breadth_first_thinning
+ (mln::topo::skeleton::priority_driven_thinning
(mln::mutable_extend((surface | is_a_triangle).rw(), surface),
nbh,
is_simple_triangle,
- detach_triangle)
+ detach_triangle,
+ priority)
/* Before pasting the result of the computation into
SURFACE_2_COLLAPSE, re-expand its domain to the initial site
set, to ensure data from all faces (i.e., both the 2-faces,
--
1.5.6.5
1
0

last-svn-commit-246-gf714e94 Simplify curvature-based thinnings using 2- and 1-collapses apps.
by Roland Levillain 12 Apr '11
by Roland Levillain 12 Apr '11
12 Apr '11
* apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc,
* apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc:
Here.
---
milena/ChangeLog | 8 +
.../mesh-complex-max-curv-1-collapse.cc | 196 +++++++++-----------
.../mesh-complex-max-curv-2-collapse.cc | 193 +++++++++----------
3 files changed, 188 insertions(+), 209 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 63b6054..8c32c8b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,11 @@
+2011-03-20 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Simplify curvature-based thinnings using 2- and 1-collapses apps.
+
+ * apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc,
+ * apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc:
+ Here.
+
2011-03-14 Roland Levillain <roland(a)lrde.epita.fr>
Miscellaneous changes in mesh-related operations.
diff --git a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc
index 0cb29dd..8b12030 100644
--- a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc
+++ b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc
@@ -41,7 +41,7 @@
#include <mln/core/image/dmorph/image_if.hh>
#include <mln/core/image/dmorph/sub_image.hh>
-#include <mln/core/image/dmorph/mutable_extension_ima.hh>
+#include <mln/core/routine/extend.hh>
#include <mln/core/routine/mutable_extend.hh>
#include <mln/data/paste.hh>
@@ -49,6 +49,7 @@
#include <mln/labeling/regional_minima.hh>
#include <mln/morpho/closing/area.hh>
+#include <mln/morpho/dilation.hh>
#include <mln/topo/is_n_face.hh>
#include <mln/topo/is_simple_pair.hh>
@@ -101,31 +102,57 @@ main(int argc, char* argv[])
mln::math::sqr(curv.second(v)));
}
+ // Neighborhood type returning the set of (n-1)-faces adjacent to a
+ // an n-face.
+ typedef mln::complex_lower_neighborhood<D, G> lower_adj_nbh_t;
+ lower_adj_nbh_t lower_adj_nbh;
+
+ // Values on edges.
+ /* FIXME: We could probably simplify this by using a
+ convolution-like operator and morphers (see
+ apps/graph-morpho). */
+ mln::p_n_faces_fwd_piter<D, G> e(float_ima.domain(), 1);
+ // For each edge (1-face) E, iterate on the the set of vertices
+ // (0-faces) adjacent to E.
+ mln_niter_(lower_adj_nbh_t) adj_v(lower_adj_nbh, e);
+ // Iterate on edges (1-faces).
+ for_all(e)
+ {
+ float s = 0.0f;
+ unsigned n = 0;
+ // Iterate on vertices (0-faces).
+ for_all(adj_v)
+ {
+ s += float_ima(adj_v);
+ ++n;
+ }
+ float_ima(e) = s / n;
+ // An edge should be adjacent to exactly two vertices.
+ mln_invariant(n == 2);
+ }
+
// Values on triangles.
+ /* FIXME: We could probably simplify this by using a
+ convolution-like operator and morphers (see
+ apps/graph-morpho). */
mln::p_n_faces_fwd_piter<D, G> t(float_ima.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);
+ // For each triangle (2-face) T, iterate on the the set of edges
+ // (1-faces) adjacent to T.
+ mln_niter_(lower_adj_nbh_t) adj_e(lower_adj_nbh, t);
// Iterate on triangles (2-faces).
for_all(t)
{
float s = 0.0f;
unsigned n = 0;
- // Iterate on vertices (0-faces).
- for_all(adj_v)
+ // Iterate on edges (1-faces).
+ for_all(adj_e)
{
- s += float_ima(adj_v);
+ s += float_ima(adj_e);
++n;
}
float_ima(t) = s / n;
- // A triangle should be adjacent to exactly two vertices.
- mln_invariant(n <= 3);
+ // A triangle should be adjacent to exactly three edges.
+ mln_invariant(n == 3);
}
// Convert the float image into an unsigned image because some
@@ -141,14 +168,6 @@ main(int argc, char* argv[])
for_all(t)
ima(t) = 1000 * float_ima(t);
- /* FIXME: Workaround: Set maximal values on vertices and edges to
- exclude them from the set of minimal values. */
- for_all(v)
- ima(v) = mln_max(mln_value_(ima_t));
- mln::p_n_faces_fwd_piter<D, G> e(float_ima.domain(), 1);
- for_all(e)
- ima(e) = mln_max(mln_value_(ima_t));
-
/*-----------------.
| Simplification. |
`-----------------*/
@@ -157,7 +176,15 @@ main(int argc, char* argv[])
typedef mln::complex_lower_dim_connected_n_face_neighborhood<D, G> nbh_t;
nbh_t nbh;
- ima_t closed_ima = mln::morpho::closing::area(ima, nbh, lambda);
+ // Predicate type: is a face a triangle (2-face)?
+ typedef mln::topo::is_n_face<mln_psite_(ima_t), 2> is_a_triangle_t;
+ is_a_triangle_t is_a_triangle;
+
+ // Consider only triangles.
+ ima_t closed_ima = mln::duplicate(ima);
+ mln::data::paste(mln::morpho::closing::area(ima | is_a_triangle,
+ nbh, lambda),
+ closed_ima);
/*---------------.
| Local minima. |
@@ -166,68 +193,13 @@ main(int argc, char* argv[])
typedef mln::value::label_16 label_t;
label_t nminima;
- /* FIXME: We should use something like `ima_t | p_n_faces(2)' instead
- of `ima_t' here. Or better: `input' should only associate data
- to 2-faces. */
+ // Consider only triangles.
typedef mln_ch_value_(ima_t, label_t) label_ima_t;
- label_ima_t minima =
- mln::labeling::regional_minima(closed_ima, nbh, nminima);
-
- typedef mln::complex_higher_neighborhood<D, G> higher_nbh_t;
- higher_nbh_t higher_nbh;
-
- // Propagate minima values from triangles to edges.
- // FIXME: Factor this inside a function.
- mln_niter_(higher_nbh_t) adj_t(higher_nbh, e);
- for_all(e)
- {
- label_t ref_adj_minimum = mln::literal::zero;
- for_all(adj_t)
- if (minima(adj_t) == mln::literal::zero)
- {
- // If E is adjacent to a non-minimal triangle, then it must
- // not belong to a minima.
- ref_adj_minimum = mln::literal::zero;
- break;
- }
- else
- {
- if (ref_adj_minimum == mln::literal::zero)
- // If this is the first minimum seen, use it as a reference.
- ref_adj_minimum = minima(adj_t);
- else
- // If this is not the first time a minimum is encountered,
- // ensure it is REF_ADJ_MINIMUM.
- mln_assertion(minima(adj_t) == ref_adj_minimum);
- }
- minima(e) = ref_adj_minimum;
- }
-
- // Likewise from edges to edges to vertices.
- mln_niter_(higher_nbh_t) adj_e(higher_nbh, v);
- for_all(v)
- {
- label_t ref_adj_minimum = mln::literal::zero;
- for_all(adj_e)
- if (minima(adj_e) == mln::literal::zero)
- {
- // If V is adjacent to a non-minimal triangle, then it must
- // not belong to a minima.
- ref_adj_minimum = mln::literal::zero;
- break;
- }
- else
- {
- if (ref_adj_minimum == mln::literal::zero)
- // If this is the first minimum seen, use it as a reference.
- ref_adj_minimum = minima(adj_e);
- else
- // If this is not the first time a minimum is encountered,
- // ensure it is REF_ADJ_MINIMUM.
- mln_assertion(minima(adj_e) == ref_adj_minimum);
- }
- minima(v) = ref_adj_minimum;
- }
+ label_ima_t minima;
+ mln::initialize(minima, closed_ima);
+ mln::data::paste(mln::labeling::regional_minima(closed_ima | is_a_triangle,
+ nbh, nminima),
+ minima);
/*-----------------------.
| Initial binary image. |
@@ -242,13 +214,39 @@ main(int argc, char* argv[])
typedef mln_ch_value_(ima_t, bool) bin_ima_t;
bin_ima_t surface(minima.domain());
- mln::data::fill(surface, true);
- // Dig ``holes'' in the surface surface by setting minima faces to false.
- // FIXME: Use fill with an image_if instead, when available/working.
- mln_piter_(bin_ima_t) f(minima.domain());
- for_all(f)
- if (minima(f) != mln::literal::zero)
- surface(f) = false;
+
+ // Predicate type: is a face an edge (1-face)?
+ typedef mln::topo::is_n_face<mln_psite_(ima_t), 1> is_an_edge_t;
+ is_an_edge_t is_an_edge;
+ // Predicate type: is a face a vertex (0-face)?
+ typedef mln::topo::is_n_face<mln_psite_(ima_t), 0> is_a_vertex_t;
+ is_a_vertex_t is_a_vertex;
+
+ // Neighborhood type returning the set of (n+1)-faces adjacent to a
+ // an n-face.
+ typedef mln::complex_higher_neighborhood<D, G> higher_adj_nbh_t;
+ higher_adj_nbh_t higher_adj_nbh;
+
+ mln::data::fill(surface, false);
+ // Set non minima triangles to true;
+ mln::data::fill
+ ((surface |
+ mln::pw::value(minima) == mln::pw::cst(mln::literal::zero)).rw(),
+ true);
+ // Extend non minima values from triangles to edges.
+ mln::data::paste (mln::morpho::dilation(mln::extend(surface | is_an_edge,
+ surface),
+ /* Dilations require windows,
+ not neighborhoods. */
+ higher_adj_nbh.win()),
+ surface);
+ // Extend non minima values from edges to vertices.
+ mln::data::paste(mln::morpho::dilation(mln::extend(surface | is_a_vertex,
+ surface),
+ /* Dilations require windows,
+ not neighborhoods. */
+ higher_adj_nbh.win()),
+ surface);
/*-------------.
| 2-collapse. |
@@ -258,9 +256,6 @@ main(int argc, char* argv[])
// Image restricted to triangles. //
// ------------------------------- //
- // Predicate type: is a face a triangle (2-face)?
- typedef mln::topo::is_n_face<mln_psite_(bin_ima_t), D> is_a_triangle_t;
- is_a_triangle_t is_a_triangle;
// Surface image type, of which domain is restricted to triangles.
typedef mln::image_if<bin_ima_t, is_a_triangle_t> bin_triangle_only_ima_t;
// Surface image type, of which iteration (not domain) is restricted
@@ -272,14 +267,6 @@ main(int argc, char* argv[])
// Simple point predicate. //
// ------------------------ //
- // Neighborhood type returning the set of (n-1)-faces adjacent to a
- // an n-face.
- typedef mln::complex_lower_neighborhood<D, G> lower_adj_nbh_t;
- lower_adj_nbh_t lower_adj_nbh;
- // Neighborhood type returning the set of (n+1)-faces adjacent to a
- // an n-face.
- typedef mln::complex_higher_neighborhood<D, G> higher_adj_nbh_t;
- higher_adj_nbh_t higher_adj_nbh;
// Predicate type: is a triangle (2-face) simple?
typedef mln::topo::is_simple_pair< bin_triangle_ima_t,
lower_adj_nbh_t,
@@ -325,9 +312,6 @@ main(int argc, char* argv[])
// Image restricted to edges. //
// --------------------------- //
- // Predicate type: is a face an edge (1-face)?
- typedef mln::topo::is_n_face<mln_psite_(bin_ima_t), D - 1> is_an_edge_t;
- is_an_edge_t is_an_edge;
// Surface image type, of which domain is restricted to edges.
typedef mln::image_if<bin_ima_t, is_an_edge_t> bin_edge_only_ima_t;
// Surface image type, of which iteration (not domain) is restricted
diff --git a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc
index 233756d..c88f10d 100644
--- a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc
+++ b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc
@@ -41,7 +41,7 @@
#include <mln/core/image/dmorph/image_if.hh>
#include <mln/core/image/dmorph/sub_image.hh>
-#include <mln/core/image/dmorph/mutable_extension_ima.hh>
+#include <mln/core/routine/extend.hh>
#include <mln/core/routine/mutable_extend.hh>
#include <mln/data/paste.hh>
@@ -49,6 +49,7 @@
#include <mln/labeling/regional_minima.hh>
#include <mln/morpho/closing/area.hh>
+#include <mln/morpho/dilation.hh>
#include <mln/topo/is_n_face.hh>
#include <mln/topo/is_simple_pair.hh>
@@ -101,31 +102,57 @@ main(int argc, char* argv[])
mln::math::sqr(curv.second(v)));
}
+ // Neighborhood type returning the set of (n-1)-faces adjacent to a
+ // an n-face.
+ typedef mln::complex_lower_neighborhood<D, G> lower_adj_nbh_t;
+ lower_adj_nbh_t lower_adj_nbh;
+
+ // Values on edges.
+ /* FIXME: We could probably simplify this by using a
+ convolution-like operator and morphers (see
+ apps/graph-morpho). */
+ mln::p_n_faces_fwd_piter<D, G> e(float_ima.domain(), 1);
+ // For each edge (1-face) E, iterate on the the set of vertices
+ // (0-faces) adjacent to E.
+ mln_niter_(lower_adj_nbh_t) adj_v(lower_adj_nbh, e);
+ // Iterate on edges (1-faces).
+ for_all(e)
+ {
+ float s = 0.0f;
+ unsigned n = 0;
+ // Iterate on vertices (0-faces).
+ for_all(adj_v)
+ {
+ s += float_ima(adj_v);
+ ++n;
+ }
+ float_ima(e) = s / n;
+ // An edge should be adjacent to exactly two vertices.
+ mln_invariant(n == 2);
+ }
+
// Values on triangles.
+ /* FIXME: We could probably simplify this by using a
+ convolution-like operator and morphers (see
+ apps/graph-morpho). */
mln::p_n_faces_fwd_piter<D, G> t(float_ima.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);
+ // For each triangle (2-face) T, iterate on the the set of edges
+ // (1-faces) adjacent to T.
+ mln_niter_(lower_adj_nbh_t) adj_e(lower_adj_nbh, t);
// Iterate on triangles (2-faces).
for_all(t)
{
float s = 0.0f;
unsigned n = 0;
- // Iterate on vertices (0-faces).
- for_all(adj_v)
+ // Iterate on edges (1-faces).
+ for_all(adj_e)
{
- s += float_ima(adj_v);
+ s += float_ima(adj_e);
++n;
}
float_ima(t) = s / n;
- // A triangle should be adjacent to exactly two vertices.
- mln_invariant(n <= 3);
+ // A triangle should be adjacent to exactly three edges.
+ mln_invariant(n == 3);
}
// Convert the float image into an unsigned image because some
@@ -141,14 +168,6 @@ main(int argc, char* argv[])
for_all(t)
ima(t) = 1000 * float_ima(t);
- /* FIXME: Workaround: Set maximal values on vertices and edges to
- exclude them from the set of minimal values. */
- for_all(v)
- ima(v) = mln_max(mln_value_(ima_t));
- mln::p_n_faces_fwd_piter<D, G> e(float_ima.domain(), 1);
- for_all(e)
- ima(e) = mln_max(mln_value_(ima_t));
-
/*-----------------.
| Simplification. |
`-----------------*/
@@ -157,7 +176,15 @@ main(int argc, char* argv[])
typedef mln::complex_lower_dim_connected_n_face_neighborhood<D, G> nbh_t;
nbh_t nbh;
- ima_t closed_ima = mln::morpho::closing::area(ima, nbh, lambda);
+ // Predicate type: is a face a triangle (2-face)?
+ typedef mln::topo::is_n_face<mln_psite_(ima_t), 2> is_a_triangle_t;
+ is_a_triangle_t is_a_triangle;
+
+ // Consider only triangles.
+ ima_t closed_ima = mln::duplicate(ima);
+ mln::data::paste(mln::morpho::closing::area(ima | is_a_triangle,
+ nbh, lambda),
+ closed_ima);
/*---------------.
| Local minima. |
@@ -166,68 +193,13 @@ main(int argc, char* argv[])
typedef mln::value::label_16 label_t;
label_t nminima;
- /* FIXME: We should use something like `ima_t | p_n_faces(2)' instead
- of `ima_t' here. Or better: `input' should only associate data
- to 2-faces. */
+ // Consider only triangles.
typedef mln_ch_value_(ima_t, label_t) label_ima_t;
- label_ima_t minima =
- mln::labeling::regional_minima(closed_ima, nbh, nminima);
-
- typedef mln::complex_higher_neighborhood<D, G> higher_nbh_t;
- higher_nbh_t higher_nbh;
-
- // Propagate minima values from triangles to edges.
- // FIXME: Factor this inside a function.
- mln_niter_(higher_nbh_t) adj_t(higher_nbh, e);
- for_all(e)
- {
- label_t ref_adj_minimum = mln::literal::zero;
- for_all(adj_t)
- if (minima(adj_t) == mln::literal::zero)
- {
- // If E is adjacent to a non-minimal triangle, then it must
- // not belong to a minima.
- ref_adj_minimum = mln::literal::zero;
- break;
- }
- else
- {
- if (ref_adj_minimum == mln::literal::zero)
- // If this is the first minimum seen, use it as a reference.
- ref_adj_minimum = minima(adj_t);
- else
- // If this is not the first time a minimum is encountered,
- // ensure it is REF_ADJ_MINIMUM.
- mln_assertion(minima(adj_t) == ref_adj_minimum);
- }
- minima(e) = ref_adj_minimum;
- }
-
- // Likewise from edges to edges to vertices.
- mln_niter_(higher_nbh_t) adj_e(higher_nbh, v);
- for_all(v)
- {
- label_t ref_adj_minimum = mln::literal::zero;
- for_all(adj_e)
- if (minima(adj_e) == mln::literal::zero)
- {
- // If V is adjacent to a non-minimal triangle, then it must
- // not belong to a minima.
- ref_adj_minimum = mln::literal::zero;
- break;
- }
- else
- {
- if (ref_adj_minimum == mln::literal::zero)
- // If this is the first minimum seen, use it as a reference.
- ref_adj_minimum = minima(adj_e);
- else
- // If this is not the first time a minimum is encountered,
- // ensure it is REF_ADJ_MINIMUM.
- mln_assertion(minima(adj_e) == ref_adj_minimum);
- }
- minima(v) = ref_adj_minimum;
- }
+ label_ima_t minima;
+ mln::initialize(minima, closed_ima);
+ mln::data::paste(mln::labeling::regional_minima(closed_ima | is_a_triangle,
+ nbh, nminima),
+ minima);
/*-----------------------.
| Initial binary image. |
@@ -242,13 +214,39 @@ main(int argc, char* argv[])
typedef mln_ch_value_(ima_t, bool) bin_ima_t;
bin_ima_t surface(minima.domain());
- mln::data::fill(surface, true);
- // Dig ``holes'' in the surface surface by setting minima faces to false.
- // FIXME: Use fill with an image_if instead, when available/working.
- mln_piter_(bin_ima_t) f(minima.domain());
- for_all(f)
- if (minima(f) != mln::literal::zero)
- surface(f) = false;
+
+ // Predicate type: is a face an edge (1-face)?
+ typedef mln::topo::is_n_face<mln_psite_(ima_t), 1> is_an_edge_t;
+ is_an_edge_t is_an_edge;
+ // Predicate type: is a face a vertex (0-face)?
+ typedef mln::topo::is_n_face<mln_psite_(ima_t), 0> is_a_vertex_t;
+ is_a_vertex_t is_a_vertex;
+
+ // Neighborhood type returning the set of (n+1)-faces adjacent to a
+ // an n-face.
+ typedef mln::complex_higher_neighborhood<D, G> higher_adj_nbh_t;
+ higher_adj_nbh_t higher_adj_nbh;
+
+ mln::data::fill(surface, false);
+ // Set non minima triangles to true;
+ mln::data::fill
+ ((surface |
+ mln::pw::value(minima) == mln::pw::cst(mln::literal::zero)).rw(),
+ true);
+ // Extend non minima values from triangles to edges.
+ mln::data::paste (mln::morpho::dilation(mln::extend(surface | is_an_edge,
+ surface),
+ /* Dilations require windows,
+ not neighborhoods. */
+ higher_adj_nbh.win()),
+ surface);
+ // Extend non minima values from edges to vertices.
+ mln::data::paste(mln::morpho::dilation(mln::extend(surface | is_a_vertex,
+ surface),
+ /* Dilations require windows,
+ not neighborhoods. */
+ higher_adj_nbh.win()),
+ surface);
/*-------------.
| 2-collapse. |
@@ -258,9 +256,6 @@ main(int argc, char* argv[])
// Image restricted to triangles. //
// ------------------------------- //
- // Predicate type: is a face a triangle (2-face)?
- typedef mln::topo::is_n_face<mln_psite_(bin_ima_t), D> is_a_triangle_t;
- is_a_triangle_t is_a_triangle;
// Surface image type, of which domain is restricted to triangles.
typedef mln::image_if<bin_ima_t, is_a_triangle_t> bin_triangle_only_ima_t;
// Surface image type, of which iteration (not domain) is restricted
@@ -272,14 +267,6 @@ main(int argc, char* argv[])
// Simple point predicate. //
// ------------------------ //
- // Neighborhood type returning the set of (n-1)-faces adjacent to a
- // an n-face.
- typedef mln::complex_lower_neighborhood<D, G> lower_adj_nbh_t;
- lower_adj_nbh_t lower_adj_nbh;
- // Neighborhood type returning the set of (n+1)-faces adjacent to a
- // an n-face.
- typedef mln::complex_higher_neighborhood<D, G> higher_adj_nbh_t;
- higher_adj_nbh_t higher_adj_nbh;
// Predicate type: is a triangle (2-face) simple?
typedef mln::topo::is_simple_pair< bin_triangle_ima_t,
lower_adj_nbh_t,
--
1.5.6.5
1
0

last-svn-commit-245-gb84bea1 Miscellaneous changes in mesh-related operations.
by Roland Levillain 12 Apr '11
by Roland Levillain 12 Apr '11
12 Apr '11
* mln/topo/is_simple_cell.hh: Add static preconditions.
Reduce the number of pointer manipulations.
Aesthetic changes.
* mln/topo/detach_cell.hh: Move a static precondition.
Aesthetic changes.
* mln/io/vtk/save.hh: Cosmetic changes.
---
milena/ChangeLog | 11 +++++++++++
milena/mln/io/vtk/save.hh | 8 ++++++--
milena/mln/topo/detach_cell.hh | 22 ++++++++++++----------
milena/mln/topo/is_simple_cell.hh | 24 ++++++++++++++----------
4 files changed, 43 insertions(+), 22 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index aa71fb7..63b6054 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,16 @@
2011-03-14 Roland Levillain <roland(a)lrde.epita.fr>
+ Miscellaneous changes in mesh-related operations.
+
+ * mln/topo/is_simple_cell.hh: Add static preconditions.
+ Reduce the number of pointer manipulations.
+ Aesthetic changes.
+ * mln/topo/detach_cell.hh: Move a static precondition.
+ Aesthetic changes.
+ * mln/io/vtk/save.hh: Cosmetic changes.
+
+2011-03-14 Roland Levillain <roland(a)lrde.epita.fr>
+
New apps: max curvature-based thinnings using 2- and 1-collapses.
* apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc,
diff --git a/milena/mln/io/vtk/save.hh b/milena/mln/io/vtk/save.hh
index fbe5a85..142608a 100644
--- a/milena/mln/io/vtk/save.hh
+++ b/milena/mln/io/vtk/save.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2010, 2011 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -269,7 +269,7 @@ namespace mln
/* ``1. The first part is the file version and
identifier. This part contains the single line:
- # vtk DataFile Version x.x.
+ # vtk DataFile Version x.x.
This line must be exactly as shown with the
exception of the version number x.x, which will vary
@@ -492,6 +492,10 @@ namespace mln
ostr << std::endl;
}
+ // -------------------- //
+ // Dataset attributes. //
+ // -------------------- //
+
/* ``5. The final part describes the dataset attributes.
This part begins with the keywords POINT_DATA or
CELL_DATA,followed by an integer number specifying
diff --git a/milena/mln/topo/detach_cell.hh b/milena/mln/topo/detach_cell.hh
index 761142e..0bf442c 100644
--- a/milena/mln/topo/detach_cell.hh
+++ b/milena/mln/topo/detach_cell.hh
@@ -30,10 +30,15 @@
/// \file
/// \brief Detaching a cell from a binary (probably complex-based) image.
+# include <mln/core/concept/function.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
+
# include <mln/core/site_set/p_set.hh>
-# include <mln/core/image/complex_image.hh>
+
# include <mln/make/detachment.hh>
+
namespace mln
{
@@ -66,7 +71,7 @@ namespace mln
\pre \a ima is an image of Boolean values.
\param ima The input image from which the cell is to be
- detached.
+ detached.
\param nbh An adjacency relationship between faces
(should return the set of (n-1)- and (n+1)-faces
adjacent to an n-face). */
@@ -80,14 +85,10 @@ namespace mln
\pre \a ima is an image of Boolean values. */
void set_image(mln::Image<I>& ima);
- /** Detach the cell corresponding to \a f from \a ima.
+ /** Detach the cell corresponding to \a f from \a ima_.
- \param f The psite corresponding to the cell to detach.
- \param nbh An adjacency relationship between faces
- (should return the set of (n-1)- and (n+1)-faces
- adjacent to an n-face). */
- void
- operator()(const mln_psite(I)& f);
+ \param f The psite corresponding to the cell to detach. */
+ void operator()(const mln_psite(I)& f);
private:
I* ima_;
@@ -95,6 +96,7 @@ namespace mln
};
+
# ifndef MLN_INCLUDE_ONLY
template <typename I, typename N>
@@ -102,6 +104,7 @@ namespace mln
detach_cell<I, N>::detach_cell(const Neighborhood<N>& nbh)
: ima_(0), nbh_(exact(nbh))
{
+ mlc_equal(mln_value(I), bool)::check();
}
template <typename I, typename N>
@@ -118,7 +121,6 @@ namespace mln
void
detach_cell<I, N>::set_image(mln::Image<I>& ima)
{
- mlc_equal(mln_value(I), bool)::check();
ima_ = exact(&ima);
}
diff --git a/milena/mln/topo/is_simple_cell.hh b/milena/mln/topo/is_simple_cell.hh
index 8796c16..9f1491a 100644
--- a/milena/mln/topo/is_simple_cell.hh
+++ b/milena/mln/topo/is_simple_cell.hh
@@ -34,15 +34,15 @@
# include <mln/core/concept/image.hh>
# include <mln/core/site_set/p_set.hh>
-# include <mln/core/site_set/complex_psite.hh>
-# include <mln/core/site_set/p_complex_piter.hh>
-# include <mln/core/image/complex_neighborhoods.hh>
-# include <mln/core/image/complex_neighborhood_piter.hh>
# include <mln/topo/is_facet.hh>
# include <mln/make/attachment.hh>
+// FIXME: Have the functor take N, NL and NH neighborhood objects at
+// the construction (instead of building them in operator()), as in
+// does is_simple_pair.
+
namespace mln
{
@@ -69,7 +69,8 @@ namespace mln
\tparam NH The neighborhood type returning the set of
(n+1)-faces adjacent to a an n-face. */
template <typename I, typename N, typename NL, typename NH>
- class is_simple_cell : public mln::Function_v2b< is_simple_cell<I, N, NL, NH> >
+ class is_simple_cell
+ : public mln::Function_v2b< is_simple_cell<I, N, NL, NH> >
{
public:
/// Result type of the functor.
@@ -108,6 +109,7 @@ namespace mln
is_simple_cell<I, N, NL, NH>::is_simple_cell()
: ima_(0)
{
+ mlc_equal(mln_value(I), bool)::check();
}
template <typename I, typename N, typename NL, typename NH>
@@ -115,6 +117,7 @@ namespace mln
is_simple_cell<I, N, NL, NH>::is_simple_cell(const mln::Image<I>& ima)
: ima_(exact(&ima))
{
+ mlc_equal(mln_value(I), bool)::check();
}
template <typename I, typename N, typename NL, typename NH>
@@ -131,23 +134,24 @@ namespace mln
is_simple_cell<I, N, NL, NH>::operator()(const mln_psite(I)& p) const
{
mln_precondition(ima_);
- // FIXME: Introduce `const I& ima = *ima_;' and use it instead of
- // `ima_'. Or introduce an `ima()' accessor?
+ // Shortcut.
+ // FIXME: Introduce an `ima()' accessor instead?
+ const I& ima = *ima_;
// The cell corresponding to P cannot be simple unless P is
// facet.
{
NH higher_adj_nbh;
- if (!is_facet(*ima_, p, higher_adj_nbh))
+ if (!is_facet(ima, p, higher_adj_nbh))
return false;
}
typedef p_set<mln_psite(I)> faces_t;
// Compute the attachment of the cell corresponding to P to the
- // domain of *IMA_.
+ // domain of IMA.
N adj_nbh;
- faces_t att = make::attachment(*ima_, p, adj_nbh);
+ faces_t att = make::attachment(ima, p, adj_nbh);
// A cell with an empty attachment is not simple.
/* FIXME: Why p_set does not provide an empty() predicate? */
--
1.5.6.5
1
0

last-svn-commit-244-gf9882da New apps: max curvature-based thinnings using 2- and 1-collapses.
by Roland Levillain 12 Apr '11
by Roland Levillain 12 Apr '11
12 Apr '11
* apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc,
* apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc:
New.
* apps/mesh-segm-skel/test-mesh-complex-max-curv-2-collapse.in,
* apps/mesh-segm-skel/test-mesh-complex-max-curv-1-collapse.in:
New.
* apps/mesh-segm-skel/Makefile.am (bin_PROGRAMS):
Add mesh-complex-max-curv-2-collapse.
And mesh-complex-max-curv-1-collapse
(mesh_complex_max_curve_2_collapse_SOURCES)
(mesh_complex_max_curve_1_collapse_SOURCES):
New.
(edit): New.
(test-mesh-complex-max-curv-2-collapse)
(test-mesh-complex-max-curv-1-collapse):
New target.
(TESTS, CLEANFILES): Add test-mesh-complex-max-curv-2-collapse
and test-mesh-complex-max-curv-1-collapse.
(MOSTLYCLEANFILES): Add teapot-max-curv-2-collapse.vtk,
bunny-holefilled-max-curv-2-collapse.vtk,
teapot-max-curv-1-collapse.vtk and
bunny-holefilled-max-curv-1-collapse.vtk.
---
milena/ChangeLog | 27 ++++
milena/apps/mesh-segm-skel/Makefile.am | 40 +++++
...skel.cc => mesh-complex-max-curv-1-collapse.cc} | 153 +++++++++++++-------
...skel.cc => mesh-complex-max-curv-2-collapse.cc} | 95 ++++++-------
...in => test-mesh-complex-max-curv-1-collapse.in} | 3 +-
...in => test-mesh-complex-max-curv-2-collapse.in} | 3 +-
6 files changed, 220 insertions(+), 101 deletions(-)
copy milena/apps/mesh-segm-skel/{mesh-complex-max-curv-skel.cc => mesh-complex-max-curv-1-collapse.cc} (68%)
copy milena/apps/mesh-segm-skel/{mesh-complex-max-curv-skel.cc => mesh-complex-max-curv-2-collapse.cc} (81%)
copy milena/apps/mesh-segm-skel/{test-mesh-complex-2-collapse.in => test-mesh-complex-max-curv-1-collapse.in} (77%)
copy milena/apps/mesh-segm-skel/{test-mesh-complex-2-collapse.in => test-mesh-complex-max-curv-2-collapse.in} (77%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 0f526db..aa71fb7 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,32 @@
2011-03-14 Roland Levillain <roland(a)lrde.epita.fr>
+ New apps: max curvature-based thinnings using 2- and 1-collapses.
+
+ * apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc,
+ * apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc:
+ New.
+ * apps/mesh-segm-skel/test-mesh-complex-max-curv-2-collapse.in,
+ * apps/mesh-segm-skel/test-mesh-complex-max-curv-1-collapse.in:
+ New.
+ * apps/mesh-segm-skel/Makefile.am (bin_PROGRAMS):
+ Add mesh-complex-max-curv-2-collapse.
+ And mesh-complex-max-curv-1-collapse
+ (mesh_complex_max_curve_2_collapse_SOURCES)
+ (mesh_complex_max_curve_1_collapse_SOURCES):
+ New.
+ (edit): New.
+ (test-mesh-complex-max-curv-2-collapse)
+ (test-mesh-complex-max-curv-1-collapse):
+ New target.
+ (TESTS, CLEANFILES): Add test-mesh-complex-max-curv-2-collapse
+ and test-mesh-complex-max-curv-1-collapse.
+ (MOSTLYCLEANFILES): Add teapot-max-curv-2-collapse.vtk,
+ bunny-holefilled-max-curv-2-collapse.vtk,
+ teapot-max-curv-1-collapse.vtk and
+ bunny-holefilled-max-curv-1-collapse.vtk.
+
+2011-03-14 Roland Levillain <roland(a)lrde.epita.fr>
+
Add VTK versions of some OFF meshes.
* mesh/bunny-holefilled.vtk,
diff --git a/milena/apps/mesh-segm-skel/Makefile.am b/milena/apps/mesh-segm-skel/Makefile.am
index 1b4d20f..4e06baf 100644
--- a/milena/apps/mesh-segm-skel/Makefile.am
+++ b/milena/apps/mesh-segm-skel/Makefile.am
@@ -209,6 +209,46 @@ TESTS += test-mesh-complex-2-collapse
CLEANFILES = test-mesh-complex-2-collapse
MOSTLYCLEANFILES += pseudo-manifold-2-collapse.vtk
+# Program computing the max curvature from a mesh, then performing a
+# 2-collapse on it.
+bin_PROGRAMS += mesh-complex-max-curv-2-collapse
+mesh_complex_max_curv_2_collapse_SOURCES = mesh-complex-max-curv-2-collapse.cc
+
+# FIXME: Factor action with test-mesh-complex-2-collapse's.
+test-mesh-complex-max-curv-2-collapse: test-mesh-complex-max-curv-2-collapse.in Makefile
+ rm -f $@ $@.tmp
+ srcdir=''; \
+ test -f ./$< || srcdir=$(srcdir)/; \
+ $(edit) $${srcdir}$< >>$@.tmp
+ chmod a-w,a+x $@.tmp
+ mv $@.tmp $@
+
+TESTS += test-mesh-complex-max-curv-2-collapse
+CLEANFILES += test-mesh-complex-max-curv-2-collapse
+MOSTLYCLEANFILES += \
+ teapot-max-curv-2-collapse.vtk \
+ bunny-holefilled-max-curv-2-collapse.vtk
+
+# Program computing the max curvature from a mesh, then performing a
+# 1-collapse on it.
+bin_PROGRAMS += mesh-complex-max-curv-1-collapse
+mesh_complex_max_curv_1_collapse_SOURCES = mesh-complex-max-curv-1-collapse.cc
+
+# FIXME: Factor action with test-mesh-complex-1-collapse's.
+test-mesh-complex-max-curv-1-collapse: test-mesh-complex-max-curv-1-collapse.in Makefile
+ rm -f $@ $@.tmp
+ srcdir=''; \
+ test -f ./$< || srcdir=$(srcdir)/; \
+ $(edit) $${srcdir}$< >>$@.tmp
+ chmod a-w,a+x $@.tmp
+ mv $@.tmp $@
+
+TESTS += test-mesh-complex-max-curv-1-collapse
+CLEANFILES += test-mesh-complex-max-curv-1-collapse
+MOSTLYCLEANFILES += \
+ teapot-max-curv-1-collapse.vtk \
+ bunny-holefilled-max-curv-1-collapse.vtk
+
## More complex skeletonization chains.
## ------------------------------------
diff --git a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc
similarity index 68%
copy from milena/apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc
copy to milena/apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc
index 2d55ff2..0cb29dd 100644
--- a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc
+++ b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-1-collapse.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2010, 2011 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of the Milena Library. This library is free
@@ -26,13 +26,13 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc
+/// \file
/// \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.
+/// surface of the (triangle) mesh of a statue, then performing a
+/// 1-collapse of this surface, using a complex-based image.
-// FIXME: Factor with mesh-complex-pinv-curv-skel.cc.
+// FIXME: Factor with mesh-complex-max-curv-skel.cc and
+// mesh-complex-pinv-curv-skel.cc, mesh-complex-max-curv-2-collapse.cc.
#include <iostream>
@@ -40,6 +40,7 @@
#include <mln/core/image/complex_neighborhoods.hh>
#include <mln/core/image/dmorph/image_if.hh>
+#include <mln/core/image/dmorph/sub_image.hh>
#include <mln/core/image/dmorph/mutable_extension_ima.hh>
#include <mln/core/routine/mutable_extend.hh>
#include <mln/data/paste.hh>
@@ -50,14 +51,12 @@
#include <mln/morpho/closing/area.hh>
#include <mln/topo/is_n_face.hh>
-#include <mln/topo/is_simple_cell.hh>
-#include <mln/topo/detach_cell.hh>
+#include <mln/topo/is_simple_pair.hh>
+#include <mln/topo/detach_pair.hh>
#include <mln/topo/skeleton/breadth_first_thinning.hh>
-#include <mln/io/off/load.hh>
-/* FIXME: Remove as soon as mln::io::off::save is able to save a
- morphed mln::complex_image (i.e., seen through image_if). */
-#include "save_bin_alt.hh"
+#include <mln/io/vtk/load.hh>
+#include <mln/io/vtk/save.hh>
#include "trimesh/misc.hh"
@@ -67,7 +66,7 @@ main(int argc, char* argv[])
{
if (argc != 4)
{
- std::cerr << "usage: " << argv[0] << " input.off lambda output.off"
+ std::cerr << "usage: " << argv[0] << " input.vtk lambda output.vtk"
<< std::endl;
std::exit(1);
}
@@ -88,11 +87,11 @@ main(int argc, char* argv[])
typedef mln_geom_(float_ima_t) G;
mln::bin_2complex_image3df bin_input;
- mln::io::off::load(bin_input, input_filename);
+ mln::io::vtk::load(bin_input, input_filename);
std::pair<float_ima_t, float_ima_t> curv =
mln::geom::mesh_curvature(bin_input.domain());
- // Compute the pseudo_inverse curvature at each vertex.
+ // Compute the max curvature at each vertex.
float_ima_t float_ima(bin_input.domain());
mln::p_n_faces_fwd_piter<D, G> v(float_ima.domain(), 0);
for_all(v)
@@ -103,7 +102,7 @@ main(int argc, char* argv[])
}
// Values on triangles.
- mln::p_n_faces_fwd_piter<D, G> t(float_ima.domain(), 2);
+ mln::p_n_faces_fwd_piter<D, G> t(float_ima.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;
@@ -249,15 +248,15 @@ main(int argc, char* argv[])
mln_piter_(bin_ima_t) f(minima.domain());
for_all(f)
if (minima(f) != mln::literal::zero)
- surface(f) = false;
+ surface(f) = false;
- /*-----------.
- | Skeleton. |
- `-----------*/
+ /*-------------.
+ | 2-collapse. |
+ `-------------*/
- // ---------------- //
- // Skeleton image. //
- // ---------------- //
+ // ------------------------------- //
+ // Image restricted to triangles. //
+ // ------------------------------- //
// Predicate type: is a face a triangle (2-face)?
typedef mln::topo::is_n_face<mln_psite_(bin_ima_t), D> is_a_triangle_t;
@@ -273,58 +272,114 @@ main(int argc, char* argv[])
// Simple point predicate. //
// ------------------------ //
- // Neighborhood type returning the set of (n-1)- and (n+1)-faces
- // adjacent to a an n-face.
- typedef mln::complex_lower_higher_neighborhood<D, G> adj_nbh_t;
// Neighborhood type returning the set of (n-1)-faces adjacent to a
// an n-face.
typedef mln::complex_lower_neighborhood<D, G> lower_adj_nbh_t;
+ lower_adj_nbh_t lower_adj_nbh;
// Neighborhood type returning the set of (n+1)-faces adjacent to a
// an n-face.
typedef mln::complex_higher_neighborhood<D, G> higher_adj_nbh_t;
+ higher_adj_nbh_t higher_adj_nbh;
// Predicate type: is a triangle (2-face) simple?
- typedef mln::topo::is_simple_cell< bin_triangle_ima_t,
- adj_nbh_t,
+ typedef mln::topo::is_simple_pair< bin_triangle_ima_t,
lower_adj_nbh_t,
higher_adj_nbh_t >
is_simple_triangle_t;
- is_simple_triangle_t is_simple_triangle;
+ is_simple_triangle_t is_simple_triangle(lower_adj_nbh, higher_adj_nbh);
// ------------------------------- //
// Simple point detach procedure. //
// ------------------------------- //
- // Type of adjacency relationships between faces of immediately
- // lower and higher dimensions.
- adj_nbh_t adj_nbh;
// Functor detaching a cell.
- mln::topo::detach_cell<bin_triangle_ima_t, adj_nbh_t> detach(adj_nbh);
+ typedef mln::topo::detach_pair< bin_triangle_ima_t,
+ lower_adj_nbh_t,
+ higher_adj_nbh_t > detach_triangle_t;
+ detach_triangle_t detach_triangle(lower_adj_nbh, higher_adj_nbh);
- mln_concrete_(bin_ima_t) skel;
- mln::initialize(skel, surface);
+ // ------------------------ //
+ // Thinning by 2-collapse. //
+ // ------------------------ //
+
+ mln_concrete_(bin_ima_t) surface_2_collapse;
+ mln::initialize(surface_2_collapse, surface);
mln::data::paste
(mln::topo::skeleton::breadth_first_thinning
(mln::mutable_extend((surface | is_a_triangle).rw(), surface),
nbh,
is_simple_triangle,
- detach),
- skel);
+ detach_triangle)
+ /* Before pasting the result of the computation into
+ SURFACE_2_COLLAPSE, re-expand its domain to the initial site
+ set, to ensure data from all faces (i.e., both the 2-faces,
+ directly processed; and the 1-faces from the extension,
+ undirectly processed). */
+ | surface.domain(),
+ surface_2_collapse);
+
+ /*-------------.
+ | 1-collapse. |
+ `-------------*/
+
+ // --------------------------- //
+ // Image restricted to edges. //
+ // --------------------------- //
+
+ // Predicate type: is a face an edge (1-face)?
+ typedef mln::topo::is_n_face<mln_psite_(bin_ima_t), D - 1> is_an_edge_t;
+ is_an_edge_t is_an_edge;
+ // Surface image type, of which domain is restricted to edges.
+ typedef mln::image_if<bin_ima_t, is_an_edge_t> bin_edge_only_ima_t;
+ // Surface image type, of which iteration (not domain) is restricted
+ // to edges.
+ typedef mln::mutable_extension_ima<bin_edge_only_ima_t, bin_ima_t>
+ bin_edge_ima_t;
+
+ // ------------------------ //
+ // Simple point predicate. //
+ // ------------------------ //
+
+ // Predicate type: is a edge (1-face) simple?
+ typedef mln::topo::is_simple_pair< bin_edge_ima_t,
+ lower_adj_nbh_t,
+ higher_adj_nbh_t >
+ is_simple_edge_t;
+ is_simple_edge_t is_simple_edge(lower_adj_nbh, higher_adj_nbh);
+ // ------------------------------- //
+ // Simple point detach procedure. //
+ // ------------------------------- //
+
+ // Functor detaching a cell.
+ typedef mln::topo::detach_pair< bin_edge_ima_t,
+ lower_adj_nbh_t,
+ higher_adj_nbh_t > detach_edge_t;
+ detach_edge_t detach_edge(lower_adj_nbh, higher_adj_nbh);
+
+ // ------------------------ //
+ // Thinning by 1-collapse. //
+ // ------------------------ //
+
+ mln_concrete_(bin_ima_t) surface_1_collapse;
+ mln::initialize(surface_1_collapse, surface_2_collapse);
+ mln::data::paste
+ (mln::topo::skeleton::breadth_first_thinning
+ (mln::mutable_extend((surface_2_collapse | is_an_edge).rw(),
+ surface_2_collapse),
+ nbh,
+ is_simple_edge,
+ detach_edge)
+ /* Likewise, before pasting the result of the computation into
+ SURFACE_1_COLLAPSE, re-expand its domain to the initial site
+ set, to ensure data from all faces (i.e., both the 1-faces,
+ directly processed; and the 0-faces from the extension,
+ undirectly processed). */
+ | surface_2_collapse.domain(),
+ surface_1_collapse);
/*---------.
| Output. |
`---------*/
- /* FIXME: This does not work (yet).
- Use workaround mln::io::off::save_bin_alt instead (bad!)
-
- Moreover, even if it worked, it would not have the same meaning
- as mln::io::off::save_bin_alt. Maybe the latter is useful, after
- all. But we need to factor it with the code of
- mln::io::off::save, anyway. */
-#if 0
- mln::io::off::save(skel | mln::pw::value(skel) == mln::pw::cst(true),
- output_filename);
-#endif
- mln::io::off::save_bin_alt(skel, output_filename);
+ mln::io::vtk::save(surface_1_collapse, output_filename);
}
diff --git a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc
similarity index 81%
copy from milena/apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc
copy to milena/apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc
index 2d55ff2..233756d 100644
--- a/milena/apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc
+++ b/milena/apps/mesh-segm-skel/mesh-complex-max-curv-2-collapse.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
+// Copyright (C) 2008, 2009, 2010, 2011 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of the Milena Library. This library is free
@@ -26,13 +26,13 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file apps/mesh-segm-skel/mesh-complex-max-curv-skel.cc
+/// \file
/// \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.
+/// surface of the (triangle) mesh of a statue, then performing a
+/// 2-collapse of this surface, using a complex-based image.
-// FIXME: Factor with mesh-complex-pinv-curv-skel.cc.
+// FIXME: Factor with mesh-complex-max-curv-skel.cc and
+// mesh-complex-pinv-curv-skel.cc, mesh-complex-max-curv-1-collapse.cc
#include <iostream>
@@ -40,6 +40,7 @@
#include <mln/core/image/complex_neighborhoods.hh>
#include <mln/core/image/dmorph/image_if.hh>
+#include <mln/core/image/dmorph/sub_image.hh>
#include <mln/core/image/dmorph/mutable_extension_ima.hh>
#include <mln/core/routine/mutable_extend.hh>
#include <mln/data/paste.hh>
@@ -50,14 +51,12 @@
#include <mln/morpho/closing/area.hh>
#include <mln/topo/is_n_face.hh>
-#include <mln/topo/is_simple_cell.hh>
-#include <mln/topo/detach_cell.hh>
+#include <mln/topo/is_simple_pair.hh>
+#include <mln/topo/detach_pair.hh>
#include <mln/topo/skeleton/breadth_first_thinning.hh>
-#include <mln/io/off/load.hh>
-/* FIXME: Remove as soon as mln::io::off::save is able to save a
- morphed mln::complex_image (i.e., seen through image_if). */
-#include "save_bin_alt.hh"
+#include <mln/io/vtk/load.hh>
+#include <mln/io/vtk/save.hh>
#include "trimesh/misc.hh"
@@ -67,7 +66,7 @@ main(int argc, char* argv[])
{
if (argc != 4)
{
- std::cerr << "usage: " << argv[0] << " input.off lambda output.off"
+ std::cerr << "usage: " << argv[0] << " input.vtk lambda output.vtk"
<< std::endl;
std::exit(1);
}
@@ -88,11 +87,11 @@ main(int argc, char* argv[])
typedef mln_geom_(float_ima_t) G;
mln::bin_2complex_image3df bin_input;
- mln::io::off::load(bin_input, input_filename);
+ mln::io::vtk::load(bin_input, input_filename);
std::pair<float_ima_t, float_ima_t> curv =
mln::geom::mesh_curvature(bin_input.domain());
- // Compute the pseudo_inverse curvature at each vertex.
+ // Compute the max curvature at each vertex.
float_ima_t float_ima(bin_input.domain());
mln::p_n_faces_fwd_piter<D, G> v(float_ima.domain(), 0);
for_all(v)
@@ -103,7 +102,7 @@ main(int argc, char* argv[])
}
// Values on triangles.
- mln::p_n_faces_fwd_piter<D, G> t(float_ima.domain(), 2);
+ mln::p_n_faces_fwd_piter<D, G> t(float_ima.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;
@@ -249,15 +248,15 @@ main(int argc, char* argv[])
mln_piter_(bin_ima_t) f(minima.domain());
for_all(f)
if (minima(f) != mln::literal::zero)
- surface(f) = false;
+ surface(f) = false;
- /*-----------.
- | Skeleton. |
- `-----------*/
+ /*-------------.
+ | 2-collapse. |
+ `-------------*/
- // ---------------- //
- // Skeleton image. //
- // ---------------- //
+ // ------------------------------- //
+ // Image restricted to triangles. //
+ // ------------------------------- //
// Predicate type: is a face a triangle (2-face)?
typedef mln::topo::is_n_face<mln_psite_(bin_ima_t), D> is_a_triangle_t;
@@ -273,58 +272,54 @@ main(int argc, char* argv[])
// Simple point predicate. //
// ------------------------ //
- // Neighborhood type returning the set of (n-1)- and (n+1)-faces
- // adjacent to a an n-face.
- typedef mln::complex_lower_higher_neighborhood<D, G> adj_nbh_t;
// Neighborhood type returning the set of (n-1)-faces adjacent to a
// an n-face.
typedef mln::complex_lower_neighborhood<D, G> lower_adj_nbh_t;
+ lower_adj_nbh_t lower_adj_nbh;
// Neighborhood type returning the set of (n+1)-faces adjacent to a
// an n-face.
typedef mln::complex_higher_neighborhood<D, G> higher_adj_nbh_t;
+ higher_adj_nbh_t higher_adj_nbh;
// Predicate type: is a triangle (2-face) simple?
- typedef mln::topo::is_simple_cell< bin_triangle_ima_t,
- adj_nbh_t,
+ typedef mln::topo::is_simple_pair< bin_triangle_ima_t,
lower_adj_nbh_t,
higher_adj_nbh_t >
is_simple_triangle_t;
- is_simple_triangle_t is_simple_triangle;
+ is_simple_triangle_t is_simple_triangle(lower_adj_nbh, higher_adj_nbh);
// ------------------------------- //
// Simple point detach procedure. //
// ------------------------------- //
- // Type of adjacency relationships between faces of immediately
- // lower and higher dimensions.
- adj_nbh_t adj_nbh;
// Functor detaching a cell.
- mln::topo::detach_cell<bin_triangle_ima_t, adj_nbh_t> detach(adj_nbh);
+ typedef mln::topo::detach_pair< bin_triangle_ima_t,
+ lower_adj_nbh_t,
+ higher_adj_nbh_t > detach_triangle_t;
+ detach_triangle_t detach_triangle(lower_adj_nbh, higher_adj_nbh);
+
+ // ------------------------ //
+ // Thinning by 2-collapse. //
+ // ------------------------ //
- mln_concrete_(bin_ima_t) skel;
- mln::initialize(skel, surface);
+ mln_concrete_(bin_ima_t) surface_2_collapse;
+ mln::initialize(surface_2_collapse, surface);
mln::data::paste
(mln::topo::skeleton::breadth_first_thinning
(mln::mutable_extend((surface | is_a_triangle).rw(), surface),
nbh,
is_simple_triangle,
- detach),
- skel);
-
+ detach_triangle)
+ /* Before pasting the result of the computation into
+ SURFACE_2_COLLAPSE, re-expand its domain to the initial site
+ set, to ensure data from all faces (i.e., both the 2-faces,
+ directly processed; and the 1-faces from the extension,
+ undirectly processed). */
+ | surface.domain(),
+ surface_2_collapse);
/*---------.
| Output. |
`---------*/
- /* FIXME: This does not work (yet).
- Use workaround mln::io::off::save_bin_alt instead (bad!)
-
- Moreover, even if it worked, it would not have the same meaning
- as mln::io::off::save_bin_alt. Maybe the latter is useful, after
- all. But we need to factor it with the code of
- mln::io::off::save, anyway. */
-#if 0
- mln::io::off::save(skel | mln::pw::value(skel) == mln::pw::cst(true),
- output_filename);
-#endif
- mln::io::off::save_bin_alt(skel, output_filename);
+ mln::io::vtk::save(surface_2_collapse, output_filename);
}
diff --git a/milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in b/milena/apps/mesh-segm-skel/test-mesh-complex-max-curv-1-collapse.in
similarity index 77%
copy from milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in
copy to milena/apps/mesh-segm-skel/test-mesh-complex-max-curv-1-collapse.in
index d2a286b..0bc967e 100644
--- a/milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in
+++ b/milena/apps/mesh-segm-skel/test-mesh-complex-max-curv-1-collapse.in
@@ -20,4 +20,5 @@ set -ex
mesh_dir=@top_srcdir@/milena/mesh
-time ./mesh-complex-2-collapse $mesh_dir/pseudo-manifold.vtk pseudo-manifold-2-collapse.vtk
+time ./mesh-complex-max-curv-1-collapse $mesh_dir/teapot.vtk 20 teapot-max-curv-1-collapse.vtk
+time ./mesh-complex-max-curv-1-collapse $mesh_dir/bunny-holefilled.vtk 50 bunny-holefilled-max-curv-1-collapse.vtk
diff --git a/milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in b/milena/apps/mesh-segm-skel/test-mesh-complex-max-curv-2-collapse.in
similarity index 77%
copy from milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in
copy to milena/apps/mesh-segm-skel/test-mesh-complex-max-curv-2-collapse.in
index d2a286b..4edf55f 100644
--- a/milena/apps/mesh-segm-skel/test-mesh-complex-2-collapse.in
+++ b/milena/apps/mesh-segm-skel/test-mesh-complex-max-curv-2-collapse.in
@@ -20,4 +20,5 @@ set -ex
mesh_dir=@top_srcdir@/milena/mesh
-time ./mesh-complex-2-collapse $mesh_dir/pseudo-manifold.vtk pseudo-manifold-2-collapse.vtk
+time ./mesh-complex-max-curv-2-collapse $mesh_dir/teapot.vtk 20 teapot-max-curv-2-collapse.vtk
+time ./mesh-complex-max-curv-2-collapse $mesh_dir/bunny-holefilled.vtk 50 bunny-holefilled-max-curv-2-collapse.vtk
--
1.5.6.5
1
0

last-svn-commit-242-g082d9ae New app: binary OFF to VTK mesh conversion.
by Roland Levillain 12 Apr '11
by Roland Levillain 12 Apr '11
12 Apr '11
* apps/mesh-segm-skel/off-to-vtk-bin.cc: New.
* apps/mesh-segm-skel/Makefile.am
(bin_PROGRAMS): Add off-to-vtk-bin.
(off_to_vtk_bin_SOURCES): New.
---
milena/ChangeLog | 9 +++
milena/apps/mesh-segm-skel/Makefile.am | 9 +++
.../mesh-segm-skel/off-to-vtk-bin.cc} | 52 ++++++++++----------
3 files changed, 44 insertions(+), 26 deletions(-)
copy milena/{sandbox/theo/tufa_2008/gradient.cc => apps/mesh-segm-skel/off-to-vtk-bin.cc} (62%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 010bf56..57fa1a1 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,14 @@
2011-03-14 Roland Levillain <roland(a)lrde.epita.fr>
+ New app: binary OFF to VTK mesh conversion.
+
+ * apps/mesh-segm-skel/off-to-vtk-bin.cc: New.
+ * apps/mesh-segm-skel/Makefile.am
+ (bin_PROGRAMS): Add off-to-vtk-bin.
+ (off_to_vtk_bin_SOURCES): New.
+
+2011-03-14 Roland Levillain <roland(a)lrde.epita.fr>
+
New app performing a 2-collapse on a mesh.
* apps/mesh-segm-skel/mesh-complex-2-collapse.cc: New.
diff --git a/milena/apps/mesh-segm-skel/Makefile.am b/milena/apps/mesh-segm-skel/Makefile.am
index d68ae7c..1b4d20f 100644
--- a/milena/apps/mesh-segm-skel/Makefile.am
+++ b/milena/apps/mesh-segm-skel/Makefile.am
@@ -236,3 +236,12 @@ TESTS += test-mesh-complex-pinv-curv-skel
MOSTLYCLEANFILES += \
socket-complex-pinv-curv-skel.off \
teapot-complex-pinv-curv-skel.off
+
+## ------------------------- ##
+## Conversion applications. ##
+## ------------------------- ##
+
+# Convert a binary OFF file (e.g. no value attached to faces) into a
+# VTK file.
+bin_PROGRAMS += off-to-vtk-bin
+off_to_vtk_bin_SOURCES = off-to-vtk-bin.cc
diff --git a/milena/sandbox/theo/tufa_2008/gradient.cc b/milena/apps/mesh-segm-skel/off-to-vtk-bin.cc
similarity index 62%
copy from milena/sandbox/theo/tufa_2008/gradient.cc
copy to milena/apps/mesh-segm-skel/off-to-vtk-bin.cc
index 31c308e..926da7d 100644
--- a/milena/sandbox/theo/tufa_2008/gradient.cc
+++ b/milena/apps/mesh-segm-skel/off-to-vtk-bin.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2011 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,36 +25,36 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file sandbox/geraud/tufa/gradient.cc
+/// \file
-#include <mln/core/image/image2d.hh>
-#include <mln/value/int_u8.hh>
-#include <mln/io/pgm/load.hh>
-#include <mln/io/pgm/save.hh>
-#include <mln/core/alias/neighb2d.hh>
+/// \brief A program converting a binary OFF file (e.g. no value
+/// attached to faces) into a VTK file.
-#include <mln/morpho/elementary/gradient.hh>
+#include <iostream>
+#include <mln/io/off/load.hh>
+#include <mln/io/vtk/save.hh>
-void usage(char* argv[])
+int
+main(int argc, char* argv[])
{
- std::cerr << "usage: " << argv[0] << " input.pgm output.pgm" << std::endl;
- std::cerr << "elementary gradient with c4" << std::endl;
- std::abort();
-}
-
-
-int main(int argc, char* argv[])
-{
- using namespace mln;
- using value::int_u8;
-
if (argc != 3)
- usage(argv);
-
- image2d<int_u8> f;
- io::pgm::load(f, argv[1]);
- io::pgm::save(morpho::elementary::gradient(f, c4()),
- argv[2]);
+ {
+ std::cerr << "usage: " << argv[0] << " input.off output.vtk"
+ << std::endl;
+ std::exit(1);
+ }
+
+ std::string input_filename = argv[1];
+ std::string output_filename = argv[2];
+
+ typedef mln::bin_2complex_image3df ima_t;
+ ima_t ima;
+
+ // FIXME: Converting bunny-holefilled.off to VTK took 30 sec, which
+ // is awfully slow. Time the load and save operations and find
+ // where is (are) the issue(s).
+ mln::io::off::load(ima, input_filename);
+ mln::io::vtk::save(ima, output_filename);
}
--
1.5.6.5
1
0