[vtkusers] AddArray() to polydata
David Doria
daviddoria at gmail.com
Tue Sep 28 21:53:13 EDT 2010
On Tue, Sep 28, 2010 at 8:39 PM, ChiaWeng Boon <chiaweng at gmail.com> wrote:
> Hi,
>
> My AddArray() to this polydata does not work. I tried also
> GetCellData()->SetScalars(speed). The array/variable speed is not
> present! Can someone tell me why?
>
> /* vtksamplefunction before this */
> vtkContourFilter *contours = vtkContourFilter::New();
> contours->SetInput(sample->GetOutput());
> contours->GenerateValues(1,-0.01, 0.01);
> vtkSmartPointer<vtkPolyData> polydata =
> vtkSmartPointer<vtkPolyData>::New();
> polydata = contours->GetOutput();
> vtkSmartPointer<vtkUnsignedCharArray> speed =
> vtkSmartPointer<vtkUnsignedCharArray>::New();
> speed->SetName("pbColors");
> vtkIdType nbCells=polydata->GetNumberOfPoints();
> for (int i=0;i<nbCells;i++){
> speed->InsertNextValue(2);
> }
> polydata->GetPointData()->AddArray(speed); // HELP HELP
> polydata->Update();
>
> Yours,
> boon
>
>
How have you tried to access it when you decided it didn't exist? You have
named it "pbColors" :
speed->SetName("pbColors");
so it should show up as that if you're looking at it in Paraview or trying
to access it by name.
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100928/fd21f035/attachment.htm>
More information about the vtkusers
mailing list