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 
158 
159  vtkGetMacro( RequestedRenderMode, int );
161 
163 
168  vtkSetClampMacro( InteractiveUpdateRate, double, 1.0e-10, 1.0e10 );
170 
172 
174  vtkGetMacro( InteractiveUpdateRate, double );
176 
179  int GetLastUsedRenderMode();
180 
182 
186  vtkSetMacro( MaxMemoryInBytes, vtkIdType );
187  vtkGetMacro( MaxMemoryInBytes, vtkIdType );
189 
191 
194  vtkSetClampMacro( MaxMemoryFraction, float, 0.1f, 1.0f );
195  vtkGetMacro( MaxMemoryFraction, float );
197 
199 
201  vtkSetClampMacro(InterpolationMode, int,
203  vtkGetMacro(InterpolationMode, int);
204  void SetInterpolationModeToNearestNeighbor();
205  void SetInterpolationModeToLinear();
206  void SetInterpolationModeToCubic();
208 
210 
213  void CreateCanonicalView( vtkRenderer *ren,
214  vtkVolume *volume,
215  vtkVolume *volume2,
217  int blend_mode,
218  double viewDirection[3],
219  double viewUp[3] );
221 
222 
223 //BTX
226  void Render( vtkRenderer *, vtkVolume * );
227 
229 
234 //ETX
236 
237 protected:
240 
244  void ConnectMapperInput(vtkVolumeMapper *m);
245 
249  void ConnectFilterInput(vtkImageResample *f);
250 
251  // Window / level ivars
252  float FinalColorWindow;
253  float FinalColorLevel;
254 
255  // GPU mapper-specific memory ivars.
256  vtkIdType MaxMemoryInBytes;
257  float MaxMemoryFraction;
258 
259  // Used for downsampling.
260  int InterpolationMode;
261 
262  // The requested render mode is used to compute the current render mode. Note
263  // that the current render mode can be invalid if the requested mode is not
264  // supported.
265  int RequestedRenderMode;
266  int CurrentRenderMode;
267 
268  // Initialization variables.
269  int Initialized;
270  vtkTimeStamp SupportStatusCheckTime;
271  int GPUSupported;
272  int RayCastSupported;
273  int LowResGPUNecessary;
274 
275  // This is the resample filter that may be used if we need to
276  // create a low resolution version of the volume for GPU rendering
277  vtkImageResample *GPUResampleFilter;
278 
279  // If the DesiredUpdateRate of the vtkRenderWindow causing the Render is at
280  // or above this value, the render is considered interactive. Otherwise it is
281  // considered still.
282  double InteractiveUpdateRate;
283 
284  // The initialize method. Called from ComputeRenderMode whenever something
285  // relevant has changed.
286  void Initialize(vtkRenderer *ren,
287  vtkVolume *vol);
288 
289  // The method that computes the render mode from the requested render mode
290  // based on the support status for each render method.
291  void ComputeRenderMode(vtkRenderer *ren,
292  vtkVolume *vol);
293 
294  // The three potential mappers
295  vtkGPUVolumeRayCastMapper *GPULowResMapper;
296  vtkGPUVolumeRayCastMapper *GPUMapper;
297  vtkFixedPointVolumeRayCastMapper *RayCastMapper;
298 
299 
300  // We need to keep track of the blend mode we had when we initialized
301  // because we need to reinitialize (and recheck hardware support) if
302  // it changes
303  int InitializedBlendMode;
304 
305 private:
306  vtkSmartVolumeMapper(const vtkSmartVolumeMapper&); // Not implemented.
307  void operator=(const vtkSmartVolumeMapper&); // Not implemented.
308 };
309 
310 #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