[vtkusers] Traversing vtkPolyData returns incorrect number of points

Andrew Maclean andrew.amaclean at gmail.com
Wed May 25 22:12:48 EDT 2016


Hi David and Dan,

I had a little look at the data using Dan's python script.

Line 29 needs to be changed from:
points.InsertPoint(currentPointId, d.GetPoint(pointIds[i]))
to:
points.InsertPoint(currentPointId, d.GetPoint(i))

When this is done, out.vtp has the points that are not associated with the
cells in the original data in it.

Now, if you change line 28 to:
if pointIds[i] == 1 and i > 0:
This will select all points associated with the cells. The extra i > 0
condition is needed as point 0 in cell 0 lies way outside the boundary of
all the other points for some reason, yet is associated with a cell. This
one point has a value of: (0, 3.6e19, -5.2e27), whilst the dimensions of
the polygonal mesh are:
X-range: -195 to 193 (delta: 389)
Y-range: -45.2 to 242 (delta: 287)
Z-range: -583 to 362 (delta: 945)

This is a nice little script Dan for filtering out points not associated
with cells, I'll add it to my list of useful scripts, thanks.


Regards
   Andrew



>
> ---------- Forwarded message ----------
> From: David Edmunds <David.Edmunds at icr.ac.uk>
> To: Dan Lipsa <dan.lipsa at kitware.com>
> Cc: "vtkusers at vtk.org" <vtkusers at vtk.org>, David Edmunds <
> David.Edmunds at icr.ac.uk>
> Date: Wed, 25 May 2016 14:51:14 +0100
> Subject: Re: [vtkusers] Traversing vtkPolyData returns incorrect number of
> points
> 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.
>
>
> --
___________________________________________
Andrew J. P. Maclean

___________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160526/ce6ca684/attachment.html>


More information about the vtkusers mailing list