// ------------------------------------------------------------------------- // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) // ------------------------------------------------------------------------- #ifndef __cpExtensions__Algorithms__RasterContourFilter__h__ #define __cpExtensions__Algorithms__RasterContourFilter__h__ #include #include #include // ------------------------------------------------------------------------- namespace cpExtensions { namespace Algorithms { /** */ template< class _TImage > class RasterContourFilter : public itk::ImageSource< _TImage > { public: // Basic types typedef RasterContourFilter Self; typedef itk::ImageSource< _TImage > Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; typedef _TImage TImage; typedef typename _TImage::IndexType TIndex; typedef typename _TImage::PixelType TPixel; typedef typename _TImage::PointType TPoint; typedef typename _TImage::RegionType TRegion; typedef itk::ImageBase< 2 > TImageBase; public: itkNewMacro( Self ); itkTypeMacro( RasterContourFilter, itk::ImageSource ); itkGetConstObjectMacro( Template, TImageBase ); itkGetConstMacro( InsideValue, TPixel ); itkGetConstMacro( OutsideValue, TPixel ); itkSetConstObjectMacro( Template, TImageBase ); itkSetMacro( InsideValue, TPixel ); itkSetMacro( OutsideValue, TPixel ); public: void AddPoint( double x, double y ); void AddPoint( double p[ 2 ] ); template< class _TPoint > inline void AddPoint( const _TPoint& p ); void ClearPoints( ); protected: RasterContourFilter( ); virtual ~RasterContourFilter( ); virtual void AllocateOutputs( ) cpExtensions_OVERRIDE; virtual void BeforeThreadedGenerateData( ) cpExtensions_OVERRIDE; virtual void AfterThreadedGenerateData( ) cpExtensions_OVERRIDE; virtual void ThreadedGenerateData( const TRegion& region, itk::ThreadIdType id ) cpExtensions_OVERRIDE; private: // Purposely not implemented RasterContourFilter( const Self& ); void operator=( const Self& ); protected: std::deque< TPoint > m_Contour; std::deque< TIndex > m_Polygon; TRegion m_ROI; typename TImageBase::ConstPointer m_Template; TPixel m_InsideValue; TPixel m_OutsideValue; }; } // ecapseman } // ecapseman // ------------------------------------------------------------------------- template< class _TImage > template< class _TPoint > void cpExtensions::Algorithms::RasterContourFilter< _TImage >:: AddPoint( const _TPoint& p ) { TPoint pnt; pnt[ 0 ] = p[ 0 ]; pnt[ 1 ] = p[ 2 ]; this->m_Contour.push_back( pnt ); this->Modified( ); } // ------------------------------------------------------------------------- #ifndef ITK_MANUAL_INSTANTIATION # include #endif // ITK_MANUAL_INSTANTIATION #endif // __cpExtensions__Algorithms__RasterContourFilter__h__ // eof - $RCSfile$