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

Method WriteLookupTable

IO/Export/vtkJSONSceneExporter.cxx:552–598  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

550
551//------------------------------------------------------------------------------
552void vtkJSONSceneExporter::WriteLookupTable(const char* name, vtkScalarsToColors* lookupTable)
553{
554 if (lookupTable == nullptr)
555 {
556 return;
557 }
558
559 vtkDiscretizableColorTransferFunction* dctfn =
560 vtkDiscretizableColorTransferFunction::SafeDownCast(lookupTable);
561 if (dctfn != nullptr)
562 {
563 constexpr const char* INDENT = " ";
564 std::stringstream lutJSON;
565 lutJSON << "{\n"
566 << INDENT << " \"clamping\": " << (dctfn->GetClamping() ? "true" : "false") << ",\n"
567 << INDENT << " \"colorSpace\": " << dctfn->GetColorSpace() << ",\n"
568 << INDENT << " \"hSVWrap\": " << (dctfn->GetHSVWrap() ? "true" : "false") << ",\n"
569 << INDENT << " \"alpha\": " << dctfn->GetAlpha() << ",\n"
570 << INDENT << " \"vectorComponent\": " << dctfn->GetVectorComponent() << ",\n"
571 << INDENT << " \"vectorSize\": " << dctfn->GetVectorSize() << ",\n"
572 << INDENT << " \"vectorMode\": " << dctfn->GetVectorMode() << ",\n"
573 << INDENT << " \"indexedLookup\": " << dctfn->GetIndexedLookup() << ",\n"
574 << INDENT << " \"nodes\": [";
575
576 // Fill nodes
577 vtkIdType nbNodes = dctfn->GetSize();
578 double node[6];
579 for (vtkIdType i = 0; i < nbNodes; i++)
580 {
581 dctfn->GetNodeValue(i, node);
582 if (i > 0)
583 {
584 lutJSON << ",";
585 }
586
587 lutJSON << "\n"
588 << INDENT << INDENT << "[" << node[0] << ", " << node[1] << ", " << node[2] << ", "
589 << node[3] << ", " << node[4] << ", " << node[5] << "]";
590 }
591
592 // Close node list
593 lutJSON << "\n ]\n }";
594
595 // Store in map...
596 this->LookupTables[name] = lutJSON.str();
597 }
598}
599
600//------------------------------------------------------------------------------
601void vtkJSONSceneExporter::WritePropCollection(

Callers 2

WritePropCollectionMethod · 0.95
WriteNamedActorsMethod · 0.95

Calls 6

GetClampingMethod · 0.80
GetColorSpaceMethod · 0.80
GetAlphaMethod · 0.80
GetSizeMethod · 0.45
GetNodeValueMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected