oln::topo::tarjan::abstract::tarjan_with_attr< Exact > Struct Template Reference

Abstract class to perform a tarjan algorithm on an image with attribute computing . More...

#include <tarjan_with_attr.hh>

Inheritance diagram for oln::topo::tarjan::abstract::tarjan_with_attr< Exact >:

Inheritance graph
[legend]
Collaboration diagram for oln::topo::tarjan::abstract::tarjan_with_attr< Exact >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef oln::topo::tarjan::tarjan_traits<
Exact >::input_type 
input_type
 Type of input image.
typedef mlc::exact< input_type
>::ret::point_type 
point_type
 Point type of image to process.
typedef mlc::exact< input_type
>::ret::value_type 
data_type
 Data type of the input image.
typedef oln::mute< input_type
>::ret 
image_type
 Concrete type of the input image.
typedef oln::topo::tarjan::tarjan_traits<
Exact >::output_type 
image_out_type
 Type of output image.
typedef oln::topo::tarjan::tarjan_traits<
Exact >::attr_type 
attr_type
 Type of attribute to use.
typedef oln::morpho::attr::attr_traits<
attr_type >::env_type 
env_type
 Environment associated to attribute type.
typedef mlc::exact< image_out_type
>::ret::value_type 
comp_type
 Type of components.
typedef mlc::exact_vt< tarjan_with_attr<
Exact >, Exact >::ret 
exact_type
 Exact type of the class.
typedef tarjan< exact_typesuper_type
 Type of parent class.

Public Member Functions

const attr_typeget_attr (const comp_type &i) const
 Return the attribute value associated to a component i.

Protected Member Functions

 tarjan_with_attr (const image_type &ima, const env_type &env)
 Constructor.
bool is_proc_impl (const point_type &p) const
 Implementation of is_proc().
comp_type find_root (const comp_type &x) const
 Implementation of find_root().
template<class N>
image_out_type get_compute_impl (const oln::abstract::neighborhood< N > &Ng)
 Implementation of get_compute().
comp_type ncomps_impl () const
 Implementation of ncomps_impl().

Protected Attributes

unsigned capacity_chunk
unsigned capacity
const image_typeinput_
std::vector< comp_typeparent_
oln::mute< input_type, comp_type
>::ret 
to_comp_
comp_type ncomps_
std::vector< typename mlc::exact<
image_out_type >::ret::value_type > 
comp_value_
std::vector< attr_typedata_
env_type env_

Friends

class tarjan< exact_type >

Detailed Description

template<class Exact>
struct oln::topo::tarjan::abstract::tarjan_with_attr< Exact >

Abstract class to perform a tarjan algorithm on an image with attribute computing .

Parameters:
Exact Exact type of the class.

Definition at line 56 of file tarjan_with_attr.hh.


Constructor & Destructor Documentation

template<class Exact>
oln::topo::tarjan::abstract::tarjan_with_attr< Exact >::tarjan_with_attr ( const image_type ima,
const env_type env 
) [inline, protected]

Constructor.

Initialization of data structures.

Warning:
This constructor is protected, because this class is abstract.

Definition at line 97 of file tarjan_with_attr.hh.

00098                                                :
00099             capacity_chunk((ima.npoints() < 100) ? ima.npoints() : (ima.npoints() / 100)),
00100             capacity(capacity_chunk),
00101             input_(ima),
00102             parent_(),
00103             to_comp_(ima.size()),
00104             comp_value_(),
00105             env_(env)
00106           {
00107             parent_.reserve(capacity);
00108             comp_value_.reserve(capacity);
00109             data_.reserve(capacity);
00110           }


Member Function Documentation

template<class Exact>
bool oln::topo::tarjan::abstract::tarjan_with_attr< Exact >::is_proc_impl ( const point_type p  )  const [inline, protected]

Implementation of is_proc().

Warning:
Do not call this method, use is_proc() instead.

Definition at line 119 of file tarjan_with_attr.hh.

00120           {
00121             return to_comp_[p] != ntg_sup_val(comp_type);
00122           };

