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 
86 class VTKRENDERINGVOLUMEOPENGL2_EXPORT vtkSmartVolumeMapper : public vtkVolumeMapper
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 
152 
153  vtkGetMacro( RequestedRenderMode, int );
155 
157 
162  vtkSetClampMacro( InteractiveUpdateRate, double, 1.0e-10, 1.0e10 );
164 
166 
168  vtkGetMacro( InteractiveUpdateRate, double );
170 
173  int GetLastUsedRenderMode();
174 
176 
180  vtkSetMacro( MaxMemoryInBytes, vtkIdType );
181  vtkGetMacro( MaxMemoryInBytes, vtkIdType );
183 
185 
188  vtkSetClampMacro( MaxMemoryFraction, float, 0.1f, 1.0f );
189  vtkGetMacro( MaxMemoryFraction, float );
191 
193 
195  vtkSetClampMacro(InterpolationMode, int,
197  vtkGetMacro(InterpolationMode, int);
198  void SetInterpolationModeToNearestNeighbor();
199  void SetInterpolationModeToLinear();
200  void SetInterpolationModeToCubic();
202 
204 
207  void CreateCanonicalView( vtkRenderer *ren,
208  vtkVolume *volume,
209  vtkVolume *volume2,
211  int blend_mode,
212  double viewDirection[3],
213  double viewUp[3] );
215 
216 
217 //BTX
220  void Render( vtkRenderer *, vtkVolume * );
221 
223 
228 //ETX
230 
231 protected:
234 
238  void ConnectMapperInput(vtkVolumeMapper *m);
239 
243  void ConnectFilterInput(vtkImageResample *f);
244 
245  // Window / level ivars
246  float FinalColorWindow;
247  float FinalColorLevel;
248 
249  // GPU mapper-specific memory ivars.
250  vtkIdType MaxMemoryInBytes;
251  float MaxMemoryFraction;
252 
253  // Used for downsampling.
254  int InterpolationMode;
255 
256  // The requested render mode is used to compute the current render mode. Note
257  // that the current render mode can be invalid if the requested mode is not
258  // supported.
259  int RequestedRenderMode;
260  int CurrentRenderMode;
261 
262  // Initialization variables.
263  int Initialized;
264  vtkTimeStamp SupportStatusCheckTime;
265  int GPUSupported;
266  int RayCastSupported;
267  int LowResGPUNecessary;
268 
269  // This is the resample filter that may be used if we need to
270  // create a low resolution version of the volume for GPU rendering
271  vtkImageResample *GPUResampleFilter;
272 
273  // If the DesiredUpdateRate of the vtkRenderWindow causing the Render is at
274  // or above this value, the render is considered interactive. Otherwise it is
275  // considered still.
276  double InteractiveUpdateRate;
277 
278  // The initialize method. Called from ComputeRenderMode whenever something
279  // relevant has changed.
280  void Initialize(vtkRenderer *ren,
281  vtkVolume *vol);
282 
283  // The method that computes the render mode from the requested render mode
284  // based on the support status for each render method.
285  void ComputeRenderMode(vtkRenderer *ren,
286  vtkVolume *vol);
287 
288  // The three potential mappers
289  vtkGPUVolumeRayCastMapper *GPULowResMapper;
290  vtkGPUVolumeRayCastMapper *GPUMapper;
291  vtkFixedPointVolumeRayCastMapper *RayCastMapper;
292 
293 
294  // We need to keep track of the blend mode we had when we initialized
295  // because we need to reinitialize (and recheck hardware support) if
296  // it changes
297  int InitializedBlendMode;
298 
299 private:
300  vtkSmartVolumeMapper(const vtkSmartVolumeMapper&); // Not implemented.
301  void operator=(const vtkSmartVolumeMapper&); // Not implemented.
302 };
303 
304 #endif
GLclampf f
Definition: vtkgl.h:14181
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:49
#define VTK_RESLICE_NEAREST
Abstract class for a volume mapper.
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: vtkgl.h:11341
#define VTK_RESLICE_CUBIC
Adaptive volume mapper.
void PrintSelf(ostream &os, vtkIndent indent)
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:83
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
#define vtkSetClampMacro(name, type, min, max)
Definition: vtkSetGet.h:133
int vtkIdType
Definition: vtkType.h:281
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:632
window superclass for vtkRenderWindow
Definition: vtkWindow.h:33
a simple class to control print indentation
Definition: vtkIndent.h:38
const GLfloat * m
Definition: vtkgl.h:18169
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.
GLenum mode
Definition: vtkgl.h:12325
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69