1 /*=========================================================================
4 Module: $RCSfile: bbitkvtkitkImage2vtkImageData.cxx,v $
6 Date: $Date: 2008/03/03 11:49:17 $
7 Version: $Revision: 1.1 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
25 #include "bbitkvtkitkImage2vtkImageData.h"
26 #include "bbitkvtkPackage.h"
28 //#include "itkVTKImageToImageFilter.h"
30 #include "itkImageToVTKImageFilter.h"
35 BBTK_USER_BLACK_BOX_IMPLEMENTATION(itkImage2vtkImageData,bbtk::AtomicBlackBox);
37 BBTK_ADD_BLACK_BOX_TO_PACKAGE(itkvtk,itkImage2vtkImageData);
42 void itkImage2vtkImageData::Convert()
44 bbtk::TypeInfo t = bbGetInputIn().type();
45 BBTK_TEMPLATE_ITK_IMAGE_SWITCH(t,Convert);
51 void itkImage2vtkImageData::Convert()
53 bbtkDebugMessageInc("Core",9,"itkImage2vtkImageData<"
55 <<">::Convert()"<<std::endl);
57 typedef T itkImageType;
58 // typedef itk::VTKImageToImageFilter< itkImageType > VtkToItkConnection;
59 typedef itk::ImageToVTKImageFilter< itkImageType > ItkToVtkConnection;
64 typename ItkToVtkConnection::Pointer conv = ItkToVtkConnection::New();
65 conv->SetInput( this->bbGetInputIn().get<itkImageType*>() );
67 vtkImageData* o = vtkImageData::New();
68 // o->SetReferenceCount(10);
69 o->DeepCopy(conv->GetOutput());
71 // o->Print(std::cout);
72 if (bbGetOutputOut()) bbGetOutputOut()->Delete();
75 catch( itk::ExceptionObject & e)
77 bbtkError("itkImage2vtkImageData<"
79 <<">::Convert() : "<<e);
84 bbtkDebugDecTab("Core",9);
90 // eo namespace bbitkvtk