------------------------------------------------------------------------------
| 663 | |
| 664 | //------------------------------------------------------------------------------ |
| 665 | void 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 | //------------------------------------------------------------------------------ |
| 710 | void GeometryViewer::SetInterpolateScalarsBeforeMapping(bool value) |
no test coverage detected