[vtk-developers] Interesting problem building a vtkLookupTable from vtkColorSeries.
Andrew Maclean
andrew.amaclean at gmail.com
Sun Jul 20 03:21:03 EDT 2014
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
___________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20140720/6862566e/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ColorSeries.zip
Type: application/zip
Size: 1344 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20140720/6862566e/attachment-0001.zip>
More information about the vtk-developers
mailing list