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