VTK
vtkSmartVolumeMapper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSmartVolumeMapper.h
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 =========================================================================*/
72 #ifndef vtkSmartVolumeMapper_h
73 #define vtkSmartVolumeMapper_h
74 
75 #include "vtkRenderingVolumeOpenGL2Module.h" // For export macro
76 #include "vtkVolumeMapper.h"
77 #include "vtkImageReslice.h" // for VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC
78 
81 class vtkImageResample;
82 class vtkRenderWindow;
83 class vtkVolume;
84 class vtkVolumeProperty;
85 
87 {
88 public:
89  static vtkSmartVolumeMapper *New();
91  void PrintSelf( ostream& os, vtkIndent indent );
92 
94 
100  vtkSetMacro( FinalColorWindow, float );
102 
104 
105  vtkGetMacro( FinalColorWindow, float );
107 
109 
113  vtkSetMacro( FinalColorLevel, float );
115 
117 
118  vtkGetMacro( FinalColorLevel, float );
120 
121 //BTX
122 // The possible values for the default and current render mode ivars
123  enum
124  {
125  DefaultRenderMode=0,
126  RayCastAndTextureRenderMode,
127  RayCastRenderMode,
128  TextureRenderMode,
129  GPURenderMode,
130  UndefinedRenderMode,
131  InvalidRenderMode
132  };
133 //ETX
134 
137  void SetRequestedRenderMode(int mode);
138 
143  void SetRequestedRenderModeToDefault();
144 
149  void SetRequestedRenderModeToRayCast();
150 
154  void SetRequestedRenderModeToGPU();
155 
157 
158  vtkGetMacro( RequestedRenderMode, int );
160 
163  int GetLastUsedRenderMode();
164 
166 
170  vtkSetMacro( MaxMemoryInBytes, vtkIdType );
171  vtkGetMacro( MaxMemoryInBytes, vtkIdType );
173 
175 
178  vtkSetClampMacro( MaxMemoryFraction, float, 0.1f, 1.0f );
179  vtkGetMacro( MaxMemoryFraction, float );
181 
183 
185  vtkSetClampMacro(InterpolationMode, int,
187  vtkGetMacro(InterpolationMode, int);
188  void SetInterpolationModeToNearestNeighbor();
189  void SetInterpolationModeToLinear();
190  void SetInterpolationModeToCubic();
192 
194 
197  void CreateCanonicalView( vtkRenderer *ren,
198  vtkVolume *volume,
199  vtkVolume *volume2,
201  int blend_mode,
202  double viewDirection[3],
203  double viewUp[3] );
205 
207 
211  vtkSetClampMacro( InteractiveUpdateRate, double, 1.0e-10, 1.0e10 );
213 
215 
217  vtkGetMacro( InteractiveUpdateRate, double );
219 
221 
227  vtkSetClampMacro( InteractiveAdjustSampleDistances, int, 0, 1);
228  vtkGetMacro( InteractiveAdjustSampleDistances, int);
229  vtkBooleanMacro( InteractiveAdjustSampleDistances, int);
231 
233 
239  vtkSetClampMacro( AutoAdjustSampleDistances, int, 0, 1 );
240  vtkGetMacro( AutoAdjustSampleDistances, int );
241  vtkBooleanMacro( AutoAdjustSampleDistances, int );
243 
245 
250  vtkSetMacro( SampleDistance, float );
251  vtkGetMacro( SampleDistance, float );
253 
254 
255 //BTX
258  void Render( vtkRenderer *, vtkVolume * );
259 
261 
266 //ETX
268 
269 protected:
272 
276  void ConnectMapperInput(vtkVolumeMapper *m);
277 
281  void ConnectFilterInput(vtkImageResample *f);
282 
283  // Window / level ivars
284  float FinalColorWindow;
285  float FinalColorLevel;
286 
287  // GPU mapper-specific memory ivars.
288  vtkIdType MaxMemoryInBytes;
289  float MaxMemoryFraction;
290 
291  // Used for downsampling.
292  int InterpolationMode;
293 
294  // The requested render mode is used to compute the current render mode. Note
295  // that the current render mode can be invalid if the requested mode is not
296  // supported.
297  int RequestedRenderMode;
298  int CurrentRenderMode;
299 
300  // Initialization variables.
301  int Initialized;
302  vtkTimeStamp SupportStatusCheckTime;
303  int GPUSupported;
304  int RayCastSupported;
305  int LowResGPUNecessary;
306 
307  // This is the resample filter that may be used if we need to
308  // create a low resolution version of the volume for GPU rendering
309  vtkImageResample *GPUResampleFilter;
310 
311  // The initialize method. Called from ComputeRenderMode whenever something
312  // relevant has changed.
313  void Initialize(vtkRenderer *ren,
314  vtkVolume *vol);
315 
316  // The method that computes the render mode from the requested render mode
317  // based on the support status for each render method.
318  void ComputeRenderMode(vtkRenderer *ren,
319  vtkVolume *vol);
320 
321  // The three potential mappers
322  vtkGPUVolumeRayCastMapper *GPULowResMapper;
323  vtkGPUVolumeRayCastMapper *GPUMapper;
324  vtkFixedPointVolumeRayCastMapper *RayCastMapper;
325 
326 
327  // We need to keep track of the blend mode we had when we initialized
328  // because we need to reinitialize (and recheck hardware support) if
329  // it changes
330  int InitializedBlendMode;
331 
332  // The distance between sample points along the ray
334 
335  // Set whether or not the sample distance should be automatically calculated
336  // within the internal volume mapper
338 
339  // If the DesiredUpdateRate of the vtkRenderWindow causing the Render is at
340  // or above this value, the render is considered interactive. Otherwise it is
341  // considered still.
342  double InteractiveUpdateRate;
343 
344  // If the InteractiveAdjustSampleDistances flag is enabled,
345  // vtkSmartVolumeMapper interactively sets and resets the
346  // AutoAdjustSampleDistances flag on the internal volume mapper. This flag
347  // along with InteractiveUpdateRate is useful to adjust volume mapper sample
348  // distance based on whether the render is interactive or still.
350 
351 private:
352  vtkSmartVolumeMapper(const vtkSmartVolumeMapper&); // Not implemented.
353  void operator=(const vtkSmartVolumeMapper&); // Not implemented.
354 };
355 
356 #endif
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:49
#define VTK_RESLICE_NEAREST
Abstract class for a volume mapper.
#define VTK_RESLICE_CUBIC
Adaptive volume mapper.
void PrintSelf(ostream &os, vtkIndent indent)
#define VTKRENDERINGVOLUMEOPENGL2_EXPORT
record modification and/or execution time
Definition: vtkTimeStamp.h:34
Resamples an image to be larger or smaller.
abstract specification for renderers
Definition: vtkRenderer.h:62
int vtkIdType
Definition: vtkType.h:247
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
a simple class to control print indentation
Definition: vtkIndent.h:38
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
virtual void Render(vtkRenderer *ren, vtkVolume *vol)=0
represents the common properties for rendering a volume.
create a window for renderers to draw into
virtual void ReleaseGraphicsResources(vtkWindow *)
static vtkAlgorithm * New()
Ray casting performed on the GPU.