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