https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make morpho meyer_wst practicable.
* mln/core/routine/ops.hh (FIXME): Resolve warning.
* mln/morpho/meyer_wst.hh (in_queue): New.
core/routine/ops.hh | 4 +---
morpho/meyer_wst.hh | 17 ++++++++++++-----
2 files changed, 13 insertions(+), 8 deletions(-)
Index: mln/core/routine/ops.hh
--- mln/core/routine/ops.hh (revision 2565)
+++ mln/core/routine/ops.hh (working copy)
@@ -456,9 +456,7 @@
operator-(const Object<O>& rhs)
{
mlc_converts_to(literal::zero_t, O)::check();
- /* FIXME: The following statements trigger a warning:
- ``'p_zero' is used uninitialized in this function.'' */
- literal::zero_t* p_zero;
+ literal::zero_t* p_zero = 0;
return O(*p_zero) - exact(rhs);
}
Index: mln/morpho/meyer_wst.hh
--- mln/morpho/meyer_wst.hh (revision 2565)
+++ mln/morpho/meyer_wst.hh (working copy)
@@ -39,8 +39,6 @@
eaux. In: Actes du 8�me Congr�s AFCET, Lyon-Villeurbanne, France
(1991), pages 847--859. */
-# include <queue>
-
# include <mln/trait/ch_value.hh>
// FIXME: See below.
@@ -53,7 +51,6 @@
# include <mln/core/site_set/p_priority.hh>
-
namespace mln
{
@@ -130,7 +127,12 @@
// Ordered queue.
typedef p_queue_fast<psite> Q;
- p_priority<mln_value(I), Q> queue;
+ p_priority<V, Q> queue;
+
+ // In_queue structure to avoid processing sites several times.
+ mln_ch_value(I, bool) in_queue;
+ initialize(in_queue, input);
+ level::fill(in_queue, false);
// Insert every neighbor P of every marked area in a
// hierarchical queue, with a priority level corresponding to
@@ -143,6 +145,7 @@
if (output.domain().has(n) && output(n) != unmarked)
{
queue.push(max - input(p), p);
+ in_queue(p) = true;
break;
}
@@ -181,8 +184,12 @@
{
output(p) = adjacent_marker;
for_all(n)
- if (output.domain().has(n) && output(n) == unmarked)
+ if (output.domain().has(n) && output(n) == unmarked
+ && ! in_queue(n))
+ {
queue.push(max - input(n), n);
+ in_queue(n) = true;
+ }
}
}
return output;