X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FPlugins%2FImageWriter.cxx;h=176e9f663ee9197aaabb01bfdd5423a936f6fd3f;hb=7c7bc497af96e7b5845be9a2fc277036ec752be9;hp=3dd319afef43ec75ef6d6476aa57ce70db4c23fc;hpb=8c23766af88a29c3e830299dffc4b95d9fe61df9;p=cpPlugins.git diff --git a/lib/cpPlugins/Plugins/ImageWriter.cxx b/lib/cpPlugins/Plugins/ImageWriter.cxx index 3dd319a..176e9f6 100644 --- a/lib/cpPlugins/Plugins/ImageWriter.cxx +++ b/lib/cpPlugins/Plugins/ImageWriter.cxx @@ -1,10 +1,33 @@ #include +#include + +#define ITK_MANUAL_INSTANTIATION +#include + +#include +#include +#include +#include +#include +#include +#include + +#undef ITK_MANUAL_INSTANTIATION +#include + // ------------------------------------------------------------------------- cpPlugins::Plugins::ImageWriter:: ImageWriter( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::ImageWriter"; + this->m_ClassCategory = "ImageWriter"; + this->SetNumberOfInputs( 1 ); + + using namespace cpPlugins::Interface; + this->m_DefaultParameters.Configure( Parameters::String, "FileName" ); + this->m_Parameters = this->m_DefaultParameters; } // ------------------------------------------------------------------------- @@ -15,16 +38,52 @@ cpPlugins::Plugins::ImageWriter:: // ------------------------------------------------------------------------- std::string cpPlugins::Plugins::ImageWriter:: -GetClassName( ) const +_GenerateData( ) +{ + itk::DataObject* i = this->m_Inputs[ 0 ]->GetITKDataObject( ); + return( this->_DemangleImageDimension( i ) ); +} + +// ------------------------------------------------------------------------- +namespace cpPlugins { - return( "cpPlugins::Plugins::ImageWriter" ); + namespace Plugins + { + cpPlugins_Image_Demangle_Methods_Code( ImageWriter, _RealGD ); + } } // ------------------------------------------------------------------------- -bool cpPlugins::Plugins::ImageWriter:: -Update( ) +template< class I > +std::string cpPlugins::Plugins::ImageWriter:: +_RealGD( itk::DataObject* image ) { - return( false ); + typedef itk::ImageFileWriter< I > _W; + + // Get filename + using namespace cpPlugins::Interface; + Parameters::TString fname = + this->m_Parameters.GetValueAsString( "FileName" ); + + _W* writer = dynamic_cast< _W* >( this->m_RealProcessObject.GetPointer( ) ); + if( writer == NULL ) + { + this->m_RealProcessObject = _W::New( ); + writer = dynamic_cast< _W* >( this->m_RealProcessObject.GetPointer( ) ); + + } // fi + writer->SetFileName( fname ); + writer->SetInput( dynamic_cast< I* >( image ) ); + try + { + writer->Update( ); + } + catch( itk::ExceptionObject& err ) + { + return( "ImageWriter: " + std::string( err.GetDescription( ) ) ); + + } // yrt + return( "" ); } // eof - $RCSfile$