]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Algorithm.h
9a44146ddee238464b799a7faa236554273dedd5
[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       typedef typename Superclass::TMinimumSpanningTree TMinimumSpanningTree;
38
39     protected:
40       typedef typename Superclass::_TVertices      _TVertices;
41       typedef typename Superclass::_TCollision     _TCollision;
42       typedef typename Superclass::_TCollisionsRow _TCollisionsRow;
43       typedef typename Superclass::_TCollisions    _TCollisions;
44       typedef typename Superclass::_TNode          _TNode;
45       typedef typename Superclass::_TNodes         _TNodes;
46
47     public:
48       itkTypeMacro( Algorithm, TAlgorithm );
49
50       /// Set/Get
51       itkGetConstMacro( NeighborhoodOrder, unsigned int );
52       itkSetMacro( NeighborhoodOrder, unsigned int );
53
54     protected:
55       Algorithm( );
56       virtual ~Algorithm( );
57
58       virtual void _BeforeGenerateData( );
59       virtual void _AfterGenerateData( );
60
61       // Graph-related abstract methods
62       virtual unsigned long _NumberOfVertices( ) const;
63       virtual const TValue& _VertexValue( const TVertex& v ) const;
64       virtual double _Distance(
65         const TVertex& a, const TVertex& b
66         ) const;
67       virtual bool _HasEdge( const TVertex& a, const TVertex& b ) const;
68       virtual void _Neighborhood(
69         _TVertices& neighborhood, const TVertex& v
70         ) const;
71
72       // Results-related abstract methods
73       virtual void _InitResults( );
74       virtual const TResult& _Result( const TVertex& v ) const;
75       virtual void _SetResult( const TVertex& v, const _TNode& n );
76
77     private:
78       // Purposely not implemented
79       Algorithm( const Self& other );
80       Self& operator=( const Self& other );
81
82     protected:
83       unsigned int m_NeighborhoodOrder;
84     };
85
86   } // ecapseman
87
88 } // ecapseman
89
90 #include <fpa/Image/Algorithm.hxx>
91
92 #endif // __FPA__IMAGE__ALGORITHM__H__
93
94 // eof - $RCSfile$