]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Dijkstra.h
1df0836a985668ee3f0f526144b63d80f8e2d7f8
[FrontAlgorithms.git] / lib / 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::TOutputValue _TOutputValue;
69           typedef fpa::Image::Functors::VertexParentBase< _TInputImage, _TOutputValue > _TVFunc;
70           _TVFunc* vfunc =
71             dynamic_cast< _TVFunc* >( this->m_VertexFunctor.GetPointer( ) );
72           if( vfunc != NULL )
73             vfunc->SetImage( this->GetInput( ) );
74
75           // Ok, continue
76           this->Superclass::GenerateData( );
77         }
78
79     private:
80       Dijkstra( const Self& other );
81       Self& operator=( const Self& other );
82     };
83
84   } // ecapseman
85
86 } // ecapseman
87
88 #endif // __fpa__Image__Dijkstra__h__
89
90 // eof - $RCSfile$