]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/Mori.h
6863278c7afe939f9c84c8af8538327bf86709f0
[FrontAlgorithms.git] / lib / fpa / Base / Mori.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Base__Mori__h__
7 #define __fpa__Base__Mori__h__
8
9 #include <deque>
10 #include <set>
11 #include <map>
12 #include <itkConceptChecking.h>
13 #include <itkFunctionBase.h>
14 #include <fpa/Base/Functors/RegionGrow/BinaryThreshold.h>
15
16 namespace fpa
17 {
18   namespace Base
19   {
20     /**
21      */
22     template< class _TAlgorithm >
23     class Mori
24       : public _TAlgorithm
25     {
26     public:
27       typedef Mori                            Self;
28       typedef _TAlgorithm                     Superclass;
29       typedef itk::SmartPointer< Self >       Pointer;
30       typedef itk::SmartPointer< const Self > ConstPointer;
31
32       typedef typename _TAlgorithm::TNode        TNode;
33       typedef typename _TAlgorithm::TNodes       TNodes;
34       typedef typename _TAlgorithm::TInputValue  TInputValue;
35       typedef typename _TAlgorithm::TOutputValue TOutputValue;
36       typedef typename _TAlgorithm::TFrontId     TFrontId;
37       typedef typename _TAlgorithm::TVertex      TVertex;
38
39       typedef std::deque< TNode >     TQueue;
40       typedef std::set< TInputValue > TThresholds;
41       typedef std::pair< TInputValue, unsigned long > TSignalData;
42       typedef std::map< TFrontId, TSignalData >       TSignal;
43       typedef fpa::Base::Functors::RegionGrow::BinaryThreshold< TInputValue > TPredicate;
44
45     public:
46       itkConceptMacro(
47         Check_TOutputValue,
48         ( itk::Concept::IsUnsignedInteger< TOutputValue > )
49         );
50
51       itkGetConstMacro( InsideValue, TOutputValue );
52       itkSetMacro( InsideValue, TOutputValue );
53
54     public:
55       virtual itk::ModifiedTimeType GetMTime( ) const override;
56
57       TOutputValue GetOutsideValue( ) const;
58       void SetOutsideValue( const TOutputValue& v );
59
60       void ClearThresholds( );
61       void AddThreshold( const TInputValue& thr );
62       void SetThresholds(
63         const TInputValue& init,
64         const TInputValue& end,
65         const TInputValue& delta
66         );
67
68     protected:
69       Mori( );
70       virtual ~Mori( );
71
72       virtual void _BeforeGenerateData( ) override;
73       virtual void _AfterGenerateData( ) override;
74       virtual void _FinishOneLoop( ) override;
75       virtual bool _ComputeOutputValue( TNode& n ) override;
76       virtual void _QueueClear( ) override;
77       virtual TNode _QueuePop( ) override;
78       virtual void _QueuePush( const TNode& node ) override;
79       virtual unsigned long _QueueSize( ) const override;
80       virtual void _PrepareSeeds( TNodes& nodes ) override;
81
82     private:
83       // Purposely not implemented.
84       Mori( const Self& other );
85       Self& operator=( const Self& other );
86
87     protected:
88       typename TPredicate::Pointer m_Predicate;
89       TThresholds m_Thresholds;
90       typename TThresholds::const_iterator m_CurrentThreshold;
91       TQueue m_Queues[ 2 ];
92       unsigned int m_CurrentQueue;
93       unsigned long m_Count;
94       TSignal m_Signal;
95
96       TOutputValue m_InsideValue;
97     };
98
99   } // ecapseman
100
101 } // ecapseman
102
103 #ifndef ITK_MANUAL_INSTANTIATION
104 #  include <fpa/Base/Mori.hxx>
105 #endif // ITK_MANUAL_INSTANTIATION
106
107 #endif // __fpa__Base__Mori__h__
108
109 // eof - $RCSfile$