MCPcopy Create free account
hub / github.com/Kitware/VTK / UpdateLUT

Method UpdateLUT

Examples/Emscripten/Cxx/GeometryViewer/GeometryViewer.cxx:803–829  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

801
802//------------------------------------------------------------------------------
803void GeometryViewer::Internal::UpdateLUT()
804{
805 auto mapper = this->Actor->GetMapper();
806 if (!mapper)
807 {
808 return;
809 }
810 std::array<double, 2> scalarRange;
811 mapper->GetScalarRange(scalarRange.data());
812 vtkNew<vtkColorTransferFunction> lut;
813 lut->SetColorSpaceToHSV();
814 vtkNew<vtkColorSeries> colorSeries;
815 colorSeries->SetColorScheme(PresetNames.at(this->ColorMapPreset));
816 auto numColors = colorSeries->GetNumberOfColors();
817 for (int i = 0; i < numColors; ++i)
818 {
819 vtkColor3ub color = colorSeries->GetColor(i);
820 double dColor[3];
821 dColor[0] = static_cast<double>(color[0]) / 255.0;
822 dColor[1] = static_cast<double>(color[1]) / 255.0;
823 dColor[2] = static_cast<double>(color[2]) / 255.0;
824 double t =
825 scalarRange[0] + (scalarRange[1] - scalarRange[0]) / (static_cast<double>(numColors) - 1) * i;
826 lut->AddRGBPoint(t, dColor[0], dColor[1], dColor[2]);
827 }
828 mapper->SetLookupTable(lut);
829}
830
831//------------------------------------------------------------------------------
832void GeometryViewer::Internal::FetchAvailableDataArrays(vtkDataObject* dataObject)

Callers 4

LoadDataFileMethod · 0.80
SetColorByArrayMethod · 0.80
SetColorMapPresetMethod · 0.80

Calls 9

GetMapperMethod · 0.80
SetColorSchemeMethod · 0.80
AddRGBPointMethod · 0.80
GetScalarRangeMethod · 0.45
dataMethod · 0.45
atMethod · 0.45
GetNumberOfColorsMethod · 0.45
GetColorMethod · 0.45
SetLookupTableMethod · 0.45

Tested by

no test coverage detected