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