]> Creatis software - FrontAlgorithms.git/blob - examples/sandbox.cxx
3a035be3864ac6beac8987c04e6ec72b1cb7fe64
[FrontAlgorithms.git] / examples / sandbox.cxx
1 #include <itkFunctionBase.h>
2 #include <itkImage.h>
3 #include <itkImageToImageFilter.h>
4 #include <fpa/Base/Algorithm.h>
5 #include <fpa/Base/SeedsInterface.h>
6 #include <fpa/Base/MarksInterface.h>
7
8 // -------------------------------------------------------------------------
9 namespace fpa
10 {
11   namespace Base
12   {
13     namespace Functors
14     {
15       namespace RegionGrow
16       {
17         /**
18          */
19         template< class _TValue >
20         class Tautology
21           : public itk::FunctionBase< _TValue, bool >
22         {
23         public:
24           typedef Tautology                          Self;
25           typedef itk::FunctionBase< _TValue, bool > Superclass;
26           typedef itk::SmartPointer< Self >          Pointer;
27           typedef itk::SmartPointer< const Self >    ConstPointer;
28
29         public:
30           itkNewMacro( Self );
31           itkTypeMacro(
32             fpa::Base::Functors::RegionGrow::Tautology,
33             itk::FunctionBase
34             );
35
36         public:
37           virtual bool Evaluate( const _TValue& input ) const override
38             {
39               return( true );
40             }
41         protected:
42           Tautology( )
43             : Superclass( )
44             {
45             }
46           virtual ~Tautology( )
47             {
48             }
49         private:
50           // Purposely not implemented
51           Tautology( const Self& other );
52           Self& operator=( const Self& other );
53         };
54
55       } // ecapseman
56
57     } // ecapseman
58
59   } // ecapseman
60
61 } // ecapseman
62
63 // -------------------------------------------------------------------------
64 namespace fpa
65 {
66   namespace Base
67   {
68     /**
69      */
70     template< class _TAlgorithm >
71     class RegionGrow
72       : public _TAlgorithm
73     {
74     };
75
76   } // ecapseman
77
78 } // ecapseman
79
80 // -------------------------------------------------------------------------
81 namespace fpa
82 {
83   namespace Image
84   {
85     /**
86      */
87     template< class _TInputImage >
88     class MarksInterface
89     {
90     };
91
92   } // ecapseman
93
94 } // ecapseman
95
96 // -------------------------------------------------------------------------
97 namespace fpa
98 {
99   namespace Image
100   {
101     /**
102      */
103     template< class _TInputImage, class _TOutputImage, class _TSeedsInterface, class _TMarksInterface >
104     class Algorithm
105       : public fpa::Base::Algorithm< itk::ImageToImageFilter< _TInputImage, _TOutputImage >, _TSeedsInterface, _TMarksInterface >
106     {
107     };
108
109   } // ecapseman
110
111 } // ecapseman
112
113 // -------------------------------------------------------------------------
114 namespace fpa
115 {
116   namespace Image
117   {
118     /**
119      */
120     template< class _TInputImage, class _TOutputImage >
121     class RegionGrow
122       : public fpa::Base::RegionGrow< fpa::Image::Algorithm< _TInputImage, _TOutputImage, fpa::Base::SeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::IndexType::LexicographicCompare >, fpa::Image::MarksInterface< _TInputImage > > >
123     {
124     };
125
126   } // ecapseman
127
128 } // ecapseman
129
130 // -------------------------------------------------------------------------
131 const unsigned int Dim = 2;
132 typedef short TInputPixel;
133 typedef unsigned char TOutputPixel;
134 typedef itk::Image< TInputPixel, Dim >  TInputImage;
135 typedef itk::Image< TOutputPixel, Dim > TOutputImage;
136
137 // -------------------------------------------------------------------------
138 int main( int argc, char* argv[] )
139 {
140   TInputImage::IndexType seed;
141   seed.Fill( 0 );
142
143   typedef fpa::Base::Functors::RegionGrow::Tautology< TInputPixel > TPredicate;
144   TPredicate::Pointer tautology = TPredicate::New( );
145
146   typedef fpa::Image::RegionGrow< TInputImage, TOutputImage > TFilter;
147   TFilter::Pointer filter = TFilter::New( );
148   filter->SetInput( input_image );
149   filter->AddSeed( seed );
150   filter->SetPredicate( tautology );
151   filter->Update( );
152
153   return( 0 );
154 }
155
156 // eof - $RCSfile$