[vtkusers] Setting specific colors to vtkPolyData
Miri Trope
miritrope at gmail.com
Thu Jan 12 02:47:16 EST 2012
Hi David,
I'd like to get a colored surface with three colors like a traffic light:
green - (which represents low values)
orange - (which represents middle values)
red - (which represents high values)
each of those values should get its brightness due to the value its range.
for example:
lets say that my vtkFloatArray consists of six elements s.t.:
[5,2,1,6,4,1]
-divide the elements to three groups and normalized each value s.t:
lighter (LI) color x {green,orange,red}
stronger (ST) color x { " }
[LI red, ST green, LI green, ST red, ST orange, LI green]
Hope that now my question is clearer.
Thanks in advance :-)
On Mon, Jan 9, 2012 at 12:12 AM, David Doria <daviddoria at gmail.com> wrote:
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120112/f8726f37/attachment.htm>
More information about the vtkusers
mailing list