[vtkusers] AddArray() to polydata
Eric E. Monson
emonson at cs.duke.edu
Wed Sep 29 09:11:51 EDT 2010
Hey Boon,
So, like Dave DeMarle is saying, you can move your AddArray() to after the Update call and that should help.
Another option you have, if you don't want to move the AddArray "out of the pipeline", is to use a vtkProgrammableAttributeDataFilter:
http://www.vtk.org/doc/nightly/html/classvtkProgrammableAttributeDataFilter.html
There are a few Tests linked from that page to show you some examples of how to use it, and one of them is in C++.
If you're really just adding an array to color by, you might instead be able to create a lookup table to map the scalars in your contoured data to the colors you want.
Good luck,
-Eric
------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group
On Sep 28, 2010, at 10:03 PM, David E DeMarle wrote:
> 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
>>
> _______________________________________________
> 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