]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Image.hxx
...
[cpPlugins.git] / lib / cpPlugins / Interface / Image.hxx
index 8c31dca4c7e6acc0caf11e6842a16168871b6037..ab2c5ea00c9b6399ce0afa635dd1bba997b50805 100644 (file)
@@ -48,6 +48,7 @@ SetITK( itk::Object* object )
     this->m_VTKObject = NULL;
     this->m_ITKvVTKConnection = NULL;
     this->Modified( );
+    return;
 
   } // fi
 
@@ -116,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