[vtk-developers] Interesting problem building a vtkLookupTable from vtkColorSeries.
David Thompson
david.thompson at kitware.com
Mon Jul 21 08:03:47 EDT 2014
Hi Andrew,
Have you tried IndexedLookupOff, i.e.
lut = vtk.vtkLookupTable()
colorSeries.BuildLookupTable(lut)
lut.IndexedLookupOff()
on the first lookup table?
David
On Jul 20, 2014, at 1:21, 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
>
> ___________________________________________
> <ColorSeries.zip>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtk-developers
>
More information about the vtk-developers
mailing list