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 "vtkVolumeMapper.h"
35 #include "vtkVolumeRayCastFunction.h" // For vtkVolumeRayCastStaticInfo
36  // and vtkVolumeRayCastDynamicInfo
37 #include "vtkFastNumericConversion.h" // for fast rounding and floor
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 //BTX
53 // Macro for floor of x
54 
55 inline int vtkFloorFuncMacro(double x)
56 {
58 }
59 
60 
61 // Macro for rounding x (for x >= 0)
62 inline int vtkRoundFuncMacro(double x)
63 {
65 }
66 //ETX
67 
68 // Macro for tri-linear interpolation - do four linear interpolations on
69 // edges, two linear interpolations between pairs of edges, then a final
70 // interpolation between faces
71 #define vtkTrilinFuncMacro(v,x,y,z,a,b,c,d,e,f,g,h) \
72  t00 = a + (x)*(b-a); \
73  t01 = c + (x)*(d-c); \
74  t10 = e + (x)*(f-e); \
75  t11 = g + (x)*(h-g); \
76  t0 = t00 + (y)*(t01-t00); \
77  t1 = t10 + (y)*(t11-t10); \
78  v = t0 + (z)*(t1-t0);
79 
80 // Forward declaration needed for use by friend declaration below.
82 
84 {
85 public:
86  static vtkVolumeRayCastMapper *New();
88  void PrintSelf( ostream& os, vtkIndent indent );
89 
91 
94  vtkSetMacro( SampleDistance, double );
95  vtkGetMacro( SampleDistance, double );
97 
99 
101  virtual void SetVolumeRayCastFunction(vtkVolumeRayCastFunction*);
102  vtkGetObjectMacro( VolumeRayCastFunction, vtkVolumeRayCastFunction );
104 
106 
107  virtual void SetGradientEstimator(vtkEncodedGradientEstimator *gradest);
108  vtkGetObjectMacro( GradientEstimator, vtkEncodedGradientEstimator );
110 
112 
113  vtkGetObjectMacro( GradientShader, vtkEncodedGradientShader );
115 
117 
120  vtkSetClampMacro( ImageSampleDistance, double, 0.1, 100.0 );
121  vtkGetMacro( ImageSampleDistance, double );
123 
125 
127  vtkSetClampMacro( MinimumImageSampleDistance, double, 0.1, 100.0 );
128  vtkGetMacro( MinimumImageSampleDistance, double );
130 
132 
134  vtkSetClampMacro( MaximumImageSampleDistance, double, 0.1, 100.0 );
135  vtkGetMacro( MaximumImageSampleDistance, double );
137 
139 
142  vtkSetClampMacro( AutoAdjustSampleDistances, int, 0, 1 );
143  vtkGetMacro( AutoAdjustSampleDistances, int );
144  vtkBooleanMacro( AutoAdjustSampleDistances, int );
146 
148 
150  void SetNumberOfThreads( int num );
151  int GetNumberOfThreads();
153 
155 
157  vtkSetClampMacro( IntermixIntersectingGeometry, int, 0, 1 );
158  vtkGetMacro( IntermixIntersectingGeometry, int );
159  vtkBooleanMacro( IntermixIntersectingGeometry, int );
161 
162 //BTX
165  void Render( vtkRenderer *, vtkVolume * );
166 
172 
175  float GetZeroOpacityThreshold( vtkVolume *vol );
176 
178 
180  virtual float GetGradientMagnitudeScale();
181  virtual float GetGradientMagnitudeBias();
182  virtual float GetGradientMagnitudeScale(int)
183  {return this->GetGradientMagnitudeScale();};
184  virtual float GetGradientMagnitudeBias(int)
185  {return this->GetGradientMagnitudeBias();};
187 
188 //ETX
189 
190 protected:
193 
198 
199  virtual void ReportReferences(vtkGarbageCollector*);
200 
201  // The distance between sample points along the ray
207 
211 
212  void UpdateShadingTables( vtkRenderer *ren,
213  vtkVolume *vol );
214 
215  void ComputeMatrices( vtkImageData *data, vtkVolume *vol );
216  int ComputeRowBounds( vtkVolume *vol, vtkRenderer *ren );
217 
219 
221 
228 
230 
234 
235  // This is how big the image would be if it covered the entire viewport
236  int ImageViewportSize[2];
237 
238  // This is how big the allocated memory for image is. This may be bigger
239  // or smaller than ImageFullSize - it will be bigger if necessary to
240  // ensure a power of 2, it will be smaller if the volume only covers a
241  // small region of the viewport
242  int ImageMemorySize[2];
243 
244  // This is the size of subregion in ImageSize image that we are using for
245  // the current image. Since ImageSize is a power of 2, there is likely
246  // wasted space in it. This number will be used for things such as clearing
247  // the image if necessary.
248  int ImageInUseSize[2];
249 
250  // This is the location in ImageFullSize image where our ImageSize image
251  // is located.
252  int ImageOrigin[2];
253 
254  // This is the allocated image
255  unsigned char *Image;
256 
257  int *RowBounds;
259 
265 
266  void StoreRenderTime( vtkRenderer *ren, vtkVolume *vol, float t );
267  float RetrieveRenderTime( vtkRenderer *ren, vtkVolume *vol );
268 
270 
271  float *ZBuffer;
272  int ZBufferSize[2];
273  int ZBufferOrigin[2];
274 
276 
277  int ClipRayAgainstVolume( vtkVolumeRayCastDynamicInfo *dynamicInfo,
278  float bounds[6] );
279 
280  void InitializeClippingPlanes( vtkVolumeRayCastStaticInfo *staticInfo,
281  vtkPlaneCollection *planes );
282 
283  int ClipRayAgainstClippingPlanes( vtkVolumeRayCastDynamicInfo *dynamicInfo,
284  vtkVolumeRayCastStaticInfo *staticInfo);
285 
286  // Get the ZBuffer value corresponding to location (x,y) where (x,y)
287  // are indexing into the ImageInUse image. This must be converted to
288  // the zbuffer image coordinates. Nearest neighbor value is returned.
289  double GetZBufferValue( int x, int y );
290 
291 private:
292  vtkVolumeRayCastMapper(const vtkVolumeRayCastMapper&); // Not implemented.
293  void operator=(const vtkVolumeRayCastMapper&); // Not implemented.
294 };
295 
296 #endif
297