/*========================================================================= Program: Visualization Toolkit Module: TestGPURayCastChangedArray.cxx Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ /** * Designed to test paraview/paraview#19012: when the array to volume render * with is changed, the volume mapper must update correctly. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int TestGPURayCastChangedArray(int argc, char* argv[]) { vtkNew rtSource; rtSource->SetWholeExtent(-10, 10, -10, 10, -10, 10); vtkNew calculator; calculator->SetInputConnection(rtSource->GetOutputPort()); calculator->AddScalarArrayName("RTData"); calculator->SetResultArrayName("sin_RTData"); calculator->SetFunction("100*sin(RTData)"); vtkNew mapper; mapper->SetInputConnection(calculator->GetOutputPort()); mapper->AutoAdjustSampleDistancesOn(); mapper->SetScalarModeToUsePointFieldData(); mapper->SelectScalarArray("sin_RTData"); vtkNew colorTransferFunction; colorTransferFunction->RemoveAllPoints(); colorTransferFunction->AddRGBPoint(0, 0.0, 0.0, 0.0); colorTransferFunction->AddRGBPoint(250.0, 1.0, 1.0, 1.0); vtkNew scalarOpacity; scalarOpacity->AddPoint(0, 0.0); scalarOpacity->AddPoint(250, 1.0); vtkNew volumeProperty; volumeProperty->SetInterpolationTypeToLinear(); volumeProperty->SetColor(colorTransferFunction); volumeProperty->SetScalarOpacity(scalarOpacity); vtkNew volume; volume->SetMapper(mapper); volume->SetProperty(volumeProperty); vtkNew renderer; renderer->AddVolume(volume); vtkNew renderWindow; renderWindow->SetSize(800, 600); renderWindow->AddRenderer(renderer); vtkNew style; vtkNew iren; iren->SetRenderWindow(renderWindow); iren->SetInteractorStyle(style); // render using sin_RTData. mapper->SelectScalarArray("sin_RTData"); renderWindow->Render(); renderer->ResetCamera(); // change array and re-render. mapper->SelectScalarArray("RTData"); renderWindow->Render(); iren->Initialize(); int retVal = vtkRegressionTestImage(renderWindow); if (retVal == vtkRegressionTester::DO_INTERACTOR) { iren->Start(); } return EXIT_SUCCESS; }