27 #ifndef MLN_DEBUG_DRAW_GRAPH_HH
28 # define MLN_DEBUG_DRAW_GRAPH_HH
36 # include <mln/core/site_set/p_vertices.hh>
37 # include <mln/core/site_set/p_edges.hh>
38 # include <mln/util/line_graph.hh>
39 # include <mln/util/site_pair.hh>
40 # include <mln/draw/line.hh>
41 # include <mln/draw/box_plain.hh>
42 # include <mln/data/fill.hh>
43 # include <mln/metal/equal.hh>
62 template <
typename I,
typename G,
typename F>
64 draw_graph(Image<I>& ima,
const p_vertices<G, F>& pv,
65 mln_value(I) vcolor, mln_value(I) ecolor);
78 template <
typename I,
typename G,
typename F,
typename V,
typename E>
81 const p_vertices<G, F>& pv,
82 const Function<V>& vcolor_f_,
const Function<E>& ecolor_f_);
94 template <
typename I,
typename G,
typename F,
typename V,
typename E>
98 const p_vertices<util::line_graph<G>, F>& pv,
99 const Function<V>& vcolor_f_,
const Function<E>& ecolor_f_);
102 # ifndef MLN_INCLUDE_ONLY
109 template <
typename I,
typename G,
typename F>
113 const p_edges<G, F>& pe,
117 trace::entering(
"debug::draw_graph");
119 I& ima = exact(ima_);
120 mln_precondition(ima.is_valid());
123 typedef p_edges<G, F> pe_t;
124 mln_piter(pe_t) p(pe);
127 if (ima.has(p.first()) && ima.has(p.second()))
128 draw::line(ima, p.first(), p.second(), ecolor);
129 if (ima.has(p.first()))
130 ima(p.first()) = vcolor;
131 if (ima.has(p.second()))
132 ima(p.second()) = vcolor;
135 trace::exiting(
"debug::draw_graph");
139 template <
typename I,
typename G,
typename F>
147 trace::entering(
"debug::draw_graph");
149 I& ima = exact(ima_);
150 mln_precondition(ima.is_valid());
153 const G& g = pv.
graph();
155 mln_edge_iter(G) ei(g);
157 draw::line(ima, pv(ei.v1()), pv(ei.v2()), ecolor);
160 mln_piter(pv_t) p(pv);
165 trace::exiting(
"debug::draw_graph");
170 template <
typename I,
typename G,
typename F,
typename V,
typename E>
177 trace::entering(
"debug::draw_graph");
179 I& ima = exact(ima_);
180 const V& vcolor_f = exact(vcolor_f_);
181 const E& ecolor_f = exact(ecolor_f_);
183 mln_precondition(ima.is_valid());
186 const G& g = pv.
graph();
188 mln_edge_iter(G) ei(g);
190 if (ei.v1() != 0 && ei.v2() != 0)
191 draw::line(ima, pv(ei.v1()), pv(ei.v2()), ecolor_f(ei.id()));
194 mln_piter(pv_t) p(pv);
196 if (ima.has(p) && p.id() != 0u)
203 trace::exiting(
"debug::draw_graph");
208 template <
typename I,
typename G,
typename F,
typename V,
typename E>
215 trace::entering(
"debug::draw_graph");
217 I& ima = exact(ima_);
218 const V& vcolor_f = exact(vcolor_f_);
219 const E& ecolor_f = exact(ecolor_f_);
221 mln_precondition(ima.is_valid());
225 const LG& lg = pv.
graph();
226 const G& g = lg.graph();
228 mln_vertex_iter(LG) vi(lg);
236 if (ima.has(l.
begin()))
237 ima(l.
begin()) = vcolor_f(g.edge(vi).v1());
238 if (ima.has(l.
end()))
239 ima(l.
end()) = vcolor_f(g.edge(vi).v2());
242 trace::exiting(
"debug::draw_graph");
245 # endif // ! MLN_INCLUDE_ONLY
251 #endif // ! MLN_DEBUG_DRAW_GRAPH_HH