]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Algorithm.h
2fd40bc1c242cef832e920189a844a63263a43dc
[FrontAlgorithms.git] / lib / fpa / Image / Algorithm.h
1 #ifndef __FPA__IMAGE__ALGORITHM__H__
2 #define __FPA__IMAGE__ALGORITHM__H__
3
4 #include <fpa/Base/Algorithm.h>
5 #include <itkImage.h>
6 #include <itkImageToImageFilter.h>
7
8 namespace fpa
9 {
10   namespace Image
11   {
12     /**
13      */
14     template< class _TInputImage, class _TOutputImage >
15     class Algorithm
16       : public fpa::Base::Algorithm< typename _TInputImage::IndexType, typename _TOutputImage::PixelType, itk::ImageToImageFilter< _TInputImage, _TOutputImage >, typename _TInputImage::IndexType::LexicographicCompare >
17     {
18     public:
19       typedef fpa::Base::Algorithm< typename _TInputImage::IndexType, typename _TOutputImage::PixelType, itk::ImageToImageFilter< _TInputImage, _TOutputImage >, typename _TInputImage::IndexType::LexicographicCompare > Superclass;
20       typedef Algorithm                       Self;
21       typedef itk::SmartPointer< Self >       Pointer;
22       typedef itk::SmartPointer< const Self > ConstPointer;
23
24       // Input types
25       typedef _TInputImage  TInputImage;
26       typedef _TOutputImage TOutputImage;
27       itkConceptMacro(
28         ImagesSameDimension,
29         (
30           itk::Concept::
31           SameDimension<
32           TInputImage::ImageDimension,
33           TOutputImage::ImageDimension
34           >
35           )
36         );
37
38       // Template arguments
39       typedef typename Superclass::TVertex        TVertex;
40       typedef typename Superclass::TScalar        TScalar;
41       typedef typename Superclass::TFilter        TFilter;
42       typedef typename Superclass::TVertexCompare TVertexCompare;
43       typedef typename Superclass::TFrontId       TFrontId;
44       typedef typename Superclass::TCollision     TCollision;
45       typedef typename Superclass::TCollisionsRow TCollisionsRow;
46       typedef typename Superclass::TCollisions    TCollisions;
47       typedef typename Superclass::TNodeLabel     TNodeLabel;
48       typedef typename Superclass::TNode          TNode;
49       typedef typename Superclass::TNodes         TNodes;
50       typedef typename Superclass::TVertices      TVertices;
51
52       typedef itk::Image< TFrontId, TInputImage::ImageDimension > TMarkImage;
53
54     public:
55       itkTypeMacro( Algorithm, _TFilter );
56
57       itkGetConstMacro( NeighborhoodOrder, unsigned short );
58       itkSetMacro( NeighborhoodOrder, unsigned short );
59
60     protected:
61       // Methods to extend itk-imaged architecture
62       Algorithm( );
63       virtual ~Algorithm( );
64
65       // Front propagation methods to be overloaded
66       virtual void _BeforeGenerateData( ) fpa_OVERRIDE;
67       virtual void _InitMarks( ) fpa_OVERRIDE;
68       virtual void _InitResults( ) fpa_OVERRIDE;
69       virtual void _DeallocateAuxiliary( ) fpa_OVERRIDE;
70       virtual TFrontId _GetMark( const TVertex& v ) fpa_OVERRIDE;
71       virtual void _Visit( const TNode& n ) fpa_OVERRIDE;
72       virtual TVertices _GetNeighborhood(
73         const TVertex& v
74         ) const fpa_OVERRIDE;
75
76     private:
77       // Purposely not implemented
78       Algorithm( const Self& other );
79       Self& operator=( const Self& other );
80
81     protected:
82       unsigned short m_NeighborhoodOrder;
83       typename TMarkImage::Pointer m_Marks;
84     };
85
86   } // ecapseman
87
88 } // ecapseman
89
90 #ifndef ITK_MANUAL_INSTANTIATION
91 #  include <fpa/Image/Algorithm.hxx>
92 #endif
93
94 #endif // __FPA__IMAGE__ALGORITHM__H__
95
96 // eof - $RCSfile$