[vtkusers] Traversing vtkPolyData returns incorrect number of points

Dan Lipsa dan.lipsa at kitware.com
Wed May 25 11:22:33 EDT 2016


Dave,
There are many points that are not part of any cell. They have a large
value (0, 3.69e+19, -5.2e+27) or they are nan.
Here is a script that writes a poly data with all the points that are part
of any cell. You can load that in ParaView and see the range of values.

On Wed, May 25, 2016 at 9:51 AM, David Edmunds <David.Edmunds at icr.ac.uk>
wrote:

> Hi,
>
> Sorry for the late reply but I couldn’t send attachments to the mailing
> list. My input file can be found at http://www.filedropper.com/organbody.
>
> Kind regards,
>
> Dave
>
> On 23 May 2016, at 18:20, Dan Lipsa <dan.lipsa at kitware.com> wrote:
>
> 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.
>>
>
>
>
> 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/20160525/6ece3645/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: points.py
Type: text/x-python
Size: 1111 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160525/6ece3645/attachment.py>


More information about the vtkusers mailing list