1 #include "ImageWriter.h"
2 #include <cpPlugins/Interface/Image.h>
4 #include <itkImageFileWriter.h>
6 // -------------------------------------------------------------------------
7 cpPlugins::IO::ImageWriter::
11 this->m_ClassName = "cpPlugins::IO::ImageWriter";
12 this->m_ClassCategory = "ImageWriter";
13 this->SetNumberOfInputs( 1 );
15 using namespace cpPlugins::Interface;
16 this->m_DefaultParameters.Configure( Parameters::String, "FileName" );
17 this->m_Parameters = this->m_DefaultParameters;
20 // -------------------------------------------------------------------------
21 cpPlugins::IO::ImageWriter::
26 // -------------------------------------------------------------------------
27 std::string cpPlugins::IO::ImageWriter::
30 cpPlugins::Interface::Image* image =
31 this->GetInput< cpPlugins::Interface::Image >( 0 );
33 return( "ImageWriter: No input image." );
35 itk::DataObject* itk_image = NULL;
37 cpPlugins_Image_Input_Demangle_Dimension_AllTypes(
38 2, image, itk_image, r, _RealGD
40 else cpPlugins_Image_Input_Demangle_Dimension_AllTypes(
41 3, image, itk_image, r, _RealGD
43 else cpPlugins_Image_Input_Demangle_Dimension_AllTypes(
44 4, image, itk_image, r, _RealGD
46 #ifndef _WIN32 // win32: Nested loops error ????
47 else cpPlugins_Image_Input_Demangle(
48 itk::DiffusionTensor3D< float >, 3, image, itk_image, r, _RealGD
50 else cpPlugins_Image_Input_Demangle(
51 itk::DiffusionTensor3D< double >, 3, image, itk_image, r, _RealGD
54 else r = "ImageWriter: Input image type not supported.";
59 // -------------------------------------------------------------------------
61 std::string cpPlugins::IO::ImageWriter::
62 _RealGD( itk::DataObject* image )
64 typedef itk::ImageFileWriter< I > _W;
67 std::string fname = this->m_Parameters.GetValueAsString( "FileName" );
68 _W* writer = dynamic_cast< _W* >( this->m_RealProcessObject.GetPointer( ) );
71 this->m_RealProcessObject = _W::New( );
72 writer = dynamic_cast< _W* >( this->m_RealProcessObject.GetPointer( ) );
75 writer->SetFileName( fname );
76 writer->SetInput( dynamic_cast< I* >( image ) );
81 catch( itk::ExceptionObject& err )
83 return( "ImageWriter: " + std::string( err.GetDescription( ) ) );