1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
5 #ifndef __cpExtensions__Algorithms__RasterContourFilter__h__
6 #define __cpExtensions__Algorithms__RasterContourFilter__h__
8 #include <cpExtensions/Config.h>
9 #include <itkImageSource.h>
12 // -------------------------------------------------------------------------
13 namespace cpExtensions
19 template< class _TImage >
20 class RasterContourFilter
21 : public itk::ImageSource< _TImage >
25 typedef RasterContourFilter Self;
26 typedef itk::ImageSource< _TImage > Superclass;
27 typedef itk::SmartPointer< Self > Pointer;
28 typedef itk::SmartPointer< const Self > ConstPointer;
30 typedef _TImage TImage;
31 typedef typename _TImage::IndexType TIndex;
32 typedef typename _TImage::PixelType TPixel;
33 typedef typename _TImage::PointType TPoint;
34 typedef typename _TImage::RegionType TRegion;
35 typedef itk::ImageBase< 2 > TImageBase;
39 itkTypeMacro( RasterContourFilter, itk::ImageSource );
41 itkGetConstObjectMacro( Template, TImageBase );
42 itkGetConstMacro( InsideValue, TPixel );
43 itkGetConstMacro( OutsideValue, TPixel );
45 itkSetConstObjectMacro( Template, TImageBase );
46 itkSetMacro( InsideValue, TPixel );
47 itkSetMacro( OutsideValue, TPixel );
50 void AddPoint( double x, double y );
51 void AddPoint( double p[ 2 ] );
52 template< class _TPoint >
53 inline void AddPoint( const _TPoint& p );
57 RasterContourFilter( );
58 virtual ~RasterContourFilter( );
60 virtual void AllocateOutputs( ) cpExtensions_OVERRIDE;
61 virtual void BeforeThreadedGenerateData( ) cpExtensions_OVERRIDE;
62 virtual void AfterThreadedGenerateData( ) cpExtensions_OVERRIDE;
63 virtual void ThreadedGenerateData(
64 const TRegion& region, itk::ThreadIdType id
65 ) cpExtensions_OVERRIDE;
68 // Purposely not implemented
69 RasterContourFilter( const Self& );
70 void operator=( const Self& );
73 std::deque< TPoint > m_Contour;
74 std::deque< TIndex > m_Polygon;
76 typename TImageBase::ConstPointer m_Template;
78 TPixel m_OutsideValue;
85 // -------------------------------------------------------------------------
86 template< class _TImage >
87 template< class _TPoint >
88 void cpExtensions::Algorithms::RasterContourFilter< _TImage >::
89 AddPoint( const _TPoint& p )
94 this->m_Contour.push_back( pnt );
98 // -------------------------------------------------------------------------
99 #ifndef ITK_MANUAL_INSTANTIATION
100 # include <cpExtensions/Algorithms/RasterContourFilter.hxx>
101 #endif // ITK_MANUAL_INSTANTIATION
103 #endif // __cpExtensions__Algorithms__RasterContourFilter__h__