#include <cpPlugins/Plugins/ImageReader.h>
+#include <cpPlugins/Interface/Image.h>
-// TODO: interesting... #define ITK_MANUAL_INSTANTIATION
-#include <itkImage.h>
#include <itkImageFileReader.h>
+
+#define ITK_MANUAL_INSTANTIATION
+#include <itkImage.h>
#include <itkRGBPixel.h>
+// -------------------------------------------------------------------------
+std::string cpPlugins::Plugins::ImageReader::
+GetClassName( ) const
+{
+ return( "cpPlugins::Plugins::ImageReader" );
+}
+
// -------------------------------------------------------------------------
cpPlugins::Plugins::ImageReader::
ImageReader( )
: Superclass( )
{
+ this->SetNumberOfOutputs( 1 );
+ this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
+
this->m_DefaultParameters[ "FileName" ] =
TParameter( "string", "no_file_name" );
this->m_DefaultParameters[ "PixelType" ] = TParameter( "type", "uchar" );
// -------------------------------------------------------------------------
std::string cpPlugins::Plugins::ImageReader::
-GetClassName( ) const
-{
- return( "cpPlugins::Plugins::ImageReader" );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Plugins::ImageReader::
-Update( )
+_GenerateData( )
{
TParameters::const_iterator dIt;
if( dIt == this->m_Parameters.end( ) )
dIt = this->m_DefaultParameters.find( "ImageDimension" );
- bool ret = false;
- if ( dIt->second.second == "1" ) ret = this->_Update0< 1 >( );
- else if( dIt->second.second == "2" ) ret = this->_Update0< 2 >( );
- else if( dIt->second.second == "3" ) ret = this->_Update0< 3 >( );
- else if( dIt->second.second == "4" ) ret = this->_Update0< 4 >( );
+ std::string r = "cpPlugins::Plugins::ImageReader: itk::Image dimension not supported.";
+ if ( dIt->second.second == "1" ) r = this->_GD0< 1 >( );
+ else if( dIt->second.second == "2" ) r = this->_GD0< 2 >( );
+ else if( dIt->second.second == "3" ) r = this->_GD0< 3 >( );
+ else if( dIt->second.second == "4" ) r = this->_GD0< 4 >( );
- return( ret );
+ return( r );
}
// -------------------------------------------------------------------------
template< unsigned int D >
-bool cpPlugins::Plugins::ImageReader::
-_Update0( )
+std::string cpPlugins::Plugins::ImageReader::
+_GD0( )
{
TParameters::const_iterator tIt, cIt;
- // Get image pixelType
+ // Get image pixel type
tIt = this->m_Parameters.find( "PixelType" );
if( tIt == this->m_Parameters.end( ) )
tIt = this->m_DefaultParameters.find( "PixelType" );
if( cIt == this->m_Parameters.end( ) )
cIt = this->m_DefaultParameters.find( "IsColorImage" );
- bool ret = false;
+ std::string r = "cpPlugins::Plugins::ImageReader: itk::Image pixel type not supported";
if( cIt->second.second == "0" )
{
if( tIt->second.second == "char" )
- ret = this->_Update1< char, D >( );
+ r = this->_GD1< char, D >( );
else if( tIt->second.second == "short" )
- ret = this->_Update1< short, D >( );
+ r = this->_GD1< short, D >( );
else if( tIt->second.second == "int" )
- ret = this->_Update1< int, D >( );
+ r = this->_GD1< int, D >( );
else if( tIt->second.second == "long" )
- ret = this->_Update1< long, D >( );
+ r = this->_GD1< long, D >( );
else if( tIt->second.second == "uchar" )
- ret = this->_Update1< unsigned char, D >( );
+ r = this->_GD1< unsigned char, D >( );
else if( tIt->second.second == "ushort" )
- ret = this->_Update1< unsigned short, D >( );
+ r = this->_GD1< unsigned short, D >( );
else if( tIt->second.second == "uint" )
- ret = this->_Update1< unsigned int, D >( );
+ r = this->_GD1< unsigned int, D >( );
else if( tIt->second.second == "ulong" )
- ret = this->_Update1< unsigned long, D >( );
+ r = this->_GD1< unsigned long, D >( );
else if( tIt->second.second == "float" )
- ret = this->_Update1< float, D >( );
+ r = this->_GD1< float, D >( );
else if( tIt->second.second == "double" )
- ret = this->_Update1< double, D >( );
+ r = this->_GD1< double, D >( );
}
else if( cIt->second.second == "1" )
{
if( tIt->second.second == "char" )
- ret = this->_Update1< itk::RGBPixel< char >, D >( );
+ r = this->_GD1< itk::RGBPixel< char >, D >( );
else if( tIt->second.second == "short" )
- ret = this->_Update1< itk::RGBPixel< short >, D >( );
+ r = this->_GD1< itk::RGBPixel< short >, D >( );
else if( tIt->second.second == "int" )
- ret = this->_Update1< itk::RGBPixel< int >, D >( );
+ r = this->_GD1< itk::RGBPixel< int >, D >( );
else if( tIt->second.second == "long" )
- ret = this->_Update1< itk::RGBPixel< long >, D >( );
+ r = this->_GD1< itk::RGBPixel< long >, D >( );
else if( tIt->second.second == "uchar" )
- ret = this->_Update1< itk::RGBPixel< unsigned char >, D >( );
+ r = this->_GD1< itk::RGBPixel< unsigned char >, D >( );
else if( tIt->second.second == "ushort" )
- ret = this->_Update1< itk::RGBPixel< unsigned short >, D >( );
+ r = this->_GD1< itk::RGBPixel< unsigned short >, D >( );
else if( tIt->second.second == "uint" )
- ret = this->_Update1< itk::RGBPixel< unsigned int >, D >( );
+ r = this->_GD1< itk::RGBPixel< unsigned int >, D >( );
else if( tIt->second.second == "ulong" )
- ret = this->_Update1< itk::RGBPixel< unsigned long >, D >( );
+ r = this->_GD1< itk::RGBPixel< unsigned long >, D >( );
else if( tIt->second.second == "float" )
- ret = this->_Update1< itk::RGBPixel< float >, D >( );
+ r = this->_GD1< itk::RGBPixel< float >, D >( );
else if( tIt->second.second == "double" )
- ret = this->_Update1< itk::RGBPixel< double >, D >( );
+ r = this->_GD1< itk::RGBPixel< double >, D >( );
} // fi
- return( ret );
+ return( r );
}
// -------------------------------------------------------------------------
template< class P, unsigned int D >
-bool cpPlugins::Plugins::ImageReader::
-_Update1( )
+std::string cpPlugins::Plugins::ImageReader::
+_GD1( )
{
TParameters::const_iterator fIt;
- // Get image pixelType
+ // Get filename
fIt = this->m_Parameters.find( "FileName" );
if( fIt == this->m_Parameters.end( ) )
fIt = this->m_DefaultParameters.find( "FileName" );
typedef itk::Image< P, D > _TImage;
- typedef itk::ImageFileReader< _TImage > _TImageReader;
+ typedef itk::ImageFileReader< _TImage > _TReader;
- _TImageReader* reader =
- dynamic_cast< _TImageReader* >( this->m_Reader.GetPointer( ) );
+ _TReader* reader =
+ dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) );
if( reader == NULL )
{
- this->m_Reader = _TImageReader::New( );
- reader = dynamic_cast< _TImageReader* >( this->m_Reader.GetPointer( ) );
+ this->m_RealProcessObject = _TReader::New( );
+ reader =
+ dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) );
} // fi
reader->SetFileName( fIt->second.second );
}
catch( itk::ExceptionObject& err )
{
- return( false );
+ return( err.GetDescription( ) );
} // yrt
- return( true );
+ this->_SetOutput( 0, reader->GetOutput( ) );
+ return( "" );
}
// eof - $RCSfile$