1 #include <cpPlugins/Plugins/ImageWriter.h>
2 #include <cpPlugins/Interface/Image.h>
4 #include <itkImageFileWriter.h>
6 // -------------------------------------------------------------------------
7 cpPlugins::Plugins::ImageWriter::
11 this->m_ClassName = "cpPlugins::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::Plugins::ImageWriter::
26 // -------------------------------------------------------------------------
27 std::string cpPlugins::Plugins::ImageWriter::
30 cpPlugins::Interface::Image* image =
31 this->_Input< 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 else cpPlugins_Image_Input_Demangle(
47 itk::DiffusionTensor3D< float >, 3, image, itk_image, r, _RealGD
49 else cpPlugins_Image_Input_Demangle(
50 itk::DiffusionTensor3D< double >, 3, image, itk_image, r, _RealGD
52 else r = "ImageWriter: Input image type not supported.";
57 // -------------------------------------------------------------------------
59 std::string cpPlugins::Plugins::ImageWriter::
60 _RealGD( itk::DataObject* image )
62 typedef itk::ImageFileWriter< I > _W;
65 std::string fname = this->m_Parameters.GetValueAsString( "FileName" );
66 _W* writer = dynamic_cast< _W* >( this->m_RealProcessObject.GetPointer( ) );
69 this->m_RealProcessObject = _W::New( );
70 writer = dynamic_cast< _W* >( this->m_RealProcessObject.GetPointer( ) );
73 writer->SetFileName( fname );
74 writer->SetInput( dynamic_cast< I* >( image ) );
79 catch( itk::ExceptionObject& err )
81 return( "ImageWriter: " + std::string( err.GetDescription( ) ) );