]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/RegionGrow.hxx
...
[FrontAlgorithms.git] / lib / fpa / Base / RegionGrow.hxx
1 #ifndef __fpa__Base__RegionGrow__hxx__
2 #define __fpa__Base__RegionGrow__hxx__
3
4 #include <fpa/Base/Functors/RegionGrow/Tautology.h>
5
6 // -------------------------------------------------------------------------
7 template< class _TSuperclass >
8 typename fpa::Base::RegionGrow< _TSuperclass >::
9 TGrowFunction* fpa::Base::RegionGrow< _TSuperclass >::
10 GetGrowFunction( )
11 {
12   // TODO: return( dynamic_cast< TGrowFunction* >( this->GetVertexFunction( ) ) );
13   return( this->m_GrowFunction );
14 }
15
16 // -------------------------------------------------------------------------
17 template< class _TSuperclass >
18 const typename fpa::Base::RegionGrow< _TSuperclass >::
19 TGrowFunction* fpa::Base::RegionGrow< _TSuperclass >::
20 GetGrowFunction( ) const
21 {
22   /* TODO
23      return(
24      dynamic_cast< const TGrowFunction* >( this->GetVertexFunction( ) )
25      );
26   */
27   return( this->m_GrowFunction );
28 }
29
30 // -------------------------------------------------------------------------
31 template< class _TSuperclass >
32 typename fpa::Base::RegionGrow< _TSuperclass >::
33 TOutput fpa::Base::RegionGrow< _TSuperclass >::
34 GetInsideValue( ) const
35 {
36   const TGrowFunction* f = this->GetGrowFunction( );
37   if( f != NULL )
38     return( f->GetInsideValue( ) );
39   else
40     return( this->m_InitResult );
41 }
42
43 // -------------------------------------------------------------------------
44 template< class _TSuperclass >
45 typename fpa::Base::RegionGrow< _TSuperclass >::
46 TOutput fpa::Base::RegionGrow< _TSuperclass >::
47 GetOutsideValue( ) const
48 {
49   const TGrowFunction* f = this->GetGrowFunction( );
50   if( f != NULL )
51     return( f->GetOutsideValue( ) );
52   else
53     return( this->m_InitResult );
54 }
55
56 // -------------------------------------------------------------------------
57 template< class _TSuperclass >
58 void fpa::Base::RegionGrow< _TSuperclass >::
59 SetGrowFunction( TGrowFunction* f )
60 {
61   TGrowFunction* old_f = this->GetGrowFunction( );
62   if( old_f != NULL )
63   {
64     f->SetInsideValue( old_f->GetInsideValue( ) );
65     f->SetOutsideValue( old_f->GetOutsideValue( ) );
66
67   } // fi
68   this->m_GrowFunction = f;
69 }
70
71 // -------------------------------------------------------------------------
72 template< class _TSuperclass >
73 void fpa::Base::RegionGrow< _TSuperclass >::
74 SetInsideValue( const TOutput& v )
75 {
76   TGrowFunction* f = this->GetGrowFunction( );
77   if( f != NULL )
78   {
79     f->SetInsideValue( v );
80     this->Modified( );
81
82   } // fi
83 }
84
85 // -------------------------------------------------------------------------
86 template< class _TSuperclass >
87 void fpa::Base::RegionGrow< _TSuperclass >::
88 SetOutsideValue( const TOutput& v )
89 {
90   TGrowFunction* f = this->GetGrowFunction( );
91   if( f != NULL )
92   {
93     f->SetOutsideValue( v );
94     this->Modified( );
95
96   } // fi
97 }
98
99 // -------------------------------------------------------------------------
100 template< class _TSuperclass >
101 fpa::Base::RegionGrow< _TSuperclass >::
102 RegionGrow( )
103   : Superclass( )
104 {
105   typedef fpa::Base::Functors::RegionGrow::Tautology< TVertex, TOutput > _TFunc;
106   this->SetGrowFunction( _TFunc::New( ) );
107   this->m_InitResult = this->GetGrowFunction( )->GetOutsideValue( );
108 }
109
110 // -------------------------------------------------------------------------
111 template< class _TSuperclass >
112 fpa::Base::RegionGrow< _TSuperclass >::
113 ~RegionGrow( )
114 {
115 }
116
117 // -------------------------------------------------------------------------
118 template< class _TSuperclass >
119 bool fpa::Base::RegionGrow< _TSuperclass >::
120 _UpdateValue( _TQueueNode& v, const _TQueueNode& p )
121 {
122   v.Result = this->_GetInputValue( v, p );
123   return( v.Result == this->GetInsideValue( ) );
124 }
125
126 #endif // __fpa__Base__RegionGrow__hxx__
127
128 // eof - $RCSfile$