VTK
vtkVolumeRayCastMapper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkVolumeRayCastMapper.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 
31 #ifndef vtkVolumeRayCastMapper_h
32 #define vtkVolumeRayCastMapper_h
33 
34 #include "vtkRenderingVolumeModule.h" // For export macro
35 #include "vtkVolumeMapper.h"
36 #include "vtkVolumeRayCastFunction.h" // For vtkVolumeRayCastStaticInfo
37  // and vtkVolumeRayCastDynamicInfo
38 
41 class vtkMatrix4x4;
42 class vtkMultiThreader;
43 class vtkPlaneCollection;
44 class vtkRenderer;
45 class vtkTimerLog;
46 class vtkVolume;
48 class vtkVolumeTransform;
49 class vtkTransform;
51 
52 // Macro for tri-linear interpolation - do four linear interpolations on
53 // edges, two linear interpolations between pairs of edges, then a final
54 // interpolation between faces
55 #define vtkTrilinFuncMacro(v,x,y,z,a,b,c,d,e,f,g,h) \
56  t00 = a + (x)*(b-a); \
57  t01 = c + (x)*(d-c); \
58  t10 = e + (x)*(f-e); \
59  t11 = g + (x)*(h-g); \
60  t0 = t00 + (y)*(t01-t00); \
61  t1 = t10 + (y)*(t11-t10); \
62  v = t0 + (z)*(t1-t0);
63 
64 // Forward declaration needed for use by friend declaration below.
66 
68 {
69 public:
70  static vtkVolumeRayCastMapper *New();
72  void PrintSelf( ostream& os, vtkIndent indent );
73 
75 
78  vtkSetMacro( SampleDistance, double );
79  vtkGetMacro( SampleDistance, double );
81 
83 
85  virtual void SetVolumeRayCastFunction(vtkVolumeRayCastFunction*);
86  vtkGetObjectMacro( VolumeRayCastFunction, vtkVolumeRayCastFunction );
88 
90 
91  virtual void SetGradientEstimator(vtkEncodedGradientEstimator *gradest);
92  vtkGetObjectMacro( GradientEstimator, vtkEncodedGradientEstimator );
94 
96 
97  vtkGetObjectMacro( GradientShader, vtkEncodedGradientShader );
99 
101 
104  vtkSetClampMacro( ImageSampleDistance, double, 0.1, 100.0 );
105  vtkGetMacro( ImageSampleDistance, double );
107 
109 
111  vtkSetClampMacro( MinimumImageSampleDistance, double, 0.1, 100.0 );
112  vtkGetMacro( MinimumImageSampleDistance, double );
114 
116 
118  vtkSetClampMacro( MaximumImageSampleDistance, double, 0.1, 100.0 );
119  vtkGetMacro( MaximumImageSampleDistance, double );
121 
123 
126  vtkSetClampMacro( AutoAdjustSampleDistances, int, 0, 1 );
127  vtkGetMacro( AutoAdjustSampleDistances, int );
128  vtkBooleanMacro( AutoAdjustSampleDistances, int );
130 
132 
134  void SetNumberOfThreads( int num );
135  int GetNumberOfThreads();
137 
139 
141  vtkSetClampMacro( IntermixIntersectingGeometry, int, 0, 1 );
142  vtkGetMacro( IntermixIntersectingGeometry, int );
143  vtkBooleanMacro( IntermixIntersectingGeometry, int );
145 
146 //BTX
149  void Render( vtkRenderer *, vtkVolume * );
150 
156 
159  float GetZeroOpacityThreshold( vtkVolume *vol );
160 
162 
164  virtual float GetGradientMagnitudeScale();
165  virtual float GetGradientMagnitudeBias();
166  virtual float GetGradientMagnitudeScale(int)
167  {return this->GetGradientMagnitudeScale();};
168  virtual float GetGradientMagnitudeBias(int)
169  {return this->GetGradientMagnitudeBias();};
171 
172 //ETX
173 
174 protected:
177 
182 
183  virtual void ReportReferences(vtkGarbageCollector*);
184 
185  // The distance between sample points along the ray
191 
195 
196  void UpdateShadingTables( vtkRenderer *ren,
197  vtkVolume *vol );
198 
199  void ComputeMatrices( vtkImageData *data, vtkVolume *vol );
200  int ComputeRowBounds( vtkVolume *vol, vtkRenderer *ren );
201 
203 
205 
212 
214 
218 
219  // This is how big the image would be if it covered the entire viewport
220  int ImageViewportSize[2];
221 
222  // This is how big the allocated memory for image is. This may be bigger
223  // or smaller than ImageFullSize - it will be bigger if necessary to
224  // ensure a power of 2, it will be smaller if the volume only covers a
225  // small region of the viewport
226  int ImageMemorySize[2];
227 
228  // This is the size of subregion in ImageSize image that we are using for
229  // the current image. Since ImageSize is a power of 2, there is likely
230  // wasted space in it. This number will be used for things such as clearing
231  // the image if necessary.
232  int ImageInUseSize[2];
233 
234  // This is the location in ImageFullSize image where our ImageSize image
235  // is located.
236  int ImageOrigin[2];
237 
238  // This is the allocated image
239  unsigned char *Image;
240 
241  int *RowBounds;
243 
249 
250  void StoreRenderTime( vtkRenderer *ren, vtkVolume *vol, float t );
251  float RetrieveRenderTime( vtkRenderer *ren, vtkVolume *vol );
252 
254 
255  float *ZBuffer;
256  int ZBufferSize[2];
257  int ZBufferOrigin[2];
258 
260 
261  int ClipRayAgainstVolume( vtkVolumeRayCastDynamicInfo *dynamicInfo,
262  float bounds[6] );
263 
264  void InitializeClippingPlanes( vtkVolumeRayCastStaticInfo *staticInfo,
265  vtkPlaneCollection *planes );
266 
267  int ClipRayAgainstClippingPlanes( vtkVolumeRayCastDynamicInfo *dynamicInfo,
268  vtkVolumeRayCastStaticInfo *staticInfo);
269 
270  // Get the ZBuffer value corresponding to location (x,y) where (x,y)
271  // are indexing into the ImageInUse image. This must be converted to
272  // the zbuffer image coordinates. Nearest neighbor value is returned.
273  double GetZBufferValue( int x, int y );
274 
275 private:
276  vtkVolumeRayCastMapper(const vtkVolumeRayCastMapper&); // Not implemented.
277  void operator=(const vtkVolumeRayCastMapper&); // Not implemented.
278 };
279 
280 #endif
281 
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:49
vtkEncodedGradientEstimator * GradientEstimator
Abstract class for a volume mapper.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:38
void PrintSelf(ostream &os, vtkIndent indent)
#define VTKRENDERINGVOLUME_EXPORT
A class for performing multithreaded execution.
maintain a list of planes
abstract specification for renderers
Definition: vtkRenderer.h:62
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
Detect and break reference loops.
helper class that draws the image to the screen
Timer support and logging.
Definition: vtkTimerLog.h:81
vtkVolumeRayCastFunction * VolumeRayCastFunction
virtual void ReportReferences(vtkGarbageCollector *)
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
virtual float GetGradientMagnitudeScale()
a simple class to control print indentation
Definition: vtkIndent.h:38
a superclass for ray casting functions
VTK_THREAD_RETURN_TYPE VolumeRayCastMapper_CastRays(void *arg)
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
Superclass for gradient estimation.
A slow but accurate mapper for rendering volumes.
Compute shading tables for encoded normals.
virtual float GetGradientMagnitudeScale(int)
virtual void Render(vtkRenderer *ren, vtkVolume *vol)=0
#define VTK_THREAD_RETURN_TYPE
virtual void ReleaseGraphicsResources(vtkWindow *)
static vtkAlgorithm * New()
virtual float GetGradientMagnitudeBias(int)
vtkRayCastImageDisplayHelper * ImageDisplayHelper
vtkEncodedGradientShader * GradientShader
virtual float GetGradientMagnitudeBias()