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 // Thank you very much Microsoft !!! :-@
27 std::string r = this->_GD0_Image< 2 >( );
28 if( r != "" ) r = this->_GD0_Image< 3 >( );
29 if( r != "" ) r = this->_GD0_Image< 4 >( );
30 if( r != "" ) r = this->_GD0_VectorImage< 2 >( );
31 if( r != "" ) r = this->_GD0_VectorImage< 3 >( );
32 if( r != "" ) r = this->_GD0_VectorImage< 4 >( );
36 // -------------------------------------------------------------------------
37 template< unsigned int D >
38 std::string cpPlugins::IO::ImageWriter::
41 cpPlugins::Interface::Image* image =
42 this->GetInput< cpPlugins::Interface::Image >( 0 );
44 return( "ImageWriter: No input image." );
46 itk::DataObject* itk_image = NULL;
48 cpPlugins_Image_Demangle_AllTypes( D, image, itk_image, r, _RealGD );
49 else r = "ImageWriter: Input image type not supported.";
54 // -------------------------------------------------------------------------
55 template< unsigned int D >
56 std::string cpPlugins::IO::ImageWriter::
59 cpPlugins::Interface::Image* image =
60 this->GetInput< cpPlugins::Interface::Image >( 0 );
62 return( "ImageWriter: No input image." );
64 itk::DataObject* itk_image = NULL;
66 cpPlugins_VectorImage_Demangle_AllTypes( D, image, itk_image, r, _RealGD );
67 else r = "ImageWriter: Input image type not supported.";
72 // -------------------------------------------------------------------------
74 std::string cpPlugins::IO::ImageWriter::
75 _RealGD( itk::DataObject* image )
78 std::string fname = this->m_Parameters->GetString( "FileName" );
80 typedef itk::ImageFileWriter< I > _W;
81 _W* writer = this->_CreateITK< _W >( );
82 writer->SetFileName( fname );
83 writer->SetInput( dynamic_cast< I* >( image ) );
88 catch( itk::ExceptionObject& err )
90 return( "ImageWriter: " + std::string( err.GetDescription( ) ) );