VTK
vtkOpenGLGPUVolumeRayCastMapper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkOpenGLGPUVolumeRayCastMapper.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 =========================================================================*/
15 
16 #ifndef vtkOpenGLGPUVolumeRayCastMapper_h
17 #define vtkOpenGLGPUVolumeRayCastMapper_h
18 
19 #include "vtkRenderingVolumeOpenGL2Module.h" // For export macro
20 
22 
23 // Forward declarations
24 class vtkOpenGLCamera;
25 class vtkShaderProgram;
26 class vtkTextureObject;
29 
30 //----------------------------------------------------------------------------
31 class VTKRENDERINGVOLUMEOPENGL2_EXPORT vtkOpenGLGPUVolumeRayCastMapper :
33 {
34 public:
36 
37  enum Passes
38  {
40  DepthPass = 1
41  };
42 
44  void PrintSelf( ostream& os, vtkIndent indent );
45 
46  // Description:
47  // Low level API to enable access to depth texture in
48  // RenderToTexture mode. It will return either NULL if
49  // RenderToImage was never turned on or texture captured
50  // the last time RenderToImage was on.
52 
53  // Description:
54  // Low level API to enable access to color texture in
55  // RenderToTexture mode. It will return either NULL if
56  // RenderToImage was never turned on or texture captured
57  // the last time RenderToImage was on.
59 
60  // Description:
61  // Low level API to export the depth texture as vtkImageData in
62  // RenderToImage mode.
64 
65  // Description:
66  // Low level API to export the color texture as vtkImageData in
67  // RenderToImage mode.
69 
70  // Description:
71  // Mapper can have multiple passes and internally it will set
72  // the state. The state can not be set externally explicitly
73  // but can be set indirectly depending on the options set by
74  // the user.
75  vtkGetMacro(CurrentPass, int);
76 
78 
85  vtkSetVector2Macro(NoiseTextureSize, int);
87 
88 protected:
91 
92  // Description:
93  // Delete OpenGL objects.
94  // \post done: this->OpenGLObjectsCreated==0
95  virtual void ReleaseGraphicsResources(vtkWindow *window);
97 
98  // Description:
99  // Build vertex and fragment shader for the volume rendering
101  int noOfComponents,
102  int independentComponents);
103 
104  // Description:
105  // Build vertex and fragment shader for the volume rendering
106  void BuildShader(vtkRenderer* ren, vtkVolume* vol, int noOfCmponents);
107 
108  // TODO Take these out as these are no longer needed
109  // Methods called by the AMR Volume Mapper.
110  virtual void PreRender(vtkRenderer * vtkNotUsed(ren),
111  vtkVolume *vtkNotUsed(vol),
112  double vtkNotUsed(datasetBounds)[6],
113  double vtkNotUsed(scalarRange)[2],
114  int vtkNotUsed(noOfComponents),
115  unsigned int vtkNotUsed(numberOfLevels)) {};
116 
117  // \pre input is up-to-date
118  virtual void RenderBlock(vtkRenderer *vtkNotUsed(ren),
119  vtkVolume *vtkNotUsed(vol),
120  unsigned int vtkNotUsed(level)) {}
121 
122  virtual void PostRender(vtkRenderer *vtkNotUsed(ren),
123  int vtkNotUsed(noOfComponents)) {}
124 
125  // Description:
126  // Rendering volume on GPU
127  void GPURender(vtkRenderer *ren, vtkVolume *vol);
128 
129  // Description:
130  // Method that performs the actual rendering given a volume and a shader
132  vtkVolume* vol,
133  vtkImageData* input,
134  vtkOpenGLCamera* cam,
135  vtkShaderProgram* shaderProgram,
136  int noOfComponents,
137  int independentComponents);
138 
139  // Description:
140  // Update the reduction factor of the render viewport (this->ReductionFactor)
141  // according to the time spent in seconds to render the previous frame
142  // (this->TimeToDraw) and a time in seconds allocated to render the next
143  // frame (allocatedTime).
144  // \pre valid_current_reduction_range: this->ReductionFactor>0.0 && this->ReductionFactor<=1.0
145  // \pre positive_TimeToDraw: this->TimeToDraw>=0.0
146  // \pre positive_time: allocatedTime>0
147  // \post valid_new_reduction_range: this->ReductionFactor>0.0 && this->ReductionFactor<=1.0
148  void ComputeReductionFactor(double allocatedTime);
149 
150  // Description:
151  // Empty implementation.
152  void GetReductionRatio(double* ratio)
153  {
154  ratio[0] = ratio[1] = ratio[2] = 1.0;
155  }
156 
157 
158  // Description:
159  // Empty implementation.
160  virtual int IsRenderSupported(vtkRenderWindow *vtkNotUsed(window),
161  vtkVolumeProperty *vtkNotUsed(property))
162  {
163  return 1;
164  }
165 
168 
169 private:
170  class vtkInternal;
171  vtkInternal* Impl;
172 
173  vtkImplicitFunction* NoiseGenerator;
174  int NoiseTextureSize[2];
175 
177  const vtkOpenGLGPUVolumeRayCastMapper&) VTK_DELETE_FUNCTION;
178  void operator=(const vtkOpenGLGPUVolumeRayCastMapper&) VTK_DELETE_FUNCTION;
179 };
180 
181 #endif // vtkOpenGLGPUVolumeRayCastMapper_h
vtkOpenGLGPUVolumeRayCastMapper::ResourceCallback
vtkGenericOpenGLResourceFreeCallback * ResourceCallback
Definition: vtkOpenGLGPUVolumeRayCastMapper.h:96
vtkOpenGLGPUVolumeRayCastMapper::BuildShader
void BuildShader(vtkRenderer *ren, vtkVolume *vol, int noOfCmponents)
vtkOpenGLGPUVolumeRayCastMapper::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkOpenGLGPUVolumeRayCastMapper::DoGPURender
void DoGPURender(vtkRenderer *ren, vtkVolume *vol, vtkImageData *input, vtkOpenGLCamera *cam, vtkShaderProgram *shaderProgram, int noOfComponents, int independentComponents)
vtkGPUVolumeRayCastMapper.h
vtkVolume
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:51
vtkOpenGLGPUVolumeRayCastMapper::RenderBlock
virtual void RenderBlock(vtkRenderer *vtkNotUsed(ren), vtkVolume *vtkNotUsed(vol), unsigned int vtkNotUsed(level))
Definition: vtkOpenGLGPUVolumeRayCastMapper.h:118
vtkOpenGLGPUVolumeRayCastMapper::GetDepthImage
void GetDepthImage(vtkImageData *im)
Low level API to export the depth texture as vtkImageData in RenderToImage mode.
vtkOpenGLGPUVolumeRayCastMapper::GetColorImage
void GetColorImage(vtkImageData *im)
Low level API to export the color texture as vtkImageData in RenderToImage mode.
vtkOpenGLGPUVolumeRayCastMapper::vtkOpenGLGPUVolumeRayCastMapper
vtkOpenGLGPUVolumeRayCastMapper()
vtkOpenGLGPUVolumeRayCastMapper::PreRender
virtual void PreRender(vtkRenderer *vtkNotUsed(ren), vtkVolume *vtkNotUsed(vol), double vtkNotUsed(datasetBounds)[6], double vtkNotUsed(scalarRange)[2], int vtkNotUsed(noOfComponents), unsigned int vtkNotUsed(numberOfLevels))
Definition: vtkOpenGLGPUVolumeRayCastMapper.h:110
vtkOpenGLGPUVolumeRayCastMapper::ReleaseGraphicsResources
virtual void ReleaseGraphicsResources(vtkWindow *window)
Release any graphics resources that are being consumed by this mapper.
vtkOpenGLGPUVolumeRayCastMapper::BuildDepthPassShader
void BuildDepthPassShader(vtkRenderer *ren, vtkVolume *vol, int noOfComponents, int independentComponents)
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
vtkOpenGLGPUVolumeRayCastMapper::RenderPass
@ RenderPass
Definition: vtkOpenGLGPUVolumeRayCastMapper.h:39
vtkOpenGLGPUVolumeRayCastMapper::Passes
Passes
Definition: vtkOpenGLGPUVolumeRayCastMapper.h:38
vtkImplicitFunction
abstract interface for implicit functions
Definition: vtkImplicitFunction.h:59
vtkX3D::level
@ level
Definition: vtkX3D.h:395
vtkShaderProgram
The ShaderProgram uses one or more Shader objects.
Definition: vtkShaderProgram.h:45
vtkGenericOpenGLResourceFreeCallback
Definition: vtkOpenGLResourceFreeCallback.h:26
vtkOpenGLGPUVolumeRayCastMapper::~vtkOpenGLGPUVolumeRayCastMapper
~vtkOpenGLGPUVolumeRayCastMapper()
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:46
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkTextureObject
abstracts an OpenGL texture object.
Definition: vtkTextureObject.h:44
vtkGPUVolumeRayCastMapper
Ray casting performed on the GPU.
Definition: vtkGPUVolumeRayCastMapper.h:41
vtkOpenGLGPUVolumeRayCastMapper::IsRenderSupported
virtual int IsRenderSupported(vtkRenderWindow *vtkNotUsed(window), vtkVolumeProperty *vtkNotUsed(property))
Based on hardware and properties, we may or may not be able to render using 3D texture mapping.
Definition: vtkOpenGLGPUVolumeRayCastMapper.h:160
vtkOpenGLCamera
OpenGL camera.
Definition: vtkOpenGLCamera.h:32
vtkOpenGLGPUVolumeRayCastMapper
Definition: vtkOpenGLGPUVolumeRayCastMapper.h:33
vtkOpenGLGPUVolumeRayCastMapper::ComputeReductionFactor
void ComputeReductionFactor(double allocatedTime)
vtkOpenGLGPUVolumeRayCastMapper::CurrentPass
int CurrentPass
Definition: vtkOpenGLGPUVolumeRayCastMapper.h:167
vtkOpenGLGPUVolumeRayCastMapper::GetColorTexture
vtkTextureObject * GetColorTexture()
vtkOpenGLGPUVolumeRayCastMapper::GetDepthTexture
vtkTextureObject * GetDepthTexture()
vtkOpenGLGPUVolumeRayCastMapper::GetReductionRatio
void GetReductionRatio(double *ratio)
Definition: vtkOpenGLGPUVolumeRayCastMapper.h:152
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:64
vtkOpenGLGPUVolumeRayCastMapper::SetNoiseGenerator
void SetNoiseGenerator(vtkImplicitFunction *generator)
Sets a user defined function to generate the ray jittering noise.
vtkOpenGLGPUVolumeRayCastMapper::ReductionFactor
double ReductionFactor
Definition: vtkOpenGLGPUVolumeRayCastMapper.h:166
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:87
vtkOpenGLGPUVolumeRayCastMapper::GPURender
void GPURender(vtkRenderer *ren, vtkVolume *vol)
Handled in the subclass - the actual render method.
vtkOpenGLGPUVolumeRayCastMapper::PostRender
virtual void PostRender(vtkRenderer *vtkNotUsed(ren), int vtkNotUsed(noOfComponents))
Definition: vtkOpenGLGPUVolumeRayCastMapper.h:122
vtkVolumeProperty
represents the common properties for rendering a volume.
Definition: vtkVolumeProperty.h:61
vtkOpenGLGPUVolumeRayCastMapper::New
static vtkOpenGLGPUVolumeRayCastMapper * New()