<div dir="ltr"><div><div><div>Hi everibody, I found the example TestColorByCellDataStringArray.cxx that creates a categorical LookupTable using vtkDiscretizableColorTransferFunction. I had to switch the IndexedColor flag on and provide the colors using the SetIndexedColor(value, annotation) method, where value is a vtkVariant object containing the current celldata's unsigned short id (this is the type of data that I am storing in the cells) and annotation is a vtkStdString.<br></div>It worked fine. I am appending the code in case anybody need the same feature.<br></div> <br> Thank you,<br><br></div>Luca Pallozzi Lavorante <br><br><p>// This is an example</p><p>
std::vetor<uint32> listIds = {3, 5, 6, 7, 8};</p><p>
table = vtkSmartPointer<vtkDiscretizableColorTransferFunction>::New();
table->IndexedLookupOn();
</p><p> table->SetNumberOfIndexedColors(listIds.size());</p><p>size_t colorIndex = 0;<br>
</p><p>foreach (uint32 id, listaIds) {
</p><p> QColor color(myFunctionTogetColorsFromIds(id));</p> vtkVariant value(static_cast<unsigned short>(id));<br><p> vtkStdString annotation (nameOfMyId());<br><br> table->SetIndexedColor(colorIndex, color.redF(), color.greenF(), color.blueF());<br> table->SetAnnotation(value, annotation);<br> colorIndex++;<br>}</p><p>// table->Build(); // This was not necessary
</p><br></div>