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

**URL:** <https://discourse.slicer.org/t/vtklookuptable-bad-table-range-0-1/8718>\
**Category:** Development\
**Created:** [October 9, 2019, 1:51pm UTC](https://discourse.slicer.org/t/vtklookuptable-bad-table-range-0-1/8718 "2019-10-09T13:51:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danial](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/danial/32/4888_2.png) [@danial](https://discourse.slicer.org/u/danial)\
**Post date:** [October 9, 2019, 1:51pm UTC](https://discourse.slicer.org/t/vtklookuptable-bad-table-range-0-1/8718/1 "2019-10-09T13:51:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 9, 2019, 3:24pm UTC](https://discourse.slicer.org/t/vtklookuptable-bad-table-range-0-1/8718/3 "2019-10-09T15:24:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![danial](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/danial/32/4888_2.png) [@danial](https://discourse.slicer.org/u/danial)\
**Post date:** [October 9, 2019, 3:57pm UTC](https://discourse.slicer.org/t/vtklookuptable-bad-table-range-0-1/8718/4 "2019-10-09T15:57:15Z")

</div>

Thank you for this solution.
