vtkLookUpTable. Bad table range: [0, -1]

Operating system: macOS 10.14.6
Slicer version: 4.10.2

Hello,

I used a vtkLookUpTable to color a vtkPolyData like this :

vtkSmartPointer<vtkPolyData> surface = m_optimizations.at(i).m_map->getShape();

 // set the lookup table (allows to draw each vertex with its own color, according to the table of values resulting from the occlusion filter)
 vtkLookupTable *vtkLUT = vtkLookupTable::New();
 vtkLUT->SetTableRange(0.0, 255.0);
 vtkLUT->SetNumberOfTableValues(26);
 vtkLUT->SetTableValue(0, 0.0, 0.5, 1.0, 1); // blue
 vtkLUT->SetTableValue(1, 0.0, 0.8, 0.5, 1); // green
 vtkLUT->SetTableValue(2, 0.0, 1.0, 0.0, 1); // green
 vtkLUT->SetTableValue(3, 0.0, 1.0, 0.0, 1); // green
 vtkLUT->SetTableValue(4, 0.2, 1.0, 0.0, 1); // green-yellow
 vtkLUT->SetTableValue(5, 0.2, 1.0, 0.0, 1); // green-yellow
 vtkLUT->SetTableValue(6, 0.5, 1.0, 0.0, 1); // yellow-green
 vtkLUT->SetTableValue(7, 0.8, 1.0, 0.0, 1); // yellow-green
 vtkLUT->SetTableValue(8, 0.5, 1.0, 0.0, 1); // yellow-green
 vtkLUT->SetTableValue(9, 0.8, 1.0, 0.0, 1); // yellow-green
 vtkLUT->SetTableValue(10, 1.0, 1.0, 0.0, 1); // yellow
 vtkLUT->SetTableValue(11, 1.0, 1.0, 0.0, 1); // yellow
 vtkLUT->SetTableValue(12, 1.0, 0.8, 0.3, 1); // yellow-orange
 vtkLUT->SetTableValue(13, 1.0, 0.8, 0.3, 1); // yellow-orange
 vtkLUT->SetTableValue(14, 1.0, 0.5, 0.0, 1); // orange
 vtkLUT->SetTableValue(15, 1.0, 0.5, 0.0, 1); // orange
 vtkLUT->SetTableValue(16, 1.0, 0.2, 0.0, 1); // dark orange
 vtkLUT->SetTableValue(17, 1.0, 0.2, 0.0, 1); // dark orange
 vtkLUT->SetTableValue(18, 1.0, 0.0, 0.0, 1); // red
 vtkLUT->SetTableValue(19, 1.0, 0.0, 0.0, 1); // red
 vtkLUT->SetTableValue(20, 1.0, 0.0, 0.0, 1); // red
 vtkLUT->SetTableValue(21, 1.0, 0.0, 0.0, 1); // red
 vtkLUT->SetTableValue(22, 1.0, 0.0, 0.0, 1); // red
 vtkLUT->SetTableValue(23, 1.0, 0.0, 0.0, 1); // red
 vtkLUT->SetTableValue(24, 1.0, 0.0, 0.0, 1); // red
 vtkLUT->SetTableValue(25, 1.0, 0.0, 0.0, 1); // red
 vtkLUT->Build();

 surface->GetPointData()->GetScalars()->SetLookupTable(vtkLUT);

But this message is appeared regularly :

Bad table range: [0, -1]

Can you help me to solve this problem, please ?

Thank you.

Why do you do this? What would you like to achieve? Normally in Slicer you use MRML color node to set up color mapping for models.

1 Like

Thank you for this solution.

1 Like