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

Method SetColorByArray

Examples/Emscripten/Cxx/GeometryViewer/GeometryViewer.cxx:665–707  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

663
664//------------------------------------------------------------------------------
665void GeometryViewer::SetColorByArray(const std::string& arrayName)
666{
667 auto mapper = this->P->Actor->GetMapper();
668 this->P->HighlighterData.ActivePointColorArray = "";
669 this->P->HighlighterData.ActiveCellColorArray = "";
670 if (!mapper)
671 {
672 return;
673 }
674 std::cout << __func__ << '(' << arrayName << ')' << std::endl;
675 if (arrayName == "Solid")
676 {
677 mapper->ScalarVisibilityOff();
678 return;
679 }
680 mapper->ScalarVisibilityOn();
681 vtkDataArray* scalarArray = nullptr;
682 if (this->P->PointDataArrays.count(arrayName))
683 {
684 this->P->HighlighterData.ActivePointColorArray = arrayName;
685 mapper->SetScalarModeToUsePointFieldData();
686 scalarArray = mapper->GetDataSetInput()->GetPointData()->GetArray(arrayName.c_str());
687 }
688 else if (this->P->CellDataArrays.count(arrayName))
689 {
690 this->P->HighlighterData.ActiveCellColorArray = arrayName;
691 mapper->SetScalarModeToUseCellFieldData();
692 scalarArray = mapper->GetDataSetInput()->GetCellData()->GetArray(arrayName.c_str());
693 }
694 else
695 {
696 return;
697 }
698 // TODO: handle multi-component arrays with magnitude, x, y, z ..
699 mapper->ColorByArrayComponent(arrayName.c_str(), 0);
700 if (scalarArray)
701 {
702 double range[2];
703 scalarArray->GetRange(range);
704 mapper->SetScalarRange(range);
705 }
706 this->P->UpdateLUT();
707}
708
709//------------------------------------------------------------------------------
710void GeometryViewer::SetInterpolateScalarsBeforeMapping(bool value)

Callers 2

LoadDataFileMethod · 0.95

Calls 11

GetMapperMethod · 0.80
UpdateLUTMethod · 0.80
countMethod · 0.45
GetArrayMethod · 0.45
GetPointDataMethod · 0.45
GetDataSetInputMethod · 0.45
c_strMethod · 0.45
GetCellDataMethod · 0.45
ColorByArrayComponentMethod · 0.45
GetRangeMethod · 0.45
SetScalarRangeMethod · 0.45

Tested by

no test coverage detected