]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Algorithm.h
I/O classes added
[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::TVertexCompare       TVertexCompare;
36       typedef typename Superclass::TMinimumSpanningTree TMinimumSpanningTree;
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( );
58       virtual void _AfterGenerateData( );
59
60       // Graph-related abstract methods
61       virtual unsigned long _NumberOfVertices( ) const;
62       virtual const TValue& _VertexValue( const TVertex& v ) const;
63       virtual double _Distance(
64         const TVertex& a, const TVertex& b
65         ) const;
66       virtual bool _HasEdge( const TVertex& a, const TVertex& b ) const;
67       virtual void _Neighborhood(
68         _TVertices& neighborhood, const TVertex& v
69         ) const;
70
71       // Results-related abstract methods
72       virtual void _InitResults( );
73       virtual const TResult& _Result( const TVertex& v ) const;
74       virtual void _SetResult( const TVertex& v, const _TNode& n );
75
76     private:
77       // Purposely not implemented
78       Algorithm( const Self& other );
79       Self& operator=( const Self& other );
80
81     protected:
82       unsigned int m_NeighborhoodOrder;
83     };
84
85   } // ecapseman
86
87 } // ecapseman
88
89 #include <fpa/Image/Algorithm.hxx>
90
91 #endif // __FPA__IMAGE__ALGORITHM__H__
92
93 // eof - $RCSfile$