Milena (Olena)
User documentation 2.0a Id
Main Page
Related Pages
Modules
Namespaces
Classes
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerator
Groups
Pages
debug.hh
1
// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
2
//
3
// This file is part of Olena.
4
//
5
// Olena is free software: you can redistribute it and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, version 2 of the License.
8
//
9
// Olena is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
// General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
16
//
17
// As a special exception, you may use this file as part of a free
18
// software project without restriction. Specifically, if other files
19
// instantiate templates or use macros or inline functions from this
20
// file, or you compile this file and link it with other files to produce
21
// an executable, this file does not by itself cause the resulting
22
// executable to be covered by the GNU General Public License. This
23
// exception does not however invalidate any other reasons why the
24
// executable file might be covered by the GNU General Public License.
25
26
#ifndef APPS_GRAPH_MORPHO_DEBUG_HH
27
# define APPS_GRAPH_MORPHO_DEBUG_HH
28
31
32
# include <mln/core/alias/complex_image.hh>
33
# include <mln/core/image/image2d.hh>
34
35
# include <mln/debug/println.hh>
36
37
# include "apps/graph-morpho/convert.hh"
38
39
40
namespace
debug
41
{
42
44
void
45
println_graph(
const
std::string& message,
const
mln::image2d<bool>
& input)
46
{
47
// INPUT must have odd numbers of rows and columns.
48
mln_precondition(input.
nrows
() % 2 == 1);
49
mln_precondition(input.
ncols
() % 2 == 1);
50
51
mln::image2d<char>
output;
52
mln::initialize
(output, input);
53
for
(
int
row = input.
domain
().pmin().row();
54
row <= input.
domain
().pmax().row(); ++row)
55
{
56
if
(row % 2 == 0)
57
// Even row: line with vertices and horizontal edges.
58
for
(
int
col = input.
domain
().pmin().col();
59
col <= input.
domain
().pmax().col(); ++col)
60
{
61
mln::point2d
p(row, col);
62
if
(col % 2 == 0)
63
// Even column: vertex.
64
output(p) = input(p) ?
'O'
:
'.'
;
65
else
66
// Odd column: horizontal edge.
67
output(p) = input(p) ?
'-'
:
' '
;
68
}
69
else
70
// Odd row: line with vertical edges and inter-edge spaces
71
// (squares).
72
for
(
int
col = input.
domain
().pmin().col();
73
col <= input.
domain
().pmax().col(); ++col)
74
{
75
mln::point2d
p(row, col);
76
if
(col % 2 == 0)
77
// Even column: vertical edge.
78
output(p) = input(p) ?
'|'
:
' '
;
79
else
80
// Odd column: space.
81
output(p) =
' '
;
82
}
83
}
84
mln::debug::println
(message, output);
85
}
86
87
89
void
90
println_graph(
const
std::string& message,
91
const
mln::bin_1complex_image2d
& input)
92
{
93
println_graph(message, convert::to_image2d(input));
94
}
95
96
}
// end of namespace debug
97
98
99
#endif // ! APPS_GRAPH_MORPHO_DEBUG_HH
apps
graph-morpho
debug.hh
Generated on Thu Nov 8 2012 10:58:00 for Milena (Olena) by
1.8.2-20120930