template<class Exact>
comp_type oln::topo::tarjan::abstract::tarjan_with_attr< Exact >::find_root ( const comp_type x  )  const [inline, protected]

Implementation of find_root().

Warning:
Do not call this method, use find_root() instead.

Definition at line 133 of file tarjan_with_attr.hh.

Referenced by oln::topo::tarjan::abstract::tarjan_with_attr< mlc::exact_vt< oln::topo::tarjan::flat_zone< T, DestType, A, Exact >, Exact >::ret >::find_root(), oln::topo::tarjan::abstract::tarjan_with_attr< mlc::exact_vt< oln::topo::tarjan::flat_zone< T, DestType, A, Exact >, Exact >::ret >::get_attr(), oln::topo::tarjan::abstract::tarjan_with_attr< mlc::exact_vt< oln::topo::tarjan::flat_zone< T, DestType, A, Exact >, Exact >::ret >::get_compute_impl(), and oln::topo::tarjan::flat_zone< T, DestType, A, Exact >::uni_impl().

00134           {
00135             if (parent_[x] != x)
00136               return parent_[x] = find_root(parent_[x]);
00137             return x;
00138           }

template<class Exact>
template<class N>
image_out_type oln::topo::tarjan::abstract::tarjan_with_attr< Exact >::get_compute_impl ( const oln::abstract::neighborhood< N > &  Ng  )  [inline, protected]

Implementation of get_compute().

Warning:
Do not call this method, use get_compute() instead.

Definition at line 150 of file tarjan_with_attr.hh.

00151           {
00152             std::vector<point_type>     I(this->get_processing_order());
00153 
00154             level::fill(to_comp_, ntg_sup_val(comp_type));
00155             to_comp_.border_adapt_assign(Ng.delta(), ntg_sup_val(comp_type));
00156             ncomps_ = 0;
00157             parent_.push_back(0);
00158             comp_value_.push_back(0);
00159             data_.push_back(attr_type());
00160 
00161             // We are ready to perform stuff
00162             for (unsigned int p = 0; p < I.size(); ++p)
00163               {
00164                 point_type p_p = I[p];
00165                 mark_set(p_p);
00166 
00167                 oln_neighb_type(N) Q_prime(Ng, p_p);
00168                 for_all (Q_prime)
00169                   if (is_proc(Q_prime))
00170                     this->uni(Q_prime.cur(), p_p);
00171                 if (to_comp_[p_p] == (ncomps_ + 1)) // new component
00172                   ++ncomps_;
00173                 else
00174                   {
00175                     comp_value_.pop_back();
00176                     parent_.pop_back();
00177                     data_.pop_back();
00178                   }
00179               }
00180 
00181             // Resolving phase
00182             std::map<comp_type, comp_type>              cmps;
00183             ncomps_ = 0;
00184             for (int p = I.size() - 1; p >= 0; --p)
00185               {
00186                 point_type p_p = I[p];
00187                 if (cmps.find(find_root(to_comp_[p_p])) == cmps.end())
00188                   {
00189                     cmps[comp_value_[find_root(to_comp_[p_p])]] = ncomps_;
00190                     comp_value_[find_root(to_comp_[p_p])] = ncomps_++;
00191                   }
00192               }
00193 
00194             image_out_type output(input_.size());
00195             for (int p = I.size() - 1; p >= 0; --p)
00196               {
00197                 point_type p_p = I[p];
00198                 output[p_p] = comp_value_[find_root(to_comp_[p_p])];
00199               }
00200             return output;
00201           }

template<class Exact>
comp_type oln::topo::tarjan::abstract::tarjan_with_attr< Exact >::ncomps_impl (  )  const [inline, protected]

Implementation of ncomps_impl().

Warning:
Do not call this method, use ncomps() instead.

Definition at line 208 of file tarjan_with_attr.hh.

00209           {
00210             return ncomps_;
00211           }


The documentation for this struct was generated from the following file:
Generated on Tue Feb 20 20:29:44 2007 for Olena by  doxygen 1.5.1