1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    TestGPURayCastTwoComponentsIndependent.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 // Description
17 // This test creates a vtkImageData with two components.
18 // The data is volume rendered considering the two components as independent.
19 
20 #include "vtkCamera.h"
21 #include "vtkColorTransferFunction.h"
22 #include "vtkGPUVolumeRayCastMapper.h"
23 #include "vtkImageData.h"
24 #include "vtkInteractorStyleTrackballCamera.h"
25 #include "vtkNew.h"
26 #include "vtkPiecewiseFunction.h"
27 #include "vtkRenderer.h"
28 #include "vtkRenderWindow.h"
29 #include "vtkRenderWindowInteractor.h"
30 #include "vtkTesting.h"
31 #include "vtkTestUtilities.h"
32 #include "vtkVolume.h"
33 #include "vtkVolumeProperty.h"
34 
35 static const char * TestGPURayCastTwoComponentsIndependentLog =
36 "# StreamVersion 1\n"
37 "EnterEvent 298 198 0 0 0 0 0\n"
38 "MouseMoveEvent 298 198 0 0 0 0 0\n"
39 "MouseMoveEvent 292 200 0 0 0 0 0\n"
40 "MouseMoveEvent 285 200 0 0 0 0 0\n"
41 "MouseMoveEvent 281 202 0 0 0 0 0\n"
42 "MouseMoveEvent 277 202 0 0 0 0 0\n"
43 "MouseMoveEvent 274 203 0 0 0 0 0\n"
44 "MouseMoveEvent 270 205 0 0 0 0 0\n"
45 "MouseMoveEvent 266 205 0 0 0 0 0\n"
46 "MouseMoveEvent 262 205 0 0 0 0 0\n"
47 "MouseMoveEvent 260 205 0 0 0 0 0\n"
48 "MouseMoveEvent 258 206 0 0 0 0 0\n"
49 "MouseMoveEvent 255 206 0 0 0 0 0\n"
50 "MouseMoveEvent 253 207 0 0 0 0 0\n"
51 "MouseMoveEvent 251 207 0 0 0 0 0\n"
52 "MouseMoveEvent 250 207 0 0 0 0 0\n"
53 "MouseMoveEvent 248 207 0 0 0 0 0\n"
54 "MouseMoveEvent 244 207 0 0 0 0 0\n"
55 "MouseMoveEvent 237 208 0 0 0 0 0\n"
56 "MouseMoveEvent 232 210 0 0 0 0 0\n"
57 "MouseMoveEvent 226 210 0 0 0 0 0\n"
58 "MouseMoveEvent 222 211 0 0 0 0 0\n"
59 "MouseMoveEvent 220 211 0 0 0 0 0\n"
60 "MouseMoveEvent 219 212 0 0 0 0 0\n"
61 "MouseMoveEvent 216 212 0 0 0 0 0\n"
62 "MouseMoveEvent 215 213 0 0 0 0 0\n"
63 "MouseMoveEvent 213 213 0 0 0 0 0\n"
64 "MouseMoveEvent 211 214 0 0 0 0 0\n"
65 "MouseMoveEvent 210 214 0 0 0 0 0\n"
66 "MouseMoveEvent 207 216 0 0 0 0 0\n"
67 "MouseMoveEvent 206 217 0 0 0 0 0\n"
68 "MouseMoveEvent 205 218 0 0 0 0 0\n"
69 "MouseMoveEvent 203 220 0 0 0 0 0\n"
70 "MouseMoveEvent 200 222 0 0 0 0 0\n"
71 "MouseMoveEvent 197 224 0 0 0 0 0\n"
72 "MouseMoveEvent 194 226 0 0 0 0 0\n"
73 "MouseMoveEvent 193 227 0 0 0 0 0\n"
74 "MouseMoveEvent 191 228 0 0 0 0 0\n"
75 "MouseMoveEvent 190 229 0 0 0 0 0\n"
76 "MouseMoveEvent 188 231 0 0 0 0 0\n"
77 "MouseMoveEvent 187 232 0 0 0 0 0\n"
78 "MouseMoveEvent 186 233 0 0 0 0 0\n"
79 "MouseMoveEvent 185 234 0 0 0 0 0\n"
80 "MouseMoveEvent 184 235 0 0 0 0 0\n"
81 "MouseMoveEvent 184 236 0 0 0 0 0\n"
82 "MouseMoveEvent 183 237 0 0 0 0 0\n"
83 "MouseMoveEvent 182 238 0 0 0 0 0\n"
84 "MouseMoveEvent 181 239 0 0 0 0 0\n"
85 "MouseMoveEvent 179 240 0 0 0 0 0\n"
86 "MouseMoveEvent 176 240 0 0 0 0 0\n"
87 "MouseMoveEvent 174 241 0 0 0 0 0\n"
88 "MouseMoveEvent 172 241 0 0 0 0 0\n"
89 "MouseMoveEvent 170 242 0 0 0 0 0\n"
90 "MouseMoveEvent 168 242 0 0 0 0 0\n"
91 "MouseMoveEvent 166 242 0 0 0 0 0\n"
92 "MouseMoveEvent 165 242 0 0 0 0 0\n"
93 "MouseMoveEvent 164 242 0 0 0 0 0\n"
94 "MouseMoveEvent 160 242 0 0 0 0 0\n"
95 "MouseMoveEvent 156 242 0 0 0 0 0\n"
96 "MouseMoveEvent 153 242 0 0 0 0 0\n"
97 "MouseMoveEvent 150 242 0 0 0 0 0\n"
98 "MouseMoveEvent 148 242 0 0 0 0 0\n"
99 "MouseMoveEvent 147 242 0 0 0 0 0\n"
100 "MouseMoveEvent 146 242 0 0 0 0 0\n"
101 "MouseMoveEvent 144 242 0 0 0 0 0\n"
102 "MouseMoveEvent 143 242 0 0 0 0 0\n"
103 "MouseMoveEvent 142 242 0 0 0 0 0\n"
104 "MouseMoveEvent 141 242 0 0 0 0 0\n"
105 "MouseMoveEvent 140 242 0 0 0 0 0\n"
106 "MouseMoveEvent 139 242 0 0 0 0 0\n"
107 "MouseMoveEvent 138 242 0 0 0 0 0\n"
108 "MouseMoveEvent 137 242 0 0 0 0 0\n"
109 "LeftButtonPressEvent 137 242 0 0 0 0 0\n"
110 "StartInteractionEvent 137 242 0 0 0 0 0\n"
111 "TimerEvent 137 242 0 0 0 0 0\n"
112 "RenderEvent 137 242 0 0 0 0 0\n"
113 "TimerEvent 137 242 0 0 0 0 0\n"
114 "RenderEvent 137 242 0 0 0 0 0\n"
115 "TimerEvent 137 242 0 0 0 0 0\n"
116 "RenderEvent 137 242 0 0 0 0 0\n"
117 "TimerEvent 137 242 0 0 0 0 0\n"
118 "RenderEvent 137 242 0 0 0 0 0\n"
119 "TimerEvent 137 242 0 0 0 0 0\n"
120 "RenderEvent 137 242 0 0 0 0 0\n"
121 "TimerEvent 137 242 0 0 0 0 0\n"
122 "RenderEvent 137 242 0 0 0 0 0\n"
123 "TimerEvent 137 242 0 0 0 0 0\n"
124 "RenderEvent 137 242 0 0 0 0 0\n"
125 "TimerEvent 137 242 0 0 0 0 0\n"
126 "RenderEvent 137 242 0 0 0 0 0\n"
127 "TimerEvent 137 242 0 0 0 0 0\n"
128 "RenderEvent 137 242 0 0 0 0 0\n"
129 "TimerEvent 137 242 0 0 0 0 0\n"
130 "RenderEvent 137 242 0 0 0 0 0\n"
131 "TimerEvent 137 242 0 0 0 0 0\n"
132 "RenderEvent 137 242 0 0 0 0 0\n"
133 "TimerEvent 137 242 0 0 0 0 0\n"
134 "RenderEvent 137 242 0 0 0 0 0\n"
135 "TimerEvent 137 242 0 0 0 0 0\n"
136 "RenderEvent 137 242 0 0 0 0 0\n"
137 "MouseMoveEvent 136 241 0 0 0 0 0\n"
138 "InteractionEvent 136 241 0 0 0 0 0\n"
139 "TimerEvent 136 241 0 0 0 0 0\n"
140 "RenderEvent 136 241 0 0 0 0 0\n"
141 "MouseMoveEvent 136 240 0 0 0 0 0\n"
142 "InteractionEvent 136 240 0 0 0 0 0\n"
143 "MouseMoveEvent 136 239 0 0 0 0 0\n"
144 "InteractionEvent 136 239 0 0 0 0 0\n"
145 "TimerEvent 136 239 0 0 0 0 0\n"
146 "RenderEvent 136 239 0 0 0 0 0\n"
147 "MouseMoveEvent 136 238 0 0 0 0 0\n"
148 "InteractionEvent 136 238 0 0 0 0 0\n"
149 "MouseMoveEvent 136 237 0 0 0 0 0\n"
150 "InteractionEvent 136 237 0 0 0 0 0\n"
151 "TimerEvent 136 237 0 0 0 0 0\n"
152 "RenderEvent 136 237 0 0 0 0 0\n"
153 "MouseMoveEvent 136 236 0 0 0 0 0\n"
154 "InteractionEvent 136 236 0 0 0 0 0\n"
155 "MouseMoveEvent 136 235 0 0 0 0 0\n"
156 "InteractionEvent 136 235 0 0 0 0 0\n"
157 "TimerEvent 136 235 0 0 0 0 0\n"
158 "RenderEvent 136 235 0 0 0 0 0\n"
159 "MouseMoveEvent 136 234 0 0 0 0 0\n"
160 "InteractionEvent 136 234 0 0 0 0 0\n"
161 "TimerEvent 136 234 0 0 0 0 0\n"
162 "RenderEvent 136 234 0 0 0 0 0\n"
163 "MouseMoveEvent 136 233 0 0 0 0 0\n"
164 "InteractionEvent 136 233 0 0 0 0 0\n"
165 "MouseMoveEvent 136 232 0 0 0 0 0\n"
166 "InteractionEvent 136 232 0 0 0 0 0\n"
167 "TimerEvent 136 232 0 0 0 0 0\n"
168 "RenderEvent 136 232 0 0 0 0 0\n"
169 "MouseMoveEvent 136 231 0 0 0 0 0\n"
170 "InteractionEvent 136 231 0 0 0 0 0\n"
171 "MouseMoveEvent 136 230 0 0 0 0 0\n"
172 "InteractionEvent 136 230 0 0 0 0 0\n"
173 "TimerEvent 136 230 0 0 0 0 0\n"
174 "RenderEvent 136 230 0 0 0 0 0\n"
175 "TimerEvent 136 230 0 0 0 0 0\n"
176 "RenderEvent 136 230 0 0 0 0 0\n"
177 "TimerEvent 136 230 0 0 0 0 0\n"
178 "RenderEvent 136 230 0 0 0 0 0\n"
179 "TimerEvent 136 230 0 0 0 0 0\n"
180 "RenderEvent 136 230 0 0 0 0 0\n"
181 "TimerEvent 136 230 0 0 0 0 0\n"
182 "RenderEvent 136 230 0 0 0 0 0\n"
183 "TimerEvent 136 230 0 0 0 0 0\n"
184 "RenderEvent 136 230 0 0 0 0 0\n"
185 "TimerEvent 136 230 0 0 0 0 0\n"
186 "RenderEvent 136 230 0 0 0 0 0\n"
187 "LeftButtonReleaseEvent 136 230 0 0 0 0 0\n"
188 "EndInteractionEvent 136 230 0 0 0 0 0\n"
189 "RenderEvent 136 230 0 0 0 0 0\n"
190 "MouseMoveEvent 136 228 0 0 0 0 0\n"
191 "MouseMoveEvent 136 226 0 0 0 0 0\n"
192 "MouseMoveEvent 136 224 0 0 0 0 0\n"
193 "MouseMoveEvent 136 222 0 0 0 0 0\n"
194 "MouseMoveEvent 136 220 0 0 0 0 0\n"
195 "MouseMoveEvent 136 218 0 0 0 0 0\n"
196 "MouseMoveEvent 136 216 0 0 0 0 0\n"
197 "MouseMoveEvent 136 213 0 0 0 0 0\n"
198 "MouseMoveEvent 136 210 0 0 0 0 0\n"
199 "MouseMoveEvent 136 207 0 0 0 0 0\n"
200 "MouseMoveEvent 136 204 0 0 0 0 0\n"
201 "MouseMoveEvent 137 201 0 0 0 0 0\n"
202 "MouseMoveEvent 138 198 0 0 0 0 0\n"
203 "MouseMoveEvent 139 196 0 0 0 0 0\n"
204 "MouseMoveEvent 139 194 0 0 0 0 0\n"
205 "MouseMoveEvent 140 191 0 0 0 0 0\n"
206 "MouseMoveEvent 142 187 0 0 0 0 0\n"
207 "MouseMoveEvent 142 184 0 0 0 0 0\n"
208 "MouseMoveEvent 144 181 0 0 0 0 0\n"
209 "MouseMoveEvent 145 177 0 0 0 0 0\n"
210 "MouseMoveEvent 148 173 0 0 0 0 0\n"
211 "MouseMoveEvent 151 169 0 0 0 0 0\n"
212 "MouseMoveEvent 156 164 0 0 0 0 0\n"
213 "MouseMoveEvent 162 158 0 0 0 0 0\n"
214 "MouseMoveEvent 166 153 0 0 0 0 0\n"
215 "MouseMoveEvent 170 149 0 0 0 0 0\n"
216 "MouseMoveEvent 174 145 0 0 0 0 0\n"
217 "MouseMoveEvent 178 143 0 0 0 0 0\n"
218 "MouseMoveEvent 184 142 0 0 0 0 0\n"
219 "MouseMoveEvent 188 140 0 0 0 0 0\n"
220 "MouseMoveEvent 193 139 0 0 0 0 0\n"
221 "MouseMoveEvent 197 139 0 0 0 0 0\n"
222 "MouseMoveEvent 201 137 0 0 0 0 0\n"
223 "MouseMoveEvent 202 137 0 0 0 0 0\n"
224 "MouseMoveEvent 204 137 0 0 0 0 0\n"
225 "MouseMoveEvent 205 137 0 0 0 0 0\n"
226 "MouseMoveEvent 206 137 0 0 0 0 0\n"
227 "MouseMoveEvent 209 136 0 0 0 0 0\n"
228 "MouseMoveEvent 211 136 0 0 0 0 0\n"
229 "MouseMoveEvent 212 136 0 0 0 0 0\n"
230 "MouseMoveEvent 213 135 0 0 0 0 0\n"
231 "MouseMoveEvent 214 135 0 0 0 0 0\n"
232 "MouseMoveEvent 215 134 0 0 0 0 0\n"
233 "MouseMoveEvent 216 133 0 0 0 0 0\n"
234 "LeftButtonPressEvent 216 133 0 0 0 0 0\n"
235 "StartInteractionEvent 216 133 0 0 0 0 0\n"
236 "TimerEvent 216 133 0 0 0 0 0\n"
237 "RenderEvent 216 133 0 0 0 0 0\n"
238 "MouseMoveEvent 219 132 0 0 0 0 0\n"
239 "InteractionEvent 219 132 0 0 0 0 0\n"
240 "MouseMoveEvent 220 131 0 0 0 0 0\n"
241 "InteractionEvent 220 131 0 0 0 0 0\n"
242 "TimerEvent 220 131 0 0 0 0 0\n"
243 "RenderEvent 220 131 0 0 0 0 0\n"
244 "MouseMoveEvent 221 130 0 0 0 0 0\n"
245 "InteractionEvent 221 130 0 0 0 0 0\n"
246 "MouseMoveEvent 222 129 0 0 0 0 0\n"
247 "InteractionEvent 222 129 0 0 0 0 0\n"
248 "TimerEvent 222 129 0 0 0 0 0\n"
249 "RenderEvent 222 129 0 0 0 0 0\n"
250 "MouseMoveEvent 223 128 0 0 0 0 0\n"
251 "InteractionEvent 223 128 0 0 0 0 0\n"
252 "TimerEvent 223 128 0 0 0 0 0\n"
253 "RenderEvent 223 128 0 0 0 0 0\n"
254 "TimerEvent 223 128 0 0 0 0 0\n"
255 "RenderEvent 223 128 0 0 0 0 0\n"
256 "TimerEvent 223 128 0 0 0 0 0\n"
257 "RenderEvent 223 128 0 0 0 0 0\n"
258 "TimerEvent 223 128 0 0 0 0 0\n"
259 "RenderEvent 223 128 0 0 0 0 0\n"
260 "TimerEvent 223 128 0 0 0 0 0\n"
261 "RenderEvent 223 128 0 0 0 0 0\n"
262 "LeftButtonReleaseEvent 223 128 0 0 0 0 0\n"
263 "EndInteractionEvent 223 128 0 0 0 0 0\n"
264 "RenderEvent 223 128 0 0 0 0 0\n"
265 "MouseMoveEvent 224 126 0 0 0 0 0\n"
266 "MouseMoveEvent 225 125 0 0 0 0 0\n"
267 "MouseMoveEvent 226 123 0 0 0 0 0\n"
268 "MouseMoveEvent 227 122 0 0 0 0 0\n"
269 "MouseMoveEvent 228 121 0 0 0 0 0\n"
270 "MouseMoveEvent 229 120 0 0 0 0 0\n"
271 "MouseMoveEvent 230 119 0 0 0 0 0\n"
272 "MouseMoveEvent 231 118 0 0 0 0 0\n"
273 "MouseMoveEvent 232 117 0 0 0 0 0\n"
274 "MouseMoveEvent 233 116 0 0 0 0 0\n"
275 "MouseMoveEvent 233 115 0 0 0 0 0\n"
276 "MouseMoveEvent 234 114 0 0 0 0 0\n"
277 "MouseMoveEvent 234 113 0 0 0 0 0\n"
278 "MouseMoveEvent 234 112 0 0 0 0 0\n"
279 "MouseMoveEvent 234 111 0 0 0 0 0\n"
280 "MouseMoveEvent 234 110 0 0 0 0 0\n"
281 "MouseMoveEvent 233 108 0 0 0 0 0\n"
282 "MouseMoveEvent 231 107 0 0 0 0 0\n"
283 "MouseMoveEvent 229 106 0 0 0 0 0\n"
284 "MouseMoveEvent 226 105 0 0 0 0 0\n"
285 "MouseMoveEvent 223 105 0 0 0 0 0\n"
286 "MouseMoveEvent 220 104 0 0 0 0 0\n"
287 "MouseMoveEvent 216 103 0 0 0 0 0\n"
288 "MouseMoveEvent 209 101 0 0 0 0 0\n"
289 "MouseMoveEvent 202 99 0 0 0 0 0\n"
290 "MouseMoveEvent 195 98 0 0 0 0 0\n"
291 "MouseMoveEvent 188 96 0 0 0 0 0\n"
292 "MouseMoveEvent 179 94 0 0 0 0 0\n"
293 "MouseMoveEvent 168 93 0 0 0 0 0\n"
294 "MouseMoveEvent 156 91 0 0 0 0 0\n"
295 "MouseMoveEvent 144 89 0 0 0 0 0\n"
296 "MouseMoveEvent 135 87 0 0 0 0 0\n"
297 "MouseMoveEvent 127 86 0 0 0 0 0\n"
298 "MouseMoveEvent 120 86 0 0 0 0 0\n"
299 "MouseMoveEvent 116 84 0 0 0 0 0\n"
300 "MouseMoveEvent 115 84 0 0 0 0 0\n"
301 "MouseMoveEvent 114 83 0 0 0 0 0\n"
302 "LeftButtonPressEvent 114 83 0 0 0 0 0\n"
303 "StartInteractionEvent 114 83 0 0 0 0 0\n"
304 "TimerEvent 114 83 0 0 0 0 0\n"
305 "RenderEvent 114 83 0 0 0 0 0\n"
306 "MouseMoveEvent 108 82 0 0 0 0 0\n"
307 "InteractionEvent 108 82 0 0 0 0 0\n"
308 "TimerEvent 108 82 0 0 0 0 0\n"
309 "RenderEvent 108 82 0 0 0 0 0\n"
310 "MouseMoveEvent 104 81 0 0 0 0 0\n"
311 "InteractionEvent 104 81 0 0 0 0 0\n"
312 "MouseMoveEvent 102 81 0 0 0 0 0\n"
313 "InteractionEvent 102 81 0 0 0 0 0\n"
314 "TimerEvent 102 81 0 0 0 0 0\n"
315 "RenderEvent 102 81 0 0 0 0 0\n"
316 "MouseMoveEvent 95 81 0 0 0 0 0\n"
317 "InteractionEvent 95 81 0 0 0 0 0\n"
318 "MouseMoveEvent 92 81 0 0 0 0 0\n"
319 "InteractionEvent 92 81 0 0 0 0 0\n"
320 "TimerEvent 92 81 0 0 0 0 0\n"
321 "RenderEvent 92 81 0 0 0 0 0\n"
322 "MouseMoveEvent 86 81 0 0 0 0 0\n"
323 "InteractionEvent 86 81 0 0 0 0 0\n"
324 "MouseMoveEvent 83 81 0 0 0 0 0\n"
325 "InteractionEvent 83 81 0 0 0 0 0\n"
326 "TimerEvent 83 81 0 0 0 0 0\n"
327 "RenderEvent 83 81 0 0 0 0 0\n"
328 "MouseMoveEvent 77 81 0 0 0 0 0\n"
329 "InteractionEvent 77 81 0 0 0 0 0\n"
330 "MouseMoveEvent 75 80 0 0 0 0 0\n"
331 "InteractionEvent 75 80 0 0 0 0 0\n"
332 "TimerEvent 75 80 0 0 0 0 0\n"
333 "RenderEvent 75 80 0 0 0 0 0\n"
334 "MouseMoveEvent 72 80 0 0 0 0 0\n"
335 "InteractionEvent 72 80 0 0 0 0 0\n"
336 "TimerEvent 72 80 0 0 0 0 0\n"
337 "RenderEvent 72 80 0 0 0 0 0\n"
338 "TimerEvent 72 80 0 0 0 0 0\n"
339 "RenderEvent 72 80 0 0 0 0 0\n"
340 "TimerEvent 72 80 0 0 0 0 0\n"
341 "RenderEvent 72 80 0 0 0 0 0\n"
342 "TimerEvent 72 80 0 0 0 0 0\n"
343 "RenderEvent 72 80 0 0 0 0 0\n"
344 "TimerEvent 72 80 0 0 0 0 0\n"
345 "RenderEvent 72 80 0 0 0 0 0\n"
346 "TimerEvent 72 80 0 0 0 0 0\n"
347 "RenderEvent 72 80 0 0 0 0 0\n"
348 "TimerEvent 72 80 0 0 0 0 0\n"
349 "RenderEvent 72 80 0 0 0 0 0\n"
350 "TimerEvent 72 80 0 0 0 0 0\n"
351 "RenderEvent 72 80 0 0 0 0 0\n"
352 "TimerEvent 72 80 0 0 0 0 0\n"
353 "RenderEvent 72 80 0 0 0 0 0\n"
354 "TimerEvent 72 80 0 0 0 0 0\n"
355 "RenderEvent 72 80 0 0 0 0 0\n"
356 "MouseMoveEvent 71 79 0 0 0 0 0\n"
357 "InteractionEvent 71 79 0 0 0 0 0\n"
358 "MouseMoveEvent 71 78 0 0 0 0 0\n"
359 "InteractionEvent 71 78 0 0 0 0 0\n"
360 "TimerEvent 71 78 0 0 0 0 0\n"
361 "RenderEvent 71 78 0 0 0 0 0\n"
362 "MouseMoveEvent 70 74 0 0 0 0 0\n"
363 "InteractionEvent 70 74 0 0 0 0 0\n"
364 "MouseMoveEvent 70 73 0 0 0 0 0\n"
365 "InteractionEvent 70 73 0 0 0 0 0\n"
366 "TimerEvent 70 73 0 0 0 0 0\n"
367 "RenderEvent 70 73 0 0 0 0 0\n"
368 "MouseMoveEvent 70 71 0 0 0 0 0\n"
369 "InteractionEvent 70 71 0 0 0 0 0\n"
370 "MouseMoveEvent 70 70 0 0 0 0 0\n"
371 "InteractionEvent 70 70 0 0 0 0 0\n"
372 "TimerEvent 70 70 0 0 0 0 0\n"
373 "RenderEvent 70 70 0 0 0 0 0\n"
374 "MouseMoveEvent 70 64 0 0 0 0 0\n"
375 "InteractionEvent 70 64 0 0 0 0 0\n"
376 "MouseMoveEvent 70 63 0 0 0 0 0\n"
377 "InteractionEvent 70 63 0 0 0 0 0\n"
378 "TimerEvent 70 63 0 0 0 0 0\n"
379 "RenderEvent 70 63 0 0 0 0 0\n"
380 "MouseMoveEvent 72 59 0 0 0 0 0\n"
381 "InteractionEvent 72 59 0 0 0 0 0\n"
382 "MouseMoveEvent 73 58 0 0 0 0 0\n"
383 "InteractionEvent 73 58 0 0 0 0 0\n"
384 "TimerEvent 73 58 0 0 0 0 0\n"
385 "RenderEvent 73 58 0 0 0 0 0\n"
386 "MouseMoveEvent 77 52 0 0 0 0 0\n"
387 "InteractionEvent 77 52 0 0 0 0 0\n"
388 "MouseMoveEvent 78 51 0 0 0 0 0\n"
389 "InteractionEvent 78 51 0 0 0 0 0\n"
390 "TimerEvent 78 51 0 0 0 0 0\n"
391 "RenderEvent 78 51 0 0 0 0 0\n"
392 "MouseMoveEvent 83 44 0 0 0 0 0\n"
393 "InteractionEvent 83 44 0 0 0 0 0\n"
394 "MouseMoveEvent 85 42 0 0 0 0 0\n"
395 "InteractionEvent 85 42 0 0 0 0 0\n"
396 "MouseMoveEvent 86 41 0 0 0 0 0\n"
397 "InteractionEvent 86 41 0 0 0 0 0\n"
398 "TimerEvent 86 41 0 0 0 0 0\n"
399 "RenderEvent 86 41 0 0 0 0 0\n"
400 "MouseMoveEvent 89 38 0 0 0 0 0\n"
401 "InteractionEvent 89 38 0 0 0 0 0\n"
402 "MouseMoveEvent 90 37 0 0 0 0 0\n"
403 "InteractionEvent 90 37 0 0 0 0 0\n"
404 "TimerEvent 90 37 0 0 0 0 0\n"
405 "RenderEvent 90 37 0 0 0 0 0\n"
406 "MouseMoveEvent 94 33 0 0 0 0 0\n"
407 "InteractionEvent 94 33 0 0 0 0 0\n"
408 "MouseMoveEvent 95 32 0 0 0 0 0\n"
409 "InteractionEvent 95 32 0 0 0 0 0\n"
410 "TimerEvent 95 32 0 0 0 0 0\n"
411 "RenderEvent 95 32 0 0 0 0 0\n"
412 "MouseMoveEvent 99 30 0 0 0 0 0\n"
413 "InteractionEvent 99 30 0 0 0 0 0\n"
414 "MouseMoveEvent 101 29 0 0 0 0 0\n"
415 "InteractionEvent 101 29 0 0 0 0 0\n"
416 "TimerEvent 101 29 0 0 0 0 0\n"
417 "RenderEvent 101 29 0 0 0 0 0\n"
418 "MouseMoveEvent 108 25 0 0 0 0 0\n"
419 "InteractionEvent 108 25 0 0 0 0 0\n"
420 "TimerEvent 108 25 0 0 0 0 0\n"
421 "RenderEvent 108 25 0 0 0 0 0\n"
422 "MouseMoveEvent 111 23 0 0 0 0 0\n"
423 "InteractionEvent 111 23 0 0 0 0 0\n"
424 "TimerEvent 111 23 0 0 0 0 0\n"
425 "RenderEvent 111 23 0 0 0 0 0\n"
426 "MouseMoveEvent 115 21 0 0 0 0 0\n"
427 "InteractionEvent 115 21 0 0 0 0 0\n"
428 "TimerEvent 115 21 0 0 0 0 0\n"
429 "RenderEvent 115 21 0 0 0 0 0\n"
430 "MouseMoveEvent 118 19 0 0 0 0 0\n"
431 "InteractionEvent 118 19 0 0 0 0 0\n"
432 "TimerEvent 118 19 0 0 0 0 0\n"
433 "RenderEvent 118 19 0 0 0 0 0\n"
434 "MouseMoveEvent 122 18 0 0 0 0 0\n"
435 "InteractionEvent 122 18 0 0 0 0 0\n"
436 "TimerEvent 122 18 0 0 0 0 0\n"
437 "RenderEvent 122 18 0 0 0 0 0\n"
438 "MouseMoveEvent 127 16 0 0 0 0 0\n"
439 "InteractionEvent 127 16 0 0 0 0 0\n"
440 "MouseMoveEvent 128 15 0 0 0 0 0\n"
441 "InteractionEvent 128 15 0 0 0 0 0\n"
442 "TimerEvent 128 15 0 0 0 0 0\n"
443 "RenderEvent 128 15 0 0 0 0 0\n"
444 "MouseMoveEvent 133 13 0 0 0 0 0\n"
445 "InteractionEvent 133 13 0 0 0 0 0\n"
446 "TimerEvent 133 13 0 0 0 0 0\n"
447 "RenderEvent 133 13 0 0 0 0 0\n"
448 "MouseMoveEvent 139 11 0 0 0 0 0\n"
449 "InteractionEvent 139 11 0 0 0 0 0\n"
450 "MouseMoveEvent 140 11 0 0 0 0 0\n"
451 "InteractionEvent 140 11 0 0 0 0 0\n"
452 "TimerEvent 140 11 0 0 0 0 0\n"
453 "RenderEvent 140 11 0 0 0 0 0\n"
454 "MouseMoveEvent 144 10 0 0 0 0 0\n"
455 "InteractionEvent 144 10 0 0 0 0 0\n"
456 "MouseMoveEvent 145 9 0 0 0 0 0\n"
457 "InteractionEvent 145 9 0 0 0 0 0\n"
458 "TimerEvent 145 9 0 0 0 0 0\n"
459 "RenderEvent 145 9 0 0 0 0 0\n"
460 "MouseMoveEvent 147 8 0 0 0 0 0\n"
461 "InteractionEvent 147 8 0 0 0 0 0\n"
462 "TimerEvent 147 8 0 0 0 0 0\n"
463 "RenderEvent 147 8 0 0 0 0 0\n"
464 "MouseMoveEvent 150 7 0 0 0 0 0\n"
465 "InteractionEvent 150 7 0 0 0 0 0\n"
466 "MouseMoveEvent 151 7 0 0 0 0 0\n"
467 "InteractionEvent 151 7 0 0 0 0 0\n"
468 "MouseMoveEvent 154 6 0 0 0 0 0\n"
469 "InteractionEvent 154 6 0 0 0 0 0\n"
470 "TimerEvent 154 6 0 0 0 0 0\n"
471 "RenderEvent 154 6 0 0 0 0 0\n"
472 "MouseMoveEvent 156 6 0 0 0 0 0\n"
473 "InteractionEvent 156 6 0 0 0 0 0\n"
474 "MouseMoveEvent 158 5 0 0 0 0 0\n"
475 "InteractionEvent 158 5 0 0 0 0 0\n"
476 "TimerEvent 158 5 0 0 0 0 0\n"
477 "RenderEvent 158 5 0 0 0 0 0\n"
478 "MouseMoveEvent 160 4 0 0 0 0 0\n"
479 "InteractionEvent 160 4 0 0 0 0 0\n"
480 "TimerEvent 160 4 0 0 0 0 0\n"
481 "RenderEvent 160 4 0 0 0 0 0\n"
482 "TimerEvent 160 4 0 0 0 0 0\n"
483 "RenderEvent 160 4 0 0 0 0 0\n"
484 "MouseMoveEvent 162 3 0 0 0 0 0\n"
485 "InteractionEvent 162 3 0 0 0 0 0\n"
486 "MouseMoveEvent 164 2 0 0 0 0 0\n"
487 "InteractionEvent 164 2 0 0 0 0 0\n"
488 "TimerEvent 164 2 0 0 0 0 0\n"
489 "RenderEvent 164 2 0 0 0 0 0\n"
490 "MouseMoveEvent 167 1 0 0 0 0 0\n"
491 "InteractionEvent 167 1 0 0 0 0 0\n"
492 "TimerEvent 167 1 0 0 0 0 0\n"
493 "RenderEvent 167 1 0 0 0 0 0\n"
494 "MouseMoveEvent 171 -1 0 0 0 0 0\n"
495 "InteractionEvent 171 -1 0 0 0 0 0\n"
496 "LeaveEvent 171 -1 0 0 0 0 0\n"
497 "MouseMoveEvent 171 -1 0 0 0 0 0\n"
498 "InteractionEvent 171 -1 0 0 0 0 0\n"
499 "TimerEvent 171 -1 0 0 0 0 0\n"
500 "RenderEvent 171 -1 0 0 0 0 0\n"
501 "TimerEvent 171 -1 0 0 0 0 0\n"
502 "RenderEvent 171 -1 0 0 0 0 0\n"
503 "TimerEvent 171 -1 0 0 0 0 0\n"
504 "RenderEvent 171 -1 0 0 0 0 0\n"
505 "LeftButtonReleaseEvent 171 -1 0 0 0 0 0\n"
506 "EndInteractionEvent 171 -1 0 0 0 0 0\n"
507 "RenderEvent 171 -1 0 0 0 0 0\n"
508 "LeaveEvent 171 -1 0 0 0 0 0\n"
509 "EnterEvent 174 0 0 0 0 0 0\n"
510 "MouseMoveEvent 174 0 0 0 0 0 0\n"
511 "MouseMoveEvent 175 1 0 0 0 0 0\n"
512 "MouseMoveEvent 175 2 0 0 0 0 0\n"
513 "MouseMoveEvent 175 4 0 0 0 0 0\n"
514 "MouseMoveEvent 175 6 0 0 0 0 0\n"
515 "MouseMoveEvent 175 8 0 0 0 0 0\n"
516 "MouseMoveEvent 175 10 0 0 0 0 0\n"
517 "MouseMoveEvent 175 12 0 0 0 0 0\n"
518 "MouseMoveEvent 175 15 0 0 0 0 0\n"
519 "MouseMoveEvent 175 18 0 0 0 0 0\n"
520 "MouseMoveEvent 175 21 0 0 0 0 0\n"
521 "MouseMoveEvent 176 23 0 0 0 0 0\n"
522 "MouseMoveEvent 178 27 0 0 0 0 0\n"
523 "MouseMoveEvent 180 29 0 0 0 0 0\n"
524 "MouseMoveEvent 188 33 0 0 0 0 0\n"
525 "MouseMoveEvent 198 34 0 0 0 0 0\n"
526 "MouseMoveEvent 207 36 0 0 0 0 0\n"
527 "MouseMoveEvent 221 36 0 0 0 0 0\n"
528 "MouseMoveEvent 238 36 0 0 0 0 0\n"
529 "MouseMoveEvent 255 36 0 0 0 0 0\n"
530 "MouseMoveEvent 272 36 0 0 0 0 0\n"
531 "MouseMoveEvent 289 36 0 0 0 0 0\n"
532 "LeaveEvent 306 36 0 0 0 0 0\n"
533 ;
534 
TestGPURayCastTwoComponentsIndependent(int argc,char * argv[])535 int TestGPURayCastTwoComponentsIndependent(int argc, char *argv[])
536 {
537   cout << "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)" << endl;
538 
539   int dims[3] = {35, 35, 35};
540 
541   // Create a vtkImageData with two components
542   vtkNew<vtkImageData> image;
543   image->SetDimensions(dims[0], dims[1], dims[2]);
544   image->AllocateScalars(VTK_DOUBLE, 2);
545 
546   // Fill the first half rectangular parallelopiped along X with the
547   // first component values and the second half with second component values
548   double * ptr = static_cast<double *> (image->GetScalarPointer(0, 0, 0));
549 
550   for (int z = 0; z < dims[2]; ++z)
551   {
552     for (int y = 0; y < dims[1]; ++y)
553     {
554       for (int x = 0; x < dims[0]; ++x)
555       {
556         if (x < dims[0]/2)
557         {
558           *ptr++ = 1.0;
559           *ptr++ = 0.0;
560         }
561         else
562         {
563           *ptr++ = 0.0;
564           *ptr++ = 1.0;
565         }
566       }
567     }
568   }
569 
570   vtkNew<vtkRenderWindow> renWin;
571   renWin->SetSize(301, 300); // Intentional NPOT size
572   renWin->SetMultiSamples(0);
573 
574   vtkNew<vtkRenderer> ren;
575   renWin->AddRenderer(ren);
576 
577   vtkNew<vtkRenderWindowInteractor> iren;
578   vtkNew<vtkInteractorStyleTrackballCamera> style;
579   iren->SetInteractorStyle(style);
580   iren->SetRenderWindow(renWin);
581 
582   renWin->Render();
583 
584   // Volume render the dataset
585   vtkNew<vtkGPUVolumeRayCastMapper> mapper;
586   mapper->AutoAdjustSampleDistancesOff();
587   mapper->SetSampleDistance(0.9);
588   mapper->SetInputData(image);
589 
590   // Color transfer function
591   vtkNew<vtkColorTransferFunction> ctf1;
592   ctf1->AddRGBPoint(0.0, 0.0, 0.0, 0.0);
593   ctf1->AddRGBPoint(1.0, 1.0, 0.0, 0.0);
594 
595   vtkNew<vtkColorTransferFunction> ctf2;
596   ctf2->AddRGBPoint(0.0, 0.0, 0.0, 0.0);
597   ctf2->AddRGBPoint(1.0, 0.0, 0.0, 1.0);
598 
599   // Opacity functions
600   vtkNew<vtkPiecewiseFunction> pf1;
601   pf1->AddPoint(0.0, 0.0);
602   pf1->AddPoint(1.0, 0.5);
603 
604   vtkNew<vtkPiecewiseFunction> pf2;
605   pf2->AddPoint(0.0, 0.0);
606   pf2->AddPoint(1.0, 0.5);
607 
608   // Volume property with independent components ON
609   vtkNew<vtkVolumeProperty> property;
610   property->IndependentComponentsOn();
611 
612   // Set color and opacity functions
613   property->SetColor(0, ctf1);
614   property->SetColor(1, ctf2);
615   property->SetScalarOpacity(0, pf1);
616   property->SetScalarOpacity(1, pf2);
617 
618   vtkNew<vtkVolume> volume;
619   volume->SetMapper(mapper);
620   volume->SetProperty(property);
621   ren->AddVolume(volume);
622 
623   ren->ResetCamera();
624 
625   iren->Initialize();
626   renWin->Render();
627 
628   return vtkTesting::InteractorEventLoop(argc, argv,
629                                          iren,
630                                          TestGPURayCastTwoComponentsIndependentLog);
631 }
632