]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/SingleSeedInterface.h
...
[FrontAlgorithms.git] / lib / fpa / Base / SingleSeedInterface.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Base__SingleSeedInterface__h__
7 #define __fpa__Base__SingleSeedInterface__h__
8
9 #include <functional>
10 #include <set>
11 #include <vector>
12
13 #include <itkConceptChecking.h>
14 #include <itkProcessObject.h>
15
16 namespace fpa
17 {
18   namespace Base
19   {
20     /**
21      */
22     template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare = std::greater< _TVertex > >
23     class SingleSeedInterface
24     {
25     public:
26       itkConceptMacro(
27         Check_TFrontId,
28         ( itk::Concept::IsUnsignedInteger< _TFrontId > )
29         );
30
31     public:
32       typedef _TVertex       TVertex;
33       typedef _TPoint        TPoint;
34       typedef _TInputValue   TInputValue;
35       typedef _TOutputValue  TOutputValue;
36       typedef _TFrontId      TFrontId;
37       typedef _TCompare      TCompare;
38       typedef SingleSeedInterface Self;
39
40       struct TSeed
41       {
42         TVertex  Vertex;
43         TPoint   Point;
44         bool     IsPoint;
45         bool     IsUnified;
46         TFrontId FrontId;
47         TSeed( )
48           : IsUnified( false ),
49             FrontId( TFrontId( 0 ) )
50           { }
51       };
52       typedef std::vector< TSeed > TSeeds;
53
54       struct TNode
55       {
56         TVertex  Vertex;
57         TVertex  Parent;
58         TFrontId FrontId;
59
60         // Hack to hide the fact that seed values need to be initialized
61         mutable TOutputValue Value;
62       };
63       struct TNodeCompare
64       {
65         bool operator()( const TNode& a, const TNode& b ) const
66           {
67             TCompare cmp;
68             return( cmp( a.Vertex, b.Vertex ) );
69           }
70       };
71       typedef std::set< TNode, TNodeCompare > TNodes;
72
73     public:
74       TSeeds& GetSeeds( );
75       const TSeeds& GetSeeds( ) const;
76
77       virtual void SetSeed( const TVertex& seed );
78       virtual void SetSeed( const TPoint& seed );
79
80     protected:
81       SingleSeedInterface( itk::ProcessObject* filter );
82       virtual ~SingleSeedInterface( );
83
84       virtual TNodes _UnifySeeds( ) = 0;
85       virtual void _PrepareSeeds( TNodes& nodes ) = 0;
86
87     protected:
88       TSeeds m_Seeds;
89       itk::ProcessObject* m_Filter;
90     };
91
92   } // ecapseman
93
94 } // ecapseman
95
96 #ifndef ITK_MANUAL_INSTANTIATION
97 #  include <fpa/Base/SingleSeedInterface.hxx>
98 #endif // ITK_MANUAL_INSTANTIATION
99
100 #endif // __fpa__Base__SingleSeedInterface__h__
101
102 // eof - $RCSfile$