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