* tools/simple_point3d_lut_26_6.cc: New.
* tools/test_simple_point3d_lut_26_6.cc: New.
* tools/tools.mk (AM_CPPFLAGS): Add -I$(top_builddir)/milena.
* tools/Makefile.am (noinst_LTLIBRARIES): New.
Add libsimple_point3d_lut_26_6.la.
(libsimple_point3d_lut_26_6_la_SOURCES): New.
(EXTRA_PROGRAMS): Add test_simple_point3d_lut_26_6.
(test_simple_point3d_lut_26_6_SOURCES)
(test_simple_point3d_lut_26_6_LDADD):
New.
---
milena/ChangeLog | 15 ++
milena/tools/Makefile.am | 10 ++
.../simple_point3d_lut_26_6.cc} | 13 +--
milena/tools/test_simple_point3d_lut_26_6.cc | 136 ++++++++++++++++++++
milena/tools/tools.mk | 6 +-
5 files changed, 168 insertions(+), 12 deletions(-)
copy milena/{tests/value/int_u32.cc => tools/simple_point3d_lut_26_6.cc} (84%)
create mode 100644 milena/tools/test_simple_point3d_lut_26_6.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 1df7452..9c667b6 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,20 @@
2011-07-12 Roland Levillain <roland(a)lrde.epita.fr>
+ Check the consistency of tools/simple_point3d_lut_26_6.hh.
+
+ * tools/simple_point3d_lut_26_6.cc: New.
+ * tools/test_simple_point3d_lut_26_6.cc: New.
+ * tools/tools.mk (AM_CPPFLAGS): Add -I$(top_builddir)/milena.
+ * tools/Makefile.am (noinst_LTLIBRARIES): New.
+ Add libsimple_point3d_lut_26_6.la.
+ (libsimple_point3d_lut_26_6_la_SOURCES): New.
+ (EXTRA_PROGRAMS): Add test_simple_point3d_lut_26_6.
+ (test_simple_point3d_lut_26_6_SOURCES)
+ (test_simple_point3d_lut_26_6_LDADD):
+ New.
+
+2011-07-12 Roland Levillain <roland(a)lrde.epita.fr>
+
Fix and improve the (fast) computation of 2D connectivity numbers.
* mln/topo/is_simple_2d.hh (mln::connectivity_number_2d): Create
diff --git a/milena/tools/Makefile.am b/milena/tools/Makefile.am
index b93d92b..6caec62 100644
--- a/milena/tools/Makefile.am
+++ b/milena/tools/Makefile.am
@@ -73,3 +73,13 @@ simple_point3d_lut_26_6.hh: simple_point3d_lut_26_6.txt $(srcdir)/gen_cxx_lut
rm -f $@.tmp
$(srcdir)/gen_cxx_lut simple_point3d_lut_26_6 "(26, 6)" <$< >$@.tmp
mv $@.tmp $@
+
+# Very long (both to compile and execute) optional test, checking the
+# consistency of the LUT in simple_point3d_lut_26_6.hh. Moreover, it
+# should be turned into a parallel program.
+noinst_LTLIBRARIES = libsimple_point3d_lut_26_6.la
+libsimple_point3d_lut_26_6_la_SOURCES = \
+ simple_point3d_lut_26_6.hh simple_point3d_lut_26_6.cc
+EXTRA_PROGRAMS += test_simple_point3d_lut_26_6
+test_simple_point3d_lut_26_6_SOURCES = test_simple_point3d_lut_26_6.cc
+test_simple_point3d_lut_26_6_LDADD = libsimple_point3d_lut_26_6.la
diff --git a/milena/tests/value/int_u32.cc b/milena/tools/simple_point3d_lut_26_6.cc
similarity index 84%
copy from milena/tests/value/int_u32.cc
copy to milena/tools/simple_point3d_lut_26_6.cc
index 61eb6e5..8fb24c6 100644
--- a/milena/tests/value/int_u32.cc
+++ b/milena/tools/simple_point3d_lut_26_6.cc
@@ -24,14 +24,7 @@
// executable file might be covered by the GNU General Public License.
/// \file
-/// \brief Exercise mln::value::int_u32.
+/// \brief A C++ source file to produce a compiled version of
+/// tools/simple_point3d_lut_26_6.hh.
-#include <iostream>
-#include <mln/value/int_u32.hh>
-
-int main()
-{
- // FIXME: This traits return `-1'.
- std::cerr << mln::trait::value_<mln::value::int_u<32u> >::max()
- << std::endl;
-}
+#include <tools/simple_point3d_lut_26_6.hh>
diff --git a/milena/tools/test_simple_point3d_lut_26_6.cc b/milena/tools/test_simple_point3d_lut_26_6.cc
new file mode 100644
index 0000000..c3afb23
--- /dev/null
+++ b/milena/tools/test_simple_point3d_lut_26_6.cc
@@ -0,0 +1,136 @@
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#include <mln/core/image/image3d.hh>
+#include <mln/core/alias/neighb3d.hh>
+#include <mln/make/box3d.hh>
+
+#include "tools/connectivity_numbers_3d.hh"
+
+// To avoid heavy recompilation times due to the huge size of the
+// look-up table, only fetch the table's declaration. Its
+// implementation is compiled separately and linked to this program.
+#define MLN_INCLUDE_ONLY
+# include "tools/simple_point3d_lut_26_6.hh"
+#undef MLN_INCLUDE_ONLY
+
+
+int
+main()
+{
+ using namespace mln;
+
+ // FIXME: This part is very similar to
+ // milena/tests/topo/connectivity_numbers_2d.cc and
+ // milena/tools/connectivity_numbers_3d.hh. Factor.
+
+ typedef image3d<bool> I;
+ // B must be a model of mln::Box.
+ typedef mln_domain_(I) B;
+ typedef mln_psite_(I) P;
+
+ B b = make::box3d(-1,-1,-1, 1,1,1);
+ I fg_ima(b, 0);
+ I bg_ima(b, 0);
+ P p(0, 0, 0);
+
+ const unsigned dim = 3;
+ const unsigned max_nneighbs = mlc_pow_int(3, dim) - 1;
+ const unsigned nconfigs = mlc_pow_int(2, max_nneighbs);
+
+ typedef neighb3d N;
+ N nbh = c26();
+
+ int exit_status = EXIT_SUCCESS;
+
+ for (config_3d_t i = 0; i < nconfigs; ++i)
+ {
+ /* Create the local i-th configuration around P.
+
+ Note that the value corresponding to P is always `false', to
+ prevent the connection of two components through P. */
+ data::fill(fg_ima, false);
+ data::fill(bg_ima, false);
+ config_3d_t tmp = i;
+ mln_fwd_niter_(N) n(nbh, p);
+ for_all(n)
+ {
+ if (tmp % 2)
+ fg_ima(n) = true;
+ else
+ bg_ima(n) = true;
+ tmp = tmp >> 1;
+ }
+
+ // Compute the simple point criterion for (26, 6)-connectivity
+ conn_number_t conn_number_fg = connectivity_number_3d__26_6_one(fg_ima);
+ conn_number_t conn_number_bg = connectivity_number_3d__6_26_one(bg_ima);
+ bool conn_number_computed = conn_number_fg == 1 &&conn_number_bg == 1;
+
+
+ // Retrieve the simple point criterion for (26, 6)-connectivity
+ // number using the LUT.
+ conn_number_t conn_number_from_lut;
+ {
+ // ``Unpack'' the i-th value.
+
+ // FIXME: Redundant with some code from
+ // mln/topo/is_simple_point3d.hh.
+
+ size_t pos = i;
+
+ /* `simple_point3d_lut_26_6' is a packed bit array. We must
+ first retrieve the cell ``containing'' the index `pos'. */
+ size_t cell = pos / 8;
+ /* FIXME: We use hard-coded neighborhoods here instead of using
+ nbh_fg_ and nbh_bg_ (for this first test version). */
+ unsigned char pack = mln::topo::simple_point3d_lut_26_6[cell];
+
+ /* Compute the position of the neighborhood configuration within
+ the packed set of valued and create a mask corresponding to
+ this position (offset). */
+ size_t offset = pos % 8;
+ unsigned char mask = 1 << offset;
+
+ /* If the pack contains a 1 at position `offset', then `pack &
+ mask' is a non-null value. Otherwise it is zero. We can
+ therefore use it to create a boolean return value. */
+ bool result = pack & mask;
+ conn_number_from_lut = result;
+ }
+
+ // Compare them.
+ if (conn_number_computed != conn_number_from_lut)
+ {
+ std::cout
+ << "Inconsistency for the " << i << "-th configuration: "
+ << conn_number_computed << " != " << conn_number_from_lut
+ << std::endl;
+ exit_status = EXIT_FAILURE;
+ }
+ }
+
+ return exit_status;
+}
diff --git a/milena/tools/tools.mk b/milena/tools/tools.mk
index 9d9a046..878c687 100644
--- a/milena/tools/tools.mk
+++ b/milena/tools/tools.mk
@@ -1,4 +1,4 @@
-# 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.
#
@@ -17,8 +17,10 @@
## FIXME: Revamp (see Olena 0.11's test suite).
-# Look for Milena header in srcdir.
+# Look for Milena headers in srcdir.
AM_CPPFLAGS = -I$(top_srcdir)/milena
+# Look for Milena headers in builddir.
+AM_CPPFLAGS += -I$(top_builddir)/milena
# FIXME: Add
#
--
1.7.2.5
* mln/topo/is_simple_2d.hh (mln::connectivity_number_2d): Create
the configuration number by considering that the first (resp.
last) neighbors (in the forward browsing order) represent the
least (resp. most) significant bits of the configuration number,
as does the algorithm that computed the 8-c and 4-c LUTs (arrays
mln::connectivity_number_c8 and mln::connectivity_number_c4).
* mln/topo/connectivity_number_2d.hh: New.
* mln/topo/is_simple_point2d.hh: Fix dates in copyright header.
* tests/topo/connectivity_numbers_2d.cc: New.
* tests/topo/Makefile.am (check_PROGRAMS):
Add connectivity_numbers_2d.
(connectivity_numbers_2d_SOURCES): New.
---
milena/ChangeLog | 17 +++
milena/mln/topo/connectivity_number_2d.hh | 130 ++++++++++++++++++++
milena/mln/topo/is_simple_2d.hh | 17 ++-
milena/mln/topo/is_simple_point2d.hh | 2 +-
milena/tests/topo/Makefile.am | 5 +
.../topo/connectivity_numbers_2d.cc} | 94 +++++++-------
6 files changed, 212 insertions(+), 53 deletions(-)
create mode 100644 milena/mln/topo/connectivity_number_2d.hh
copy milena/{sandbox/lazzara/afp/micro_films/keep_background.cc => tests/topo/connectivity_numbers_2d.cc} (51%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 632bacd..1df7452 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,22 @@
2011-07-12 Roland Levillain <roland(a)lrde.epita.fr>
+ Fix and improve the (fast) computation of 2D connectivity numbers.
+
+ * mln/topo/is_simple_2d.hh (mln::connectivity_number_2d): Create
+ the configuration number by considering that the first (resp.
+ last) neighbors (in the forward browsing order) represent the
+ least (resp. most) significant bits of the configuration number,
+ as does the algorithm that computed the 8-c and 4-c LUTs (arrays
+ mln::connectivity_number_c8 and mln::connectivity_number_c4).
+ * mln/topo/connectivity_number_2d.hh: New.
+ * mln/topo/is_simple_point2d.hh: Fix dates in copyright header.
+ * tests/topo/connectivity_numbers_2d.cc: New.
+ * tests/topo/Makefile.am (check_PROGRAMS):
+ Add connectivity_numbers_2d.
+ (connectivity_numbers_2d_SOURCES): New.
+
+2011-07-12 Roland Levillain <roland(a)lrde.epita.fr>
+
Add more tests.
* tests/core/alias/dpoint2d.cc: Exercise the substraction of a
diff --git a/milena/mln/topo/connectivity_number_2d.hh b/milena/mln/topo/connectivity_number_2d.hh
new file mode 100644
index 0000000..221ca26
--- /dev/null
+++ b/milena/mln/topo/connectivity_number_2d.hh
@@ -0,0 +1,130 @@
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef MLN_TOPO_CONNECTIVITY_NUMBER_2D_HH
+# define MLN_TOPO_CONNECTIVITY_NUMBER_2D_HH
+
+/// \file
+/// \brief 2D connectivity numbers computation.
+
+# include <mln/core/concept/image.hh>
+
+# include <mln/core/alias/neighb2d.hh>
+
+# include <mln/value/int_u8.hh>
+
+// FIXME: This file includes the routine mln::connectivity_number_2d,
+// which should be moved into its own file.
+# include <mln/topo/is_simple_2d.hh>
+
+
+// FIXME: This implementation used the LUT-based (mask-based)
+// computation of 2D connectivity numbers, which may is fast but may
+// be inexact on the border of an image. We shoud rename these
+// routines with a `_fast' suffix.
+
+namespace mln
+{
+
+ namespace topo
+ {
+
+ /** Type of a connectivity number.
+
+ Note: The maximun number of connected components in the
+ neighborhood of a point is necessarily lower or equal to half
+ the number of neighbors. This number fits on an
+ mln::value::int_u8 when the dimension is lower or equal to
+ 5. */
+ typedef mln::value::int_u8 conn_number_t;
+
+
+ /** Compute the 2D connectivity number of \a p within \a ima
+ according to the 4-connectivity. If \a ref_val is set to \c
+ true, compute the number w.r.t. the foreground, otherwise
+ compute it w.r.t. the background.
+
+ \param ima The image on which the connectivity number is
+ computed.
+ \param p The site the connectivity number of which is
+ computed.
+ \param ref_val The reference value, telling whether the
+ foreground (true) or the background (false) is
+ considered. */
+ template<typename I>
+ conn_number_t
+ connectivity_number_2d_c4(const Image<I>& ima, const mln_psite(I)& p,
+ bool ref_val);
+
+ /** Compute the 2D connectivity number of \a p within \a ima
+ according to the 8-connectivity. If \a ref_val is set to \c
+ true, compute the number w.r.t. the foreground, otherwise
+ compute it w.r.t. the background.
+
+ \param ima The image on which the connectivity number is
+ computed.
+ \param p The site the connectivity number of which is
+ computed.
+ \param ref_val The reference value, telling whether the
+ foreground (true) or the background (false) is
+ considered. */
+ template<typename I>
+ conn_number_t
+ connectivity_number_2d_c8(const Image<I>& ima, const mln_psite(I)& p,
+ bool ref_val);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template<typename I>
+ conn_number_t
+ connectivity_number_2d_c4(const Image<I>& ima, const mln_psite(I)& p,
+ bool ref_val)
+ {
+ // Create a copy of mln::c4()'s own neighborhood to avoid
+ // thread-unsafe accesses to this neighborhood.
+ neighb2d nbh = c4();
+ return mln::connectivity_number_2d(ima, nbh, p, ref_val);
+ }
+
+ template<typename I>
+ conn_number_t
+ connectivity_number_2d_c8(const Image<I>& ima, const mln_psite(I)& p,
+ bool ref_val)
+ {
+ // Create a copy of mln::c8()'s own neighborhood to avoid
+ // thread-unsafe accesses to this neighborhood.
+ neighb2d nbh = c8();
+ return mln::connectivity_number_2d(ima, nbh, p, ref_val);
+ }
+
+# endif // MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::topo
+
+} // end of namespace mln
+
+#endif // ! MLN_TOPO_CONNECTIVITY_NUMBER_2D_HH
diff --git a/milena/mln/topo/is_simple_2d.hh b/milena/mln/topo/is_simple_2d.hh
index 18ffe78..f93bc7c 100644
--- a/milena/mln/topo/is_simple_2d.hh
+++ b/milena/mln/topo/is_simple_2d.hh
@@ -1,4 +1,4 @@
-// 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.
//
@@ -139,13 +139,18 @@ namespace mln
const N& nbh = exact(nbh_);
unsigned res = 0;
+ unsigned mask = 1;
mln_fwd_niter(neighb2d) n(c8(), p);
for_all(n)
- {
- res = (res << 1);
- if (ima.has(n) && ima(n) == b)
- res = res | 1;
- }
+ {
+ /* FIXME: The `ima.has(n)' predicate is not meaningful, as the
+ computation below is wrong as soon as `p' has a number of
+ neighbors other than 8. We should instead abort or warn if
+ for any `n' we don't have `ima.has(n)'. */
+ if (ima.has(n) && ima(n) == b)
+ res = res | mask;
+ mask = mask << 1;
+ }
unsigned number;
if (nbh == c4())
diff --git a/milena/mln/topo/is_simple_point2d.hh b/milena/mln/topo/is_simple_point2d.hh
index 219789e..8d0d7dd 100644
--- a/milena/mln/topo/is_simple_point2d.hh
+++ b/milena/mln/topo/is_simple_point2d.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
diff --git a/milena/tests/topo/Makefile.am b/milena/tests/topo/Makefile.am
index 608ac92..d9d2096 100644
--- a/milena/tests/topo/Makefile.am
+++ b/milena/tests/topo/Makefile.am
@@ -19,13 +19,18 @@ include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = skeleton
+## FIXME: Also add tests for is_simple_cell, detach_cell,
+## is_simple_point2d and detach_point.
+
check_PROGRAMS = \
complex \
+ connectivity_numbers_2d \
detach_pair \
is_facet \
is_simple_pair
complex_SOURCES = complex.cc
+connectivity_numbers_2d_SOURCES = connectivity_numbers_2d.cc
detach_pair_SOURCES = detach_pair.cc
is_facet_SOURCES = is_facet.cc
is_simple_pair_SOURCES = is_simple_pair.cc
diff --git a/milena/sandbox/lazzara/afp/micro_films/keep_background.cc b/milena/tests/topo/connectivity_numbers_2d.cc
similarity index 51%
copy from milena/sandbox/lazzara/afp/micro_films/keep_background.cc
copy to milena/tests/topo/connectivity_numbers_2d.cc
index 78373ad..599c02a 100644
--- a/milena/sandbox/lazzara/afp/micro_films/keep_background.cc
+++ b/milena/tests/topo/connectivity_numbers_2d.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,63 +23,65 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-
/// \file
-///
-/// Keep the background from a binary image.
+/// \brief Exercise the fast (LUT-based) computation of 2D
+/// connectivity numbers.
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
+#include <mln/make/box2d.hh>
-#include <mln/pw/all.hh>
-#include <mln/core/image/dmorph/image_if.hh>
+#include <mln/topo/connectivity_number_2d.hh>
#include <mln/data/fill.hh>
-#include <mln/io/pbm/all.hh>
-#include <mln/labeling/blobs.hh>
#include <mln/logical/not.hh>
-#include <mln/value/label_16.hh>
-
-#include <tools/usage.hh>
-
-
-const char *args_desc[][2] =
-{
- { "input.pbm", "A binary image. Objects are set to 'true'." },
- { 0, 0 }
-};
-
-
-int main(int argc, char *argv[])
+int
+main()
{
using namespace mln;
- if (argc != 3)
- return tools::usage(argv,
- "Extract the background from a binary image.",
- "input.pbm output.pbm",
- args_desc, "A binary image. Background is set to 'false'.");
-
- image2d<bool> input;
- io::pbm::load(input, argv[1]);
-
- logical::not_inplace(input);
-
- typedef value::label_16 V;
- V nlabels;
- image2d<V> lbl = labeling::blobs(input, c8(), nlabels);
-
- image2d<bool> output;
- initialize(output, input);
-
- V bg_lbl = lbl(literal::origin);
-
- data::fill(output, false);
- data::fill((output | (pw::value(lbl) == pw::cst(bg_lbl))).rw(), true);
-
- io::pbm::save(output, argv[2]);
+ // Exercise the computation of 2D connectivity numbers using the
+ // look-up table.
+ box2d b = make::box2d(-1, -1,
+ +1, +1);
+ image2d<bool> ima(b);
+ data::fill(ima, false);
+
+ point2d p(0, 0);
+ mln_niter_(neighb2d) n(c4(), p);
+ for_all(n)
+ ima(n) = true;
+ /* Test case 1.
+ ima =
+
+ - | -
+ | - |
+ - | -
+ */
+ mln_assertion(topo::connectivity_number_2d_c4(ima, p, true) == 4);
+ mln_assertion(topo::connectivity_number_2d_c8(ima, p, true) == 1);
+
+ logical::not_inplace(ima);
+ ima.at_ (0, 0) = false;
+ /* Test case 2.
+ ima =
+
+ | - |
+ - - -
+ | - |
+ */
+ mln_assertion(topo::connectivity_number_2d_c4(ima, p, true) == 0);
+ mln_assertion(topo::connectivity_number_2d_c8(ima, p, true) == 4);
+
+
+ /* FIXME: Also exercise the direct computation of connectivity
+ numbers, using the number of connected components around the
+ point in the foreground and the background.
+
+ Possibly move this part in another test, especially if the
+ corresponding routine is located in another file. */
+ // ...
}
-
--
1.7.2.5
* mln/io/fld/write_header.hh (mln::io::fld::write_header)
* mln/io/off/save.hh
(mln::io::off::internal::off_saver<I, E>::operator())
* mln/io/pnm/save_header.hh (mln::io::pnm::save_header)
* mln/io/vtk/save.hh
(mln::io::vtk::internal::vtk_saver<I, E>::operator()):
Here.
* mln/version.hh.in (OLN_PACKAGE_URL, OLN_PACKAGE_AUTHORS):
New macros.
---
milena/ChangeLog | 14 ++++++++++++++
milena/mln/io/fld/write_header.hh | 9 ++++++---
milena/mln/io/off/save.hh | 9 ++++++---
milena/mln/io/pnm/save_header.hh | 10 +++++++---
milena/mln/io/vtk/save.hh | 3 ++-
milena/mln/version.hh.in | 6 ++++++
6 files changed, 41 insertions(+), 10 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 5b3737b..cebc7f6 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,19 @@
2011-07-11 Roland Levillain <roland(a)lrde.epita.fr>
+ Use package metadata macros instead of hard-coded strings in I/Os.
+
+ * mln/io/fld/write_header.hh (mln::io::fld::write_header)
+ * mln/io/off/save.hh
+ (mln::io::off::internal::off_saver<I, E>::operator())
+ * mln/io/pnm/save_header.hh (mln::io::pnm::save_header)
+ * mln/io/vtk/save.hh
+ (mln::io::vtk::internal::vtk_saver<I, E>::operator()):
+ Here.
+ * mln/version.hh.in (OLN_PACKAGE_URL, OLN_PACKAGE_AUTHORS):
+ New macros.
+
+2011-07-11 Roland Levillain <roland(a)lrde.epita.fr>
+
No longer consider mln/version.hh.in as handled by autoheader.
* mln/version.hh.in (OLN_PACKAGE_BUGREPORT, OLN_PACKAGE_NAME)
diff --git a/milena/mln/io/fld/write_header.hh b/milena/mln/io/fld/write_header.hh
index c803528..d49ac13 100644
--- a/milena/mln/io/fld/write_header.hh
+++ b/milena/mln/io/fld/write_header.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.
@@ -34,8 +34,10 @@
# include <iostream>
+# include <mln/version.hh>
# include <mln/io/fld/header.hh>
+
namespace mln
{
@@ -58,8 +60,9 @@ namespace mln
write_header(std::ostream& file, const fld_header& h)
{
file << "# AVS field file" << std::endl;
- file << "# Generated by Milena 1.0 http://olena.lrde.epita.fr" << std::endl;
- file << "# EPITA Research and Development Laboratory (LRDE)" << std::endl;
+ file << "# Generated by " OLN_PACKAGE_STRING " (" OLN_PACKAGE_URL ")"
+ << std::endl
+ << "# " OLN_PACKAGE_AUTHORS << std::endl;
file << "ndim=" << h.ndim << std::endl;
for (int i = 0; i < h.ndim; i++)
diff --git a/milena/mln/io/off/save.hh b/milena/mln/io/off/save.hh
index 1ec747d..ba50d6b 100644
--- a/milena/mln/io/off/save.hh
+++ b/milena/mln/io/off/save.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.
//
@@ -40,6 +41,7 @@
# include <string>
+# include <mln/version.hh>
# include <mln/core/alias/complex_image.hh>
# include <mln/core/image/complex_neighborhoods.hh>
# include <mln/core/image/complex_neighborhood_piter.hh>
@@ -247,8 +249,9 @@ namespace mln
ostr << "OFF" << std::endl;
// A comment.
- ostr << "# Generated by Milena 1.0 http://olena.lrde.epita.fr\n"
- << "# EPITA Research and Development Laboratory (LRDE)"
+ ostr << "# Generated by " OLN_PACKAGE_STRING " (" OLN_PACKAGE_URL ")"
+ << std::endl
+ << "# " OLN_PACKAGE_AUTHORS
<< std::endl;
/* ``The next line states the number of vertices, the number
diff --git a/milena/mln/io/pnm/save_header.hh b/milena/mln/io/pnm/save_header.hh
index 17f3dfe..0f49596 100644
--- a/milena/mln/io/pnm/save_header.hh
+++ b/milena/mln/io/pnm/save_header.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+// 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -33,6 +34,8 @@
# include <iostream>
# include <fstream>
+# include <mln/version.hh>
+
# include <mln/io/pnm/max_component.hh>
# include <mln/value/rgb.hh>
@@ -76,11 +79,12 @@ namespace mln
abort();
}
file << "P" << type << std::endl;
- file << "# Generated by Milena 1.0 http://olena.lrde.epita.fr" << std::endl;
- file << "# EPITA Research and Development Laboratory (LRDE)" << std::endl;
// We have a two-line comment because xv is buggy for some
// tiny binary images and their workaround is to have such a
// two-line comment...
+ file << "# Generated by " OLN_PACKAGE_STRING " (" OLN_PACKAGE_URL ")"
+ << std::endl
+ << "# " OLN_PACKAGE_AUTHORS << std::endl;
file << geom::ncols(ima) << ' ' << geom::nrows(ima) << std::endl;
mln_value(I) i;
diff --git a/milena/mln/io/vtk/save.hh b/milena/mln/io/vtk/save.hh
index 142608a..e3b8893 100644
--- a/milena/mln/io/vtk/save.hh
+++ b/milena/mln/io/vtk/save.hh
@@ -41,6 +41,7 @@
# include <string>
+# include <mln/version.hh>
# include <mln/core/alias/complex_image.hh>
# include <mln/core/image/complex_neighborhoods.hh>
# include <mln/core/image/complex_neighborhood_piter.hh>
@@ -283,7 +284,7 @@ namespace mln
character `\n'. The header is 256 characters
maximum. The header can be used to describe the data
and include any other pertinent information.'' */
- ostr << "Generated by Milena 1.0 http://olena.lrde.epita.fr"
+ ostr << "Generated by " OLN_PACKAGE_STRING " (" OLN_PACKAGE_URL ")"
<< std::endl;
/* ``3. The next part is the file format. The file format
diff --git a/milena/mln/version.hh.in b/milena/mln/version.hh.in
index 1dd45dd..6612aa2 100644
--- a/milena/mln/version.hh.in
+++ b/milena/mln/version.hh.in
@@ -32,4 +32,10 @@
/// The version of this package.
#define OLN_PACKAGE_VERSION "@PACKAGE_VERSION@"
+/// Home page for this package.
+#define OLN_PACKAGE_URL "@PACKAGE_URL@"
+
+/// Authors of the package.
+#define OLN_PACKAGE_AUTHORS "EPITA Research and Development Laboratory (LRDE)"
+
#endif // ! MLN_VERSION_HH
--
1.7.2.5
* mln/version.hh.in (OLN_PACKAGE_BUGREPORT, OLN_PACKAGE_NAME)
(OLN_PACKAGE_STRING, OLN_PACKAGE_VERSION): Define these macros
using "@PACKAGE_BUGREPORT@", "@PACKAGE_NAME@", "@PACKAGE_STRING@"
and "@PACKAGE_VERSION@".
---
milena/ChangeLog | 9 +++++++++
milena/mln/version.hh.in | 13 ++++++++-----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 736d6cf..5b3737b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,12 @@
+2011-07-11 Roland Levillain <roland(a)lrde.epita.fr>
+
+ No longer consider mln/version.hh.in as handled by autoheader.
+
+ * mln/version.hh.in (OLN_PACKAGE_BUGREPORT, OLN_PACKAGE_NAME)
+ (OLN_PACKAGE_STRING, OLN_PACKAGE_VERSION): Define these macros
+ using "@PACKAGE_BUGREPORT@", "@PACKAGE_NAME@", "@PACKAGE_STRING@"
+ and "@PACKAGE_VERSION@".
+
2011-06-16 Roland Levillain <roland(a)lrde.epita.fr>
Set connectivity number functions when building is_simple_point3d.
diff --git a/milena/mln/version.hh.in b/milena/mln/version.hh.in
index ac1d712..1dd45dd 100644
--- a/milena/mln/version.hh.in
+++ b/milena/mln/version.hh.in
@@ -1,4 +1,4 @@
-// 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.
//
@@ -14,19 +14,22 @@
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+/// \file
+/// \brief Package metadata (name, version, etc.)
+
#ifndef MLN_VERSION_HH
# define MLN_VERSION_HH
/// The address where bug reports should be sent.
-#undef OLN_PACKAGE_BUGREPORT
+#define OLN_PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
/// The full name of this package.
-#undef OLN_PACKAGE_NAME
+#define OLN_PACKAGE_NAME "@PACKAGE_NAME@"
// The full name and version of this package.
-#undef OLN_PACKAGE_STRING
+#define OLN_PACKAGE_STRING "@PACKAGE_STRING@"
/// The version of this package.
-#undef OLN_PACKAGE_VERSION
+#define OLN_PACKAGE_VERSION "@PACKAGE_VERSION@"
#endif // ! MLN_VERSION_HH
--
1.7.2.5