---
milena/ChangeLog | 4 ++
milena/mln/debug/draw_graph.hh | 66 +++++++++++++++++++++++++++++-----------
2 files changed, 52 insertions(+), 18 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index c8f5f24..fdc8bd7 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,7 @@
+2012-09-28 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * mln/debug/draw_graph.hh: Add a new overload and fix comments.
+
2012-05-11 Guillaume Lazzara <z(a)lrde.epita.fr>
* mln/core/alias/neighb3d.hh: Fix invalid c8_3d neighborhood.
diff --git a/milena/mln/debug/draw_graph.hh b/milena/mln/debug/draw_graph.hh
index 1bcbde6..0bab6f3 100644
--- a/milena/mln/debug/draw_graph.hh
+++ b/milena/mln/debug/draw_graph.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011, 2012 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -48,10 +48,11 @@ namespace mln
namespace debug
{
- /// Draw an image \p ima from a mln::p_vertices \p pv, with
- /// value \p vcolor for vertices, value \p ecolor for edges and 0 for
- /// the background.
- /*
+ /// \brief Draw an image \p ima from a mln::p_vertices \p pv.
+ /*!
+ * Value \p vcolor for vertices, value \p ecolor for edges
+ * and 0 for the background.
+ *
* \param[in,out] ima The image to be drawn.
* \param[in] pv The p_vertices which contains vertices positions.
* \param[in] vcolor The value to assign to pixels which contains
@@ -65,26 +66,41 @@ namespace mln
mln_value(I) vcolor, mln_value(I) ecolor);
- /// Draw an image \p ima from a mln::p_vertices \p pv. Colors for vertices
- /// are defined through \p vcolor_f_. Colors for edges are defined though
- /// \p ecolor_f_.
- /*
+ /// \brief Draw an image \p ima from a mln::p_vertices \p pv.
+ /*!
+ * Colors for vertices are defined through \p vcolor_f_. Colors
+ * for edges are defined though \p ecolor_f_.
+ * Vertices are drawn using a box of width \vwidth.
+ *
* \param[in,out] ima The image to be drawn.
* \param[in] pv The p_vertices which contains vertices positions.
- * \param[in] vcolor_f_ A function returning a color value for vertices.
- * \param[in] ecolor_f_ A function returning a color value for edges.
+ * \param[in] vcolor_f A function returning a color value for vertices.
+ * \param[in] ecolor_f A function returning a color value for edges.
+ * \param[in] vwidth
*
*/
template <typename I, typename G, typename F, typename V, typename E>
void
draw_graph(Image<I>& ima,
const p_vertices<G, F>& pv,
+ const Function<V>& vcolor_f, const Function<E>& ecolor_f,
+ unsigned vwidth);
+
+
+ /// \overload
+ template <typename I, typename G, typename F, typename V, typename E>
+ inline
+ void
+ draw_graph(Image<I>& ima_,
+ const p_vertices<G, F>& pv,
const Function<V>& vcolor_f_, const Function<E>& ecolor_f_);
- /// Draw an image \p ima from a mln::p_vertices \p pv. Colors for vertices
- /// are defined through \p vcolor_f_. Colors for edges are defined though
- /// \p ecolor_f_.
- /*
+ /// \brief Draw an image \p ima from a mln::p_vertices \p pv.
+ /*!
+ * Colors for vertices
+ * are defined through \p vcolor_f_. Colors for edges are defined though
+ * \p ecolor_f_.
+ *
* \param[in,out] ima The image to be drawn.
* \param[in] pv The p_vertices which contains vertices positions.
* \param[in] vcolor_f_ A function returning a color value for vertices.
@@ -172,7 +188,8 @@ namespace mln
void
draw_graph(Image<I>& ima_,
const p_vertices<G, F>& pv,
- const Function<V>& vcolor_f_, const Function<E>& ecolor_f_)
+ const Function<V>& vcolor_f_, const Function<E>& ecolor_f_,
+ unsigned vwidth)
{
trace::entering("debug::draw_graph");
@@ -191,11 +208,13 @@ namespace mln
draw::line(ima, pv(ei.v1()), pv(ei.v2()), ecolor_f(ei.id()));
// Draw vertices.
+ unsigned vhalf_width = vwidth / 2;
mln_piter(pv_t) p(pv);
for_all(p)
if (ima.has(p) && p.id() != 0u)
{
- box2d box(p + dpoint2d(-5, -5), p + dpoint2d(+5, +5));
+ box2d box(p + dpoint2d(-vhalf_width, -vhalf_width),
+ p + dpoint2d(+vhalf_width, +vhalf_width));
box.crop_wrt(ima.domain());
draw::box_plain(ima, box, vcolor_f(p.id()));
}
@@ -204,6 +223,17 @@ namespace mln
}
+ template <typename I, typename G, typename F, typename V, typename E>
+ inline
+ void
+ draw_graph(Image<I>& ima,
+ const p_vertices<G, F>& pv,
+ const Function<V>& vcolor_f, const Function<E>& ecolor_f)
+ {
+ draw_graph(ima, pv, vcolor_f, ecolor_f, 5);
+ }
+
+
// FIXME: Refactor + be more restrictive on the function type.
template <typename I, typename G, typename F, typename V, typename E>
inline
--
1.7.2.5