]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/SeedsInterface.hxx
...
[FrontAlgorithms.git] / lib / fpa / Base / SeedsInterface.hxx
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Base__SeedsInterface__hxx__
7 #define __fpa__Base__SeedsInterface__hxx__
8
9 // -------------------------------------------------------------------------
10 template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
11 unsigned int
12 fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
13 GetNumberOfSeeds( ) const
14 {
15   return( this->m_Seeds.size( ) );
16 }
17
18 // -------------------------------------------------------------------------
19 template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
20 const typename
21 fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
22 TSeeds&
23 fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
24 GetSeeds( ) const
25 {
26   return( this->m_Seeds );
27 }
28
29 // -------------------------------------------------------------------------
30 template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
31 typename
32 fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
33 TSeeds::const_iterator
34 fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
35 BeginSeeds( ) const
36 {
37   return( this->m_Seeds.begin( ) );
38 }
39
40 // -------------------------------------------------------------------------
41 template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
42 typename
43 fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
44 TSeeds::const_iterator
45 fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
46 EndSeeds( ) const
47 {
48   return( this->m_Seeds.end( ) );
49 }
50
51 // -------------------------------------------------------------------------
52 template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
53 void
54 fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
55 AddSeed( const TVertex& seed )
56 {
57   TNode node;
58   node.Vertex = seed;
59   node.Parent = seed;
60   node.FrontId = TFrontId( this->m_Seeds.size( ) + 1 );
61   if( this->m_Seeds.insert( node ).second && this->m_Filter != NULL )
62     this->m_Filter->Modified( );
63 }
64
65 // -------------------------------------------------------------------------
66 template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
67 void
68 fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
69 RemoveSeed( const TVertex& seed )
70 {
71   TNode node;
72   node.Vertex = seed;
73   node.Parent = seed;
74   typename TSeeds::const_iterator i = this->m_Seeds.find( node );
75   if( i != this->m_Seeds.end( ) )
76   {
77     this->m_Seeds.erase( i );
78     if( this->m_Filter != NULL )
79       this->m_Filter->Modified( );
80
81   } // fi
82 }
83
84 // -------------------------------------------------------------------------
85 template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
86 void
87 fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
88 ClearSeeds( )
89 {
90   if( this->m_Seeds.size( ) > 0 )
91   {
92     this->m_Seeds.clear( );
93     if( this->m_Filter != NULL )
94       this->m_Filter->Modified( );
95
96   } // fi
97 }
98
99 // -------------------------------------------------------------------------
100 template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
101 fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
102 SeedsInterface( itk::ProcessObject* filter )
103   : m_Filter( filter )
104 {
105 }
106
107 // -------------------------------------------------------------------------
108 template< class _TVertex, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare >
109 fpa::Base::SeedsInterface< _TVertex, _TInputValue, _TOutputValue, _TFrontId, _TCompare >::
110 ~SeedsInterface( )
111 {
112   this->m_Seeds.clear( );
113 }
114
115 #endif // __fpa__Base__SeedsInterface__hxx__
116
117 // eof - $RCSfile$