]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/RegionGrow.h
...
[FrontAlgorithms.git] / lib / fpa / Base / RegionGrow.h
1 #ifndef __FPA__BASE__REGIONGROW__H__
2 #define __FPA__BASE__REGIONGROW__H__
3
4 #include <queue>
5 #include <utility>
6 #include <fpa/Base/Algorithm.h>
7 #include <fpa/Base/Functors/TautologyFunction.h>
8
9 namespace fpa
10 {
11   namespace Base
12   {
13     /**
14      * Region grow is a front propagation with no costs.
15      *
16      * @param V  Vertex type.
17      * @param C  Vertex value type.
18      * @param R  Result value type.
19      * @param S  Space type where vertices are.
20      * @param VC Vertex lexicographical compare.
21      * @param B  Base class for this algorithm. It should be any itk-based
22      *           filter (itk::ProcessObject).
23      *
24      */
25     template< class V, class C, class R, class S, class VC, class B >
26     class RegionGrow
27       : public Algorithm< V, C, R, S, VC, B >
28     {
29     public:
30       typedef RegionGrow                       Self;
31       typedef Algorithm< V, C, R, S, VC, B >   Superclass;
32       typedef itk::SmartPointer< Self >        Pointer;
33       typedef itk::SmartPointer< const Self >  ConstPointer;
34
35       typedef typename Superclass::TVertex        TVertex;
36       typedef typename Superclass::TValue         TValue;
37       typedef typename Superclass::TResult        TResult;
38       typedef typename Superclass::TSpace         TSpace;
39       typedef typename Superclass::TVertexCompare TVertexCompare;
40
41       typedef fpa::Base::Functors::TautologyFunction< S, V > TGrowingFunction;
42
43     protected:
44       typedef typename Superclass::_TVertices      _TVertices;
45       typedef typename Superclass::_TCollision     _TCollision;
46       typedef typename Superclass::_TCollisionsRow _TCollisionsRow;
47       typedef typename Superclass::_TCollisions    _TCollisions;
48       typedef typename Superclass::_TNode          _TNode;
49       typedef typename Superclass::_TNodes         _TNodes;
50
51       typedef std::queue< std::pair< TVertex, _TNode > > _TQueue;
52
53     public:
54       itkTypeMacro( RegionGrow, Algorithm );
55
56       itkGetConstMacro( InsideValue, TResult );
57       itkGetConstMacro( OutsideValue, TResult );
58       itkGetObjectMacro( GrowingFunction, TGrowingFunction );
59       itkGetConstObjectMacro( GrowingFunction, TGrowingFunction );
60
61       itkSetMacro( InsideValue, TResult );
62       itkSetMacro( OutsideValue, TResult );
63       itkSetObjectMacro( GrowingFunction, TGrowingFunction );
64
65     protected:
66       RegionGrow( );
67       virtual ~RegionGrow( );
68
69       virtual bool _CheckMembership( const TVertex& v ) const;
70
71       // Results-related abstract methods
72       virtual bool _ComputeNeighborResult(
73         TResult& result, const TVertex& neighbor, const TVertex& parent
74         ) const ITK_OVERRIDE;
75
76       // Queue-related abstract methods
77       virtual bool _IsQueueEmpty( ) const ITK_OVERRIDE;
78       virtual void _QueuePush( const TVertex& v, const _TNode& n ) ITK_OVERRIDE;
79       virtual void _QueuePop( TVertex& v, _TNode& n ) ITK_OVERRIDE;
80       virtual void _QueueClear( ) ITK_OVERRIDE;
81
82     private:
83       // Purposely not implemented
84       RegionGrow( const Self& other );
85       Self& operator=( const Self& other );
86
87     protected:
88       TResult m_InsideValue;
89       TResult m_OutsideValue;
90       _TQueue m_Queue;
91
92       typename TGrowingFunction::Pointer m_GrowingFunction;
93     };
94
95   } // ecapseman
96
97 } // ecapseman
98
99 #ifndef ITK_MANUAL_INSTANTIATION
100 #include <fpa/Base/RegionGrow.hxx>
101 #endif // ITK_MANUAL_INSTANTIATION
102
103 #endif // __FPA__BASE__REGIONGROW__H__
104
105 // eof - $RCSfile$