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