]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Filters/Image/DefaultTraits.h
...
[FrontAlgorithms.git] / lib / fpa / Filters / Image / DefaultTraits.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __fpa__Filters__Image__DefaultTraits__h__
6 #define __fpa__Filters__Image__DefaultTraits__h__
7
8 #include <set>
9 #include <vector>
10 #include <itkImage.h>
11 #include <itkImageToImageFilter.h>
12 #include <fpa/Filters/CollisionMarksInterface.h>
13 #include <fpa/Filters/MultipleSeedsInterface.h>
14
15 namespace fpa
16 {
17   namespace Filters
18   {
19     namespace Image
20     {
21       /**
22        */
23       template< class _TInputImage, class _TOutputImage, class _TMark >
24       class DefaultTraits
25       {
26       public:
27         typedef _TInputImage  TInputImage;
28         typedef _TOutputImage TOutputImage;
29
30         /**
31          */
32         class TInternalTraits
33         {
34         public:
35           typedef _TMark TMark;
36           typedef typename TInputImage::IndexType  TVertex;
37           typedef typename TInputImage::PixelType  TInputValue;
38           typedef typename TInputImage::PointType  TPoint;
39           typedef typename TOutputImage::PixelType TOutputValue;
40           typedef typename TVertex::LexicographicCompare TVertexCompare;
41           itkStaticConstMacro(
42             Dimension, unsigned int, TInputImage::ImageDimension
43             );
44
45           typedef std::vector< TVertex > TNeighborhood;
46           struct TNode
47           {
48             TVertex Vertex;
49             TVertex Parent;
50             TMark   FrontId;
51
52             // Hack to hide the fact that nodes need to be (re-)initialized
53             mutable TOutputValue Value;
54           };
55           struct TNodeCompare
56           {
57             bool operator()( const TNode& a, const TNode& b ) const
58               {
59                 static TVertexCompare c;
60                 return( c( a.Vertex, b.Vertex ) );
61               }
62           };
63           typedef std::set< TNode, TNodeCompare > TNodes;
64
65           struct TSeed
66           {
67             TVertex Vertex;
68             TPoint  Point;
69             bool    IsPoint;
70             TMark   FrontId;
71             TSeed( const TMark& fid = 0 )
72               : FrontId( fid )
73               { }
74           };
75           typedef std::vector< TSeed > TSeeds;
76         };
77         itkStaticConstMacro(
78           Dimension, unsigned int, TInternalTraits::Dimension
79           );
80
81         typedef itk::Image< _TMark, TInternalTraits::Dimension >         TMarksImage;
82         typedef itk::ImageToImageFilter< TInputImage, TOutputImage >     TFilterInterface;
83         typedef fpa::Filters::CollisionMarksInterface< TInternalTraits > TMarksInterface;
84         typedef fpa::Filters::MultipleSeedsInterface< TInternalTraits >  TSeedsInterface;
85       };
86
87     } // ecapseman
88
89   } // ecapseman
90
91 } // ecapseman
92
93 #endif // __fpa__Filters__Image__DefaultTraits__h__
94 // eof - $RCSfile$