]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Plugins/ImageWriter.cxx
...
[cpPlugins.git] / lib / cpPlugins / Plugins / ImageWriter.cxx
index 3dd319afef43ec75ef6d6476aa57ce70db4c23fc..176e9f663ee9197aaabb01bfdd5423a936f6fd3f 100644 (file)
@@ -1,10 +1,33 @@
 #include <cpPlugins/Plugins/ImageWriter.h>
 
+#include <complex>
+
+#define ITK_MANUAL_INSTANTIATION
+#include <itkImage.h>
+
+#include <itkCovariantVector.h>
+#include <itkDiffusionTensor3D.h>
+#include <itkPoint.h>
+#include <itkRGBPixel.h>
+#include <itkRGBAPixel.h>
+#include <itkSymmetricSecondRankTensor.h>
+#include <itkVector.h>
+
+#undef ITK_MANUAL_INSTANTIATION
+#include <itkImageFileWriter.h>
+
 // -------------------------------------------------------------------------
 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$