1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
6 #ifndef __fpa__Base__RegionGrow__hxx__
7 #define __fpa__Base__RegionGrow__hxx__
9 // -------------------------------------------------------------------------
10 template< class _TAlgorithm >
11 itk::ModifiedTimeType fpa::Base::RegionGrow< _TAlgorithm >::
14 itk::ModifiedTimeType t = this->Superclass::GetMTime( );
15 if( this->m_ValuePredicate.IsNotNull( ) )
17 itk::ModifiedTimeType q = this->m_ValuePredicate->GetMTime( );
21 if( this->m_VertexPredicate.IsNotNull( ) )
23 itk::ModifiedTimeType q = this->m_VertexPredicate->GetMTime( );
31 // -------------------------------------------------------------------------
32 template< class _TAlgorithm >
33 typename fpa::Base::RegionGrow< _TAlgorithm >::
34 TOutputValue fpa::Base::RegionGrow< _TAlgorithm >::
35 GetOutsideValue( ) const
37 return( this->GetInitValue( ) );
40 // -------------------------------------------------------------------------
41 template< class _TAlgorithm >
42 void fpa::Base::RegionGrow< _TAlgorithm >::
43 SetOutsideValue( const TOutputValue& v )
45 this->SetInitValue( v );
48 // -------------------------------------------------------------------------
49 template< class _TAlgorithm >
50 void fpa::Base::RegionGrow< _TAlgorithm >::
51 SetPredicate( TValuePredicate* p )
53 if( this->m_ValuePredicate.GetPointer( ) != p )
55 this->m_ValuePredicate = p;
61 // -------------------------------------------------------------------------
62 template< class _TAlgorithm >
63 void fpa::Base::RegionGrow< _TAlgorithm >::
64 SetPredicate( TVertexPredicate* p )
66 if( this->m_VertexPredicate.GetPointer( ) != p )
68 this->m_VertexPredicate = p;
74 // -------------------------------------------------------------------------
75 template< class _TAlgorithm >
76 fpa::Base::RegionGrow< _TAlgorithm >::
79 m_InsideValue( TOutputValue( 1 ) )
81 this->SetInitValue( TOutputValue( 0 ) );
84 // -------------------------------------------------------------------------
85 template< class _TAlgorithm >
86 fpa::Base::RegionGrow< _TAlgorithm >::
91 // -------------------------------------------------------------------------
92 template< class _TAlgorithm >
93 typename fpa::Base::RegionGrow< _TAlgorithm >::
94 TOutputValue fpa::Base::RegionGrow< _TAlgorithm >::
95 _ComputeOutputValue( const TNode& n )
97 TInputValue value = this->_GetInputValue( n.Vertex );
99 if( this->m_ValuePredicate.IsNotNull( ) )
100 inside = this->m_ValuePredicate->Evaluate( value );
101 if( this->m_VertexPredicate.IsNotNull( ) )
102 inside &= this->m_VertexPredicate->Evaluate( n.Vertex );
103 return( ( inside )? this->m_InsideValue: this->m_InitValue );
106 // -------------------------------------------------------------------------
107 template< class _TAlgorithm >
108 void fpa::Base::RegionGrow< _TAlgorithm >::
111 typedef typename Superclass::TSeedsInterface::TSeeds::iterator _TIt;
113 this->Superclass::_QueueInit( );
114 for( _TIt sIt = this->BeginSeeds( ); sIt != this->EndSeeds( ); ++sIt )
115 sIt->Value = this->m_InsideValue;
118 // -------------------------------------------------------------------------
119 template< class _TAlgorithm >
120 void fpa::Base::RegionGrow< _TAlgorithm >::
123 this->m_Queue.clear( );
126 // -------------------------------------------------------------------------
127 template< class _TAlgorithm >
128 typename fpa::Base::RegionGrow< _TAlgorithm >::
129 TNode fpa::Base::RegionGrow< _TAlgorithm >::
132 TNode n = this->m_Queue.front( );
133 this->m_Queue.pop_front( );
137 // -------------------------------------------------------------------------
138 template< class _TAlgorithm >
139 void fpa::Base::RegionGrow< _TAlgorithm >::
140 _QueuePush( const TNode& node )
142 this->m_Queue.push_back( node );
145 // -------------------------------------------------------------------------
146 template< class _TAlgorithm >
147 unsigned long fpa::Base::RegionGrow< _TAlgorithm >::
150 return( this->m_Queue.size( ) );
153 #endif // __fpa__Base__RegionGrow__hxx__