]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/SeedsInterface.h
...
[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 #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 SeedsInterface
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 SeedsInterface Self;
39
40       struct TSeed
41       {
42         TVertex Vertex;
43         TPoint  Point;
44         bool    IsPoint;
45         bool    IsUnified;
46         TSeed( ) : IsUnified( false ) { }
47       };
48       typedef std::vector< TSeed > TSeeds;
49
50       struct TNode
51       {
52         TVertex  Vertex;
53         TVertex  Parent;
54         TFrontId FrontId;
55
56         // Hack to hide the fact that seed values need to be initialized
57         mutable TOutputValue Value;
58       };
59       struct TNodeCompare
60       {
61         bool operator()( const TNode& a, const TNode& b ) const
62           {
63             TCompare cmp;
64             return( cmp( a.Vertex, b.Vertex ) );
65           }
66       };
67       typedef std::set< TNode, TNodeCompare > TNodes;
68
69     public:
70       const TSeeds& GetSeeds( ) const;
71
72       virtual void AddSeed( const TVertex& seed );
73       virtual void AddSeed( const TPoint& seed );
74       virtual void ClearSeeds( );
75
76     protected:
77       SeedsInterface( itk::ProcessObject* filter );
78       virtual ~SeedsInterface( );
79
80       virtual TNodes _UnifySeeds( ) = 0;
81       virtual void _PrepareSeeds( TNodes& nodes ) = 0;
82
83     protected:
84       TSeeds m_Seeds;
85       itk::ProcessObject* m_Filter;
86     };
87
88   } // ecapseman
89
90 } // ecapseman
91
92 #ifndef ITK_MANUAL_INSTANTIATION
93 #  include <fpa/Base/SeedsInterface.hxx>
94 #endif // ITK_MANUAL_INSTANTIATION
95
96 #endif // __fpa__Base__SeedsInterface__h__
97
98 // eof - $RCSfile$