Commit b97c12ae authored by Roland Levillain's avatar Roland Levillain
Browse files

Prevent a site from being introduced twice in thinning's queues.

	* mln/topo/skeleton/breadth_first_thinning.hh,
	* mln/topo/skeleton/priority_driven_thinning.hh:
	Use an image `in_queue' to tag sites inserted in the queue.
parent 6cb33ef7
2011-03-14 Roland Levillain <roland@lrde.epita.fr>
Prevent a site from being introduced twice in thinning's queues.
* mln/topo/skeleton/breadth_first_thinning.hh,
* mln/topo/skeleton/priority_driven_thinning.hh:
Use an image `in_queue' to tag sites inserted in the queue.
2011-03-14 Roland Levillain <roland@lrde.epita.fr>
 
Add routines to identify and detach (collapse) simple pairs.
// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
//
......@@ -41,6 +42,9 @@
# include <mln/fun/p2b/tautology.hh>
# include <mln/data/fill.hh>
namespace mln
{
......@@ -123,20 +127,30 @@ namespace mln
is_simple.set_image(output);
detach.set_image(output);
// FIFO queue.
typedef mln_psite(I) psite;
typedef p_queue_fast<psite> queue_t;
queue_t queue;
// Image showing whether a site has been inserted into the queue.
mln_ch_value(I, bool) in_queue;
initialize(in_queue, input);
data::fill(in_queue, false);
// Populate QUEUE with candidate simple points.
mln_piter(I) p(output.domain());
for_all(p)
{
if (output(p) && constraint(p) && is_simple(p))
queue.push(p);
{
queue.push(p);
in_queue(p) = true;
}
}
while (!queue.is_empty())
{
psite p = queue.pop_front();
in_queue(p) = false;
if (output(p) && constraint(p) && is_simple(p))
{
detach(p);
......@@ -144,8 +158,12 @@ namespace mln
for_all(n)
{
if (output.domain().has(n)
&& output(n) && constraint(n) && is_simple(n))
queue.push(n);
&& output(n) && constraint(n) && is_simple(n)
&& !in_queue(n))
{
queue.push(n);
in_queue(n) = true;
}
}
}
}
......
......@@ -43,6 +43,9 @@
# include <mln/fun/p2b/tautology.hh>
# include <mln/data/fill.hh>
namespace mln
{
......@@ -133,21 +136,31 @@ namespace mln
is_simple.set_image(output);
detach.set_image(output);
// Priority queue.
typedef mln_psite(I) psite;
typedef p_queue_fast<psite> queue_t;
typedef p_priority<mln_value(J), queue_t> priority_queue_t;
priority_queue_t queue;
// Image showing whether a site has been inserted into the queue.
mln_ch_value(I, bool) in_queue;
initialize(in_queue, input);
data::fill(in_queue, false);
// Populate QUEUE with candidate simple points.
mln_piter(I) p(output.domain());
for_all(p)
{
if (output(p) && constraint(p) && is_simple(p))
queue.push(priority(p), p);
{
queue.push(priority(p), p);
in_queue(p) = true;
}
}
while (!queue.is_empty())
{
psite p = queue.pop_front();
in_queue(p) = false;
if (output(p) && constraint(p) && is_simple(p))
{
detach(p);
......@@ -155,8 +168,12 @@ namespace mln
for_all(n)
{
if (output.domain().has(n)
&& output(n) && constraint(n) && is_simple(n))
queue.push(priority(n), n);
&& output(n) && constraint(n) && is_simple(n)
&& !in_queue(n))
{
queue.push(priority(n), n);
in_queue(n) = true;
}
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment