]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Dijkstra.h
7ff59081345767d8badac5218e47ab850f787a92
[FrontAlgorithms.git] / lib / fpa / Image / Dijkstra.h
1 #ifndef __FPA__IMAGE__DIJKSTRA__H__
2 #define __FPA__IMAGE__DIJKSTRA__H__
3
4 #include <itkFunctionBase.h>
5 #include <itkImageToImageFilter.h>
6 #include <fpa/Base/Dijkstra.h>
7 #include <fpa/Image/Algorithm.h>
8 #include <fpa/Image/MinimumSpanningTree.h>
9 #include <fpa/Image/Functors/ImageCostFunction.h>
10
11 namespace fpa
12 {
13   namespace Image
14   {
15     /**
16      * @param I Input image type
17      * @param O Output image type
18      */
19     template< class I, class O = I >
20     class Dijkstra
21       : public Algorithm< I, O, fpa::Base::Dijkstra< typename I::IndexType, typename I::PixelType, typename O::PixelType, I, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, fpa::Image::MinimumSpanningTree< I::ImageDimension >, itk::ImageToImageFilter< I, O > > >
22     {
23     public:
24       typedef fpa::Base::Dijkstra< typename I::IndexType, typename I::PixelType, typename O::PixelType, I, itk::Functor::IndexLexicographicCompare< I::ImageDimension >, fpa::Image::MinimumSpanningTree< I::ImageDimension >, itk::ImageToImageFilter< I, O > > TBaseAlgorithm;
25       typedef Dijkstra                          Self;
26       typedef Algorithm< I, O, TBaseAlgorithm > Superclass;
27       typedef itk::SmartPointer< Self >         Pointer;
28       typedef itk::SmartPointer< const Self >   ConstPointer;
29
30       typedef typename Superclass::TInputImage  TInputImage;
31       typedef typename Superclass::TOutputImage TOutputImage;
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
37       typedef typename Superclass::TStartEvent     TStartEvent;
38       typedef typename Superclass::TStartLoopEvent TStartLoopEvent;
39       typedef typename Superclass::TEndEvent       TEndEvent;
40       typedef typename Superclass::TEndLoopEvent   TEndLoopEvent;
41       typedef typename Superclass::TAliveEvent     TAliveEvent;
42       typedef typename Superclass::TFrontEvent     TFrontEvent;
43       typedef typename Superclass::TFreezeEvent    TFreezeEvent;
44
45       typedef typename Superclass::TStartBacktrackingEvent TStartBacktrackingEvent;
46       typedef typename Superclass::TEndBacktrackingEvent TEndBacktrackingEvent;
47       typedef typename Superclass::TBacktrackingEvent TBacktrackingEvent;
48
49       typedef typename TBaseAlgorithm::TMinimumSpanningTree TMinimumSpanningTree;
50
51       typedef fpa::Image::Functors::ImageCostFunction< TInputImage, TResult > TCostFunction;
52       typedef itk::FunctionBase< TResult, TResult > TConversionFunction;
53
54     protected:
55       typedef typename Superclass::_TVertices      _TVertices;
56       typedef typename Superclass::_TCollision     _TCollision;
57       typedef typename Superclass::_TCollisionsRow _TCollisionsRow;
58       typedef typename Superclass::_TCollisions    _TCollisions;
59       typedef typename Superclass::_TNode          _TNode;
60       typedef typename Superclass::_TNodes         _TNodes;
61
62     public:
63       itkNewMacro( Self );
64       itkTypeMacro( Dijkstra, Algorithm );
65
66       itkGetObjectMacro( CostFunction, TCostFunction );
67       itkGetObjectMacro( ConversionFunction, TConversionFunction );
68
69       itkGetConstObjectMacro( CostFunction, TCostFunction );
70       itkGetConstObjectMacro( ConversionFunction, TConversionFunction );
71
72       itkSetObjectMacro( CostFunction, TCostFunction );
73       itkSetObjectMacro( ConversionFunction, TConversionFunction );
74
75     protected:
76       Dijkstra( );
77       virtual ~Dijkstra( );
78
79       virtual TResult _Cost( const TVertex& v, const TVertex& p ) const;
80
81       virtual void _BeforeGenerateData( );
82       virtual void _AfterGenerateData( );
83       virtual void _InitResults( );
84
85     private:
86       // Purposely not implemented
87       Dijkstra( const Self& other );
88       Self& operator=( const Self& other );
89
90     protected:
91       typename TCostFunction::Pointer m_CostFunction;
92       typename TConversionFunction::Pointer m_ConversionFunction;
93     };
94
95   } // ecapseman
96
97 } // ecapseman
98
99 #ifndef ITK_MANUAL_INSTANTIATION
100 #include <fpa/Image/Dijkstra.hxx>
101 #endif // ITK_MANUAL_INSTANTIATION
102
103 #endif // __FPA__IMAGE__DIJKSTRA__H__
104
105 // eof - $RCSfile$