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