* mln/border/resize.hh: precise mln:: in order to avoir ambiguity.
* mln/fun/internal/array_base.hh: add append().
* mln/geom/complex_geometry.hh: cleanup comments.
* mln/util/site_pair.hh: add operator<<.
* mln/morpho/line_gradient.hh,
* tests/morpho/lena_line_graph_image_wst1.cc: use i2v::array::append().
* tests/morpho/line_graph_image_wst.cc: Fix test. Associate edges to
the proper sites.
---
milena/ChangeLog | 18 ++++++++++++++++++
milena/mln/border/resize.hh | 2 +-
milena/mln/fun/internal/array_base.hh | 12 ++++++++++++
milena/mln/geom/complex_geometry.hh | 12 ++++++------
milena/mln/morpho/line_gradient.hh | 7 ++-----
milena/mln/util/site_pair.hh | 13 +++++++++++++
milena/tests/morpho/lena_line_graph_image_wst1.cc | 8 +++-----
milena/tests/morpho/line_graph_image_wst.cc | 16 ++++++++++++----
8 files changed, 67 insertions(+), 21 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index dbb1dea..3b45f6e 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,23 @@
2008-12-31 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Few small fixes.
+
+ * mln/border/resize.hh: precise mln:: in order to avoir ambiguity.
+
+ * mln/fun/internal/array_base.hh: add append().
+
+ * mln/geom/complex_geometry.hh: cleanup comments.
+
+ * mln/util/site_pair.hh: add operator<<.
+
+ * mln/morpho/line_gradient.hh,
+ * tests/morpho/lena_line_graph_image_wst1.cc: use i2v::array::append().
+
+ * tests/morpho/line_graph_image_wst.cc: Fix test. Associate edges to
+ the proper sites.
+
+2008-12-31 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Propagate renaming has_data as is_valid.
* doc/tutorial/image_types.txt,
diff --git a/milena/mln/border/resize.hh b/milena/mln/border/resize.hh
index fcdfad8..1963469 100644
--- a/milena/mln/border/resize.hh
+++ b/milena/mln/border/resize.hh
@@ -79,7 +79,7 @@ namespace mln
if (border::get(ima) == thickness)
return; // No-op.
- mln_concrete(I) memo = duplicate(ima);
+ mln_concrete(I) memo = mln::duplicate(ima);
ima.resize_(thickness);
data::fill(ima, memo);
diff --git a/milena/mln/fun/internal/array_base.hh
b/milena/mln/fun/internal/array_base.hh
index e26ab91..637fab7 100644
--- a/milena/mln/fun/internal/array_base.hh
+++ b/milena/mln/fun/internal/array_base.hh
@@ -62,6 +62,10 @@ namespace mln
/// Set the function size to \p n and initialize the value with
/// \p val.
void resize(unsigned n, const T& val);
+
+ /// Append a new value in the function.
+ void append(const T& val);
+
/// Return the number of values.
unsigned size() const;
@@ -160,6 +164,14 @@ namespace mln
template <typename T>
inline
void
+ array_base<T>::append(const T& val)
+ {
+ v_.push_back(val);
+ }
+
+ template <typename T>
+ inline
+ void
array_base<T>::resize(unsigned n, const T& val)
{
v_.resize(n, val);
diff --git a/milena/mln/geom/complex_geometry.hh b/milena/mln/geom/complex_geometry.hh
index 18ed6da..a162c6c 100644
--- a/milena/mln/geom/complex_geometry.hh
+++ b/milena/mln/geom/complex_geometry.hh
@@ -29,7 +29,7 @@
# define MLN_GEOM_COMPLEX_GEOMETRY_HH
/// \file mln/geom/complex_geometry.hh
-/// \brief A functor associating geometry (location) data to the faces
+/// A functor associating geometry (location) data to the faces
/// of a complex.
///
/// \see mln::topo::complex.
@@ -68,7 +68,7 @@ namespace mln
}
- /** \brief A functor returning the sites of the faces of a complex
+ /** A functor returning the sites of the faces of a complex
where the locations of each 0-face is stored. Faces of higher
dimensions are computed.
@@ -94,18 +94,18 @@ namespace mln
typedef util::multi_site<P> site;
public:
- /// \brief Build a complex geometry object.
+ /// Build a complex geometry object.
complex_geometry();
public:
- /// \brief Populate the set of locations.
+ /// Populate the set of locations.
///
/// Append a new location \a p. Return the index of the newly
/// created location (which should semantically match the id of
/// the corresonding 0-face in the complex).
unsigned add_location(const P& p);
- /// \brief Retrieve the site associated to \a f.
+ /// Retrieve the site associated to \a f.
site operator()(const mln::topo::face<D>& f) const;
private:
@@ -115,7 +115,7 @@ namespace mln
namespace internal
{
- /// \brief The data stored in a complex_geometry object.
+ /// The data stored in a complex_geometry object.
///
/// \arg \p P The type of the location of a 0-face.
template <typename P>
diff --git a/milena/mln/morpho/line_gradient.hh b/milena/mln/morpho/line_gradient.hh
index bc49df9..4b12d4a 100644
--- a/milena/mln/morpho/line_gradient.hh
+++ b/milena/mln/morpho/line_gradient.hh
@@ -107,11 +107,8 @@ namespace mln
{
g.add_edge(vpsite(p), vpsite(q));
// The computed value is a norm of the gradient between P and Q.
- unsigned edge_id = edge_values.size();
- edge_values.resize(edge_values.size() + 1);
- edge_sites.resize(edge_sites.size() + 1);
- edge_values(edge_id) = math::abs(ima(p) - ima(q));
- edge_sites(edge_id) = util::site_pair<point2d>(p, q);
+ edge_values.append(math::abs(ima(p) - ima(q)));
+ edge_sites.append(util::site_pair<point2d>(p, q));
}
// Line graph point set.
diff --git a/milena/mln/util/site_pair.hh b/milena/mln/util/site_pair.hh
index 9bb3162..0dbc531 100644
--- a/milena/mln/util/site_pair.hh
+++ b/milena/mln/util/site_pair.hh
@@ -83,6 +83,10 @@ namespace mln
template <typename P>
bool operator< (const site_pair<P>& lhs, const site_pair<P>&
rhs);
+ template <typename P>
+ std::ostream&
+ operator<<(std::ostream& ostr, const site_pair<P>& p);
+
} // end of namespace mln::util
@@ -181,6 +185,15 @@ namespace mln
return lhs.pair() <= rhs.pair();
}
+ template <typename P>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr, const site_pair<P>& p)
+ {
+ ostr << "(" << p.first() << ", " <<
p.second() << ")";
+ return ostr;
+ }
+
} // end of mln::util
namespace internal
diff --git a/milena/tests/morpho/lena_line_graph_image_wst1.cc
b/milena/tests/morpho/lena_line_graph_image_wst1.cc
index d897d96..b100bec 100644
--- a/milena/tests/morpho/lena_line_graph_image_wst1.cc
+++ b/milena/tests/morpho/lena_line_graph_image_wst1.cc
@@ -139,11 +139,9 @@ int main()
for_all(q)
if (work.domain().has(q))
{
- unsigned edge_id = g.add_edge(equiv_vertex(p), equiv_vertex(q));
- edge_values.resize(edge_values.size() + 1);
- edge_sites.resize(edge_sites.size() + 1);
- edge_values(edge_id) = math::max(work(p), work(q));
- edge_sites(edge_id) = util::site_pair<point2d>(p, q);
+ g.add_edge(equiv_vertex(p), equiv_vertex(q));
+ edge_values.append(math::max(work(p), work(q)));
+ edge_sites.append(util::site_pair<point2d>(p, q));
}
// Line graph point set.
diff --git a/milena/tests/morpho/line_graph_image_wst.cc
b/milena/tests/morpho/line_graph_image_wst.cc
index e9f5871..c6c2ac0 100644
--- a/milena/tests/morpho/line_graph_image_wst.cc
+++ b/milena/tests/morpho/line_graph_image_wst.cc
@@ -39,6 +39,7 @@
#include <mln/pw/all.hh>
#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
+#include <mln/util/site_pair.hh>
#include <mln/morpho/meyer_wst.hh>
@@ -70,7 +71,7 @@ int main()
// Sites associated to vertices.
typedef fun::i2v::array<point2d> fsite_t;
- fsite_t sites(5);
+ fsite_t sites(8);
sites(0) = point2d(0,0); // Point associated to vertex 0.
sites(1) = point2d(0,1); // Point associated to vertex 1.
sites(2) = point2d(0,2); // Point associated to vertex 2.
@@ -97,8 +98,15 @@ int main()
g.add_edge(5, 6);
g.add_edge(6, 7);
- typedef p_edges<util::graph, fsite_t> pe_t;
- pe_t pe(g, sites);
+ // Associate edges to sites.
+ typedef fun::i2v::array< util::site_pair<point2d> > edge_sites_t;
+ edge_sites_t edge_sites(g.e_nmax());
+ mln_edge_iter_(util::graph) e(g);
+ for_all(e)
+ edge_sites(e) = util::site_pair<point2d>(sites(e.v1()), sites(e.v2()));
+
+ typedef p_edges<util::graph, edge_sites_t> pe_t;
+ pe_t pe(g, edge_sites);
// Edge values.
typedef fun::i2v::array<int> edge_values_t;
@@ -122,7 +130,7 @@ int main()
std::cout << "ima (" << p << ") = " <<
ima(p) << std::endl;
std::cout << std::endl;
- typedef line_graph_elt_window<util::graph, fsite_t> win_t;
+ typedef line_graph_elt_window<util::graph, edge_sites_t> win_t;
win_t win;
neighb<win_t> nbh(win);
--
1.5.6.5