<div dir="ltr">Recently I updated my VTK to Release <a href="http://5.2.0.">5.2.0.</a> 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. <div>
<br></div><div>The sample code is shown below:</div><div><br></div><div><div>#include "itkImage.h"</div><div><br></div><div>#include "itkImageFileReader.h"</div><div>#include "itkImageFileWriter.h"</div>
<div><br></div><div>#include "vtkCellArray.h"</div><div>#include "vtkPoints.h"</div><div>#include "vtkPolyData.h"</div><div>#include "vtkPolyDataWriter.h"</div><div>#include "vtkPolyDataReader.h"</div>
<div>#include "vtkDoubleArray.h"</div><div>#include "vtkPointData.h"</div><div><br></div><div>#include <fstream></div><div><br></div><div>// ------ end of header files ------</div><div><br></div>
<div><br></div><div><br></div><div>const unsigned int Dimension = 3;</div><div>typedef float VectorComponentType;</div><div><br></div><div>typedef itk::Vector< VectorComponentType, Dimension ><span class="Apple-tab-span" style="white-space:pre"> </span> VectorType;</div>
<div>typedef itk::Image< VectorType, Dimension ><span class="Apple-tab-span" style="white-space:pre"> </span> DeformationFieldType;</div><div>typedef itk::DeformationFieldSource< DeformationFieldType ><span class="Apple-tab-span" style="white-space:pre"> </span> DeformationSourceType;</div>
<div><br></div><div>typedef float PixelType;</div><div>typedef itk::Image< PixelType, Dimension ><span class="Apple-tab-span" style="white-space:pre"> </span> ImageType;</div><div>//typedef itk::ImageFileReader< ImageType ><span class="Apple-tab-span" style="white-space:pre"> </span> ReaderType;</div>
<div>typedef itk::ImageFileWriter< ImageType ><span class="Apple-tab-span" style="white-space:pre"> </span> WriterType;</div><div><br></div><div>typedef itk::ImageFileReader< DeformationFieldType > DeformationFieldReaderType;</div>
<div><br></div><div>typedef itk::WarpImageFilter< ImageType, ImageType, DeformationFieldType > FilterType;</div><div><br></div><div>typedef itk::LinearInterpolateImageFunction< ImageType, double > InterpolaterType;</div>
<div><br></div><div>typedef itk::Point< double, Dimension> PointType;</div><div><br></div><div>//ReaderType::Pointer<span class="Apple-tab-span" style="white-space:pre"> </span>fixedReader;</div><div>WriterType::Pointer<span class="Apple-tab-span" style="white-space:pre"> </span>outputWriter;</div>
<div><br></div><div>DeformationFieldReaderType::Pointer deformationFieldReader;</div><div><br></div><div>InterpolaterType::Pointer interpolator;</div><div><br></div><div>//PointType point;</div><div><br></div><div>//---------------------------------------------------------------------------------------</div>
<div><br></div><div>int main( int argc, char * argv[] )</div><div>{</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>std::cout << " Starting....... " << std::endl;</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>if( argc < 1 ) {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>std::cerr << "Missing Parameters " << std::endl;</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>std::cerr << "Usage: " << argv[0];</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>std::cerr << "fixedImage ";</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>std::cerr << "contour " << std::endl;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>return 1;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>outputWriter<span class="Apple-tab-span" style="white-space:pre"> </span>= WriterType::New();</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>interpolator = InterpolaterType::New();</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>// read in the original contour</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>vtkPolyDataReader *contourReader = vtkPolyDataReader::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>contourReader->SetFileName( argv[1] );</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>contourReader->Update();</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>catch( itk::ExceptionObject & excp_poly ) {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>std::cerr << "Exception thrown " << std::endl;</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>std::cerr << excp_poly << std::endl;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>return EXIT_FAILURE;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>vtkPolyData *poly = vtkPolyData::New();</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>poly->DeepCopy( contourReader->GetOutput() );</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>contourReader->Delete();</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>vtkPoints *points = poly->GetPoints();</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>//vtkFloatArray *array = vtkFloatArray::New();</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>//array->SetNumberOfComponents(3);</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>//return 0;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>int NumberOfTotalPoints = points->GetNumberOfPoints();</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>std::cout << "total number of points = " << NumberOfTotalPoints << std::endl;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span></div>
<div><br></div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>return 0;</div><div><br></div><div>}</div></div></div>