[vtkusers] Can not change the color of dataset.

公维学 weixuegong at gmail.com
Sun Jul 13 10:03:41 EDT 2014


Now I have an vtkDataSet object from a reader.I had tried to change the
color of the output of vtkDataSetReader(not set the color of actor), but
had no idea.

The reason is that I want to write the dataset back to hard disk with the
new color.

I could get the number of cells in this dataset, and when I tried to get
the scalars and modify the scalars(it holds the color, am I right), it
crushed.
    this->reader->Update();
    vtkDataSet* ds = reader->GetOutput();
    vtkCellData* cellData = ds->GetCellData();
    vtkDataArray* scalars = cellData->GetScalars();
    int size = scalars->GetSize();//equals to the number of cells in
dataset?
    //then we can  modify scalars...


I am not sure if it is the right way, and I googled it, but found nothing
helpful,

The vtk file was converted from vrml.and it has about 332 points, 110
lines, 102 polygons,and I found in this file there were:
POINT_DATA 332
COLOR_SCALARS VRMLColor 3

So, could any one give me some tips?
Any advice would be appreciated!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140713/200e1eef/attachment.html>


More information about the vtkusers mailing list