/*========================================================================= Program: Visualization Toolkit Module: TestGPURayCastVolumeUpdate.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. =========================================================================*/ // This test volume tests whether updating the volume MTime updates the , // geometry in the volume mapper. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int TestGPURayCastCellData(int argc, char* argv[]) { cout << "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)" << endl; bool useOSP = true; for (int i = 0; i < argc; i++) { if (!strcmp(argv[i], "-GL")) { cerr << "GL" << endl; useOSP = false; } } double scalarRange[2]; vtkNew outlineActor; vtkNew outlineMapper; vtkNew volumeMapper; vtkNew reader; char* volumeFile = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/vase_1comp.vti"); reader->SetFileName(volumeFile); delete[] volumeFile; vtkNew pointToCell; pointToCell->SetInputConnection(reader->GetOutputPort()); volumeMapper->SetInputConnection(pointToCell->GetOutputPort()); // Add outline filter vtkNew outlineFilter; outlineFilter->SetInputConnection(pointToCell->GetOutputPort()); outlineMapper->SetInputConnection(outlineFilter->GetOutputPort()); outlineActor->SetMapper(outlineMapper); volumeMapper->GetInput()->GetScalarRange(scalarRange); volumeMapper->SetSampleDistance(0.1); volumeMapper->SetAutoAdjustSampleDistances(0); volumeMapper->SetBlendModeToComposite(); vtkNew renWin; renWin->SetMultiSamples(0); renWin->SetSize(400, 400); vtkNew iren; iren->SetRenderWindow(renWin); vtkNew style; iren->SetInteractorStyle(style); renWin->Render(); // make sure we have an OpenGL context. vtkNew ren; ren->SetBackground(0.2, 0.2, 0.5); renWin->AddRenderer(ren); vtkNew scalarOpacity; scalarOpacity->AddPoint(50, 0.0); scalarOpacity->AddPoint(75, 1.0); vtkNew volumeProperty; volumeProperty->SetInterpolationType(VTK_LINEAR_INTERPOLATION); volumeProperty->SetScalarOpacity(scalarOpacity); vtkNew colorTransferFunction; colorTransferFunction->RemoveAllPoints(); colorTransferFunction->AddRGBPoint(scalarRange[0], 0.6, 0.4, 0.1); volumeProperty->SetColor(colorTransferFunction); vtkNew volume; volume->SetMapper(volumeMapper); volume->SetProperty(volumeProperty); ren->AddVolume(volume); ren->AddActor(outlineActor); ren->ResetCamera(); vtkNew osprayPass; if (useOSP) { ren->SetPass(osprayPass); } renWin->Render(); ren->ResetCamera(); iren->Initialize(); int retVal = vtkRegressionTestImage(renWin); if (retVal == vtkRegressionTester::DO_INTERACTOR) { iren->Start(); } return !retVal; }