URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-30 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add debug display tools for fllt.
* mln/util/tree_to_image.hh: Add functions :
(display_set(const Image<J>& ima_, set_p<P>& s)) :
display set_p with ima_ domain into a binary image.
(display_tree_rec(const Image<J>& ima_, node<T>* node, int level))
Recursive function of ...
(display_tree(const Image<J>& ima_, tree<I>& tree))
... function which displays all nodes of tree with display_set,
it shows the actual state of tree (of kind fllt) in pritting
each set_p of node with a number which gives the level of the node.
It isn't generic at all, it's just viewing tools for debugging,
to fix later when fllt will be generic too.
Use it ...
* sandbox/garrigues/fllt.hh: ... here for a better view of the
situation and so for the debbuging.
* sandbox/garrigues/test_fllt.cc: Fix the beggining of loop (1 -> 0).
---
mln/util/tree_to_image.hh | 59 +++++++++++++++++++++++++++++++++++++++--
sandbox/garrigues/fllt.hh | 18 +++++++++++-
sandbox/garrigues/test_fllt.cc | 4 +-
3 files changed, 76 insertions(+), 5 deletions(-)
Index: trunk/milena/mln/util/tree_to_image.hh
===================================================================
--- trunk/milena/mln/util/tree_to_image.hh (revision 1410)
+++ trunk/milena/mln/util/tree_to_image.hh (revision 1411)
@@ -53,6 +53,18 @@
void
tree_to_image (tree<T>& tree, Image<I>& output_);
+ template <typename P, typename J>
+ void
+ display_set(const Image<J>& ima_, set_p<P>& s);
+
+ template <typename T, typename J>
+ void
+ display_tree_rec(const Image<J>& ima_, node<T>* node, int level);
+
+ template <typename I, typename J>
+ void
+ display_tree(const Image<J>& ima_, tree<I>& tree);
+
# ifndef MLN_INCLUDE_ONLY
template <typename T, typename I>
@@ -61,7 +73,6 @@
{
I& output = exact(output_);
-
mln_piter(set_p<point2d>) p(node->elt().points);
for_all(p)
@@ -78,7 +89,6 @@
}
}
-
template <typename T, typename I>
void
tree_to_image (tree<T>& tree, Image<I>& output_)
@@ -87,6 +97,51 @@
tree_to_image_rec(tree.root(), output);
}
+
+ template <typename P, typename J>
+ void
+ display_set(const Image<J>& ima_, set_p<P>& s)
+ {
+ const J& ima = exact(ima_);
+ image2d<bool> out (ima.bbox ());
+
+ level::fill(out, false);
+ mln_piter(set_p<P>) p (s);
+ for_all (p)
+ out(p) = true;
+ debug::println(out);
+ }
+
+
+ template <typename T, typename J>
+ void
+ display_tree_rec(const Image<J>& ima_, node<T>* node, int level)
+ {
+ const J& ima = exact(ima_);
+ std::cout << level << std::endl;
+ std::cout << std::endl;
+ display_set(ima, node->elt().points);
+ typename mln::util::node<T>::children_t::iterator it =
node->children().begin();
+ for (;
+ it != node->children().end(); ++it)
+ display_tree_rec(ima, (*it), level + 1);
+ std::cout << std::endl;
+ std::cout << std::endl;
+ std::cout << std::endl;
+ std::cout << std::endl;
+ }
+
+ template <typename I, typename J>
+ void
+ display_tree(const Image<J>& ima_, tree<I>& tree)
+ {
+ const J& ima = exact(ima_);
+ int level = 0;
+
+ mln_assertion(tree.root());
+ display_tree_rec(ima, tree.root(), level);
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::util
Index: trunk/milena/sandbox/garrigues/fllt.hh
===================================================================
--- trunk/milena/sandbox/garrigues/fllt.hh (revision 1410)
+++ trunk/milena/sandbox/garrigues/fllt.hh (revision 1411)
@@ -269,7 +269,16 @@
static image2d<int> tmp(u.domain().to_larger(1));
static image2d<bool> border_ima(tmp.domain());
level::fill(border_ima, false);
- level::fill(inplace(border_ima | N), true);
+
+// level::fill(inplace(border_ima | N), true);
+// std::cout << "tmp border = " << tmp.border () <<
std::endl;
+// std::cout << "ima border = " << border_ima.border ()
<< std::endl;
+ mln_piter(set_p<P>) z(N);
+ for_all(z)
+ {
+ mln_assertion(border_ima.owns_(z));
+ border_ima(z) = true;
+ }
unsigned n;
labeling::level(border_ima, true, F::bdr_nbh(), tmp, n);
@@ -459,6 +468,7 @@
fllt_tree(P, V)& tree = *new fllt_tree(P, V)(current_region);
util::tree_to_image (tree, output);
+ util::display_tree(ima, tree);
// debug::println(output);
// std::cout << std::endl;
@@ -576,6 +586,7 @@
mln_piter(set_p<P>) p(node.elt().holes);
for_all(p)
{
+ std::cout << "OK start loop" << std::endl;
bool h = true;
fllt_node(P, V)* hole = find_the_hole(node, point2d(p), other_reg);
typename fllt_node(P, V)::children_t::iterator it;
@@ -591,7 +602,10 @@
}
}
if (h)
+ {
move_shape(node, *hole, tree, other_reg);
+ std::cout << "OK" << std::endl;
+ }
}
}
@@ -615,6 +629,7 @@
{
fllt_node(P, V)& n(p);
fill_a_shape(n, lower, upp_reg);
+ mln_assertion(n.check_consistency());
}
// fllt_branch_iter(P, V) q(upper.main_branch());
// for_all(q)
@@ -704,6 +719,7 @@
abort();
}
+
// io::pgm::save(output, "out_final.pgm");
// std::cout << "out_final.pgm generate"
// << std::endl;
Index: trunk/milena/sandbox/garrigues/test_fllt.cc
===================================================================
--- trunk/milena/sandbox/garrigues/test_fllt.cc (revision 1410)
+++ trunk/milena/sandbox/garrigues/test_fllt.cc (revision 1411)
@@ -32,8 +32,8 @@
// fllt::fllt(ima);
- for (int i = 1; i < 16; ++i)
- for (int j = 1; j < 16; ++j)
+ for (int i = 0; i < 16; ++i)
+ for (int j = 0; j < 16; ++j)
{
std::stringstream path;
path << "/lrde/tegucigalpa/theo/pub/mln_docs/lena_tiles/lena_" <<
i << "_" << j << ".pgm";
Index: trunk/milena/sandbox/garrigues/test_fllt2.cc
===================================================================