------------------------------------------------------------------------------
| 547 | |
| 548 | //------------------------------------------------------------------------------ |
| 549 | void vtkSmartVolumeMapper::ComputeMagnitudeCellData(vtkDataSet* input, vtkDataArray* arr) |
| 550 | { |
| 551 | vtkImageData* imData = vtkImageData::SafeDownCast(input); |
| 552 | if (!imData) |
| 553 | { |
| 554 | // TODO: Support image magnitude calculation for rectilinear grids |
| 555 | return; |
| 556 | } |
| 557 | |
| 558 | vtkNew<vtkImageData> tempInput; |
| 559 | tempInput->ShallowCopy(imData); |
| 560 | |
| 561 | tempInput->GetCellData()->SetActiveAttribute(arr->GetName(), vtkDataSetAttributes::SCALARS); |
| 562 | |
| 563 | // vtkImageMagnitude can only process point data so, data is transformed first |
| 564 | // to points and then back to cells. |
| 565 | vtkNew<vtkCellDataToPointData> cellToPoints; |
| 566 | cellToPoints->SetInputData(tempInput); |
| 567 | cellToPoints->Update(); |
| 568 | tempInput->ShallowCopy(cellToPoints->GetOutput()); |
| 569 | |
| 570 | const int id = |
| 571 | tempInput->GetPointData()->SetActiveAttribute(arr->GetName(), vtkDataSetAttributes::SCALARS); |
| 572 | if (id < 0) |
| 573 | { |
| 574 | vtkErrorMacro("Failed to set the active attribute in vtkImageMagnitude's input" |
| 575 | " (from cellToPoints)!"); |
| 576 | return; |
| 577 | } |
| 578 | |
| 579 | this->ImageMagnitude->SetInputData(tempInput); |
| 580 | this->ImageMagnitude->Update(); |
| 581 | |
| 582 | vtkNew<vtkPointDataToCellData> pointsToCells; |
| 583 | pointsToCells->SetInputConnection(this->ImageMagnitude->GetOutputPort()); |
| 584 | pointsToCells->Update(); |
| 585 | this->InputDataMagnitude->ShallowCopy(pointsToCells->GetOutput()); |
| 586 | } |
| 587 | |
| 588 | //------------------------------------------------------------------------------ |
| 589 | void vtkSmartVolumeMapper::ComputeMagnitudePointData(vtkDataSet* input, vtkDataArray* arr) |
no test coverage detected