]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Algorithm.h
...
[FrontAlgorithms.git] / lib / fpa / Image / Algorithm.h
1 #ifndef __FPA__IMAGE__ALGORITHM__H__
2 #define __FPA__IMAGE__ALGORITHM__H__
3
4 #include <itkImage.h>
5
6 namespace fpa
7 {
8   namespace Image
9   {
10     /**
11      * A generic front propagation algorithm were vertices are image pixels.
12      *
13      * @param I Input image type
14      * @param O Output image type
15      * @param A Base algorithm (RegionGrow, Dijkstra or FastMarching)
16      */
17     template< class I, class O, class A >
18     class Algorithm
19       : public A
20     {
21     public:
22       /// Standard class typdedefs
23       typedef Algorithm                       Self;
24       typedef A                               Superclass;
25       typedef itk::SmartPointer< Self >       Pointer;
26       typedef itk::SmartPointer< const Self > ConstPointer;
27
28       /// Template input values
29       typedef I TInputImage;
30       typedef O TOutputImage;
31
32       typedef typename Superclass::TVertex        TVertex;
33       typedef typename Superclass::TValue         TValue;
34       typedef typename Superclass::TResult        TResult;
35       typedef typename Superclass::TSpace         TSpace;
36       typedef typename Superclass::TVertexCompare TVertexCompare;
37
38     protected:
39       typedef typename Superclass::_TVertices      _TVertices;
40       typedef typename Superclass::_TCollision     _TCollision;
41       typedef typename Superclass::_TCollisionsRow _TCollisionsRow;
42       typedef typename Superclass::_TCollisions    _TCollisions;
43       typedef typename Superclass::_TNode          _TNode;
44       typedef typename Superclass::_TNodes         _TNodes;
45
46     public:
47       itkTypeMacro( Algorithm, TAlgorithm );
48
49       /// Set/Get
50       itkGetConstMacro( NeighborhoodOrder, unsigned int );
51       itkSetMacro( NeighborhoodOrder, unsigned int );
52
53     protected:
54       Algorithm( );
55       virtual ~Algorithm( );
56
57       virtual void _BeforeGenerateData( ) ITK_OVERRIDE;
58
59       // Graph-related abstract methods
60       virtual unsigned long _NumberOfVertices( ) const ITK_OVERRIDE;
61       virtual const TValue& _VertexValue( const TVertex& v ) const ITK_OVERRIDE;
62       virtual double _Distance(
63         const TVertex& a, const TVertex& b
64         ) const ITK_OVERRIDE;
65       virtual bool _HasEdge( const TVertex& a, const TVertex& b ) const ITK_OVERRIDE;
66       virtual void _Neighborhood(
67         _TVertices& neighborhood, const TVertex& v
68         ) const ITK_OVERRIDE;
69
70       // Results-related abstract methods
71       virtual void _InitResults( ) ITK_OVERRIDE;
72       virtual const TResult& _Result( const TVertex& v ) const ITK_OVERRIDE;
73       virtual void _SetResult( const TVertex& v, const _TNode& n ) ITK_OVERRIDE;
74
75     private:
76       // Purposely not implemented
77       Algorithm( const Self& other );
78       Self& operator=( const Self& other );
79
80     protected:
81       unsigned int m_NeighborhoodOrder;
82     };
83
84   } // ecapseman
85
86 } // ecapseman
87
88 #ifndef ITK_MANUAL_INSTANTIATION
89 #include <fpa/Image/Algorithm.hxx>
90 #endif // ITK_MANUAL_INSTANTIATION
91
92 #endif // __FPA__IMAGE__ALGORITHM__H__
93
94 // eof - $RCSfile$