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