$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
char_space_image.hh
1 // Copyright (C) 2010, 2011 EPITA Research and Development Laboratory
2 // (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 #ifndef SCRIBO_DEBUG_CHAR_SPACE_IMAGE_HH
28 # define SCRIBO_DEBUG_CHAR_SPACE_IMAGE_HH
29 
33 
34 # include <mln/core/concept/image.hh>
35 # include <mln/core/alias/point2d.hh>
36 # include <mln/value/rgb8.hh>
37 # include <mln/data/convert.hh>
38 
39 # include <mln/draw/box.hh>
40 # include <mln/draw/line.hh>
41 
42 # include <mln/literal/colors.hh>
43 
44 # include <scribo/core/line_set.hh>
45 
46 
47 namespace scribo
48 {
49 
50  namespace debug
51  {
52 
53  using namespace mln;
54 
55 
59  //
60  template <typename I, typename L>
61  mln_ch_value(I,value::rgb8)
62  char_space_image(const Image<I>& input, const line_set<L>& line,
63  const value::rgb8& v = literal::cyan);
64 
65 
66 # ifndef MLN_INCLUDE_ONLY
67 
68 
69  template <typename I, typename L>
70  mln_ch_value(I,value::rgb8)
71  char_space_image(const Image<I>& input, const line_set<L>& line,
72  const value::rgb8& v)
73  {
74  mln_trace("scribo::debug::char_space_image");
75 
76  mln_ch_value(I,value::rgb8) output = data::convert(value::rgb8(), input);
77 
78  const component_set<L>& comps = line.components();
79  for_all_lines(l, line)
80  {
81  if (! line(l).is_valid() || line(l).is_hidden()
82  || line(l).component_ids().size() < 2)
83  continue;
84 
85 
86  for_all_elements(i, line(l).component_ids())
87  {
88  if (i == line(l).component_ids().nelements() - 1)
89  continue;
90 
91  unsigned c = line(l).component_ids()[i];
92 
93  point2d
94  beg = comps(c).bbox().pmax(),
95  end = beg;
96  beg.row() = comps(c).bbox().pmin().row();
97  mln::draw::line(output, beg, end, v);
98  beg.col() += line(l).char_space();
99  end.col() += line(l).char_space();
100  mln::draw::line(output, beg, end, v);
101  }
102 
103  }
104 
105  return output;
106  }
107 
108 
109 # endif // ! MLN_INCLUDE_ONLY
110 
111  } // end of namespace scribo::debug
112 
113 } // end of namespace scribo
114 
115 #endif // ! SCRIBO_DEBUG_CHAR_SPACE_IMAGE_HH