]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Filters/SingleSeedInterface.hxx
c82b6b45aee863f741100c45353797359b0fa94e
[FrontAlgorithms.git] / lib / fpa / Filters / SingleSeedInterface.hxx
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __fpa__Filters__SingleSeedInterface__hxx__
6 #define __fpa__Filters__SingleSeedInterface__hxx__
7
8 // -------------------------------------------------------------------------
9 template< class _TTraits >
10 fpa::Filters::SingleSeedInterface< _TTraits >::
11 SingleSeedInterface( itk::ProcessObject* f )
12   : m_Filter( f )
13 {
14 }
15
16 // -------------------------------------------------------------------------
17 template< class _TTraits >
18 fpa::Filters::SingleSeedInterface< _TTraits >::
19 ~SingleSeedInterface( )
20 {
21 }
22
23 // -------------------------------------------------------------------------
24 template< class _TTraits >
25 void fpa::Filters::SingleSeedInterface< _TTraits >::
26 SetSeed( const TPoint& s )
27 {
28   this->m_InputSeed.Point = s;
29   this->m_InputSeed.IsPoint = true;
30   if( this->m_Filter.IsNotNull( ) )
31     this->m_Filter->Modified( );
32 }
33
34 // -------------------------------------------------------------------------
35 template< class _TTraits >
36 void fpa::Filters::SingleSeedInterface< _TTraits >::
37 SetSeed( const TVertex& s )
38 {
39   this->m_InputSeed.Vertex = s;
40   this->m_InputSeed.IsPoint = false;
41   if( this->m_Filter.IsNotNull( ) )
42     this->m_Filter->Modified( );
43 }
44
45 // -------------------------------------------------------------------------
46 template< class _TTraits >
47 const typename fpa::Filters::SingleSeedInterface< _TTraits >::
48 TNodes& fpa::Filters::SingleSeedInterface< _TTraits >::
49 GetSeeds( ) const
50 {
51   return( this->m_UnifiedSeed );
52 }
53
54 // -------------------------------------------------------------------------
55 template< class _TTraits >
56 void fpa::Filters::SingleSeedInterface< _TTraits >::
57 _PrepareSeeds( const itk::DataObject* input )
58 {
59   // Input object is an image?
60   typedef itk::ImageBase< Self::Dimension > _TImageBase;
61   const _TImageBase* image = dynamic_cast< const _TImageBase* >( input );
62   if( image != NULL )
63   {
64     this->m_UnifiedSeed.clear( );
65     TSeed iSeed = this->m_InputSeed;
66     if( iSeed.IsPoint )
67       image->TransformPhysicalPointToIndex( iSeed.Point, iSeed.Vertex );
68     TNode node;
69     node.Vertex = iSeed.Vertex;
70     node.Parent = iSeed.Vertex;
71     node.FrontId = iSeed.FrontId;
72     this->m_UnifiedSeed.insert( node );
73
74   } // fi
75 }
76
77 #endif // __fpa__Filters__SingleSeedInterface__hxx__
78 // eof - $RCSfile$