1 /*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: TestGPURayCastFourComponentsMinIP.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 // This test volume renders the vase dataset with 4 dependent components the
17 // minimum intensity projection method.
18
19 #include "vtkGPUVolumeRayCastMapper.h"
20 #include "vtkTestUtilities.h"
21 #include "vtkXMLImageDataReader.h"
22 #include "vtkImageShiftScale.h"
23 #include "vtkColorTransferFunction.h"
24 #include "vtkPiecewiseFunction.h"
25 #include "vtkTransform.h"
26 #include "vtkRenderer.h"
27 #include "vtkRenderWindow.h"
28 #include "vtkRenderWindowInteractor.h"
29 #include "vtkVolumeProperty.h"
30 #include "vtkCamera.h"
31 #include "vtkRegressionTestImage.h"
32
TestGPURayCastFourComponentsMinIP(int argc,char * argv[])33 int TestGPURayCastFourComponentsMinIP(int argc,
34 char *argv[])
35 {
36 cout << "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)" << endl;
37 char *cfname=
38 vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/vase_4comp.vti");
39
40 vtkXMLImageDataReader *reader=vtkXMLImageDataReader::New();
41 reader->SetFileName(cfname);
42 delete [] cfname;
43
44 vtkImageShiftScale *shiftScale=vtkImageShiftScale::New();
45 shiftScale->SetShift(-255);
46 shiftScale->SetScale(-1);
47 shiftScale->SetInputConnection(reader->GetOutputPort());
48
49
50 vtkRenderer *ren1=vtkRenderer::New();
51 vtkRenderWindow *renWin=vtkRenderWindow::New();
52 renWin->AddRenderer(ren1);
53 renWin->SetSize(301,300);
54 vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();
55 iren->SetRenderWindow(renWin);
56
57 renWin->Render();
58
59 vtkGPUVolumeRayCastMapper *volumeMapper;
60 vtkVolumeProperty *volumeProperty;
61 vtkVolume *volume;
62
63 volumeMapper=vtkGPUVolumeRayCastMapper::New();
64 volumeMapper->SetBlendModeToMinimumIntensity();
65 volumeMapper->SetInputConnection(
66 shiftScale->GetOutputPort());
67
68 volumeProperty=vtkVolumeProperty::New();
69 volumeProperty->IndependentComponentsOff();
70
71 vtkPiecewiseFunction *f = vtkPiecewiseFunction::New();
72 f->AddPoint(0,1.0);
73 f->AddPoint(255,0.0);
74 volumeProperty->SetScalarOpacity(f);
75 f->Delete();
76
77 volume=vtkVolume::New();
78 volume->SetMapper(volumeMapper);
79 volume->SetProperty(volumeProperty);
80 ren1->AddViewProp(volume);
81
82 int valid=volumeMapper->IsRenderSupported(renWin,volumeProperty);
83
84 int retVal;
85 if(valid)
86 {
87 iren->Initialize();
88 ren1->SetBackground(0.1,0.4,0.2);
89 ren1->ResetCamera();
90 renWin->Render();
91
92 retVal = vtkTesting::Test(argc, argv, renWin, 75);
93 if (retVal == vtkRegressionTester::DO_INTERACTOR)
94 {
95 iren->Start();
96 }
97 }
98 else
99 {
100 retVal=vtkTesting::PASSED;
101 cout << "Required extensions not supported." << endl;
102 }
103
104 iren->Delete();
105 renWin->Delete();
106 ren1->Delete();
107 volumeMapper->Delete();
108 volumeProperty->Delete();
109 volume->Delete();
110
111 reader->Delete();
112 shiftScale->Delete();
113
114 if ((retVal == vtkTesting::PASSED) || (retVal == vtkTesting::DO_INTERACTOR))
115 {
116 return 0;
117 }
118 else
119 {
120 return 1;
121 }
122 }
123