27 #ifndef SCRIBO_DRAW_BOUNDING_BOX_LINKS_HH
28 # define SCRIBO_DRAW_BOUNDING_BOX_LINKS_HH
34 # include <mln/core/concept/image.hh>
35 # include <mln/draw/line.hh>
36 # include <mln/util/array.hh>
37 # include <mln/canvas/browsing/depth_first_search.hh>
39 # include <scribo/core/tag/anchor.hh>
40 # include <scribo/core/macros.hh>
41 # include <scribo/core/object_links.hh>
42 # include <scribo/primitive/internal/is_link_valid.hh>
43 # include <scribo/primitive/link/internal/compute_anchor.hh>
60 template <
typename I,
typename L>
63 const object_links<L>& link,
64 const mln_value(I)&
value,
71 template <
typename I,
typename L>
74 const object_links<L>& link,
75 const mln_value(I)&
value);
89 template <
typename I,
typename L>
93 const object_links<L>& left_link,
94 const object_links<L>& right_link,
95 const mln_value(I)& left_link_value,
96 const mln_value(I)& right_link_value,
97 const mln_value(I)& validated_link_value,
108 template <
typename I,
typename G>
113 const mln_value(I)& link_value);
116 # ifndef MLN_INCLUDE_ONLY
123 template <
typename I>
125 shift_site(const I& ima,
126 const mln_site(I)& p, const mln_dpsite(mln_site_(I))& dp)
135 template <
typename I,
typename G>
136 struct draw_graph_edges_functor
143 draw_graph_edges_functor(I& ima,
144 const mln_value(I)&
value)
145 : ima_(ima), value_(value)
155 deja_vu.resize(
exact(g).v_nmax(),
false);
163 void next_component()
168 void new_component_from_vertex(
unsigned)
173 void added_to_queue(
unsigned id)
181 void process_vertex(
unsigned id)
182 { current_vertex = id; }
185 bool to_be_treated(
unsigned id)
186 {
return ! deja_vu[id]; }
189 bool to_be_queued(
unsigned id)
190 {
return to_be_treated(
id); }
199 unsigned current_vertex;
202 std::vector<
bool> deja_vu;
210 template <typename I, typename L>
214 const object_links<L>& links,
215 const mln_value(I)&
value,
218 mln_trace(
"scribo::draw::bounding_box_links");
220 I& input =
exact(input_);
222 mln_precondition(input.is_valid());
224 const component_set<L>& comps = links.components();
225 for_all_links(i, links)
226 if (links(i) != i && links(i) != 0)
229 p1 = primitive::link::internal::compute_anchor(comps, i, anchor),
230 p2 = primitive::link::internal::compute_anchor(comps, links(i), anchor);
232 mln::draw::
line(input, p1, p2, value);
238 template <typename I, typename L>
242 const object_links<L>& links,
243 const mln_value(I)& value)
249 template <
typename I,
typename L>
253 const object_links<L>& left_link,
254 const object_links<L>& right_link,
255 const mln_value(I)& left_link_value,
256 const mln_value(I)& right_link_value,
257 const mln_value(I)& validated_link_value,
260 mln_trace(
"scribo::draw::bounding_box_links");
262 I& input =
exact(input_);
263 mln_precondition(input.is_valid());
265 typedef mln_site(I) P;
267 const component_set<L>& comps = left_link.
components();
269 mln_dpsite(P) dleft = literal::zero;
271 mln_dpsite(P) dright = literal::zero;
273 for_all_links(i, left_link)
276 internal::shift_site(input,
277 primitive::link::internal::compute_anchor(comps, i, anchor),
279 internal::shift_site(input,
280 primitive::link::internal::compute_anchor(comps, left_link(i), anchor),
287 internal::shift_site(input,
288 primitive::link::internal::compute_anchor(comps, i, anchor),
290 internal::shift_site(input,
291 primitive::link::internal::compute_anchor(comps, right_link(i), anchor),
299 primitive::link::internal::compute_anchor(comps, i, anchor),
300 primitive::link::internal::compute_anchor(comps, left_link(i), anchor),
301 validated_link_value);
309 template <
typename I,
typename G>
314 const mln_value(I)& link_value)
316 mln_trace(
"scribo::draw::bounding_box_links");
317 mln_precondition(
exact(input).is_valid());
320 internal::draw_graph_edges_functor<I,G> f(
exact(input), link_value);
326 # endif // ! MLN_INCLUDE_ONLY
333 #endif // ! SCRIBO_DRAW_BOUNDING_BOX_LINKS_HH