Advantage of adding annotations to a look up table?

Hi VTKers,
I’m trying to use VTK to visualize some data with a categorical color map in C# and am having some issues adding annotations to the look up table. I can work around the issues by setting the table indexing to ORDINAL and ignoring the annotations. Is there any disadvantage to doing this?
much thanks,

Hi, David,

Annotations work just fine for me, though it is not obvious make it work as expected:

vtkSmartPointer<vtkLookupTable> View3dColorTables::getCategoricalColorTable( CategoryDefinition *cd, bool useGSLibColors )
    int catCount = cd->getCategoryCount();

    //determine the greatest categorical code
    int maxCatCode = 0;
    for( int i = 0; i < catCount; ++i )
        maxCatCode = std::max<int>( maxCatCode, cd->getCategoryCode(i) );

    //table color indexes must go from 0 to greatest facies code, without skipping values
    size_t tableSize = maxCatCode + 1;
    vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();

    //but assign only the codes defined in the category definition
    //which may be less than the total number of entries in the color table
    //this is a requirement by the way VTK's LUT work for categorical color tables
    for(size_t i = 0; i < tableSize; ++i)
        if( cd->codeExists( i ) ){
            double rgb[3];
            QColor color;
            int catIndex = cd->getCategoryIndex( i );
            if( useGSLibColors )
                color = Util::getGSLibColor( cd->getColorCode( catIndex ) );
                color = cd->getCustomColor( catIndex );
            rgb[0] = color.redF();
            rgb[1] = color.greenF();
            rgb[2] = color.blueF();
            lut->SetTableValue(i, rgb[0], rgb[1], rgb[2], 1.0);
            lut->SetAnnotation(i, QString::number(i).toStdString() );
        } else {
            lut->SetTableValue(i, 1.0, 0.0, 1.0, 0.3); //ilegal color codes are rendered as pink 70% transparent.
            lut->SetAnnotation(i, "UNKNOWN CATEGORY" );
    lut->SetNanColor( 1.0, 0.0, 1.0, 0.3 ); //unvalued locations are rendered as pink 70% transparent.

    return lut;


For some reason, the annotation table cannot have numbers like, 1, 13, 7, 20, etc. It must be in ascending order and cannot skip values.



Thanks very much @Paulo_Carvalho. I’m trying to use vtkColorSeries to make the lookup table. I’ll see if I can just create the table from scratch as you’ve done.