[Insight-users] ITK and VTK integration

Diego R. Medaglia diegomedaglia at terra.com.br
Mon Nov 7 09:12:48 EST 2005


Hi!
    I'm starting to work with integration between ITK and VTK, and I wrote a basic program, as follows:

#include "itkImageFileReader.h"
#include "itkRawImageIO.h"
#include "itkVTKImageExport.h"
#include "itkImage.h"

#include "vtkImageImport.h"
#include "vtkImageViewer.h"


int main( )
{
  
  
  typedef unsigned short      PixelType;
  const   unsigned int        Dimension = 2;

  typedef itk::Image< PixelType, Dimension >    ImageType;

  typedef itk::RawImageIO<PixelType, Dimension> IOType;

  typedef itk::ImageFileReader< ImageType >  ReaderType;
  typedef itk::VTKImageExport< ImageType >  ExporterType;
  
  
  ReaderType::Pointer reader = ReaderType::New();
  ExporterType::Pointer exporter = ExporterType::New();
  IOType::Pointer io = IOType::New();

  io->SetDimensions(0,64);
  io->SetDimensions(1,64);

  reader->SetImageIO( io );
  

  reader->SetFileName( "D:\\VTK\\VTKData\\Data\\headsq\\quarter.30" );
  
  exporter->SetInput( reader->GetOutput() );
  
  vtkImageImport *importer = vtkImageImport::New();
  vtkImageViewer *viewer = vtkImageViewer::New();

  importer->SetImportVoidPointer( exporter );
  viewer->SetInput(importer->GetOutput() );



  try 
    { 
    viewer->Render(); 
    } 
  catch( itk::ExceptionObject & err ) 
    { 
    std::cerr << "ExceptionObject caught !" << std::endl; 
    std::cerr << err << std::endl; 
    return EXIT_FAILURE;
    } 
  
  return EXIT_SUCCESS;
}


which just reads a raw image with ITK and passes it to VTK for visualisation. I get an unresolved external symbol error during compilation (VS .NET 2005) concerning the callback fuctions in VTKImageExportBase:

ITKtoVTK error LNK2001: unresolved external symbol "protected: virtual int __thiscall itk::VTKImageExportBase::PipelineModifiedCallback(void)" (?PipelineModifiedCallback at VTKImageExportBase@itk@@MAEHXZ)
ITKtoVTK error LNK2001: unresolved external symbol "protected: virtual void __thiscall itk::VTKImageExportBase::PrintSelf(class std::basic_ostream<char,struct std::char_traits<char> > &,class itk::Indent)const " (?PrintSelf at VTKImageExportBase@itk@@MBEXAAV?$basic_ostream at DU?$char_traits at D@std@@@std@@VIndent at 2@@Z)
ITKtoVTK error LNK2001: unresolved external symbol "protected: virtual void __thiscall itk::VTKImageExportBase::UpdateDataCallback(void)" (?UpdateDataCallback at VTKImageExportBase@itk@@MAEXXZ)
ITKtoVTK error LNK2001: unresolved external symbol "protected: virtual void __thiscall itk::VTKImageExportBase::UpdateInformationCallback(void)" (?UpdateInformationCallback at VTKImageExportBase@itk@@MAEXXZ)
ITKtoVTK error LNK2019: unresolved external symbol "protected: __thiscall itk::VTKImageExportBase::VTKImageExportBase(void)" (??0VTKImageExportBase at itk@@IAE at XZ) referenced in function "protected: __thiscall itk::VTKImageExport<class itk::Image<unsigned short,2> >::VTKImageExport<class itk::Image<unsigned short,2> >(void)" (??0?$VTKImageExport at V?$Image at G$01 at itk@@@itk@@IAE at XZ)

    Do I have to create those functions? From what I read in the docs, I think that these are passed to VTKImageImport, that sets them as its callbacks. Also, it seemed like an "include" error, but ITK's VTKImageExport header includes the VTKImageExportBase header file. 

CMakeLists.txt looks like this:

PROJECT(ITKtoVTK)

FIND_PACKAGE ( ITK)
IF ( ITK_FOUND)
INCLUDE( ${USE_ITK_FILE} )
ENDIF( ITK_FOUND)

FIND_PACKAGE ( VTK)
IF ( VTK_FOUND)
INCLUDE( ${USE_VTK_FILE} )
ENDIF( VTK_FOUND)

INCLUDE_DIRECTORIES(${C:\[CORRECT_PATH]\ITKtoVTK})

ADD_EXECUTABLE( ITKtoVTK ITKtoVTK.cxx)

TARGET_LINK_LIBRARIES (ITKtoVTK ITKCommon ITKIO vtkRendering vtkGraphics vtkHybrid vtkImaging vtkIO vtkCommon)

Am I missing some libraries?

    Thanks a lot for any help, Diego
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20051107/49325a7a/attachment.html


More information about the Insight-users mailing list