]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Plugins/ImageReader.cxx
...
[cpPlugins.git] / lib / cpPlugins / Plugins / ImageReader.cxx
index 24399718c9e5477f8c6a45fb6461abe95e5e0570..fc752efaafe5d8227b2be6f91e70bebd6ae2c452 100644 (file)
@@ -1,21 +1,8 @@
 #include <cpPlugins/Plugins/ImageReader.h>
 #include <cpPlugins/Interface/Image.h>
 
-#include <complex>
 #include <set>
 
-#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 <itkImageFileReader.h>
 #include <itkImageSeriesReader.h>
 
@@ -66,7 +53,6 @@ _GenerateData( )
       {
         switch( io->GetNumberOfDimensions( ) )
         {
-        case 1: r = this->_GD0< 1 >( io, names ); break;
         case 2: r = this->_GD0< 2 >( io, names ); break;
         case 3: r = this->_GD0< 3 >( io, names ); break;
         case 4: r = this->_GD0< 4 >( io, names ); break;
@@ -283,9 +269,6 @@ _GD0( itk::ImageIOBase* io, const TStringList& names )
   {
     switch( D )
     {
-    case 1:
-      r = this->_RealGD< itk::Offset< 1 >, 1 >( names );
-      break;
     case 2:
       r = this->_RealGD< itk::Offset< 2 >, 2 >( names );
       break;
@@ -383,6 +366,21 @@ _GD0( itk::ImageIOBase* io, const TStringList& names )
         break;
       } // hctiws
     }
+    else if( D == 4 )
+    {
+      switch( ct )
+      {
+      case itk::ImageIOBase::FLOAT:
+        r = this->_RealGD< itk::DiffusionTensor3D< float >, 4 >( names );
+        break;
+      case itk::ImageIOBase::DOUBLE:
+        r = this->_RealGD< itk::DiffusionTensor3D< double >, 4 >( names );
+        break;
+      default:
+        r = "ImageReader: Diffusion tensor type not supported.";
+        break;
+      } // hctiws
+    }
     else
       r = "ImageReader: Diffusion tensor dimension not supported.";
   }
@@ -436,12 +434,22 @@ _RealGD( const TStringList& names )
     try
     {
       reader->Update( );
-      this->m_Outputs[ 0 ]->SetITKDataObject( reader->GetOutput( ) );
+      cpPlugins::Interface::Image* out =
+        this->_Output< cpPlugins::Interface::Image >( 0 );
+      if( out != NULL )
+        out->SetITKImage< _I >( reader->GetOutput( ) );
+      else
+        r = "ImageReader: output not correctly created.";
     }
     catch( itk::ExceptionObject& err )
     {
       r = "ImageReader: " + std::string( err.GetDescription( ) );
-      this->m_Outputs[ 0 ]->SetITKDataObject( NULL );
+      cpPlugins::Interface::Image* out =
+        this->_Output< cpPlugins::Interface::Image >( 0 );
+      if( out != NULL )
+        out->SetITKImage< _I >( NULL );
+      else
+        r = "ImageReader: output not correctly created.";
 
     } // yrt
   }
@@ -468,12 +476,22 @@ _RealGD( const TStringList& names )
     try
     {
       reader->Update( );
-      this->m_Outputs[ 0 ]->SetITKDataObject( reader->GetOutput( ) );
+      cpPlugins::Interface::Image* out =
+        this->_Output< cpPlugins::Interface::Image >( 0 );
+      if( out != NULL )
+        out->SetITKImage< _I >( reader->GetOutput( ) );
+      else
+        r = "ImageReader: output not correctly created.";
     }
     catch( itk::ExceptionObject& err )
     {
       r = "ImageReader: " + std::string( err.GetDescription( ) );
-      this->m_Outputs[ 0 ]->SetITKDataObject( NULL );
+      cpPlugins::Interface::Image* out =
+        this->_Output< cpPlugins::Interface::Image >( 0 );
+      if( out != NULL )
+        out->SetITKImage< _I >( NULL );
+      else
+        r = "ImageReader: output not correctly created.";
 
     } // yrt
   }