]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Algorithms/RasterContourFilter.h
Raster filter updated. LUT image visualization strange bug :-(
[cpPlugins.git] / lib / cpExtensions / Algorithms / RasterContourFilter.h
1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
4
5 #ifndef __cpExtensions__Algorithms__RasterContourFilter__h__
6 #define __cpExtensions__Algorithms__RasterContourFilter__h__
7
8 #include <cpExtensions/Config.h>
9 #include <itkImageSource.h>
10 #include <vtkSmartPointer.h>
11
12 // -------------------------------------------------------------------------
13 class vtkPoints;
14 class vtkPolygon;
15
16 // -------------------------------------------------------------------------
17 namespace cpExtensions
18 {
19   namespace Algorithms
20   {
21     /**
22      */
23     template< class _TImage >
24     class RasterContourFilter
25       : public itk::ImageSource< _TImage >
26     {
27     public:
28       // Basic types
29       typedef RasterContourFilter             Self;
30       typedef itk::ImageSource< _TImage >     Superclass;
31       typedef itk::SmartPointer< Self >       Pointer;
32       typedef itk::SmartPointer< const Self > ConstPointer;
33
34       typedef _TImage TImage;
35       typedef typename _TImage::IndexType  TIndex;
36       typedef typename _TImage::PixelType  TPixel;
37       typedef typename _TImage::PointType  TPoint;
38       typedef typename _TImage::RegionType TRegion;
39       typedef itk::ImageBase< 2 > TImageBase;
40
41     public:
42       itkNewMacro( Self );
43       itkTypeMacro( RasterContourFilter, itk::ImageSource );
44
45       itkGetConstObjectMacro( Template, TImageBase );
46       itkGetConstMacro( InsideValue, TPixel );
47       itkGetConstMacro( OutsideValue, TPixel );
48
49       itkSetConstObjectMacro( Template, TImageBase );
50       itkSetMacro( InsideValue, TPixel );
51       itkSetMacro( OutsideValue, TPixel );
52
53     public:
54       void AddPoint( double x, double y );
55       void AddPoint( double p[ 2 ] );
56       void AddPoints( vtkPoints* points );
57       void ClearPoints( );
58
59     protected:
60       RasterContourFilter( );
61       virtual ~RasterContourFilter( );
62
63       virtual void AllocateOutputs( ) cpExtensions_OVERRIDE;
64       virtual void BeforeThreadedGenerateData( ) cpExtensions_OVERRIDE;
65       virtual void AfterThreadedGenerateData( ) cpExtensions_OVERRIDE;
66       virtual void ThreadedGenerateData(
67         const TRegion& region, itk::ThreadIdType id
68         ) cpExtensions_OVERRIDE;
69
70     private:
71       // Purposely not implemented
72       RasterContourFilter( const Self& );
73       void operator=( const Self& );
74
75     protected:
76       vtkSmartPointer< vtkPolygon >     m_Polygon;
77       typename TImageBase::ConstPointer m_Template;
78       TPixel m_InsideValue;
79       TPixel m_OutsideValue;
80     };
81
82   } // ecapseman
83
84 } // ecapseman
85
86 #ifndef ITK_MANUAL_INSTANTIATION
87 #  include <cpExtensions/Algorithms/RasterContourFilter.hxx>
88 #endif // ITK_MANUAL_INSTANTIATION
89
90 #endif // __cpExtensions__Algorithms__RasterContourFilter__h__
91
92 // eof - $RCSfile$