* mln/core/image/graph_elt_neighborhood.hh
(mln::graph_elt_neighborhood<P>::point)
(mln::graph_elt_neighborhood<P>::dpoint):
Remove typedefs.
(mln::graph_elt_neighborhood<P>::psite)
(mln::graph_elt_neighborhood<P>::window):
New typedefs.
(mln::graph_elt_neighborhood<P>::to_window):
New method.
(mln::graph_elt_neighborhood<P>::compute_sites_):
Catch up with the new interface of iterators on graph
neighborhood.
---
milena/ChangeLog | 17 +++++++++
milena/mln/core/image/graph_elt_neighborhood.hh | 42 +++++++++++++++++------
2 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 65bbcef..f7932d2 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,22 @@
2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+ Update elementary neighborhood on graph image.
+
+ * mln/core/image/graph_elt_neighborhood.hh
+ (mln::graph_elt_neighborhood<P>::point)
+ (mln::graph_elt_neighborhood<P>::dpoint):
+ Remove typedefs.
+ (mln::graph_elt_neighborhood<P>::psite)
+ (mln::graph_elt_neighborhood<P>::window):
+ New typedefs.
+ (mln::graph_elt_neighborhood<P>::to_window):
+ New method.
+ (mln::graph_elt_neighborhood<P>::compute_sites_):
+ Catch up with the new interface of iterators on graph
+ neighborhood.
+
+2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+
Update elementary window on graph image.
* mln/core/image/graph_elt_window.hh
diff --git a/milena/mln/core/image/graph_elt_neighborhood.hh b/milena/mln/core/image/graph_elt_neighborhood.hh
index 6270801..df0420a 100644
--- a/milena/mln/core/image/graph_elt_neighborhood.hh
+++ b/milena/mln/core/image/graph_elt_neighborhood.hh
@@ -38,16 +38,22 @@
- mln::graph_elt_window
- mln::graph_elt_neighborhood
- mln::line_graph_elt_window
- - mln::line_graph_elt_neighborhood. */
+ - 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. */
+# include <set>
+
# include <mln/core/concept/neighborhood.hh>
# include <mln/core/image/graph_psite.hh>
# include <mln/core/image/graph_neighborhood_piter.hh>
+# include <mln/core/image/graph_elt_window.hh>
+
namespace mln
{
@@ -56,7 +62,7 @@ namespace mln
template <typename P, typename N> class graph_neighborhood_bkd_piter;
- /// Elementary neighborhood on graph class.
+ /// \brief Elementary neighborhood on graph class.
template <typename P>
class graph_elt_neighborhood
: public Neighborhood< graph_elt_neighborhood<P> >
@@ -66,17 +72,14 @@ namespace mln
public:
/// Associated types.
/// \{
- /// The type of point corresponding to the neighborhood.
- typedef P point;
/// The type of psite corresponding to the neighborhood.
typedef graph_psite<P> 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<util::vertex_id> sites_t;
- // FIXME: This is a dummy value.
- typedef void dpoint;
-
/// \brief Site_Iterator type to browse the psites of the
/// neighborhood w.r.t. the ordering of vertices.
typedef graph_neighborhood_fwd_piter<P, self_> fwd_niter;
@@ -89,6 +92,14 @@ namespace mln
typedef fwd_niter niter;
/// \}
+ /// Conversions.
+ /// \{
+ /// The window type corresponding to this neighborhood.
+ typedef 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.
@@ -101,16 +112,25 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
template <typename P>
+ inline
+ graph_elt_window<P>
+ graph_elt_neighborhood<P>::to_window() const
+ {
+ return graph_elt_window<P>();
+ }
+
+ template <typename P>
template <typename Piter>
inline
void
graph_elt_neighborhood<P>::compute_sites_(Site_Iterator<Piter>& piter_) const
{
Piter& piter = exact(piter_);
- util::vertex_id ref_vertex_id = piter.p_ref().id();
- const util::vertex<P>& ref_vertex = piter.pg().gr_->vertex(ref_vertex_id);
+ util::vertex_id ref_vertex_id = piter.center().vertex_id();
sites_t& sites = piter.sites();
sites.clear();
+ const util::vertex<P>& ref_vertex =
+ piter.center().site_set().gr_->vertex(ref_vertex_id);
/* 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. */
@@ -119,12 +139,12 @@ namespace mln
ref_vertex.edges.begin();
e != ref_vertex.edges.end(); ++e)
{
- util::vertex_id v1 = piter.pg().gr_->edges()[*e]->v1();
+ util::vertex_id v1 = piter.center().site_set().gr_->edges()[*e]->v1();
// We explicitly enforce that the reference piter vertex id is
// *not* inserted into SITES.
if (v1 != ref_vertex_id)
sites.insert(v1);
- util::vertex_id v2 = piter.pg().gr_->edges()[*e]->v2();
+ util::vertex_id v2 = piter.center().site_set().gr_->edges()[*e]->v2();
// Likewise.
if (v2 != ref_vertex_id)
sites.insert(v2);
--
1.5.6.5
* mln/core/image/graph_elt_window.hh
(mln::graph_elt_window<P>::point): Remove typedef.
(mln::graph_elt_window<P>::psite): New typedef.
(mln::graph_elt_window<P>::dpoint): Turn typedef into...
(mln::graph_elt_window<P>::dpsite): ...this.
(mln::graph_elt_window<P>::compute_sites_):
Catch up with the new interface of iterators on graph window.
---
milena/ChangeLog | 12 ++++++++++++
milena/mln/core/image/graph_elt_window.hh | 19 +++++++++++--------
2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index a2e7ce6..65bbcef 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,17 @@
2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+ Update elementary window on graph image.
+
+ * mln/core/image/graph_elt_window.hh
+ (mln::graph_elt_window<P>::point): Remove typedef.
+ (mln::graph_elt_window<P>::psite): New typedef.
+ (mln::graph_elt_window<P>::dpoint): Turn typedef into...
+ (mln::graph_elt_window<P>::dpsite): ...this.
+ (mln::graph_elt_window<P>::compute_sites_):
+ Catch up with the new interface of iterators on graph window.
+
+2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+
Update graph neighborhood piters.
* mln/core/image/graph_neighborhood_piter.hh
diff --git a/milena/mln/core/image/graph_elt_window.hh b/milena/mln/core/image/graph_elt_window.hh
index 9e936bd..c679afd 100644
--- a/milena/mln/core/image/graph_elt_window.hh
+++ b/milena/mln/core/image/graph_elt_window.hh
@@ -38,7 +38,9 @@
- mln::graph_elt_window
- mln::graph_elt_neighborhood
- mln::line_graph_elt_window
- - mln::line_graph_elt_neighborhood. */
+ - 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.
@@ -65,16 +67,16 @@ namespace mln
public:
/// Associated types.
/// \{
- /// The type of point corresponding to the window.
- typedef P point;
/// The type of psite corresponding to the window.
typedef 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 (vertex ids adjacent to the
// reference psite).
typedef std::set<util::vertex_id> sites_t;
// FIXME: This is a dummy value.
- typedef void dpoint;
+ typedef void dpsite;
/// \brief Site_Iterator type to browse the psites of the window
/// w.r.t. the ordering of vertices.
@@ -132,10 +134,11 @@ namespace mln
graph_elt_window<P>::compute_sites_(Site_Iterator<Piter>& piter_) const
{
Piter& piter = exact(piter_);
- util::vertex_id ref_vertex_id = piter.p_ref().id();
- const util::vertex<P>& ref_vertex = piter.pg().gr_->vertex(ref_vertex_id);
+ util::vertex_id ref_vertex_id = piter.center().vertex_id();
sites_t& sites = piter.sites();
sites.clear();
+ const util::vertex<P>& ref_vertex =
+ piter.center().site_set().gr_->vertex(ref_vertex_id);
/* 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. */
@@ -149,9 +152,9 @@ namespace mln
ref_vertex.edges.begin();
e != ref_vertex.edges.end(); ++e)
{
- util::vertex_id v1 = piter.pg().gr_->edges()[*e]->v1();
+ util::vertex_id v1 = piter.center().site_set().gr_->edges()[*e]->v1();
sites.insert(v1);
- util::vertex_id v2 = piter.pg().gr_->edges()[*e]->v2();
+ util::vertex_id v2 = piter.center().site_set().gr_->edges()[*e]->v2();
sites.insert(v2);
}
}
--
1.5.6.5
* mln/core/site_set/p_graph.hh
(mln::trait::site_set_< p_graph<P> >): New properties.
(mln::p_graph<P>): Inherit from internal::site_set_base_.
(mln::p_graph<P>::self_
(mln::p_graph<P>::super_)
(mln::p_graph<P>::element)
(mln::p_graph<P>::piter):
New typedefs.
(mln::p_graph<P>::bbox): Remove method.
(mln::p_graph<P>::bb_): Remove attribute.
(mln::p_graph<P>::p_graph): Adjust ctor.
(mln::p_graph<P>::has): Update.
(mln::p_graph<P>::to_graph): Update accessors.
Rename them as...
(mln::p_graph<P>::gr): ...these.
(mln::p_graph<P>::nsites): Change return type of this method to
unsigned.
(mln::p_graph<P>::is_valid)
(mln::p_graph<P>::memory_size):
New methods.
---
milena/ChangeLog | 25 ++++++
milena/mln/core/site_set/p_graph.hh | 158 ++++++++++++++++++++++++-----------
2 files changed, 134 insertions(+), 49 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index ba324e4..746a34a 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,30 @@
2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+ Update site set mln::p_graph.
+
+ * mln/core/site_set/p_graph.hh
+ (mln::trait::site_set_< p_graph<P> >): New properties.
+ (mln::p_graph<P>): Inherit from internal::site_set_base_.
+ (mln::p_graph<P>::self_
+ (mln::p_graph<P>::super_)
+ (mln::p_graph<P>::element)
+ (mln::p_graph<P>::piter):
+ New typedefs.
+ (mln::p_graph<P>::bbox): Remove method.
+ (mln::p_graph<P>::bb_): Remove attribute.
+ (mln::p_graph<P>::p_graph): Adjust ctor.
+ (mln::p_graph<P>::has): Update.
+ (mln::p_graph<P>::to_graph): Update accessors.
+ Rename them as...
+ (mln::p_graph<P>::gr): ...these.
+ (mln::p_graph<P>::nsites): Change return type of this method to
+ unsigned.
+ (mln::p_graph<P>::is_valid)
+ (mln::p_graph<P>::memory_size):
+ New methods.
+
+2008-09-22 Roland Levillain <roland(a)lrde.epita.fr>
+
Update complex-based image.
* mln/core/complex_iter.hh: More documentation.
diff --git a/milena/mln/core/site_set/p_graph.hh b/milena/mln/core/site_set/p_graph.hh
index d7de799..073b91f 100644
--- a/milena/mln/core/site_set/p_graph.hh
+++ b/milena/mln/core/site_set/p_graph.hh
@@ -28,26 +28,49 @@
#ifndef MLN_CORE_SITE_SET_P_GRAPH_HH
# define MLN_CORE_SITE_SET_P_GRAPH_HH
-# include <mln/core/concept/point_site.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/accu/bbox.hh>
-# include <mln/util/tracked_ptr.hh>
# include <mln/util/graph.hh>
+# include <mln/util/tracked_ptr.hh>
# include <mln/core/image/graph_psite.hh>
# include <mln/core/site_set/p_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
{
- /* FIXME: Contray to, e.g., p_array, the sole parameter P of p_graph
- is expected to be a point, not a psite!! We should have a
- uniform scheme for point site sets. */
+ // 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_< graph_psite<P>, p_graph<P> >
+ : 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<P> graph;
/// \brief Construct a graph psite set from a graph of points.
@@ -56,8 +79,12 @@ namespace mln
///
/// \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);
+ p_graph(const graph& gr);
+ /// Associated types.
+ /// \{
+ /// Element associated type.
+ typedef mln_site(super_) element;
/// Point_Site associated type.
typedef graph_psite<P> psite;
@@ -67,27 +94,48 @@ namespace mln
/// 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.
- std::size_t nsites() const;
+ /* 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.
std::size_t nvertices() const;
/// Return The number of edges in the graph.
std::size_t nedges() const;
- /// Give the exact bounding box.
- const box<P>& bbox() 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;
@@ -95,6 +143,9 @@ namespace mln
/// 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.
@@ -111,21 +162,11 @@ namespace mln
const util::vertex_id& rhs) const;
/// \}
- /// Return the graph associated to the p_graph domain.
- // FIXME: Rename as something else (graph() ?).
- const graph& to_graph() const;
- graph& to_graph();
-
+ /// \}
- // FIXME: Should be private.
public:
+ // FIXME: Should be private.
util::tracked_ptr<graph> gr_;
- // FIXME: (Roland) Is it really useful/needed?
- /* 2007-12-19: It seems so, since graph_image must implement a method
- named bbox(). Now the question is: should each image type have a
- bounding box? */
- private:
- box<P> bb_;
};
@@ -137,6 +178,10 @@ namespace mln
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
@@ -159,15 +204,11 @@ namespace mln
// Create a deep, managed copy of GR.
: gr_ (new util::graph<P>(gr))
{
- accu::bbox<P> a;
- for (unsigned i = 0; i < nsites(); ++i)
- a.take(gr_->vertex_data(i));
- bb_ = a.to_result();
}
template <typename P>
inline
- std::size_t
+ unsigned
p_graph<P>::nsites() const
{
return nvertices();
@@ -191,10 +232,11 @@ namespace mln
template <typename P>
inline
- const box<P>&
- p_graph<P>::bbox() const
+ bool
+ p_graph<P>::is_valid() const
{
- return bb_;
+ // FIXME: Might be too low-level, again.
+ return gr_.ptr_;
}
template <typename P>
@@ -202,11 +244,39 @@ namespace mln
bool
p_graph<P>::has(const psite& p) const
{
+ mln_precondition(is_valid());
return
// Check whether P is compatible with this psite set.
- (&p.pg() == this) &&
- // Check that the vertex id of P belongs to the range of valid vertex ids.
- (p.id() < gr_->nvertices());
+ (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>
@@ -301,25 +371,15 @@ namespace mln
return adjacent(lhs, rhs);
}
- template <typename P>
- const typename p_graph<P>::graph&
- p_graph<P>::to_graph() const
- {
- return this->gr_;
- }
-
- template <typename P>
- typename p_graph<P>::graph&
- p_graph<P>::to_graph()
- {
- return this->gr_;
- }
-
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_;
}
--
1.5.6.5