]> Creatis software - FrontAlgorithms.git/blob - libs/fpa/Image/Dijkstra.h
...
[FrontAlgorithms.git] / libs / fpa / Image / Dijkstra.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Image__Dijkstra__h__
7 #define __fpa__Image__Dijkstra__h__
8
9 #include <fpa/Base/Dijkstra.h>
10 #include <fpa/Base/SeedsInterface.h>
11 #include <fpa/Image/MarksInterface.h>
12 #include <fpa/Image/Filter.h>
13 #include <fpa/Image/MinimumSpanningTree.h>
14 #include <fpa/Image/Functors/VertexParentBase.h>
15
16 namespace fpa
17 {
18   namespace Image
19   {
20     /**
21      */
22     template< class _TInputImage, class _TOutputImage >
23     class Dijkstra
24       : public fpa::Base::Dijkstra< fpa::Image::Filter< _TInputImage, _TOutputImage >, fpa::Image::MarksInterface< _TInputImage::ImageDimension >, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare >, fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > >
25     {
26     public:
27       // Interfaces
28       typedef fpa::Image::Filter< _TInputImage, _TOutputImage > TFilter;
29       typedef fpa::Image::MarksInterface< _TInputImage::ImageDimension > TMarksInterface;
30       typedef fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare > TSeedsInterface;
31       typedef fpa::Image::MinimumSpanningTree< _TInputImage::ImageDimension > TMST;
32
33       // Smart pointers
34       typedef Dijkstra Self;
35       typedef fpa::Base::Dijkstra< TFilter, TMarksInterface, TSeedsInterface, TMST > Superclass;
36       typedef itk::SmartPointer< Self > Pointer;
37       typedef itk::SmartPointer< const Self > ConstPointer;
38
39       typedef typename TFilter::TInputImage TInputImage;
40       typedef typename TFilter::TOutputValue TOutputValue;
41       typedef typename TFilter::TVertex TVertex;
42
43     public:
44       itkNewMacro( Self );
45       itkTypeMacro( fpa::Image::Dijkstra, fpa::Base::Dijkstra );
46
47     protected:
48       Dijkstra( ) : Superclass( ) { }
49       virtual ~Dijkstra( )        { }
50
51       virtual void _ConfigureOutputs( const TOutputValue& init_value ) override
52         {
53           this->Superclass::_ConfigureOutputs( init_value );
54
55           typename TVertex::OffsetType o;
56           o.Fill( 0 );
57           const TInputImage* input = this->GetInput( );
58           TMST* mst = this->GetMinimumSpanningTree( );
59           mst->CopyInformation( input );
60           mst->SetBufferedRegion( input->GetRequestedRegion( ) );
61           mst->Allocate( );
62           mst->FillBuffer( o );
63         }
64
65       virtual void GenerateData( ) override
66         {
67           // Configure functors with input image
68           typedef typename TFilter::TInputImage  _TInputIage;
69           typedef typename TFilter::TOutputValue _TOutputValue;
70           typedef fpa::Image::Functors::VertexParentBase< _TInputImage, _TOutputValue > _TVFunc;
71           _TVFunc* vfunc =
72             dynamic_cast< _TVFunc* >( this->m_VertexFunctor.GetPointer( ) );
73           if( vfunc != NULL )
74             vfunc->SetImage( this->GetInput( ) );
75
76           // Ok, continue
77           this->Superclass::GenerateData( );
78         }
79
80     private:
81       Dijkstra( const Self& other );
82       Self& operator=( const Self& other );
83     };
84
85   } // ecapseman
86
87 } // ecapseman
88
89 #endif // __fpa__Image__Dijkstra__h__
90
91 // eof - $RCSfile$