
Index: ChangeLog from Ugo Jardonnet <ugo.jardonnet@lrde.epita.fr> Update cc_tarjan impl + facade. * oln/morpho/cc_tarjan.hh: Up (shape). cc_tarjan.hh | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) Index: oln/morpho/cc_tarjan.hh --- oln/morpho/cc_tarjan.hh (revision 916) +++ oln/morpho/cc_tarjan.hh (working copy) @@ -25,8 +25,8 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef OLN_MORPHO_DILATION_HH -# define OLN_MORPHO_DILATION_HH +#ifndef OLN_MORPHO_CC_TARJAN_HH +# define OLN_MORPHO_CC_TARJAN_HH #include <oln/debug/print.hh> @@ -36,21 +36,19 @@ namespace morpho { + namespace impl + { template <typename I> oln_point(I) find_root(I& ima, const oln_point(I)& x, oln_plain_value(I, oln_point(I))& parent) { - std::cout << "enter_root( " << parent(x) << "," << x << " )" << std::endl; - if (parent(x) != x) { parent(x) = find_root(ima, parent(x), parent); return parent(x); } return x; - - std::cout << "leave_root" << std::endl; } template <typename I> @@ -81,17 +79,12 @@ if ( input(n) ) { if ( is_processed(n) ) - { do_union(input ,n, p, parent); - std::cout << "union ("<< p << ") -> parent :" << std::endl; - debug::print(parent); - } } } is_processed(p) = true; } } - std::cout << "pass 1" << std::endl; } template <typename I> @@ -100,26 +93,19 @@ oln_plain_value(I, unsigned)& output) { unsigned current_label = 0; - - // Second pass oln_fwd_piter(I) p(input.points()); for_all(p) { - if ( input(p) ) - { - if ( parent(p) == p ) + if ( input(p) && parent(p) == p ) output(p) = ++current_label; else output(p) = output(parent(p)); - std::cout << "output :" << std::endl; - debug::print(output); - } } } template <typename I> oln_plain_value(I, unsigned) - cc_tarjan(const Image_with_Nbh<I>& input) + cc_tarjan_(const Image_with_Nbh<I>& input) { oln_plain_value(I, unsigned) output; prepare(output, with, input); @@ -127,24 +113,31 @@ oln_plain_value(I, oln_point(I)) parent; prepare(parent, with, input); - // Init oln_plain(I) is_processed; prepare(is_processed, with, input); oln_piter(I) p1(input.points()); for_all(p1) - is_processed(p1) = false; // FIXME : built with. + is_processed(p1) = false; // FIXME : built with ?. first_pass(input, parent, is_processed); - second_pass(input, parent, output); - - ::oln::debug::print(parent); return output; } + } // end of namespace oln::morpho::impl + + // Facades. + + template <typename I> + oln_plain_value(I, unsigned) + cc_tarjan(const Binary_Image<I>& input) + { + return impl::cc_tarjan_(exact(input)); + } + } // end of namespace oln::morpho } // end of namespace oln -#endif // ! OLN_MORPHO_DILATION_HH +#endif // ! OLN_MORPHO_CC_TARJAN_HH