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 =========================================================================*/
109 #ifndef vtkSmartVolumeMapper_h
110 #define vtkSmartVolumeMapper_h
111 
112 #include "vtkRenderingVolumeOpenGLModule.h" // For export macro
113 #include "vtkVolumeMapper.h"
114 #include "vtkImageReslice.h" // for VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC
115 
118 class vtkImageResample;
120 class vtkRenderWindow;
121 class vtkVolume;
122 class vtkVolumeProperty;
123 #if !defined(VTK_LEGACY_REMOVE)
125 #endif // VTK_LEGACY_REMOVE
126 
127 class VTKRENDERINGVOLUMEOPENGL_EXPORT vtkSmartVolumeMapper : public vtkVolumeMapper
128 {
129 public:
130  static vtkSmartVolumeMapper *New();
132  void PrintSelf( ostream& os, vtkIndent indent ) VTK_OVERRIDE;
133 
135 
145  vtkSetMacro( FinalColorWindow, float );
147 
149 
152  vtkGetMacro( FinalColorWindow, float );
154 
156 
163  vtkSetMacro( FinalColorLevel, float );
165 
167 
170  vtkGetMacro( FinalColorLevel, float );
172 
173 // The possible values for the default and current render mode ivars
174  enum
175  {
176  DefaultRenderMode=0,
183  InvalidRenderMode
184  };
185 
190  void SetRequestedRenderMode(int mode);
191 
197  void SetRequestedRenderModeToDefault();
198 
204  void SetRequestedRenderModeToGPU();
205 
210 #if !defined(VTK_LEGACY_REMOVE)
211  void SetRequestedRenderModeToTexture();
212 #endif // VTK_LEGACY_REMOVE
213 
221 #if !defined(VTK_LEGACY_REMOVE)
222  void SetRequestedRenderModeToRayCastAndTexture();
223 #endif // VTK_LEGACY_REMOVE
224 
230  void SetRequestedRenderModeToRayCast();
231 
236  void SetRequestedRenderModeToOSPRay();
237 
239 
242  vtkGetMacro( RequestedRenderMode, int );
244 
246 
253  vtkSetClampMacro( InteractiveUpdateRate, double, 1.0e-10, 1.0e10 );
255 
257 
262  vtkGetMacro( InteractiveUpdateRate, double );
264 
269  int GetLastUsedRenderMode();
270 
272 
279  vtkSetMacro( MaxMemoryInBytes, vtkIdType );
280  vtkGetMacro( MaxMemoryInBytes, vtkIdType );
282 
284 
290  vtkSetClampMacro( MaxMemoryFraction, float, 0.1f, 1.0f );
291  vtkGetMacro( MaxMemoryFraction, float );
293 
295 
299  vtkSetClampMacro(InterpolationMode, int,
301  vtkGetMacro(InterpolationMode, int);
302  void SetInterpolationModeToNearestNeighbor();
303  void SetInterpolationModeToLinear();
304  void SetInterpolationModeToCubic();
306 
312  void CreateCanonicalView( vtkRenderer *ren,
313  vtkVolume *volume,
314  vtkVolume *volume2,
316  int blend_mode,
317  double viewDirection[3],
318  double viewUp[3] );
319 
324  void Render( vtkRenderer *, vtkVolume * ) VTK_OVERRIDE;
325 
332  void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE;
333 
334 protected:
336  ~vtkSmartVolumeMapper() VTK_OVERRIDE;
337 
343  void ConnectMapperInput(vtkVolumeMapper *m);
344 
350  void ConnectFilterInput(vtkImageResample *f);
351 
352  // Window / level ivars
353  float FinalColorWindow;
354  float FinalColorLevel;
355 
356  // GPU mapper-specific memory ivars.
357  vtkIdType MaxMemoryInBytes;
358  float MaxMemoryFraction;
359 
360  // Used for downsampling.
361  int InterpolationMode;
362 
363  // The requested render mode is used to compute the current render mode. Note
364  // that the current render mode can be invalid if the requested mode is not
365  // supported.
366  int RequestedRenderMode;
367  int CurrentRenderMode;
368 
369  // Initialization variables.
370  int Initialized;
371  vtkTimeStamp SupportStatusCheckTime;
372  int TextureSupported;
373  int GPUSupported;
374  int RayCastSupported;
375  int LowResGPUNecessary;
376 
377  // This is the resample filter that may be used if we need to
378  // create a low resolution version of the volume for GPU rendering
379  vtkImageResample *GPUResampleFilter;
380 
381  // If the DesiredUpdateRate of the vtkRenderWindow causing the Render is at
382  // or above this value, the render is considered interactive. Otherwise it is
383  // considered still.
384  double InteractiveUpdateRate;
385 
386  // The initialize method. Called from ComputeRenderMode whenever something
387  // relevant has changed.
388  void Initialize(vtkRenderer *ren,
389  vtkVolume *vol);
390 
391  // The method that computes the render mode from the requested render mode
392  // based on the support status for each render method.
393  void ComputeRenderMode(vtkRenderer *ren,
394  vtkVolume *vol);
395 
396  // The three potential mappers
397  vtkGPUVolumeRayCastMapper *GPULowResMapper;
400 #if !defined(VTK_LEGACY_REMOVE)
402 #endif // VTK_LEGACY_REMOVE
403 
404  // We need to keep track of the blend mode we had when we initialized
405  // because we need to reinitialize (and recheck hardware support) if
406  // it changes
408 
409 private:
410  vtkSmartVolumeMapper(const vtkSmartVolumeMapper&) VTK_DELETE_FUNCTION;
411  void operator=(const vtkSmartVolumeMapper&) VTK_DELETE_FUNCTION;
412 
413  vtkOSPRayVolumeInterface *OSPRayMapper;
414 };
415 
416 #endif
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:50
#define VTK_RESLICE_NEAREST
Abstract class for a volume mapper.
volume render with 3D texture mapping
#define VTK_RESLICE_CUBIC
Adaptive volume mapper.
record modification and/or execution time
Definition: vtkTimeStamp.h:35
Resamples an image to be larger or smaller.
abstract specification for renderers
Definition: vtkRenderer.h:63
int vtkIdType
Definition: vtkType.h:345
void Render(vtkRenderer *ren, vtkVolume *vol) override=0
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
a simple class to control print indentation
Definition: vtkIndent.h:39
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
represents the common properties for rendering a volume.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
create a window for renderers to draw into
Removes link dependence on optional ospray module.
int InitializedBlendMode
We need to keep track of the blend mode we had when we initialized because we need to reinitialize (a...
static vtkAlgorithm * New()
Ray casting performed on the GPU.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkVolumeTextureMapper3D * TextureMapper