1 #include "ImageWriter.h"
2 #include <cpPlugins/Interface/Image.h>
4 #include <itkImageFileWriter.h>
6 // -------------------------------------------------------------------------
7 cpPlugins::IO::ImageWriter::
11 this->SetNumberOfInputs( 1 );
13 this->m_Parameters->ConfigureAsString( "FileName", "" );
16 // -------------------------------------------------------------------------
17 cpPlugins::IO::ImageWriter::
22 // -------------------------------------------------------------------------
23 std::string cpPlugins::IO::ImageWriter::
26 cpPlugins::Interface::Image* image =
27 this->GetInput< cpPlugins::Interface::Image >( 0 );
29 return( "ImageWriter: No input image." );
31 itk::DataObject* itk_image = NULL;
33 cpPlugins_Image_Demangle_AllTypes( 2, image, itk_image, r, _RealGD );
34 else cpPlugins_Image_Demangle_AllTypes( 3, image, itk_image, r, _RealGD );
35 else cpPlugins_Image_Demangle_AllTypes( 4, image, itk_image, r, _RealGD );
36 else cpPlugins_VectorImage_Demangle_AllTypes( 2, image, itk_image, r, _RealGD );
37 else cpPlugins_VectorImage_Demangle_AllTypes( 3, image, itk_image, r, _RealGD );
38 else cpPlugins_VectorImage_Demangle_AllTypes( 4, image, itk_image, r, _RealGD );
39 else r = "ImageWriter: Input image type not supported.";
44 // -------------------------------------------------------------------------
46 std::string cpPlugins::IO::ImageWriter::
47 _RealGD( itk::DataObject* image )
50 std::string fname = this->m_Parameters->GetString( "FileName" );
52 typedef itk::ImageFileWriter< I > _W;
53 _W* writer = this->_CreateITK< _W >( );
54 writer->SetFileName( fname );
55 writer->SetInput( dynamic_cast< I* >( image ) );
60 catch( itk::ExceptionObject& err )
62 return( "ImageWriter: " + std::string( err.GetDescription( ) ) );