[vtkusers] Traversing vtkPolyData returns incorrect number of points

David Edmunds David.Edmunds at icr.ac.uk
Mon May 23 10:01:01 EDT 2016


Dear all,

I am traversing a vtkPolyData object which is read in from a file using vtkXMLPolyDataReader. I access the number of points in the vtkPolyData in two different ways, here is my source code:

  vtkSmartPointer<vtkXMLPolyDataReader> reader = vtkSmartPointer<vtkXMLPolyDataReader>::New();
  reader->SetFileName("/Users/dedmunds/Desktop/organ_Body.vtp");
  reader->Update();
  vtkSmartPointer<vtkPolyData> poly_data = reader->GetOutput();

  cout << "Number of points: " << poly_data->GetNumberOfPoints() << endl;

  int traversal_points = 0;
  for (int i=0; i<poly_data->GetNumberOfCells(); i++) {
    traversal_points += poly_data->GetCell(i)->GetNumberOfPoints();
  }
  cout << "Traversal number of points: " << traversal_points << endl;

Here is the output:

Number of points: 286402
Traversal number of points: 143204

Why do I get two different answers? The second number is approximately half the first. What am I doing wrong?

Thanks for your help,

Kind regards,

Dave 

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the addressee only.  If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer and network.


More information about the vtkusers mailing list