[vtk-developers] Interesting problem building a vtkLookupTable from vtkColorSeries.

Andrew Maclean andrew.amaclean at gmail.com
Sun Jul 20 20:23:52 EDT 2014


Just to add to this, I get the same result in C++.


On Sun, Jul 20, 2014 at 5:21 PM, Andrew Maclean <andrew.amaclean at gmail.com>
wrote:

> I wanted to generate a lookup table from vtkCOlor series using
> BuildLookupTable().
> However the only way I can do it is to create a second lookup table and
> copy from the first to the second one.
> I thought I could do this:
>     colorSeries = vtk.vtkColorSeries()
>     colorSeriesEnum = colorSeries.BREWER_DIVERGING_BROWN_BLUE_GREEN_10
>     colorSeries.SetColorScheme(colorSeriesEnum)
>     lut = vtk.vtkLookupTable()
>     colorSeries.BuildLookupTable(lut)
>
> But I have to do this:
>     colorSeries = vtk.vtkColorSeries()
>     colorSeriesEnum = colorSeries.BREWER_DIVERGING_BROWN_BLUE_GREEN_10
>     colorSeries.SetColorScheme(colorSeriesEnum)
>     lut1 = vtk.vtkLookupTable()
>     colorSeries.BuildLookupTable(lut1)
>     lut = vtk.vtkLookupTable()
>     lut.SetNumberOfTableValues(lut1.GetNumberOfTableValues())
>     for i in range(0,lut1.GetNumberOfTableValues()):
>         lut.SetTableValue(i,lut1.GetTableValue(i))
>
> In looking at the code in vtkColorSeries.cxx, namely:
>
> //-----------------------------------------------------------------------------
> void vtkColorSeries::BuildLookupTable(vtkLookupTable* lkup)
> {
>   if (lkup)
>     {
>     lkup->SetNumberOfTableValues(this->GetNumberOfColors());
>     lkup->IndexedLookupOn();
>     for (int i = 0; i < this->GetNumberOfColors(); ++i)
>       {
>       vtkColor3ub colr = this->GetColor(i);
>       lkup->SetTableValue(
>         i, colr.GetRed()/255., colr.GetGreen()/255., colr.GetBlue()/255.,
> 1.);
>       }
>     }
> }
> It seems lkup is built correctly.
>
> I can't see any reason for building and then copying to a new table.
>
> I would appreciate it if anyone could point out what I am missing.
>
> I have also attached a Python script that illustrates this.
>
> Regards
>    Andrew
> --
> ___________________________________________
> Andrew J. P. Maclean
>
> ___________________________________________
>



-- 
___________________________________________
Andrew J. P. Maclean

___________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20140721/8885ce17/attachment-0002.html>


More information about the vtk-developers mailing list