r3653: Fix bugs related to 'glut leaves' process

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox ChangeLog: 2009-04-10 Edwin Carlinet <carlinet@lrde.epita.fr> Fix bugs related to 'glut leaves' process. * edwin/tree/propagate_node.hh: Minor changes. * edwin/tree/run.hh: Fix bugs. * edwin/tree/sharp.cc: Nothing important. --- propagate_node.hh | 3 +++ run.hh | 6 +++--- sharp.cc | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) Index: trunk/milena/sandbox/edwin/tree/sharp.cc =================================================================== --- trunk/milena/sandbox/edwin/tree/sharp.cc (revision 3652) +++ trunk/milena/sandbox/edwin/tree/sharp.cc (revision 3653) @@ -190,11 +190,11 @@ dsp(s.str()); } - if (sharpness != 0) { + if (nb_components) { + obj_array = morpho::tree::run_ntimes(tree, a, argmax, nb_components); + } else if (sharpness > 0) { mln_VAR(predicate, pw::value(a) > pw::cst(sharpness)); obj_array = morpho::tree::run_while(tree, a, argmax, predicate); - } else if (nb_components) { - obj_array = morpho::tree::run_ntimes(tree, a, argmax, nb_components); } else { obj_array = morpho::tree::run_until_glutted_leaves(tree, a, argmax); } Index: trunk/milena/sandbox/edwin/tree/run.hh =================================================================== --- trunk/milena/sandbox/edwin/tree/run.hh (revision 3652) +++ trunk/milena/sandbox/edwin/tree/run.hh (revision 3653) @@ -139,12 +139,9 @@ arr_values.append(a(p)); morpho::tree::propagate_node_to_descendants(p, tree, a, 0, 0); morpho::tree::propagate_node_to_ancestors(p, tree, a, 0); - if (pred(p)) // may have changed - { a(p) = 0; p = morpho::tree::run(tree, a, accu); } - } for (unsigned i = 0; i < arr_sites.nsites(); i++) a(arr_sites[i]) = arr_values[i]; return arr_sites; @@ -225,11 +222,14 @@ do { p = morpho::tree::run(tree, a, acc); + if (a(p) == 0) + break; arr_sites.insert(p); arr_values.append(a(p)); morpho::tree::propagate_node_to_descendants(p, tree, a, 0, &nb_leaves); morpho::tree::propagate_node_to_ancestors(p, tree, a, 0); a(p) = 0; + mln_assertion(nb_leaves <= n); } while ((n -= nb_leaves)); Index: trunk/milena/sandbox/edwin/tree/propagate_node.hh =================================================================== --- trunk/milena/sandbox/edwin/tree/propagate_node.hh (revision 3652) +++ trunk/milena/sandbox/edwin/tree/propagate_node.hh (revision 3653) @@ -113,6 +113,7 @@ template <typename T, typename A> + inline void propagate_node_to_descendants(mln_psite(A) n, const T& t, @@ -133,8 +134,10 @@ typename T::preorder_piter pp(t, n); pp.start(); // We don't set n to v. + if (nb_leaves) *nb_leaves = t.is_a_leaf(pp); + for (pp.next(); pp.is_valid(); pp.next()) { a(pp) = v;
participants (1)
-
Edwin Carlinet