]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/Algorithm.h
...
[FrontAlgorithms.git] / lib / fpa / Base / Algorithm.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Base__Algorithm__h__
7 #define __fpa__Base__Algorithm__h__
8
9 #include <fpa/Config.h>
10
11 #include <vector>
12 #include <itkObject.h>
13 #include <itkEventObject.h>
14
15 namespace fpa
16 {
17   namespace Base
18   {
19     /**
20      */
21     template< class _TFilter, class _TMarksInterface, class _TSeedsInterface >
22     class Algorithm
23       : public _TFilter,
24         public _TMarksInterface,
25         public _TSeedsInterface
26     {
27     public:
28       typedef Algorithm                       Self;
29       typedef _TFilter                        Superclass;
30       typedef _TMarksInterface                TMarksInterface;
31       typedef _TSeedsInterface                TSeedsInterface;
32       typedef itk::SmartPointer< Self >       Pointer;
33       typedef itk::SmartPointer< const Self > ConstPointer;
34
35       typedef typename _TSeedsInterface::TInputValue  TInputValue;
36       typedef typename _TSeedsInterface::TOutputValue TOutputValue;
37       typedef typename _TSeedsInterface::TNode        TNode;
38       typedef typename _TSeedsInterface::TNodes       TNodes;
39       typedef typename _TSeedsInterface::TSeeds       TSeeds;
40       typedef typename _TSeedsInterface::TVertex      TVertex;
41
42       typedef std::vector< TVertex > TNeighborhood;
43
44       /**
45        */
46       class TEvent
47         : public itk::EventObject
48       {
49       public:
50         typedef TEvent           Self;
51         typedef itk::EventObject Superclass;
52
53       public:
54         TEvent( );
55         TEvent( const TVertex& v, unsigned long fid, bool intoq );
56         virtual ~TEvent( );
57         virtual const char* GetEventName( ) const override;
58         virtual bool CheckEvent( const itk::EventObject* e ) const override;
59         virtual itk::EventObject* MakeObject( ) const override;
60
61       private:
62         // Purposely not implemented.
63         Self& operator=( const Self& other );
64
65       public:
66         TVertex       Vertex;
67         unsigned long FrontId;
68         bool          IntoQueue;
69       };
70
71     public:
72       itkTypeMacro( fpa::Base::Algorithm, _TFilter );
73
74       itkBooleanMacro( VisualDebug );
75
76       itkGetConstMacro( InitValue, TOutputValue );
77       itkGetConstMacro( VisualDebug, bool );
78
79       itkSetMacro( InitValue, TOutputValue );
80       itkSetMacro( VisualDebug, bool );
81
82     public:
83       virtual void InvokeEvent( const itk::EventObject& e );
84       virtual void InvokeEvent( const itk::EventObject& e ) const;
85
86     protected:
87       Algorithm( );
88       virtual ~Algorithm( );
89
90       virtual void GenerateData( ) override;
91       virtual void _BeforeGenerateData( );
92       virtual void _AfterGenerateData( );
93       virtual void _FinishOneLoop( );
94
95       virtual void _QueueInit( );
96
97       virtual void _ConfigureOutput( const TOutputValue& v ) = 0;
98       virtual TNeighborhood _GetNeighbors( const TVertex& v ) const = 0;
99       virtual TInputValue _GetInputValue( const TVertex& v ) const = 0;
100       virtual TOutputValue _GetOutputValue( const TVertex& v ) const = 0;
101
102       virtual void _ComputeOutputValue( TNode& n ) = 0;
103       virtual void _UpdateOutputValue( TNode& n ) = 0;
104       virtual void _QueueClear( ) = 0;
105       virtual void _QueuePush( const TNode& node ) = 0;
106       virtual unsigned long _QueueSize( ) const = 0;
107       virtual TNode _QueuePop( ) = 0;
108
109     private:
110       // Purposely not implemented
111       Algorithm( const Self& other );
112       Self& operator=( const Self& other );
113
114     protected:
115       bool m_VisualDebug;
116       TOutputValue m_InitValue;
117     };
118
119   } // ecapseman
120
121 } // ecapseman
122
123 #ifndef ITK_MANUAL_INSTANTIATION
124 #  include <fpa/Base/Algorithm.hxx>
125 #endif // ITK_MANUAL_INSTANTIATION
126
127 #endif // __fpa__Base__Algorithm__h__
128
129 // eof - $RCSfile$