X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FPlugins%2FImageReader.cxx;h=b232268917881a0a99c36e52aa2f45f5e9d64112;hb=c29448936abc15d110205b2da435035131398a87;hp=5bc182ed530bb2f0e4fbf2c71e586d2ed0cb06e6;hpb=8c23766af88a29c3e830299dffc4b95d9fe61df9;p=cpPlugins.git diff --git a/lib/cpPlugins/Plugins/ImageReader.cxx b/lib/cpPlugins/Plugins/ImageReader.cxx index 5bc182e..b232268 100644 --- a/lib/cpPlugins/Plugins/ImageReader.cxx +++ b/lib/cpPlugins/Plugins/ImageReader.cxx @@ -1,8 +1,9 @@ #include -// TODO: interesting... #define ITK_MANUAL_INSTANTIATION -#include #include + +#define ITK_MANUAL_INSTANTIATION +#include #include // ------------------------------------------------------------------------- @@ -10,6 +11,8 @@ cpPlugins::Plugins::ImageReader:: ImageReader( ) : Superclass( ) { + this->SetNumberOfOutputs( 1 ); + this->m_DefaultParameters[ "FileName" ] = TParameter( "string", "no_file_name" ); this->m_DefaultParameters[ "PixelType" ] = TParameter( "type", "uchar" ); @@ -31,8 +34,8 @@ GetClassName( ) const } // ------------------------------------------------------------------------- -bool cpPlugins::Plugins::ImageReader:: -Update( ) +std::string cpPlugins::Plugins::ImageReader:: +_GenerateData( ) { TParameters::const_iterator dIt; @@ -41,19 +44,19 @@ Update( ) 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 ret = "itk::Image dimension not supported."; + if ( dIt->second.second == "1" ) ret = this->_GenerateData0< 1 >( ); + else if( dIt->second.second == "2" ) ret = this->_GenerateData0< 2 >( ); + else if( dIt->second.second == "3" ) ret = this->_GenerateData0< 3 >( ); + else if( dIt->second.second == "4" ) ret = this->_GenerateData0< 4 >( ); return( ret ); } // ------------------------------------------------------------------------- template< unsigned int D > -bool cpPlugins::Plugins::ImageReader:: -_Update0( ) +std::string cpPlugins::Plugins::ImageReader:: +_GenerateData0( ) { TParameters::const_iterator tIt, cIt; @@ -65,60 +68,60 @@ _Update0( ) if( cIt == this->m_Parameters.end( ) ) cIt = this->m_DefaultParameters.find( "IsColorImage" ); - bool ret = false; + std::string ret = "itk::Image pixel type not supported"; if( cIt->second.second == "0" ) { if( tIt->second.second == "char" ) - ret = this->_Update1< char, D >( ); + ret = this->_GenerateData1< char, D >( ); else if( tIt->second.second == "short" ) - ret = this->_Update1< short, D >( ); + ret = this->_GenerateData1< short, D >( ); else if( tIt->second.second == "int" ) - ret = this->_Update1< int, D >( ); + ret = this->_GenerateData1< int, D >( ); else if( tIt->second.second == "long" ) - ret = this->_Update1< long, D >( ); + ret = this->_GenerateData1< long, D >( ); else if( tIt->second.second == "uchar" ) - ret = this->_Update1< unsigned char, D >( ); + ret = this->_GenerateData1< unsigned char, D >( ); else if( tIt->second.second == "ushort" ) - ret = this->_Update1< unsigned short, D >( ); + ret = this->_GenerateData1< unsigned short, D >( ); else if( tIt->second.second == "uint" ) - ret = this->_Update1< unsigned int, D >( ); + ret = this->_GenerateData1< unsigned int, D >( ); else if( tIt->second.second == "ulong" ) - ret = this->_Update1< unsigned long, D >( ); + ret = this->_GenerateData1< unsigned long, D >( ); else if( tIt->second.second == "float" ) - ret = this->_Update1< float, D >( ); + ret = this->_GenerateData1< float, D >( ); else if( tIt->second.second == "double" ) - ret = this->_Update1< double, D >( ); + ret = this->_GenerateData1< double, D >( ); } else if( cIt->second.second == "1" ) { if( tIt->second.second == "char" ) - ret = this->_Update1< itk::RGBPixel< char >, D >( ); + ret = this->_GenerateData1< itk::RGBPixel< char >, D >( ); else if( tIt->second.second == "short" ) - ret = this->_Update1< itk::RGBPixel< short >, D >( ); + ret = this->_GenerateData1< itk::RGBPixel< short >, D >( ); else if( tIt->second.second == "int" ) - ret = this->_Update1< itk::RGBPixel< int >, D >( ); + ret = this->_GenerateData1< itk::RGBPixel< int >, D >( ); else if( tIt->second.second == "long" ) - ret = this->_Update1< itk::RGBPixel< long >, D >( ); + ret = this->_GenerateData1< itk::RGBPixel< long >, D >( ); else if( tIt->second.second == "uchar" ) - ret = this->_Update1< itk::RGBPixel< unsigned char >, D >( ); + ret = this->_GenerateData1< itk::RGBPixel< unsigned char >, D >( ); else if( tIt->second.second == "ushort" ) - ret = this->_Update1< itk::RGBPixel< unsigned short >, D >( ); + ret = this->_GenerateData1< itk::RGBPixel< unsigned short >, D >( ); else if( tIt->second.second == "uint" ) - ret = this->_Update1< itk::RGBPixel< unsigned int >, D >( ); + ret = this->_GenerateData1< itk::RGBPixel< unsigned int >, D >( ); else if( tIt->second.second == "ulong" ) - ret = this->_Update1< itk::RGBPixel< unsigned long >, D >( ); + ret = this->_GenerateData1< itk::RGBPixel< unsigned long >, D >( ); else if( tIt->second.second == "float" ) - ret = this->_Update1< itk::RGBPixel< float >, D >( ); + ret = this->_GenerateData1< itk::RGBPixel< float >, D >( ); else if( tIt->second.second == "double" ) - ret = this->_Update1< itk::RGBPixel< double >, D >( ); + ret = this->_GenerateData1< itk::RGBPixel< double >, D >( ); } // fi return( ret ); } // ------------------------------------------------------------------------- template< class P, unsigned int D > -bool cpPlugins::Plugins::ImageReader:: -_Update1( ) +std::string cpPlugins::Plugins::ImageReader:: +_GenerateData1( ) { TParameters::const_iterator fIt; @@ -145,10 +148,11 @@ _Update1( ) } catch( itk::ExceptionObject& err ) { - return( false ); + return( err.GetDescription( ) ); } // yrt - return( true ); + this->_SetOutput( 0, reader->GetOutput( ) ); + return( "" ); } // eof - $RCSfile$