[vtkusers] Setting specific colors to vtkPolyData

David Doria daviddoria at gmail.com
Sun Jan 8 17:12:07 EST 2012


On Sun, Jan 8, 2012 at 5:08 PM, Miri Trope <miritrope at gmail.com> wrote:
> 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

I think you'll still need to explain your second question more clearly
- prehaps give more concrete examples (specific values that you want
mapped to specific colors, and then then recoloring you're trying to
describe).

For the first question, you must not have attached the colors properly
to surfacePolyData. Ideally please post fully compilable code with no
external dependencies. If you can't do that for some reason, at least
show us the way you are setting up the polydata. In you original post
the variable was called mySurface - could that be the problem?

David



More information about the vtkusers mailing list