[vtkusers] Difference between AddArray, SetScalars, SetVectors

David Doria daviddoria+vtk at gmail.com
Thu Oct 22 15:42:53 EDT 2009


To attach colors to points in a polydata, which one of these should I use?

  vtkSmartPointer<vtkUnsignedCharArray> Colors =
vtkSmartPointer<vtkUnsignedCharArray>::New();
  Colors->SetNumberOfComponents ( 3 );
  Colors->SetName ( "RGB" );

1) polydata->GetPointData()->SetScalars ( Colors ); - this one seems
to be the most "paraview compatible", as the colors are automatically
applied without having to go to "Display -> Color by -> RGB" as you do
if you use the following two
2) polydata->GetCellData()->SetVectors ( Colors );
3) polydata->GetCellData()->AddArray(Colors);

This is not scalar data (they are triples):

unsigned char Red[3] = {255, 0, 0};
Colors->InsertNextTupleValue ( Red );

so I don't even understand why this one would work (and it is the "best")?

Can anyone explain what is actually going on with these functions?

Thanks,

David



More information about the vtkusers mailing list