]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/RegionGrow.h
Almost there...
[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
8 namespace fpa
9 {
10   namespace Base
11   {
12     /**
13      * Region grow is a front propagation with no costs.
14      *
15      * @param V  Vertex type.
16      * @param C  Vertex value type.
17      * @param R  Result value type.
18      * @param VC Vertex lexicographical compare.
19      * @param B  Base class for this algorithm. It should be any itk-based
20      *           filter (itk::ProcessObject).
21      *
22      */
23     template< class V, class C, class R, class VC, class B >
24     class RegionGrow
25       : public Algorithm< V, C, R, VC, B >
26     {
27     public:
28       typedef RegionGrow                       Self;
29       typedef Algorithm< V, C, R, VC, B >      Superclass;
30       typedef itk::SmartPointer< Self >        Pointer;
31       typedef itk::SmartPointer< const Self >  ConstPointer;
32
33       typedef typename Superclass::TVertex        TVertex;
34       typedef typename Superclass::TValue         TValue;
35       typedef typename Superclass::TResult        TResult;
36       typedef typename Superclass::TVertexCompare TVertexCompare;
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       typedef std::queue< std::pair< TVertex, _TNode > > _TQueue;
47
48     public:
49       itkTypeMacro( RegionGrow, Algorithm );
50
51       itkGetConstMacro( InsideValue, TResult );
52       itkGetConstMacro( OutsideValue, TResult );
53
54       itkSetMacro( InsideValue, TResult );
55       itkSetMacro( OutsideValue, TResult );
56
57     protected:
58       RegionGrow( );
59       virtual ~RegionGrow( );
60
61       virtual bool _CheckMembership( const TVertex& v ) const = 0;
62
63       // Results-related abstract methods
64       virtual bool _ComputeNeighborResult(
65         TResult& result, const TVertex& neighbor, const TVertex& parent
66         ) const;
67
68       // Queue-related abstract methods
69       virtual bool _IsQueueEmpty( ) const;
70       virtual void _QueuePush( const TVertex& v, const _TNode& n );
71       virtual void _QueuePop( TVertex& v, _TNode& n );
72       virtual void _QueueClear( );
73
74     private:
75       // Purposely not implemented
76       RegionGrow( const Self& other );
77       Self& operator=( const Self& other );
78
79     protected:
80       TResult m_InsideValue;
81       TResult m_OutsideValue;
82       _TQueue m_Queue;
83     };
84
85   } // ecapseman
86
87 } // ecapseman
88
89 #include <fpa/Base/RegionGrow.hxx>
90
91 #endif // __FPA__BASE__REGIONGROW__H__
92
93 // eof - $RCSfile$