https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add a test on p_vaccess.
* doc/tutorial/examples/p_vaccess.cc: Fix missing update.
* tests/core/site_set/p_vaccess.cc: New.
* tests/core/site_set/Makefile.am: Update.
* mln/convert/to.hh (include): New: from_to.hh
so that user of convert::to does not have to also include
convert::from_to.
* mln/convert/impl/from_image_to_site_set.hh
(from_image_to_site_set_): New overload for s containing
pairs like (v,p).
Upgrade doc style.
* mln/morpho/tree/compute_parent.hh
(zfind_root): Move from impl::generic to internal.
doc/tutorial/examples/p_vaccess.cc | 2
mln/convert/impl/from_image_to_site_set.hh | 29 ++++++++----
mln/convert/to.hh | 7 ++-
mln/morpho/tree/compute_parent.hh | 32 ++++++-------
tests/core/site_set/Makefile.am | 2
tests/core/site_set/p_vaccess.cc | 67 +++++++++++++++++++++++++++++
6 files changed, 110 insertions(+), 29 deletions(-)
Index: tests/core/site_set/Makefile.am
--- tests/core/site_set/Makefile.am (revision 2959)
+++ tests/core/site_set/Makefile.am (working copy)
@@ -13,6 +13,7 @@
p_queue_fast \
p_set \
pset_if \
+ p_vaccess \
p_vertices
p_array_SOURCES = p_array.cc
@@ -24,6 +25,7 @@
p_queue_fast_SOURCES = p_queue_fast.cc
p_set_SOURCES = p_set.cc
pset_if_SOURCES = pset_if.cc
+p_vaccess_SOURCES = p_vaccess.cc
p_vertices_SOURCES = p_vertices.cc
p_edges_SOURCES = p_edges.cc
Index: tests/core/site_set/p_vaccess.cc
--- tests/core/site_set/p_vaccess.cc (revision 0)
+++ tests/core/site_set/p_vaccess.cc (revision 0)
@@ -0,0 +1,67 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/core/site_set/p_vaccess.cc
+///
+/// Tests on mln::p_vaccess.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/site_set/p_array.hh>
+#include <mln/core/site_set/p_vaccess.hh>
+#include <mln/debug/println.hh>
+#include <mln/convert/to.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned char vals[] = { 1, 2, 1,
+ 2, 2, 3,
+ 3, 4, 1 };
+ image2d<unsigned char> ima = make::image2d(vals);
+
+ debug::println(ima);
+
+ typedef p_array<point2d> Arr;
+ typedef p_vaccess<unsigned char, Arr> S;
+
+ S s = convert::to<S>(ima);
+
+ mln_viter_(S::vset) v(s.values());
+ for_all(v)
+ {
+ if (s(v).nsites() == 0)
+ continue;
+ std::cout << int(v) << ": ";
+ mln_piter_(Arr) p(s(v));
+ for_all(p)
+ std::cout << p << ' ';
+ std::cout << std::endl;
+ }
+
+}
Index: doc/tutorial/examples/p_vaccess.cc
--- doc/tutorial/examples/p_vaccess.cc (revision 2959)
+++ doc/tutorial/examples/p_vaccess.cc (working copy)
@@ -40,7 +40,7 @@
{0, 1, 1, 0},
{1, 1, 0, 1}
};
- image2d<bool> ima = make::image2d(vals);
+ image2d<bool> ima = make::image(vals);
debug::println(ima);
unsigned n;
Index: mln/convert/to.hh
--- mln/convert/to.hh (revision 2959)
+++ mln/convert/to.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
@@ -81,4 +81,7 @@
} // end of namespace mln
+# include <mln/convert/from_to.hh>
+
+
#endif // ! MLN_CONVERT_TO_HH
Index: mln/convert/impl/from_image_to_site_set.hh
--- mln/convert/impl/from_image_to_site_set.hh (revision 2959)
+++ mln/convert/impl/from_image_to_site_set.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,14 +28,13 @@
#ifndef MLN_CONVERT_IMPL_FROM_IMAGE_TO_SITE_SET_HH
# define MLN_CONVERT_IMPL_FROM_IMAGE_TO_SITE_SET_HH
-/*! \file mln/convert/from_to.hh
- *
- * \brief General conversion procedure from an image to a site_set.
- *
- * \todo Augment code + add checks.
- *
- * \todo Add (?) the case p_run-based -> site set.
- */
+/// \file mln/convert/from_to.hh
+///
+/// General conversion procedure from an image to a site_set.
+///
+/// \todo Augment code + add checks.
+///
+/// \todo Add (?) the case p_run-based -> site set.
# include <utility>
# include <mln/core/concept/image.hh>
@@ -125,6 +124,18 @@
}
+ template <typename I, typename P, typename S>
+ void
+ from_image_to_site_set_(const I& input, const Gpoint<P>&,
+ S& s, const std::pair< mln_value(I), P >&)
+ {
+ s.clear();
+ mln_fwd_piter(I) p(input.domain());
+ for_all(p)
+ s.insert(input(p), p);
+ }
+
+
// Facade.
template <typename I, typename S>
Index: mln/morpho/tree/compute_parent.hh
--- mln/morpho/tree/compute_parent.hh (revision 2959)
+++ mln/morpho/tree/compute_parent.hh (working copy)
@@ -101,24 +101,12 @@
}
- } // end of namespace mln::morpho::tree::internal
-
-
-
- // Implementations.
-
-
- namespace impl
- {
-
- namespace generic
- {
-
// Z-Find-Root.
template <typename T>
inline
- mln_psite(T) zfind_root(T& zpar, const mln_psite(T)& x)
+ mln_psite(T)
+ zfind_root(T& zpar, const mln_psite(T)& x)
{
mlc_equal(mln_value(T), mln_psite(T))::check();
if (zpar(x) == x)
@@ -127,7 +115,18 @@
return zpar(x) = zfind_root(zpar, zpar(x));
}
- // Compute-Parent.
+ } // end of namespace mln::morpho::tree::internal
+
+
+
+ // Implementations.
+
+
+ namespace impl
+ {
+
+ namespace generic
+ {
template <typename I, typename N, typename S>
inline
@@ -172,7 +171,7 @@
if (f.domain().has(n) && deja_vu(n))
{
// Do-Union.
- P r = zfind_root(zpar, n);
+ P r = internal::zfind_root(zpar, n);
if (r != p)
{
parent(r) = p;
@@ -202,7 +201,6 @@
} // end of namespace mln::morpho::tree::impl
-
// Dispatch.
namespace internal