-#include <ImageGenericFilters/RegionOfInterestImageFilter.h>
-#include <cpPlugins/DataObjects/Image.h>
-#include <cpPlugins/DataObjects/BoundingBox.h>
-#include <cpPlugins/DataObjects/Image_Demanglers.h>
-
-#include <itkRGBPixel.h>
-#include <itkRGBAPixel.h>
-#include <itkRegionOfInterestImageFilter.h>
-
-// -------------------------------------------------------------------------
-cpPluginsImageGenericFilters::RegionOfInterestImageFilter::
-RegionOfInterestImageFilter( )
- : Superclass( )
-{
- typedef cpPlugins::DataObjects::Image _TImage;
- typedef cpPlugins::DataObjects::BoundingBox _TBBox;
- this->_ConfigureInput< _TImage >( "Input", true, false );
- this->_ConfigureInput< _TBBox >( "BoundingBox", true, false );
- this->_ConfigureOutput< _TImage >( "Output" );
-}
-
-// -------------------------------------------------------------------------
-cpPluginsImageGenericFilters::RegionOfInterestImageFilter::
-~RegionOfInterestImageFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-void cpPluginsImageGenericFilters::RegionOfInterestImageFilter::
-_GenerateData( )
-{
- auto o = this->GetInputData( "Input" );
- cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
- cpPlugins_Demangle_Image_ColorPixels_AllDims_1( o, _GD0 )
- this->_Error( "Invalid input image." );
-}
-
-// -------------------------------------------------------------------------
-template< class _TImage >
-void cpPluginsImageGenericFilters::RegionOfInterestImageFilter::
-_GD0( _TImage* input )
-{
- typedef cpPlugins::DataObjects::BoundingBox _TBBox;
- typedef itk::RegionOfInterestImageFilter< _TImage, _TImage > _TFilter;
- typedef typename _TImage::IndexType _TIndex;
- typedef typename _TImage::PointType _TPoint;
- typedef typename _TImage::RegionType _TRegion;
- typedef typename _TImage::SizeType _TSize;
-
- auto bb = this->GetInput< _TBBox >( "BoundingBox" );
-
- _TIndex i0, i1;
- input->TransformPhysicalPointToIndex( bb->GetMinimum< _TPoint >( ), i0 );
- input->TransformPhysicalPointToIndex( bb->GetMaximum< _TPoint >( ), i1 );
-
- _TSize size;
- for( unsigned int d = 0; d < _TImage::ImageDimension; ++d )
- size[ d ] = i1[ d ] - i0[ d ] + 1;
-
- _TRegion region;
- region.SetIndex( i0 );
- region.SetSize( size );
-
- auto filter = this->_CreateITK< _TFilter >( );
- filter->SetInput( input );
- filter->SetRegionOfInterest( region );
- filter->Update( );
- this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
-}
-
-// eof - $RCSfile$