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 =========================================================================*/
78 #ifndef vtkSmartVolumeMapper_h
79 #define vtkSmartVolumeMapper_h
80 
81 #include "vtkRenderingVolumeOpenGL2Module.h" // For export macro
82 #include "vtkVolumeMapper.h"
83 #include "vtkImageReslice.h" // for VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC
84 
87 class vtkImageResample;
88 class vtkRenderWindow;
89 class vtkVolume;
90 class vtkVolumeProperty;
91 
92 class VTKRENDERINGVOLUMEOPENGL2_EXPORT vtkSmartVolumeMapper : public vtkVolumeMapper
93 {
94 public:
95  static vtkSmartVolumeMapper *New();
97  void PrintSelf( ostream& os, vtkIndent indent );
98 
100 
106  vtkSetMacro( FinalColorWindow, float );
108 
110 
111  vtkGetMacro( FinalColorWindow, float );
113 
115 
119  vtkSetMacro( FinalColorLevel, float );
121 
123 
124  vtkGetMacro( FinalColorLevel, float );
126 
127 //BTX
128 // The possible values for the default and current render mode ivars
129  enum
130  {
131  DefaultRenderMode=0,
132  RayCastAndTextureRenderMode,
133  RayCastRenderMode,
134  TextureRenderMode,
135  GPURenderMode,
136  UndefinedRenderMode,
137  InvalidRenderMode
138  };
139 //ETX
140 
143  void SetRequestedRenderMode(int mode);
144 
149  void SetRequestedRenderModeToDefault();
150 
155  void SetRequestedRenderModeToRayCast();
156 
160  void SetRequestedRenderModeToGPU();
161 
163 
164  vtkGetMacro( RequestedRenderMode, int );
166 
169  int GetLastUsedRenderMode();
170 
172 
176  vtkSetMacro( MaxMemoryInBytes, vtkIdType );
177  vtkGetMacro( MaxMemoryInBytes, vtkIdType );
179 
181 
184  vtkSetClampMacro( MaxMemoryFraction, float, 0.1f, 1.0f );
185  vtkGetMacro( MaxMemoryFraction, float );
187 
189 
191  vtkSetClampMacro(InterpolationMode, int,
193  vtkGetMacro(InterpolationMode, int);
194  void SetInterpolationModeToNearestNeighbor();
195  void SetInterpolationModeToLinear();
196  void SetInterpolationModeToCubic();
198 
200 
203  void CreateCanonicalView( vtkRenderer *ren,
204  vtkVolume *volume,
205  vtkVolume *volume2,
207  int blend_mode,
208  double viewDirection[3],
209  double viewUp[3] );
211 
213 
217  vtkSetClampMacro( InteractiveUpdateRate, double, 1.0e-10, 1.0e10 );
219 
221 
223  vtkGetMacro( InteractiveUpdateRate, double );
225 
227 
233  vtkSetClampMacro( InteractiveAdjustSampleDistances, int, 0, 1);
234  vtkGetMacro( InteractiveAdjustSampleDistances, int);
235  vtkBooleanMacro( InteractiveAdjustSampleDistances, int);
237 
239 
245  vtkSetClampMacro( AutoAdjustSampleDistances, int, 0, 1 );
246  vtkGetMacro( AutoAdjustSampleDistances, int );
247  vtkBooleanMacro( AutoAdjustSampleDistances, int );
249 
251 
256  vtkSetMacro( SampleDistance, float );
257  vtkGetMacro( SampleDistance, float );
259 
260 
261 //BTX
264  void Render( vtkRenderer *, vtkVolume * );
265 
267 
272 //ETX
274 
275 protected:
278 
282  void ConnectMapperInput(vtkVolumeMapper *m);
283 
287  void ConnectFilterInput(vtkImageResample *f);
288 
289  // Window / level ivars
290  float FinalColorWindow;
291  float FinalColorLevel;
292 
293  // GPU mapper-specific memory ivars.
294  vtkIdType MaxMemoryInBytes;
295  float MaxMemoryFraction;
296 
297  // Used for downsampling.
298  int InterpolationMode;
299 
300  // The requested render mode is used to compute the current render mode. Note
301  // that the current render mode can be invalid if the requested mode is not
302  // supported.
303  int RequestedRenderMode;
304  int CurrentRenderMode;
305 
306  // Initialization variables.
307  int Initialized;
308  vtkTimeStamp SupportStatusCheckTime;
309  int GPUSupported;
310  int RayCastSupported;
311  int LowResGPUNecessary;
312 
313  // This is the resample filter that may be used if we need to
314  // create a low resolution version of the volume for GPU rendering
315  vtkImageResample *GPUResampleFilter;
316 
317  // The initialize method. Called from ComputeRenderMode whenever something
318  // relevant has changed.
319  void Initialize(vtkRenderer *ren,
320  vtkVolume *vol);
321 
322  // The method that computes the render mode from the requested render mode
323  // based on the support status for each render method.
324  void ComputeRenderMode(vtkRenderer *ren,
325  vtkVolume *vol);
326 
327  // The three potential mappers
328  vtkGPUVolumeRayCastMapper *GPULowResMapper;
329  vtkGPUVolumeRayCastMapper *GPUMapper;
330  vtkFixedPointVolumeRayCastMapper *RayCastMapper;
331 
332 
333  // We need to keep track of the blend mode we had when we initialized
334  // because we need to reinitialize (and recheck hardware support) if
335  // it changes
336  int InitializedBlendMode;
337 
338  // The distance between sample points along the ray
340 
341  // Set whether or not the sample distance should be automatically calculated
342  // within the internal volume mapper
344 
345  // If the DesiredUpdateRate of the vtkRenderWindow causing the Render is at
346  // or above this value, the render is considered interactive. Otherwise it is
347  // considered still.
348  double InteractiveUpdateRate;
349 
350  // If the InteractiveAdjustSampleDistances flag is enabled,
351  // vtkSmartVolumeMapper interactively sets and resets the
352  // AutoAdjustSampleDistances flag on the internal volume mapper. This flag
353  // along with InteractiveUpdateRate is useful to adjust volume mapper sample
354  // distance based on whether the render is interactive or still.
356 
357 private:
358  vtkSmartVolumeMapper(const vtkSmartVolumeMapper&); // Not implemented.
359  void operator=(const vtkSmartVolumeMapper&); // Not implemented.
360 };
361 
362 #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)
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:63
int vtkIdType
Definition: vtkType.h:275
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.