From 35ad6a2af5b7b0f93d342f7d10d5d669e92ca6d5 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Thu, 26 Nov 2015 09:43:12 -0500 Subject: [PATCH] Interactive filters synchronization debugged --- lib/cpPlugins/Interface/Image.hxx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/cpPlugins/Interface/Image.hxx b/lib/cpPlugins/Interface/Image.hxx index 8c31dca..5b675b2 100644 --- a/lib/cpPlugins/Interface/Image.hxx +++ b/lib/cpPlugins/Interface/Image.hxx @@ -116,6 +116,7 @@ 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 _I* image = dynamic_cast< _I* >( object ); @@ -123,14 +124,20 @@ _ITK_2_VTK( itk::Object* object ) 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 -- 2.47.1