27 #ifndef SCRIBO_TEXT_LINK_LINES_HH
28 # define SCRIBO_TEXT_LINK_LINES_HH
35 #include <mln/value/int_u16.hh>
36 #include <mln/data/fill.hh>
37 #include <mln/geom/rotate.hh>
38 #include <mln/geom/ncols.hh>
39 #include <mln/draw/box_plain.hh>
40 #include <mln/util/array.hh>
42 #include <scribo/core/line_links.hh>
66 # ifndef MLN_INCLUDE_ONLY
73 typedef value::int_u16 V;
75 const mln_concrete(L)& lbl = lines.components().labeled_image();
79 -90, lbl.domain().pcenter()));
80 mln::
data::
fill(blocks, literal::zero);
83 mln::util::array<mln_box(L)> rbbox(1);
84 rbbox.reserve(lines.nelements());
86 for_all_lines(l, lines)
88 if (! lines(l).is_valid() || lines(l).is_hidden() || lines(l).type() != line::Text)
90 rbbox.resize(rbbox.nelements() + 1);
94 mln_box(L) b = mln::geom::
rotate(lines(l).
bbox(), -90, lbl.domain().pcenter());
100 line_links<L> links(lines);
103 for_all_lines(l, lines)
105 if (! lines(l).is_valid() || lines(l).is_hidden() || lines(l).type() != line::Text)
108 int dmax = 1.5 * lines(l).x_height();
109 mln_site(L) c = rbbox(l).pcenter();
112 midcol = (rbbox(l).pmax().col()
113 - rbbox(l).pmin().col()) / 2;
116 nleftima = std::
abs(c.col() - blocks.domain().pmin().col()),
117 nleft = std::
min(nleftima, midcol + dmax);
125 for (; p != pstop; --p)
127 if (*p != literal::zero
140 nrightima =
geom::ncols(blocks) - c.col() + blocks.domain().pmin().col(),
141 nright =
std::min(nrightima, midcol + dmax);
145 *pstop = p + nright - 1;
147 for (; p != pstop; ++p)
149 if (*p != literal::zero
165 # endif // ! MLN_INCLUDE_ONLY
173 #endif // ! SCRIBO_TEXT_LINK_LINES_HH