[Insight-users] A problem of VTK+ITK

Xuelin Cui xuelin at hawaii.edu
Fri Jun 10 04:43:04 EDT 2005


Hi:

When I run a small demo copy from Getting Started II, I got a problem.

here is my source code:

#include "itkImage.h"
#include <iostream>
#include "itkImageFileReader.h"
#include "itkImageToVTKImageFilter.h"
#include "vtkImageViewer.h"
#include "vtkRenderWindowInteractor.h"

int main(int argc, char **argv)
{
	typedef itk::Image<unsigned short,2> ImageType;
	typedef itk::ImageFileReader<ImageType> ReaderType;
	typedef itk::ImageToVTKImageFilter<ImageType> ConnectorType;

	ReaderType::Pointer reader= ReaderType::New();
	ConnectorType::Pointer connector= ConnectorType::New();

	//reader->SetFileName( argv[1]);
	//reader->SetImageIO(vtkIO);
	reader->SetFileName( "G:\VTK\VTK_Source\VTKData-release-4-2
\Data\blowGeom.vtk");

	try 
	{
        reader->Update();
    }
    catch( itk::ExceptionObject & exp )
    {
        std::cerr << "Exception caught" << std::endl;
        std::cerr << exp << std::endl;
    }
 
    std::cout << reader << std::endl;

	connector->SetInput( reader->GetOutput() );

	vtkImageViewer* viewer= vtkImageViewer::New();
	vtkRenderWindowInteractor* renderWindowInteractor=
	vtkRenderWindowInteractor::New();


	viewer->SetupInteractor( renderWindowInteractor);
	viewer->SetInput( connector->GetOutput() );
	viewer->Render();
	viewer->SetColorWindow( 255);
	viewer->SetColorLevel( 128);

	renderWindowInteractor->Start();

	return 0;

}


But, when I run the exe file, a error alway occur. I use F10 to watch 
step by step, and I found the error occurs at "viewer->Render();"

Can anyone tell me what is wrong with it, and how to debug it?  

Many thanks


Xuelin




Department of Mechanical Engineering
University of Hawaii at Manoa
2540 Dole St
Honolulu HI 96822
United States



More information about the Insight-users mailing list