[vtkusers] GetNumberOfPoints error when using vtkPoints

David Cole david.cole at kitware.com
Mon Oct 13 11:37:33 EDT 2008


What input data do you pass to this code?
What is the error message you get?
What is the number of points reported? What is the number you expect?


On Mon, Oct 13, 2008 at 11:23 AM, Ming Chao <mingchao2005 at gmail.com> wrote:

> 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;
>
> }
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081013/3c9aea17/attachment.htm>


More information about the vtkusers mailing list