[vtkusers] VTK slow to display 300 vtkArrowSource in real-time
David Lonie
david.lonie at kitware.com
Mon Oct 17 11:20:06 EDT 2016
I spot an issue with the vtkPoints setup:
> int num_pts = 10;
>
> vtkPoints *ptsText = vtkPoints::New();
> ptsText->SetNumberOfPoints(num_pts);
>
> for (int i = 1; i < num_pts; i++)
> {
> ptsText->InsertNextPoint(i, 0, 0);
> }
>
SetNumberOfPoints resizes the array to hold 10 points, and then the loop
appends an additional 10 points, so ptsText now contains 20 points, with
the first 10 containing uninitialized memory. Try using SetPoint instead of
InsertNextPoint.
> vtkStringArray *strings = vtkStringArray::New();
> strings->SetNumberOfValues(num_pts);
> strings->SetName("labels");
> for (int i = 1; i < 5; i++)
> {
> strings->InsertNextValue("bob");
> }
> for (int i = 5; i < 10; i++)
> {
> strings->InsertNextValue("bob2");
> }
>
Same here.
Looks like this is also wrong (my bad, I told you to do this earlier :P):
polydata->GetFieldData()->AddArray(strings);
>
Despite the method name referring to FieldData, I just checked the
implementation and it's actually looking in the PointData for the label
array. Change this line to:
polydata->GetPointData()->AddArray(strings);
and I think you'll have it.
HTH,
Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161017/25a48541/attachment.html>
More information about the vtkusers
mailing list