00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef APPS_GRAPH_MORPHO_DEBUG_HH
00027 # define APPS_GRAPH_MORPHO_DEBUG_HH
00028
00031
00032 # include <mln/core/alias/complex_image.hh>
00033 # include <mln/core/image/image2d.hh>
00034
00035 # include <mln/debug/println.hh>
00036
00037 # include "apps/graph-morpho/convert.hh"
00038
00039
00040 namespace debug
00041 {
00042
00044 void
00045 println_graph(const std::string& message, const mln::image2d<bool>& input)
00046 {
00047
00048 mln_precondition(input.nrows() % 2 == 1);
00049 mln_precondition(input.ncols() % 2 == 1);
00050
00051 mln::image2d<char> output;
00052 mln::initialize(output, input);
00053 for (int row = input.domain().pmin().row();
00054 row <= input.domain().pmax().row(); ++row)
00055 {
00056 if (row % 2 == 0)
00057
00058 for (int col = input.domain().pmin().col();
00059 col <= input.domain().pmax().col(); ++col)
00060 {
00061 mln::point2d p(row, col);
00062 if (col % 2 == 0)
00063
00064 output(p) = input(p) ? 'O' : '.';
00065 else
00066
00067 output(p) = input(p) ? '-' : ' ';
00068 }
00069 else
00070
00071
00072 for (int col = input.domain().pmin().col();
00073 col <= input.domain().pmax().col(); ++col)
00074 {
00075 mln::point2d p(row, col);
00076 if (col % 2 == 0)
00077
00078 output(p) = input(p) ? '|' : ' ';
00079 else
00080
00081 output(p) = ' ';
00082 }
00083 }
00084 mln::debug::println(message, output);
00085 }
00086
00087
00089 void
00090 println_graph(const std::string& message,
00091 const mln::bin_1complex_image2d& input)
00092 {
00093 println_graph(message, convert::to_image2d(input));
00094 }
00095
00096 }
00097
00098
00099 #endif // ! APPS_GRAPH_MORPHO_DEBUG_HH