]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Filters/RegionGrow.hxx
...
[FrontAlgorithms.git] / lib / fpa / Filters / RegionGrow.hxx
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __fpa__Filters__RegionGrow__hxx__
6 #define __fpa__Filters__RegionGrow__hxx__
7
8 #include <limits>
9 #include <fpa/Functors/RegionGrow/Tautology.h>
10
11 // -------------------------------------------------------------------------
12 template< class _TDataInterface >
13 void fpa::Filters::RegionGrow< _TDataInterface >::
14 SetPredicate( TScalarPredicate* p )
15 {
16   if( this->m_ScalarPredicate.GetPointer( ) != p )
17   {
18     this->_Deassociate( this->m_ScalarPredicate );
19     this->m_ScalarPredicate = p;
20     this->_Associate( this->m_ScalarPredicate );
21     this->Modified( );
22
23   } // fi
24 }
25
26 // -------------------------------------------------------------------------
27 template< class _TDataInterface >
28 void fpa::Filters::RegionGrow< _TDataInterface >::
29 SetPredicate( TVertexPredicate* p )
30 {
31   if( this->m_VertexPredicate.GetPointer( ) != p )
32   {
33     this->_Deassociate( this->m_VertexPredicate );
34     this->m_VertexPredicate = p;
35     this->_Associate( this->m_VertexPredicate );
36     this->Modified( );
37
38   } // fi
39 }
40
41 // -------------------------------------------------------------------------
42 template< class _TDataInterface >
43 typename fpa::Filters::RegionGrow< _TDataInterface >::
44 TOutputValue fpa::Filters::RegionGrow< _TDataInterface >::
45 GetOutsideValue( ) const
46 {
47   return( this->GetInitValue( ) );
48 }
49
50 // -------------------------------------------------------------------------
51 template< class _TDataInterface >
52 void fpa::Filters::RegionGrow< _TDataInterface >::
53 SetOutsideValue( const TOutputValue& v )
54 {
55   this->SetInitValue( v );
56 }
57
58 // -------------------------------------------------------------------------
59 template< class _TDataInterface >
60 fpa::Filters::RegionGrow< _TDataInterface >::
61 RegionGrow( )
62   : Superclass( false )
63 {
64   this->SetOutsideValue( TOutputValue( 0 ) );
65   this->m_InsideValue = std::numeric_limits< TOutputValue >::max( );
66   this->SetPredicate(
67     fpa::Functors::RegionGrow::Tautology< TInputValue >::New( )
68     );
69 }
70
71 // -------------------------------------------------------------------------
72 template< class _TDataInterface >
73 fpa::Filters::RegionGrow< _TDataInterface >::
74 ~RegionGrow( )
75 {
76 }
77
78 // -------------------------------------------------------------------------
79 template< class _TDataInterface >
80 void fpa::Filters::RegionGrow< _TDataInterface >::
81 _PostComputeOutputValue( TNode& n )
82 {
83   TInputValue value = this->_GetInputValue( n.Vertex );
84   bool inside = false;
85   if( this->m_ScalarPredicate.IsNotNull( ) )
86     inside = this->m_ScalarPredicate->Evaluate( value );
87   if( this->m_VertexPredicate.IsNotNull( ) )
88     inside &= this->m_VertexPredicate->Evaluate( n.Vertex, n.Parent );
89   if( !inside )
90   {
91     n.Value = this->GetOutsideValue( );
92     n.FrontId = 0;
93   }
94   else
95     n.Value = this->GetInsideValue( );
96 }
97
98 // -------------------------------------------------------------------------
99 template< class _TDataInterface >
100 void fpa::Filters::RegionGrow< _TDataInterface >::
101 _PreComputeOutputValue( TNode& n )
102 {
103   // Nothing to do with this algorithm
104 }
105
106 #endif // __fpa__Filters__RegionGrow__hxx__
107 // eof - $RCSfile$