/*========================================================================= Program: bbtk Module: $RCSfile: bbitkvtkitkImage2vtkImageData.cxx,v $ Language: C++ Date: $Date: 2008/04/18 12:59:50 $ Version: $Revision: 1.2 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ /** * \file * \brief */ #ifdef _USE_ITK_ #ifdef _USE_VTK_ #include "bbitkvtkitkImage2vtkImageData.h" #include "bbitkvtkPackage.h" // VtkToItkConnection //#include "itkVTKImageToImageFilter.h" // ItkToVtkConnection #include "itkImageToVTKImageFilter.h" namespace bbitkvtk { BBTK_BLACK_BOX_IMPLEMENTATION(itkImage2vtkImageData,bbtk::AtomicBlackBox); BBTK_ADD_BLACK_BOX_TO_PACKAGE(itkvtk,itkImage2vtkImageData); void itkImage2vtkImageData::Convert() { bbtk::TypeInfo t = bbGetInputIn().type(); BBTK_TEMPLATE_ITK_IMAGE_SWITCH(t,Convert); } template void itkImage2vtkImageData::Convert() { bbtkDebugMessageInc("Core",9,"itkImage2vtkImageData<" <() <<">::Convert()"< VtkToItkConnection; typedef itk::ImageToVTKImageFilter< itkImageType > ItkToVtkConnection; try { typename ItkToVtkConnection::Pointer conv = ItkToVtkConnection::New(); conv->SetInput( this->bbGetInputIn().get() ); conv->Update(); vtkImageData* o = vtkImageData::New(); // o->SetReferenceCount(10); o->DeepCopy(conv->GetOutput()); // o->Print(std::cout); if (bbGetOutputOut()) bbGetOutputOut()->Delete(); bbSetOutputOut(o); } catch( itk::ExceptionObject & e) { bbtkError("itkImage2vtkImageData<" <() <<">::Convert() : "<