]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Algorithm.h
Major refactoring
[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
36     protected:
37       typedef typename Superclass::_TVertices      _TVertices;
38       typedef typename Superclass::_TCollision     _TCollision;
39       typedef typename Superclass::_TCollisionsRow _TCollisionsRow;
40       typedef typename Superclass::_TCollisions    _TCollisions;
41       typedef typename Superclass::_TNode          _TNode;
42       typedef typename Superclass::_TNodes         _TNodes;
43
44       typedef itk::Image< _TNode, I::ImageDimension > _TMarks;
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( );
58
59       // Graph-related abstract methods
60       virtual unsigned long _NumberOfVertices( ) const;
61       virtual const TValue& _VertexValue( const TVertex& v ) const;
62       virtual double _Distance(
63         const TVertex& a, const TVertex& b
64         ) const;
65       virtual bool _HasEdge( const TVertex& a, const TVertex& b ) const;
66       virtual void _Neighborhood(
67         _TVertices& neighborhood, const TVertex& v
68         ) const;
69
70       // Results-related abstract methods
71       virtual void _InitResults( );
72       virtual const TResult& _Result( const TVertex& v ) const;
73       virtual void _SetResult( const TVertex& v, const TResult& r );
74
75       // Marks-related abstract methods
76       virtual const _TNode& _Node( const TVertex& v ) const;
77       virtual void _InitMarks( );
78       virtual void _Mark( const _TNode& node );
79
80     private:
81       // Purposely not implemented
82       Algorithm( const Self& other );
83       Self& operator=( const Self& other );
84
85     protected:
86       unsigned int m_NeighborhoodOrder;
87       typename _TMarks::Pointer m_Marks;
88     };
89
90   } // ecapseman
91
92 } // ecapseman
93
94 #include <fpa/Image/Algorithm.hxx>
95
96 #endif // __FPA__IMAGE__ALGORITHM__H__
97
98 // eof - $RCSfile$