/*========================================================================= Program: Visualization Toolkit 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. =========================================================================*/ #include "vtkActor.h" #include "vtkLight.h" #include "vtkNew.h" #include "vtkPolyDataMapper.h" #include "vtkRTAnalyticSource.h" #include "vtkRenderWindow.h" #include "vtkRenderer.h" #include "vtkSmartVolumeMapper.h" #include "vtkSphereSource.h" #include "vtkTestUtilities.h" #include "vtkVolume.h" #include "vtkWindowNode.h" #include "vtksys/SystemTools.hxx" #include "vtkArchiver.h" #include "vtkJSONRenderWindowExporter.h" int TestJSONRenderWindowExporter(int argc, char* argv[]) { char* tempDir = vtkTestUtilities::GetArgOrEnvOrDefault("-T", argc, argv, "VTK_TEMP_DIR", "Testing/Temporary"); if (!tempDir) { std::cout << "Could not determine temporary directory.\n"; return EXIT_FAILURE; } std::string testDirectory = tempDir; delete[] tempDir; std::string filename = testDirectory + std::string("/") + std::string("ExportVtkJS"); vtkNew sphere; vtkNew pmap; pmap->SetInputConnection(sphere->GetOutputPort()); vtkNew wavelet; wavelet->SetWholeExtent(-10, 10, -10, 10, -10, 10); wavelet->SetCenter(0, 0, 0); vtkNew volumeMapper; volumeMapper->SetBlendModeToComposite(); volumeMapper->SetInputConnection(wavelet->GetOutputPort()); vtkNew rwin; vtkNew ren; rwin->AddRenderer(ren); vtkNew light; ren->AddLight(light); vtkNew actor; ren->AddActor(actor); actor->SetMapper(pmap); vtkNew volume; ren->AddVolume(volume); volume->SetMapper(volumeMapper); vtkNew exporter; exporter->GetArchiver()->SetArchiveName(filename.c_str()); exporter->SetRenderWindow(rwin); exporter->Write(); vtksys::SystemTools::RemoveADirectory(filename); return EXIT_SUCCESS; }