[vtkusers] Setting specific colors to vtkPolyData

Miri Trope miritrope at gmail.com
Sun Jan 8 17:08:05 EST 2012


Hi David,

Thank you for your answer.
Regarding my previous questions, I tried some new manipulations and came
with results:

*First, regarding the writing of vtkPolyData with its scalars:
  I tried to use this filter with the following code:

  vtkSmartPointer<vtkXMLPolyDataWriter> writerXML =
    vtkSmartPointer<vtkXMLPolyDataWriter>::New();

  writerXML->SetFileName("Colored_Surface.vtp");

  writerXML->SetInput(surfacePolyData);

  writerXML->Write();

  But It's only writing the polyData without its scalars/colors.
  What have I missed?

*Second, regarding the look up table: I simply used the following code and
got the right results, but I'm still searching for a way to get a variety
from the same color in each range (for example, in the i'th table which I
set to red, I'd like to get lighter/darker color due to its value in the
range).

  vtkSmartPointer<vtkLookupTable> lut =
vtkSmartPointer<vtkLookupTable>::New();

  lut->SetNumberOfTableValues(3); // I need only three colors

  lut->Build();

  lut->SetTableValue(0,0,1,0);

  lut->SetTableValue(1,1,1,0);

  lut->SetTableValue(2,1,0,0);

  myVtkFloatArray->SetLookupTable(lut);


Any help would be very appreciated!
Regards,
Miri


On Sun, Jan 8, 2012 at 9:44 PM, David Doria <daviddoria at gmail.com> wrote:

> On Sun, Jan 8, 2012 at 2:15 PM, Miri Trope <miritrope at gmail.com> wrote:
> > Hi Again,
> >
> > In addition,
> > I'd like to ask about vtkPolyDataWriter:
> > I set scalars on vtkPolyData and would like to save both the vtkPolyData
> > with his scalars (it means that I'd like to save the colored surface).
> >
> > How should I do this?
>
> You should probably be using vtkXMLPolyDataWriter to write a .vtp
> file. Use Paraview (paraview.org) to inspect the result - the
> PointData, CellData, and FieldData
> (http://www.vtk.org/Wiki/VTK/Tutorials/DataStorage) should
> automatically be saved to the file.
>
> David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120109/4b3a43fd/attachment.htm>


More information about the vtkusers mailing list