[vtkusers] AddArray() to polydata
David E DeMarle
dave.demarle at kitware.com
Tue Sep 28 22:03:27 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
It suspect polydata contains the array at this point in time.
> polydata->Update();
I suspect this call causes contour to update, replaces the contents of
polydata with new information, and getting rid of your array when it
does so.
>
> Yours,
> boon
> _______________________________________________
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list