]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Image.hxx
...
[cpPlugins.git] / lib / cpPlugins / Interface / Image.hxx
index 2f5f1d59a5071adee381adc82ef18361ad95d9fd..ab2c5ea00c9b6399ce0afa635dd1bba997b50805 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef __CPPLUGINS__INTERFACE__IMAGE__HXX__
 #define __CPPLUGINS__INTERFACE__IMAGE__HXX__
 
-#include <cpPlugins/Interface/Macros.h>
-
 #include <complex>
 
 #include <itkImage.h>
@@ -50,9 +48,16 @@ SetITK( itk::Object* object )
     this->m_VTKObject = NULL;
     this->m_ITKvVTKConnection = NULL;
     this->Modified( );
+    return;
 
   } // fi
 
+  // --------- TODO ---------------
+  typename I::DirectionType norm_dir;
+  norm_dir.SetIdentity( );
+  image->SetDirection( norm_dir );
+  // --------- TODO ---------------
+
   // Connect it to VTK
   cpPlugins_VTKImage_Demangle_AllDims( I, char, image );
   else cpPlugins_VTKImage_Demangle_AllDims( I, short, image );
@@ -112,21 +117,28 @@ void cpPlugins::Interface::Image::
 _ITK_2_VTK( itk::Object* object )
 {
   typedef itk::Image< P, D > _I;
+  typedef itk::ImageToVTKImageFilter< _I > _I2Vtk;
 
-  // Check if input object has the desired type
+  // Check (yes, again!!!) if input object has the desired type
   _I* image = dynamic_cast< _I* >( object );
   if( image == NULL )
     return;
 
   // Connect it to VTK
-  typename itk::ImageToVTKImageFilter< _I >::Pointer f =
-    itk::ImageToVTKImageFilter< _I >::New( );
+  _I2Vtk* f =
+    dynamic_cast< _I2Vtk* >( this->m_ITKvVTKConnection.GetPointer( ) );
+  if( f == NULL )
+  {
+    typename _I2Vtk::Pointer nf = _I2Vtk::New( );
+    this->m_ITKvVTKConnection = nf;
+    f = nf.GetPointer( );
+
+  } // fi
   f->SetInput( image );
   f->Update( );
 
-  // Keep objects
+  // Keep object track
   this->m_VTKObject = f->GetOutput( );
-  this->m_ITKvVTKConnection = f;
 }
 
 #ifndef cpPlugins_Interface_EXPORTS