/*========================================================================= Program: Visualization Toolkit Module: TestSmartVolumeMapperVolumeUpdate.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 int TestSmartVolumeMapperVolumeUpdate(int argc, char* argv[]) { cout << "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)" << endl; double scalarRange[2]; vtkNew volumeMapper; vtkNew wavelet; wavelet->SetWholeExtent(-127, 128, -127, 128, -127, 128); wavelet->Update(); vtkImageData* waveletData = wavelet->GetOutput(); vtkNew reader; char* volumeFile = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/vase_1comp.vti"); reader->SetFileName(volumeFile); reader->Update(); auto readerData = reader->GetOutput(); delete[] volumeFile; volumeMapper->SetInputData(readerData); 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->ShadeOn(); 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->ResetCamera(); renWin->Render(); volumeMapper->SetInputData(waveletData); ren->ResetCamera(); iren->Initialize(); return vtkTesting::InteractorEventLoop(argc, argv, iren); }