1 /*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: TestOSPRayIsosurface.cxx
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14 =========================================================================*/
15
16 #include "vtkTestUtilities.h"
17
18 #include "vtkColorTransferFunction.h"
19 #include "vtkContourValues.h"
20 #include "vtkOSPRayPass.h"
21 #include "vtkOSPRayVolumeMapper.h"
22 #include "vtkPiecewiseFunction.h"
23 #include "vtkRTAnalyticSource.h"
24 #include "vtkRenderWindow.h"
25 #include "vtkRenderWindowInteractor.h"
26 #include "vtkRenderer.h"
27 #include "vtkVolumeProperty.h"
28
TestOSPRayIsosurface(int vtkNotUsed (argc),char * vtkNotUsed (argv)[])29 int TestOSPRayIsosurface(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
30 {
31 vtkNew<vtkRenderWindowInteractor> iren;
32 vtkNew<vtkRenderWindow> renWin;
33 iren->SetRenderWindow(renWin);
34 vtkNew<vtkRenderer> renderer;
35 renWin->AddRenderer(renderer);
36
37 vtkNew<vtkRTAnalyticSource> wavelet;
38
39 vtkNew<vtkOSPRayVolumeMapper> volumeMapper;
40 volumeMapper->SetInputConnection(wavelet->GetOutputPort());
41 volumeMapper->SetBlendModeToIsoSurface();
42
43 vtkNew<vtkColorTransferFunction> colorTransferFunction;
44 colorTransferFunction->AddRGBPoint(220.0, 0.0, 1.0, 0.0);
45 colorTransferFunction->AddRGBPoint(150.0, 1.0, 1.0, 1.0);
46 colorTransferFunction->AddRGBPoint(190.0, 0.0, 1.0, 1.0);
47
48 vtkNew<vtkPiecewiseFunction> scalarOpacity;
49 scalarOpacity->AddPoint(220.0, 1.0);
50 scalarOpacity->AddPoint(150.0, 0.2);
51 scalarOpacity->AddPoint(190.0, 0.6);
52
53 vtkNew<vtkVolumeProperty> volumeProperty;
54 volumeProperty->ShadeOn();
55 volumeProperty->SetInterpolationTypeToLinear();
56 volumeProperty->SetColor(colorTransferFunction);
57 volumeProperty->SetScalarOpacity(scalarOpacity);
58 volumeProperty->GetIsoSurfaceValues()->SetValue(0, 220.0);
59 volumeProperty->GetIsoSurfaceValues()->SetValue(1, 150.0);
60 volumeProperty->GetIsoSurfaceValues()->SetValue(2, 190.0);
61
62 vtkNew<vtkVolume> volume;
63 volume->SetMapper(volumeMapper);
64 volume->SetProperty(volumeProperty);
65
66 renderer->AddVolume(volume);
67 renWin->SetSize(400, 400);
68
69 vtkNew<vtkOSPRayPass> ospray;
70 renderer->SetPass(ospray);
71
72 renWin->Render();
73
74 iren->Start();
75 return 0;
76 }
77