VTK/Examples/Cxx/Utilities/ColorLookupTable

From KitwarePublic

Jump to: navigation, search

This example shows how to create a table of colors that map from a continuous range of values.

ColorLookupTable.cxx

#include <vtkSmartPointer.h>
#include <vtkLookupTable.h>
 
int main(int, char *[])
{
  vtkSmartPointer<vtkLookupTable> lookupTable = 
    vtkSmartPointer<vtkLookupTable>::New();
 
  lookupTable->SetTableRange(0.0, 10.0);
  // If you don't want to use the whole color range, you can use
  // SetValueRange, SetHueRange, and SetSaturationRange
  lookupTable->Build();
 
  double color[3];
  lookupTable->GetColor(1.0, color);
  std::cout << color[0] << " " << color[1] << " " << color[2] << std::endl;
 
  lookupTable->GetColor(5.0, color);
  std::cout << color[0] << " " << color[1] << " " << color[2] << std::endl;
 
  return EXIT_SUCCESS;
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.6)
 
PROJECT(LookupTable)
 
FIND_PACKAGE(VTK REQUIRED)
INCLUDE(${VTK_USE_FILE})
 
ADD_EXECUTABLE(LookupTable LookupTable.cpp)
TARGET_LINK_LIBRARIES(LookupTable vtkHybrid vtkInfovis)
Personal tools