Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- 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
- 9625 discussions
18 Nov '08
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-11-18 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Convert the labeling canvas into a routine.
* mln/canvas/labeling.hh: .
* mln/labeling/level.hh: Update to use the routine.
---
canvas/labeling.hh | 226 ++++++++++++++++++++---------------------------------
labeling/level.hh | 8 -
2 files changed, 92 insertions(+), 142 deletions(-)
Index: branches/cleanup-2008/milena/mln/canvas/labeling.hh
===================================================================
--- branches/cleanup-2008/milena/mln/canvas/labeling.hh (revision 2891)
+++ branches/cleanup-2008/milena/mln/canvas/labeling.hh (revision 2892)
@@ -48,15 +48,34 @@
{
// General version.
+ template <typename I, typename N, typename F>
+ mln_ch_value(I, typename F::L)
+ labeling(const Image<I>& input, const Neighborhood<N>& nbh,
+ F& functor, typename F::L& nlabels);
- template <typename F>
- struct labeling
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I>
+ static inline
+ mln_psite(I)
+ find_root(I& parent,
+ const mln_psite(I)& x)
{
- // Functor.
- F& f;
+ if (parent(x) == x)
+ return x;
+ else
+ return parent(x) = find_root(parent, parent(x));
+ }
+
+ template <typename I, typename N, typename F>
+ mln_ch_value(I, typename F::L)
+ labeling(const Image<I>& input, const Neighborhood<N>& nbh,
+ F& functor, typename F::L& nlabels)
+ {
+ trace::entering("canvas::labeling");
- typedef typename F::I I;
- typedef typename F::N N;
typedef typename F::L L;
typedef typename F::S S;
@@ -69,31 +88,78 @@
// Output.
mln_ch_value(I, L) output;
- L nlabels;
bool status;
- // Ctor.
- labeling(F& f);
-
- void init();
-
- void pass_1();
-
- void pass_2();
-
-
- // Auxiliary methods.
+ // Initialization. init();
+ {
+ initialize(deja_vu, functor.input);
+ mln::level::fill(deja_vu, false);
+ initialize(parent, functor.input);
+ initialize(output, functor.input);
+ mln::level::fill(output, L(literal::zero));
+ nlabels = 0;
+ functor.init(); // Client initialization.
+ }
- void make_set(const psite& p);
+ // First Pass. pass_1();
+ {
+ mln_fwd_piter(S) p(functor.s);
+ mln_niter(N) n(functor.nbh, p);
+ for_all(p) if (functor.handles(p))
+ {
+ // Make the set with p as root. make_set(p).
+ parent(p) = p;
+ functor.init_attr(p);
- bool is_root(const psite& p) const;
+ for_all(n)
+ if (functor.input.domain().has(n) && deja_vu(n))
+ {
+ if (functor.equiv(n, p))
+ {
+ // Put p as root. do_union(n, p);
+ psite r = find_root(parent, n);
+ if (r != p)
+ {
+ parent(r) = p;
+ functor.merge_attr(r, p);
+ }
+ }
+ else
+ functor.do_no_union(n, p);
+ }
+ deja_vu(p) = true;
+ }
+ }
- psite find_root(const psite& x);
+ // Second Pass. pass_2();
+ {
+ mln_bkd_piter(S) p(functor.s);
+ for_all(p) if (functor.handles(p))
+ {
+ if (parent(p) == p) // if p is root
+ {
+ if (functor.labels(p))
+ {
+ if (nlabels == mln_max(L))
+ {
+ status = false;
+ return output;
+ }
+ output(p) = ++nlabels;
+ }
+ }
+ else
+ output(p) = output(parent(p));
+ }
+ status = true;
- void do_union(const psite& n, const psite& p);
+ }
- };
+ trace::exiting("canvas::labeling");
+ return output;
+ }
+# endif // ! MLN_INCLUDE_ONLY
// Fastest version.
@@ -136,120 +202,6 @@
# ifndef MLN_INCLUDE_ONLY
- /*-------------------.
- | canvas::labeling. |
- `-------------------*/
-
- template <typename F>
- labeling<F>::labeling(F& f)
- : f(f)
- {
- trace::entering("canvas::labeling");
-
- init();
- f.init(); // Client initialization.
- pass_1();
- pass_2();
-
- trace::exiting("canvas::labeling");
- }
-
- template <typename F>
- void
- labeling<F>::init()
- {
- initialize(deja_vu, f.input);
- mln::level::fill(deja_vu, false);
- initialize(parent, f.input);
- initialize(output, f.input);
- mln::level::fill(output, L(literal::zero));
- nlabels = 0;
- }
-
- template <typename F>
- void
- labeling<F>::pass_1()
- {
- mln_fwd_piter(S) p(f.s);
- mln_niter(N) n(f.nbh, p);
- for_all(p) if (f.handles(p))
- {
- make_set(p);
- for_all(n)
- if (f.input.domain().has(n) && deja_vu(n))
- {
- if (f.equiv(n, p))
- do_union(n, p);
- else
- f.do_no_union(n, p);
- }
- deja_vu(p) = true;
- }
- }
-
- template <typename F>
- void
- labeling<F>::pass_2()
- {
- mln_bkd_piter(S) p(f.s);
- for_all(p) if (f.handles(p))
- {
- if (is_root(p))
- {
- if (f.labels(p))
- {
- if (nlabels == mln_max(L))
- {
- status = false;
- return;
- }
- output(p) = ++nlabels;
- }
- }
- else
- output(p) = output(parent(p));
- }
- status = true;
- }
-
- template <typename F>
- void
- labeling<F>::make_set(const psite& p)
- {
- parent(p) = p;
- f.init_attr(p);
- }
-
- template <typename F>
- bool
- labeling<F>::is_root(const psite& p) const
- {
- return parent(p) == p;
- }
-
- template <typename F>
- typename labeling<F>::psite
- labeling<F>::find_root(const psite& x)
- {
- if (parent(x) == x)
- return x;
- else
- return parent(x) = find_root(parent(x));
- }
-
- template <typename F>
- void
- labeling<F>::do_union(const psite& n, const psite& p)
- {
- psite r = find_root(n);
- if (r != p)
- {
- parent(r) = p;
- f.merge_attr(r, p);
- }
- }
-
-
/*---------------------------.
| canvas::labeling_fastest. |
`---------------------------*/
Index: branches/cleanup-2008/milena/mln/labeling/level.hh
===================================================================
--- branches/cleanup-2008/milena/mln/labeling/level.hh (revision 2891)
+++ branches/cleanup-2008/milena/mln/labeling/level.hh (revision 2892)
@@ -153,13 +153,11 @@
typedef level_functor<I,N,L> F;
F f(exact(input), val, exact(nbh));
- canvas::labeling<F> run(f);
-
- nlabels = run.nlabels;
- // FIXME: Handle run.status
+ mln_ch_value(I, L) output = canvas::labeling(input, nbh, f, nlabels);
+ // FIXME: Handle canvas status.
trace::exiting("labeling::impl::generic::level");
- return run.output;
+ return output;
}
} // end of namespace mln::labeling::impl::generic
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Cleanup tests make dual_neighb.
* tests/make/dual_neighb.cc: Upgrade doc style.
(count): Remove std cout echo.
(main): Augment commentary.
dual_neighb.cc | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
Index: tests/make/dual_neighb.cc
--- tests/make/dual_neighb.cc (revision 2890)
+++ tests/make/dual_neighb.cc (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
@@ -25,10 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/make/dual_neighb.cc
- *
- * \brief Tests on mln::make::dual_neighb.
- */
+/// \file tests/make/dual_neighb.cc
+///
+/// Tests on mln::make::dual_neighb.
#include <mln/make/dual_neighb.hh>
#include <mln/core/alias/neighb2d.hh>
@@ -44,7 +43,7 @@
unsigned c = 0;
for_all(p)
for_all(n)
- { std::cout << n << std::endl; ++c; }
+ ++c;
return c;
}
@@ -61,5 +60,8 @@
== c4().size() + c8().size() );
// We can observe that the neighboord is not restricted by the
- // respective domains defined by ima(p) == false and true.
+ // respective domains defined by ima(p) == false and ima(p) == true:
+ // for instance, at (0,0) we are in the *object* (ima(0,0) == true),
+ // thus the neighborhood is c4(), yet from p we browse neighbors n
+ // that are in the *background* (ima(n) == false).
}
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix warning in tests morpho elementary.
* tests/morpho/elementary/gradient.cc,
* tests/morpho/elementary/erosion.cc,
* tests/morpho/elementary/closing.cc,
* tests/morpho/elementary/top_hat.cc,
* tests/morpho/elementary/gradient_external.cc,
* tests/morpho/elementary/opening.cc,
* tests/morpho/elementary/dilation.cc,
* tests/morpho/elementary/gradient_internal.cc: Fix warning.
closing.cc | 2 +-
dilation.cc | 2 +-
erosion.cc | 2 +-
gradient.cc | 2 +-
gradient_external.cc | 2 +-
gradient_internal.cc | 2 +-
opening.cc | 2 +-
top_hat.cc | 2 +-
8 files changed, 8 insertions(+), 8 deletions(-)
Index: tests/morpho/elementary/gradient.cc
--- tests/morpho/elementary/gradient.cc (revision 2889)
+++ tests/morpho/elementary/gradient.cc (working copy)
@@ -62,7 +62,7 @@
}
image2d<bool> msk(3, 3, 0);
- level::fill(msk, pw::value(ima) >= pw::cst(5));
+ level::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
{
mln_VAR(gra,
Index: tests/morpho/elementary/erosion.cc
--- tests/morpho/elementary/erosion.cc (revision 2889)
+++ tests/morpho/elementary/erosion.cc (working copy)
@@ -57,7 +57,7 @@
}
image2d<bool> msk(3, 3, 0);
- level::fill(msk, pw::value(ima) >= pw::cst(5));
+ level::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
{
image2d<bool> ero = morpho::elementary::erosion(msk, c4());
Index: tests/morpho/elementary/closing.cc
--- tests/morpho/elementary/closing.cc (revision 2889)
+++ tests/morpho/elementary/closing.cc (working copy)
@@ -57,7 +57,7 @@
}
image2d<bool> msk(3, 3, 0);
- level::fill(msk, pw::value(ima) >= pw::cst(5));
+ level::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
{
image2d<bool> clo = morpho::elementary::closing(msk, c4());
Index: tests/morpho/elementary/top_hat.cc
--- tests/morpho/elementary/top_hat.cc (revision 2889)
+++ tests/morpho/elementary/top_hat.cc (working copy)
@@ -56,7 +56,7 @@
debug::println( morpho::elementary::top_hat_self_complementary(ima, c4()) );
image2d<bool> msk(3, 3, 0);
- level::fill(msk, pw::value(ima) >= pw::cst(5));
+ level::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
debug::println( morpho::elementary::top_hat_white(msk, c4()) );
Index: tests/morpho/elementary/gradient_external.cc
--- tests/morpho/elementary/gradient_external.cc (revision 2889)
+++ tests/morpho/elementary/gradient_external.cc (working copy)
@@ -62,7 +62,7 @@
}
image2d<bool> msk(3, 3, 0);
- level::fill(msk, pw::value(ima) >= pw::cst(5));
+ level::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
{
mln_VAR(gra,
Index: tests/morpho/elementary/opening.cc
--- tests/morpho/elementary/opening.cc (revision 2889)
+++ tests/morpho/elementary/opening.cc (working copy)
@@ -57,7 +57,7 @@
}
image2d<bool> msk(3, 3, 0);
- level::fill(msk, pw::value(ima) >= pw::cst(5));
+ level::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
{
image2d<bool> ope = morpho::elementary::opening(msk, c4());
Index: tests/morpho/elementary/dilation.cc
--- tests/morpho/elementary/dilation.cc (revision 2889)
+++ tests/morpho/elementary/dilation.cc (working copy)
@@ -57,7 +57,7 @@
}
image2d<bool> msk(3, 3, 0);
- level::fill(msk, pw::value(ima) >= pw::cst(5));
+ level::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
{
image2d<bool> dil = morpho::elementary::dilation(msk, c4());
Index: tests/morpho/elementary/gradient_internal.cc
--- tests/morpho/elementary/gradient_internal.cc (revision 2889)
+++ tests/morpho/elementary/gradient_internal.cc (working copy)
@@ -62,7 +62,7 @@
}
image2d<bool> msk(3, 3, 0);
- level::fill(msk, pw::value(ima) >= pw::cst(5));
+ level::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
{
mln_VAR(gra,
1
0
17 Nov '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Rename some graph-related files and classes.
* mln/util/internal/graph_edge.hh: Rename as...
* mln/util/edge.hh: ...this.
* mln/util/internal/graph_vertex.hh: Rename as...
* mln/util/vertex.hh: ...this.
* mln/util/all.hh: Update.
* mln/util/internal/graph_psite_base.hh: Rename as...
* mln/core/internal/graph_psite_base.hh: ...this.
* mln/util/internal/graph_vertex_psite.hh: Rename as...
* mln/core/site_set/p_vertices_psite.hh: ...this.
(internal::graph_vertex_psite): Rename as...
(p_vertices_psite): ...this.
* mln/util/internal/graph_edge_psite.hh: Rename as...
* mln/core/site_set/p_edges_psite.hh: ...this.
(internal::graph_edge_psite): Rename as...
(p_edges_psite): ...this.
* mln/util/internal/graph_iter.hh,
* mln/util/internal/graph_base.hh,
* mln/util/internal/graph_iter_base.hh,
* mln/core/site_set/p_vertices.hh,
* mln/core/site_set/p_edges.hh,
* mln/core/image/line_graph_neighborhood_piter.hh,
* mln/core/image/line_graph_window_piter.hh,
* mln/core/image/line_graph_elt_window.hh,
* mln/core/image/line_graph_elt_neighborhood.hh,
* mln/core/image/graph_window_piter.hh,
* mln/core/image/graph_neighborhood_piter.hh,
* mln/core/image/graph_elt_neighborhood.hh,
* mln/core/image/graph_elt_window.hh: Update.
core/image/graph_elt_neighborhood.hh | 6 -
core/image/graph_elt_window.hh | 6 -
core/image/graph_neighborhood_piter.hh | 4 -
core/image/graph_window_piter.hh | 4 -
core/image/line_graph_elt_neighborhood.hh | 7 +-
core/image/line_graph_elt_window.hh | 7 +-
core/image/line_graph_neighborhood_piter.hh | 4 -
core/image/line_graph_window_piter.hh | 4 -
core/internal/graph_psite_base.hh | 24 ++-----
core/site_set/p_edges.hh | 7 +-
core/site_set/p_edges_psite.hh | 41 +++++--------
core/site_set/p_vertices.hh | 10 +--
core/site_set/p_vertices_psite.hh | 41 +++++--------
util/all.hh | 10 +--
util/edge.hh | 29 ++++++---
util/internal/graph_base.hh | 9 +-
util/internal/graph_iter.hh | 24 ++++++-
util/internal/graph_iter_base.hh | 1
util/vertex.hh | 88 +++++++++++++++++-----------
19 files changed, 177 insertions(+), 149 deletions(-)
Index: mln/core/site_set/p_vertices.hh
--- mln/core/site_set/p_vertices.hh (revision 2888)
+++ mln/core/site_set/p_vertices.hh (working copy)
@@ -34,13 +34,9 @@
# include <mln/core/internal/site_set_base.hh>
# include <mln/core/site_set/p_graph_piter.hh>
-# include <mln/util/internal/graph_vertex_psite.hh>
+# include <mln/core/site_set/p_vertices_psite.hh>
# include <mln/util/graph.hh>
- //# include <mln/util/tracked_ptr.hh>
-
- //# include <mln/core/image/graph_psite.hh>
- //# include <mln/core/site_set/p_vertices_piter.hh>
namespace mln
@@ -52,6 +48,7 @@
namespace trait
{
+
template <typename G, typename F>
struct site_set_< p_vertices<G, F> >
{
@@ -61,6 +58,7 @@
typedef trait::site_set::contents::fixed contents;
typedef trait::site_set::arity::unique arity;
};
+
} // end of namespace mln::trait
@@ -104,7 +102,7 @@
typedef mln_site(super_) element;
/// Point_Site associated type.
- typedef internal::vertex_psite<G, F> psite;
+ typedef p_vertices_psite<G,F> psite;
/// Forward Site_Iterator associated type.
typedef p_graph_piter< self_, mln_vertex_fwd_iter(G) > fwd_piter;
Index: mln/core/site_set/p_edges.hh
--- mln/core/site_set/p_edges.hh (revision 2888)
+++ mln/core/site_set/p_edges.hh (working copy)
@@ -29,11 +29,12 @@
# define MLN_CORE_SITE_SET_P_EDGES_HH
/// \file mln/core/site_set/p_edges.hh
- /// \brief Definition of a site set based on graph edges.
+///
+/// Definition of a site set based on graph edges.
# include <mln/core/internal/site_set_base.hh>
# include <mln/core/site_set/p_graph_piter.hh>
-# include <mln/util/internal/graph_edge_psite.hh>
+# include <mln/core/site_set/p_edges_psite.hh>
# include <mln/util/graph.hh>
@@ -90,7 +91,7 @@
typedef mln_site(super_) element;
/// Point_Site associated type.
- typedef internal::edge_psite<G, F> psite;
+ typedef p_edges_psite<G, F> psite;
/// Forward Site_Iterator associated type.
typedef p_graph_piter< self_, mln_edge_fwd_iter(G) > fwd_piter;
Index: mln/core/site_set/p_vertices_psite.hh
--- mln/core/site_set/p_vertices_psite.hh (revision 2888)
+++ mln/core/site_set/p_vertices_psite.hh (working copy)
@@ -25,16 +25,16 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_UTIL_INTERNAL_GRAPH_VERTEX_PSITE_HH
-# define MLN_UTIL_INTERNAL_GRAPH_VERTEX_PSITE_HH
+#ifndef MLN_CORE_SITE_SET_P_VERTICES_PSITE_HH
+# define MLN_CORE_SITE_SET_P_VERTICES_PSITE_HH
-/// \file mln/util/internal/graph_vertex_psite.hh
+/// \file mln/core/site_set/p_vertices_psite.hh
///
/// Implementation of p_vertices psite.
# include <mln/core/concept/pseudo_site.hh>
-# include <mln/util/internal/graph_psite_base.hh>
-# include <mln/util/internal/graph_vertex.hh>
+# include <mln/core/internal/graph_psite_base.hh>
+# include <mln/util/vertex.hh>
namespace mln
@@ -44,23 +44,20 @@
template <typename G, typename F> class p_vertices;
- namespace internal
- {
-
template <typename G, typename F>
- class vertex_psite :
- public graph_psite_base< p_vertices<G,F>,
- vertex_psite<G,F> >
+ class p_vertices_psite :
+
+ public internal::graph_psite_base< p_vertices<G,F>, p_vertices_psite<G,F> >
{
- typedef vertex_psite<G,F> self_;
- typedef graph_psite_base<p_vertices<G,F>, self_> super_;
+ typedef p_vertices_psite<G,F> self_;
+ typedef internal::graph_psite_base<p_vertices<G,F>, self_> super_;
public:
- vertex_psite();
- vertex_psite(const p_vertices<G,F>& s);
- vertex_psite(const p_vertices<G,F>& s, unsigned id);
+ p_vertices_psite();
+ p_vertices_psite(const p_vertices<G,F>& s);
+ p_vertices_psite(const p_vertices<G,F>& s, unsigned id);
const util::vertex<G>& v() const;
};
@@ -71,20 +68,20 @@
template <typename G, typename F>
inline
- vertex_psite<G, F>::vertex_psite()
+ p_vertices_psite<G, F>::p_vertices_psite()
{
}
template <typename G, typename F>
inline
- vertex_psite<G, F>::vertex_psite(const p_vertices<G,F>& s)
+ p_vertices_psite<G, F>::p_vertices_psite(const p_vertices<G,F>& s)
: super_(s)
{
}
template <typename G, typename F>
inline
- vertex_psite<G, F>::vertex_psite(const p_vertices<G,F>& s, unsigned i)
+ p_vertices_psite<G, F>::p_vertices_psite(const p_vertices<G,F>& s, unsigned i)
: super_(s, i)
{
}
@@ -92,17 +89,15 @@
template <typename G, typename F>
inline
const util::vertex<G>&
- vertex_psite<G, F>::v() const
+ p_vertices_psite<G, F>::v() const
{
return this->elt_;
}
# endif // ! MLN_INCLUDE_ONLY
-} // end of namespace internal
-
} // end of namespace mln
-#endif // !MLN_UTIL_INTERNAL_GRAPH_VERTEX_PSITE_HH
+#endif // ! MLN_CORE_SITE_SET_P_VERTICES_PSITE_HH
Property changes on: mln/core/site_set/p_vertices_psite.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/core/site_set/p_edges_psite.hh
--- mln/core/site_set/p_edges_psite.hh (revision 2888)
+++ mln/core/site_set/p_edges_psite.hh (working copy)
@@ -25,15 +25,15 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_UTIL_INTERNAL_GRAPH_EDGE_PSITE_HH
-# define MLN_UTIL_INTERNAL_GRAPH_EDGE_PSITE_HH
+#ifndef MLN_CORE_SITE_SET_P_EDGES_PSITE_HH
+# define MLN_CORE_SITE_SET_P_EDGES_PSITE_HH
-/// \file mln/util/internal/graph_edge_psite.hh
+/// \file mln/core/site_set/p_edges_psite.hh
///
/// Implementation of p_edges psite.
-# include <mln/util/internal/graph_psite_base.hh>
-# include <mln/util/internal/graph_edge.hh>
+# include <mln/core/internal/graph_psite_base.hh>
+# include <mln/util/edge.hh>
namespace mln
@@ -43,25 +43,20 @@
template <typename G, typename F> class p_edges;
- namespace internal
- {
-
-
template <typename G, typename F>
- class edge_psite :
- public graph_psite_base< p_edges<G,F>,
- edge_psite<G,F> >
+ class p_edges_psite :
+ public internal::graph_psite_base< p_edges<G,F>, p_edges_psite<G,F> >
{
- typedef edge_psite<G,F> self_;
- typedef graph_psite_base<p_edges<G,F>, self_> super_;
+ typedef p_edges_psite<G,F> self_;
+ typedef internal::graph_psite_base<p_edges<G,F>, self_> super_;
public:
/// Constructors
/// \{
- edge_psite();
- edge_psite(const p_edges<G,F>& s);
- edge_psite(const p_edges<G,F>& s, unsigned);
+ p_edges_psite();
+ p_edges_psite(const p_edges<G,F>& s);
+ p_edges_psite(const p_edges<G,F>& s, unsigned);
/// \}
/// Accessors
@@ -78,20 +73,20 @@
template <typename G, typename F>
inline
- edge_psite<G, F>::edge_psite()
+ p_edges_psite<G, F>::p_edges_psite()
{
}
template <typename G, typename F>
inline
- edge_psite<G, F>::edge_psite(const p_edges<G,F>& s)
+ p_edges_psite<G, F>::p_edges_psite(const p_edges<G,F>& s)
: super_(s)
{
}
template <typename G, typename F>
inline
- edge_psite<G, F>::edge_psite(const p_edges<G,F>& s, unsigned id)
+ p_edges_psite<G, F>::p_edges_psite(const p_edges<G,F>& s, unsigned id)
: super_(s, id)
{
}
@@ -99,17 +94,15 @@
template <typename G, typename F>
inline
const util::edge<G>&
- edge_psite<G, F>::e() const
+ p_edges_psite<G, F>::e() const
{
return this->elt_;
}
# endif // ! MLN_INCLUDE_ONLY
-} // end of namespace internal
-
} // end of namespace mln
-#endif // ! MLN_UTIL_INTERNAL_GRAPH_EDGE_PSITE_HH
+#endif // ! MLN_CORE_SITE_SET_P_EDGES_PSITE_HH
Property changes on: mln/core/site_set/p_edges_psite.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/core/image/line_graph_neighborhood_piter.hh
--- mln/core/image/line_graph_neighborhood_piter.hh (revision 2888)
+++ mln/core/image/line_graph_neighborhood_piter.hh (working copy)
@@ -194,7 +194,7 @@
mln_psite(N)
line_graph_neighborhood_fwd_piter<G, F, N>::compute_p_() const
{
- return internal::edge_psite<G, F>(this->center().site_set(), *i_);
+ return p_edges_psite<G, F>(this->center().site_set(), *i_);
}
@@ -256,7 +256,7 @@
mln_psite(N)
line_graph_neighborhood_bkd_piter<G, F, N>::compute_p_() const
{
- return internal::edge_psite<G, F>(this->center().site_set(), *i_);
+ return p_edges_psite<G, F>(this->center().site_set(), *i_);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/image/line_graph_window_piter.hh
--- mln/core/image/line_graph_window_piter.hh (revision 2888)
+++ mln/core/image/line_graph_window_piter.hh (working copy)
@@ -193,7 +193,7 @@
mln_psite(W)
line_graph_window_fwd_piter<G, F, W>::compute_p_() const
{
- return internal::edge_psite<G, F>(this->center().site_set(), *i_);
+ return p_edges_psite<G, F>(this->center().site_set(), *i_);
}
@@ -255,7 +255,7 @@
mln_psite(W)
line_graph_window_bkd_piter<G, F, W>::compute_p_() const
{
- return internal::edge_psite<G, F>(this->center().site_set(), *i_);
+ return p_edges_psite<G, F>(this->center().site_set(), *i_);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/image/line_graph_elt_window.hh
--- mln/core/image/line_graph_elt_window.hh (revision 2888)
+++ mln/core/image/line_graph_elt_window.hh (working copy)
@@ -30,11 +30,12 @@
# define MLN_CORE_IMAGE_LINE_GRAPH_ELT_WINDOW_HH
/// \file mln/core/image/line_graph_elt_window.hh
+///
/// Definition of the elementary ``window'' on a line graph.
# include <mln/core/concept/window.hh>
# include <mln/core/internal/graph_window_base.hh>
-# include <mln/util/internal/graph_edge_psite.hh>
+# include <mln/core/site_set/p_edges_psite.hh>
# include <mln/core/image/line_graph_window_piter.hh>
@@ -64,7 +65,7 @@
class line_graph_elt_window : public graph_window_base<
G,
F,
- internal::edge_psite<G, F>,
+ p_edges_psite<G, F>,
line_graph_elt_window<G, F> >
{
typedef line_graph_elt_window<G, F> self_;
@@ -73,7 +74,7 @@
/// Associated types.
/// \{
/// The type of psite corresponding to the window.
- typedef internal::edge_psite<G, F> psite;
+ typedef p_edges_psite<G, F> psite;
/// Site_Iterator type to browse the psites of the window
/// w.r.t. the ordering of edges.
Index: mln/core/image/line_graph_elt_neighborhood.hh
--- mln/core/image/line_graph_elt_neighborhood.hh (revision 2888)
+++ mln/core/image/line_graph_elt_neighborhood.hh (working copy)
@@ -30,13 +30,14 @@
# define MLN_CORE_IMAGE_LINE_GRAPH_ELT_NEIGHBORHOOD_HH
/// \file mln/core/image/line_graph_elt_neighborhood.hh
+///
/// Definition of the elementary ``neighborhood'' on a line graph.
# include <set>
# include <mln/core/concept/neighborhood.hh>
# include <mln/core/internal/graph_neighborhood_base.hh>
-# include <mln/util/internal/graph_edge_psite.hh>
+# include <mln/core/site_set/p_edges_psite.hh>
# include <mln/core/image/line_graph_neighborhood_piter.hh>
# include <mln/core/image/line_graph_elt_window.hh>
@@ -50,7 +51,7 @@
class line_graph_elt_neighborhood
: public graph_neighborhood_base<G,
F,
- internal::edge_psite<G, F>,
+ p_edges_psite<G, F>,
line_graph_elt_neighborhood<G, F> >
{
typedef line_graph_elt_neighborhood<G, F> self_;
@@ -59,7 +60,7 @@
/// Associated types.
/// \{
/// The type of psite corresponding to the neighborhood.
- typedef internal::edge_psite<G, F> psite;
+ typedef p_edges_psite<G, F> psite;
/// Site_Iterator type to browse the psites of the
/// neighborhood w.r.t. the ordering of edges.
Index: mln/core/image/graph_window_piter.hh
--- mln/core/image/graph_window_piter.hh (revision 2888)
+++ mln/core/image/graph_window_piter.hh (working copy)
@@ -190,7 +190,7 @@
mln_psite(W)
graph_window_fwd_piter<G, F, W>::compute_p_() const
{
- return internal::vertex_psite<G, F>(this->center().site_set(), *i_);
+ return p_vertices_psite<G, F>(this->center().site_set(), *i_);
}
@@ -252,7 +252,7 @@
mln_psite(W)
graph_window_bkd_piter<G, F, W>::compute_p_() const
{
- return internal::vertex_psite<G, F>(this->center().site_set(), *i_);
+ return p_vertices_psite<G, F>(this->center().site_set(), *i_);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/image/graph_neighborhood_piter.hh
--- mln/core/image/graph_neighborhood_piter.hh (revision 2888)
+++ mln/core/image/graph_neighborhood_piter.hh (working copy)
@@ -194,7 +194,7 @@
mln_psite(N)
graph_neighborhood_fwd_piter<G, F, N>::compute_p_() const
{
- return internal::vertex_psite<G, F>(this->center().site_set(), *i_);
+ return p_vertices_psite<G, F>(this->center().site_set(), *i_);
}
@@ -256,7 +256,7 @@
mln_psite(N)
graph_neighborhood_bkd_piter<G, F, N>::compute_p_() const
{
- return internal::vertex_psite<G, F>(this->center().site_set(), *i_);
+ return p_vertices_psite<G, F>(this->center().site_set(), *i_);
}
Index: mln/core/image/graph_elt_neighborhood.hh
--- mln/core/image/graph_elt_neighborhood.hh (revision 2888)
+++ mln/core/image/graph_elt_neighborhood.hh (working copy)
@@ -36,7 +36,7 @@
# include <mln/core/concept/neighborhood.hh>
# include <mln/core/internal/graph_neighborhood_base.hh>
-# include <mln/util/internal/graph_vertex_psite.hh>
+# include <mln/core/site_set/p_vertices_psite.hh>
# include <mln/core/image/graph_neighborhood_piter.hh>
# include <mln/core/image/graph_elt_window.hh>
@@ -54,7 +54,7 @@
class graph_elt_neighborhood
: public graph_neighborhood_base<G,
F,
- internal::vertex_psite<G, F>,
+ p_vertices_psite<G, F>,
graph_elt_neighborhood<G, F> >
{
typedef graph_elt_neighborhood<G, F> self_;
@@ -63,7 +63,7 @@
/// Associated types.
/// \{
/// The type of psite corresponding to the neighborhood.
- typedef internal::vertex_psite<G, F> psite;
+ typedef p_vertices_psite<G, F> psite;
/// Site_Iterator type to browse the psites of the
/// neighborhood w.r.t. the ordering of vertices.
Index: mln/core/image/graph_elt_window.hh
--- mln/core/image/graph_elt_window.hh (revision 2888)
+++ mln/core/image/graph_elt_window.hh (working copy)
@@ -34,7 +34,7 @@
# include <mln/core/concept/window.hh>
# include <mln/core/internal/graph_window_base.hh>
-# include <mln/util/internal/graph_vertex_psite.hh>
+# include <mln/core/site_set/p_vertices_psite.hh>
# include <mln/core/image/graph_window_piter.hh>
@@ -64,7 +64,7 @@
class graph_elt_window : public graph_window_base<
G,
F,
- internal::vertex_psite<G, F>,
+ p_vertices_psite<G, F>,
graph_elt_window<G, F> >
{
@@ -74,7 +74,7 @@
/// Associated types.
/// \{
/// The type of psite corresponding to the window.
- typedef internal::vertex_psite<G, F> psite;
+ typedef p_vertices_psite<G, F> psite;
/// \brief Site_Iterator type to browse the psites of the window
/// w.r.t. the ordering of vertices.
Index: mln/core/internal/graph_psite_base.hh
--- mln/core/internal/graph_psite_base.hh (revision 2888)
+++ mln/core/internal/graph_psite_base.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_UTIL_INTERNAL_GRAPH_PSITE_BASE_HH
-# define MLN_UTIL_INTERNAL_GRAPH_PSITE_BASE_HH
+#ifndef MLN_CORE_INTERNAL_GRAPH_PSITE_BASE_HH
+# define MLN_CORE_INTERNAL_GRAPH_PSITE_BASE_HH
-/// \file mln/util/internal/graph_psite_base.hh
+/// \file mln/core/internal/graph_psite_base.hh
///
/// Base implementation for graph based psites.
@@ -113,11 +113,11 @@
};
- /// Comparison of two mln::graph_psite_base<S,E> instances.
- /// \{
/* FIXME: Shouldn't those comparisons be part of a much general
mechanism? */
+ /// Comparison of two mln::graph_psite_base<S,E> instances.
+ /// \{
/// \brief Is \a lhs equal to \a rhs?
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
@@ -145,19 +145,10 @@
operator< (const graph_psite_base<S,E>& lhs, const graph_psite_base<S,E>& rhs);
/// \}
-} // end of namespace internal
-
- } // end of namespace mln
-
# ifndef MLN_INCLUDE_ONLY
-namespace mln
-{
-
- namespace internal
- {
template <typename S, typename E>
inline
@@ -295,11 +286,12 @@
return lhs.id() < rhs.id();
}
+# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace internal
} // end of namespace mln
-# endif // !MLN_INCLUDE_ONLY
-#endif // !MLN_UTIL_INTERNAL_GRAPH_PSITE_BASE_HH
+#endif // ! MLN_CORE_INTERNAL_GRAPH_PSITE_BASE_HH
Property changes on: mln/core/internal/graph_psite_base.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/util/all.hh
--- mln/util/all.hh (revision 2888)
+++ mln/util/all.hh (working copy)
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 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,10 +29,9 @@
#ifndef MLN_UTIL_ALL_HH
# define MLN_UTIL_ALL_HH
-/*! \file mln/util/all.hh
- *
- * \brief File that includes all util-related routines.
- */
+/// \file mln/util/all.hh
+///
+/// File that includes all util-related routines.
namespace mln
@@ -52,6 +52,7 @@
# include <mln/util/branch_iter_ind.hh>
# include <mln/util/dindex.hh>
# include <mln/util/eat.hh>
+# include <mln/util/edge.hh>
# include <mln/util/graph.hh>
# include <mln/util/greater_point.hh>
# include <mln/util/greater_psite.hh>
@@ -73,6 +74,7 @@
# include <mln/util/tree_fast_to_image.hh>
# include <mln/util/tree_to_fast.hh>
//# include <mln/util/tree_to_image.hh>
+# include <mln/util/vertex.hh>
# include <mln/util/yes.hh>
#endif // ! MLN_UTIL_ALL_HH
Index: mln/util/internal/graph_iter.hh
--- mln/util/internal/graph_iter.hh (revision 2888)
+++ mln/util/internal/graph_iter.hh (working copy)
@@ -28,13 +28,15 @@
#ifndef MLN_UTIL_INTERNAL_GRAPH_ITER_HH
# define MLN_UTIL_INTERNAL_GRAPH_ITER_HH
-# include <mln/core/concept/iterator.hh>
-# include <mln/util/internal/graph_vertex.hh>
-# include <mln/util/internal/graph_edge.hh>
+/// \file mln/util/internal/graph_iter.hh
+///
+/// Implementation for graph iterators.
+
# include <mln/util/internal/graph_iter_base.hh>
+# include <mln/util/vertex.hh>
+# include <mln/util/edge.hh>
+
-/// \file mln/util/internal/graph_iter.hh
-/// \brief Implementation for graph iterators.
namespace mln
{
@@ -42,6 +44,8 @@
namespace internal
{
+ /// Forward vertex iterator.
+
template<typename G>
class vertex_fwd_iterator
: public graph_iter_base<G, util::vertex<G>, vertex_fwd_iterator<G> >
@@ -69,6 +73,8 @@
};
+ /// Backward vertex iterator.
+
template<typename G>
class vertex_bkd_iterator
: public graph_iter_base<G, util::vertex<G>, vertex_bkd_iterator<G> >
@@ -95,7 +101,9 @@
friend class graph_iter_base<G, util::vertex<G>, vertex_bkd_iterator<G> >;
};
+
/// Forward edge iterator.
+
template <typename G>
class edge_fwd_iterator
: public graph_iter_base<G, util::edge<G>, edge_fwd_iterator<G> >
@@ -122,6 +130,9 @@
friend class graph_iter_base<G, util::edge<G>, edge_fwd_iterator<G> >;
};
+
+ /// Backward edge iterator.
+
template <typename G>
class edge_bkd_iterator
: public graph_iter_base<G, util::edge<G>, edge_bkd_iterator<G> >
@@ -150,8 +161,10 @@
+
# ifndef MLN_INCLUDE_ONLY
+
/*--------------------`
| vertex_fwd_iterator |
\--------------------*/
@@ -296,5 +309,6 @@
} // end of namespace mln
+
#endif // ! MLN_UTIL_INTERNAL_GRAPH_ITER_HH
Index: mln/util/internal/graph_base.hh
--- mln/util/internal/graph_base.hh (revision 2888)
+++ mln/util/internal/graph_base.hh (working copy)
@@ -30,12 +30,11 @@
# define MLN_UTIL_INTERNAL_GRAPH_BASE_HH
/// \file mln/util/internal/graph_base.hh
-/// \brief Factored implementation of undirected graphs.
+///
+/// Factored implementation of undirected graphs.
# include <cstddef>
-
# include <algorithm>
-
# include <vector>
# include <set>
# include <ostream>
@@ -45,8 +44,8 @@
# include <mln/core/concept/proxy.hh>
# include <mln/core/internal/data.hh>
-# include <mln/util/internal/graph_edge.hh>
-# include <mln/util/internal/graph_vertex.hh>
+# include <mln/util/edge.hh>
+# include <mln/util/vertex.hh>
# include <mln/util/ord_pair.hh>
# include <mln/util/tracked_ptr.hh>
Index: mln/util/internal/graph_iter_base.hh
--- mln/util/internal/graph_iter_base.hh (revision 2888)
+++ mln/util/internal/graph_iter_base.hh (working copy)
@@ -37,7 +37,6 @@
# include <mln/core/concept/iterator.hh>
# include <mln/core/concept/proxy.hh>
-# include <mln/util/internal/graph_edge.hh>
namespace mln
Index: mln/util/edge.hh
--- mln/util/edge.hh (revision 2888)
+++ mln/util/edge.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_UTIL_INTERNAL_GRAPH_EDGE_HH
-# define MLN_UTIL_INTERNAL_GRAPH_EDGE_HH
+#ifndef MLN_UTIL_EDGE_HH
+# define MLN_UTIL_EDGE_HH
-/// \file mln/util/internal/graph_edge.hh
+/// \file mln/util/edge.hh
///
/// Definition of a graph edge.
@@ -110,6 +110,7 @@
unsigned id_;
};
+
template <typename G>
std::ostream&
operator<<(std::ostream& ostr, const edge<G>& p);
@@ -122,14 +123,16 @@
bool
operator< (const edge<G>& lhs, const edge<G>& rhs);
- } // End of namespace mln::util
+ } // end of namespace mln::util
+
- /// subject_impl specialization (Proxy)
- /// \{
namespace internal
{
+ /// subject_impl specialization (Proxy)
+ /// \{
+
template <typename G, typename E>
struct subject_impl< const util::edge<G>, E >
{
@@ -159,9 +162,11 @@
E& exact_();
};
- } // end of namespace mln::internal
/// \}
+ } // end of namespace mln::internal
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -290,6 +295,7 @@
}
template <typename G>
+ inline
std::ostream&
operator<<(std::ostream& ostr, const edge<G>& p)
{
@@ -314,6 +320,8 @@
} // end of namespace mln::util
+
+
namespace internal
{
@@ -422,11 +430,12 @@
return exact_().get_subject().invalidate();
}
- } // End of namespace mln::internal
+ } // end of namespace mln::internal
# endif // !MLN_INCLUDE_ONLY
-} // End of namespace mln
+} // end of namespace mln
+
-#endif // !MLN_UTIL_INTERNAL_GRAPH_EDGE_HH
+#endif // ! MLN_UTIL_EDGE_HH
Property changes on: mln/util/edge.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/util/vertex.hh
--- mln/util/vertex.hh (revision 2888)
+++ mln/util/vertex.hh (working copy)
@@ -25,12 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_UTIL_INTERNAL_GRAPH_VERTEX_HH
-# define MLN_UTIL_INTERNAL_GRAPH_VERTEX_HH
+#ifndef MLN_UTIL_VERTEX_HH
+# define MLN_UTIL_VERTEX_HH
# include <mln/util/internal/graph_vertex_impl.hh>
-/// \file mln/util/internal/graph_vertex.hh
+/// \file mln/util/vertex.hh
///
/// Implementation of a graph vertex.
@@ -43,6 +43,7 @@
{
/// Vertex of a graph \p G.
+
template<typename G>
class vertex : public internal::vertex_impl_<G>
{
@@ -96,23 +97,35 @@
unsigned id_;
};
- /// Comparison operator. Test whether two vertices have the same id.
+
+ /// Push the vertex \p v in the output stream \p ostr.
+ template <typename G>
+ std::ostream&
+ operator<<(std::ostream& ostr, const vertex<G>& v);
+
+ /// Equality operator. Test whether two vertices have the same
+ /// id.
template<typename G>
bool
- operator==(const util::vertex<G>& v1, const util::vertex<G>& v2);
+ operator==(const vertex<G>& v1, const vertex<G>& v2);
- /// Inferior operator. Test whether lhs.id() < rhs.id().
+
+ /// Less operator. Test whether lhs.id() < rhs.id().
template<typename G>
bool
- operator<(const util::vertex<G>& lhs, const util::vertex<G>& rhs);
+ operator<(const vertex<G>& lhs, const vertex<G>& rhs);
+
+
+ } // end of namespace mln::util
- } // End of namespace mln::util
-/// subject_impl specialization (Proxy)
-/// \{
namespace internal
{
+
+ /// \{
+ /// subject_impl specialization (Proxy)
+
template <typename G, typename E>
struct subject_impl< const util::vertex<G>, E >
{
@@ -142,10 +155,13 @@
E& exact_();
};
+ /// \}
+
} // end of namespace mln::internal
-} // End of namespace mln
-/// \}
+} // end of namespace mln
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -158,24 +174,6 @@
template<typename G>
inline
- bool
- operator==(const util::vertex<G>& v1, const util::vertex<G>& v2)
- {
- return v1.id() == v2.id();
- }
-
- template<typename G>
- inline
- bool
- operator<(const util::vertex<G>& lhs, const util::vertex<G>& rhs)
- {
- return lhs.id() < rhs.id();
- }
-
-
-
- template <typename G>
- inline
vertex<G>::vertex()
{
invalidate();
@@ -293,8 +291,34 @@
return id_;
}
+
+ template <typename G>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr, const vertex<G>& v)
+ {
+ return ostr << v.id();
+ }
+
+ template<typename G>
+ inline
+ bool
+ operator==(const vertex<G>& v1, const vertex<G>& v2)
+ {
+ return v1.id() == v2.id();
+ }
+
+ template<typename G>
+ inline
+ bool
+ operator<(const vertex<G>& lhs, const vertex<G>& rhs)
+ {
+ return lhs.id() < rhs.id();
+ }
+
} // end of namespace mln::util
+
namespace internal
{
@@ -406,10 +430,10 @@
} // end of namespace mln::internal
-} // End of namespace mln
+} // end of namespace mln
# endif // !MLN_INCLUDE_ONLY
-#endif // !MLN_UTIL_INTERNAL_GRAPH_VERTEX_HH
+#endif // ! MLN_UTIL_VERTEX_HH
Property changes on: mln/util/vertex.hh
___________________________________________________________________
Added: svn:mergeinfo
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Some fixes in graph-related materials.
* tests/core/site_set/p_vertices.cc: Layout.
(UINT_MAX): Fix warning; use mln_max(unsigned).
* tests/core/site_set/p_edges.cc: Likewise.
* mln/core/site_set/p_vertices.hh (graph_t): (Re-)New.
* mln/core/site_set/p_edges.hh: .
It is used so it is featured!
* mln/algebra/vec.hh: Upgrade doc style.
(operator/): Fix warning with g++-4.3.
* mln/util/internal/graph_edge.hh (graph): Fix return sig.
* mln/util/internal/graph_vertex.hh: Likewise.
* mln/util/internal/graph_edge_psite.hh: Layout.
(e): Fix missing update; inherited attr is elt_.
* mln/util/internal/graph_vertex_psite.hh: Likewise.
* mln/util/internal/graph_psite_base.hh: Layout.
(super): Remove; unused.
Layout.
mln/algebra/vec.hh | 11 +++++------
mln/core/site_set/p_edges.hh | 5 +++++
mln/core/site_set/p_vertices.hh | 4 ++++
mln/util/internal/graph_edge.hh | 6 +++---
mln/util/internal/graph_edge_psite.hh | 15 +++------------
mln/util/internal/graph_psite_base.hh | 12 ++++--------
mln/util/internal/graph_vertex.hh | 6 +++---
mln/util/internal/graph_vertex_psite.hh | 18 ++++--------------
tests/core/site_set/p_edges.cc | 11 +++++++----
tests/core/site_set/p_vertices.cc | 7 +++++--
10 files changed, 43 insertions(+), 52 deletions(-)
Index: tests/core/site_set/p_vertices.cc
--- tests/core/site_set/p_vertices.cc (revision 2887)
+++ tests/core/site_set/p_vertices.cc (working copy)
@@ -34,6 +34,7 @@
#include <mln/core/site_set/p_vertices.hh>
#include <mln/fun/i2v/array.hh>
+
int main()
{
using namespace mln;
@@ -63,6 +64,7 @@
typedef p_vertices<util::graph, F> p_vertices;
p_vertices pv(g, f);
+ // Forward iterator.
{
mln_fwd_piter_(p_vertices) p(pv);
unsigned i = 0;
@@ -70,13 +72,14 @@
mln_assertion(p.p_hook_().v().id() == i++);
mln_assertion(i == g.v_nmax());
}
+
+ // Backward iterator.
{
mln_bkd_piter_(p_vertices) p(pv);
unsigned i = g.v_nmax() - 1;
for_all(p)
mln_assertion(p.p_hook_().v().id() == i--);
- mln_assertion(i == UINT_MAX);
+ mln_assertion(i == mln_max(unsigned));
}
- return 0;
}
Index: tests/core/site_set/p_edges.cc
--- tests/core/site_set/p_edges.cc (revision 2887)
+++ tests/core/site_set/p_edges.cc (working copy)
@@ -34,7 +34,9 @@
#include <mln/core/alias/point2d.hh>
#include <mln/core/site_set/p_edges.hh>
+
// Function mapping an edge to a specific site.
+
template <typename G>
struct my_fun
{
@@ -48,6 +50,7 @@
}
};
+
int main()
{
using namespace mln;
@@ -72,7 +75,7 @@
typedef p_edges<util::graph, my_fun<util::graph> > p_edges;
p_edges pv(g, my_fun<util::graph>());
- // Forward iterator
+ // Forward iterator.
{
mln_fwd_piter_(p_edges) p(pv);
unsigned i = 0;
@@ -80,14 +83,14 @@
mln_assertion(p.p_hook_().e().id() == i++);
mln_assertion(i == g.e_nmax());
}
- // Backward iterator
+
+ // Backward iterator.
{
mln_bkd_piter_(p_edges) p(pv);
unsigned i = g.e_nmax() - 1;
for_all(p)
mln_assertion(p.p_hook_().e().id() == i--);
- mln_assertion(i == UINT_MAX);
+ mln_assertion(i == mln_max(unsigned));
}
- return 0;
}
Index: mln/core/site_set/p_vertices.hh
--- mln/core/site_set/p_vertices.hh (revision 2887)
+++ mln/core/site_set/p_vertices.hh (working copy)
@@ -75,6 +75,10 @@
public:
+ /// Graph associated type.
+ typedef G graph_t;
+
+
/// Type of graph vertex.
typedef util::vertex<G> vertex;
Index: mln/core/site_set/p_edges.hh
--- mln/core/site_set/p_edges.hh (revision 2887)
+++ mln/core/site_set/p_edges.hh (working copy)
@@ -39,9 +39,11 @@
namespace mln
{
+
// Forward declaration.
template <typename G, typename F> struct p_edges;
+
namespace trait
{
template <typename G, typename F>
@@ -66,6 +68,9 @@
public:
+ /// Graph associated type.
+ typedef G graph_t;
+
/// Type of graph edge.
typedef util::edge<G> edge;
Index: mln/algebra/vec.hh
--- mln/algebra/vec.hh (revision 2887)
+++ mln/algebra/vec.hh (working copy)
@@ -1,4 +1,5 @@
// Copyright (C) 2006, 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,11 +29,9 @@
#ifndef MLN_ALGEBRA_VEC_HH
# define MLN_ALGEBRA_VEC_HH
-/*!
- * \file mln/algebra/vec.hh
- *
- * \brief Definition of a generic vector class.
- */
+/// \file mln/algebra/vec.hh
+///
+/// Definition of a generic vector class.
# include <iostream>
# include <cmath>
@@ -533,7 +532,7 @@
vec<n, mln_trait_op_div(T, S)>
operator/(const vec<n,T>& lhs, const mln::value::scalar_<S>& s)
{
- mln_precondition(value::equiv(s) != literal::zero);
+ mln_precondition(value::equiv(s) != (S)(literal::zero));
vec<n, mln_trait_op_div(T, S)> tmp;
for (unsigned i = 0; i < n; ++i)
tmp[i] = lhs[i] / s.to_equiv();
Index: mln/util/internal/graph_edge.hh
--- mln/util/internal/graph_edge.hh (revision 2887)
+++ mln/util/internal/graph_edge.hh (working copy)
@@ -134,7 +134,7 @@
struct subject_impl< const util::edge<G>, E >
{
unsigned id() const;
- const mlc_const(G)& graph() const;
+ const G& graph() const;
unsigned v_other(unsigned id_v) const;
bool is_valid() const;
unsigned v1() const;
@@ -213,7 +213,7 @@
template <typename G>
inline
- const typename edge<G>::G&
+ const G&
edge<G>::graph() const
{
return g_;
@@ -339,7 +339,7 @@
template <typename G, typename E>
inline
- const mlc_const(G)&
+ const G&
subject_impl< const util::edge<G>, E >::graph() const
{
return exact_().get_subject().graph();
Index: mln/util/internal/graph_edge_psite.hh
--- mln/util/internal/graph_edge_psite.hh (revision 2887)
+++ mln/util/internal/graph_edge_psite.hh (working copy)
@@ -72,20 +72,10 @@
};
- } // end of namespace mln::internal
-
-} // end of namespace mln
-
# ifndef MLN_INCLUDE_ONLY
-namespace mln
-{
-
- namespace internal
- {
-
template <typename G, typename F>
inline
edge_psite<G, F>::edge_psite()
@@ -111,14 +101,15 @@
const util::edge<G>&
edge_psite<G, F>::e() const
{
- return this->v_;
+ return this->elt_;
}
+# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace internal
} // end of namespace mln
-# endif // !MLN_INCLUDE_ONLY
#endif // !MLN_UTIL_INTERNAL_GRAPH_EDGE_PSITE_HH
Index: mln/util/internal/graph_vertex.hh
--- mln/util/internal/graph_vertex.hh (revision 2887)
+++ mln/util/internal/graph_vertex.hh (working copy)
@@ -117,7 +117,7 @@
struct subject_impl< const util::vertex<G>, E >
{
bool is_valid() const;
- const mlc_const(G)& graph() const;
+ const G& graph() const;
unsigned id() const;
unsigned other(unsigned id_e) const;
@@ -279,7 +279,7 @@
template<typename G>
inline
- const typename vertex<G>::G&
+ const G&
vertex<G>::graph() const
{
return g_;
@@ -316,7 +316,7 @@
template <typename G, typename E>
inline
- const mlc_const(G)&
+ const G&
subject_impl< const util::vertex<G>, E >::graph() const
{
return exact_().get_subject().graph();
Index: mln/util/internal/graph_psite_base.hh
--- mln/util/internal/graph_psite_base.hh (revision 2887)
+++ mln/util/internal/graph_psite_base.hh (working copy)
@@ -32,18 +32,16 @@
///
/// Base implementation for graph based psites.
-# include <mln/core/concept/pseudo_site.hh>
+# include <mln/core/internal/pseudo_site_base.hh>
+
+
namespace mln
{
+ // Forward declaration.
template <typename G, typename F> class p_vertices;
-} // end of namespace mln
-
-
-namespace mln
-{
namespace internal
{
@@ -52,8 +50,6 @@
class graph_psite_base : public internal::pseudo_site_base_< const mln_site(S)&,
E >
{
- typedef Pseudo_Site< graph_psite_base<S,E> > super;
-
public:
// This associated type is important to know that this particular
Index: mln/util/internal/graph_vertex_psite.hh
--- mln/util/internal/graph_vertex_psite.hh (revision 2887)
+++ mln/util/internal/graph_vertex_psite.hh (working copy)
@@ -66,21 +66,9 @@
};
- } // end of namespace mln::internal
-
-} // end of namespace mln
-
-
-
# ifndef MLN_INCLUDE_ONLY
-namespace mln
-{
-
- namespace internal
- {
-
template <typename G, typename F>
inline
vertex_psite<G, F>::vertex_psite()
@@ -106,13 +94,15 @@
const util::vertex<G>&
vertex_psite<G, F>::v() const
{
- return this->v_;
+ return this->elt_;
}
+# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace internal
} // end of namespace mln
-# endif // !MLN_INCLUDE_ONLY
+
#endif // !MLN_UTIL_INTERNAL_GRAPH_VERTEX_PSITE_HH
1
0
17 Nov '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Cleanup basic graph class and related materials.
* mln/core/site_set/p_graph_piter.hh: Upgrade doc style.
(operator<<): Remove; useless.
* mln/core/site_set/p_vertices.hh
(vertex, graph_element): New typedefs.
(graph_t): Remove; use explicitly G instead.
* mln/core/site_set/p_edges.hh
(edge, graph_element): New typedefs.
(graph_t): Remove; use explicitly G instead.
* mln/util/graph.hh: Layout.
* mln/util/internal/graph_base.hh (graph_id): Fix return type.
That avoids a warning at compile-time.
* mln/core/concept/graph.hh: Update.
* mln/util/internal/graph_iter.hh: Layout.
* mln/util/internal/graph_edge.hh: Upgrade doc style.
(operator<<): Fix missing const.
(edge::edge): Prefer invalidate over id_ set to 0.
(FIXME): New.
(invalidate): Set id_ to unsigned max value; less error-prone.
(graph_t): Use instead explicit...
(G): ...parameter type.
* mln/util/internal/graph_edge_psite.hh: Upgrade doc style.
(target_t, edge_t): Use instead the explicit...
(p_edges, util::edge): ...types.
* mln/util/internal/graph_vertex.hh
(vertex::vertex): Prefer invalidate over id_ set to 0.
(FIXME): New.
(invalidate): Set id_ to unsigned max value; less error-prone.
(graph_t): Use instead explicit...
(G): ...parameter type.
Fix doc.
* mln/util/internal/graph_psite_base.hh: Fix doc.
(V, P): Remove these useless parameters, now deduce from S.
(v_): Rename this attribute as...
(elt_): ...this; more explicit name.
(target): Prefer to use the explicit...
(S): ...type.
(t_): Rename as...
(s_): ...this; consistent with other classes.
(q_subject): Remove; obsolete.
(to_site): Remove; inherited.
(operator<<): Remove; useless.
(operator graph_element): New conversion operator.
(site_set, graph, subj_): Fix missing precondition.
* mln/util/internal/graph_vertex_psite.hh: Fix doc.
(target_t, vertex_t): Prefer to use explicit...
(p_vertices, util::vertex): ...types.
* mln/util/internal/graph_iter_base.hh
(P): Rename this parameter as...
(Elt): ...this; more explicit.
(invalidate): Fix missing postcondition.
(next): Fix missing precondition.
core/concept/graph.hh | 2
core/site_set/p_edges.hh | 28 +++--
core/site_set/p_graph_piter.hh | 34 ++----
core/site_set/p_vertices.hh | 43 +++++---
util/graph.hh | 12 +-
util/internal/graph_base.hh | 6 -
util/internal/graph_edge.hh | 50 ++++-----
util/internal/graph_edge_psite.hh | 53 +++------
util/internal/graph_iter.hh | 6 -
util/internal/graph_iter_base.hh | 59 +++++------
util/internal/graph_psite_base.hh | 193 +++++++++++++++++-------------------
util/internal/graph_vertex.hh | 41 ++++---
util/internal/graph_vertex_psite.hh | 48 ++++----
13 files changed, 291 insertions(+), 284 deletions(-)
Index: mln/core/site_set/p_graph_piter.hh
--- mln/core/site_set/p_graph_piter.hh (revision 2886)
+++ mln/core/site_set/p_graph_piter.hh (working copy)
@@ -30,15 +30,17 @@
# define MLN_CORE_SITE_SET_P_GRAPH_PITER_HH
/// \file mln/core/site_set/p_graph_piter.hh
-/// \brief Definition of point iterator on graph-based point set.
+///
+/// Definition of point iterator on graph-based point set.
# include <mln/core/internal/site_set_iterator_base.hh>
-//# include <mln/core/site_set/p_graph.hh>
-//# include <mln/core/image/graph_psite.hh>
+
+
namespace mln
{
- // Fwd decls.
+
+ // Forward declaration.
template <typename S, typename I> class graph_psite;
@@ -46,7 +48,7 @@
| p_graph_piter<S,I>. |
`------------------------*/
- /// \brief Generic iterator on point sites of a mln::S.
+ /// Generic iterator on point sites of a mln::S.
template <typename S, typename I>
class p_graph_piter
: public internal::site_set_iterator_base< S,
@@ -57,7 +59,8 @@
typedef I iter;
public:
- /// Construction and assignment.
+
+ /// Constructors.
/// \{
p_graph_piter();
p_graph_piter(const S& pv);
@@ -77,10 +80,12 @@
/// \}
private:
+
/// Update the psite corresponding to this iterator.
void update_();
private:
+
/// The psite corresponding to this iterator.
using super_::p_;
@@ -89,11 +94,6 @@
};
- /// Print an mln::p_graph_piter<S,I>.
- template <typename S, typename I>
- inline
- std::ostream&
- operator<<(std::ostream& ostr, const p_graph_piter<S,I>& p);
# ifndef MLN_INCLUDE_ONLY
@@ -164,19 +164,9 @@
p_.update_id(iter_.id());
}
-
-
- template <typename S, typename I>
- inline
- std::ostream&
- operator<<(std::ostream& ostr, const p_graph_piter<S,I>& p)
- {
- return ostr << p.unproxy_();
- }
-
# endif // ! MLN_INCLUDE_ONLY
-} // end of mln
+} // end of namespace mln
#endif // ! MLN_CORE_SITE_SET_P_GRAPH_PITER_HH
Index: mln/core/site_set/p_vertices.hh
--- mln/core/site_set/p_vertices.hh (revision 2886)
+++ mln/core/site_set/p_vertices.hh (working copy)
@@ -29,7 +29,8 @@
# define MLN_CORE_SITE_SET_P_VERTICES_HH
/// \file mln/core/site_set/p_vertices.hh
- /// \brief Definition of a point set based on a graph.
+///
+/// Definition of a point set based on a graph.
# include <mln/core/internal/site_set_base.hh>
# include <mln/core/site_set/p_graph_piter.hh>
@@ -41,11 +42,14 @@
//# include <mln/core/image/graph_psite.hh>
//# include <mln/core/site_set/p_vertices_piter.hh>
+
namespace mln
{
+
// Forward declaration.
template <typename G, typename F> struct p_vertices;
+
namespace trait
{
template <typename G, typename F>
@@ -60,33 +64,41 @@
} // end of namespace mln::trait
+
template <typename G, typename F>
class p_vertices
- : public internal::site_set_base_< typename F::result, p_vertices<G, F> >
+ : public internal::site_set_base_< mln_result(F), p_vertices<G, F> >
{
- typedef util::vertex<G> vertex_t;
typedef p_vertices<G, F> self_;
- typedef internal::site_set_base_< typename F::result, self_ > super_;
+ typedef internal::site_set_base_< mln_result(F), self_ > super_;
public:
- /// Type of the graph this site set is based on.
- typedef G graph_t;
+ /// Type of graph vertex.
+ typedef util::vertex<G> vertex;
- /// \brief Construct a graph psite set from a graph of points.
- /// \{
+
+ /// Type of graph element this site set focuses on.
+ typedef util::vertex<G> graph_element;
+
+
+ /// Constructor without argument.
p_vertices();
+ /// Construct a graph psite set from a graph of points.
/// \param gr The graph upon which the graph psite set is built.
/// \param f the function which maps a vertex to a site.
- p_vertices(const graph_t& gr, const F& f);
+ p_vertices(const G& gr, const F& f);
/// \}
+
/// Associated types.
/// \{
+
/// Element associated type.
typedef mln_site(super_) element;
+
/// Point_Site associated type.
typedef internal::vertex_psite<G, F> psite;
@@ -98,8 +110,10 @@
/// Site_Iterator associated type.
typedef fwd_piter piter;
+
/// \}
+
/// \brief Return The number of points (sites) of the set, i.e.,
/// the number of \em vertices.
///
@@ -109,8 +123,9 @@
/// Return The number of vertices in the graph.
unsigned nvertices() const;
- /// Is this site set valid?
+ /// Test this site set validity.
bool is_valid() const;
+
/// Invalidate this site set.
void invalidate();
@@ -134,13 +149,13 @@
/// Accessors.
/// \{
/// Return the graph associated to this site set (const version)
- const graph_t& graph() const;
+ const G& graph() const;
/// Return the association function.
const F& function() const;
/// \}
private:
- mlc_const(graph_t)* g_;
+ const G* g_;
F f_;
};
@@ -182,7 +197,7 @@
template <typename G, typename F>
inline
- p_vertices<G, F>::p_vertices(const graph_t& g, const F& f)
+ p_vertices<G, F>::p_vertices(const G& g, const F& f)
: g_ (&g), f_(f)
{
}
@@ -282,7 +297,7 @@
template <typename G, typename F>
inline
- const typename p_vertices<G, F>::graph_t&
+ const G&
p_vertices<G, F>::graph() const
{
mln_precondition(is_valid());
Index: mln/core/site_set/p_edges.hh
--- mln/core/site_set/p_edges.hh (revision 2886)
+++ mln/core/site_set/p_edges.hh (working copy)
@@ -58,27 +58,32 @@
template <typename G, typename F>
class p_edges
- : public internal::site_set_base_< typename F::result, p_edges<G, F> >
+ : public internal::site_set_base_< mln_result(F), p_edges<G, F> >
{
- typedef util::edge<G> edge_t;
typedef p_edges<G, F> self_;
- typedef internal::site_set_base_< typename F::result, self_ > super_;
+ typedef internal::site_set_base_< mln_result(F), self_ > super_;
public:
- /// Type of the graph this site set is based on.
- typedef G graph_t;
- /// \brief Construct a graph edge psite set from a graph and a function.
+ /// Type of graph edge.
+ typedef util::edge<G> edge;
+
+ /// Type of graph element this site set focuses on.
+ typedef util::edge<G> graph_element;
+
+
+ /// Construct a graph edge psite set from a graph and a function.
///
/// \param gr The graph upon which the graph edge psite set is built.
/// \param f the function mapping edges and sites.
- p_edges(const graph_t& gr, const F& f);
+ p_edges(const G& gr, const F& f);
/// Associated types.
/// \{
/// Element associated type.
typedef mln_site(super_) element;
+
/// Point_Site associated type.
typedef internal::edge_psite<G, F> psite;
@@ -117,13 +122,14 @@
/// Accessors.
/// \{
/// Return the graph associated to this site set
- const graph_t& graph() const;
+ const G& graph() const;
/// Return the mapping function.
const F& function() const;
/// \}
private:
- mlc_const(graph_t)* g_;
+
+ const G* g_;
F f_;
};
@@ -155,7 +161,7 @@
template <typename G, typename F>
inline
- p_edges<G, F>::p_edges(const graph_t& g, const F& f)
+ p_edges<G, F>::p_edges(const G& g, const F& f)
: g_ (&g), f_(f)
{
}
@@ -223,7 +229,7 @@
template <typename G, typename F>
inline
- const typename p_edges<G, F>::graph_t&
+ const G&
p_edges<G, F>::graph() const
{
mln_precondition(is_valid());
Index: mln/core/concept/graph.hh
--- mln/core/concept/graph.hh (revision 2886)
+++ mln/core/concept/graph.hh (working copy)
@@ -109,7 +109,7 @@
//typedef mln_bkd_piter(E) bkd_piter;
// Check methods
- const void * const(E::*m1)() const = & E::graph_id;
+ const void* (E::*m1)() const = & E::graph_id;
m1 = 0;
unsigned (E::*m2)(unsigned id_e, unsigned id_v) const = & E::v_other;
m2 = 0;
Index: mln/util/graph.hh
--- mln/util/graph.hh (revision 2886)
+++ mln/util/graph.hh (working copy)
@@ -30,19 +30,21 @@
# define MLN_UTIL_GRAPH_HH
/// \file mln/util/graph.hh
-/// Definitions of undirected graphs.
+///
+/// Definition of a basic undirected graph.
# include <mln/util/internal/graph_base.hh>
# include <mln/util/internal/graph_iter.hh>
# include <mln/util/internal/graph_nbh_iter.hh>
# include <mln/util/ord_pair.hh>
+
namespace mln
{
namespace util
{
- /// Fwd declaration.
+ /// Forward declaration.
class graph;
}
@@ -134,6 +136,8 @@
graph();
+
+
/// Vertex oriented.
/// \{
/// Shortcuts factoring the insertion of vertices and edges.
@@ -173,7 +177,6 @@
-
/// Edge oriented.
/// \{
/// Add an edge.
@@ -219,6 +222,9 @@
} // end of namespace mln
+
+
+
# ifndef MLN_INCLUDE_ONLY
namespace mln
Index: mln/util/internal/graph_iter.hh
--- mln/util/internal/graph_iter.hh (revision 2886)
+++ mln/util/internal/graph_iter.hh (working copy)
@@ -148,6 +148,8 @@
friend class graph_iter_base<G, util::edge<G>, edge_bkd_iterator<G> >;
};
+
+
# ifndef MLN_INCLUDE_ONLY
/*--------------------`
@@ -290,9 +292,9 @@
# endif // !MLN_INCLUDE_ONLY
- } // End of namespace mln::internal
+ } // end of namespace mln::internal
-} // End of namespace mln
+} // end of namespace mln
#endif // !MLN_UTIL_INTERNAL_GRAPH_ITER_HH
Index: mln/util/internal/graph_edge.hh
--- mln/util/internal/graph_edge.hh (revision 2886)
+++ mln/util/internal/graph_edge.hh (working copy)
@@ -28,11 +28,12 @@
#ifndef MLN_UTIL_INTERNAL_GRAPH_EDGE_HH
# define MLN_UTIL_INTERNAL_GRAPH_EDGE_HH
+/// \file mln/util/internal/graph_edge.hh
+///
+/// Definition of a graph edge.
+
# include <mln/util/internal/graph_edge_impl.hh>
-/*! \file mln/util/internal/graph_edge.hh
- * \brief Definition of a graph edge.
- */
namespace mln
{
@@ -44,22 +45,23 @@
| Edge. |
`-------*/
- /// \brief Edge of a graph \p G.
+ /// Edge of a graph \p G.
template <typename G>
class edge : public internal::edge_impl_<G>
{
- typedef mlc_unconst(G) graph_t;
-
public:
+
+ /// Graph associated type.
+ typedef G graph_t;
+
/// Constructors
/// \{
edge();
- explicit edge(const graph_t& g);
- edge(const graph_t& g, unsigned id);
+ explicit edge(const G& g);
+ edge(const G& g, unsigned id);
/// \}
-
/// Misc.
/// \{
/// Return whether is points to a known edge.
@@ -74,14 +76,13 @@
void update_id(unsigned id);
/// Return a reference to the graph holding this edge.
- const graph_t& graph() const;
+ const G& graph() const;
/// Set g_ with \p g;
- void change_graph(const graph_t& g);
+ void change_graph(const G& g);
/// \}
-
/// Vertex and edges oriented.
/// \{
/// Return the vertex id of this edge which is different from \p id_v.
@@ -105,13 +106,13 @@
/// \}
private:
- graph_t g_;
+ G g_;
unsigned id_;
};
template <typename G>
std::ostream&
- operator<<(std::ostream& ostr, edge<G>& p);
+ operator<<(std::ostream& ostr, const edge<G>& p);
template <typename G>
bool
@@ -174,23 +175,24 @@
template <typename G>
inline
edge<G>::edge()
- : id_(0)
{
+ invalidate();
}
template <typename G>
inline
- edge<G>::edge(const graph_t& g)
- : g_(g), id_(g.e_nmax())
+ edge<G>::edge(const G& g)
+ : g_(g)
{
+ invalidate();
}
template <typename G>
inline
- edge<G>::edge(const graph_t& g, unsigned id)
+ edge<G>::edge(const G& g, unsigned id)
: g_(g), id_(id)
{
- mln_precondition(g.has_e(id));
+ mln_precondition(/* FIXME: g_.is_valid() && */ g.has_e(id));
}
template <typename G>
@@ -211,7 +213,7 @@
template <typename G>
inline
- const typename edge<G>::graph_t&
+ const typename edge<G>::G&
edge<G>::graph() const
{
return g_;
@@ -220,7 +222,7 @@
template <typename G>
inline
void
- edge<G>::change_graph(const graph_t& g)
+ edge<G>::change_graph(const G& g)
{
g_ = g;
}
@@ -230,7 +232,7 @@
bool
edge<G>::is_valid() const
{
- return g_.has_e(id_);
+ return /* FIXME: g_.is_valid() && */ g_.has_e(id_);
}
template <typename G>
@@ -238,7 +240,7 @@
void
edge<G>::invalidate()
{
- id_ = g_.e_nmax();
+ id_ = mln_max(unsigned);
}
@@ -289,7 +291,7 @@
template <typename G>
std::ostream&
- operator<<(std::ostream& ostr, edge<G>& p)
+ operator<<(std::ostream& ostr, const edge<G>& p)
{
return ostr << p.id();
}
Index: mln/util/internal/graph_edge_psite.hh
--- mln/util/internal/graph_edge_psite.hh (revision 2886)
+++ mln/util/internal/graph_edge_psite.hh (working copy)
@@ -28,67 +28,56 @@
#ifndef MLN_UTIL_INTERNAL_GRAPH_EDGE_PSITE_HH
# define MLN_UTIL_INTERNAL_GRAPH_EDGE_PSITE_HH
-# include <mln/core/concept/pseudo_site.hh>
+/// \file mln/util/internal/graph_edge_psite.hh
+///
+/// Implementation of p_edges psite.
+
# include <mln/util/internal/graph_psite_base.hh>
# include <mln/util/internal/graph_edge.hh>
+
namespace mln
{
+ // Forward declaration.
template <typename G, typename F> class p_edges;
-} // end of namespace mln
-
-/// \file mln/util/internal/graph_edge_psite.hh
-/// \brief Implementation of p_edges psite.
-
-namespace mln
-{
namespace internal
{
+
template <typename G, typename F>
class edge_psite :
- public graph_psite_base<util::edge<G>, typename F::result,
- p_edges<G, F>,
+ public graph_psite_base< p_edges<G,F>,
edge_psite<G, F> >
{
typedef edge_psite<G, F> self_;
- typedef p_edges<G, F> target_t;
- typedef graph_psite_base<util::edge<G>, typename F::result, target_t, self_> super_;
- typedef util::edge<G> edge_t;
+ typedef graph_psite_base<p_edges<G,F>, self_> super_;
public:
- /// Associated Types
- /// \{
- /// Site type, the return type of the mapping function \p F here.
- typedef typename F::result site;
- /// \}
/// Constructors
/// \{
edge_psite();
- edge_psite(const target_t& t);
- edge_psite(const target_t& t, unsigned);
+ edge_psite(const p_edges<G,F>& s);
+ edge_psite(const p_edges<G,F>& s, unsigned);
/// \}
/// Accessors
/// \{
/// Return the underlying edge.
- const edge_t& e() const;
+ const util::edge<G>& e() const;
/// \}
-
- protected:
- /// The underlying edge (inherited).
- using super_::v_;
};
- } // end of namespace internal
+
+ } // end of namespace mln::internal
} // end of namespace mln
+
# ifndef MLN_INCLUDE_ONLY
namespace mln
@@ -105,24 +94,24 @@
template <typename G, typename F>
inline
- edge_psite<G, F>::edge_psite(const target_t& t)
- : super_(t)
+ edge_psite<G, F>::edge_psite(const p_edges<G,F>& s)
+ : super_(s)
{
}
template <typename G, typename F>
inline
- edge_psite<G, F>::edge_psite(const target_t& t, unsigned id)
- : super_(t, id)
+ edge_psite<G, F>::edge_psite(const p_edges<G,F>& s, unsigned id)
+ : super_(s, id)
{
}
template <typename G, typename F>
inline
- const typename edge_psite<G, F>::edge_t&
+ const util::edge<G>&
edge_psite<G, F>::e() const
{
- return v_;
+ return this->v_;
}
} // end of namespace internal
Index: mln/util/internal/graph_base.hh
--- mln/util/internal/graph_base.hh (revision 2886)
+++ mln/util/internal/graph_base.hh (working copy)
@@ -83,7 +83,7 @@
/// Misc. methods
/// \{
/// Returns the graph id, the "this" pointer.
- const void * const graph_id() const;
+ const void* graph_id() const;
/// \}
/// Vertex oriented methods
@@ -158,10 +158,10 @@
template<typename E>
inline
- const void * const
+ const void*
graph_base<E>::graph_id() const
{
- return static_cast<const void * const>(data_.ptr_);
+ return static_cast<const void*>(data_.ptr_);
}
/*-------------------------.
Index: mln/util/internal/graph_vertex.hh
--- mln/util/internal/graph_vertex.hh (revision 2886)
+++ mln/util/internal/graph_vertex.hh (working copy)
@@ -31,7 +31,10 @@
# include <mln/util/internal/graph_vertex_impl.hh>
/// \file mln/util/internal/graph_vertex.hh
-/// \brief Implementation of a graph vertex.
+///
+/// Implementation of a graph vertex.
+
+
namespace mln
{
@@ -39,19 +42,20 @@
namespace util
{
- /// \brief Vertex of a graph \p G.
+ /// Vertex of a graph \p G.
template<typename G>
class vertex : public internal::vertex_impl_<G>
{
- typedef mlc_unconst(G) graph_t;
-
public:
+ /// Graph associated type.
+ typedef G graph_t;
+
/// Constructors.
/// \{
vertex();
- explicit vertex(const graph_t& g);
- vertex(const graph_t& g, unsigned id);
+ explicit vertex(const G& g);
+ vertex(const G& g, unsigned id);
/// \}
/// Check whether the vertex is still part of the graph.
@@ -78,17 +82,17 @@
/// Change the parent graph of that vertex.
void change_graph(const G& g);
- /// Update vertex id.
+ /// Update the vertex id.
void update_id(unsigned id);
/// Returns the graph pointer this vertex belongs to.
- const graph_t& graph() const;
+ const G& graph() const;
- /// Returns vertex id.
+ /// Returns the vertex id.
unsigned id() const;
protected:
- graph_t g_;
+ G g_;
unsigned id_;
};
@@ -173,23 +177,24 @@
template <typename G>
inline
vertex<G>::vertex()
- : id_(0)
{
+ invalidate();
}
template <typename G>
inline
- vertex<G>::vertex(const graph_t& g)
- : g_(g), id_(g_.v_nmax())
+ vertex<G>::vertex(const G& g)
+ : g_(g)
{
+ invalidate();
}
template<typename G>
inline
- vertex<G>::vertex(const graph_t& g, unsigned id)
+ vertex<G>::vertex(const G& g, unsigned id)
: g_(g), id_(id)
{
- mln_precondition(g_.has_v(id));
+ mln_precondition(/* FIXME: g_.is_valid() && */ g_.has_v(id));
}
template<typename G>
@@ -197,7 +202,7 @@
bool
vertex<G>::is_valid() const
{
- return g_.has_v(id_);
+ return /* FIXME: g_.is_valid() && */ g_.has_v(id_);
}
template<typename G>
@@ -205,7 +210,7 @@
void
vertex<G>::invalidate()
{
- id_ = g_.v_nmax();
+ id_ = mln_max(unsigned);
}
@@ -274,7 +279,7 @@
template<typename G>
inline
- const typename vertex<G>::graph_t&
+ const typename vertex<G>::G&
vertex<G>::graph() const
{
return g_;
Index: mln/util/internal/graph_psite_base.hh
--- mln/util/internal/graph_psite_base.hh (revision 2886)
+++ mln/util/internal/graph_psite_base.hh (working copy)
@@ -28,6 +28,10 @@
#ifndef MLN_UTIL_INTERNAL_GRAPH_PSITE_BASE_HH
# define MLN_UTIL_INTERNAL_GRAPH_PSITE_BASE_HH
+/// \file mln/util/internal/graph_psite_base.hh
+///
+/// Base implementation for graph based psites.
+
# include <mln/core/concept/pseudo_site.hh>
namespace mln
@@ -37,8 +41,6 @@
} // end of namespace mln
-/// \file mln/util/internal/graph_psite_base.hh
-/// \brief Base implementation for graph based psites.
namespace mln
{
@@ -46,41 +48,43 @@
namespace internal
{
- template <typename V, typename P, typename S, typename E>
- class graph_psite_base : public mln::Pseudo_Site<E>,
- public internal::proxy_impl<const P&, E>
+ template <typename S, typename E>
+ class graph_psite_base : public internal::pseudo_site_base_< const mln_site(S)&,
+ E >
{
- typedef Pseudo_Site< graph_psite_base<V, P, S, E> > super;
- typedef typename S::graph_t graph_t;
+ typedef Pseudo_Site< graph_psite_base<S,E> > super;
public:
- /// Associated types.
- /// \{
- typedef P site;
+
+ // This associated type is important to know that this particular
+ // pseudo site knows the site set it refers to.
typedef S target;
- /// \}
+
+ // As a Proxy:
+ const mln_site(S)& subj_();
+
/// Setters.
/// \{
/// Change the targe site set.
- void change_target(const target& new_target);
+ void change_target(const S& new_target);
/// Update the underlying element's id.
/// This element can be an edge, a vertex...
- void update_id(unsigned v_id);
+ void update_id(unsigned elt_id);
/// \}
/// Getters.
/// \{
/// Return the target (the site set).
- const target* target_() const; // Hook to the target.
+ const S* target_() const; // Hook to the target.
/// Return the site set (the target).
- const target& site_set() const;
+ const S& site_set() const;
/// Return the graph associated to the target of this psite.
- const graph_t& graph() const;
+ const typename S::graph_t& graph() const;
- /// Return the graph associated to the target of this psite.
+ /// Return the id of the graph element designated by this psite.
unsigned id() const;
/// \}
@@ -90,38 +94,30 @@
/// Invalidate this psite.
void invalidate();
- /// Pseudo site Interface
- /// \{
- /// Subject type.
- typedef const site& q_subject;
- /// Return the subject.
- const site& subj_();
- /// Return the underlying site.
- const site& to_site() const;
- /// \}
+ /// Conversion towards the graph element (vertex or edge).
+ operator const typename S::graph_element&() const;
protected:
+
/// Constructors.
+
/// \{
graph_psite_base();
/// \p t A site set.
/// \sa p_vertices, p_edges.
- graph_psite_base(const target& t);
+ graph_psite_base(const S& s);
/// \p t A site set.
/// \sa p_vertices, p_edges.
/// \p id The id of the element associated to this psite.
- graph_psite_base(const target& t, unsigned id);
+ graph_psite_base(const S& , unsigned id);
/// \}
- mlc_const(target)* t_;
- V v_;
+ const S* s_;
+ typename S::graph_element elt_;
};
- template <typename V, typename P, typename S, typename E>
- std::ostream&
- operator<<(std::ostream& ostr, graph_psite_base<V, P, S, E>& p);
- /// Comparison of two mln::graph_psite_base<V, P, S, E> instances.
+ /// Comparison of two mln::graph_psite_base<S,E> instances.
/// \{
/* FIXME: Shouldn't those comparisons be part of a much general
mechanism? */
@@ -130,17 +126,17 @@
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
/// mln::p_vertices.
- template <typename V, typename P, typename S, typename E>
+ template <typename S, typename E>
bool
- operator==(const graph_psite_base<V, P, S, E>& lhs, const graph_psite_base<V, P, S, E>& rhs);
+ operator==(const graph_psite_base<S,E>& lhs, const graph_psite_base<S,E>& rhs);
/// \brief Is \a lhs not equal to \a rhs?
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
/// mln::p_vertices.
- template <typename V, typename P, typename S, typename E>
+ template <typename S, typename E>
bool
- operator!=(const graph_psite_base<V, P, S, E>& lhs, const graph_psite_base<V, P, S, E>& rhs);
+ operator!=(const graph_psite_base<S,E>& lhs, const graph_psite_base<S,E>& rhs);
/// \brief Is \a lhs ``less'' than \a rhs?
///
@@ -148,9 +144,9 @@
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
/// mln::p_vertices.
- template <typename V, typename P, typename S, typename E>
+ template <typename S, typename E>
bool
- operator< (const graph_psite_base<V, P, S, E>& lhs, const graph_psite_base<V, P, S, E>& rhs);
+ operator< (const graph_psite_base<S,E>& lhs, const graph_psite_base<S,E>& rhs);
/// \}
} // end of namespace internal
@@ -158,6 +154,7 @@
} // end of namespace mln
+
# ifndef MLN_INCLUDE_ONLY
namespace mln
@@ -166,143 +163,137 @@
namespace internal
{
- template <typename V, typename P, typename S, typename E>
+ template <typename S, typename E>
inline
- graph_psite_base<V, P, S, E>::graph_psite_base()
- : t_(0)
+ graph_psite_base<S,E>::graph_psite_base()
+ : s_(0)
{
}
- template <typename V, typename P, typename S, typename E>
+ template <typename S, typename E>
inline
- graph_psite_base<V, P, S, E>::graph_psite_base(const target& t)
- : t_(0)
+ graph_psite_base<S,E>::graph_psite_base(const S& s)
{
- change_target(t);
+ change_target(s);
}
- template <typename V, typename P, typename S, typename E>
+ template <typename S, typename E>
inline
- graph_psite_base<V, P, S, E>::graph_psite_base(const target& t, unsigned id)
- : t_(0)
+ graph_psite_base<S,E>::graph_psite_base(const S& s, unsigned id)
{
- change_target(t);
+ change_target(s);
update_id(id);
}
- template <typename V, typename P, typename S, typename E>
+ template <typename S, typename E>
inline
void
- graph_psite_base<V, P, S, E>::change_target(const target& new_target)
+ graph_psite_base<S,E>::change_target(const S& new_target)
{
- t_ = &new_target;
- v_.change_graph(new_target.graph());
+ s_ = & new_target;
+ elt_.change_graph(new_target.graph());
}
- template <typename V, typename P, typename S, typename E>
+ template <typename S, typename E>
inline
void
- graph_psite_base<V, P, S, E>::update_id(unsigned id)
+ graph_psite_base<S,E>::update_id(unsigned id)
{
- v_.update_id(id);
+ elt_.update_id(id);
}
- template <typename v, typename p, typename s, typename e>
+ template <typename S, typename E>
inline
- const typename graph_psite_base<v, p, s, e>::target*
- graph_psite_base<v, p, s, e>::target_() const
+ const S*
+ graph_psite_base<S,E>::target_() const
{
- return t_;
+ return s_;
}
- template <typename v, typename p, typename s, typename e>
+ template <typename S, typename E>
inline
- const typename graph_psite_base<v, p, s, e>::target&
- graph_psite_base<v, p, s, e>::site_set() const
+ const S&
+ graph_psite_base<S,E>::site_set() const
{
- return *t_;
+ mln_precondition(s_ != 0);
+ return *s_;
}
- template <typename v, typename p, typename s, typename e>
+ template <typename S, typename E>
inline
- const typename graph_psite_base<v, p, s, e>::graph_t&
- graph_psite_base<v, p, s, e>::graph() const
+ const typename S::graph_t&
+ graph_psite_base<S,E>::graph() const
{
- return t_->graph();
+ mln_precondition(s_ != 0);
+ return s_->graph();
}
- template <typename v, typename p, typename s, typename e>
+ template <typename S, typename E>
inline
unsigned
- graph_psite_base<v, p, s, e>::id() const
+ graph_psite_base<S,E>::id() const
{
- return v_.id();
+ return elt_.id();
}
- template <typename V, typename P, typename S, typename E>
+ template <typename S, typename E>
inline
bool
- graph_psite_base<V, P, S, E>::is_valid() const
+ graph_psite_base<S,E>::is_valid() const
{
- return t_ != 0 && t_->is_valid() && v_.is_valid();
+ return s_ != 0 && s_->is_valid() && elt_.is_valid();
}
- template <typename V, typename P, typename S, typename E>
+ template <typename S, typename E>
inline
void
- graph_psite_base<V, P, S, E>::invalidate()
+ graph_psite_base<S,E>::invalidate()
{
- t_ = 0;
- v_.invalidate();
+ s_ = 0;
+ elt_.invalidate();
}
- template <typename V, typename P, typename S, typename E>
+ template <typename S, typename E>
inline
- const typename graph_psite_base<V, P, S, E>::site&
- graph_psite_base<V, P, S, E>::subj_()
+ const mln_site(S)&
+ graph_psite_base<S,E>::subj_()
{
- return to_site();
+ mln_precondition(s_ != 0);
+ return s_->function()(elt_.id());
}
- template <typename V, typename P, typename S, typename E>
+ template <typename S, typename E>
inline
- const typename graph_psite_base<V, P, S, E>::site&
- graph_psite_base<V, P, S, E>::to_site() const
+ graph_psite_base<S,E>::operator const typename S::graph_element&() const
{
- return t_->function()(v_.id());
+ mln_precondition(is_valid());
+ return elt_;
}
- template <typename V, typename P, typename S, typename E>
- std::ostream&
- operator<<(std::ostream& ostr, graph_psite_base<V, P, S, E>& p)
- {
- return ostr << p.unproxy_();
- }
-
/*--------------.
| Comparisons. |
`--------------*/
- template <typename V, typename P, typename S, typename E>
+ template <typename S, typename E>
bool
- operator==(const graph_psite_base<V, P, S, E>& lhs, const graph_psite_base<V, P, S, E>& rhs)
+ operator==(const graph_psite_base<S,E>& lhs, const graph_psite_base<S,E>& rhs)
{
mln_assertion(lhs.target_() == rhs.target_());
return lhs.id() == rhs.id();
}
- template <typename V, typename P, typename S, typename E>
+ template <typename S, typename E>
bool
- operator!=(const graph_psite_base<V, P, S, E>& lhs, const graph_psite_base<V, P, S, E>& rhs)
+ operator!=(const graph_psite_base<S,E>& lhs, const graph_psite_base<S,E>& rhs)
{
mln_assertion(lhs.target_() == rhs.target_());
return lhs.id() != rhs.id();
}
- template <typename V, typename P, typename S, typename E>
+ template <typename S, typename E>
bool
- operator< (const graph_psite_base<V, P, S, E>& lhs, const graph_psite_base<V, P, S, E>& rhs)
+ operator< (const graph_psite_base<S,E>& lhs, const graph_psite_base<S,E>& rhs)
{
mln_assertion(lhs.target_() == rhs.target_());
return lhs.id() < rhs.id();
Index: mln/util/internal/graph_vertex_psite.hh
--- mln/util/internal/graph_vertex_psite.hh (revision 2886)
+++ mln/util/internal/graph_vertex_psite.hh (working copy)
@@ -28,55 +28,51 @@
#ifndef MLN_UTIL_INTERNAL_GRAPH_VERTEX_PSITE_HH
# define MLN_UTIL_INTERNAL_GRAPH_VERTEX_PSITE_HH
+/// \file mln/util/internal/graph_vertex_psite.hh
+///
+/// Implementation of p_vertices psite.
+
# include <mln/core/concept/pseudo_site.hh>
# include <mln/util/internal/graph_psite_base.hh>
# include <mln/util/internal/graph_vertex.hh>
+
namespace mln
{
+ // Forward declaration.
template <typename G, typename F> class p_vertices;
-} // end of namespace mln
-
-/// \file mln/util/internal/graph_vertex_psite.hh
-/// \brief Implementation of p_vertices psite.
-
-namespace mln
-{
namespace internal
{
+
template <typename G, typename F>
class vertex_psite :
- public graph_psite_base<util::vertex<G>, typename F::result,
- p_vertices<G, F>,
+ public graph_psite_base< p_vertices<G,F>,
vertex_psite<G, F> >
{
typedef vertex_psite<G, F> self_;
- typedef p_vertices<G, F> target_t;
- typedef graph_psite_base<util::vertex<G>, typename F::result, target_t, self_> super_;
- typedef util::vertex<G> vertex_t;
+ typedef graph_psite_base<p_vertices<G,F>, self_> super_;
public:
- typedef typename F::result site;
vertex_psite();
- vertex_psite(const target_t& t);
- vertex_psite(const target_t& t, unsigned id);
+ vertex_psite(const p_vertices<G,F>& s);
+ vertex_psite(const p_vertices<G,F>& s, unsigned id);
- const vertex_t& v() const;
-
- protected:
- using super_::v_;
+ const util::vertex<G>& v() const;
};
- } // end of namespace internal
+
+ } // end of namespace mln::internal
} // end of namespace mln
+
+
# ifndef MLN_INCLUDE_ONLY
namespace mln
@@ -93,24 +89,24 @@
template <typename G, typename F>
inline
- vertex_psite<G, F>::vertex_psite(const target_t& t)
- : super_(t)
+ vertex_psite<G, F>::vertex_psite(const p_vertices<G,F>& s)
+ : super_(s)
{
}
template <typename G, typename F>
inline
- vertex_psite<G, F>::vertex_psite(const target_t& t, unsigned i)
- : super_(t, i)
+ vertex_psite<G, F>::vertex_psite(const p_vertices<G,F>& s, unsigned i)
+ : super_(s, i)
{
}
template <typename G, typename F>
inline
- const typename vertex_psite<G, F>::vertex_t&
+ const util::vertex<G>&
vertex_psite<G, F>::v() const
{
- return v_;
+ return this->v_;
}
} // end of namespace internal
Index: mln/util/internal/graph_iter_base.hh
--- mln/util/internal/graph_iter_base.hh (revision 2886)
+++ mln/util/internal/graph_iter_base.hh (working copy)
@@ -28,12 +28,17 @@
#ifndef MLN_UTIL_INTERNAL_GRAPH_ITER_BASE_HH
# define MLN_UTIL_INTERNAL_GRAPH_ITER_BASE_HH
+/// \file mln/util/internal/graph_iter_base.hh
+///
+/// Base implementation for graph iterators.
+///
+/// \todo Have special types for ids (vertex_id) to disambiguate the
+/// conversion op.
+
# include <mln/core/concept/iterator.hh>
# include <mln/core/concept/proxy.hh>
# include <mln/util/internal/graph_edge.hh>
-/// \file mln/util/internal/graph_iter_base.hh
-/// \brief Base implementation for graph iterators.
namespace mln
{
@@ -41,10 +46,10 @@
namespace internal
{
- template <typename G, typename P, typename E>
+ template <typename G, typename Elt, typename E>
class graph_iter_base
: public Proxy< E >,
- public internal::proxy_impl< const P&, E >
+ public internal::proxy_impl< const Elt&, E >
{
public:
/// Iterator interface
@@ -67,80 +72,80 @@
operator unsigned() const;
/// \}
- /// Proxy.
- /// \{
/// Proxy subject
- const P& subj_();
- /// \}
+ const Elt& subj_();
protected:
graph_iter_base(const G& g);
- P p_;
+ Elt p_;
};
+
# ifndef MLN_INCLUDE_ONLY
- template <typename G, typename P, typename E>
+ template <typename G, typename Elt, typename E>
inline
- graph_iter_base<G, P, E>::graph_iter_base(const G& g)
- : p_(P(g))
+ graph_iter_base<G, Elt, E>::graph_iter_base(const G& g)
+ : p_(Elt(g))
{
invalidate();
}
- template <typename G, typename P, typename E>
+ template <typename G, typename Elt, typename E>
inline
bool
- graph_iter_base<G, P, E>::is_valid() const
+ graph_iter_base<G, Elt, E>::is_valid() const
{
return p_.is_valid();
}
- template <typename G, typename P, typename E>
+ template <typename G, typename Elt, typename E>
inline
void
- graph_iter_base<G, P, E>::invalidate()
+ graph_iter_base<G, Elt, E>::invalidate()
{
p_.invalidate();
+ mln_postcondition(! is_valid());
}
- template <typename G, typename P, typename E>
+ template <typename G, typename Elt, typename E>
inline
void
- graph_iter_base<G, P, E>::start()
+ graph_iter_base<G, Elt, E>::start()
{
p_.update_id(exact(this)->start_id_());
}
- template <typename G, typename P, typename E>
+ template <typename G, typename Elt, typename E>
inline
void
- graph_iter_base<G, P, E>::next()
+ graph_iter_base<G, Elt, E>::next()
{
+ mln_precondition(is_valid());
p_.update_id(exact(this)->next_id_());
}
- template <typename G, typename P, typename E>
+ template <typename G, typename Elt, typename E>
inline
unsigned
- graph_iter_base<G, P, E>::index() const
+ graph_iter_base<G, Elt, E>::index() const
{
return p_.id();
}
- template <typename G, typename P, typename E>
+ template <typename G, typename Elt, typename E>
inline
- graph_iter_base<G, P, E>::operator unsigned() const
+ graph_iter_base<G, Elt, E>::operator unsigned() const
{
return p_.id();
}
- template <typename G, typename P, typename E>
+ template <typename G, typename Elt, typename E>
inline
- const P&
- graph_iter_base<G, P, E>::subj_()
+ const Elt&
+ graph_iter_base<G, Elt, E>::subj_()
{
return p_;
}
1
0
17 Nov '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Use unmeta and handle accu object when needed.
* mln/level/compute.hh,
* mln/accu/compute.hh,
* mln/morpho/elementary/like_ero_fun.hh,
* mln/labeling/compute.hh: Use unmeta.
* mln/accu/transform_directional.hh,
* mln/accu/transform_diagonal.hh,
* mln/accu/transform_snake.hh: Handle the accu object.
(FIXME): Remove.
* mln/accu/transform_stop.hh: Layout.
accu/compute.hh | 7 +++---
accu/transform_diagonal.hh | 44 +++++++++++++++-----------------------
accu/transform_directional.hh | 20 ++++++++---------
accu/transform_snake.hh | 26 ++++++++++++----------
labeling/compute.hh | 16 ++++++++-----
level/compute.hh | 8 ++++--
morpho/elementary/like_ero_fun.hh | 12 +++++-----
7 files changed, 67 insertions(+), 66 deletions(-)
Index: mln/level/compute.hh
--- mln/level/compute.hh (revision 2885)
+++ mln/level/compute.hh (working copy)
@@ -94,10 +94,12 @@
template <typename A, typename I>
inline
mln_accu_with(A, mln_value(I))::result
- compute(const Meta_Accumulator<A>&, const Image<I>& input)
+ compute(const Meta_Accumulator<A>& a, const Image<I>& input)
{
- mln_accu_with(A, mln_value(I)) accu;
- return level::compute(accu, input); // Call the previous version.
+ typedef mln_accu_with(A, mln_value(I)) A_;
+ A_ a_ = accu::unmeta(exact(a), mln_value(I)());
+
+ return level::compute(a_, input); // Call the previous version.
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/accu/transform_directional.hh
--- mln/accu/transform_directional.hh (revision 2885)
+++ mln/accu/transform_directional.hh (working copy)
@@ -58,14 +58,14 @@
template <typename A, typename I, typename W>
mln_ch_value(I, mln_result(A))
- transform_directional(const Accumulator<A>&,
+ transform_directional(const Accumulator<A>& a,
const Image<I>& input, const Window<W>& win,
unsigned dir);
template <typename A, typename I, typename W>
mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
- transform_directional(const Meta_Accumulator<A>&,
+ transform_directional(const Meta_Accumulator<A>& a,
const Image<I>& input, const Window<W>& win,
unsigned dir);
@@ -135,10 +135,10 @@
q_l,
q_r;
- directional_functor(const I& input, const W& win, int dir)
+ directional_functor(const I& input, const W& win, const A& a, int dir)
: input(input),
win(win),
- accu(),
+ accu(a),
dir(dir),
win_left(win::shift(win, -dp_directional<dpsite>(dir)) - win),
win_right(win - win::shift(win, -dp_directional<dpsite>(dir))),
@@ -202,10 +202,10 @@
mln_qixter(const I, window2d) q_l, q_r;
- directional_fastest_functor(const I& input, const W& win, unsigned dir)
+ directional_fastest_functor(const I& input, const W& win, const A& a, unsigned dir)
: input(input),
win(win),
- accu(),
+ accu(a),
dir(dir),
win_left(win::shift(win, -dp_directional<dpsite>(dir)) - win),
win_right(win - win::shift(win, -dp_directional<dpsite>(dir))),
@@ -254,12 +254,12 @@
inline
mln_ch_value(I, mln_result(A))
transform_directional_dispatch(trait::image::speed::any,
- const Accumulator<A>& /* FIXME a */,
+ const Accumulator<A>& a,
const Image<I>& input, const Window<W>& win,
unsigned dir)
{
typedef directional_functor<I, W, A> F;
- F f(exact(input), exact(win), dir); // FIXME: Pass a to f.
+ F f(exact(input), exact(win), exact(a), dir);
canvas::browsing::directional(f);
return f.output;
}
@@ -268,12 +268,12 @@
inline
mln_ch_value(I, mln_result(A))
transform_directional_dispatch(trait::image::speed::fastest,
- const Accumulator<A>& /* FIXME a*/,
+ const Accumulator<A>& a,
const Image<I>& input, const Window<W>& win,
unsigned dir)
{
typedef directional_fastest_functor<I, W, A> F;
- F f(exact(input), exact(win), dir); // FIXME: Pass a to f.
+ F f(exact(input), exact(win), exact(a), dir);
canvas::browsing::directional(f);
return f.output;
}
Index: mln/accu/transform_diagonal.hh
--- mln/accu/transform_diagonal.hh (revision 2885)
+++ mln/accu/transform_diagonal.hh (working copy)
@@ -62,13 +62,13 @@
template <typename A, typename I, typename W>
mln_ch_value(I, mln_result(A))
- transform_diagonal(const Accumulator<A>&,
+ transform_diagonal(const Accumulator<A>& a,
const Image<I>& input, const Window<W>& win);
template <typename A, typename I, typename W>
mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
- transform_diagonal(const Meta_Accumulator<A>&,
+ transform_diagonal(const Meta_Accumulator<A>& a,
const Image<I>& input, const Window<W>& win);
@@ -114,17 +114,15 @@
mln_psite(I) p;
enum { dim = I::site::dim };
- unsigned dir;
window2d win_left, win_right;
mln_qiter(window2d) q_l, q_r;
- diagonal_functor(const I& input, const W& win)
+ diagonal_functor(const I& input, const W& win, const A& a)
: input(input),
win(win),
- accu(),
- dir(dir),
+ accu(a),
win_left(win::shift(win, dpsite(1, -1)) - win),
win_right(win - win::shift(win, dpsite(1, -1))),
q_l(win_left, p),
@@ -178,17 +176,15 @@
mln_psite(I) p;
enum { dim = I::site::dim };
- unsigned dir;
window2d win_left, win_right;
mln_qiter(window2d) q_l, q_r;
- backdiagonal_functor(const I& input, const W& win)
+ backdiagonal_functor(const I& input, const W& win, const A& a)
: input(input),
win(win),
- accu(),
- dir(dir),
+ accu(a),
win_left(win::shift(win, dpsite(-1, -1)) - win),
win_right(win - win::shift(win, dpsite(-1, -1))),
q_l(win_left, p),
@@ -245,17 +241,15 @@
mln_psite(I) p;
enum { dim = I::site::dim };
- unsigned dir;
window2d win_left, win_right;
mln_qixter(const I, window2d) q_l, q_r;
- diagonal_fastest_functor(const I& input, const W& win)
+ diagonal_fastest_functor(const I& input, const W& win, const A& a)
: input(input),
win(win),
- accu(),
- dir(dir),
+ accu(a),
win_left(win::shift(win, dpsite(1, -1)) - win),
win_right(win - win::shift(win, dpsite(1, -1))),
q_l(input, win_left, p),
@@ -308,17 +302,15 @@
mln_psite(I) p;
enum { dim = I::site::dim };
- unsigned dir;
window2d win_left, win_right;
mln_qixter(const I, window2d) q_l, q_r;
- backdiagonal_fastest_functor(const I& input, const W& win)
+ backdiagonal_fastest_functor(const I& input, const W& win, const A& a)
: input(input),
win(win),
- accu(),
- dir(dir),
+ accu(a),
win_left(win::shift(win, dpsite(-1, -1)) - win),
win_right(win - win::shift(win, dpsite(-1, -1))),
q_l(input, win_left, p),
@@ -366,11 +358,11 @@
inline
mln_ch_value(I, mln_result(A))
transform_diagonal_dispatch(trait::image::speed::any,
- const Accumulator<A>& /* FIXME a */,
+ const Accumulator<A>& a,
const Image<I>& input, const win::diag2d& win)
{
typedef diagonal_functor<I, win::diag2d, A> F;
- F f(exact(input), win); // FIXME: Pass a to f.
+ F f(exact(input), win, exact(a));
canvas::browsing::diagonal2d(f);
return f.output;
}
@@ -379,11 +371,11 @@
inline
mln_ch_value(I, mln_result(A))
transform_diagonal_dispatch(trait::image::speed::any,
- const Accumulator<A>& /* FIXME a */,
+ const Accumulator<A>& a,
const Image<I>& input, const win::backdiag2d& win)
{
typedef backdiagonal_functor<I, win::backdiag2d, A> F;
- F f(exact(input), win); // FIXME: Pass a to f.
+ F f(exact(input), win, exact(a));
canvas::browsing::backdiagonal2d(f);
return f.output;
}
@@ -392,11 +384,11 @@
inline
mln_ch_value(I, mln_result(A))
transform_diagonal_dispatch(trait::image::speed::fastest,
- const Accumulator<A>& /* FIXME a*/,
+ const Accumulator<A>& a,
const Image<I>& input, const win::diag2d& win)
{
typedef diagonal_fastest_functor<I, win::diag2d, A> F;
- F f(exact(input), win); // FIXME: Pass a to f.
+ F f(exact(input), win, exact(a));
canvas::browsing::diagonal2d(f);
return f.output;
}
@@ -405,11 +397,11 @@
inline
mln_ch_value(I, mln_result(A))
transform_diagonal_dispatch(trait::image::speed::fastest,
- const Accumulator<A>& /* FIXME a*/,
+ const Accumulator<A>& a,
const Image<I>& input, const win::backdiag2d& win)
{
typedef backdiagonal_fastest_functor<I, win::backdiag2d, A> F;
- F f(exact(input), win); // FIXME: Pass a to f.
+ F f(exact(input), win, exact(a));
canvas::browsing::backdiagonal2d(f);
return f.output;
}
Index: mln/accu/transform_stop.hh
Index: mln/accu/transform_snake.hh
--- mln/accu/transform_snake.hh (revision 2885)
+++ mln/accu/transform_snake.hh (working copy)
@@ -60,12 +60,12 @@
template <typename A, typename I, typename W>
mln_ch_value(I, mln_result(A))
- transform_snake(const Accumulator<A>&, const Image<I>& input, const Window<W>& win);
+ transform_snake(const Accumulator<A>& a, const Image<I>& input, const Window<W>& win);
template <typename A, typename I, typename W>
mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
- transform_snake(const Meta_Accumulator<A>&, const Image<I>& input, const Window<W>& win);
+ transform_snake(const Meta_Accumulator<A>& a, const Image<I>& input, const Window<W>& win);
@@ -101,9 +101,10 @@
const I& input;
const W& win;
- mln_ch_value(I, mln_result(A)) output;
A accu;
+ mln_ch_value(I, mln_result(A)) output;
+
mln_psite(I) p;
window2d
@@ -129,10 +130,10 @@
std::vector<move_fun> moves;
std::vector<dpsite> dps;
- transform_snake_functor(const Image<I>& input, const Window<W>& win)
+ transform_snake_functor(const Image<I>& input, const Window<W>& win, const Accumulator<A>& a)
: input(exact(input)),
win(exact(win)),
- accu(),
+ accu(exact(a)),
win_left_fwd(win::shift(win, mln::left) - win),
win_right_fwd(win - win::shift(win, mln::left)),
@@ -253,9 +254,10 @@
const I& input;
const W& win;
- mln_ch_value(I, mln_result(A)) output;
A accu;
+ mln_ch_value(I, mln_result(A)) output;
+
mln_psite(I) p;
window2d
@@ -282,10 +284,10 @@
std::vector<move_fun> moves;
std::vector<dpsite> dps;
- transform_snake_fastest_functor(const I& input, const W& win)
+ transform_snake_fastest_functor(const I& input, const W& win, const A& a)
: input(input),
win(win),
- accu(),
+ accu(a),
win_left_fwd(win::shift(win, mln::left) - win),
win_right_fwd(win - win::shift(win, mln::left)),
@@ -394,11 +396,11 @@
inline
mln_ch_value(I, mln_result(A))
transform_snake_dispatch(trait::image::speed::any,
- const Accumulator<A>& /* FIXME a */,
+ const Accumulator<A>& a,
const Image<I>& input, const Window<W>& win)
{
typedef transform_snake_functor<I, W, A> F;
- F f(exact(input), exact(win)); // FIXME: Pass a to f.
+ F f(exact(input), exact(win), exact(a));
canvas::browsing::snake_generic(f);
return f.output;
}
@@ -407,11 +409,11 @@
inline
mln_ch_value(I, mln_result(A))
transform_snake_dispatch(trait::image::speed::fastest,
- const Accumulator<A>& /* FIXME a*/,
+ const Accumulator<A>& a,
const Image<I>& input, const Window<W>& win)
{
typedef transform_snake_fastest_functor<I, W, A> F;
- F f(exact(input), exact(win)); // FIXME: Pass a to f.
+ F f(exact(input), exact(win), exact(a));
canvas::browsing::snake_generic(f);
return f.output;
}
Index: mln/accu/compute.hh
--- mln/accu/compute.hh (revision 2885)
+++ mln/accu/compute.hh (working copy)
@@ -142,15 +142,16 @@
template <typename A, typename I>
inline
mln_accu_with(A, util::pix<I>)::result
- compute(const Meta_Accumulator<A>&, const Image<I>& input)
+ compute(const Meta_Accumulator<A>& a, const Image<I>& input)
{
trace::entering("accu::compute");
mln_precondition(exact(input).has_data());
typedef mln_accu_with(A, util::pix<I>) A_;
- A_ a;
- mln_result(A_) output = internal::compute_dispatch(a, input);
+ A_ a_ = accu::unmeta(exact(a), util::pix<I>());
+
+ mln_result(A_) output = internal::compute_dispatch(a_, input);
trace::exiting("accu::compute");
return output;
Index: mln/morpho/elementary/like_ero_fun.hh
--- mln/morpho/elementary/like_ero_fun.hh (revision 2885)
+++ mln/morpho/elementary/like_ero_fun.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
@@ -48,7 +48,7 @@
template <typename A, typename F,
typename I, typename N>
mln_concrete(I)
- like_ero_fun(const Meta_Accumulator<A>&, const F& f,
+ like_ero_fun(const Meta_Accumulator<A>& a, const F& f,
const Image<I>& input, const Neighborhood<N>& nbh);
@@ -79,7 +79,7 @@
template <typename A, typename F,
typename I, typename N>
mln_concrete(I)
- like_ero_fun(const Meta_Accumulator<A>&, const F& f,
+ like_ero_fun(const Meta_Accumulator<A>& a_, const F& f,
const Image<I>& input_, const Neighborhood<N>& nbh_)
{
trace::entering("morpho::elementary::impl::generic::like_ero_fun");
@@ -87,7 +87,7 @@
const I& input = exact(input_);
const N& nbh = exact(nbh_);
- mln_accu_with(A, mln_value(I)) a;
+ mln_accu_with(A, mln_value(I)) a = accu::unmeta(exact(a_), mln_value(I)());
extension::adjust_fill(input, nbh, a);
mln_concrete(I) output;
@@ -113,7 +113,7 @@
template <typename A, typename F,
typename I, typename N>
mln_concrete(I)
- like_ero_fun_fastest(const Meta_Accumulator<A>&, const F& f,
+ like_ero_fun_fastest(const Meta_Accumulator<A>& a_, const F& f,
const Image<I>& input_, const Neighborhood<N>& nbh_)
{
trace::entering("morpho::elementary::impl::like_ero_fun_fastest");
@@ -121,7 +121,7 @@
const I& input = exact(input_);
const N& nbh = exact(nbh_);
- mln_accu_with(A, mln_value(I)) a;
+ mln_accu_with(A, mln_value(I)) a = accu::unmeta(exact(a_), mln_value(I)());
extension::adjust_fill(input, nbh, a);
mln_concrete(I) output;
Index: mln/labeling/compute.hh
--- mln/labeling/compute.hh (revision 2885)
+++ mln/labeling/compute.hh (working copy)
@@ -150,12 +150,14 @@
template <typename A, typename I, typename J>
inline
util::array<mln_accu_with(A, mln_value(I))::result>
- compute(const Meta_Accumulator<A>&,
+ compute(const Meta_Accumulator<A>& a,
const Image<I>& input,
const Image<J>& label, mln_value(J) nlabels)
{
- mln_accu_with(A, mln_value(I)) accu;
- return compute(accu, input, label, nlabels);
+ typedef mln_accu_with(A, mln_value(I)) A_;
+ A_ a_ = accu::unmeta(exact(a), mln_value(I)());
+
+ return compute(a_, input, label, nlabels);
}
@@ -190,11 +192,13 @@
template <typename A, typename J>
inline
util::array<mln_accu_with(A, mln_psite(J))::result>
- compute(const Meta_Accumulator<A>&,
+ compute(const Meta_Accumulator<A>& a,
const Image<J>& label, mln_value(J) nlabels)
{
- mln_accu_with(A, mln_psite(J)) accu;
- return compute(accu, label, nlabels);
+ typedef mln_accu_with(A, mln_psite(J)) A_;
+ A_ a_ = accu::unmeta(exact(a), mln_psite(J)());
+
+ return compute(a_, label, nlabels);
}
1
0
* mln/core/concept/graph.hh: does not force add_* methods.
* mln/util/dual_graph.hh: new class.
* mln/util/graph.hh: cleanup comments
* mln/util/internal/graph_edge.hh: add missing operator<<.
* mln/util/internal/graph_nbh_iter_base.hh,
* mln/util/internal/graph_iter_base.hh: add operator unsigned().
* tests/util/Makefile.am,
* tests/util/dual_graph.cc: Add a new test.
---
milena/ChangeLog | 18 ++
milena/mln/core/concept/graph.hh | 2 -
milena/mln/util/{graph.hh => dual_graph.hh} | 243 +++++++++++------------
milena/mln/util/graph.hh | 14 +-
milena/mln/util/internal/graph_edge.hh | 19 ++-
milena/mln/util/internal/graph_iter_base.hh | 11 +
milena/mln/util/internal/graph_nbh_iter_base.hh | 10 +
milena/tests/util/Makefile.am | 2 +
milena/tests/util/dual_graph.cc | 164 +++++++++++++++
9 files changed, 338 insertions(+), 145 deletions(-)
copy milena/mln/util/{graph.hh => dual_graph.hh} (58%)
create mode 100644 milena/tests/util/dual_graph.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index c947990..809f727 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,21 @@
+2008-11-17 Guillaume Lazzara <guillaume.lazzara(a)lrde.epita.fr>
+
+ Introduce a dual graph class.
+
+ * mln/core/concept/graph.hh: does not force add_* methods.
+
+ * mln/util/dual_graph.hh: new class.
+
+ * mln/util/graph.hh: cleanup comments
+
+ * mln/util/internal/graph_edge.hh: add missing operator<<.
+
+ * mln/util/internal/graph_nbh_iter_base.hh,
+ * mln/util/internal/graph_iter_base.hh: add operator unsigned().
+
+ * tests/util/Makefile.am,
+ * tests/util/dual_graph.cc: Add a new test.
+
2008-11-14 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Factor code for erosion on lines.
diff --git a/milena/mln/core/concept/graph.hh b/milena/mln/core/concept/graph.hh
index c98d9e5..e89acc2 100644
--- a/milena/mln/core/concept/graph.hh
+++ b/milena/mln/core/concept/graph.hh
@@ -113,8 +113,6 @@ namespace mln
m1 = 0;
unsigned (E::*m2)(unsigned id_e, unsigned id_v) const = & E::v_other;
m2 = 0;
- unsigned (E::*m3)() = & E::add_vertex;
- m3 = 0;
size_t (E::*m4)() const = & E::v_nmax;
m4 = 0;
bool (E::*m5)(unsigned id_v) const = & E::has_v;
diff --git a/milena/mln/util/graph.hh b/milena/mln/util/dual_graph.hh
similarity index 58%
copy from milena/mln/util/graph.hh
copy to milena/mln/util/dual_graph.hh
index dfcbc23..3533e7c 100644
--- a/milena/mln/util/graph.hh
+++ b/milena/mln/util/dual_graph.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 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
@@ -26,10 +26,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_UTIL_GRAPH_HH
-# define MLN_UTIL_GRAPH_HH
+#ifndef MLN_UTIL_DUAL_GRAPH_HH
+# define MLN_UTIL_DUAL_GRAPH_HH
-/// \file mln/util/graph.hh
+/// \file mln/util/dual_graph.hh
/// Definitions of undirected graphs.
# include <mln/util/internal/graph_base.hh>
@@ -43,7 +43,8 @@ namespace mln
namespace util
{
/// Fwd declaration.
- class graph;
+ template <typename G>
+ class dual_graph;
}
@@ -51,23 +52,22 @@ namespace mln
{
/// Data structure for \c mln::image2d<T>.
- template <>
- struct data<util::graph>
+ template <typename G>
+ struct data< util::dual_graph<G> >
{
- typedef util::graph G;
+
typedef std::vector<std::vector<unsigned> > vertices_t;
typedef std::vector<util::ord_pair<unsigned> > edges_t;
- typedef std::set<util::ord_pair<unsigned> > edges_set_t;
data();
+ data(const G& g);
~data();
+ G g_;
/// The vertices.
vertices_t vertices_;
/// The edges.
edges_t edges_;
- /// An index of the set of edges, for fast-access purpose.
- edges_set_t edges_set_;
};
} // end of namespace mln::internal
@@ -76,14 +76,18 @@ namespace mln
namespace util
{
- /// \brief Undirected graph.
- class graph : public internal::graph_base<graph>
+ /// Undirected dual graph of a graph of type \tparam G.
+ template <typename G>
+ class dual_graph : public internal::graph_base< dual_graph<G> >
{
/// The super class.
- typedef internal::graph_base<graph> super;
+ typedef internal::graph_base< dual_graph<G> > super;
- using super::vertex_data_t;
- using super::edge_data_t;
+ typedef typename super::vertex_t vertex_t;
+ typedef typename super::edge_t edge_t;
+
+ typedef typename super::vertex_data_t vertex_data_t;
+ typedef typename super::edge_data_t edge_data_t;
public:
/// The type of the set of vertices.
@@ -91,71 +95,46 @@ namespace mln
/// The type of the set of edges.
typedef std::vector<edge_data_t> edges_t;
- /// A set to test the presence of a given edge.
- typedef std::set<edge_data_t> edges_set_t;
/// Iterator types
/// \{
/// Vertex iterators
/// \{
- typedef mln::internal::vertex_fwd_iterator<graph> vertex_fwd_iter;
- typedef mln::internal::vertex_bkd_iterator<graph> vertex_bkd_iter;
+ typedef mln::internal::vertex_fwd_iterator< dual_graph<G> >
+ vertex_fwd_iter;
+ typedef mln::internal::vertex_bkd_iterator< dual_graph<G> >
+ vertex_bkd_iter;
typedef vertex_fwd_iter vertex_iter;
- /// \}
- /// Vertex centered edge iterators
- /// \{
- typedef mln::internal::vertex_nbh_edge_fwd_iterator<graph> vertex_nbh_edge_fwd_iter;
- typedef mln::internal::vertex_nbh_edge_bkd_iterator<graph> vertex_nbh_edge_bkd_iter;
- typedef vertex_nbh_edge_fwd_iter vertex_nbh_edge_iter;
- /// \}
-
- /// Vertex centered vertex iterators
- /// \{
- typedef mln::internal::vertex_nbh_vertex_fwd_iterator<graph> vertex_nbh_vertex_fwd_iter;
- typedef mln::internal::vertex_nbh_vertex_bkd_iterator<graph> vertex_nbh_vertex_bkd_iter;
- typedef vertex_nbh_vertex_fwd_iter vertex_nbh_vertex_iter;
- /// \}
-
- /// Edge iterators
- /// \{
- typedef mln::internal::edge_fwd_iterator<graph> edge_fwd_iter;
- typedef mln::internal::edge_bkd_iterator<graph> edge_bkd_iter;
+ typedef mln::internal::edge_fwd_iterator< dual_graph<G> >
+ edge_fwd_iter;
+ typedef mln::internal::edge_bkd_iterator< dual_graph<G> >
+ edge_bkd_iter;
typedef edge_fwd_iter edge_iter;
- /// \}
- /// Edge centered edge iterators.
- /// \{
- typedef mln::internal::edge_nbh_edge_fwd_iterator<graph> edge_nbh_edge_fwd_iter;
- typedef mln::internal::edge_nbh_edge_bkd_iterator<graph> edge_nbh_edge_bkd_iter;
- typedef edge_nbh_edge_fwd_iter edge_nbh_edge_iter;
/// \}
/// \}
- graph();
+ dual_graph();
+ dual_graph(const G& g);
/// Vertex oriented.
/// \{
/// Shortcuts factoring the insertion of vertices and edges.
/// \{
- /// \brief Add a vertex.
- ///
- /// \return The id of the new vertex.
- unsigned add_vertex();
-
/// Return the vertex whose id is \a v.
/// \{
vertex_t vertex(unsigned id_v) const;
/// \}
- /// \brief Return the number of vertices in the graph.
+ /// Return the number of vertices in the graph.
size_t v_nmax() const;
/// Check whether a vertex id \p id_v exists in the graph.
bool has_v(unsigned id_v) const;
/// Check whether an edge \p v exists in the graph.
- template <typename G>
- bool has_v(const util::vertex<G>& v) const;
+ template <typename G2>
+ bool has_v(const util::vertex<G2>& v) const;
/// Return the number of adjacent edges of vertex \p id_v.
@@ -176,23 +155,17 @@ namespace mln
/// Edge oriented.
/// \{
- /// \brief Add an edge.
- ///
- /// \return The id of the new edge if it does not exist yet;
- /// otherwise, return <tt>mln_max(unsigned)</tt>.
- unsigned add_edge(unsigned id_v1, unsigned id_v2);
-
/// Return the edge whose id is \a e.
edge_t edge(unsigned e) const;
- /// \brief Return the number of edges in the graph.
+ /// Return the number of edges in the graph.
size_t e_nmax() const;
/// Return whether \p id_e is in the graph.
bool has_e(unsigned id_e) const;
/// Return whether \p e is in the graph.
- template <typename G>
- bool has_e(const util::edge<G>& e) const;
+ template <typename G2>
+ bool has_e(const util::edge<G2>& e) const;
/// Return the first vertex associated to the edge \p id_e.
@@ -213,6 +186,8 @@ namespace mln
bool is_subgraph_of(const G2& g) const;
/// \}
+ protected:
+ using super::data_;
};
} // end of namespace mln::util
@@ -227,13 +202,32 @@ namespace mln
namespace internal
{
+ template <typename G>
inline
- data<util::graph>::data()
+ data< util::dual_graph<G> >::data()
{
}
+ template <typename G>
inline
- data<util::graph>::~data()
+ data< util::dual_graph<G> >::data(const G& g)
+ {
+ g_ = g;
+ vertices_.resize(g.e_nmax());
+ mln_edge_iter(G) e(g);
+ mln_edge_nbh_edge_iter(G) ne(e);
+
+ for_all(e)
+ for_all(ne)
+ {
+ vertices_[e].push_back(edges_.size());
+ edges_.push_back(util::ord_pair<unsigned>(e, ne));
+ }
+ }
+
+ template <typename G>
+ inline
+ data< util::dual_graph<G> >::~data()
{
}
@@ -242,69 +236,73 @@ namespace mln
namespace util
{
+ template <typename G>
inline
- graph::graph()
+ dual_graph<G>::dual_graph()
{
- this->data_ = new mln::internal::data<util::graph>();
+ this->data_ = new mln::internal::data< util::dual_graph<G> >();
}
- /*---------------.
- | Vertex related |
- `---------------*/
-
+ template <typename G>
inline
- unsigned
- graph::add_vertex()
+ dual_graph<G>::dual_graph(const G& g)
{
- /* FIXME: This is not thread-proof (these two lines should
- form an atomic section). */
- data_->vertices_.resize(data_->vertices_.size() + 1);
-
- return v_nmax() - 1;
+ this->data_ = new mln::internal::data< util::dual_graph<G> >(g);
}
+ /*---------------.
+ | Vertex related |
+ `---------------*/
+
+ template <typename G>
inline
- graph::vertex_t
- graph::vertex(unsigned id_v) const
+ typename dual_graph<G>::vertex_t
+ dual_graph<G>::vertex(unsigned id_v) const
{
mln_assertion(has_v(id_v));
return vertex_t(*this, id_v);
}
+ template <typename G>
inline
size_t
- graph::v_nmax() const
+ dual_graph<G>::v_nmax() const
{
- return data_->vertices_.size();
+ return data_->g_.e_nmax();
}
+ template <typename G>
inline
bool
- graph::has_v(unsigned id_v) const
+ dual_graph<G>::has_v(unsigned id_v) const
{
- return id_v < data_->vertices_.size();
+ return data_->g_.has_e(id_v);
}
template <typename G>
+ template <typename G2>
inline
bool
- graph::has_v(const util::vertex<G>& v) const
+ dual_graph<G>::has_v(const util::vertex<G2>& v) const
{
+ //FIXME: not sure...
return v.graph().is_subgraph_of(*this) && has_v(v.id());
}
+ template <typename G>
inline
size_t
- graph::v_nmax_nbh_edges(unsigned id_v) const
+ dual_graph<G>::v_nmax_nbh_edges(unsigned id_v) const
{
mln_precondition(has_v(id_v));
- return data_->vertices_[id_v].size();
+ return data_->g_.e_nmax_nbh_edges(id_v);
}
+ template <typename G>
inline
unsigned
- graph::v_ith_nbh_edge(unsigned id_v, unsigned i) const
+ dual_graph<G>::v_ith_nbh_edge(unsigned id_v, unsigned i) const
{
mln_precondition(has_v(id_v));
if (i >= v_nmax_nbh_edges(id_v))
@@ -312,22 +310,24 @@ namespace mln
return data_->vertices_[id_v][i];
}
+ template <typename G>
inline
size_t
- graph::v_nmax_nbh_vertices(unsigned id_v) const
+ dual_graph<G>::v_nmax_nbh_vertices(unsigned id_v) const
{
mln_precondition(has_v(id_v));
return v_nmax_nbh_edges(id_v);
}
+ template <typename G>
inline
unsigned
- graph::v_ith_nbh_vertex(unsigned id_v, unsigned i) const
+ dual_graph<G>::v_ith_nbh_vertex(unsigned id_v, unsigned i) const
{
mln_precondition(has_v(id_v));
- unsigned id_e = v_ith_nbh_edge(id_v, i);
- return v_other(id_e, id_v);
+ unsigned id_e = this->v_ith_nbh_edge(id_v, i);
+ return this->v_other(id_e, id_v);
}
@@ -335,91 +335,71 @@ namespace mln
| Edges related |
`---------------*/
+ template <typename G>
inline
- unsigned
- graph::add_edge(unsigned id_v1, unsigned id_v2)
- {
- // Does this edge already exist in the graph?
- edge_data_t edge(id_v1, id_v2);
- if (data_->edges_set_.find(edge) != data_->edges_set_.end ())
- {
- // Return the erroneous value.
- return mln_max(unsigned);
- }
- else
- {
- // Otherwise insert it into the graph.
- /* FIXME: This is not thread-proof (these two lines should
- form an atomic section). */
- data_->edges_.push_back(edge);
- unsigned id = data_->edges_.size() - 1;
-
- // Update the set of edges.
- data_->edges_set_.insert(edge);
- data_->vertices_[edge.first()].push_back(id);
- data_->vertices_[edge.second()].push_back(id);
-
- return id;
- }
- }
-
- inline
- graph::edge_t
- graph::edge(unsigned e) const
+ typename dual_graph<G>::edge_t
+ dual_graph<G>::edge(unsigned e) const
{
mln_assertion(e < e_nmax());
return edge_t(*this, e);
}
+ template <typename G>
inline
size_t
- graph::e_nmax() const
+ dual_graph<G>::e_nmax() const
{
return data_->edges_.size();
}
+ template <typename G>
inline
bool
- graph::has_e(unsigned id_e) const
+ dual_graph<G>::has_e(unsigned id_e) const
{
return id_e < data_->edges_.size();
}
template <typename G>
+ template <typename G2>
inline
bool
- graph::has_e(const util::edge<G>& e) const
+ dual_graph<G>::has_e(const util::edge<G2>& e) const
{
return e.graph().is_subgraph_of(*this) && has_e(e.id());
}
+ template <typename G>
inline
unsigned
- graph::v1(unsigned id_e) const
+ dual_graph<G>::v1(unsigned id_e) const
{
mln_precondition(has_e(id_e));
return data_->edges_[id_e].first();
}
+ template <typename G>
inline
unsigned
- graph::v2(unsigned id_e) const
+ dual_graph<G>::v2(unsigned id_e) const
{
mln_precondition(has_e(id_e));
return data_->edges_[id_e].second();
}
+ template <typename G>
inline
size_t
- graph::e_nmax_nbh_edges(unsigned id_e) const
+ dual_graph<G>::e_nmax_nbh_edges(unsigned id_e) const
{
mln_precondition(has_e(id_e));
return v_nmax_nbh_edges(v1(id_e)) + v_nmax_nbh_edges(v2(id_e));
}
+ template <typename G>
inline
unsigned
- graph::e_ith_nbh_edge(unsigned id_e, unsigned i) const
+ dual_graph<G>::e_ith_nbh_edge(unsigned id_e, unsigned i) const
{
mln_precondition(has_e(id_e));
if (i >= e_nmax_nbh_edges(id_e))
@@ -432,10 +412,11 @@ namespace mln
}
+ template <typename G>
template <typename G2>
inline
bool
- graph::is_subgraph_of(const G2& g) const
+ dual_graph<G>::is_subgraph_of(const G2& g) const
{
return g.graph_id() == this->graph_id();
}
@@ -447,4 +428,4 @@ namespace mln
# endif // ! MLN_INCLUDE_ONLY
-#endif // ! MLN_UTIL_GRAPH_HH
+#endif // ! MLN_UTIL_DUAL_GRAPH_HH
diff --git a/milena/mln/util/graph.hh b/milena/mln/util/graph.hh
index dfcbc23..30b19bd 100644
--- a/milena/mln/util/graph.hh
+++ b/milena/mln/util/graph.hh
@@ -76,14 +76,14 @@ namespace mln
namespace util
{
- /// \brief Undirected graph.
+ /// Undirected graph.
class graph : public internal::graph_base<graph>
{
/// The super class.
typedef internal::graph_base<graph> super;
- using super::vertex_data_t;
- using super::edge_data_t;
+ typedef super::vertex_data_t vertex_data_t;
+ typedef super::edge_data_t edge_data_t;
public:
/// The type of the set of vertices.
@@ -138,7 +138,7 @@ namespace mln
/// \{
/// Shortcuts factoring the insertion of vertices and edges.
/// \{
- /// \brief Add a vertex.
+ /// Add a vertex.
///
/// \return The id of the new vertex.
unsigned add_vertex();
@@ -148,7 +148,7 @@ namespace mln
vertex_t vertex(unsigned id_v) const;
/// \}
- /// \brief Return the number of vertices in the graph.
+ /// Return the number of vertices in the graph.
size_t v_nmax() const;
/// Check whether a vertex id \p id_v exists in the graph.
@@ -176,7 +176,7 @@ namespace mln
/// Edge oriented.
/// \{
- /// \brief Add an edge.
+ /// Add an edge.
///
/// \return The id of the new edge if it does not exist yet;
/// otherwise, return <tt>mln_max(unsigned)</tt>.
@@ -185,7 +185,7 @@ namespace mln
/// Return the edge whose id is \a e.
edge_t edge(unsigned e) const;
- /// \brief Return the number of edges in the graph.
+ /// Return the number of edges in the graph.
size_t e_nmax() const;
/// Return whether \p id_e is in the graph.
diff --git a/milena/mln/util/internal/graph_edge.hh b/milena/mln/util/internal/graph_edge.hh
index 06e39d4..bab22d8 100644
--- a/milena/mln/util/internal/graph_edge.hh
+++ b/milena/mln/util/internal/graph_edge.hh
@@ -110,12 +110,16 @@ namespace mln
};
template <typename G>
+ std::ostream&
+ operator<<(std::ostream& ostr, edge<G>& p);
+
+ template <typename G>
bool
- operator==(const util::edge<G>& lhs, const util::edge<G>& rhs);
+ operator==(const edge<G>& lhs, const edge<G>& rhs);
template <typename G>
bool
- operator< (const util::edge<G>& lhs, const util::edge<G>& rhs);
+ operator< (const edge<G>& lhs, const edge<G>& rhs);
} // End of namespace mln::util
@@ -283,12 +287,17 @@ namespace mln
return g_.e_ith_nbh_edge(id_, i);
}
-
+ template <typename G>
+ std::ostream&
+ operator<<(std::ostream& ostr, edge<G>& p)
+ {
+ return ostr << p.id();
+ }
template <typename G>
inline
bool
- operator==(const util::edge<G>& lhs, const util::edge<G>& rhs)
+ operator==(const edge<G>& lhs, const edge<G>& rhs)
{
return lhs.pair_vertex_ == rhs.pair_vertex_;
}
@@ -296,7 +305,7 @@ namespace mln
template <typename G>
inline
bool
- operator< (const util::edge<G>& lhs, const util::edge<G>& rhs)
+ operator< (const edge<G>& lhs, const edge<G>& rhs)
{
return lhs.pair_vertex_ < rhs.pair_vertex_;
}
diff --git a/milena/mln/util/internal/graph_iter_base.hh b/milena/mln/util/internal/graph_iter_base.hh
index a901192..96777af 100644
--- a/milena/mln/util/internal/graph_iter_base.hh
+++ b/milena/mln/util/internal/graph_iter_base.hh
@@ -62,6 +62,9 @@ namespace mln
/// Return current index
unsigned index() const;
+
+ /// Conversion operator. Returns the element id.
+ operator unsigned() const;
/// \}
/// Proxy.
@@ -76,6 +79,7 @@ namespace mln
P p_;
};
+
# ifndef MLN_INCLUDE_ONLY
template <typename G, typename P, typename E>
@@ -128,6 +132,13 @@ namespace mln
template <typename G, typename P, typename E>
inline
+ graph_iter_base<G, P, E>::operator unsigned() const
+ {
+ return p_.id();
+ }
+
+ template <typename G, typename P, typename E>
+ inline
const P&
graph_iter_base<G, P, E>::subj_()
{
diff --git a/milena/mln/util/internal/graph_nbh_iter_base.hh b/milena/mln/util/internal/graph_nbh_iter_base.hh
index 14950a1..f6f02ea 100644
--- a/milena/mln/util/internal/graph_nbh_iter_base.hh
+++ b/milena/mln/util/internal/graph_nbh_iter_base.hh
@@ -61,6 +61,9 @@ namespace mln
/// Return current index
unsigned index() const;
+
+ /// Conversion operator. Returns the element ID.
+ operator unsigned() const;
/// \}
/// Proxy.
@@ -145,6 +148,13 @@ namespace mln
template <typename G, typename C, typename P, typename E>
inline
+ nbh_iterator_base<G, C, P, E>::operator unsigned() const
+ {
+ return p_.id();
+ }
+
+ template <typename G, typename C, typename P, typename E>
+ inline
const P&
nbh_iterator_base<G, C, P, E>::subj_()
{
diff --git a/milena/tests/util/Makefile.am b/milena/tests/util/Makefile.am
index d0fe4be..fcfb902 100644
--- a/milena/tests/util/Makefile.am
+++ b/milena/tests/util/Makefile.am
@@ -6,6 +6,7 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
branch_iter \
branch_iter_ind \
+ dual_graph \
eat \
graph \
lazy_set \
@@ -19,6 +20,7 @@ check_PROGRAMS = \
branch_iter_SOURCES = branch_iter.cc
branch_iter_ind_SOURCES = branch_iter_ind.cc
+dual_graph_SOURCES = dual_graph.cc
eat_SOURCES = eat.cc
graph_SOURCES = graph.cc
lazy_set_SOURCES = lazy_set.cc
diff --git a/milena/tests/util/dual_graph.cc b/milena/tests/util/dual_graph.cc
new file mode 100644
index 0000000..ff8c8ad
--- /dev/null
+++ b/milena/tests/util/dual_graph.cc
@@ -0,0 +1,164 @@
+// 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/util/dual_graph.cc
+/// test of mln::util::dual_graph
+
+#include <mln/util/graph.hh>
+#include <mln/util/dual_graph.hh>
+#include <iostream>
+
+int main ()
+{
+ using namespace mln;
+
+ util::graph g;
+
+ g.add_vertex (); // 0
+ g.add_vertex (); // 1
+ g.add_vertex (); // 2
+ g.add_vertex (); // 3
+ g.add_vertex (); // 4
+ g.add_vertex (); // 5
+ g.add_edge (0, 1);
+ g.add_edge (1, 0); // Not inserted twice
+ g.add_edge (0, 2);
+ g.add_edge (3, 4);
+ g.add_edge (4, 5);
+ g.add_edge (5, 4); // Not inserted twice
+ g.add_edge (5, 3);
+ g.add_edge (2, 1);
+
+ typedef util::dual_graph<util::graph> DG;
+ DG dg(g);
+
+ // Vertex iter and edge iter
+ {
+ unsigned i = 0;
+ mln_vertex_fwd_iter_(DG) v(dg);
+ for_all(v)
+ std::cout << v.index() << std::endl;
+// mln_assertion(i++ == v.index());
+ //mln_assertion(i != 0);
+
+ i = 0;
+ mln_edge_fwd_iter_(util::graph) e(g);
+ for_all(e)
+ std::cout << e << std::endl;
+// mln_assertion(i++ == e.index());
+// mln_assertion(i != 0);*/
+ }
+/* {
+ unsigned i = g.v_nmax() - 1;
+ mln_vertex_bkd_iter_(util::graph) v(g);
+ for_all(v)
+ mln_assertion(i-- == v.index());
+ mln_assertion(i != g.v_nmax() - 1);
+
+ i = g.e_nmax() - 1;
+ mln_edge_bkd_iter_(util::graph) e(g);
+ for_all(e)
+ mln_assertion(i-- == e.index());
+ mln_assertion(i != g.e_nmax() - 1);
+ }
+
+ // vertex iter + Edge nbh iter
+ {
+ mln_vertex_fwd_iter_(util::graph) v(g);
+ mln_vertex_nbh_edge_fwd_iter_(util::graph) n(v);
+ for_all(v)
+ {
+ unsigned i = 0;
+ for_all(n)
+ mln_assertion(i++ == n.index());
+ mln_assertion(i != 0);
+ }
+ }
+ {
+ mln_vertex_bkd_iter_(util::graph) v(g);
+ mln_vertex_nbh_edge_bkd_iter_(util::graph) e(v);
+ for_all(v)
+ {
+ unsigned i = v.nmax_nbh_edges();
+ for_all(e)
+ mln_assertion(--i == e.index());
+ mln_assertion((v.nmax_nbh_edges() == 0 && i == 0) || i != v.nmax_nbh_edges());
+ }
+ }
+
+ {
+ mln_edge_fwd_iter_(util::graph) e(g);
+ mln_edge_nbh_edge_fwd_iter_(util::graph) n(e);
+ for_all(e)
+ {
+ unsigned i = 0;
+ for_all(n)
+ ++i;
+ // we check i == e.nmax_nbh_edges() - 2 since e is it's own neighboor and the
+ // iterator skip it.
+ mln_assertion((i == 0 && e.nmax_nbh_edges() < 2) || i == e.nmax_nbh_edges() - 2);
+ }
+ }
+ {
+ mln_edge_bkd_iter_(util::graph) e(g);
+ mln_edge_nbh_edge_bkd_iter_(util::graph) n(e);
+ for_all(e)
+ {
+ //std::cout << "== e.id() = " << e.id() << std::endl;
+ unsigned i = e.nmax_nbh_edges();
+ for_all(n)
+ --i;
+ // we check i == e.nmax_nbh_edges() - 2 since e is it's own neighboor and the
+ // iterator skip it.
+ mln_assertion((i == e.nmax_nbh_edges() && e.nmax_nbh_edges() < 2) || i == 2);
+
+ }
+ }
+
+ {
+ mln_vertex_fwd_iter_(util::graph) v(g);
+ mln_vertex_nbh_vertex_fwd_iter_(util::graph) n(v);
+ for_all(v)
+ {
+ unsigned i = 0;
+ for_all(n)
+ ++i;
+ mln_assertion(i == v.nmax_nbh_vertices());
+ }
+ }
+ {
+ mln_vertex_bkd_iter_(util::graph) v(g);
+ mln_vertex_nbh_vertex_bkd_iter_(util::graph) n(v);
+ for_all(v)
+ {
+ unsigned i = v.nmax_nbh_vertices();
+ for_all(n)
+ --i;
+ mln_assertion(i == 0);
+ }
+ }*/
+}
--
1.5.6.5
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Factor code for erosion on lines.
* mln/accu/transform_directional.hh (include): Layout.
(output): Fix typedef.
* mln/accu/transform_diagonal.hh: Likewise.
Fix declaration signature.
* tests/accu/transform_directional.cc: New.
* tests/accu/transform_diagonal.cc: New.
* mln/accu/all.hh: Update.
* mln/morpho/erosion.spe.hh
(erosion_dispatch_wrt_win): Handle the case win.size == 1.
Remove useless qualif morpho::.
(erosion_dispatch_wrt_win): Factor code for hline2d and vline2d
into...
(erosion_dispatch_line): ...this new overloaded routine.
(erosion_dispatch_diagonal): Remove check on kind::logic cause it
also works on this case.
To be consistent:
* mln/accu/snake_2d.hh: Rename as...
* mln/accu/transform_snake.hh: ...this.
* mln/morpho/erosion.spe.hh (erosion_arbitrary_2d): Update.
* mln/morpho/includes.hh: Update.
* tests/accu/snake_2d.cc: Rename as...
* tests/accu/transform_snake.cc: ...this.
* tests/accu/Makefile.am: Update.
mln/accu/all.hh | 5 +-
mln/accu/transform_diagonal.hh | 15 +++---
mln/accu/transform_directional.hh | 5 +-
mln/accu/transform_snake.hh | 64 ++++++++++++++--------------
mln/morpho/erosion.spe.hh | 82 +++++++-----------------------------
mln/morpho/includes.hh | 3 -
tests/accu/Makefile.am | 8 ++-
tests/accu/transform_diagonal.cc | 23 +++++++---
tests/accu/transform_directional.cc | 12 +++--
tests/accu/transform_snake.cc | 8 +--
10 files changed, 98 insertions(+), 127 deletions(-)
Index: tests/accu/transform_snake.cc
--- tests/accu/transform_snake.cc (revision 2882)
+++ tests/accu/transform_snake.cc (working copy)
@@ -25,12 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/accu/snake_2d.cc
+/// \file tests/accu/transform_snake.cc
///
-/// Tests on mln::accu::snake_2d.
+/// Tests on mln::accu::transform_snake.
#include <mln/core/image/image2d.hh>
-#include <mln/accu/snake_2d.hh>
+#include <mln/accu/transform_snake.hh>
#include <mln/accu/count.hh>
#include <mln/win/rectangle2d.hh>
#include <mln/pw/all.hh>
@@ -45,7 +45,7 @@
win::rectangle2d rec(3, 3);
image2d<unsigned>
- out = accu::snake_2d(accu::meta::count(), ima, rec),
+ out = accu::transform_snake(accu::meta::count(), ima, rec),
ref(ima.domain());
mln_assertion(out == (pw::cst(rec.size()) | ima.domain()));
Property changes on: tests/accu/transform_snake.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/accu/transform_diagonal.cc
--- tests/accu/transform_diagonal.cc (revision 2882)
+++ tests/accu/transform_diagonal.cc (working copy)
@@ -25,14 +25,13 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/accu/snake_2d.cc
+/// \file tests/accu/transform_diagonal.cc
///
-/// Tests on mln::accu::snake_2d.
+/// Tests on mln::accu::transform_diagonal.
#include <mln/core/image/image2d.hh>
-#include <mln/accu/snake_2d.hh>
+#include <mln/accu/transform_diagonal.hh>
#include <mln/accu/count.hh>
-#include <mln/win/rectangle2d.hh>
#include <mln/pw/all.hh>
#include <mln/level/compare.hh>
@@ -42,11 +41,21 @@
using namespace mln;
image2d<int> ima(4, 5);
- win::rectangle2d rec(3, 3);
+ {
+ win::diag2d w(3);
image2d<unsigned>
- out = accu::snake_2d(accu::meta::count(), ima, rec),
+ out = accu::transform_diagonal(accu::meta::count(), ima, w),
ref(ima.domain());
+ mln_assertion(out == (pw::cst(w.size()) | ima.domain()));
+ }
+
+ {
+ win::backdiag2d w(3);
+ image2d<unsigned>
+ out = accu::transform_diagonal(accu::meta::count(), ima, w),
+ ref(ima.domain());
+ mln_assertion(out == (pw::cst(w.size()) | ima.domain()));
+ }
- mln_assertion(out == (pw::cst(rec.size()) | ima.domain()));
}
Property changes on: tests/accu/transform_diagonal.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/accu/Makefile.am
--- tests/accu/Makefile.am (revision 2882)
+++ tests/accu/Makefile.am (working copy)
@@ -19,8 +19,10 @@
nil \
pair \
rank \
- snake_2d \
transform \
+ transform_diagonal \
+ transform_directional \
+ transform_snake \
tuple
all_accus_SOURCES = all_accus.cc
@@ -39,8 +41,10 @@
nil_SOURCES = nil.cc
pair_SOURCES = pair.cc
rank_SOURCES = rank.cc
-snake_2d_SOURCES = snake_2d.cc
transform_SOURCES = transform.cc
+transform_diagonal_SOURCES = transform_diagonal.cc
+transform_directional_SOURCES = transform_directional.cc
+transform_snake_SOURCES = transform_snake.cc
tuple_SOURCES = tuple.cc
TESTS = $(check_PROGRAMS)
Index: tests/accu/transform_directional.cc
--- tests/accu/transform_directional.cc (revision 2882)
+++ tests/accu/transform_directional.cc (working copy)
@@ -25,12 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/accu/snake_2d.cc
+/// \file tests/accu/transform_directional.cc
///
-/// Tests on mln::accu::snake_2d.
+/// Tests on mln::accu::transform_directional.
#include <mln/core/image/image2d.hh>
-#include <mln/accu/snake_2d.hh>
+#include <mln/accu/transform_directional.hh>
#include <mln/accu/count.hh>
#include <mln/win/rectangle2d.hh>
#include <mln/pw/all.hh>
@@ -44,9 +44,11 @@
image2d<int> ima(4, 5);
win::rectangle2d rec(3, 3);
+ for (unsigned dir = 0; dir < 2; ++dir)
+ {
image2d<unsigned>
- out = accu::snake_2d(accu::meta::count(), ima, rec),
+ out = accu::transform_directional(accu::meta::count(), ima, rec, dir),
ref(ima.domain());
-
mln_assertion(out == (pw::cst(rec.size()) | ima.domain()));
}
+}
Property changes on: tests/accu/transform_directional.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/accu/transform_directional.hh
--- mln/accu/transform_directional.hh (revision 2882)
+++ mln/accu/transform_directional.hh (working copy)
@@ -40,6 +40,7 @@
#include <mln/core/concept/image.hh>
#include <mln/core/concept/meta_accumulator.hh>
#include <mln/core/alias/window2d.hh>
+# include <mln/win/diff.hh>
#include <mln/win/shift.hh>
#include <mln/geom/delta.hh>
#include <mln/literal/zero.hh>
@@ -119,7 +120,7 @@
const I& input;
const W& win;
- mln_concrete(I) output;
+ mln_ch_value(I, mln_result(A)) output;
A accu;
enum { dim = I::site::dim };
@@ -190,7 +191,7 @@
const I& input;
const W& win;
- mln_concrete(I) output;
+ mln_ch_value(I, mln_result(A)) output;
A accu;
mln_psite(I) p;
Index: mln/accu/all.hh
--- mln/accu/all.hh (revision 2882)
+++ mln/accu/all.hh (working copy)
@@ -80,9 +80,12 @@
// Routines.
# include <mln/accu/convolve.hh>
-# include <mln/accu/snake_2d.hh>
# include <mln/accu/transform.hh>
# include <mln/accu/transform_stop.hh>
+# include <mln/accu/transform_directional.hh>
+# include <mln/accu/transform_diagonal.hh>
+# include <mln/accu/transform_snake.hh>
+
#endif // ! MLN_ACCU_ALL_HH
Index: mln/accu/transform_diagonal.hh
--- mln/accu/transform_diagonal.hh (revision 2882)
+++ mln/accu/transform_diagonal.hh (working copy)
@@ -40,6 +40,7 @@
#include <mln/core/concept/image.hh>
#include <mln/core/concept/meta_accumulator.hh>
#include <mln/core/alias/window2d.hh>
+#include <mln/win/diff.hh>
#include <mln/win/shift.hh>
#include <mln/geom/delta.hh>
#include <mln/extension/adjust.hh>
@@ -62,15 +63,13 @@
template <typename A, typename I, typename W>
mln_ch_value(I, mln_result(A))
transform_diagonal(const Accumulator<A>&,
- const Image<I>& input, const Window<W>& win,
- unsigned dir);
+ const Image<I>& input, const Window<W>& win);
template <typename A, typename I, typename W>
mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
transform_diagonal(const Meta_Accumulator<A>&,
- const Image<I>& input, const Window<W>& win,
- unsigned dir);
+ const Image<I>& input, const Window<W>& win);
@@ -110,7 +109,7 @@
const I& input;
const W& win;
- mln_concrete(I) output;
+ mln_ch_value(I, mln_result(A)) output;
A accu;
mln_psite(I) p;
@@ -174,7 +173,7 @@
const I& input;
const W& win;
- mln_concrete(I) output;
+ mln_ch_value(I, mln_result(A)) output;
A accu;
mln_psite(I) p;
@@ -241,7 +240,7 @@
const I& input;
const W& win;
- mln_concrete(I) output;
+ mln_ch_value(I, mln_result(A)) output;
A accu;
mln_psite(I) p;
@@ -304,7 +303,7 @@
const I& input;
const W& win;
- mln_concrete(I) output;
+ mln_ch_value(I, mln_result(A)) output;
A accu;
mln_psite(I) p;
Index: mln/accu/transform_snake.hh
--- mln/accu/transform_snake.hh (revision 2882)
+++ mln/accu/transform_snake.hh (working copy)
@@ -25,15 +25,13 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_ACCU_SNAKE_2D_HH
-# define MLN_ACCU_SNAKE_2D_HH
+#ifndef MLN_ACCU_TRANSFORM_SNAKE_HH
+# define MLN_ACCU_TRANSFORM_SNAKE_HH
-/// \file mln/accu/snake_2d.hh
+/// \file mln/accu/transform_snake.hh
///
/// Run an accumulator in a snake-like browsing.
///
-/// \todo Rename as transform_snake_2d.
-///
/// \todo Make it n-D.
///
/// \todo Split dispatch and impl.
@@ -47,6 +45,8 @@
#include <mln/win/shift.hh>
#include <mln/geom/delta.hh>
#include <mln/extension/adjust.hh>
+
+# include <mln/canvas/browsing/snake_fwd.hh>
#include <mln/canvas/browsing/snake_generic.hh>
@@ -60,12 +60,12 @@
template <typename A, typename I, typename W>
mln_ch_value(I, mln_result(A))
- snake_2d(const Accumulator<A>&, const Image<I>& input, const Window<W>& win);
+ transform_snake(const Accumulator<A>&, const Image<I>& input, const Window<W>& win);
template <typename A, typename I, typename W>
mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
- snake_2d(const Meta_Accumulator<A>&, const Image<I>& input, const Window<W>& win);
+ transform_snake(const Meta_Accumulator<A>&, const Image<I>& input, const Window<W>& win);
@@ -76,7 +76,7 @@
template <typename I, typename W>
- void snake_2d_tests(const Image<I>& input_, const Window<W>& win_)
+ void transform_snake_tests(const Image<I>& input_, const Window<W>& win_)
{
const I& input = exact(input_);
const W& win = exact(win_);
@@ -93,9 +93,9 @@
// Functor.
template <typename I, typename W, typename A>
- struct snake_2d_functor
+ struct transform_snake_functor
{
- typedef snake_2d_functor<I,W, A> self;
+ typedef transform_snake_functor<I,W, A> self;
typedef void (self::*move_fun)();
typedef mln_deduce(I, psite, delta) dpsite;
@@ -129,7 +129,7 @@
std::vector<move_fun> moves;
std::vector<dpsite> dps;
- snake_2d_functor(const Image<I>& input, const Window<W>& win)
+ transform_snake_functor(const Image<I>& input, const Window<W>& win)
: input(exact(input)),
win(exact(win)),
accu(),
@@ -245,15 +245,15 @@
// Functor (fastest version).
template <typename I, typename W, typename A>
- struct snake_2d_fastest_functor
+ struct transform_snake_fastest_functor
{
- typedef snake_2d_fastest_functor<I,W,A> self;
+ typedef transform_snake_fastest_functor<I,W,A> self;
typedef void (self::*move_fun)();
typedef mln_deduce(I, psite, delta) dpsite;
const I& input;
const W& win;
- mln_concrete(I) output;
+ mln_ch_value(I, mln_result(A)) output;
A accu;
mln_psite(I) p;
@@ -282,7 +282,7 @@
std::vector<move_fun> moves;
std::vector<dpsite> dps;
- snake_2d_fastest_functor(const I& input, const W& win)
+ transform_snake_fastest_functor(const I& input, const W& win)
: input(input),
win(win),
accu(),
@@ -393,11 +393,11 @@
template <typename A, typename I, typename W>
inline
mln_ch_value(I, mln_result(A))
- snake_2d_dispatch(trait::image::speed::any,
+ transform_snake_dispatch(trait::image::speed::any,
const Accumulator<A>& /* FIXME a */,
const Image<I>& input, const Window<W>& win)
{
- typedef snake_2d_functor<I, W, A> F;
+ typedef transform_snake_functor<I, W, A> F;
F f(exact(input), exact(win)); // FIXME: Pass a to f.
canvas::browsing::snake_generic(f);
return f.output;
@@ -406,11 +406,11 @@
template <typename A, typename I, typename W>
inline
mln_ch_value(I, mln_result(A))
- snake_2d_dispatch(trait::image::speed::fastest,
+ transform_snake_dispatch(trait::image::speed::fastest,
const Accumulator<A>& /* FIXME a*/,
const Image<I>& input, const Window<W>& win)
{
- typedef snake_2d_fastest_functor<I, W, A> F;
+ typedef transform_snake_fastest_functor<I, W, A> F;
F f(exact(input), exact(win)); // FIXME: Pass a to f.
canvas::browsing::snake_generic(f);
return f.output;
@@ -419,10 +419,10 @@
template <typename A, typename I, typename W>
inline
mln_ch_value(I, mln_result(A))
- snake_2d_dispatch(const Accumulator<A>& a,
+ transform_snake_dispatch(const Accumulator<A>& a,
const Image<I>& input, const Window<W>& win)
{
- return snake_2d_dispatch(mln_trait_image_speed(I)(),
+ return transform_snake_dispatch(mln_trait_image_speed(I)(),
a, input, win);
}
@@ -434,18 +434,18 @@
template <typename A, typename I, typename W>
inline
mln_ch_value(I, mln_result(A))
- snake_2d(const Accumulator<A>& a,
+ transform_snake(const Accumulator<A>& a,
const Image<I>& input, const Window<W>& win)
{
- trace::entering("accu::snake_2d");
+ trace::entering("accu::transform_snake");
- internal::snake_2d_tests(input, win);
+ internal::transform_snake_tests(input, win);
extension::adjust(input, geom::delta(win) + 1);
mln_ch_value(I, mln_result(A)) output;
- output = internal::snake_2d_dispatch(a, input, win);
+ output = internal::transform_snake_dispatch(a, input, win);
- trace::exiting("accu::snake_2d");
+ trace::exiting("accu::transform_snake");
return output;
}
@@ -453,21 +453,21 @@
template <typename A, typename I, typename W>
inline
mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
- snake_2d(const Meta_Accumulator<A>& a,
+ transform_snake(const Meta_Accumulator<A>& a,
const Image<I>& input, const Window<W>& win)
{
- trace::entering("accu::snake_2d");
+ trace::entering("accu::transform_snake");
- internal::snake_2d_tests(input, win);
+ internal::transform_snake_tests(input, win);
typedef mln_accu_with(A, mln_value(I)) A_;
A_ a_ = accu::unmeta(exact(a), mln_value(I)());
extension::adjust(input, geom::delta(win) + 1);
mln_ch_value(I, mln_result(A_)) output;
- output = internal::snake_2d_dispatch(a_, input, win);
+ output = internal::transform_snake_dispatch(a_, input, win);
- trace::exiting("accu::snake_2d");
+ trace::exiting("accu::transform_snake");
return output;
}
@@ -479,4 +479,4 @@
} // end of namespace mln
-#endif // ! MLN_ACCU_SNAKE_2D_HH
+#endif // ! MLN_ACCU_TRANSFORM_SNAKE_HH
Index: mln/morpho/erosion.spe.hh
--- mln/morpho/erosion.spe.hh (revision 2882)
+++ mln/morpho/erosion.spe.hh (working copy)
@@ -39,18 +39,9 @@
# include <mln/win/octagon2d.hh>
# include <mln/win/rectangle2d.hh>
-# include <mln/win/shift.hh>
-# include <mln/win/diff.hh>
-
# include <mln/accu/min_h.hh>
# include <mln/accu/line.hh>
-# include <mln/canvas/browsing/snake_fwd.hh>
-# include <mln/canvas/browsing/snake_generic.hh>
-# include <mln/canvas/browsing/directional.hh>
-# include <mln/canvas/browsing/diagonal2d.hh>
-# include <mln/canvas/browsing/backdiagonal2d.hh>
-
/// \file mln/morpho/erosion.spe.hh
///
@@ -269,7 +260,7 @@
A a;
extension::adjust_fill(input, geom::delta(win) + 1, a);
- mln_concrete(I) output = accu::snake_2d(a, input, win);
+ mln_concrete(I) output = accu::transform_snake(a, input, win);
trace::exiting("morpho::impl:erosion_arbitrary_2d");
return output;
@@ -408,9 +399,10 @@
mln_concrete(I)
erosion_dispatch_wrt_win(const I& input, const win::rectangle2d& win)
{
+ if (win.size() == 1)
+ return clone(input);
if (win.size() <= 9) // FIXME: Hard-coded!
return erosion_dispatch_for_generic(input, win);
- else
return impl::erosion_rectangle2d(input, win);
}
@@ -420,74 +412,35 @@
erosion_dispatch_wrt_win(const I& input, const win::octagon2d& win)
{
if (win.length() < 5)
- return morpho::impl::erosion_arbitrary_2d(input, win);
+ return impl::erosion_arbitrary_2d(input, win);
else
return impl::erosion_octagon2d(input, win);
}
- /// Handling win::hline2d.
- /// \{
-
- template <typename I>
- mln_concrete(I)
- erosion_dispatch_wrt_win(metal::true_,
- const I& input, const win::hline2d& win)
- {
- return impl::erosion_directional(input, win, 1);
- }
-
- template <typename I>
- mln_concrete(I)
- erosion_dispatch_wrt_win(metal::false_,
- const I& input, const win::hline2d& win)
- {
- return erosion_dispatch_for_generic(input, win);
- }
-
- template <typename I>
- mln_concrete(I)
- erosion_dispatch_wrt_win(const I& input, const win::hline2d& win)
- {
- if (win.size() == 1)
- return clone(input);
- else if (win.size() == 3)
- return erosion_dispatch_for_generic(input, win);
- else
- {
- enum { test = mlc_is_a(mln_pset(I), Box)::value
- && mlc_equal(mln_trait_image_quant(I),
- mln::trait::image::quant::low)::value };
- return erosion_dispatch_wrt_win(metal::bool_<test>(),
- input, win);
- }
- }
-
- /// \}
-
- /// Handling win::vline2d.
+ /// Handling win::line(s).
/// \{
- template <typename I>
+ template <typename I, typename W>
mln_concrete(I)
- erosion_dispatch_wrt_win(metal::true_,
- const I& input, const win::vline2d& win)
+ erosion_dispatch_line(metal::true_,
+ const I& input, const W& win)
{
- return impl::erosion_directional(input, win, 0);
+ return impl::erosion_directional(input, win, W::dir);
}
- template <typename I>
+ template <typename I, typename W>
mln_concrete(I)
- erosion_dispatch_wrt_win(metal::false_,
- const I& input, const win::vline2d& win)
+ erosion_dispatch_line(metal::false_,
+ const I& input, const W& win)
{
return erosion_dispatch_for_generic(input, win);
}
- template <typename I>
+ template <typename I, typename M, unsigned i, typename C>
mln_concrete(I)
- erosion_dispatch_wrt_win(const I& input, const win::vline2d& win)
+ erosion_dispatch_wrt_win(const I& input, const win::line<M,i,C>& win)
{
if (win.size() == 1)
return clone(input);
@@ -498,7 +451,7 @@
enum { test = mlc_is_a(mln_pset(I), Box)::value
&& mlc_equal(mln_trait_image_quant(I),
mln::trait::image::quant::low)::value };
- return erosion_dispatch_wrt_win(metal::bool_<test>(),
+ return erosion_dispatch_line(metal::bool_<test>(),
input, win);
}
}
@@ -537,9 +490,7 @@
return erosion_dispatch_for_generic(input, win);
else
{
- enum { test = mlc_is_not(mln_trait_image_kind(I),
- mln::trait::image::kind::logic)::value
- && mlc_is_a(mln_pset(I), Box)::value
+ enum { test = mlc_is_a(mln_pset(I), Box)::value
&& mlc_equal(mln_trait_image_quant(I),
mln::trait::image::quant::low)::value };
return erosion_dispatch_diagonal(metal::bool_<test>(),
@@ -565,6 +516,7 @@
/// \}
+
// The dispatch entry point.
template <typename I, typename W>
Index: mln/morpho/includes.hh
--- mln/morpho/includes.hh (revision 2882)
+++ mln/morpho/includes.hh (working copy)
@@ -51,11 +51,12 @@
# include <mln/accu/max_h.hh>
# include <mln/accu/rank.hh>
-# include <mln/accu/snake_2d.hh>
# include <mln/accu/transform.hh>
# include <mln/accu/transform_stop.hh>
+
# include <mln/accu/transform_directional.hh>
# include <mln/accu/transform_diagonal.hh>
+# include <mln/accu/transform_snake.hh>
# include <mln/fun/v2v/saturate.hh>
1
0
cleanup-2008 2882: Move diagonal-related code out of erosion, then factor.
by Thierry Geraud 14 Nov '08
by Thierry Geraud 14 Nov '08
14 Nov '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Move diagonal-related code out of erosion, then factor.
* mln/accu/transform_diagonal.hh: New file.
* mln/morpho/erosion.spe.hh
(erosion_diagonal2d_functor),
(erosion_diagonal2d_fastest_functor),
(erosion_backdiagonal2d_functor),
(erosion_backdiagonal2d_fastest_functor): Move and rename as...
* mln/accu/transform_diagonal.hh
(diagonal_functor, diagonal_fastest_functor),
(backdiagonal_functor, backdiagonal_fastest_functor): ...these.
* mln/morpho/erosion.spe.hh (erosion_diagonal2d): Rename as...
(erosion_diagonal_2d): ...this; it is the only impl routine.
(erosion_backdiagonal2d),
(erosion_diagonal2d_fastest),
(erosion_backdiagonal2d_fastest): Remove these impl routines.
Thanks to factorization in accu::transform_diagonal, those are
now useless.
(erosion_dispatch_for_diagonal2d),
(erosion_dispatch_for_backdiagonal2d): Factor into...
(erosion_dispatch_diagonal): ...this new dispatch routine.
Now both diagonals are handled by the same code.
* mln/morpho/includes.hh: Update.
* mln/accu/transform_directional.hh
(diff): Remove useless include.
* mln/win/line.hh: Upgrade doc style.
(dir): New constant.
accu/transform_diagonal.hh | 481 ++++++++++++++++++++++++++++++++++++++++++
accu/transform_directional.hh | 1
morpho/erosion.spe.hh | 468 +++-------------------------------------
morpho/includes.hh | 1
win/line.hh | 17 -
5 files changed, 526 insertions(+), 442 deletions(-)
Index: mln/accu/transform_directional.hh
--- mln/accu/transform_directional.hh (revision 2881)
+++ mln/accu/transform_directional.hh (working copy)
@@ -40,7 +40,6 @@
#include <mln/core/concept/image.hh>
#include <mln/core/concept/meta_accumulator.hh>
#include <mln/core/alias/window2d.hh>
-#include <mln/win/diff.hh>
#include <mln/win/shift.hh>
#include <mln/geom/delta.hh>
#include <mln/literal/zero.hh>
Index: mln/accu/transform_diagonal.hh
--- mln/accu/transform_diagonal.hh (revision 0)
+++ mln/accu/transform_diagonal.hh (revision 0)
@@ -0,0 +1,481 @@
+// 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.
+
+#ifndef MLN_ACCU_TRANSFORM_DIAGONAL_HH
+# define MLN_ACCU_TRANSFORM_DIAGONAL_HH
+
+/// \file mln/accu/transform_diagonal.hh
+///
+/// Run an accumulator over a diagonal.
+///
+/// \todo Split dispatch and impl.
+///
+/// \todo Pass the accumulator to the function-object.
+
+
+#include <mln/core/concept/image.hh>
+#include <mln/core/concept/meta_accumulator.hh>
+#include <mln/core/alias/window2d.hh>
+#include <mln/win/shift.hh>
+#include <mln/geom/delta.hh>
+#include <mln/extension/adjust.hh>
+
+#include <mln/win/diag2d.hh>
+#include <mln/canvas/browsing/diagonal2d.hh>
+
+#include <mln/win/backdiag2d.hh>
+#include <mln/canvas/browsing/backdiagonal2d.hh>
+
+
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+
+ template <typename A, typename I, typename W>
+ mln_ch_value(I, mln_result(A))
+ transform_diagonal(const Accumulator<A>&,
+ const Image<I>& input, const Window<W>& win,
+ unsigned dir);
+
+
+ template <typename A, typename I, typename W>
+ mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
+ transform_diagonal(const Meta_Accumulator<A>&,
+ const Image<I>& input, const Window<W>& win,
+ unsigned dir);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+
+ // Tests.
+
+
+ template <typename I, typename W>
+ void transform_diagonal_tests(const Image<I>& input_, const Window<W>& win_)
+ {
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+
+ mln_precondition(input.has_data());
+ mln_precondition(! win.is_empty());
+ // mln_precondition(! win.is_valid());
+
+ (void) input;
+ (void) win;
+ }
+
+
+
+ // Functors.
+
+
+ template <typename I_, typename W, typename A>
+ struct diagonal_functor
+ {
+ typedef I_ I;
+ typedef mln_deduce(I, psite, delta) dpsite;
+
+ const I& input;
+ const W& win;
+ mln_concrete(I) output;
+ A accu;
+
+ mln_psite(I) p;
+ enum { dim = I::site::dim };
+ unsigned dir;
+
+ window2d win_left, win_right;
+
+ mln_qiter(window2d) q_l, q_r;
+
+ diagonal_functor(const I& input, const W& win)
+ : input(input),
+ win(win),
+ accu(),
+ dir(dir),
+ win_left(win::shift(win, dpsite(1, -1)) - win),
+ win_right(win - win::shift(win, dpsite(1, -1))),
+ q_l(win_left, p),
+ q_r(win_right, p)
+ {
+ }
+
+ void init()
+ {
+ initialize(output, input);
+ }
+
+ void next()
+ {
+ for_all(q_l)
+ accu.untake(input(q_l));
+ for_all(q_r)
+ accu.take(input(q_r));
+ output(p) = accu;
+ }
+
+
+ void init_diag()
+ {
+ accu.init();
+ p = p - dpsite(-1, 1);
+ mln_qiter(W) q(win, p);
+ for_all(q)
+ accu.take(input(q));
+ p = p + dpsite(-1, 1);
+ }
+
+ void final()
+ {
+ }
+
+ };
+
+
+
+ template <typename I_, typename W, typename A>
+ struct backdiagonal_functor
+ {
+ typedef I_ I;
+ typedef mln_deduce(I, psite, delta) dpsite;
+
+ const I& input;
+ const W& win;
+ mln_concrete(I) output;
+ A accu;
+
+ mln_psite(I) p;
+ enum { dim = I::site::dim };
+ unsigned dir;
+
+ window2d win_left, win_right;
+
+ mln_qiter(window2d) q_l, q_r;
+
+ backdiagonal_functor(const I& input, const W& win)
+ : input(input),
+ win(win),
+ accu(),
+ dir(dir),
+ win_left(win::shift(win, dpsite(-1, -1)) - win),
+ win_right(win - win::shift(win, dpsite(-1, -1))),
+ q_l(win_left, p),
+ q_r(win_right, p)
+ {
+ }
+
+ void init()
+ {
+ initialize(output, input);
+ }
+
+ void next()
+ {
+ for_all(q_l)
+ accu.untake(input(q_l));
+ for_all(q_r)
+ accu.take(input(q_r));
+ output(p) = accu;
+ }
+
+
+ void init_diag()
+ {
+ accu.init();
+ p = p - dpsite(1, 1);
+ mln_qiter(W) q(win, p);
+ for_all(q)
+ accu.take(input(q));
+ p = p + dpsite(1, 1);
+ }
+
+ void final()
+ {
+ }
+
+ };
+
+
+
+ // Functors (fastest versions).
+
+
+ template <typename I_, typename W, typename A>
+ struct diagonal_fastest_functor
+ {
+ typedef I_ I;
+ typedef mln_deduce(I, psite, delta) dpsite;
+
+ const I& input;
+ const W& win;
+ mln_concrete(I) output;
+ A accu;
+
+ mln_psite(I) p;
+ enum { dim = I::site::dim };
+ unsigned dir;
+
+ window2d win_left, win_right;
+
+ mln_qixter(const I, window2d) q_l, q_r;
+
+ diagonal_fastest_functor(const I& input, const W& win)
+ : input(input),
+ win(win),
+ accu(),
+ dir(dir),
+ win_left(win::shift(win, dpsite(1, -1)) - win),
+ win_right(win - win::shift(win, dpsite(1, -1))),
+ q_l(input, win_left, p),
+ q_r(input, win_right, p)
+ {
+ }
+
+ void init()
+ {
+ initialize(output, input);
+ }
+
+ void next()
+ {
+ for_all(q_l)
+ accu.untake(q_l.val());
+ for_all(q_r)
+ accu.take(q_r.val());
+ output(p) = accu;
+ }
+
+
+ void init_diag()
+ {
+ accu.init();
+ p = p - dpsite(-1, 1);
+ mln_qixter(const I, W) q(input, win, p);
+ for_all(q)
+ accu.take(q.val());
+ p = p + dpsite(-1, 1);
+ }
+
+ void final()
+ {
+ }
+
+ };
+
+
+ template <typename I_, typename W, typename A>
+ struct backdiagonal_fastest_functor
+ {
+ typedef I_ I;
+ typedef mln_deduce(I, psite, delta) dpsite;
+
+ const I& input;
+ const W& win;
+ mln_concrete(I) output;
+ A accu;
+
+ mln_psite(I) p;
+ enum { dim = I::site::dim };
+ unsigned dir;
+
+ window2d win_left, win_right;
+
+ mln_qixter(const I, window2d) q_l, q_r;
+
+ backdiagonal_fastest_functor(const I& input, const W& win)
+ : input(input),
+ win(win),
+ accu(),
+ dir(dir),
+ win_left(win::shift(win, dpsite(-1, -1)) - win),
+ win_right(win - win::shift(win, dpsite(-1, -1))),
+ q_l(input, win_left, p),
+ q_r(input, win_right, p)
+ {
+ }
+
+ void init()
+ {
+ initialize(output, input);
+ }
+
+ void next()
+ {
+ for_all(q_l)
+ accu.untake(q_l.val());
+ for_all(q_r)
+ accu.take(q_r.val());
+ output(p) = accu;
+ }
+
+
+ void init_diag()
+ {
+ accu.init();
+ p = p - dpsite(1, 1);
+ mln_qixter(const I, W) q(input, win, p);
+ for_all(q)
+ accu.take(q.val());
+ p = p + dpsite(1, 1);
+ }
+
+ void final()
+ {
+ }
+
+ };
+
+
+
+
+ // Both dispatch and implementation (hum...)
+
+ template <typename A, typename I>
+ inline
+ mln_ch_value(I, mln_result(A))
+ transform_diagonal_dispatch(trait::image::speed::any,
+ const Accumulator<A>& /* FIXME a */,
+ const Image<I>& input, const win::diag2d& win)
+ {
+ typedef diagonal_functor<I, win::diag2d, A> F;
+ F f(exact(input), win); // FIXME: Pass a to f.
+ canvas::browsing::diagonal2d(f);
+ return f.output;
+ }
+
+ template <typename A, typename I>
+ inline
+ mln_ch_value(I, mln_result(A))
+ transform_diagonal_dispatch(trait::image::speed::any,
+ const Accumulator<A>& /* FIXME a */,
+ const Image<I>& input, const win::backdiag2d& win)
+ {
+ typedef backdiagonal_functor<I, win::backdiag2d, A> F;
+ F f(exact(input), win); // FIXME: Pass a to f.
+ canvas::browsing::backdiagonal2d(f);
+ return f.output;
+ }
+
+ template <typename A, typename I>
+ inline
+ mln_ch_value(I, mln_result(A))
+ transform_diagonal_dispatch(trait::image::speed::fastest,
+ const Accumulator<A>& /* FIXME a*/,
+ const Image<I>& input, const win::diag2d& win)
+ {
+ typedef diagonal_fastest_functor<I, win::diag2d, A> F;
+ F f(exact(input), win); // FIXME: Pass a to f.
+ canvas::browsing::diagonal2d(f);
+ return f.output;
+ }
+
+ template <typename A, typename I>
+ inline
+ mln_ch_value(I, mln_result(A))
+ transform_diagonal_dispatch(trait::image::speed::fastest,
+ const Accumulator<A>& /* FIXME a*/,
+ const Image<I>& input, const win::backdiag2d& win)
+ {
+ typedef backdiagonal_fastest_functor<I, win::backdiag2d, A> F;
+ F f(exact(input), win); // FIXME: Pass a to f.
+ canvas::browsing::backdiagonal2d(f);
+ return f.output;
+ }
+
+ template <typename A, typename I, typename W>
+ inline
+ mln_ch_value(I, mln_result(A))
+ transform_diagonal_dispatch(const Accumulator<A>& a,
+ const Image<I>& input, const Window<W>& win)
+ {
+ return transform_diagonal_dispatch(mln_trait_image_speed(I)(),
+ a, input, exact(win));
+ }
+
+ } // end of namespace mln::accu::internal
+
+
+
+
+ template <typename A, typename I, typename W>
+ inline
+ mln_ch_value(I, mln_result(A))
+ transform_diagonal(const Accumulator<A>& a,
+ const Image<I>& input, const Window<W>& win)
+ {
+ trace::entering("accu::transform_diagonal");
+
+ internal::transform_diagonal_tests(input, win);
+
+ extension::adjust(input, geom::delta(win) + 1);
+ mln_ch_value(I, mln_result(A)) output;
+ output = internal::transform_diagonal_dispatch(a, input, win);
+
+ trace::exiting("accu::transform_diagonal");
+ return output;
+ }
+
+
+ template <typename A, typename I, typename W>
+ inline
+ mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
+ transform_diagonal(const Meta_Accumulator<A>& a,
+ const Image<I>& input, const Window<W>& win)
+ {
+ trace::entering("accu::transform_diagonal");
+
+ internal::transform_diagonal_tests(input, win);
+
+ typedef mln_accu_with(A, mln_value(I)) A_;
+ A_ a_ = accu::unmeta(exact(a), mln_value(I)());
+
+ extension::adjust(input, geom::delta(win) + 1);
+ mln_ch_value(I, mln_result(A_)) output;
+ output = internal::transform_diagonal_dispatch(a_, input, win);
+
+ trace::exiting("accu::transform_diagonal");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_TRANSFORM_DIAGONAL_HH
Index: mln/win/line.hh
--- mln/win/line.hh (revision 2881)
+++ mln/win/line.hh (working copy)
@@ -73,12 +73,12 @@
template <typename M, unsigned i, typename C>
struct line : public internal::classical_window_base< dpoint<M, C>, line<M,i,C> >
{
- /*! \brief Constructor.
- *
- * \param[in] length Length of the line.
- *
- * \pre \p length is odd.
- */
+ /// Direction.
+ enum { dir = i };
+
+ /// Constructor.
+ /// \param[in] length Length of the line.
+ /// \pre \p length is odd.
line(unsigned length);
/// Give the line length.
@@ -87,9 +87,8 @@
/// Give the line size, that is, its length.
unsigned size() const;
- /*! \brief Give the maximum coordinate gap between the window
- * center and a window point.
- */
+ /// Give the maximum coordinate gap between the window
+ /// center and a window point.
unsigned delta_() const;
void print_(std::ostream& ostr) const;
Index: mln/morpho/erosion.spe.hh
--- mln/morpho/erosion.spe.hh (revision 2881)
+++ mln/morpho/erosion.spe.hh (working copy)
@@ -161,6 +161,9 @@
+ // Line case.
+
+
template <typename I, typename G, unsigned Dir, typename C>
inline
mln_concrete(I)
@@ -210,6 +213,10 @@
}
+
+ // Particular windows.
+
+
template <typename I>
inline
mln_concrete(I)
@@ -250,7 +257,6 @@
}
-
template <typename I, typename W>
inline
mln_concrete(I)
@@ -270,7 +276,6 @@
}
-
template <typename I, typename W>
inline
mln_concrete(I)
@@ -290,350 +295,32 @@
}
-
- // Diagonal2d non fastest.
- template <typename I_, typename W, typename A>
- struct erosion_diagonal2d_functor
- {
- typedef I_ I;
- typedef mln_deduce(I, psite, delta) dpsite;
-
- const I& input;
- const W& win;
- mln_concrete(I) output;
- A accu;
-
- mln_psite(I) p;
- enum { dim = I::site::dim };
- unsigned dir;
-
- window2d win_left, win_right;
-
- mln_qiter(window2d) q_l, q_r;
-
- erosion_diagonal2d_functor(const I& input, const W& win)
- : input(input),
- win(win),
- accu(),
- dir(dir),
- win_left(win::shift(win, dpsite(1, -1)) - win),
- win_right(win - win::shift(win, dpsite(1, -1))),
- q_l(win_left, p),
- q_r(win_right, p)
- {
- }
-
- void init()
- {
- extension::adjust_fill(input, win, accu);
- initialize(output, input);
- }
-
- void next()
- {
- for_all(q_l)
- accu.untake(input(q_l));
- for_all(q_r)
- accu.take(input(q_r));
- output(p) = accu;
- }
-
-
- void init_diag()
- {
- accu.init();
- p = p - dpsite(-1, 1);
- mln_qiter(W) q(win, p);
- for_all(q)
- accu.take(input(q));
- p = p + dpsite(-1, 1);
- }
-
- void final()
- {
- }
-
- };
-
- // Backdiagonal2d non fastest.
- template <typename I, typename W>
- inline
- mln_concrete(I)
- erosion_diagonal2d(const Image<I>& input, const Window<W>& win)
- {
- trace::entering("morpho::impl:erosion_diagonal2d");
-
- typedef mlc_is(mln_trait_image_kind(I),
- trait::image::kind::binary) is_binary;
- typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A;
-
- typedef erosion_diagonal2d_functor<I, W, A> F;
- F f(exact(input), exact(win));
- canvas::browsing::diagonal2d(f);
-
- trace::exiting("morpho::impl:erosion_diagonal2d");
-
- return f.output;
- }
-
-
-
- template <typename I_, typename W, typename A>
- struct erosion_backdiagonal2d_functor
- {
- typedef I_ I;
- typedef mln_deduce(I, psite, delta) dpsite;
-
- const I& input;
- const W& win;
- mln_concrete(I) output;
- A accu;
-
- mln_psite(I) p;
- enum { dim = I::site::dim };
- unsigned dir;
-
- window2d win_left, win_right;
-
- mln_qiter(window2d) q_l, q_r;
-
- erosion_backdiagonal2d_functor(const I& input, const W& win)
- : input(input),
- win(win),
- accu(),
- dir(dir),
- win_left(win::shift(win, dpsite(-1, -1)) - win),
- win_right(win - win::shift(win, dpsite(-1, -1))),
- q_l(win_left, p),
- q_r(win_right, p)
- {
- }
-
- void init()
- {
- extension::adjust_fill(input, win, accu);
- initialize(output, input);
- }
-
- void next()
- {
- for_all(q_l)
- accu.untake(input(q_l));
- for_all(q_r)
- accu.take(input(q_r));
- output(p) = accu;
- }
-
-
- void init_diag()
- {
- accu.init();
- p = p - dpsite(1, 1);
- mln_qiter(W) q(win, p);
- for_all(q)
- accu.take(input(q));
- p = p + dpsite(1, 1);
- }
-
- void final()
- {
- }
-
- };
-
template <typename I, typename W>
inline
mln_concrete(I)
- erosion_backdiagonal2d(const Image<I>& input, const Window<W>& win)
- {
- trace::entering("morpho::impl:erosion_backdiagonal2d");
-
- typedef mlc_is(mln_trait_image_kind(I),
- trait::image::kind::binary) is_binary;
- typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A;
-
- typedef erosion_backdiagonal2d_functor<I, W, A> F;
- F f(exact(input), exact(win));
- canvas::browsing::backdiagonal2d(f);
-
- trace::exiting("morpho::impl:erosion_backdiagonal2d");
-
- return f.output;
- }
-
-
-
- // Diagonal2d fastest.
- template <typename I_, typename W, typename A>
- struct erosion_diagonal2d_fastest_functor
+ erosion_diagonal_2d(const Image<I>& input, const Window<W>& win)
{
- typedef I_ I;
- typedef mln_deduce(I, psite, delta) dpsite;
-
- const I& input;
- const W& win;
- mln_concrete(I) output;
- A accu;
-
- mln_psite(I) p;
- enum { dim = I::site::dim };
- unsigned dir;
-
- window2d win_left, win_right;
-
- mln_qixter(const I, window2d) q_l, q_r;
-
- erosion_diagonal2d_fastest_functor(const I& input, const W& win)
- : input(input),
- win(win),
- accu(),
- dir(dir),
- win_left(win::shift(win, dpsite(1, -1)) - win),
- win_right(win - win::shift(win, dpsite(1, -1))),
- q_l(input, win_left, p),
- q_r(input, win_right, p)
- {
- }
+ trace::entering("morpho::impl:erosion_diagonal_2d");
- void init()
- {
- extension::adjust_fill(input, win, accu);
- initialize(output, input);
- }
-
- void next()
- {
- for_all(q_l)
- accu.untake(q_l.val());
- for_all(q_r)
- accu.take(q_r.val());
- output(p) = accu;
- }
-
-
- void init_diag()
- {
- accu.init();
- p = p - dpsite(-1, 1);
- mln_qixter(const I, W) q(input, win, p);
- for_all(q)
- accu.take(q.val());
- p = p + dpsite(-1, 1);
- }
-
- void final()
- {
- }
-
- };
-
- template <typename I, typename W>
- inline
- mln_concrete(I)
- erosion_diagonal2d_fastest(const Image<I>& input, const Window<W>& win)
- {
- trace::entering("morpho::impl:erosion_diagonal2d_fastest");
-
- typedef mlc_is(mln_trait_image_kind(I),
- trait::image::kind::binary) is_binary;
+ typedef mlc_is(mln_trait_image_kind(I), trait::image::kind::binary) is_binary;
typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A;
+ A a;
- typedef erosion_diagonal2d_fastest_functor<I, W, A> F;
- F f(exact(input), exact(win));
- canvas::browsing::diagonal2d(f);
-
- trace::exiting("morpho::impl:erosion_diagonal2d_fastest");
-
- return f.output;
- }
-
-
-
- // Backdiagonal2d fastest.
- template <typename I_, typename W, typename A>
- struct erosion_backdiagonal2d_fastest_functor
- {
- typedef I_ I;
- typedef mln_deduce(I, psite, delta) dpsite;
-
- const I& input;
- const W& win;
- mln_concrete(I) output;
- A accu;
-
- mln_psite(I) p;
- enum { dim = I::site::dim };
- unsigned dir;
-
- window2d win_left, win_right;
-
- mln_qixter(const I, window2d) q_l, q_r;
-
- erosion_backdiagonal2d_fastest_functor(const I& input, const W& win)
- : input(input),
- win(win),
- accu(),
- dir(dir),
- win_left(win::shift(win, dpsite(-1, -1)) - win),
- win_right(win - win::shift(win, dpsite(-1, -1))),
- q_l(input, win_left, p),
- q_r(input, win_right, p)
- {
- }
-
- void init()
- {
- extension::adjust_fill(input, win, accu);
- initialize(output, input);
- }
-
- void next()
- {
- for_all(q_l)
- accu.untake(q_l.val());
- for_all(q_r)
- accu.take(q_r.val());
- output(p) = accu;
- }
-
+ extension::adjust_fill(input, geom::delta(win) + 1, a);
+ mln_concrete(I) output = accu::transform_diagonal(a, input, win);
- void init_diag()
- {
- accu.init();
- p = p - dpsite(1, 1);
- mln_qixter(const I, W) q(input, win, p);
- for_all(q)
- accu.take(q.val());
- p = p + dpsite(1, 1);
+ trace::exiting("morpho::impl:erosion_diagonal_2d");
+ return output;
}
- void final()
- {
- }
- };
- template <typename I, typename W>
- inline
- mln_concrete(I)
- erosion_backdiagonal2d_fastest(const Image<I>& input, const Window<W>& win)
- {
- trace::entering("morpho::impl:erosion_backdiagonal2d_fastest");
-
- typedef mlc_is(mln_trait_image_kind(I),
- trait::image::kind::binary) is_binary;
- typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A;
+ } // end of namespace mln::morpho::impl
- typedef erosion_backdiagonal2d_fastest_functor<I, W, A> F;
- F f(exact(input), exact(win));
- canvas::browsing::backdiagonal2d(f);
- trace::exiting("morpho::impl:erosion_backdiagonal2d_fastest");
- return f.output;
- }
- } // end of namespace mln::morpho::impl
+ // Dispatch.
namespace internal
@@ -675,67 +362,6 @@
- // dispatch for diagonal2d w.r.t. speed
-
- template <typename I, typename W>
- mln_concrete(I)
- erosion_dispatch_for_diagonal2d(trait::image::speed::fastest,
- const I& input, const W& win)
- {
- return impl::erosion_diagonal2d_fastest(input, win);
- }
-
- template <typename I, typename W>
- mln_concrete(I)
- erosion_dispatch_for_diagonal2d(trait::image::speed::any,
- const I& input, const W& win)
- {
- return impl::erosion_diagonal2d(input, win);
- }
-
- template <typename I, typename W>
- mln_concrete(I)
- erosion_dispatch_for_diagonal2d(const I& input, const W& win)
- {
- trace::entering("morpho::erosion_dispatch_for_diagonal2d");
- mln_concrete(I) ima =
- erosion_dispatch_for_diagonal2d(mln_trait_image_speed(I)(),
- input, win);
- trace::exiting("morpho::erosion_dispatch_for_diagonal2d");
- return ima;
- }
-
-
- // dispatch for backdiagonal2d w.r.t. speed
-
- template <typename I, typename W>
- mln_concrete(I)
- erosion_dispatch_for_backdiagonal2d(trait::image::speed::fastest,
- const I& input, const W& win)
- {
- return impl::erosion_backdiagonal2d_fastest(input, win);
- }
-
- template <typename I, typename W>
- mln_concrete(I)
- erosion_dispatch_for_backdiagonal2d(trait::image::speed::any,
- const I& input, const W& win)
- {
- return impl::erosion_backdiagonal2d(input, win);
- }
-
- template <typename I, typename W>
- mln_concrete(I)
- erosion_dispatch_for_backdiagonal2d(const I& input, const W& win)
- {
- trace::entering("morpho::erosion_dispatch_for_backdiagonal2d");
- mln_concrete(I) ima =
- erosion_dispatch_for_backdiagonal2d(mln_trait_image_speed(I)(),
- input, win);
- trace::exiting("morpho::erosion_dispatch_for_backdiagonal2d");
- return ima;
- }
-
// dispatch w.r.t. win
@@ -776,6 +402,8 @@
input, win);
}
+
+
template <typename I>
mln_concrete(I)
erosion_dispatch_wrt_win(const I& input, const win::rectangle2d& win)
@@ -786,6 +414,7 @@
return impl::erosion_rectangle2d(input, win);
}
+
template <typename I>
mln_concrete(I)
erosion_dispatch_wrt_win(const I& input, const win::octagon2d& win)
@@ -877,28 +506,30 @@
/// \}
- /// Handling win::diag2d.
+
+
+ /// Handling diagonals.
/// \{
- template <typename I>
+ template <typename I, typename W>
mln_concrete(I)
- erosion_dispatch_wrt_win(metal::true_,
- const I& input, const win::diag2d& win)
+ erosion_dispatch_diagonal(metal::true_,
+ const I& input, const W& win)
{
- return erosion_dispatch_for_diagonal2d(input, win);
+ return impl::erosion_diagonal_2d(input, win);
}
- template <typename I>
+ template <typename I, typename W>
mln_concrete(I)
- erosion_dispatch_wrt_win(metal::false_,
- const I& input, const win::diag2d& win)
+ erosion_dispatch_diagonal(metal::false_,
+ const I& input, const W& win)
{
return erosion_dispatch_for_generic(input, win);
}
- template <typename I>
+ template <typename I, typename W>
mln_concrete(I)
- erosion_dispatch_wrt_win(const I& input, const win::diag2d& win)
+ erosion_dispatch_diagonal(const I& input, const W& win)
{
if (win.size() == 1)
return clone(input);
@@ -911,51 +542,24 @@
&& mlc_is_a(mln_pset(I), Box)::value
&& mlc_equal(mln_trait_image_quant(I),
mln::trait::image::quant::low)::value };
- return erosion_dispatch_wrt_win(metal::bool_<test>(),
+ return erosion_dispatch_diagonal(metal::bool_<test>(),
input, win);
}
}
- /// \}
-
-
- /// Handling win::backdiag2d.
- /// \{
template <typename I>
mln_concrete(I)
- erosion_dispatch_wrt_win(metal::true_,
- const I& input, const win::backdiag2d& win)
- {
- return erosion_dispatch_for_backdiagonal2d(input, win);
- }
-
- template <typename I>
- mln_concrete(I)
- erosion_dispatch_wrt_win(metal::false_,
- const I& input, const win::backdiag2d& win)
+ erosion_dispatch_wrt_win(const I& input, const win::diag2d& win)
{
- return erosion_dispatch_for_generic(input, win);
+ return erosion_dispatch_diagonal(input, win);
}
template <typename I>
mln_concrete(I)
erosion_dispatch_wrt_win(const I& input, const win::backdiag2d& win)
{
- if (win.size() == 1)
- return clone(input);
- else if (win.size() == 3)
- return erosion_dispatch_for_generic(input, win);
- else
- {
- enum { test = mlc_is_not(mln_trait_image_kind(I),
- mln::trait::image::kind::logic)::value
- && mlc_is_a(mln_pset(I), Box)::value
- && mlc_equal(mln_trait_image_quant(I),
- mln::trait::image::quant::low)::value };
- return erosion_dispatch_wrt_win(metal::bool_<test>(),
- input, win);
- }
+ return erosion_dispatch_diagonal(input, win);
}
/// \}
Index: mln/morpho/includes.hh
--- mln/morpho/includes.hh (revision 2881)
+++ mln/morpho/includes.hh (working copy)
@@ -55,6 +55,7 @@
# include <mln/accu/transform.hh>
# include <mln/accu/transform_stop.hh>
# include <mln/accu/transform_directional.hh>
+# include <mln/accu/transform_diagonal.hh>
# include <mln/fun/v2v/saturate.hh>
1
0