1 #ifndef __fpa__Image__Algorithm__hxx__
2 #define __fpa__Image__Algorithm__hxx__
4 // Send Piotr's code to Anna
8 // -------------------------------------------------------------------------
9 template< class _TInputImage, class _TOutputImage >
10 fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
14 typedef itk::Image< TFrontId, _TInputImage::ImageDimension > _TMarks;
15 this->m_MarksIdx = this->GetNumberOfRequiredOutputs( );
16 this->itk::ProcessObject::SetNumberOfRequiredOutputs( this->m_MarksIdx + 1 );
17 typename _TMarks::Pointer marks = _TMarks::New( );
18 this->SetNthOutput( this->m_MarksIdx, marks );
21 // -------------------------------------------------------------------------
22 template< class _TInputImage, class _TOutputImage >
23 fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
28 // -------------------------------------------------------------------------
29 template< class _TInputImage, class _TOutputImage >
30 void fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
31 _BeforeGenerateData( )
33 this->Superclass::_BeforeGenerateData( );
34 this->AllocateOutputs( );
36 TNeighborhoodFunction* neighFunc =
37 dynamic_cast< TNeighborhoodFunction* >( this->GetNeighborhoodFunction( ) );
38 if( neighFunc == NULL )
39 itkExceptionMacro( << "NeighborhoodFunction not well defined." );
40 neighFunc->SetImage( this->GetInput( ) );
43 // -------------------------------------------------------------------------
44 template< class _TInputImage, class _TOutputImage >
45 void fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
48 typedef itk::Image< TFrontId, _TInputImage::ImageDimension > _TMarks;
50 dynamic_cast< _TMarks* >(
51 this->itk::ProcessObject::GetOutput( this->m_MarksIdx )
53 marks->FillBuffer( 0 );
56 // -------------------------------------------------------------------------
57 template< class _TInputImage, class _TOutputImage >
58 void fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
59 _InitResults( const TOutput& init_value )
61 this->GetOutput( )->FillBuffer( init_value );
64 // -------------------------------------------------------------------------
65 template< class _TInputImage, class _TOutputImage >
66 bool fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
67 _IsMarked( const TVertex& v ) const
69 typedef itk::Image< TFrontId, _TInputImage::ImageDimension > _TMarks;
70 const _TMarks* marks =
71 dynamic_cast< const _TMarks* >(
72 this->itk::ProcessObject::GetOutput( this->m_MarksIdx )
74 return( marks->GetPixel( v ) != 0 );
77 // -------------------------------------------------------------------------
78 template< class _TInputImage, class _TOutputImage >
79 void fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
80 _Mark( const _TQueueNode& n )
82 typedef itk::Image< TFrontId, _TInputImage::ImageDimension > _TMarks;
84 dynamic_cast< _TMarks* >(
85 this->itk::ProcessObject::GetOutput( this->m_MarksIdx )
87 marks->SetPixel( n.Vertex, n.FrontId );
90 // -------------------------------------------------------------------------
91 template< class _TInputImage, class _TOutputImage >
92 typename fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
93 TFrontId fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
94 _GetMark( const TVertex& v ) const
96 typedef itk::Image< TFrontId, _TInputImage::ImageDimension > _TMarks;
97 const _TMarks* marks =
98 dynamic_cast< const _TMarks* >(
99 this->itk::ProcessObject::GetOutput( this->m_MarksIdx )
101 return( marks->GetPixel( v ) );
104 // -------------------------------------------------------------------------
105 template< class _TInputImage, class _TOutputImage >
106 void fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
107 _UpdateResult( const _TQueueNode& n )
109 this->GetOutput( )->SetPixel( n.Vertex, n.Result );
112 #endif // __fpa__Image__Algorithm__hxx__