Commit 095d4d83 authored by Roland Levillain's avatar Roland Levillain
Browse files

Fix the processing order in topo::breadth_first_thinning.

	* mln/topo/skeleton/breadth_first_thinning.hh: Use a p_queue_fast
	site set instead of a pair of p_set's to ensure an actual
	breadth-first processing of sites.
parent 306940e5
2010-09-17 Roland Levillain <roland@lrde.epita.fr>
Fix the processing order in topo::breadth_first_thinning.
* mln/topo/skeleton/breadth_first_thinning.hh: Use a p_queue_fast
site set instead of a pair of p_set's to ensure an actual
breadth-first processing of sites.
2010-09-16 Roland Levillain <roland@lrde.epita.fr>
 
Split interface and implementation of topo::is_not_end_point.
......@@ -37,7 +37,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
# include <mln/core/site_set/p_set.hh>
# include <mln/core/site_set/p_queue_fast.hh>
# include <mln/fun/p2b/tautology.hh>
......@@ -116,9 +116,9 @@ namespace mln
is_simple.set_image(output);
typedef mln_psite(I) psite;
typedef p_set<psite> set_t;
set_t set;
// Populate SET with candidate simple points.
typedef p_queue_fast<psite> queue_t;
queue_t queue;
// Populate QUEUE with candidate simple points.
mln_piter(I) p_(output.domain());
for_all(p_)
{
......@@ -129,43 +129,34 @@ namespace mln
the compiler and pass an actual, explicit psite. */
psite p = p_;
if (output(p) && constraint(p) && is_simple(p))
set.insert(p);
queue.push(p);
}
while (!set.is_empty())
while (!queue.is_empty())
{
set_t next_set;
mln_piter(set_t) ps(set);
for_all(ps)
{
// Same remark as above.
psite p = ps;
/* FIXME: We compute the cell and attachment of P twice:
during the call to is_simple() and within detach().
How could we reuse this elegantly, without breaking
the genericity of the skeleton algorithm?
Also, keep in mind that functors can maintain an
internal state and make side effects, meaning that
e.g. constraint(p) might not be constant for a
given p during the thinning. */
if (output(p) && constraint(p) && is_simple(p))
psite p = queue.pop_front();
/* FIXME: We compute the cell and attachment of P twice:
during the call to is_simple() and within detach().
How could we reuse this elegantly, without breaking
the genericity of the skeleton algorithm?
Also, keep in mind that functors can maintain an
internal state and make side effects, meaning that
e.g. constraint(p) might not be constant for a
given p during the thinning. */
if (output(p) && constraint(p) && is_simple(p))
{
detach(p, output);
mln_niter(N) n_(nbh, p);
for_all(n_)
{
detach(p, output);
mln_niter(N) n_(nbh, p);
for_all(n_)
{
// Same remark as above regarding P and P_.
psite n = n_;
if (output.domain().has(n)
&& output(n) && constraint(n) && is_simple(n))
next_set.insert(n);
}
// Same remark as above regarding P and P_.
psite n = n_;
if (output.domain().has(n)
&& output(n) && constraint(n) && is_simple(n))
queue.push(n);
}
}
set.clear();
std::swap(set, next_set);
}
}
trace::exiting("topo::skeleton::breadth_first_thinning");
......
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