[vtkusers] Traversing vtkPolyData returns incorrect number of points
Dan Lipsa
dan.lipsa at kitware.com
Mon May 23 13:20:59 EDT 2016
I see,
Well, in this case, you may have points that are not part of any cells. Can
you share your data file?
On Mon, May 23, 2016 at 12:16 PM, David Edmunds <David.Edmunds at icr.ac.uk>
wrote:
> Hi Dan,
>
> Thanks, but I actually get a much smaller number when I count all the
> points from cells. Also, in my input dataset the cells are disjoint, i.e.
> no points are shared between multiple cells.
>
> Kind regards,
>
> Dave
>
> On 23 May 2016, at 16:51, Dan Lipsa <dan.lipsa at kitware.com> wrote:
>
> Hi David,
> You have shared points between cells so it is normal you'll get a bigger
> number when you count all the points from cells.
>
> On Mon, May 23, 2016 at 10:01 AM, David Edmunds <David.Edmunds at icr.ac.uk>
> wrote:
>
>> 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.
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>
>
>
> 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160523/259f2c55/attachment.html>
More information about the vtkusers
mailing list