]> Creatis software - FrontAlgorithms.git/blob - libs/fpa/Image/MarksInterface.hxx
4d639acda2645f947a4883d2dff477c5e2a36858
[FrontAlgorithms.git] / libs / fpa / Image / MarksInterface.hxx
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Image__MarksInterface__hxx__
7 #define __fpa__Image__MarksInterface__hxx__
8
9 // -------------------------------------------------------------------------
10 template< unsigned int _VDim >
11 bool fpa::Image::MarksInterface< _VDim >::
12 _IsMarked( const TVertex& v ) const
13 {
14   return( this->m_Marks->GetPixel( v ) != 0 );
15 }
16
17 // -------------------------------------------------------------------------
18 template< unsigned int _VDim >
19 unsigned long fpa::Image::MarksInterface< _VDim >::
20 _GetMark( const TVertex& v ) const
21 {
22   return( this->m_Marks->GetPixel( v ) );
23 }
24
25 // -------------------------------------------------------------------------
26 template< unsigned int _VDim >
27 void fpa::Image::MarksInterface< _VDim >::
28 _Mark( const TVertex& v, unsigned long frontId )
29 {
30   this->m_Marks->SetPixel( v, frontId );
31 }
32
33 // -------------------------------------------------------------------------
34 template< unsigned int _VDim >
35 void fpa::Image::MarksInterface< _VDim >::
36 _FreeMarks( )
37 {
38   this->m_Marks = NULL;
39 }
40
41 // -------------------------------------------------------------------------
42 template< unsigned int _VDim >
43 void fpa::Image::MarksInterface< _VDim >::
44 _InitMarks( unsigned long nSeeds )
45 {
46   this->Superclass::_InitMarks( nSeeds );
47
48   // Try to guess input
49   if( this->m_Filter == NULL )
50     return;
51   if( this->m_Filter->GetInputs( ).size( ) == 0 )
52     return;
53   itk::ImageBase< _VDim >* input =
54     dynamic_cast< itk::ImageBase< _VDim >* >(
55       this->m_Filter->GetInputs( )[ 0 ].GetPointer( )
56       );
57   if( input == NULL )
58     return;
59
60   // Reserve memory for marks
61   this->m_Marks = TMarks::New( );
62   this->m_Marks->CopyInformation( input );
63   this->m_Marks->SetRequestedRegion( input->GetRequestedRegion( ) );
64   this->m_Marks->SetBufferedRegion( input->GetBufferedRegion( ) );
65   this->m_Marks->Allocate( );
66   this->m_Marks->FillBuffer( 0 );
67 }
68
69 // -------------------------------------------------------------------------
70 template< unsigned int _VDim >
71 fpa::Image::MarksInterface< _VDim >::
72 MarksInterface( itk::ProcessObject* filter )
73   : Superclass( filter )
74 {
75 }
76
77 // -------------------------------------------------------------------------
78 template< unsigned int _VDim >
79 fpa::Image::MarksInterface< _VDim >::
80 ~MarksInterface( )
81 {
82 }
83
84 #endif // __fpa__Image__MarksInterface__hxx__
85
86 // eof - $RCSfile$