]> 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 // -------------------------------------------------------------------------
9 template< class _TTraits >
10 void fpa::Filters::RegionGrow< _TTraits >::
11 SetPredicate( TScalarPredicate* p )
12 {
13   if( this->m_ScalarPredicate.GetPointer( ) != p )
14   {
15     this->_Deassociate( this->m_ScalarPredicate );
16     this->m_ScalarPredicate = p;
17     this->_Associate( this->m_ScalarPredicate );
18     this->Modified( );
19
20   } // fi
21 }
22
23 // -------------------------------------------------------------------------
24 template< class _TTraits >
25 void fpa::Filters::RegionGrow< _TTraits >::
26 SetPredicate( TVertexPredicate* p )
27 {
28   if( this->m_VertexPredicate.GetPointer( ) != p )
29   {
30     this->_Deassociate( this->m_VertexPredicate );
31     this->m_VertexPredicate = p;
32     this->_Associate( this->m_VertexPredicate );
33     this->Modified( );
34
35   } // fi
36 }
37
38 // -------------------------------------------------------------------------
39 template< class _TTraits >
40 typename fpa::Filters::RegionGrow< _TTraits >::
41 TOutputValue fpa::Filters::RegionGrow< _TTraits >::
42 GetOutsideValue( ) const
43 {
44   return( this->GetInitValue( ) );
45 }
46
47 // -------------------------------------------------------------------------
48 template< class _TTraits >
49 void fpa::Filters::RegionGrow< _TTraits >::
50 SetOutsideValue( const TOutputValue& v )
51 {
52   this->SetInitValue( v );
53 }
54
55 // -------------------------------------------------------------------------
56 template< class _TTraits >
57 fpa::Filters::RegionGrow< _TTraits >::
58 RegionGrow( )
59   : Superclass( ),
60     m_InsideValue( TOutputValue( 1 ) )
61 {
62   this->SetOutsideValue( 0 );
63 }
64
65 // -------------------------------------------------------------------------
66 template< class _TTraits >
67 fpa::Filters::RegionGrow< _TTraits >::
68 ~RegionGrow( )
69 {
70 }
71
72 // -------------------------------------------------------------------------
73 template< class _TTraits >
74 void fpa::Filters::RegionGrow< _TTraits >::
75 _UpdateOutputValue( TNode& n )
76 {
77   TInputValue value = this->_GetInputValue( n );
78   bool inside = false;
79   if( this->m_ScalarPredicate.IsNotNull( ) )
80     inside = this->m_ScalarPredicate->Evaluate( value );
81   if( this->m_VertexPredicate.IsNotNull( ) )
82     inside &= this->m_VertexPredicate->Evaluate( n.Vertex, n.Parent );
83   if( !inside )
84   {
85     n.Value = this->GetOutsideValue( );
86     n.FrontId = 0;
87   }
88   else
89     n.Value = this->GetInsideValue( );
90 }
91
92 // -------------------------------------------------------------------------
93 template< class _TTraits >
94 void fpa::Filters::RegionGrow< _TTraits >::
95 _QueueClear( )
96 {
97   this->m_Queue.clear( );
98 }
99
100 // -------------------------------------------------------------------------
101 template< class _TTraits >
102 typename fpa::Filters::RegionGrow< _TTraits >::
103 TNode fpa::Filters::RegionGrow< _TTraits >::
104 _QueuePop( )
105 {
106   TNode n = this->m_Queue.front( );
107   this->m_Queue.pop_front( );
108   return( n );
109 }
110
111 // -------------------------------------------------------------------------
112 template< class _TTraits >
113 void fpa::Filters::RegionGrow< _TTraits >::
114 _QueuePush( const TNode& n )
115 {
116   this->m_Queue.push_back( n );
117 }
118
119 // -------------------------------------------------------------------------
120 template< class _TTraits >
121 unsigned long fpa::Filters::RegionGrow< _TTraits >::
122 _QueueSize( ) const
123 {
124   return( this->m_Queue.size( ) );
125 }
126
127 // -------------------------------------------------------------------------
128 template< class _TTraits >
129 void fpa::Filters::RegionGrow< _TTraits >::
130 _ComputeOutputValue( TNode& n )
131 {
132   // Do nothing
133 }
134
135 #endif // __fpa__Filters__RegionGrow__hxx__
136 // eof - $RCSfile$