[vtk-developers] Interesting problem building a vtkLookupTable from vtkColorSeries.
Andrew Maclean
andrew.amaclean at gmail.com
Mon Jul 21 01:08:49 EDT 2014
I have found the problem. It lies in line 576 of vtkColorSeries.cxx:
lkup->IndexedLookupOn();
in vtkColorSeries.cxx.
This means that any lookup table has this set when returned from
BuildLookupTable() or CreateLookupTable()
The default value is off so this behaviour is unexpected.
I am wondering whether this line should be removed and the tests should
explicitly set this when needed.
If this is too much then an alternative would be to add a comment.
Any comments?
I'll do any changes and test them.
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/fda50733/attachment-0002.html>
More information about the vtk-developers
mailing list