[vtkusers] error with GetNumberOfPoint in using vtkPoints

Ming Chao mingchao2005 at gmail.com
Sun Oct 12 18:52:11 EDT 2008


Recently I updated my VTK to Release 5.2.0. However, I encountered an error
when using the function GetNumberOfPoints in using vtkPoints. In the past
when I used a earlier version I didn't have this problem. My code remains
the same, but I got an error now. Any help would be appreciated.
The sample code is shown below:

#include "itkImage.h"

#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"

#include "vtkCellArray.h"
#include "vtkPoints.h"
#include "vtkPolyData.h"
#include "vtkPolyDataWriter.h"
#include "vtkPolyDataReader.h"
#include "vtkDoubleArray.h"
#include "vtkPointData.h"

#include <fstream>

// ------ end of header files  ------



const   unsigned int   Dimension = 3;
typedef float VectorComponentType;

typedef itk::Vector< VectorComponentType, Dimension >  VectorType;
typedef itk::Image< VectorType,  Dimension >  DeformationFieldType;
typedef itk::DeformationFieldSource< DeformationFieldType >
 DeformationSourceType;

typedef float PixelType;
typedef itk::Image< PixelType, Dimension >  ImageType;
//typedef itk::ImageFileReader<  ImageType >  ReaderType;
typedef itk::ImageFileWriter<  ImageType >  WriterType;

typedef itk::ImageFileReader< DeformationFieldType >
 DeformationFieldReaderType;

typedef itk::WarpImageFilter< ImageType, ImageType, DeformationFieldType >
FilterType;

typedef itk::LinearInterpolateImageFunction< ImageType, double >
InterpolaterType;

typedef itk::Point< double, Dimension> PointType;

//ReaderType::Pointer fixedReader;
WriterType::Pointer outputWriter;

DeformationFieldReaderType::Pointer  deformationFieldReader;

InterpolaterType::Pointer   interpolator;

//PointType point;

//---------------------------------------------------------------------------------------

int main( int argc, char * argv[] )
{

std::cout << " Starting....... " << std::endl;

if( argc < 1 ) {
std::cerr << "Missing Parameters " << std::endl;
std::cerr << "Usage: " << argv[0];
std::cerr << "fixedImage ";
std::cerr << "contour " << std::endl;
return 1;
}

outputWriter = WriterType::New();

interpolator    = InterpolaterType::New();

// read in the original contour
vtkPolyDataReader *contourReader = vtkPolyDataReader::New();
contourReader->SetFileName( argv[1] );

try {
contourReader->Update();
}
catch( itk::ExceptionObject & excp_poly ) {
std::cerr << "Exception thrown " << std::endl;
std::cerr << excp_poly << std::endl;
return EXIT_FAILURE;
}

vtkPolyData *poly = vtkPolyData::New();
poly->DeepCopy( contourReader->GetOutput() );
contourReader->Delete();

vtkPoints *points = poly->GetPoints();
 //vtkFloatArray *array =  vtkFloatArray::New();
//array->SetNumberOfComponents(3);

//return 0;

int NumberOfTotalPoints = points->GetNumberOfPoints();

std::cout << "total number of points = " << NumberOfTotalPoints <<
std::endl;



return 0;

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081012/9d62b2ba/attachment.htm>


More information about the vtkusers mailing list