* mln/core/internal/graph_neighborhood_base.hh,
* mln/core/image/graph_elt_neighborhood.hh,
* mln/core/image/line_graph_elt_neighborhood.hh,
* mln/core/internal/graph_window_base.hh,
* mln/core/image/graph_elt_window.hh,
* mln/core/image/line_graph_elt_window.hh: refactor.
* mln/make/voronoi.hh,
* mln/core/internal/line_graph_vicinity_piter.hh,
* mln/core/image/line_graph_window_piter.hh,
* mln/core/image/line_graph_neighborhood_piter.hh: update according
the new graph structure.
* mln/core/site_set/p_graph.hh,
* mln/core/site_set/p_line_graph.hh,
* mln/core/site_set/p_line_graph_piter.hh,
* mln/core/image/line_graph_psite.hh: deprecated and deleted.
* tests/core/site_set/p_vertices.cc,
* mln/util/graph.hh,
* mln/util/internal/graph_vertex_impl.hh,
* mln/util/internal/graph_edge_impl.hh: fix comments.
* mln/util/internal/graph_edge_psite.hh: fix initialization.
* tests/core/site_set/p_edges.cc,
* tests/core/image/graph_image.cc,
* tests/core/image/line_graph_image.cc: fix tests.
* mln/make/all.hh
* mln/make/essential.hh: uncomment inclusion of voronoi.hh.
---
milena/ChangeLog | 36 ++
milena/mln/core/image/graph_elt_neighborhood.hh | 46 +--
milena/mln/core/image/graph_elt_window.hh | 96 +-----
.../mln/core/image/line_graph_elt_neighborhood.hh | 107 ++----
milena/mln/core/image/line_graph_elt_window.hh | 165 +++------
.../core/image/line_graph_neighborhood_piter.hh | 94 +++---
milena/mln/core/image/line_graph_psite.hh | 399 --------------------
milena/mln/core/image/line_graph_window_piter.hh | 96 +++---
.../internal/graph_neighborhood_base.hh} | 89 +++---
milena/mln/core/internal/graph_window_base.hh | 146 +++++++
.../mln/core/internal/line_graph_vicinity_piter.hh | 9 +-
milena/mln/core/site_set/p_graph.hh | 396 -------------------
milena/mln/core/site_set/p_line_graph.hh | 360 ------------------
milena/mln/core/site_set/p_line_graph_piter.hh | 272 -------------
milena/mln/make/all.hh | 2 +-
milena/mln/make/essential.hh | 4 +-
milena/mln/make/voronoi.hh | 27 +-
milena/mln/util/graph.hh | 2 +-
milena/mln/util/internal/graph_edge_impl.hh | 11 +-
milena/mln/util/internal/graph_edge_psite.hh | 3 +-
milena/mln/util/internal/graph_vertex_impl.hh | 11 +-
milena/tests/core/image/graph_image.cc | 42 ++-
milena/tests/core/image/line_graph_image.cc | 159 ++++++---
milena/tests/core/site_set/p_edges.cc | 12 +-
milena/tests/core/site_set/p_vertices.cc | 9 +-
25 files changed, 593 insertions(+), 2000 deletions(-)
delete mode 100644 milena/mln/core/image/line_graph_psite.hh
copy milena/mln/{util/internal/graph_vertex_impl.hh =>
core/internal/graph_neighborhood_base.hh} (50%)
create mode 100644 milena/mln/core/internal/graph_window_base.hh
delete mode 100644 milena/mln/core/site_set/p_graph.hh
delete mode 100644 milena/mln/core/site_set/p_line_graph.hh
delete mode 100644 milena/mln/core/site_set/p_line_graph_piter.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 560b8ab..20e278b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,39 @@
+2008-11-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Update graph related classes.
+
+ * mln/core/internal/graph_neighborhood_base.hh,
+ * mln/core/image/graph_elt_neighborhood.hh,
+ * mln/core/image/line_graph_elt_neighborhood.hh,
+ * mln/core/internal/graph_window_base.hh,
+ * mln/core/image/graph_elt_window.hh,
+ * mln/core/image/line_graph_elt_window.hh: refactor.
+
+ * mln/make/voronoi.hh,
+ * mln/core/internal/line_graph_vicinity_piter.hh,
+ * mln/core/image/line_graph_window_piter.hh,
+ * mln/core/image/line_graph_neighborhood_piter.hh: update according
+ the new graph structure.
+
+ * mln/core/site_set/p_graph.hh,
+ * mln/core/site_set/p_line_graph.hh,
+ * mln/core/site_set/p_line_graph_piter.hh,
+ * mln/core/image/line_graph_psite.hh: deprecated and deleted.
+
+ * tests/core/site_set/p_vertices.cc,
+ * mln/util/graph.hh
+ * mln/util/internal/graph_vertex_impl.hh,
+ * mln/util/internal/graph_edge_impl.hh: fix comments.
+
+ * mln/util/internal/graph_edge_psite.hh: fix initialization.
+
+ * tests/core/site_set/p_edges.cc,
+ * tests/core/image/graph_image.cc,
+ * tests/core/image/line_graph_image.cc: fix tests.
+
+ * mln/make/all.hh
+ * mln/make/essential.hh: uncomment inclusion of voronoi.hh.
+
2008-11-14 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Migrate generic code from morpho erosion to new files in accu.
diff --git a/milena/mln/core/image/graph_elt_neighborhood.hh
b/milena/mln/core/image/graph_elt_neighborhood.hh
index ac48f6d..5b568c0 100644
--- a/milena/mln/core/image/graph_elt_neighborhood.hh
+++ b/milena/mln/core/image/graph_elt_neighborhood.hh
@@ -30,19 +30,12 @@
# define MLN_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH
/// \file mln/core/image/graph_elt_neighborhood.hh
-/// \brief Definition of the elementary ``neighborhood'' on a graph.
-
-/* FIXME: Factor those classes:
- - mln::graph_elt_window
- - mln::graph_elt_neighborhood
- - mln::line_graph_elt_window
- - mln::line_graph_elt_neighborhood.
-
- See
https://trac.lrde.org/olena/ticket/139. */
+/// Definition of the elementary ``neighborhood'' on a graph.
# include <set>
# 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/image/graph_neighborhood_piter.hh>
@@ -56,10 +49,13 @@ namespace mln
template <typename G, typename F, typename N> class
graph_neighborhood_bkd_piter;
- /// \brief Elementary neighborhood on graph class.
+ /// Elementary neighborhood on graph class.
template <typename G, typename F>
class graph_elt_neighborhood
- : public Neighborhood< graph_elt_neighborhood<G, F> >
+ : public graph_neighborhood_base<G,
+ F,
+ internal::vertex_psite<G, F>,
+ graph_elt_neighborhood<G, F> >
{
typedef graph_elt_neighborhood<G, F> self_;
@@ -68,17 +64,12 @@ namespace mln
/// \{
/// The type of psite corresponding to the neighborhood.
typedef internal::vertex_psite<G, F> psite;
- /// The type of site corresponding to the neighborhood.
- typedef mln_site(psite) site;
- // The type of the set of neighbors (vertex ids adjacent to the
- // reference psite).
- typedef std::set<unsigned> sites_t;
- /// \brief Site_Iterator type to browse the psites of the
+ /// Site_Iterator type to browse the psites of the
/// neighborhood w.r.t. the ordering of vertices.
typedef graph_neighborhood_fwd_piter<G, F, self_> fwd_niter;
- /// \brief Site_Iterator type to browse the psites of the
+ /// Site_Iterator type to browse the psites of the
/// neighborhood w.r.t. the reverse ordering of vertices.
typedef graph_neighborhood_bkd_piter<G, F, self_> bkd_niter;
@@ -86,13 +77,6 @@ namespace mln
typedef fwd_niter niter;
/// \}
- /// Conversions.
- /// \{
- /// The window type corresponding to this neighborhood.
- typedef graph_elt_window<G, F> window;
- /// Create a window corresponding to this neighborhood.
- window win() const;
- /// \}
/// Services for iterators.
/// \{
@@ -100,20 +84,16 @@ namespace mln
template <typename Piter>
void compute_sites_(Site_Iterator<Piter>& piter) const;
/// \}
+
+ protected:
+ typedef graph_neighborhood_base<G, F, psite, self_> super_;
+ typedef typename super_::sites_t sites_t;
};
# ifndef MLN_INCLUDE_ONLY
template <typename G, typename F>
- inline
- graph_elt_window<G, F>
- graph_elt_neighborhood<G, F>::win() const
- {
- return graph_elt_window<G, F>();
- }
-
- template <typename G, typename F>
template <typename Piter>
inline
void
diff --git a/milena/mln/core/image/graph_elt_window.hh
b/milena/mln/core/image/graph_elt_window.hh
index e09b257..f71c499 100644
--- a/milena/mln/core/image/graph_elt_window.hh
+++ b/milena/mln/core/image/graph_elt_window.hh
@@ -30,17 +30,10 @@
# define MLN_CORE_IMAGE_GRAPH_ELT_WINDOW_HH
/// \file mln/core/image/graph_elt_window.hh
-/// \brief Definition of the elementary ``window'' on a graph.
-
-/* FIXME: Factor those classes:
- - mln::graph_elt_window
- - mln::graph_elt_neighborhood
- - mln::line_graph_elt_window
- - mln::line_graph_elt_neighborhood.
-
- See
https://trac.lrde.org/olena/ticket/139. */
+/// Definition of the elementary ``window'' on a graph.
# 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/image/graph_window_piter.hh>
@@ -68,24 +61,20 @@ namespace mln
/// \brief Elementary window on graph class.
template <typename G, typename F>
- class graph_elt_window : public Window< graph_elt_window<G, F> >
+ class graph_elt_window : public graph_window_base<
+ G,
+ F,
+ internal::vertex_psite<G, F>,
+ graph_elt_window<G, F> >
+
{
typedef graph_elt_window<G, F> self_;
- typedef mln_result(F) P;
public:
/// Associated types.
/// \{
/// The type of psite corresponding to the window.
typedef internal::vertex_psite<G, F> psite;
- /// The type of site corresponding to the window.
- typedef mln_site(psite) site;
- // The type of the set of window sites (vertex ids adjacent to the
- // reference psite).
- typedef std::set<unsigned> sites_t;
-
- // FIXME: This is a dummy value.
- typedef void dpsite;
/// \brief Site_Iterator type to browse the psites of the window
/// w.r.t. the ordering of vertices.
@@ -106,31 +95,9 @@ namespace mln
void compute_sites_(Site_Iterator<Piter>& piter) const;
/// \}
- /// Interface of the concept Window.
- /// \{
- /// Is the window is empty?
- bool is_empty() const;
- /// Is the window centered?
- bool is_centered() const;
- /// Is the window symmetric?
- // FIXME: We should define this more precisely.
- bool is_symmetric() const;
- /// Return the maximum coordinate gap between the window center
- /// and a window point.
- /* FIXME: This method returns a dummy value (0), since the delta
- of a window on a graph
-
- 1. is not constant (graph vertices are not necessarily aligned on
- a regular grid);
-
- 2. depends on the underlying graph, too.
-
- It raises another question: should delta() be part of the
- concept ``Window''? */
- unsigned delta() const;
- /// Apply a central symmetry to the target window.
- self_& sym();
- /// \}
+ protected:
+ typedef graph_window_base<G, F, psite, self_> super_;
+ typedef typename super_::sites_t sites_t;
};
@@ -154,47 +121,6 @@ namespace mln
sites.insert(g.v_ith_nbh_vertex(central_vertex, i));
}
- template <typename G, typename F>
- inline
- bool
- graph_elt_window<G, F>::is_empty() const
- {
- return false;
- }
-
- template <typename G, typename F>
- inline
- bool
- graph_elt_window<G, F>::is_centered() const
- {
- return false;
- }
-
- template <typename G, typename F>
- inline
- bool
- graph_elt_window<G, F>::is_symmetric() const
- {
- return true;
- }
-
- template <typename G, typename F>
- inline
- unsigned
- graph_elt_window<G, F>::delta() const
- {
- // Dummy value (see the interface of the method above).
- return 0;
- }
-
- template <typename G, typename F>
- inline
- graph_elt_window<G, F>&
- graph_elt_window<G, F>::sym()
- {
- return *this;
- }
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/core/image/line_graph_elt_neighborhood.hh
b/milena/mln/core/image/line_graph_elt_neighborhood.hh
index 1f79084..55236f3 100644
--- a/milena/mln/core/image/line_graph_elt_neighborhood.hh
+++ b/milena/mln/core/image/line_graph_elt_neighborhood.hh
@@ -30,27 +30,13 @@
# define MLN_CORE_IMAGE_LINE_GRAPH_ELT_NEIGHBORHOOD_HH
/// \file mln/core/image/line_graph_elt_neighborhood.hh
-/// \brief Definition of the elementary ``neighborhood'' on a line graph.
-
-/* FIXME: Have a consistent naming: we have window (without '_') but
- point_, neighb_, etc. */
-
-/* FIXME: Factor those classes:
- - mln::graph_elt_window
- - mln::graph_elt_neighborhood
- - mln::line_graph_elt_window
- - mln::line_graph_elt_neighborhood.
-
- See
https://trac.lrde.org/olena/ticket/139. */
-
-/* FIXME: Due to the poor interface of mln::p_line_graph and
- mln::util::graph, we show to much implementation details here.
- Enrich their interfaces to avoid that. */
+/// Definition of the elementary ``neighborhood'' on a line graph.
# include <set>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/core/image/line_graph_psite.hh>
+# include <mln/core/internal/graph_neighborhood_base.hh>
+# include <mln/util/internal/graph_edge_psite.hh>
# include <mln/core/image/line_graph_neighborhood_piter.hh>
# include <mln/core/image/line_graph_elt_window.hh>
@@ -58,99 +44,70 @@
namespace mln
{
- // Fwd decls.
- template <typename P, typename N> class line_graph_neighborhood_fwd_piter;
- template <typename P, typename N> class line_graph_neighborhood_bkd_piter;
-
- /// \brief Elementary neighborhood on line graph class.
- template <typename P>
+ /// Elementary neighborhood on line graph class.
+ template <typename G, typename F>
class line_graph_elt_neighborhood
- : public Neighborhood< line_graph_elt_neighborhood<P> >
+ : public graph_neighborhood_base<G,
+ F,
+ internal::edge_psite<G, F>,
+ line_graph_elt_neighborhood<G, F> >
{
- typedef line_graph_elt_neighborhood<P> self_;
+ typedef line_graph_elt_neighborhood<G, F> self_;
public:
/// Associated types.
/// \{
/// The type of psite corresponding to the neighborhood.
- typedef line_graph_psite<P> psite;
- /// The type of site corresponding to the neighborhood.
- typedef mln_site(psite) site;
- // The type of the set of neighbors (edge ids adjacent to the
- // reference psite).
- typedef std::set<util::edge_id> sites_t;
-
- /// \brief Site_Iterator type to browse the psites of the
+ typedef internal::edge_psite<G, F> psite;
+
+ /// Site_Iterator type to browse the psites of the
/// neighborhood w.r.t. the ordering of edges.
- typedef line_graph_neighborhood_fwd_piter<P, self_> fwd_niter;
+ typedef line_graph_neighborhood_fwd_piter<G, F, self_> fwd_niter;
- /// \brief Site_Iterator type to browse the psites of the
+ /// Site_Iterator type to browse the psites of the
/// neighborhood w.r.t. the reverse ordering of edges.
- typedef line_graph_neighborhood_bkd_piter<P, self_> bkd_niter;
+ typedef line_graph_neighborhood_bkd_piter<G, F, self_> bkd_niter;
/// The default niter type.
typedef fwd_niter niter;
/// \}
- /// Conversions.
- /// \{
- /// The window type corresponding to this neighborhood.
- typedef line_graph_elt_window<P> window;
- /// Create a window corresponding to this neighborhood.
- window to_window() const;
- /// \}
-
/// Services for iterators.
/// \{
/// Compute the set of sites for this neighborhood around \a piter.
template <typename Piter>
void compute_sites_(Site_Iterator<Piter>& piter) const;
/// \}
+
+ protected:
+ typedef graph_neighborhood_base<G, F, psite, self_> super_;
+ typedef typename super_::sites_t sites_t;
};
# ifndef MLN_INCLUDE_ONLY
- template <typename P>
- inline
- line_graph_elt_window<P>
- line_graph_elt_neighborhood<P>::to_window() const
- {
- return line_graph_elt_window<P>();
- }
-
- template <typename P>
+ template <typename G, typename F>
template <typename Piter>
inline
void
- line_graph_elt_neighborhood<P>::compute_sites_(Site_Iterator<Piter>&
piter_) const
+ line_graph_elt_neighborhood<G, F>::compute_sites_(Site_Iterator<Piter>&
piter_) const
{
Piter& piter = exact(piter_);
- util::edge_id ref_edge_id = piter.center().edge_id();
+ unsigned central_edge = piter.center().e().id();
sites_t& sites = piter.sites();
sites.clear();
- /* FIXME: Move this computation out of the neighborhood. In fact,
- this should be a service of the graph, also proposed by the
- p_line_graph. */
- // Ajacent edges connected through vertex 1.
- util::vertex_id id1 = piter.center().first_id();
- const util::vertex<P>& vertex1 =
piter.center().site_set().gr_->vertex(id1);
- for (std::vector<util::edge_id>::const_iterator e =
- vertex1.edges.begin(); e != vertex1.edges.end(); ++e)
- // We explicitly enforce that the reference piter edge id is
- // *not* inserted into SITES.
- if (*e != ref_edge_id)
- sites.insert(*e);
- // Ajacent edges connected through vertex 2.
- util::vertex_id id2 = piter.center().second_id();
- const util::vertex<P>& vertex2 =
piter.center().site_set().gr_->vertex(id2);
- for (std::vector<util::edge_id>::const_iterator e =
- vertex2.edges.begin(); e != vertex2.edges.end(); ++e)
- // Same remark as above.
- if (*e != ref_edge_id)
- sites.insert(*e);
+
+ const G& g = piter.center().site_set().graph();
+
+ for (unsigned i = 0; i < g.e_nmax_nbh_edges(central_edge); ++i)
+ {
+ unsigned n = g.e_ith_nbh_edge(central_edge, i);
+ if (n != central_edge)
+ sites.insert(g.e_ith_nbh_edge(central_edge, i));
+ }
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/image/line_graph_elt_window.hh
b/milena/mln/core/image/line_graph_elt_window.hh
index 920ba4e..c727230 100644
--- a/milena/mln/core/image/line_graph_elt_window.hh
+++ b/milena/mln/core/image/line_graph_elt_window.hh
@@ -30,66 +30,62 @@
# define MLN_CORE_IMAGE_LINE_GRAPH_ELT_WINDOW_HH
/// \file mln/core/image/line_graph_elt_window.hh
-/// \brief Definition of the elementary ``window'' on a line graph.
-
-/* FIXME: Have a consistent naming: we have window (without '_') but
- point_, neighb_, etc. */
-
-/* FIXME: Factor those classes:
- - mln::graph_elt_window
- - mln::graph_elt_neighborhood
- - mln::line_graph_elt_window
- - mln::line_graph_elt_neighborhood.
-
- See
https://trac.lrde.org/olena/ticket/139. */
-
-/* FIXME: Due to the poor interface of mln::p_line_graph and
- mln::util::graph, we show to much implementation details here.
- Enrich their interfaces to avoid that. */
+/// Definition of the elementary ``window'' on a line graph.
# include <mln/core/concept/window.hh>
-# include <mln/core/image/line_graph_psite.hh>
+# include <mln/core/internal/graph_window_base.hh>
+# include <mln/util/internal/graph_edge_psite.hh>
# include <mln/core/image/line_graph_window_piter.hh>
namespace mln
{
- // Fwd decls.
- template <typename P, typename W> class line_graph_window_fwd_piter;
- template <typename P, typename W> class line_graph_window_bkd_piter;
+
+ /// Forward declaration
+ template <typename G, typename F> class line_graph_elt_window;
+
+ namespace trait
+ {
+
+ ///FIXME: check that!
+ template <typename G, typename F>
+ struct window_< mln::line_graph_elt_window<G, F> >
+ {
+ typedef trait::window::size::unknown size;
+ typedef trait::window::support::irregular support;
+ typedef trait::window::definition::varying definition;
+ };
+
+ } // end of namespace mln::trait
/// \brief Elementary window on line graph class.
- template <typename P>
- class line_graph_elt_window : public Window< line_graph_elt_window<P> >
+ template <typename G, typename F>
+ class line_graph_elt_window : public graph_window_base<
+ G,
+ F,
+ internal::edge_psite<G, F>,
+ line_graph_elt_window<G, F> >
{
- typedef line_graph_elt_window<P> self_;
+ typedef line_graph_elt_window<G, F> self_;
public:
/// Associated types.
/// \{
/// The type of psite corresponding to the window.
- typedef line_graph_psite<P> psite;
- /// The type of site corresponding to the window.
- typedef mln_site(psite) site;
- // The type of the set of window sites (edge ids adjacent to the
- // reference psite).
- typedef std::set<util::edge_id> sites_t;
-
- // FIXME: This is a dummy value.
- typedef void dpsite;
+ typedef internal::edge_psite<G, F> psite;
- /// \brief Site_Iterator type to browse the psites of the window
+ /// Site_Iterator type to browse the psites of the window
/// w.r.t. the ordering of edges.
- typedef line_graph_window_fwd_piter<P, self_> fwd_qiter;
+ typedef line_graph_window_fwd_piter<G, F, self_> fwd_qiter;
- /// \brief Site_Iterator type to browse the psites of the window
+ /// Site_Iterator type to browse the psites of the window
/// w.r.t. the reverse ordering of edges.
- typedef line_graph_window_bkd_piter<P, self_> bkd_qiter;
+ typedef line_graph_window_bkd_piter<G, F, self_> bkd_qiter;
/// The default qiter type.
typedef fwd_qiter qiter;
- /// \}
+
/// Services for iterators.
/// \{
@@ -98,105 +94,30 @@ namespace mln
void compute_sites_(Site_Iterator<Piter>& piter) const;
/// \}
- /// Interface of the concept Window.
- /// \{
- /// Is the window is empty?
- bool is_empty() const;
- /// Is the window centered?
- bool is_centered() const;
- /// Is the window symmetric?
- // FIXME: We should define this more precisely.
- bool is_symmetric() const;
- /// Return the maximum coordinate gap between the window center
- /// and a window point.
- /* FIXME: This method returns a dummy value (0), since the delta
- of a window on a line_graph
-
- 1. is not constant (line graph edges are not necessarily
- aligned on a regular grid);
-
- 2. depends on the underlying line_graph, too.
-
- It raises another question: should delta() be part of the
- concept ``Window''? */
- unsigned delta() const;
- /// Apply a central symmetry to the target window.
- self_& sym();
- /// \}
+ protected:
+ typedef graph_window_base<G, F, psite, self_> super_;
+ typedef typename super_::sites_t sites_t;
};
# ifndef MLN_INCLUDE_ONLY
- template <typename P>
+ template <typename G, typename F>
template <typename Piter>
inline
void
- line_graph_elt_window<P>::compute_sites_(Site_Iterator<Piter>& piter_)
const
+ line_graph_elt_window<G, F>::compute_sites_(Site_Iterator<Piter>&
piter_) const
{
Piter& piter = exact(piter_);
+ unsigned central_edge = piter.center().e().id();
sites_t& sites = piter.sites();
sites.clear();
- /* FIXME: Move this computation out of the window. In fact,
- this should be a service of the graph, also proposed by the
- p_line_graph. */
- // Ajacent edges connected through vertex 1.
- /* We don't need to explicitely insert the reference piter (edge
- id) itself into SITES, since it is part of the set of edges
- adjacent to VERTEX1 and VERTEX2, and will therefore be
- automatically added. */
- util::vertex_id id1 = piter.center().first_id();
- const util::vertex<P>& vertex1 =
piter.center().site_set().gr_->vertex(id1);
- for (std::vector<util::edge_id>::const_iterator e =
- vertex1.edges.begin(); e != vertex1.edges.end(); ++e)
- sites.insert(*e);
- // Ajacent edges connected through vertex 2.
- util::vertex_id id2 = piter.center().second_id();
- const util::vertex<P>& vertex2 =
piter.center().site_set().gr_->vertex(id2);
- for (std::vector<util::edge_id>::const_iterator e =
- vertex2.edges.begin(); e != vertex2.edges.end(); ++e)
- sites.insert(*e);
- }
-
- template <typename P>
- inline
- bool
- line_graph_elt_window<P>::is_empty() const
- {
- return false;
- }
-
- template <typename P>
- inline
- bool
- line_graph_elt_window<P>::is_centered() const
- {
- return false;
- }
-
- template <typename P>
- inline
- bool
- line_graph_elt_window<P>::is_symmetric() const
- {
- return true;
- }
- template <typename P>
- inline
- unsigned
- line_graph_elt_window<P>::delta() const
- {
- // Dummy value (see the interface of the method above).
- return 0;
- }
+ const G& g = piter.center().site_set().graph();
- template <typename P>
- inline
- line_graph_elt_window<P>&
- line_graph_elt_window<P>::sym()
- {
- return *this;
+ sites.insert(central_edge);
+ for (unsigned i = 0; i < g.e_nmax_nbh_edges(central_edge); ++i)
+ sites.insert(g.e_ith_nbh_edge(central_edge, i));
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/image/line_graph_neighborhood_piter.hh
b/milena/mln/core/image/line_graph_neighborhood_piter.hh
index 9a30b74..83594c7 100644
--- a/milena/mln/core/image/line_graph_neighborhood_piter.hh
+++ b/milena/mln/core/image/line_graph_neighborhood_piter.hh
@@ -34,25 +34,21 @@
# include <mln/core/internal/line_graph_vicinity_piter.hh>
-/* FIXME: Due to the poor interface of mln::p_line_graph and
- mln::util::graph, we show to much implementation details here.
- Enrich their interfaces to avoid that. */
-
namespace mln
{
/*------------------------------------------.
- | line_graph_neighborhood_fwd_piter<P, N>. |
+ | line_graph_neighborhood_fwd_piter<G, F, N>. |
`------------------------------------------*/
/// \brief Forward iterator on line graph neighborhood.
- template <typename P, typename N>
+ template <typename G, typename F, typename N>
class line_graph_neighborhood_fwd_piter :
- public internal::line_graph_vicinity_piter_< P, N,
- line_graph_neighborhood_fwd_piter<P, N> >
+ public internal::line_graph_vicinity_piter_< mln_result(F), N,
+ line_graph_neighborhood_fwd_piter<G, F, N> >
{
- typedef line_graph_neighborhood_fwd_piter<P, N> self_;
- typedef internal::line_graph_vicinity_piter_<P, N, self_> super_;
+ typedef line_graph_neighborhood_fwd_piter<G, F, N> self_;
+ typedef internal::line_graph_vicinity_piter_<mln_result(F), N, self_> super_;
public:
/// The Point_Site type.
@@ -90,17 +86,17 @@ namespace mln
/*------------------------------------------.
- | line_graph_neighborhood_bkd_piter<P, N>. |
+ | line_graph_neighborhood_bkd_piter<G, F, N>. |
`------------------------------------------*/
/// \brief Backward iterator on line graph neighborhood.
- template <typename P, typename N>
+ template <typename G, typename F, typename N>
class line_graph_neighborhood_bkd_piter :
- public internal::line_graph_vicinity_piter_< P, N,
- line_graph_neighborhood_bkd_piter<P, N> >
+ public internal::line_graph_vicinity_piter_< mln_result(F), N,
+ line_graph_neighborhood_bkd_piter<G, F, N> >
{
- typedef line_graph_neighborhood_bkd_piter<P, N> self_;
- typedef internal::line_graph_vicinity_piter_<P, N, self_> super_;
+ typedef line_graph_neighborhood_bkd_piter<G, F, N> self_;
+ typedef internal::line_graph_vicinity_piter_<mln_result(F), N, self_> super_;
public:
/// The Point_Site type.
@@ -141,126 +137,126 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
/*------------------------------------------.
- | line_graph_neighborhood_fwd_piter<P, N>. |
+ | line_graph_neighborhood_fwd_piter<G, F, N>. |
`------------------------------------------*/
- template <typename P, typename N>
+ template <typename G, typename F, typename N>
inline
- line_graph_neighborhood_fwd_piter<P, N>::line_graph_neighborhood_fwd_piter()
+ line_graph_neighborhood_fwd_piter<G, F, N>::line_graph_neighborhood_fwd_piter()
{
}
- template <typename P, typename N>
+ template <typename G, typename F, typename N>
template <typename Pref>
inline
- line_graph_neighborhood_fwd_piter<P, N>::line_graph_neighborhood_fwd_piter(const
Neighborhood<N>& nbh,
- const Pref& p_ref)
+ line_graph_neighborhood_fwd_piter<G, F,
N>::line_graph_neighborhood_fwd_piter(const Neighborhood<N>& nbh,
+ const Pref& p_ref)
: super_(p_ref)
{
this->change_target(exact(nbh));
}
- template <typename P, typename N>
+ template <typename G, typename F, typename N>
inline
bool
- line_graph_neighborhood_fwd_piter<P, N>::is_valid_() const
+ line_graph_neighborhood_fwd_piter<G, F, N>::is_valid_() const
{
return i_ != this->sites_.end();
}
- template <typename P, typename N>
+ template <typename G, typename F, typename N>
inline
void
- line_graph_neighborhood_fwd_piter<P, N>::invalidate_()
+ line_graph_neighborhood_fwd_piter<G, F, N>::invalidate_()
{
i_ = this->sites_.end();
}
- template <typename P, typename N>
+ template <typename G, typename F, typename N>
inline
void
- line_graph_neighborhood_fwd_piter<P, N>::do_start_()
+ line_graph_neighborhood_fwd_piter<G, F, N>::do_start_()
{
this->site_set().compute_sites_(*this);
i_ = this->sites_.begin();
}
- template <typename P, typename N>
+ template <typename G, typename F, typename N>
inline
void
- line_graph_neighborhood_fwd_piter<P, N>::do_next_()
+ line_graph_neighborhood_fwd_piter<G, F, N>::do_next_()
{
++i_;
}
- template <typename P, typename N>
+ template <typename G, typename F, typename N>
inline
mln_psite(N)
- line_graph_neighborhood_fwd_piter<P, N>::compute_p_() const
+ line_graph_neighborhood_fwd_piter<G, F, N>::compute_p_() const
{
- return line_graph_psite<P>(this->center().site_set(), *i_);
+ return internal::edge_psite<G, F>(this->center().site_set(), *i_);
}
/*------------------------------------------.
- | line_graph_neighborhood_bkd_piter<P, N>. |
+ | line_graph_neighborhood_bkd_piter<G, F, N>. |
`------------------------------------------*/
- template <typename P, typename N>
+ template <typename G, typename F, typename N>
inline
- line_graph_neighborhood_bkd_piter<P, N>::line_graph_neighborhood_bkd_piter()
+ line_graph_neighborhood_bkd_piter<G, F, N>::line_graph_neighborhood_bkd_piter()
{
}
- template <typename P, typename N>
+ template <typename G, typename F, typename N>
template <typename Pref>
inline
- line_graph_neighborhood_bkd_piter<P, N>::line_graph_neighborhood_bkd_piter(const
Neighborhood<N>& nbh,
+ line_graph_neighborhood_bkd_piter<G, F,
N>::line_graph_neighborhood_bkd_piter(const Neighborhood<N>& nbh,
const Pref& p_ref)
: super_(p_ref)
{
this->change_target(exact(nbh));
}
- template <typename P, typename N>
+ template <typename G, typename F, typename N>
inline
bool
- line_graph_neighborhood_bkd_piter<P, N>::is_valid_() const
+ line_graph_neighborhood_bkd_piter<G, F, N>::is_valid_() const
{
return i_ != this->sites_.rend();
}
- template <typename P, typename N>
+ template <typename G, typename F, typename N>
inline
void
- line_graph_neighborhood_bkd_piter<P, N>::invalidate_()
+ line_graph_neighborhood_bkd_piter<G, F, N>::invalidate_()
{
i_ = this->sites_.rend();
}
- template <typename P, typename N>
+ template <typename G, typename F, typename N>
inline
void
- line_graph_neighborhood_bkd_piter<P, N>::do_start_()
+ line_graph_neighborhood_bkd_piter<G, F, N>::do_start_()
{
this->site_set().compute_sites_(*this);
i_ = this->sites_.rbegin();
}
- template <typename P, typename N>
+ template <typename G, typename F, typename N>
inline
void
- line_graph_neighborhood_bkd_piter<P, N>::do_next_()
+ line_graph_neighborhood_bkd_piter<G, F, N>::do_next_()
{
++i_;
}
- template <typename P, typename N>
+ template <typename G, typename F, typename N>
inline
mln_psite(N)
- line_graph_neighborhood_bkd_piter<P, N>::compute_p_() const
+ line_graph_neighborhood_bkd_piter<G, F, N>::compute_p_() const
{
- return line_graph_psite<P>(this->center().site_set(), *i_);
+ return internal::edge_psite<G, F>(this->center().site_set(), *i_);
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/image/line_graph_psite.hh
b/milena/mln/core/image/line_graph_psite.hh
deleted file mode 100644
index 0898f30..0000000
--- a/milena/mln/core/image/line_graph_psite.hh
+++ /dev/null
@@ -1,399 +0,0 @@
-// 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
-// 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.
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_CORE_IMAGE_LINE_GRAPH_PSITE_HH
-# define MLN_CORE_IMAGE_LINE_GRAPH_PSITE_HH
-
-/// \file mln/core/image/line_graph_psite.hh
-/// \brief Definition of a line graph-based psite.
-
-# include <mln/core/internal/pseudo_site_base.hh>
-
-# include <mln/util/site_pair.hh>
-# include <mln/core/site_set/p_line_graph.hh>
-
-/* FIXME: This class shares a lot with graph_psite. Factor as much as
- possible. */
-
-// FIXME: Rename line_graph_psite as p_line_graph_psite, and move this
-// to core/site_set.
-
-
-namespace mln
-{
-
- // Forward declaration.
- template <typename P> class p_line_graph;
- template <typename P> class line_graph_psite;
-
-
- /// \brief Point site associated to a mln::line_graph_image.
- ///
- /// \arg \p P The type of the site.
- template <typename P>
- class line_graph_psite
- : public internal::pseudo_site_base_< const util::site_pair<P>&,
- line_graph_psite<P> >
- {
- typedef line_graph_psite<P> self_;
-
- public:
- // This associated type is important to know that this particular
- // pseudo site knows the site set it refers to.
- typedef p_line_graph<P> target;
-
- /// Construction and assignment.
- /// \{
- line_graph_psite();
- line_graph_psite(const p_line_graph<P>& plg, util::edge_id id);
- /// \}
-
- /// Psite manipulators.
- /// \{
- /// Is this psite valid?
- bool is_valid() const;
- /// Invalidate this psite.
- void invalidate();
- /// \}
-
- /// Site set manipulators.
- /// \{
- /// \brief Get the site set (shortcut for *target()).
- /// \pre Member plg_ is non null.
- const target& site_set() const;
-
- /// Get a pointer to the target site_set.
- const target* target_() const;
- /// Set the target site_set.
- void change_target(const target& new_target);
- /// \}
-
- /// Proxy manipulators.
- /// \{
- /// Return the site corresponding to this psite.
- const util::site_pair<P>& subj_();
- /// \}
-
- /// Edge id manipulators.
- //// \{
- /// Return the edge id of this point site.
- util::edge_id edge_id() const;
- /// Set the edge id of this point site.
- void change_edge_id(const util::edge_id& id);
- /// Increment the edge id of this point site.
- void inc_edge_id();
- /// Increment the edge id of this point site.
- void dec_edge_id();
- /// \}
-
- /// Accessors.
- /// \{
- /// Return the first associated vertex.
- P first() const;
- /// Return the second associated vertex.
- P second() const;
-
- /// Return the id of the first associated vertex.
- // FIXME: Rename as first_vertex_id.
- util::vertex_id first_id() const;
- /// Return the id of the second associated vertex.
- // FIXME: Rename as second_vertex_id.
- util::vertex_id second_id() const;
- /// \}
-
- private:
- /// Site-related members.
- /// \{
- /// Update the site corresponding to this psite.
- void update_();
- // The site corresponding to this psite.
- util::site_pair<P> p_;
- /// \}
-
- private:
- /// Graph-related members.
- /// \{
- /// The p_line_graph this point site belongs to.
- const target* plg_;
- /// The id of the edge this psite is pointing towards.
- util::edge_id id_;
- /// \}
- };
-
-
- /// Comparison of two mln::line_graph_psite<P> instances.
- /// \{
- /* FIXME: Shouldn't those comparisons be part of a much general
- mechanism? */
-
- /// \brief Is \a lhs equal to \a rhs?
- ///
- /// \pre Arguments \a lhs and \a rhs must belong to the same
- /// mln::p_line_graph.
- template <typename P>
- bool
- operator==(const line_graph_psite<P>& lhs, const
line_graph_psite<P>& rhs);
-
- /// \brief Is \a lhs not equal to \a rhs?
- ///
- /// \pre Arguments \a lhs and \a rhs must belong to the same
- /// mln::p_line_graph.
- template <typename P>
- bool
- operator!=(const line_graph_psite<P>& lhs, const
line_graph_psite<P>& rhs);
-
- /// \brief Is \a lhs ``less'' than \a rhs?
- ///
- /// This comparison is required by algorithms sorting psites.
- ///
- /// \pre Arguments \a lhs and \a rhs must belong to the same
- /// mln::p_line_graph.
- template <typename P>
- bool
- operator< (const line_graph_psite<P>& lhs, const
line_graph_psite<P>& rhs);
- /// \}
-
-
- template <typename P>
- inline
- std::ostream&
- operator<<(std::ostream& ostr, const line_graph_psite<P>& p);
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename P>
- inline
- line_graph_psite<P>::line_graph_psite()
- : plg_(0)
- {
- }
-
- template <typename P>
- inline
- line_graph_psite<P>::line_graph_psite(const p_line_graph<P>& plg,
- util::edge_id id)
- // FIXME: Use change_target instead.
- : plg_(&plg),
- id_(id)
- {
- update_();
- }
-
- template <typename P>
- inline
- bool
- line_graph_psite<P>::is_valid() const
- {
- /* FIXME: Instead of `plg_->gr_->nedges()', we should have
- something like `run_->has_edge_id(id_)' (see the implementation of
- p_run_psite. */
- return plg_ && id_ < plg_->gr_->nedges();
- }
-
- template <typename P>
- inline
- void
- line_graph_psite<P>::invalidate()
- {
- /* FIXME: Instead of `plg_->gr_->nedges()', we should have
- something like `run_->has_edge_id(id_)' (see the implementation of
- p_run_psite. */
- id_ = plg_->gr_->nedges();
- }
-
- template <typename P>
- inline
- const p_line_graph<P>&
- line_graph_psite<P>::site_set() const
- {
- mln_precondition(target_());
- return *target_();
- }
-
- template <typename P>
- inline
- const p_line_graph<P>*
- line_graph_psite<P>::target_() const
- {
- return plg_;
- }
-
- template <typename P>
- inline
- void
- line_graph_psite<P>::change_target(const target& new_target)
- {
- plg_ = &new_target;
- invalidate();
- }
-
- // FIXME: Write or extend a test to exercise this method.
- template <typename P>
- inline
- const util::site_pair<P>&
- line_graph_psite<P>::subj_()
- {
- return p_;
- }
-
- template <typename P>
- inline
- util::edge_id
- line_graph_psite<P>::edge_id() const
- {
- return id_;
- }
-
- template <typename P>
- inline
- void
- line_graph_psite<P>::change_edge_id(const util::edge_id& id)
- {
- id_ = id;
- if (is_valid())
- update_();
- }
-
- template <typename P>
- inline
- void
- line_graph_psite<P>::inc_edge_id()
- {
- ++id_.to_equiv();
- if (is_valid())
- update_();
- }
-
- template <typename P>
- inline
- void
- line_graph_psite<P>::dec_edge_id()
- {
- --id_.to_equiv();
- if (is_valid())
- update_();
- }
-
- template <typename P>
- inline
- P
- line_graph_psite<P>::first() const
- {
- mln_precondition(is_valid());
- // FIXME: Too low-level.
- return plg_->gr_->vertex_data(first_id());
- }
-
- template <typename P>
- inline
- P
- line_graph_psite<P>::second() const
- {
- mln_precondition(is_valid());
- // FIXME: Too low-level.
- return plg_->gr_->vertex_data(second_id());
- }
-
- template <typename P>
- inline
- util::vertex_id
- line_graph_psite<P>::first_id() const
- {
- mln_precondition(is_valid());
- // FIXME: Too low-level.
- return plg_->gr_->edge(id_).v1();
- }
-
- template <typename P>
- inline
- util::vertex_id
- line_graph_psite<P>::second_id() const
- {
- mln_precondition(is_valid());
- // FIXME: Too low-level.
- return plg_->gr_->edge(id_).v2();
- }
-
- template <typename P>
- inline
- void
- line_graph_psite<P>::update_()
- {
- mln_precondition(is_valid());
- p_.pair_.change_both(first(), second());
- }
-
-
- /*--------------.
- | Comparisons. |
- `--------------*/
-
- template <typename P>
- bool
- operator==(const line_graph_psite<P>& lhs, const
line_graph_psite<P>& rhs)
- {
- mln_precondition(lhs.target_() == rhs.target_());
- return lhs.edge_id() == rhs.edge_id();
- }
-
- template <typename P>
- bool
- operator!=(const line_graph_psite<P>& lhs, const
line_graph_psite<P>& rhs)
- {
- mln_precondition(lhs.target_() == rhs.target_());
- return lhs.edge_id() != rhs.edge_id();
- }
-
- template <typename P>
- bool
- operator< (const line_graph_psite<P>& lhs, const
line_graph_psite<P>& rhs)
- {
- mln_precondition(lhs.target_() == rhs.target_());
- return lhs.edge_id() < rhs.edge_id();
- }
-
-
- /*------------------.
- | Pretty-printing. |
- `------------------*/
-
- template <typename P>
- inline
- std::ostream&
- operator<<(std::ostream& ostr, const line_graph_psite<P>& p)
- {
- return ostr << '(' << p.first() << " -- "
<< p.second() << ')';
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
-} // end of mln
-
-#endif // MLN_CORE_IMAGE_LINE_GRAPH_PSITE_HH
diff --git a/milena/mln/core/image/line_graph_window_piter.hh
b/milena/mln/core/image/line_graph_window_piter.hh
index f1f7d09..3b9c00e 100644
--- a/milena/mln/core/image/line_graph_window_piter.hh
+++ b/milena/mln/core/image/line_graph_window_piter.hh
@@ -34,25 +34,21 @@
# include <mln/core/internal/line_graph_vicinity_piter.hh>
-/* FIXME: Due to the poor interface of mln::p_line_graph and
- mln::util::graph, we show to much implementation details here.
- Enrich their interfaces to avoid that. */
-
namespace mln
{
/*------------------------------------.
- | line_graph_window_fwd_piter<P, W>. |
+ | line_graph_window_fwd_piter<G, F, W>. |
`------------------------------------*/
/// \brief Forward iterator on line graph window.
- template <typename P, typename W>
+ template <typename G, typename F, typename W>
class line_graph_window_fwd_piter
- : public internal::line_graph_vicinity_piter_<P, W,
- line_graph_window_fwd_piter<P, W> >
+ : public internal::line_graph_vicinity_piter_<mln_result(F), W,
+ line_graph_window_fwd_piter<G, F, W> >
{
- typedef line_graph_window_fwd_piter<P, W> self_;
- typedef internal::line_graph_vicinity_piter_<P, W, self_> super_;
+ typedef line_graph_window_fwd_piter<G, F, W> self_;
+ typedef internal::line_graph_vicinity_piter_<mln_result(F), W, self_> super_;
public:
/// The Point_Site type.
@@ -85,21 +81,21 @@ namespace mln
private:
/// An iterator on the set of adjacent edges.
- typename super_::sites_t::const_iterator i_;
+ typename super_::sites_t::const_iterator i_;
};
/*------------------------------------.
- | line_graph_window_bkd_piter<P, W>. |
+ | line_graph_window_bkd_piter<G, F, W>. |
`------------------------------------*/
/// \brief Backward iterator on line graph window.
- template <typename P, typename W>
+ template <typename G, typename F, typename W>
class line_graph_window_bkd_piter
- : public internal::line_graph_vicinity_piter_<P, W,
line_graph_window_bkd_piter<P, W> >
+ : public internal::line_graph_vicinity_piter_<mln_result(F), W,
line_graph_window_bkd_piter<G, F, W> >
{
- typedef line_graph_window_bkd_piter<P, W> self_;
- typedef internal::line_graph_vicinity_piter_<P, W, self_> super_;
+ typedef line_graph_window_bkd_piter<G, F, W> self_;
+ typedef internal::line_graph_vicinity_piter_<mln_result(F), W, self_> super_;
public:
/// The Point_Site type.
@@ -132,7 +128,7 @@ namespace mln
private:
/// An iterator on the set of adjacent edges.
- typename super_::sites_t::const_reverse_iterator i_;
+ typename super_::sites_t::const_reverse_iterator i_;
};
@@ -140,126 +136,126 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
/*------------------------------------.
- | line_graph_window_fwd_piter<P, W>. |
+ | line_graph_window_fwd_piter<G, F, W>. |
`------------------------------------*/
- template <typename P, typename W>
+ template <typename G, typename F, typename W>
inline
- line_graph_window_fwd_piter<P, W>::line_graph_window_fwd_piter()
+ line_graph_window_fwd_piter<G, F, W>::line_graph_window_fwd_piter()
{
}
- template <typename P, typename W>
+ template <typename G, typename F, typename W>
template <typename Pref>
inline
- line_graph_window_fwd_piter<P, W>::line_graph_window_fwd_piter(const
Window<W>& win,
+ line_graph_window_fwd_piter<G, F, W>::line_graph_window_fwd_piter(const
Window<W>& win,
const Pref& p_ref)
: super_(p_ref)
{
this->change_target(exact(win));
}
- template <typename P, typename W>
+ template <typename G, typename F, typename W>
inline
bool
- line_graph_window_fwd_piter<P, W>::is_valid_() const
+ line_graph_window_fwd_piter<G, F, W>::is_valid_() const
{
return i_ != this->sites_.end();
}
- template <typename P, typename W>
+ template <typename G, typename F, typename W>
inline
void
- line_graph_window_fwd_piter<P, W>::invalidate_()
+ line_graph_window_fwd_piter<G, F, W>::invalidate_()
{
i_ = this->sites_.end();
}
- template <typename P, typename W>
+ template <typename G, typename F, typename W>
inline
void
- line_graph_window_fwd_piter<P, W>::do_start_()
+ line_graph_window_fwd_piter<G, F, W>::do_start_()
{
this->site_set().compute_sites_(*this);
i_ = this->sites_.begin();
}
- template <typename P, typename W>
+ template <typename G, typename F, typename W>
inline
void
- line_graph_window_fwd_piter<P, W>::do_next_()
+ line_graph_window_fwd_piter<G, F, W>::do_next_()
{
++i_;
}
- template <typename P, typename W>
+ template <typename G, typename F, typename W>
inline
mln_psite(W)
- line_graph_window_fwd_piter<P, W>::compute_p_() const
+ line_graph_window_fwd_piter<G, F, W>::compute_p_() const
{
- return line_graph_psite<P>(this->center().site_set(), *i_);
+ return internal::edge_psite<G, F>(this->center().site_set(), *i_);
}
/*------------------------------------.
- | line_graph_window_bkd_piter<P, W>. |
+ | line_graph_window_bkd_piter<G, F, W>. |
`------------------------------------*/
- template <typename P, typename W>
+ template <typename G, typename F, typename W>
inline
- line_graph_window_bkd_piter<P, W>::line_graph_window_bkd_piter()
+ line_graph_window_bkd_piter<G, F, W>::line_graph_window_bkd_piter()
{
}
- template <typename P, typename W>
+ template <typename G, typename F, typename W>
template <typename Pref>
inline
- line_graph_window_bkd_piter<P, W>::line_graph_window_bkd_piter(const
Window<W>& win,
- const Pref& p_ref)
+ line_graph_window_bkd_piter<G, F, W>::line_graph_window_bkd_piter(const
Window<W>& win,
+ const Pref& p_ref)
: super_(p_ref)
{
this->change_target(exact(win));
}
- template <typename P, typename W>
+ template <typename G, typename F, typename W>
inline
bool
- line_graph_window_bkd_piter<P, W>::is_valid_() const
+ line_graph_window_bkd_piter<G, F, W>::is_valid_() const
{
return i_ != this->sites_.rend();
}
- template <typename P, typename W>
+ template <typename G, typename F, typename W>
inline
void
- line_graph_window_bkd_piter<P, W>::invalidate_()
+ line_graph_window_bkd_piter<G, F, W>::invalidate_()
{
i_ = this->sites_.rend();
}
- template <typename P, typename W>
+ template <typename G, typename F, typename W>
inline
void
- line_graph_window_bkd_piter<P, W>::do_start_()
+ line_graph_window_bkd_piter<G, F, W>::do_start_()
{
this->site_set().compute_sites_(*this);
i_ = this->sites_.rbegin();
}
- template <typename P, typename W>
+ template <typename G, typename F, typename W>
inline
void
- line_graph_window_bkd_piter<P, W>::do_next_()
+ line_graph_window_bkd_piter<G, F, W>::do_next_()
{
++i_;
}
- template <typename P, typename W>
+ template <typename G, typename F, typename W>
inline
mln_psite(W)
- line_graph_window_bkd_piter<P, W>::compute_p_() const
+ line_graph_window_bkd_piter<G, F, W>::compute_p_() const
{
- return line_graph_psite<P>(this->center().site_set(), *i_);
+ return internal::edge_psite<G, F>(this->center().site_set(), *i_);
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/util/internal/graph_vertex_impl.hh
b/milena/mln/core/internal/graph_neighborhood_base.hh
similarity index 50%
copy from milena/mln/util/internal/graph_vertex_impl.hh
copy to milena/mln/core/internal/graph_neighborhood_base.hh
index 3abfaf5..0e39cce 100644
--- a/milena/mln/util/internal/graph_vertex_impl.hh
+++ b/milena/mln/core/internal/graph_neighborhood_base.hh
@@ -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,65 +25,68 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_INTERNAL_GRAPH_VERTEX_IMPL_HH
-# define MLN_CORE_INTERNAL_GRAPH_VERTEX_IMPL_HH
-
-/*! \file mln/util/internal/graph_vertex_impl.hh
- *
- * \brief Define a couple of implementation classes to provide methods
- * to classes of generalized vertexs.
- */
-
-# include <mln/core/internal/force_exact.hh>
+#ifndef MLN_CORE_INTERNAL_GRAPH_NEIGHBORHOOD_BASE_HH
+# define MLN_CORE_INTERNAL_GRAPH_NEIGHBORHOOD_BASE_HH
+/// \file mln/internal/graph_neighborhood_base.hh
+///
+/// FIXME: doc
namespace mln
{
- namespace util
+ template <typename G, typename F, typename P, typename E>
+ class graph_neighborhood_base : public Neighborhood< E >
{
-
- namespace internal
- {
-
- /// Implementation class to equip generalized vertex classes.
- template <typename G>
- class vertex_impl_
- {
- protected:
- vertex_impl_();
- };
-
- } // end of namespace internal
-
- } // end of namespace util
+ typedef graph_neighborhood_base<G, F, P, E> self_;
+
+ public:
+ /// Associated types.
+ /// \{
+ /// The type of site corresponding to the neighborhood.
+ typedef mln_site(P) site;
+
+ // The type of the set of neighborhood sites (ids adjacent to the
+ // reference psite).
+ typedef std::set<unsigned> sites_t;
+ /// \}
+
+ /// Conversions.
+ /// \{
+ /// The window type corresponding to this neighborhood.
+ typedef E window;
+ /// Create a window corresponding to this neighborhood.
+ E win() const;
+ /// \}
+
+ protected:
+ graph_neighborhood_base();
+ };
} // end of namespace mln
-#ifndef MLN_INCLUDE_ONLY
+# ifndef MLN_INCLUDE_ONLY
namespace mln
{
- namespace util
+ template <typename G, typename F, typename P, typename E>
+ inline
+ graph_neighborhood_base<G, F, P, E>::graph_neighborhood_base()
{
+ }
- namespace internal
- {
-
- template <typename G>
- inline
- vertex_impl_<G>::vertex_impl_()
- {
- }
-
- } // end of namespace internal
-
- } // end of namespace util
+ template <typename G, typename F, typename P, typename E>
+ inline
+ E
+ graph_neighborhood_base<G, F, P, E>::win() const
+ {
+ return E();
+ }
} // end of namespace mln
-#endif // ! MLN_INCLUDE_ONLY
+# endif // !MLN_INCLUDE_ONLY
+#endif // !MLN_CORE_INTERNAL_GRAPH_NEIGHBORHOOD_BASE_HH
-#endif // ! MLN_CORE_INTERNAL_GRAPH_VERTEX_IMPL_HH
diff --git a/milena/mln/core/internal/graph_window_base.hh
b/milena/mln/core/internal/graph_window_base.hh
new file mode 100644
index 0000000..ff4bfc0
--- /dev/null
+++ b/milena/mln/core/internal/graph_window_base.hh
@@ -0,0 +1,146 @@
+// 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_CORE_INTERNAL_GRAPH_WINDOW_BASE_HH
+# define MLN_CORE_INTERNAL_GRAPH_WINDOW_BASE_HH
+
+/// \file mln/internal/graph_window_base.hh
+///
+/// FIXME: doc
+
+namespace mln
+{
+
+ template <typename G, typename F, typename P, typename E>
+ class graph_window_base : public Window< E >
+ {
+ typedef graph_window_base<G, F, P, E> self_;
+
+ public:
+ /// Associated types.
+ /// \{
+ /// The type of site corresponding to the window.
+ typedef mln_site(P) site;
+
+ // The type of the set of window sites (ids adjacent to the
+ // reference psite).
+ typedef std::set<unsigned> sites_t;
+
+ // FIXME: This is a dummy value.
+ typedef void dpsite;
+ /// \}
+
+ /// Interface of the concept Window.
+ /// \{
+ /// Is the window is empty?
+ bool is_empty() const;
+ /// Is the window centered?
+ bool is_centered() const;
+ /// Is the window symmetric?
+ // FIXME: We should define this more precisely.
+ bool is_symmetric() const;
+ /// Return the maximum coordinate gap between the window center
+ /// and a window point.
+ /* FIXME: This method returns a dummy value (0), since the delta
+ of a window on a graph/line_graph
+
+ 1. is not constant (line graph edges/graph vertices are not necessarily
+ aligned on a regular grid);
+
+ 2. depends on the underlying line_graph/graph, too.
+
+ It raises another question: should delta() be part of the
+ concept ``Window''? */
+ unsigned delta() const;
+ /// Apply a central symmetry to the target window.
+ self_& sym();
+ /// \}
+
+ protected:
+ graph_window_base();
+ };
+
+} // end of namespace mln
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ template <typename G, typename F, typename P, typename E>
+ inline
+ graph_window_base<G, F, P, E>::graph_window_base()
+ {
+ }
+
+ template <typename G, typename F, typename P, typename E>
+ inline
+ bool
+ graph_window_base<G, F, P, E>::is_empty() const
+ {
+ return false;
+ }
+
+ template <typename G, typename F, typename P, typename E>
+ inline
+ bool
+ graph_window_base<G, F, P, E>::is_centered() const
+ {
+ return false;
+ }
+
+ template <typename G, typename F, typename P, typename E>
+ inline
+ bool
+ graph_window_base<G, F, P, E>::is_symmetric() const
+ {
+ return true;
+ }
+
+ template <typename G, typename F, typename P, typename E>
+ inline
+ unsigned
+ graph_window_base<G, F, P, E>::delta() const
+ {
+ // Dummy value (see the interface of the method above).
+ return 0;
+ }
+
+ template <typename G, typename F, typename P, typename E>
+ inline
+ graph_window_base<G, F, P, E>&
+ graph_window_base<G, F, P, E>::sym()
+ {
+ return *this;
+ }
+
+} // end of namespace mln
+
+# endif // !MLN_INCLUDE_ONLY
+
+#endif // !MLN_CORE_INTERNAL_GRAPH_WINDOW_BASE_HH
+
diff --git a/milena/mln/core/internal/line_graph_vicinity_piter.hh
b/milena/mln/core/internal/line_graph_vicinity_piter.hh
index 395b014..9ef41e6 100644
--- a/milena/mln/core/internal/line_graph_vicinity_piter.hh
+++ b/milena/mln/core/internal/line_graph_vicinity_piter.hh
@@ -36,8 +36,6 @@
# include <set>
# include <mln/core/internal/site_relative_iterator_base.hh>
-# include <mln/core/site_set/p_line_graph.hh>
-# include <mln/core/image/line_graph_psite.hh>
/* FIXME: Factor those classes:
@@ -47,9 +45,6 @@
namespace mln
{
- // Fwd decls.
- template <typename P> class p_line_graph;
- template <typename P> class line_graph_psite;
// FIXME: Consider renaming line_graph_vicinity_piter_ as
// line_graph_relative_piter_.
@@ -72,7 +67,7 @@ namespace mln
typedef void mesh;
// The type of the set of vicinity sites (adjacent edge ids).
- typedef std::set<util::edge_id> sites_t;
+ typedef std::set<unsigned> sites_t;
public:
/// Return the set of sites (adjacent edge ids).
@@ -119,7 +114,7 @@ namespace mln
template <typename P, typename S, typename E>
inline
- std::set<util::edge_id>&
+ std::set<unsigned>&
line_graph_vicinity_piter_<P, S, E>::sites()
{
return sites_;
diff --git a/milena/mln/core/site_set/p_graph.hh b/milena/mln/core/site_set/p_graph.hh
deleted file mode 100644
index c0711c6..0000000
--- a/milena/mln/core/site_set/p_graph.hh
+++ /dev/null
@@ -1,396 +0,0 @@
-// 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
-// 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.
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_CORE_SITE_SET_P_GRAPH_HH
-# define MLN_CORE_SITE_SET_P_GRAPH_HH
-
-/// \file mln/core/site_set/p_graph.hh
-/// \brief Definition of a point set based on a graph.
-
-# include <mln/core/internal/site_set_base.hh>
-# include <mln/util/graph.hh>
-# include <mln/util/tracked_ptr.hh>
-
-# include <mln/core/site_set/p_graph_piter.hh>
-
-/* FIXME: This class shares a lot with p_line_graph. Factor as much
- as possible. */
-
-/* FIXME: We should move the `adjacent'/`adjacent_or_equal' methods
- out of this class (into iterators on *graph*). */
-
-
-namespace mln
-{
- // Forward declaration.
- template <typename P> struct p_graph;
-
- namespace trait
- {
- template <typename P>
- struct site_set_< p_graph<P> >
- {
- typedef trait::site_set::nsites::known nsites;
- // FIXME: Depends on P!
- typedef trait::site_set::bbox::unknown bbox;
- typedef trait::site_set::contents::fixed contents;
- typedef trait::site_set::arity::unique arity;
- };
- } // end of namespace mln::trait
-
-
- template <typename P>
- struct p_graph
- : public internal::site_set_base_< P, p_graph<P> >
- {
- typedef p_graph<P> self_;
- typedef internal::site_set_base_< P, self_ > super_;
-
- typedef util::graph graph;
-
- /// \brief Construct a graph psite set from a graph of points.
- ///
- /// \param gr The graph upon which the graph psite set is built.
- ///
- /// \a gr is \em copied internally, so that the graph psite set is
- /// still valid after the initial graph has been removed.
- p_graph(const graph& gr);
-
- /// Associated types.
- /// \{
- /// Element associated type.
- typedef mln_site(super_) element;
- /// Point_Site associated type.
- typedef graph_psite<P> psite;
-
- /// Forward Site_Iterator associated type.
- typedef p_graph_fwd_piter_<P> fwd_piter;
-
- /// Backward Site_Iterator associated type.
- typedef p_graph_bkd_piter_<P> bkd_piter;
-
- /// 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.
- ///
- /// Required by the mln::Point_Set concept.
- unsigned nsites() const;
-
- /// Return The number of vertices in the graph.
- unsigned nvertices() const;
- /// Return The number of edges in the graph.
- unsigned nedges() const;
-
- /// Is this site set valid?
- bool is_valid() const;
-
- /// Does this site set has \a p?
- bool has(const psite& p) const;
-
- // FIXME: Dummy.
- std::size_t memory_size() const;
-
- /// Accessors.
- /// \{
- /// Return the graph associated to this site set (const version)
- const graph& gr() const;
- /// Return the graph associated to this site set (mutable version).
- graph& gr();
- /// \}
-
- /// \brief Graph-related services
- ///
- /// \todo Move them into iterators on graphs.
- /// \{
- /// Return the graph point (FIXME site?) from an index
- const P& point_from_id(const util::vertex_id& id) const;
- P& point_from_id(const util::vertex_id& id);
-
- /// Return the point contained in the first vertex adjacent
- // to the edge id \a e.
- const P& vertex1(const util::edge_id& e) const;
- /// Return the point contained in the second vertex adjacent
- /// to the edge id \a e.
- const P& vertex2(const util::edge_id& e) const;
-
- // FIXME: These would probably be no longer needed as soon as
- // iterators on graphs are available.
-
- /// Adjacency tests.
- /// \{
- /// Return true if the psites \a lhs and \a rhs are adjacent.
- /// (If \a lhs and \a rhs are equal, return false).
- bool adjacent(const psite& lhs, const psite& rhs) const;
- /// Return true if the vertices \a lhs and \a rhs are adjacent.
- /// (If \a lhs and \a rhs are equal, return false).
- bool adjacent(const util::vertex_id& lhs, const util::vertex_id& rhs) const;
-
- /// Return true if the psites \a lhs and \a rhs are adjacent, or equal.
- bool adjacent_or_equal(const psite& lhs, const psite& rhs) const;
- /// Return true if the vertices \a lhs and \a rhs are adjacent, or equal
- bool adjacent_or_equal(const util::vertex_id& lhs,
- const util::vertex_id& rhs) const;
- /// \}
-
- /// \}
-
- public:
- // FIXME: Should be private.
- util::tracked_ptr<graph> gr_;
- };
-
-
- /// \brief Comparison between two mln::p_graph's.
- ///
- /// Two mln::p_graph's are considered equal if they share the
- /// same graph.
- template <typename P>
- bool
- operator==(const p_graph<P>& lhs, const p_graph<P>& rhs);
-
-
- /* FIXME: Extend the `ord' mechanism instead of this ill-defined
- pseudo-order. */
-
- /// \brief Inclusion of a mln::p_graph in another one.
- ///
- /// This inclusion relation is very strict for the moment, since our
- /// infrastructure for graphs is simple: a mln::p_graph is included
- /// in another one if their are equal.
- ///
- /// \todo Refine this later, when we are able to express subgraph
- /// relations.
- template <typename P>
- bool
- operator<=(const p_graph<P>& lhs, const p_graph<P>& rhs);
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename P>
- inline
- p_graph<P>::p_graph(const graph& gr)
- // Create a deep, managed copy of GR.
- : gr_ (new util::graph(gr))
- {
- }
-
- template <typename P>
- inline
- unsigned
- p_graph<P>::nsites() const
- {
- return nvertices();
- }
-
- template <typename P>
- inline
- unsigned
- p_graph<P>::nvertices() const
- {
- return this->gr_->nvertices();
- }
-
- template <typename P>
- inline
- unsigned
- p_graph<P>::nedges() const
- {
- return this->gr_->nedges();
- }
-
- template <typename P>
- inline
- bool
- p_graph<P>::is_valid() const
- {
- // FIXME: Might be too low-level, again.
- return gr_.ptr_;
- }
-
- template <typename P>
- inline
- bool
- p_graph<P>::has(const psite& p) const
- {
- mln_precondition(is_valid());
- return
- // Check whether P is compatible with this psite set.
- (p.target_() == this) &&
- // Check that the vertex id of P belongs to the range of valid
- // vertex ids.
- (p.is_valid());
- }
-
- template <typename P>
- inline
- std::size_t
- p_graph<P>::memory_size() const
- {
- // FIXME: Dummy; implement (see other site sets).
- abort();
- return 0;
- }
-
- template <typename P>
- const typename p_graph<P>::graph&
- p_graph<P>::gr() const
- {
- mln_precondition(is_valid());
- return *gr_.ptr;
- }
-
- template <typename P>
- typename p_graph<P>::graph&
- p_graph<P>::gr()
- {
- mln_precondition(is_valid());
- return *gr_.ptr;
- }
-
- template <typename P>
- const P&
- p_graph<P>::point_from_id(const util::vertex_id& id) const
- {
- return this->gr_->vertex_data(id);
- }
-
- template <typename P>
- P&
- p_graph<P>::point_from_id(const util::vertex_id& id)
- {
- return this->gr_->vertex_data(id);
- }
-
- template <typename P>
- const P&
- p_graph<P>::vertex1(const util::edge_id& e) const
- {
- util::vertex_id v1 = this->gr_->edge(e).v1();
- return this->point_from_id(v1);
- }
-
- template <typename P>
- const P&
- p_graph<P>::vertex2(const util::edge_id& e) const
- {
- util::vertex_id v2 = this->gr_->edge(e).v2();
- return this->point_from_id(v2);
- }
-
- template <typename P>
- inline
- bool
- p_graph<P>::adjacent(const psite& lhs, const psite& rhs) const
- {
- mln_assertion(&lhs.pg() == this && rhs.pg() == this);
- return adjacent(lhs.id(), rhs.id());
- }
-
- /* FIXME: This could be more efficient, if the graph structure had a
- richer interface. */
- template <typename P>
- inline
- bool
- p_graph<P>::adjacent(const util::vertex_id& lhs,
- const util::vertex_id& rhs) const
- {
- mln_assertion(lhs < this->nsites());
- mln_assertion(rhs < this->nsites());
-
- // Ensure LHS and RHS are *not* equal.
- if (rhs == lhs)
- return false;
-
- // Check whether LHS and RHS are adjacent (i.e., whether RHS is
- // among the neighbors of LHS).
- typedef std::vector<util::edge_id> edges_t;
- const edges_t& lhs_neighbs = gr_->vertices()[lhs]->edges;
- for (edges_t::const_iterator e = lhs_neighbs.begin();
- e != lhs_neighbs.end(); ++e)
- if (gr_->edges()[*e]->v1() == rhs ||
- gr_->edges()[*e]->v2() == rhs)
- return true;
-
- return false;
- }
-
- template <typename P>
- inline
- bool
- p_graph<P>::adjacent_or_equal(const psite& lhs, const psite& rhs) const
- {
- mln_assertion(&lhs.pg() == this && rhs.pg() == this);
- return adjacent_or_equal(lhs.id(), rhs.id());
- }
-
- template <typename P>
- inline
- bool
- p_graph<P>::adjacent_or_equal(const util::vertex_id& lhs,
- const util::vertex_id& rhs) const
- {
- mln_assertion(lhs < this->nsites());
- mln_assertion(rhs < this->nsites());
-
- // Check whether LHS and RHS are equal.
- if (lhs == rhs)
- return true;
- // Check whether LHS and RHS are adjacent.
- return adjacent(lhs, rhs);
- }
-
-
- template <typename P>
- bool
- operator==(const p_graph<P>& lhs, const p_graph<P>& rhs)
- {
- /* FIXME: We should not rely on pointer equality here, as graph
- will soon become shells using (shared) tracked pointers to
- actual data. So, delegate the equality test to the graphs
- themselves. */
- return lhs.gr_.ptr_ == rhs.gr_.ptr_;
- }
-
- template <typename P>
- bool
- operator<=(const p_graph<P>& lhs, const p_graph<P>& rhs)
- {
- return lhs == rhs;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
-} // end of mln
-
-
-#endif // MLN_CORE_SITE_SET_P_GRAPH_HH
diff --git a/milena/mln/core/site_set/p_line_graph.hh
b/milena/mln/core/site_set/p_line_graph.hh
deleted file mode 100644
index 28780ea..0000000
--- a/milena/mln/core/site_set/p_line_graph.hh
+++ /dev/null
@@ -1,360 +0,0 @@
-// 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
-// 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.
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_CORE_SITE_SET_P_LINE_GRAPH_HH
-# define MLN_CORE_SITE_SET_P_LINE_GRAPH_HH
-
-/// \file mln/core/site_set/p_line_graph.hh
-/// \brief Definition of a point set based on a line graph.
-
-# include <mln/core/internal/site_set_base.hh>
-# include <mln/util/graph.hh>
-# include <mln/util/tracked_ptr.hh>
-# include <mln/util/site_pair.hh>
-
-# include <mln/core/image/line_graph_psite.hh>
-# include <mln/core/site_set/p_line_graph_piter.hh>
-
-/* FIXME: This class shares a lot with p_graph. Factor as much as
- possible. */
-
-/* FIXME: We should move the `adjacent'/`adjacent_or_equal' methods
- out of this class (into iterators on *graph*). */
-
-namespace mln
-{
-
- // Forward declaration.
- template<typename P> struct p_line_graph;
-
-
- namespace trait
- {
- template <typename P>
- struct site_set_< p_line_graph<P> >
- {
- typedef trait::site_set::nsites::known nsites;
- // FIXME: Depends on P!
- typedef trait::site_set::bbox::unknown bbox;
- typedef trait::site_set::contents::fixed contents;
- typedef trait::site_set::arity::unique arity;
- };
- } // end of namespace mln::trait
-
-
- template<typename P>
- struct p_line_graph
- : public internal::site_set_base_< util::site_pair<P>, p_line_graph<P>
>
- {
- typedef p_line_graph<P> self_;
- typedef internal::site_set_base_< util::site_pair<P>, self_ > super_;
-
- typedef util::graph<P> graph;
-
- /// \brief Construct a line graph psite set from a graph of points.
- ///
- /// \param gr The graph upon which the line graph psite set is built.
- ///
- /// \a gr is \em copied internally, so that the line graph psite
- /// set is still valid after the initial graph has been removed.
- p_line_graph(const graph& gr);
-
- /// Associated types.
- /// \{
- /// Element associated type.
- typedef mln_site(super_) element;
-
- /// Point_Site associated type.
- typedef line_graph_psite<P> psite;
-
- /// Forward Site_Iterator associated type.
- typedef p_line_graph_fwd_piter_<P> fwd_piter;
-
- /// Backward Site_Iterator associated type.
- typedef p_line_graph_bkd_piter_<P> bkd_piter;
-
- /// Site_Iterator associated type.
- typedef fwd_piter piter;
- /// \}
-
- /// \brief Return The number of sites of the set, i.e., the number
- /// of \em edges.
- ///
- /// (Required by the mln::Site_Set concept, since the property
- /// trait::site_set::nsites::known of this site set is set to
- /// `known'.)
- /* FIXME: Return type should be std::size_t (see
- mln/core/concept/site_set.hh). */
- unsigned nsites() const;
-
- /// Return The number of vertices in the graph.
- unsigned nvertices() const;
- /// Return The number of edges in the graph.
- unsigned nedges() const;
-
- /// Is this site set valid?
- bool is_valid() const;
-
- /// Does this site set has \a p?
- bool has(const psite& p) const;
-
- // FIXME: Dummy.
- std::size_t memory_size() const;
-
- /// Accessors.
- /// \{
- /// Return the graph associated to this site set (const version)
- const graph& gr() const;
- /// Return the graph associated to this site set (mutable version).
- graph& gr();
- /// \}
-
- // FIXME: These would probably be no longer needed as soon as
- // iterators on graphs are available.
-
- /// Adjacency tests.
- /// \{
- /// Return true if the psites \a lhs and \a rhs are adjacent.
- /// (If \a lhs and \a rhs are equal, return false).
- bool adjacent(const psite& lhs, const psite& rhs) const;
- /// Return true if the edges \a lhs and \a rhs are adjacent.
- /// (If \a lhs and \a rhs are equal, return false).
- bool adjacent(const util::edge_id& lhs, const util::edge_id& rhs) const;
-
- /// Return true if the psites \a lhs and \a rhs are adjacent, or equal.
- bool adjacent_or_equal(const psite& lhs, const psite& rhs) const;
- /// Return true if the edges \a lhs and \a rhs are adjacent, or equal
- bool adjacent_or_equal(const util::edge_id& lhs,
- const util::edge_id& rhs) const;
- /// \}
-
- // FIXME: Should be private.
- /// The graph on which the pset is built.
- util::tracked_ptr<graph> gr_;
- };
-
-
- /// \brief Comparison between two mln::p_line_graph's.
- ///
- /// Two mln::p_line_graph's are considered equal if they share the
- /// same graph.
- template <typename P>
- bool
- operator==(const p_line_graph<P>& lhs, const p_line_graph<P>&
rhs);
-
-
- /* FIXME: Extend the `ord' mechanism instead of this ill-defined
- pseudo-order. */
-
- /// \brief Inclusion of a mln::p_line_graph in another one.
- ///
- /// This inclusion relation is very strict for the moment, since our
- /// infrastructure for graphs is simple: a mln::p_line_graph is
- /// included in another one if their are equal.
- ///
- /// \todo Refine this later, when we are able to express subgraph
- /// relations.
- template <typename P>
- bool
- operator<=(const p_line_graph<P>& lhs, const p_line_graph<P>&
rhs);
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename P>
- inline
- p_line_graph<P>::p_line_graph(const graph& gr)
- // Create a deep, managed copy of GR.
- : gr_(new util::graph<P>(gr))
- {
- }
-
- template <typename P>
- inline
- unsigned
- p_line_graph<P>::nsites() const
- {
- return nedges();
- }
-
- template <typename P>
- inline
- unsigned
- p_line_graph<P>::nvertices() const
- {
- return this->gr_->nvertices();
- }
-
- template <typename P>
- inline
- unsigned
- p_line_graph<P>::nedges() const
- {
- return this->gr_->nedges();
- }
-
- template <typename P>
- inline
- bool
- p_line_graph<P>::is_valid() const
- {
- // FIXME: Might be too low-level, again.
- return gr_.ptr_;
- }
-
- template <typename P>
- inline
- bool
- p_line_graph<P>::has(const psite& p) const
- {
- mln_precondition(is_valid());
- return
- // Check whether P is compatible with this psite set.
- (p.target_() == this) &&
- // Check that the edge id of P belongs to the range of valid edge ids.
- (p.is_valid());
- }
-
- template <typename P>
- inline
- std::size_t
- p_line_graph<P>::memory_size() const
- {
- // FIXME: Dummy; implement (see other site sets).
- abort();
- return 0;
- }
-
- template <typename P>
- const util::graph<P>&
- p_line_graph<P>::gr() const
- {
- mln_precondition(is_valid());
- return *gr_.ptr_;
- }
-
- template <typename P>
- util::graph<P>&
- p_line_graph<P>::gr()
- {
- mln_precondition(is_valid());
- return *gr_.ptr_;
- }
-
- template <typename P>
- inline
- bool
- p_line_graph<P>::adjacent(const psite& lhs, const psite& rhs) const
- {
- mln_assertion(&lhs.plg() == this && rhs.plg() == this);
- return adjacent(lhs.id(), rhs.id());
- }
-
- /* FIXME: This could be more efficient, if the graph structure had a
- richer interface. */
- template <typename P>
- inline
- bool
- p_line_graph<P>::adjacent(const util::edge_id& lhs,
- const util::edge_id& rhs) const
- {
- mln_assertion(lhs < this->nsites());
- mln_assertion(rhs < this->nsites());
-
- // Ensure LHS and RHS are *not* equal.
- if (lhs == rhs)
- return false;
-
- // Check whether LHS and RHS are adjacent (i.e., whether LHS and
- // RHS share a common vertex.
- /* FIXME: This is too low-level. Yet another service the graph
- should provide. */
- if (gr_->edge(lhs).v1() == gr_->edge(rhs).v1() ||
- gr_->edge(lhs).v1() == gr_->edge(rhs).v2() ||
- gr_->edge(lhs).v2() == gr_->edge(rhs).v1() ||
- gr_->edge(lhs).v2() == gr_->edge(rhs).v2())
- return true;
-
- return false;
- }
-
- template <typename P>
- inline
- bool
- p_line_graph<P>::adjacent_or_equal(const psite& lhs, const psite& rhs)
const
- {
- mln_assertion(&lhs.pg() == this && rhs.pg() == this);
- return adjacent_or_equal(lhs.id(), rhs.id());
- }
-
- template <typename P>
- inline
- bool
- p_line_graph<P>::adjacent_or_equal(const util::edge_id& lhs,
- const util::edge_id& rhs) const
- {
- mln_assertion(lhs < this->nsites());
- mln_assertion(rhs < this->nsites());
-
- // Check whether LHS and RHS are equal.
- if (lhs == rhs)
- return true;
- // Check whether RHS and LHS are adjacent.
- return adjacent(lhs, rhs);
- }
-
-
- /*--------------.
- | Comparisons. |
- `--------------*/
-
- template <typename P>
- bool
- operator==(const p_line_graph<P>& lhs, const p_line_graph<P>& rhs)
- {
- /* FIXME: We should not rely on pointer equality here, as graph
- will soon become shells using (shared) tracked pointers to
- actual data. So, delegate the equality test to the graphs
- themselves. */
- return lhs.gr_.ptr_ == rhs.gr_.ptr_;
- }
-
- template <typename P>
- bool
- operator<=(const p_line_graph<P>& lhs, const p_line_graph<P>&
rhs)
- {
- return lhs == rhs;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
-} // end of mln
-
-
-#endif // ! MLN_CORE_SITE_SET_P_LINE_GRAPH_HH
diff --git a/milena/mln/core/site_set/p_line_graph_piter.hh
b/milena/mln/core/site_set/p_line_graph_piter.hh
deleted file mode 100644
index 8c73c26..0000000
--- a/milena/mln/core/site_set/p_line_graph_piter.hh
+++ /dev/null
@@ -1,272 +0,0 @@
-// 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
-// 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.
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_CORE_SITE_SET_P_LINE_GRAPH_PITER_HH
-# define MLN_CORE_SITE_SET_P_LINE_GRAPH_PITER_HH
-
-/// \file mln/core/site_set/p_line_graph_piter.hh
-/// \brief Definition of point iterators on line graph-based site set.
-
-# include <mln/core/internal/site_set_iterator_base.hh>
-# include <mln/core/site_set/p_line_graph.hh>
-# include <mln/core/image/line_graph_psite.hh>
-
-/* FIXME: Iterators on p_graph and p_line_graph share common code.
- Factor as much as possible. */
-
-
-namespace mln
-{
-
- // Forward declarations.
- template <typename P> class p_line_graph;
- template <typename P> class line_graph_psite;
-
-
- /*-----------------------------.
- | p_line_graph_fwd_piter_<P>. |
- `-----------------------------*/
-
- /// \brief Forward iterator on point sites of a mln::p_line_graph<P>.
- template <typename P>
- class p_line_graph_fwd_piter_
- : public internal::site_set_iterator_base< p_line_graph<P>,
- p_line_graph_fwd_piter_<P> >
- {
- typedef p_line_graph_fwd_piter_<P> self_;
- typedef internal::site_set_iterator_base< p_line_graph<P>, self_ >
super_;
-
- public:
- /// Construction and assignment.
- /// \{
- p_line_graph_fwd_piter_();
- p_line_graph_fwd_piter_(const p_line_graph<P>& plg);
- /// \}
-
- /// Manipulation.
- /// \{
- /// Test if the iterator is valid.
- bool is_valid_() const;
- /// Invalidate the iterator.
- void invalidate_();
-
- /// Start an iteration.
- void start_();
- /// Go to the next point.
- void next_();
- /// \}
-
- protected:
- /// The psite corresponding to this iterator.
- using super_::p_;
- };
-
-
- /// Print an mln::p_line_graph_fwd_piter_<P>.
- template <typename P>
- inline
- std::ostream&
- operator<<(std::ostream& ostr, const p_line_graph_fwd_piter_<P>&
p);
-
-
- /*-----------------------------.
- | p_line_graph_bkd_piter_<P>. |
- `-----------------------------*/
-
- /// \brief Backward iterator on point sites of a mln::p_line_graph<P>.
- template <typename P>
- class p_line_graph_bkd_piter_
- : public internal::site_set_iterator_base< p_line_graph<P>,
- p_line_graph_bkd_piter_<P> >
- {
- typedef p_line_graph_bkd_piter_<P> self_;
- typedef internal::site_set_iterator_base< p_line_graph<P>, self_ >
super_;
-
- public:
- /// Construction and assignment.
- /// \{
- p_line_graph_bkd_piter_();
- p_line_graph_bkd_piter_(const p_line_graph<P>& plg);
- /// \}
-
- /// Manipulation.
- /// \{
- /// Test if the iterator is valid.
- bool is_valid_() const;
- /// Invalidate the iterator.
- void invalidate_();
-
- /// Start an iteration.
- void start_();
- /// Go to the next point.
- void next_();
- /// \}
-
- protected:
- /// The psite corresponding to this iterator.
- using super_::p_;
- };
-
-
- /// Print an mln::p_line_graph_bkd_piter_<P>.
- template <typename P>
- inline
- std::ostream&
- operator<<(std::ostream& ostr, const p_line_graph_bkd_piter_<P>&
p);
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- /*-----------------------------.
- | p_line_graph_fwd_piter_<P>. |
- `-----------------------------*/
-
- template <typename P>
- inline
- p_line_graph_fwd_piter_<P>::p_line_graph_fwd_piter_()
- {
- mln_postcondition(!this->is_valid());
- }
-
- template <typename P>
- inline
- p_line_graph_fwd_piter_<P>::p_line_graph_fwd_piter_(const
p_line_graph<P>& plg)
- {
- this->change_target(plg);
- mln_postcondition(!this->is_valid());
- }
-
- template <typename P>
- inline
- bool
- p_line_graph_fwd_piter_<P>::is_valid_() const
- {
- return p_.is_valid();
- }
-
- template <typename P>
- inline
- void
- p_line_graph_fwd_piter_<P>::invalidate_()
- {
- p_.invalidate();
- }
-
- template <typename P>
- inline
- void
- p_line_graph_fwd_piter_<P>::start_()
- {
- p_.change_edge_id(0);
- }
-
- template <typename P>
- inline
- void
- p_line_graph_fwd_piter_<P>::next_()
- {
- p_.inc_edge_id();
- }
-
-
- template <typename P>
- inline
- std::ostream&
- operator<<(std::ostream& ostr, const p_line_graph_fwd_piter_<P>&
p)
- {
- return ostr << p.unproxy_();
- }
-
-
- /*-----------------------------.
- | p_line_graph_bkd_piter_<P>. |
- `-----------------------------*/
-
- template <typename P>
- inline
- p_line_graph_bkd_piter_<P>::p_line_graph_bkd_piter_()
- {
- mln_postcondition(!this->is_valid());
- }
-
- template <typename P>
- inline
- p_line_graph_bkd_piter_<P>::p_line_graph_bkd_piter_(const
p_line_graph<P>& plg)
- {
- this->change_target(plg);
- mln_postcondition(!this->is_valid());
- }
-
- template <typename P>
- inline
- bool
- p_line_graph_bkd_piter_<P>::is_valid_() const
- {
- return p_.is_valid();
- }
-
- template <typename P>
- inline
- void
- p_line_graph_bkd_piter_<P>::invalidate_()
- {
- p_.change_edge_id(this->site_set().nedges());
- }
-
- template <typename P>
- inline
- void
- p_line_graph_bkd_piter_<P>::start_()
- {
- p_.change_edge_id(this->site_set().nedges() - 1);
- }
-
- template <typename P>
- inline
- void
- p_line_graph_bkd_piter_<P>::next_()
- {
- p_.dec_edge_id();
- }
-
-
- template <typename P>
- inline
- std::ostream&
- operator<<(std::ostream& ostr, const p_line_graph_bkd_piter_<P>&
p)
- {
- return ostr << p.unproxy_();
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
-} // end of mln
-
-
-#endif // ! MLN_CORE_SITE_SET_P_LINE_GRAPH_PITER_HH
diff --git a/milena/mln/make/all.hh b/milena/mln/make/all.hh
index 5d11136..910d943 100644
--- a/milena/mln/make/all.hh
+++ b/milena/mln/make/all.hh
@@ -55,7 +55,7 @@ namespace mln
# include <mln/make/pixel.hh>
# include <mln/make/point2d_h.hh>
# include <mln/make/vec.hh>
-//# include <mln/make/voronoi.hh>
+# include <mln/make/voronoi.hh>
# include <mln/make/w_window.hh>
# include <mln/make/w_window1d.hh>
# include <mln/make/w_window1d_int.hh>
diff --git a/milena/mln/make/essential.hh b/milena/mln/make/essential.hh
index d0e8f85..856e75a 100644
--- a/milena/mln/make/essential.hh
+++ b/milena/mln/make/essential.hh
@@ -40,9 +40,9 @@
# include <mln/make/pix.hh>
# include <mln/make/pixel.hh>
# include <mln/make/vec.hh>
-//# include <mln/make/voronoi.hh>
+# include <mln/make/voronoi.hh>
# include <mln/make/w_window.hh>
# include <mln/make/w_window_directional.hh>
-//# include <mln/make/win_chamfer.hh>
+# include <mln/make/win_chamfer.hh>
#endif // ! MLN_MAKE_ESSENTIAL_HH
diff --git a/milena/mln/make/voronoi.hh b/milena/mln/make/voronoi.hh
index 0127c97..30101f2 100644
--- a/milena/mln/make/voronoi.hh
+++ b/milena/mln/make/voronoi.hh
@@ -29,18 +29,18 @@
#ifndef MLN_MAKE_VORONOI_HH
# define MLN_MAKE_VORONOI_HH
-/*! \file mln/make/voronoi.hh
- *
- * \brief Routine to construct a Voronoi mln::p_graph.
- */
+/// \file mln/make/voronoi.hh
+///
+/// Routine to construct a Voronoi mln::p_graph.
# include <vector>
# include <map>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/core/site_set/p_graph.hh>
+# include <mln/core/site_set/p_vertices.hh>
# include <mln/accu/mean.hh>
# include <mln/estim/min_max.hh>
+# include <mln/util/graph.hh>
namespace mln
{
@@ -48,10 +48,9 @@ namespace mln
namespace make
{
+ /// Apply the Voronoi algorithm on \p ima_ with the original
+ /// image \p orig_ for node computing with neighborhood \p nbh.
/*!
- * \brief Apply the Voronoi algorithm on \p ima_ with the original
- * image \p orig_ for node computing with neighborhood \p nbh.
- *
* \param[in] ima_ The labeling image.
* \param[in] orig_ The original image.
* \param[in] nbh The neighborhood for computing algorithm.
@@ -59,7 +58,7 @@ namespace mln
* \return The computed graph.
*/
template <typename I, typename N>
- p_graph<mln_psite(I)>
+ p_vertices<util::graph, fun::i2v::array<mln_site(I)> >
voronoi (Image<I>& ima_,
Image<I>& orig_,
const Neighborhood<N>& nbh);
@@ -68,7 +67,7 @@ namespace mln
template <typename I, typename N>
inline
- p_graph<mln_psite(I)>
+ p_vertices<util::graph, fun::i2v::array<mln_site(I)> >
voronoi (Image<I>& ima_,
Image<I>& orig_,
const Neighborhood<N>& nbh)
@@ -79,11 +78,11 @@ namespace mln
I& ima = exact(ima_);
I& orig = exact(orig_);
- util::graph<void> gr;
+ util::graph gr;
V min, max;
estim::min_max (ima, min, max);
unsigned nb = max - min + 1;
- std::vector<P> v(nb);
+ fun::i2v::array<P> v(nb);
std::vector< accu::mean< X > > tab_mean (nb);
std::map<std::pair<V, V>, bool> m;
@@ -120,7 +119,7 @@ namespace mln
gr.add_vertex();
/// FIXME
- v[i] = point2d ((unsigned)tab_mean[i].to_result ()[0],
+ v[i] = point2d ((unsigned)tab_mean[i].to_result ()[0],
(unsigned)tab_mean[i].to_result ()[1]);
}
@@ -128,7 +127,7 @@ namespace mln
for (; it != m.end (); ++it)
gr.add_edge((*it).first.first, (*it).first.second);
- p_graph<P> res(gr, v);
+ p_vertices<util::graph, fun::i2v::array<P> > res(gr, v);
return res;
}
diff --git a/milena/mln/util/graph.hh b/milena/mln/util/graph.hh
index 0f8c1fa..dfcbc23 100644
--- a/milena/mln/util/graph.hh
+++ b/milena/mln/util/graph.hh
@@ -30,7 +30,7 @@
# define MLN_UTIL_GRAPH_HH
/// \file mln/util/graph.hh
-/// \brief Definitions of undirected graphs.
+/// Definitions of undirected graphs.
# include <mln/util/internal/graph_base.hh>
# include <mln/util/internal/graph_iter.hh>
diff --git a/milena/mln/util/internal/graph_edge_impl.hh
b/milena/mln/util/internal/graph_edge_impl.hh
index 7f77f2a..3b75086 100644
--- a/milena/mln/util/internal/graph_edge_impl.hh
+++ b/milena/mln/util/internal/graph_edge_impl.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,11 +28,10 @@
#ifndef MLN_CORE_INTERNAL_GRAPH_EDGE_IMPL_HH
# define MLN_CORE_INTERNAL_GRAPH_EDGE_IMPL_HH
-/*! \file mln/util/internal/graph_edge_impl.hh
- *
- * \brief Define a couple of implementation classes to provide methods
- * to classes of generalized edges.
- */
+/// \file mln/util/internal/graph_edge_impl.hh
+///
+/// Define a couple of implementation classes to provide methods
+/// to classes of generalized edges.
# include <mln/core/internal/force_exact.hh>
diff --git a/milena/mln/util/internal/graph_edge_psite.hh
b/milena/mln/util/internal/graph_edge_psite.hh
index 05ad74f..c1c7d16 100644
--- a/milena/mln/util/internal/graph_edge_psite.hh
+++ b/milena/mln/util/internal/graph_edge_psite.hh
@@ -30,6 +30,7 @@
# include <mln/core/concept/pseudo_site.hh>
# include <mln/util/internal/graph_psite_base.hh>
+# include <mln/util/internal/graph_edge.hh>
namespace mln
{
@@ -112,7 +113,7 @@ namespace mln
template <typename G, typename F>
inline
edge_psite<G, F>::edge_psite(const target_t& t, unsigned id)
- : super_(id)
+ : super_(t, id)
{
}
diff --git a/milena/mln/util/internal/graph_vertex_impl.hh
b/milena/mln/util/internal/graph_vertex_impl.hh
index 3abfaf5..bfe6360 100644
--- a/milena/mln/util/internal/graph_vertex_impl.hh
+++ b/milena/mln/util/internal/graph_vertex_impl.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,11 +28,10 @@
#ifndef MLN_CORE_INTERNAL_GRAPH_VERTEX_IMPL_HH
# define MLN_CORE_INTERNAL_GRAPH_VERTEX_IMPL_HH
-/*! \file mln/util/internal/graph_vertex_impl.hh
- *
- * \brief Define a couple of implementation classes to provide methods
- * to classes of generalized vertexs.
- */
+/// \file mln/util/internal/graph_vertex_impl.hh
+///
+/// Define a couple of implementation classes to provide methods
+/// to classes of generalized vertexs.
# include <mln/core/internal/force_exact.hh>
diff --git a/milena/tests/core/image/graph_image.cc
b/milena/tests/core/image/graph_image.cc
index 4c3f09a..9fc556c 100644
--- a/milena/tests/core/image/graph_image.cc
+++ b/milena/tests/core/image/graph_image.cc
@@ -46,12 +46,10 @@
#include <mln/core/image/graph_elt_neighborhood.hh>
#include <mln/fun/i2v/array.hh>
-#include <mln/fun/p2v/iota.hh>
#include <mln/util/graph.hh>
#include <mln/debug/graph.hh>
-//#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
#include <mln/core/concept/function.hh>
@@ -101,18 +99,18 @@ int main()
*/
// Points associated to vertices.
- typedef fun::i2v::array<point2d> fpoint_t;
- fpoint_t points(5);
- points(0) = point2d(0,0); // Point associated to vertex 0.
- points(1) = point2d(2,2); // Point associated to vertex 1.
- points(2) = point2d(0,4); // Point associated to vertex 2.
- points(3) = point2d(4,3); // Point associated to vertex 3.
- points(4) = point2d(4,4); // Point associated to vertex 4.
+ typedef fun::i2v::array<point2d> fsite_t;
+ fsite_t sites(5);
+ sites(0) = point2d(0,0); // Point associated to vertex 0.
+ sites(1) = point2d(2,2); // Point associated to vertex 1.
+ sites(2) = point2d(0,4); // Point associated to vertex 2.
+ sites(3) = point2d(4,3); // Point associated to vertex 3.
+ sites(4) = point2d(4,4); // Point associated to vertex 4.
// Edges.
util::graph g;
// Populate the graph with vertices.
- for (unsigned i = 0; i < points.size(); ++i)
+ for (unsigned i = 0; i < sites.size(); ++i)
g.add_vertex();
// Populate the graph with edges.
g.add_edge(0, 1);
@@ -127,8 +125,8 @@ int main()
| Graph image support. |
`----------------------*/
- typedef p_vertices<util::graph, fpoint_t> S;
- S pv(g, points);
+ typedef p_vertices<util::graph, fsite_t> S;
+ S pv(g, sites);
/*-------------.
| Graph image. |
@@ -187,7 +185,7 @@ int main()
{
// Window - Forward iteration
- typedef graph_elt_window<util::graph, fpoint_t> win_t;
+ typedef graph_elt_window<util::graph, fsite_t> win_t;
win_t win;
mln_qiter_(win_t) q(win, p);
for_all (p)
@@ -201,7 +199,7 @@ int main()
{
// Window - Backward iteration
- typedef graph_elt_window<util::graph, fpoint_t> win_t;
+ typedef graph_elt_window<util::graph, fsite_t> win_t;
win_t win;
mln_bkd_qiter_(win_t) q(win, p);
for_all (p)
@@ -215,29 +213,33 @@ int main()
{
// Neighborhood - Forward iteration
- typedef graph_elt_neighborhood<util::graph, fpoint_t> neigh_t;
+ typedef graph_elt_neighborhood<util::graph, fsite_t> neigh_t;
neigh_t neigh;
mln_niter_(neigh_t) n(neigh, p);
for_all (p)
{
- std::cout << "neighbors of " << p << " ("
<< ima(p) << "), "
- << "including the site itself:" << std::endl;
+ std::cout << "neighbors of " << p << " ("
<< ima(p) << "), " << std::endl;
for_all (n)
+ {
+ mln_assertion(n != p);
std::cout << " " << n << " (level = " <<
ima(n) << ")" << std::endl;
+ }
}
}
{
// Neighborhood - Backward iteration
- typedef graph_elt_neighborhood<util::graph, fpoint_t> neigh_t;
+ typedef graph_elt_neighborhood<util::graph, fsite_t> neigh_t;
neigh_t neigh;
mln_bkd_niter_(neigh_t) n(neigh, p);
for_all (p)
{
- std::cout << "neighbors of " << p << " ("
<< ima(p) << "), "
- << "including the site itself:" << std::endl;
+ std::cout << "neighbors of " << p << " ("
<< ima(p) << "), " << std::endl;
for_all (n)
+ {
+ mln_assertion(n != p);
std::cout << " " << n << " (level = " <<
ima(n) << ")" << std::endl;
+ }
}
}
std::cout << std::endl;
diff --git a/milena/tests/core/image/line_graph_image.cc
b/milena/tests/core/image/line_graph_image.cc
index 74d374b..360623c 100644
--- a/milena/tests/core/image/line_graph_image.cc
+++ b/milena/tests/core/image/line_graph_image.cc
@@ -31,9 +31,41 @@
#include <vector>
#include <mln/core/alias/point2d.hh>
-#include <mln/core/image/line_graph_image.hh>
+#include <mln/pw/all.hh>
+
+//#include <mln/core/image/line_graph_image.hh>
#include <mln/core/image/line_graph_elt_window.hh>
-#include <mln/core/image/line_graph_window_piter.hh>
+#include <mln/core/image/line_graph_elt_neighborhood.hh>
+#include <mln/core/site_set/p_edges.hh>
+
+#include <mln/fun/i2v/array.hh>
+
+#include <mln/util/graph.hh>
+
+#include <mln/core/var.hh>
+
+template <typename S>
+struct viota_t : public mln::Function_p2v< viota_t<S> >
+{
+ typedef unsigned result;
+
+ viota_t(unsigned size)
+ {
+ v_.resize(size);
+ for (unsigned i = 0; i < size; ++i)
+ v_[i] = 10 + i;
+ }
+
+ unsigned
+ operator()(const mln_psite(S)& p) const
+ {
+ return v_[p.e().id()];
+ }
+
+ protected:
+ std::vector<result> v_;
+};
+
int main()
@@ -48,7 +80,7 @@ int main()
0 1 2 3 4 0 1 2 3 4
.----------- .-----------
- | |
+ | |
0 | 0 2 0 | * *
1 | \ / | 1 | 0 1 |
2 | 1 | 2 | * 4
@@ -57,19 +89,19 @@ int main()
*/
- // Points associated to vertices.
- std::vector<point2d> points;
- points.push_back(point2d(0,0)); // Point associated to vertex 0.
- points.push_back(point2d(2,2)); // Point associated to vertex 1.
- points.push_back(point2d(0,4)); // Point associated to vertex 2.
- points.push_back(point2d(4,3)); // Point associated to vertex 3.
- points.push_back(point2d(4,4)); // Point associated to vertex 4.
+ // Sites associated to edges.
+ typedef fun::i2v::array<point2d> fsite_t;
+ fsite_t sites(5);
+ sites(0) = point2d(0,0); // Point associated to edge 0.
+ sites(1) = point2d(2,2); // Point associated to edge 1.
+ sites(2) = point2d(0,4); // Point associated to edge 2.
+ sites(3) = point2d(4,3); // Point associated to edge 3.
+ sites(4) = point2d(4,4); // Point associated to edge 4.
- // Edges.
- util::graph<point2d> g;
+ util::graph g;
// Populate the graph with vertices.
- for (unsigned i = 0; i < points.size(); ++i)
- g.add_vertex (points[i]);
+ for (unsigned i = 0; i < sites.size(); ++i)
+ g.add_vertex();
// Populate the graph with edges.
g.add_edge(0, 1);
g.add_edge(1, 2);
@@ -81,33 +113,18 @@ int main()
| Line graph image support. |
`---------------------------*/
- p_line_graph<point2d> plg(g);
-
- // Check adjacencies of edge 1.
- mln_assertion( plg.adjacent(1, 0));
- mln_assertion(!plg.adjacent(1, 1));
- mln_assertion( plg.adjacent(1, 2));
- mln_assertion(!plg.adjacent(1, 3));
- mln_assertion( plg.adjacent(1, 4));
+ typedef p_edges<util::graph, fsite_t> S;
+ S pe(g, sites);
/*-------------------.
| Line graph image. |
`-------------------*/
- // Values ("empty" vectors).
- std::vector<int> vertex_values(5);
- std::vector<int> edge_values(5);
- // FIXME: hand-made iota's.
- for (unsigned i = 0; i < vertex_values.size(); ++i)
- vertex_values[i] = i;
- for (unsigned i = 0; i < edge_values.size(); ++i)
- edge_values[i] = i;
-
- // Line graph image.
- /* FIXME: We probably don't want to build line_graph_images by hand;
- provide helpers and/or conversion functions. */
- typedef line_graph_image<point2d, int> ima_t;
- ima_t ima(plg, vertex_values, edge_values);
+ // Graph values.
+ viota_t<S> iota(5);
+
+ // Create line graph image.
+ mln_const_VAR(ima, (iota | pe));
/*------------.
| Iterators. |
@@ -115,20 +132,68 @@ int main()
// Manual iteration over the domain of IMA.
mln_piter_(ima_t) p(ima.domain());
+ unsigned i = 10;
for_all (p)
- std::cout << "ima (" << p << ") = " <<
ima(p) << std::endl;
+ mln_assertion(ima(p) == i++);
+
+ {
+ // Window - Forward iteration
+ typedef line_graph_elt_window<util::graph, fsite_t> win_t;
+ win_t win;
+ mln_qiter_(win_t) q(win, p);
+ for_all (p)
+ {
+ std::cout << "neighbors of " << p << " ("
<< ima(p) << "), "
+ << "including the site itself:" << std::endl;
+ for_all (q)
+ std::cout << " " << q << " (level = " <<
ima(q) << ")" << std::endl;
+ }
+ }
- // Manual iterations over the neighborhoods of each point site of IMA.
- typedef line_graph_elt_window<point2d> win_t;
- win_t win;
- mln_qiter_(win_t) q(win, p);
- for_all (p)
{
- std::cout << "sites adjacent to " << p << " ("
<< ima(p) << "), "
- << "including the site itself:" << std::endl;
- for_all (q)
- std::cout << " " << q << " (level = "
<< ima(q) << ")"
- << std::endl;
+ // Window - Backward iteration
+ typedef line_graph_elt_window<util::graph, fsite_t> win_t;
+ win_t win;
+ mln_bkd_qiter_(win_t) q(win, p);
+ for_all (p)
+ {
+ std::cout << "neighbors of " << p << " ("
<< ima(p) << "), "
+ << "including the site itself:" << std::endl;
+ for_all (q)
+ std::cout << " " << q << " (level = " <<
ima(q) << ")" << std::endl;
+ }
}
+ {
+ // Neighborhood - Forward iteration
+ typedef line_graph_elt_neighborhood<util::graph, fsite_t> neigh_t;
+ neigh_t neigh;
+ mln_niter_(neigh_t) n(neigh, p);
+ for_all (p)
+ {
+ std::cout << "neighbors of " << p << " ("
<< ima(p) << "), " << std::endl;
+ for_all (n)
+ {
+ mln_assertion(n != p);
+ std::cout << " " << n << " (level = " <<
ima(n) << ")" << std::endl;
+ }
+ }
+ }
+
+ {
+ // Neighborhood - Backward iteration
+ typedef line_graph_elt_neighborhood<util::graph, fsite_t> neigh_t;
+ neigh_t neigh;
+ mln_bkd_niter_(neigh_t) n(neigh, p);
+ for_all (p)
+ {
+ std::cout << "neighbors of " << p << " ("
<< ima(p) << "), " << std::endl;
+ for_all (n)
+ {
+ mln_assertion(n != p);
+ std::cout << " " << n << " (level = " <<
ima(n) << ")" << std::endl;
+ }
+ }
+ }
+
std::cout << std::endl;
}
diff --git a/milena/tests/core/site_set/p_edges.cc
b/milena/tests/core/site_set/p_edges.cc
index 9ab01a1..1210bce 100644
--- a/milena/tests/core/site_set/p_edges.cc
+++ b/milena/tests/core/site_set/p_edges.cc
@@ -1,4 +1,5 @@
// 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 +26,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/core/site_set/p_edges.cc
- *
- * \brief Tests on mln::p_edges.
- */
+/// \file tests/core/site_set/p_edges.cc
+///
+/// Tests on mln::p_edges.
#include <mln/util/graph.hh>
#include <mln/core/alias/point2d.hh>
@@ -40,10 +40,10 @@ struct my_fun
{
typedef mln::point2d result;
- const result& operator()(const mln::util::edge<G>& v) const
+ const result& operator()(unsigned v) const
{
static mln::point2d res(0, 0);
- res.row() = v.id();
+ res.row() = v;
return res;
}
};
diff --git a/milena/tests/core/site_set/p_vertices.cc
b/milena/tests/core/site_set/p_vertices.cc
index b2c600d..f94ad3b 100644
--- a/milena/tests/core/site_set/p_vertices.cc
+++ b/milena/tests/core/site_set/p_vertices.cc
@@ -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/core/site_set/p_vertices.cc
- *
- * \brief Tests on mln::p_vertices.
- */
+/// \file tests/core/site_set/p_vertices.cc
+///
+/// Tests on mln::p_vertices.
#include <mln/util/graph.hh>
#include <mln/core/alias/point2d.hh>
--
1.5.6.5