https://svn.lrde.epita.fr/svn/oln/trunk/milena
Wow! I wanted to do this for *weeks*! Now it reads much better.
Index: ChangeLog from Roland Levillain roland@lrde.epita.fr
Rename (and clean up a bit) graph-related classes.
* mln/util/graph.hh (add_edge): Fix the update of the list of edges. * mln/core/mesh_image.hh, * mln/core/mesh_p.hh, * mln/core/mesh_p_piter.hh, * mln/core/mesh_psite.hh, * mln/core/mesh_elt_window.hh, * mln/core/mesh_window_piter.hh: Rename as... * mln/core/graph_image.hh, * mln/core/p_graph.hh, * mln/core/p_graph_piter.hh, * mln/core/graph_psite.hh, * mln/core/graph_elt_window.hh, * mln/core/graph_window_piter.hh: ...these. (mesh_image, mesh_p, mesh_p_piter_, mesh_psite) (mesh_elt_window, mesh_window_fwd_piter): Rename as... (graph_image, p_graph, p_graph_piter_, graph_psite) (graph_elt_window, graph_window_fwd_piter): ...these. * mln/draw/mesh.hh: Adjust. Rename as... * mln/draw/graph.hh: ...these. (mesh(Image<I>&, const mesh_p<P>&, mln_value(I), mln_value(I))) (mesh(Image<I>&, const mesh_image<P, V>&, mln_value(I))): Rename as... (graph(Image<I>&, const p_graph<P>&, mln_value(I), mln_value(I))) (graph(Image<I>&, const graph_image<P, V>&, mln_value(I))): ...these. * tests/core/mesh_elt_window.cc, * tests/core/mesh_image.cc, * tests/draw/mesh.cc: Adjust. Rename those tests as... * tests/core/graph_elt_window.cc, * tests/core/graph_image.cc, * tests/draw/graph.cc: ...these. * tests/core/Makefile.am, tests/draw/Makefile.am: Adjust names.
mln/core/graph_elt_window.hh | 94 ++++++++++++++++++++--------------------- mln/core/graph_image.hh | 90 +++++++++++++++++++-------------------- mln/core/graph_psite.hh | 50 ++++++++++----------- mln/core/graph_window_piter.hh | 79 +++++++++++++++++----------------- mln/core/p_graph.hh | 57 +++++++++++++----------- mln/core/p_graph_piter.hh | 59 +++++++++++++------------ mln/draw/graph.hh | 86 ++++++++++++++++++------------------- mln/util/graph.hh | 36 ++++++++++++--- tests/core/Makefile.am | 8 +-- tests/core/graph_elt_window.cc | 22 ++++----- tests/core/graph_image.cc | 60 ++++++++++++-------------- tests/draw/Makefile.am | 4 - tests/draw/graph.cc | 20 +++----- 13 files changed, 345 insertions(+), 320 deletions(-)
Index: mln/util/graph.hh --- mln/util/graph.hh (revision 1703) +++ mln/util/graph.hh (working copy) @@ -79,7 +79,9 @@ template<typename T> struct s_edge { - s_edge() : pair_node_ (0, 0) {} + s_edge() + : pair_node_ (0, 0) + {}
T data; ordpair_<unsigned> pair_node_; @@ -95,9 +97,11 @@ ordpair_<unsigned> pair_node_; };
- bool operator==(const struct s_edge <void>& lhs, const struct s_edge <void>& rhs); + bool operator==(const struct s_edge <void>& lhs, + const struct s_edge <void>& rhs);
- bool operator< (const struct s_edge <void>& lhs, const struct s_edge <void>& rhs); + bool operator< (const struct s_edge <void>& lhs, + const struct s_edge <void>& rhs);
/// \brief Generic graph structure using s_node and s_edge. /* FIXME: We don't mention anywhere whether this graph structure @@ -105,6 +109,10 @@ template<typename N, typename E = void> struct graph { + /* FIXME: Do we really want handle edges and nodes through + pointers? In my (Roland) opinion, this is just a drawback, + here. */ + /// The type of the set of nodes. typedef std::vector< s_node<N>* > nodes; /// The type of the set of edges. @@ -217,12 +225,20 @@ edge = new s_edge<E>; edge->pair_node_.first = n1; edge->pair_node_.second = n2; - if (links_.end () == std::find(links_.begin(), links_.end(), edge)) + // Does this edge already exist in the graph? + if (std::find(links_.begin(), links_.end(), edge) != links_.end ()) + { delete edge; + edge = 0; + } else { links_.push_back (edge); ++nb_link_; + /* FIXME: In fact, we should store adjaceny information in + *both* nodes. Change this globally later, and mention + that the graph is undirected in the documentation. And + don't forget to update clients! */ nodes_[n1]->links.push_back (n2); } } @@ -234,15 +250,18 @@ { mln_precondition(nodes_.size () == this->nb_node_); mln_precondition(links_.size () == this->nb_link_); - typename std::vector<struct s_node <N>*>::const_iterator it = nodes_.begin (); + typename std::vector<struct s_node <N>*>::const_iterator it = + nodes_.begin (); for (; it != nodes_.end (); ++it) { - typename std::list<unsigned>::const_iterator it2 = (*it)->links.begin (); + typename std::list<unsigned>::const_iterator it2 = + (*it)->links.begin (); for (; it2 != (*it)->links.end (); ++it2) mln_precondition((*it2) < nb_node_); }
- typename std::vector<struct s_edge<E>*>::const_iterator it3 = links_.begin (); + typename std::vector<struct s_edge<E>*>::const_iterator it3 = + links_.begin (); for (; it3 != links_.end (); ++it3) { mln_precondition((*it3)->pair_node_.first < nb_node_); @@ -257,7 +276,8 @@ { ostr << "nodes :" << std::endl;
- typename std::vector<struct s_node<N>*>::const_iterator it = nodes_.begin (); + typename std::vector<struct s_node<N>*>::const_iterator it = + nodes_.begin (); int i = 0; for (; it != nodes_.end (); ++it, ++i) { Index: mln/core/graph_psite.hh --- mln/core/graph_psite.hh (revision 1703) +++ mln/core/graph_psite.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -25,35 +25,35 @@ // reasons why the executable file might be covered by the GNU General // Public License.
-#ifndef MLN_CORE_MESH_PSITE_HH -# define MLN_CORE_MESH_PSITE_HH +#ifndef MLN_CORE_GRAPH_PSITE_HH +# define MLN_CORE_GRAPH_PSITE_HH
-/*! \file mln/core/mesh_psite.hh +/*! \file mln/core/graph_psite.hh * * \brief Definition of a graph-based point site. * * \todo Clean-up! */
-# include <mln/core/mesh_p.hh> +# include <mln/core/p_graph.hh>
namespace mln {
// Fwd decl. - template<typename P> class mesh_p; + template<typename P> class p_graph;
/*! - * \brief Point site associate to mesh_image. + * \brief Point site associate to graph_image. * * \todo Fix access to member. */ template<typename P> - class mesh_psite : public Point_Site< mesh_psite<P> > + class graph_psite : public Point_Site< graph_psite<P> > { - typedef mesh_psite<P> self_; + typedef graph_psite<P> self_;
public: typedef mln_mesh(P) mesh; @@ -64,8 +64,8 @@
/// Construction and assignment. /// { - mesh_psite(const mesh_p<P>& mesh_, unsigned i); - mesh_psite(const self_& rhs); + graph_psite(const p_graph<P>& pg_, unsigned i); + graph_psite(const self_& rhs); self_& operator= (const self_& rhs); /// }
@@ -74,7 +74,7 @@ coord operator[](unsigned i) const;
// FIXME: These shouldn't be public. - const mesh_p<P>& mesh_; + const p_graph<P>& pg_; unsigned i_; };
@@ -82,56 +82,56 @@
template<typename P> inline - mesh_psite<P>::mesh_psite(const mesh_p<P>& mesh, unsigned i) - : mesh_(mesh), + graph_psite<P>::graph_psite(const p_graph<P>& g, unsigned i) + : pg_(g), i_(i) { }
template<typename P> inline - mesh_psite<P>::mesh_psite(const mesh_psite<P>& rhs) - : mesh_(rhs.mesh_), + graph_psite<P>::graph_psite(const graph_psite<P>& rhs) + : pg_(rhs.pg_), i_(rhs.i_) { }
template<typename P> inline - mesh_psite<P>& - mesh_psite<P>::operator= (const mesh_psite<P>& rhs) + graph_psite<P>& + graph_psite<P>::operator= (const graph_psite<P>& rhs) { if (&rhs == this) return *this; // FIXME: Could we get rid of this cast? - const_cast< mesh_p<P>& >(mesh_) = rhs.mesh_; + const_cast< p_graph<P>& >(pg_) = rhs.pg_; i_ = rhs.i_; return *this; }
template<typename P> inline - mesh_psite<P>::operator P() const + graph_psite<P>::operator P() const { // FIXME: This is quite unsafe: we should check that i_ is a valid // index before dereferencing loc_ to ensure clear error messages. - return mesh_.loc_[i_]; + return pg_.loc_[i_]; }
template<typename P> inline const P& - mesh_psite<P>::to_point() const + graph_psite<P>::to_point() const { // FIXME: This is quite unsafe: we should check that i_ is a valid // index before dereferencing loc_ to ensure clear error messages. - return mesh_.loc_[i_]; + return pg_.loc_[i_]; }
template<typename P> inline mln_coord(P) - mesh_psite<P>::operator[](unsigned i) const + graph_psite<P>::operator[](unsigned i) const { return to_point()[i]; } @@ -141,4 +141,4 @@
} // end of mln
-#endif // MLN_CORE_MESH_PSITE_HH +#endif // MLN_CORE_GRAPH_PSITE_HH Index: mln/core/p_graph.hh --- mln/core/p_graph.hh (revision 1703) +++ mln/core/p_graph.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -25,48 +25,47 @@ // reasons why the executable file might be covered by the GNU General // Public License.
-#ifndef MLN_CORE_MESH_P_HH -# define MLN_CORE_MESH_P_HH +#ifndef MLN_CORE_GRAPH_P_HH +# define MLN_CORE_GRAPH_P_HH
# include <mln/core/concept/point_site.hh> # include <mln/core/internal/point_set_base.hh> # include <mln/accu/bbox.hh> # include <mln/util/graph.hh> -# include <mln/core/mesh_psite.hh> -# include <mln/core/mesh_p_piter.hh> +# include <mln/core/graph_psite.hh> +# include <mln/core/p_graph_piter.hh>
-// FIXME: Rename as mesh_p_set? We shall definitely write a coding -// style somewhere. - -/*! \file mln/core/mesh_p.hh - * - * \brief Definition of an point set based on graph. - */ +/// \file mln/core/p_graph.hh +/// \brief Definition of a point set based on graph.
namespace mln {
- template<typename P> class mesh_p_piter_; + template<typename P> class p_graph_piter_;
template<typename P> - struct mesh_p : public internal::point_set_base_< mesh_psite<P>, mesh_p<P> > + struct p_graph : public internal::point_set_base_< graph_psite<P>, p_graph<P> > { typedef util::graph<void> graph;
- /// Construct a mesh psite set from a graph and an array of locations. - mesh_p (graph& gr, std::vector<P>& loc); + /// Construct a graph psite set from a graph and an array of locations. + p_graph (graph& gr, std::vector<P>& loc);
/// Point_Site associated type. - typedef mesh_psite<P> psite; + typedef graph_psite<P> psite;
/// Forward Point_Iterator associated type. - typedef mesh_p_piter_<P> fwd_piter; + typedef p_graph_piter_<P> fwd_piter;
/// Backward Point_Iterator associated type. - typedef mesh_p_piter_<P> bkd_piter; // FIXME + typedef p_graph_piter_<P> bkd_piter;
+ /// Return The number of points (i.e., nodes) in the graph. std::size_t npoints() const;
+ /// Return The number of lines (i.e., edges) in the graph. + std::size_t nlines() const; + /// Give the exact bounding box. const box_<P>& bbox() const;
@@ -75,7 +74,7 @@ graph gr_; std::vector<P> loc_; // FIXME: (Roland) Is it really useful/needed? - /* 2007-12-19: It seems so, since mesh_image must implement a method + /* 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? */ box_<P> bb_; @@ -85,7 +84,7 @@
template<typename P> inline - mesh_p<P>::mesh_p (util::graph<void>& gr, std::vector<P>& loc) + p_graph<P>::p_graph (util::graph<void>& gr, std::vector<P>& loc) : gr_ (gr), loc_ (loc) { @@ -98,15 +97,23 @@ template<typename P> inline std::size_t - mesh_p<P>::npoints() const + p_graph<P>::npoints() const { return this->gr_.nb_node_; }
template<typename P> inline + std::size_t + p_graph<P>::nlines() const + { + return this->gr_.nb_link_; + } + + template<typename P> + inline const box_<P>& - mesh_p<P>::bbox() const + p_graph<P>::bbox() const { return bb_; } @@ -114,7 +121,7 @@ template<typename P> inline bool - mesh_p<P>::has(const psite& p) const + p_graph<P>::has(const psite& p) const { for (unsigned i = 0; i < loc_.size(); ++i) if (loc_[i] == p) @@ -128,4 +135,4 @@ } // end of mln
-#endif // MLN_CORE_MESH_P_HH +#endif // MLN_CORE_P_GRAPH_HH Index: mln/core/graph_window_piter.hh --- mln/core/graph_window_piter.hh (revision 1703) +++ mln/core/graph_window_piter.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -25,40 +25,42 @@ // reasons why the executable file might be covered by the GNU General // Public License.
-#ifndef MLN_CORE_MESH_WINDOW_PITER_HH -# define MLN_CORE_MESH_WINDOW_PITER_HH +#ifndef MLN_CORE_GRAPH_WINDOW_PITER_HH +# define MLN_CORE_GRAPH_WINDOW_PITER_HH
-/*! - * \file mln/core/mesh_window_piter.hh - * - * \brief Definition of point iterator of mesh window. - * - */ +/// \file mln/core/graph_window_piter.hh +/// \brief Definition of a point iterator on a graph window.
# include <mln/core/concept/point_iterator.hh> -# include <mln/core/mesh_p.hh> -# include <mln/core/mesh_psite.hh> +# include <mln/core/p_graph.hh> +# include <mln/core/graph_psite.hh>
+/* FIXME: Doc. */ + +/* FIXME: Due to the poor interface of mln::p_graph and + mln::util::graph, we show to much implementation details here. + Enrich their interfaces to avoid that. */
namespace mln { // Fwd decls. - template <typename P> class mesh_p; - template <typename P> class mesh_psite; + template <typename P> class p_graph; + template <typename P> class graph_psite;
template <typename P> - class mesh_window_fwd_piter : - public Point_Iterator< mesh_window_fwd_piter<P> > // or Iterator<...>? + class graph_window_fwd_piter : + public Point_Iterator< graph_window_fwd_piter<P> > // or Iterator<...>? { - typedef mesh_window_fwd_piter<P> self_; + typedef graph_window_fwd_piter<P> self_; typedef Point_Iterator< self_ > super_;
public: - typedef mesh_psite<P> psite; + typedef graph_psite<P> psite;
enum { dim = P::dim }; - typedef mesh_p<P> mesh; + // FIXME: Dummy value. + typedef void mesh;
typedef P point; // FIXME: Dummy typedef. @@ -67,8 +69,7 @@
public: template <typename W, typename Pref> - mesh_window_fwd_piter(const W& win, - const Point_Site<Pref>& p_ref); + graph_window_fwd_piter(const W& win, const Point_Site<Pref>& p_ref);
bool is_valid() const; void invalidate(); @@ -78,7 +79,7 @@ bool adjacent_or_equal_to_p_ref_() const;
// FIXME: In fact, this method should be named `to_psite', since - // it return as mln::mesh_psite<P> object, not a P object. + // it returns a mln::graph_psite<P> object, not a P object. const point& to_point() const; operator psite () const; coord operator[](unsigned i) const; @@ -91,7 +92,7 @@ unsigned i_; };
- // FIXME: mesh_window_bkd_piter. + // FIXME: Implement graph_window_bkd_piter.
# ifndef MLN_INCLUDE_ONLY @@ -99,7 +100,7 @@ // FIXME: Currently, argument win is ignored. template <typename P> template <typename W, typename Pref> - mesh_window_fwd_piter<P>::mesh_window_fwd_piter(const W& /* win */, + graph_window_fwd_piter<P>::graph_window_fwd_piter(const W& /* win */, const Point_Site<Pref>& p_ref) : p_ref_(exact(p_ref).to_psite()) { @@ -109,24 +110,24 @@
template <typename P> bool - mesh_window_fwd_piter<P>::is_valid() const + graph_window_fwd_piter<P>::is_valid() const { // FIXME: We depend too much on the implementation of util::graph // here. The util::graph should provide the service to abstract // these manipulations. - return i_ >= 0 && i_ < p_ref_.mesh_.gr_.nb_node_; + return i_ >= 0 && i_ < p_ref_.pg_.gr_.nb_node_; }
template <typename P> void - mesh_window_fwd_piter<P>::invalidate() + graph_window_fwd_piter<P>::invalidate() { - i_ = p_ref_.mesh_.gr_.nb_node_; + i_ = p_ref_.pg_.gr_.nb_node_; }
template <typename P> void - mesh_window_fwd_piter<P>::start() + graph_window_fwd_piter<P>::start() { i_ = 0; if (!adjacent_or_equal_to_p_ref_()) @@ -135,7 +136,7 @@
template <typename P> void - mesh_window_fwd_piter<P>::next_() + graph_window_fwd_piter<P>::next_() { // FIXME: This is inefficient. The graph structure should be able // to produce the set of adjacent nodes fast. Boost Graphs @@ -148,7 +149,7 @@
template <typename P> bool - mesh_window_fwd_piter<P>::adjacent_or_equal_to_p_ref_() const + graph_window_fwd_piter<P>::adjacent_or_equal_to_p_ref_() const { // FIXME: Likewise, this is inefficient.
@@ -162,9 +163,9 @@ { // Paranoid assertion. assert (p_ref_.i_ >= 0 && - p_ref_.i_ < p_ref_.mesh_.gr_.nodes_.size ()); + p_ref_.i_ < p_ref_.pg_.gr_.nodes_.size ()); const adjacency_type& p_ref_neighbs = - p_ref_.mesh_.gr_.nodes_[p_ref_.i_]->links; + p_ref_.pg_.gr_.nodes_[p_ref_.i_]->links; adjacency_type::const_iterator j = std::find (p_ref_neighbs.begin(), p_ref_neighbs.end(), i_); if (j != p_ref_neighbs.end()) @@ -174,7 +175,7 @@ // Check whether P_REF_ is among the neighbors of the iterator. { assert (is_valid ()); - const adjacency_type& i_neighbs = p_ref_.mesh_.gr_.nodes_[i_]->links; + const adjacency_type& i_neighbs = p_ref_.pg_.gr_.nodes_[i_]->links; adjacency_type::const_iterator k = std::find (i_neighbs.begin(), i_neighbs.end(), p_ref_.i_); if (k != i_neighbs.end()) @@ -187,21 +188,21 @@
template <typename P> const P& - mesh_window_fwd_piter<P>::to_point() const + graph_window_fwd_piter<P>::to_point() const { - return p_ref_.mesh_.loc_[i_]; + return p_ref_.pg_.loc_[i_]; }
template <typename P> - mesh_window_fwd_piter<P>::operator mesh_psite<P> () const + graph_window_fwd_piter<P>::operator graph_psite<P> () const { - return mesh_psite<P>(p_ref_.mesh_, i_); + return graph_psite<P>(p_ref_.pg_, i_); }
template <typename P> inline mln_coord(P) - mesh_window_fwd_piter<P>::operator[](unsigned i) const + graph_window_fwd_piter<P>::operator[](unsigned i) const { assert(i < dim); return to_point()[i]; @@ -211,4 +212,4 @@
} // end of namespace mln
-#endif // ! MLN_CORE_MESH_WINDOW_PITER_HH +#endif // ! MLN_CORE_GRAPH_WINDOW_PITER_HH Index: mln/core/graph_image.hh --- mln/core/graph_image.hh (revision 1703) +++ mln/core/graph_image.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -25,10 +25,10 @@ // reasons why the executable file might be covered by the GNU General // Public License.
-#ifndef MLN_CORE_MESH_IMAGE_HH -# define MLN_CORE_MESH_IMAGE_HH +#ifndef MLN_CORE_GRAPH_IMAGE_HH +# define MLN_CORE_GRAPH_IMAGE_HH
-/*! \file mln/core/mesh_image.hh +/*! \file mln/core/graph_image.hh * * \brief Definition of a graph-based image. */ @@ -37,8 +37,8 @@
# include <mln/core/internal/image_primary.hh> # include <mln/metal/vec.hh> -# include <mln/core/mesh_p.hh> -# include <mln/core/mesh_psite.hh> +# include <mln/core/p_graph.hh> +# include <mln/core/graph_psite.hh> # include <mln/value/set.hh> # include <vector>
@@ -46,19 +46,19 @@ {
// Fwd decl. - template <typename P, typename V> struct mesh_image; + template <typename P, typename V> struct graph_image;
namespace internal {
- /// \internal Data structure for \c mln::mesh_image<P,V>. + /// \internal Data structure for \c mln::graph_image<P,V>. template <typename P, typename V> - struct data_< mesh_image<P, V> > + struct data_< graph_image<P, V> > { - data_(mesh_p<P>& mesh, std::vector<V>& val); + data_(p_graph<P>& g, std::vector<V>& val);
std::vector<V> val_; - mesh_p<P>& mesh_; + p_graph<P>& pg_; };
} // end of namespace mln::internal @@ -68,7 +68,7 @@ {
template <typename P, typename V> - struct image_< mesh_image<P, V> > : default_image_< V, mesh_image<P, V> > + struct image_< graph_image<P, V> > : default_image_< V, graph_image<P, V> > { typedef trait::image::category::primary category;
@@ -91,11 +91,11 @@ * */ template <typename P, typename V> - struct mesh_image : - public internal::image_primary_< mesh_p<P>, mesh_image<P, V> > + struct graph_image : + public internal::image_primary_< p_graph<P>, graph_image<P, V> > {
- typedef mln::internal::image_base_< mesh_p<P>, mesh_image<P, V> > super_; + typedef mln::internal::image_base_< p_graph<P>, graph_image<P, V> > super_;
/// Value associated type. typedef V value; @@ -111,20 +111,20 @@
/// Skeleton. - typedef mesh_image< tag::psite_<P>, tag::value_<V> > skeleton; + typedef graph_image< tag::psite_<P>, tag::value_<V> > skeleton;
/// Constructors. - mesh_image(mesh_p<P>& mesh, std::vector<V>& val); - mesh_image(); + graph_image(p_graph<P>& g, std::vector<V>& val); + graph_image();
/// Initialize an empty image. - void init_(mesh_p<P>& mesh, std::vector<V>& val); + void init_(p_graph<P>& g, std::vector<V>& val);
/// Read-only access of pixel value at point site \p p. - const V& operator()(const mesh_psite<P>& p) const; + const V& operator()(const graph_psite<P>& p) const;
/// Read-write access of pixel value at point site \p p. - V& operator()(const mesh_psite<P>& p); + V& operator()(const graph_psite<P>& p);
/// Give the set of values of the image. const vset& values() const; @@ -132,7 +132,7 @@ // FIXME: Keep this name? const std::vector<V>& data_values () const;
- const mesh_p<P>& domain() const; + const p_graph<P>& domain() const;
/// Return the first node of the link at i from loc const P& access_location_link_node1 (const unsigned& i) const; @@ -144,7 +144,7 @@ // Fwd decl. template <typename P, typename V> void init_(tag::image_t, - mesh_image<P, V>& target, const mesh_image<P, V>& model); + graph_image<P, V>& target, const graph_image<P, V>& model);
# ifndef MLN_INCLUDE_ONLY @@ -156,7 +156,7 @@ template <typename P, typename V> inline void init_(tag::image_t, - mesh_image<P, V>& target, const mesh_image<P, V>& model) + graph_image<P, V>& target, const graph_image<P, V>& model) { /* FIXME: Unfortunately, we cannot simply use
@@ -164,9 +164,9 @@
here, since domain() and data_values() return const data, and init_ expects non mutable data. These constness problems exist - also in mesh_psite (see uses of const_cast<>). Hence the + also in graph_psite (see uses of const_cast<>). Hence the inelegant use of const_cast<>'s. */ - target.init_(const_cast<mesh_p<P>&> (model.domain()), + target.init_(const_cast<p_graph<P>&> (model.domain()), const_cast<std::vector<V>&> (model.data_values ())); }
@@ -178,9 +178,9 @@ { template <typename P, typename V> inline - data_< mesh_image<P, V> >::data_(mesh_p<P>& mesh, std::vector<V>& val) + data_< graph_image<P, V> >::data_(p_graph<P>& g, std::vector<V>& val) : val_ (val), - mesh_ (mesh) + pg_ (g) { }
@@ -192,28 +192,28 @@
template <typename P, typename V> inline - mesh_image<P, V>::mesh_image(mesh_p<P>& mesh, std::vector<V>& val) + graph_image<P, V>::graph_image(p_graph<P>& g, std::vector<V>& val) { - init_(mesh, val); + init_(g, val); }
template <typename P, typename V> inline - mesh_image<P, V>::mesh_image() + graph_image<P, V>::graph_image() { }
template <typename P, typename V> inline void - mesh_image<P, V>::init_(mesh_p<P>& mesh, std::vector<V>& val) + graph_image<P, V>::init_(p_graph<P>& g, std::vector<V>& val) { /* FIXME: We leak memory here: calling init_ twice loses the previous content pointed by data_.
We should definitely write down formal guidelines on initialization and memory management in general! */ - this->data_ = new internal::data_< mesh_image<P, V> > (mesh, val); + this->data_ = new internal::data_< graph_image<P, V> > (g, val); }
/*---------------. @@ -223,9 +223,9 @@ template <typename P, typename V> inline const V& - mesh_image<P, V>::operator()(const mesh_psite<P>& p) const + graph_image<P, V>::operator()(const graph_psite<P>& p) const { - mln_precondition(&p.mesh_ == &this->data_->mesh_); + mln_precondition(&p.pg_ == &this->data_->pg_); mln_precondition(p.i_ < this->data_->val_.size()); return this->data_->val_[p.i_]; } @@ -233,9 +233,9 @@ template <typename P, typename V> inline V& - mesh_image<P, V>::operator()(const mesh_psite<P>& p) + graph_image<P, V>::operator()(const graph_psite<P>& p) { - mln_precondition(&p.mesh_ == &this->data_->mesh_); + mln_precondition(&p.pg_ == &this->data_->pg_); mln_precondition(p.i_ < this->data_->val_.size()); return this->data_->val_[p.i_]; } @@ -243,7 +243,7 @@ template <typename P, typename V> inline const mln::value::set<V> & - mesh_image<P, V>::values() const + graph_image<P, V>::values() const { return vset::the(); } @@ -251,24 +251,24 @@ template <typename P, typename V> inline const std::vector<V>& - mesh_image<P, V>::data_values () const + graph_image<P, V>::data_values () const { return this->data_->val_; }
template <typename P, typename V> inline - const mesh_p<P>& - mesh_image<P, V>::domain() const + const p_graph<P>& + graph_image<P, V>::domain() const { mln_precondition(this->has_data()); - return this->data_->mesh_; + return this->data_->pg_; }
template <typename P, typename V> inline const P& - mesh_image<P, V>::access_location_link_node1 (const unsigned& i) const + graph_image<P, V>::access_location_link_node1 (const unsigned& i) const { // FIXME: This is ugly! Too much implementation details are shown here. return this->domain().loc_[this->domain().gr_.links_[i]->pair_node_.first]; @@ -277,7 +277,7 @@ template <typename P, typename V> inline const P& - mesh_image<P, V>::access_location_link_node2 (const unsigned& i) const + graph_image<P, V>::access_location_link_node2 (const unsigned& i) const { // FIXME: This is ugly! Too much implementation details are shown here. return this->domain().loc_[this->domain().gr_.links_[i]->pair_node_.second]; @@ -288,4 +288,4 @@ } // end of namespace mln
-#endif // ! MLN_CORE_MESH_IMAGE_HH +#endif // ! MLN_CORE_GRAPH_IMAGE_HH Index: mln/core/p_graph_piter.hh --- mln/core/p_graph_piter.hh (revision 1703) +++ mln/core/p_graph_piter.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -25,14 +25,14 @@ // reasons why the executable file might be covered by the GNU General // Public License.
-#ifndef MLN_CORE_MESH_P_PITER_HH -# define MLN_CORE_MESH_P_PITER_HH +#ifndef MLN_CORE_P_GRAPH_PITER_HH +# define MLN_CORE_P_GRAPH_PITER_HH
# include <mln/core/internal/point_iterator_base.hh> -# include <mln/core/mesh_p.hh> -# include <mln/core/mesh_psite.hh> +# include <mln/core/p_graph.hh> +# include <mln/core/graph_psite.hh>
-/*! \file mln/core/mesh_p_piter.hh +/*! \file mln/core/p_graph_piter.hh * * \brief Definition of point iterator on graph-based point set. */ @@ -40,26 +40,27 @@ namespace mln { // Fwd decls. - template<typename P> class mesh_p; - template<typename P> class mesh_psite; + template<typename P> class p_graph; + template<typename P> class graph_psite;
- // FIXME: Why `mesh_p_piter_' and not `mesh_p_piter' (without `_')? + // FIXME: Why `p_graph_piter_' and not `p_graph_piter' (without `_')?
template<typename P> - class mesh_p_piter_ : public internal::point_iterator_base_< P, mesh_p_piter_<P> > + class p_graph_piter_ + : public internal::point_iterator_base_< P, p_graph_piter_<P> > { - typedef mesh_p_piter_<P> self_; + typedef p_graph_piter_<P> self_; typedef internal::point_iterator_base_< P, self_ > super_;
public:
// Make definitions from super class available. enum { dim = super_::dim }; - typedef mesh_psite<P> psite; + typedef graph_psite<P> psite; typedef P point;
- mesh_p_piter_(const mesh_p<P>& psite_set); + p_graph_piter_(const p_graph<P>& psite_set);
/// Read-only access to the \p i-th coordinate. mln_coord(P) operator[](unsigned i) const; @@ -88,11 +89,11 @@ /// Convert the iterator into a point. operator point() const;
- /// Convert the iterator into a mesh psite. + /// Convert the iterator into a graph psite. operator psite() const;
protected: - const mesh_p<P>& psite_set_; + const p_graph<P>& psite_set_; unsigned i_; P p_; psite psite_; @@ -104,7 +105,7 @@
template<typename P> inline - mesh_p_piter_<P>::mesh_p_piter_(const mesh_p<P>& psite_set) + p_graph_piter_<P>::p_graph_piter_(const p_graph<P>& psite_set) : psite_set_(psite_set), p_(), // Initialize psite_ to a dummy value. @@ -117,7 +118,7 @@ template<typename P> inline mln_coord(P) - mesh_p_piter_<P>::operator[](unsigned i) const + p_graph_piter_<P>::operator[](unsigned i) const { return p_[i]; } @@ -125,7 +126,7 @@ template<typename P> inline bool - mesh_p_piter_<P>::is_valid() const + p_graph_piter_<P>::is_valid() const { return i_ != psite_set_.loc_.size(); } @@ -133,7 +134,7 @@ template<typename P> inline void - mesh_p_piter_<P>::invalidate() + p_graph_piter_<P>::invalidate() { i_ = psite_set_.loc_.size(); } @@ -141,7 +142,7 @@ template<typename P> inline void - mesh_p_piter_<P>::start() + p_graph_piter_<P>::start() { i_ = 0; if (is_valid()) @@ -151,7 +152,7 @@ template<typename P> inline void - mesh_p_piter_<P>::next_() + p_graph_piter_<P>::next_() { ++i_; if (is_valid()) @@ -161,18 +162,18 @@ template<typename P> inline void - mesh_p_piter_<P>::update_() + p_graph_piter_<P>::update_() { // Update p_. p_ = psite_set_.loc_[i_]; // Update psite_. - psite_ = mesh_psite<P>(psite_set_, i_); + psite_ = graph_psite<P>(psite_set_, i_); }
template<typename P> inline const P& - mesh_p_piter_<P>::to_point() const + p_graph_piter_<P>::to_point() const { /* We don't check whether the iterator is valid before returning the value using @@ -190,8 +191,8 @@
template<typename P> inline - const mesh_psite<P>& - mesh_p_piter_<P>::to_psite() const + const graph_psite<P>& + p_graph_piter_<P>::to_psite() const { /* We don't check whether the iterator is valid before returning the value using @@ -209,7 +210,7 @@
template<typename P> inline - mesh_p_piter_<P>::operator P() const + p_graph_piter_<P>::operator P() const { mln_precondition(is_valid()); return p_; @@ -217,7 +218,7 @@
template<typename P> inline - mesh_p_piter_<P>::operator mesh_psite<P>() const + p_graph_piter_<P>::operator graph_psite<P>() const { mln_precondition(is_valid()); return psite_; @@ -228,4 +229,4 @@ } // end of mln
-#endif // MLN_MESH_P_PITER_HH +#endif // MLN_P_GRAPH_PITER_HH Index: mln/core/graph_elt_window.hh --- mln/core/graph_elt_window.hh (revision 1703) +++ mln/core/graph_elt_window.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -25,39 +25,37 @@ // reasons why the executable file might be covered by the GNU General // Public License.
-#ifndef MLN_WIN_MESH_ELT_WINDOW_HH -# define MLN_WIN_MESH_ELT_WINDOW_HH +#ifndef MLN_WIN_GRAPH_ELT_WINDOW_HH +# define MLN_WIN_GRAPH_ELT_WINDOW_HH
-/*! \file mln/core/mesh_elt_window.hh +/*! \file mln/core/graph_elt_window.hh * - * \brief Definition of the elementary neighborhood (wrongly - * -- but purposefully -- named "window" here, for consistency - * reasons) on a mesh (a graph, in fact). + * \brief Definition of the elementary ``window'' on a graph. * * \todo Make naming coherent: we have window (without '_') but * point_, neighb_, etc. */
# include <mln/core/concept/window.hh> -# include <mln/core/mesh_psite.hh> -# include <mln/core/mesh_window_piter.hh> +# include <mln/core/graph_psite.hh> +# include <mln/core/graph_window_piter.hh>
namespace mln { // Fwd decls. - template <typename P> class mesh_window_fwd_piter; - template <typename P> class mesh_window_bkd_piter; + template <typename P> class graph_window_fwd_piter; + template <typename P> class graph_window_bkd_piter;
- /*! \brief Elementary window on mesh class. + /*! \brief Elementary window on graph class. * * FIXME: Doc. */ template <typename P> - class mesh_elt_window : public Window< mesh_elt_window<P> > + class graph_elt_window : public Window< graph_elt_window<P> > { - typedef mesh_elt_window<P> self_; + typedef graph_elt_window<P> self_;
public: /// Associated types. @@ -67,97 +65,101 @@ // psites, not points? typedef P point;
- // FIXME: This is a dummy value. This is yet another evidence - // that mesh_elt_window shall not be a Window, and therefore be - // renamed as mesh_elt_neighb, or better: elt_graph_neighb. + // FIXME: This is a dummy value. typedef void dpoint;
/*! \brief Point_Iterator type to browse the points of a generic window * w.r.t. the ordering of delta-points. */ - typedef mesh_window_fwd_piter<P> fwd_qiter; + typedef graph_window_fwd_piter<P> fwd_qiter;
/*! \brief Point_Iterator type to browse the points of a generic window * w.r.t. the reverse ordering of delta-points. */ - typedef mesh_window_bkd_piter<P> bkd_qiter; + typedef graph_window_bkd_piter<P> bkd_qiter;
/// The default qiter type. typedef fwd_qiter qiter; /// }
- /// Construct an elementary mesh window centered on \a psite. - mesh_elt_window(/*const mesh_psite<P>& psite*/); + /// Construct an elementary graph window. + graph_elt_window();
- // FIXME: The following methods make no sense for a - // general-purpose neighborhood. Anyway, we provide - // implementations for them for this first draft of graph - // neighborhood. + /// Is the window is empty? bool is_empty() const; + + /// Is the window centered? bool is_centered() const; + + /// Is the window symmetric? + // FIXME: We should defin this more precisely. bool is_symmetric() const; - unsigned delta() const; - self_& sym();
- // protected: - // const mesh_psite<P>& psite_; - }; + /// 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 nodes are not necessarily aligned on + a regular grid);
- // FIXME: Add an operator<< on ostreams ? + 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(); + };
# ifndef MLN_INCLUDE_ONLY
template <typename P> inline - mesh_elt_window<P>::mesh_elt_window(/*const mesh_psite<P>& psite*/) - // : psite_(psite) + graph_elt_window<P>::graph_elt_window() { }
template <typename P> inline bool - mesh_elt_window<P>::is_empty() const + graph_elt_window<P>::is_empty() const { - // FIXME: Dummy value. return false; }
template <typename P> inline bool - mesh_elt_window<P>::is_centered() const + graph_elt_window<P>::is_centered() const { - // FIXME: Dummy value. return false; }
template <typename P> inline bool - mesh_elt_window<P>::is_symmetric() const + graph_elt_window<P>::is_symmetric() const { - // FIXME: Dummy value. - return false; + return true; }
template <typename P> inline unsigned - mesh_elt_window<P>::delta() const + graph_elt_window<P>::delta() const { - // FIXME: Dummy value. + // Dummy value (see the interface of the method above). return 0; }
template <typename P> inline - mesh_elt_window<P>& - mesh_elt_window<P>::sym() + graph_elt_window<P>& + graph_elt_window<P>::sym() { - // FIXME: Dummy value. return *this; }
@@ -166,4 +168,4 @@ } // end of namespace mln
-#endif // ! MLN_WIN_MESH_ELT_WINDOW_HH +#endif // ! MLN_WIN_GRAPH_ELT_WINDOW_HH Index: mln/draw/graph.hh --- mln/draw/graph.hh (revision 1703) +++ mln/draw/graph.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -25,103 +25,101 @@ // reasons why the executable file might be covered by the GNU General // Public License.
-#ifndef MLN_DRAW_MESH_HH -# define MLN_DRAW_MESH_HH +#ifndef MLN_DRAW_GRAPH_HH +# define MLN_DRAW_GRAPH_HH
-/*! \file mln/draw/mesh.hh - * - * \brief Draw an image from type mesh_image. - * - */ +/// \file mln/draw/graph.hh +/// \brief Draw an (classical) image from a mln::graph_image.
# include <mln/pw/image.hh> # include <mln/level/fill.hh> # include <mln/draw/line.hh> -# include <mln/core/mesh_p.hh> -# include <mln/core/mesh_image.hh> +# include <mln/core/p_graph.hh> +# include <mln/core/graph_image.hh>
namespace mln {
namespace draw { - /* FIXME: `draw::mesh' is not a good name. These functions do not - actually draw the mesh/mesh_image; it *converts* it to a + /* FIXME: `draw::graph' is not a good name. These functions do not + actually _draw_ the graph/graph_image; it *converts* it to a printable image. These functions should be put elsewhere (e.g., in debug::). */
- /*! Draw an image \p ima from a mesh_p \p m, with value \p node_v - * for nodes, value \p link_v for links and 0 for the background. + /*! \brief Draw an image \p ima from a mln::p_graph \p pg, with + * value \p node_v for nodes, value \p link_v for links and 0 for + * the background. * * \param[in,out] ima The image to be drawn. - * \param[in] m The mesh_p which contains nodes and links positions. - * \param[in] node_v The value to assign to pixels which contains nodes. - * \param[in] link_v The value to assign to pixels which contains links. - * + * \param[in] pg The p_graph which contains nodes and links + * positions. + * \param[in] node_v The value to assign to pixels which contains + * nodes. + * \param[in] link_v The value to assign to pixels which contains + * links. */ template <typename I, typename P> void - mesh(Image<I>& ima, const mesh_p<P>& m, - mln_value(I) node_v, - mln_value(I) link_v); + graph(Image<I>& ima, const p_graph<P>& pg, + mln_value(I) node_v, mln_value(I) link_v);
- /*! Draw an image \p ima from a mesh_image \p mesh. - * The background is filled to value 0. + /*! \brief Draw an image \p ima from a mln::graph_image \p gi. + * + * The background is filled with value 0. * * \param[in,out] ima The image to be drawn. - * \param[in] mesh The mesh_image which contains nodes, links + * \param[in] gi The graph_image which contains the nodes, links * positions and the values of it. - * \param[in] link_v The value to assign to pixels which contains links, - * defaulting to 1. - * + * \param[in] link_v The value to assign to pixels which contains + * links, defaulting to 1. */ // FIXME: The type of the last argument cannot always been // constructed from `int'! We should remove this last argument. template <typename I, typename P, typename V> void - mesh(Image<I>& ima, const mesh_image<P, V>& mesh, + graph(Image<I>& ima, const graph_image<P, V>& gi, mln_value(I) link_v = 1);
# ifndef MLN_INCLUDE_ONLY
// FIXME: Add assertions on the size of the image: it must be large - // enough to hold the reprensentation of the graph. + // enough to hold the representation of the graph/graph_image.
template <typename I, typename P> inline void - mesh(Image<I>& ima, const mesh_p<P>& m, - mln_value(I) node_v, - mln_value(I) link_v) + graph(Image<I>& ima, const p_graph<P>& pg, + mln_value(I) node_v, mln_value(I) link_v) { level::fill(ima, 0);
- for (unsigned i = 0; i < m.gr_.nb_link_; ++i) + for (unsigned i = 0; i < pg.nlines(); ++i) line (exact(ima), - m.loc_[m.gr_.links_[i]->pair_node_.first], - m.loc_[m.gr_.links_[i]->pair_node_.second], + pg.loc_[pg.gr_.links_[i]->pair_node_.first], + pg.loc_[pg.gr_.links_[i]->pair_node_.second], link_v);
- for (unsigned i = 0; i < m.gr_.nb_node_; ++i) - exact(ima)(m.loc_[i]) = node_v; + for (unsigned i = 0; i < pg.npoints(); ++i) + exact(ima)(pg.loc_[i]) = node_v; }
template <typename I, typename P, typename V> inline void - mesh(Image<I>& ima, const mesh_image<P, V>& mesh, + graph(Image<I>& ima, const graph_image<P, V>& gi, mln_value(I) link_v) { level::fill(ima, 0);
- for (unsigned i = 0; i < mesh.domain().gr_.nb_link_; ++i) + for (unsigned i = 0; i < gi.domain().nlines(); ++i) line (exact(ima), - mesh.access_location_link_node1 (i), - mesh.access_location_link_node2 (i), + gi.access_location_link_node1 (i), + gi.access_location_link_node2 (i), link_v);
- for (unsigned i = 0; i < mesh.domain().gr_.nb_node_; ++i) - exact(ima)(mesh.domain().loc_[i]) = mesh.data_values ()[i]; + for (unsigned i = 0; i < gi.domain().npoints(); ++i) + exact(ima)(gi.domain().loc_[i]) = gi.data_values ()[i]; }
# endif // ! MLN_INCLUDE_ONLY @@ -130,4 +128,4 @@
} // end of namespace mln
-#endif // MLN_MESH_PSITE_HH +#endif // MLN_GRAPH_PSITE_HH Index: tests/core/graph_elt_window.cc --- tests/core/graph_elt_window.cc (revision 1703) +++ tests/core/graph_elt_window.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -25,15 +25,15 @@ // reasons why the executable file might be covered by the GNU General // Public License.
-/*! \file tests/core/mesh_elt_window.cc +/*! \file tests/core/graph_elt_window.cc * - * \brief Tests on mln::win::mesh_elt_window. + * \brief Tests on mln::win::graph_elt_window. */
#include <vector>
#include <mln/core/point2d.hh> -#include <mln/core/mesh_elt_window.hh> +#include <mln/core/graph_elt_window.hh>
#include <mln/debug/iota.hh> #include <mln/debug/println.hh> @@ -70,13 +70,13 @@ g.add_edge(4, 2);
/*------------------. - | Mesh and window. | + | Graph and window. | `------------------*/
- // Mesh psite set. - mesh_p<p_t> mesh(g, points); - // Mesh point site. - mesh_psite<p_t> psite(mesh, 0); - // ``Sliding'' window (in fact, neighborhood) of a psite of MESH. - mesh_elt_window<p_t> win; + // Graph psite set. + p_graph<p_t> pg(g, points); + // Graph point site. + graph_psite<p_t> psite(pg, 0); + // ``Sliding'' window (in fact, neighborhood) of a psite of PG. + graph_elt_window<p_t> win; } Index: tests/core/graph_image.cc --- tests/core/graph_image.cc (revision 1703) +++ tests/core/graph_image.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -25,19 +25,19 @@ // reasons why the executable file might be covered by the GNU General // Public License.
-/// \file tests/core/mesh_image.cc -/// \brief Tests on mln::mesh_image. +/// \file tests/core/graph_image.cc +/// \brief Tests on mln::graph_image.
#include <vector>
#include <mln/core/point2d.hh> -#include <mln/core/mesh_image.hh> -#include <mln/core/mesh_elt_window.hh> -#include <mln/core/mesh_window_piter.hh> +#include <mln/core/graph_image.hh> +#include <mln/core/graph_elt_window.hh> +#include <mln/core/graph_window_piter.hh>
#include <mln/morpho/dilation.hh>
-#include <mln/draw/mesh.hh> +#include <mln/draw/graph.hh> #include <mln/debug/iota.hh> #include <mln/debug/println.hh>
@@ -71,45 +71,45 @@ g.add_edge(4, 2);
/*-------. - | Mesh. | + | Graph. | `-------*/
- mesh_p<point2d> mesh(g, points); + p_graph<point2d> pg(g, points);
/*-------------. - | Mesh image. | + | Graph image. | `-------------*/
// Values ("empty" vector). std::vector<int> values(5); - // Mesh image. - typedef mesh_image<point2d, int> ima_t; - ima_t ima(mesh, values); + // Graph image. + typedef graph_image<point2d, int> ima_t; + ima_t ima(pg, values); // Initialize values. debug::iota(ima); // Print the image. - /* FIXME: Unfortunately, displaying mesh images is not easy right - now (2007-12-19). We could use + /* FIXME: Unfortunately, displaying graph images is not easy right + now (2008-02-05). We could use
debug::println(ima);
- but there's not specialization working for mesh_image; the one + but there's not specialization working for graph_image; the one selected by the compiler is based on a 2-D bbox, and expects the - interface of mesh_image to work with points (not psites). - Moreover, this iplementation only shows *values*, not the graph + interface of graph_image to work with points (not psites). + Moreover, this implementation only shows *values*, not the graph itslef.
- An alternative is to use draw::mesh (which, again, is misnamed), + An alternative is to use draw::graph (which, again, is misnamed), but it doesn't show the values, only the nodes and edges of the graph.
- The current solution is a mix between draw::mesh and hand-made + The current solution is a mix between draw::graph and hand-made iterations. */ image2d<int> ima_rep(ima.bbox()); - // We use the value 9 in draw::mesh instead of the default (which is + // We use the value 9 in draw::graph instead of the default (which is // 1) to represent edges to distinguish it from nodes holding a // value of 1. - draw::mesh (ima_rep, ima, 9); + draw::graph (ima_rep, ima, 9); debug::println (ima_rep);
@@ -123,10 +123,7 @@ std::cout << "ima (" << p << ") = " << ima(p) << std::endl;
// Manual iterations over the neighborhoods of each point site of IMA. - /* FIXME: In fact, this class should be named - `mesh_elt_neighborhood' (there's no such thing as an elementary - window on a mesh/graph!). */ - typedef mesh_elt_window<point2d> win_t; + typedef graph_elt_window<point2d> win_t; win_t win; mln_qiter_(win_t) q(win, p); for_all (p) @@ -136,16 +133,17 @@ for_all (q) std::cout << " " << q << " (level = " << ima(q) << ")" << std::endl; } + std::cout << std::endl;
/*-------------------------. - | Processing mesh images. | + | Processing graph images. | `-------------------------*/
- mesh_image<point2d, int> ima_dil = morpho::dilation(ima, win); - draw::mesh(ima_rep, ima_dil, 9); + graph_image<point2d, int> ima_dil = morpho::dilation(ima, win); + draw::graph(ima_rep, ima_dil, 9); debug::println(ima_rep);
- mesh_image<point2d, int> ima_ero = morpho::erosion(ima, win); - draw::mesh(ima_rep, ima_ero, 9); + graph_image<point2d, int> ima_ero = morpho::erosion(ima, win); + draw::graph(ima_rep, ima_ero, 9); debug::println(ima_rep); } Index: tests/core/Makefile.am --- tests/core/Makefile.am (revision 1703) +++ tests/core/Makefile.am (working copy) @@ -8,8 +8,8 @@ exact \ h_vec \ initialize \ - mesh_elt_window \ - mesh_image \ + graph_elt_window \ + graph_image \ mono_obased_rle_image \ mono_rle_image \ obased_rle_image \ @@ -29,8 +29,8 @@ exact_SOURCES = exact.cc h_vec_SOURCES = h_vec.cc initialize_SOURCES = initialize.cc -mesh_elt_window_SOURCES = mesh_elt_window.cc -mesh_image_SOURCES = mesh_image.cc +graph_elt_window_SOURCES = graph_elt_window.cc +graph_image_SOURCES = graph_image.cc mono_obased_rle_image_SOURCES = mono_obased_rle_image.cc mono_rle_image_SOURCES = mono_rle_image.cc obased_rle_image_SOURCES = obased_rle_image.cc Index: tests/draw/graph.cc --- tests/draw/graph.cc (revision 1703) +++ tests/draw/graph.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// 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 @@ -25,9 +25,9 @@ // reasons why the executable file might be covered by the GNU General // Public License.
-/*! \file tests/draw/mesh.cc +/*! \file tests/draw/graph.cc * - * \brief Tests on mln::draw::mesh. + * \brief Tests on mln::draw::graph. * * Build a graph, convert it to an image, and compare it with a * reference images. @@ -40,10 +40,10 @@ #include <mln/core/point2d.hh> #include <mln/debug/println.hh> #include <mln/util/graph.hh> -#include <mln/core/mesh_p.hh> -#include <mln/core/mesh_psite.hh> -#include <mln/draw/mesh.hh> -#include <mln/core/mesh_image.hh> +#include <mln/core/p_graph.hh> +#include <mln/core/graph_psite.hh> +#include <mln/draw/graph.hh> +#include <mln/core/graph_image.hh> #include <mln/level/compare.hh>
@@ -71,12 +71,10 @@ // Check its consistency. g.consistency ();
- mln::mesh_p<point2d> m(g, points); + mln::p_graph<point2d> pg(g, points);
image2d<int> ima(nrows, ncols); - // FIXME: `draw::mesh' is not a good name. This function doesn't - // actually draw the mesh; it *converts* it to a printable image. - draw::mesh (ima, m, 2, 1); + draw::graph (ima, pg, 2, 1); mln_assertion (ima == ref); }
Index: tests/draw/Makefile.am --- tests/draw/Makefile.am (revision 1703) +++ tests/draw/Makefile.am (working copy) @@ -5,10 +5,10 @@ check_PROGRAMS = \ all_headers \ line \ - mesh + graph
all_headers_SOURCES = all_headers.cc line_SOURCES = line.cc -mesh_SOURCES = mesh.cc +graph_SOURCES = graph.cc
TESTS = $(check_PROGRAMS)
Le 5 févr. 08 à 17:22, Roland Levillain a écrit :
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Wow! I wanted to do this for *weeks*! Now it reads much better.
[...]
- mln/util/graph.hh (add_edge): Fix the update of the list of
edges.
It took me a couple of hours to spot this bug. Grrr...
Please, don't forget to replay tests, or to write ones when they are missing. TIA.