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 
33 #ifndef vtkVolumeRayCastMapper_h
34 #define vtkVolumeRayCastMapper_h
35 
36 #include "vtkRenderingVolumeModule.h" // For export macro
37 #include "vtkVolumeMapper.h"
38 #include "vtkVolumeRayCastFunction.h" // For vtkVolumeRayCastStaticInfo
39  // and vtkVolumeRayCastDynamicInfo
40 
43 class vtkMatrix4x4;
44 class vtkMultiThreader;
45 class vtkPlaneCollection;
46 class vtkRenderer;
47 class vtkTimerLog;
48 class vtkVolume;
49 class vtkVolumeTransform;
50 class vtkTransform;
52 
53 #if !defined(VTK_LEGACY_REMOVE)
55 
56 // Macro for tri-linear interpolation - do four linear interpolations on
57 // edges, two linear interpolations between pairs of edges, then a final
58 // interpolation between faces
59 #define vtkTrilinFuncMacro(v,x,y,z,a,b,c,d,e,f,g,h) \
60  t00 = a + (x)*(b-a); \
61  t01 = c + (x)*(d-c); \
62  t10 = e + (x)*(f-e); \
63  t11 = g + (x)*(h-g); \
64  t0 = t00 + (y)*(t01-t00); \
65  t1 = t10 + (y)*(t11-t10); \
66  v = t0 + (z)*(t1-t0);
67 
68 // Forward declaration needed for use by friend declaration below.
70 
71 class VTKRENDERINGVOLUME_EXPORT vtkVolumeRayCastMapper : public vtkVolumeMapper
72 {
73 public:
74  static vtkVolumeRayCastMapper *New();
76  void PrintSelf( ostream& os, vtkIndent indent );
77 
79 
85  vtkSetMacro( SampleDistance, double );
86  vtkGetMacro( SampleDistance, double );
88 
90 
94  virtual void SetVolumeRayCastFunction(vtkVolumeRayCastFunction*);
95  vtkGetObjectMacro( VolumeRayCastFunction, vtkVolumeRayCastFunction );
97 
99 
102  virtual void SetGradientEstimator(vtkEncodedGradientEstimator *gradest);
103  vtkGetObjectMacro( GradientEstimator, vtkEncodedGradientEstimator );
105 
107 
110  vtkGetObjectMacro( GradientShader, vtkEncodedGradientShader );
112 
114 
119  vtkSetClampMacro( ImageSampleDistance, double, 0.1, 100.0 );
120  vtkGetMacro( ImageSampleDistance, double );
122 
124 
128  vtkSetClampMacro( MinimumImageSampleDistance, double, 0.1, 100.0 );
129  vtkGetMacro( MinimumImageSampleDistance, double );
131 
133 
137  vtkSetClampMacro( MaximumImageSampleDistance, double, 0.1, 100.0 );
138  vtkGetMacro( MaximumImageSampleDistance, double );
140 
142 
148  vtkSetClampMacro( AutoAdjustSampleDistances, int, 0, 1 );
149  vtkGetMacro( AutoAdjustSampleDistances, int );
150  vtkBooleanMacro( AutoAdjustSampleDistances, int );
152 
154 
158  void SetNumberOfThreads( int num );
159  int GetNumberOfThreads();
161 
163 
167  vtkSetClampMacro( IntermixIntersectingGeometry, int, 0, 1 );
168  vtkGetMacro( IntermixIntersectingGeometry, int );
169  vtkBooleanMacro( IntermixIntersectingGeometry, int );
171 
176  void Render( vtkRenderer *, vtkVolume * );
177 
185 
190  float GetZeroOpacityThreshold( vtkVolume *vol );
191 
193 
197  virtual float GetGradientMagnitudeScale();
198  virtual float GetGradientMagnitudeBias();
199  virtual float GetGradientMagnitudeScale(int)
200  {return this->GetGradientMagnitudeScale();};
201  virtual float GetGradientMagnitudeBias(int)
202  {return this->GetGradientMagnitudeBias();};
204 
205 protected:
208 
213 
214  void ReportReferences(vtkGarbageCollector*) VTK_OVERRIDE;
215 
216  // The distance between sample points along the ray
217  double SampleDistance;
218  double ImageSampleDistance;
219  double MinimumImageSampleDistance;
220  double MaximumImageSampleDistance;
221  int AutoAdjustSampleDistances;
222 
223  double WorldSampleDistance;
224  int ScalarDataType;
225  void *ScalarDataPointer;
226 
227  void UpdateShadingTables( vtkRenderer *ren,
228  vtkVolume *vol );
229 
230  void ComputeMatrices( vtkImageData *data, vtkVolume *vol );
231  int ComputeRowBounds( vtkVolume *vol, vtkRenderer *ren );
232 
234 
235  vtkMultiThreader *Threader;
236 
237  vtkMatrix4x4 *PerspectiveMatrix;
238  vtkMatrix4x4 *ViewToWorldMatrix;
239  vtkMatrix4x4 *ViewToVoxelsMatrix;
240  vtkMatrix4x4 *VoxelsToViewMatrix;
241  vtkMatrix4x4 *WorldToVoxelsMatrix;
242  vtkMatrix4x4 *VoxelsToWorldMatrix;
243 
244  vtkMatrix4x4 *VolumeMatrix;
245 
246  vtkTransform *PerspectiveTransform;
247  vtkTransform *VoxelsTransform;
248  vtkTransform *VoxelsToViewTransform;
249 
250  // This is how big the image would be if it covered the entire viewport
251  int ImageViewportSize[2];
252 
253  // This is how big the allocated memory for image is. This may be bigger
254  // or smaller than ImageFullSize - it will be bigger if necessary to
255  // ensure a power of 2, it will be smaller if the volume only covers a
256  // small region of the viewport
257  int ImageMemorySize[2];
258 
259  // This is the size of subregion in ImageSize image that we are using for
260  // the current image. Since ImageSize is a power of 2, there is likely
261  // wasted space in it. This number will be used for things such as clearing
262  // the image if necessary.
263  int ImageInUseSize[2];
264 
265  // This is the location in ImageFullSize image where our ImageSize image
266  // is located.
267  int ImageOrigin[2];
268 
269  // This is the allocated image
270  unsigned char *Image;
271 
272  int *RowBounds;
273  int *OldRowBounds;
274 
275  float *RenderTimeTable;
276  vtkVolume **RenderVolumeTable;
277  vtkRenderer **RenderRendererTable;
278  int RenderTableSize;
279  int RenderTableEntries;
280 
281  void StoreRenderTime( vtkRenderer *ren, vtkVolume *vol, float t );
282  float RetrieveRenderTime( vtkRenderer *ren, vtkVolume *vol );
283 
284  int IntermixIntersectingGeometry;
285 
286  float *ZBuffer;
287  int ZBufferSize[2];
288  int ZBufferOrigin[2];
289 
290  float MinimumViewDistance;
291 
292  int ClipRayAgainstVolume( vtkVolumeRayCastDynamicInfo *dynamicInfo,
293  float bounds[6] );
294 
295  void InitializeClippingPlanes( vtkVolumeRayCastStaticInfo *staticInfo,
296  vtkPlaneCollection *planes );
297 
298  int ClipRayAgainstClippingPlanes( vtkVolumeRayCastDynamicInfo *dynamicInfo,
299  vtkVolumeRayCastStaticInfo *staticInfo);
300 
301  // Get the ZBuffer value corresponding to location (x,y) where (x,y)
302  // are indexing into the ImageInUse image. This must be converted to
303  // the zbuffer image coordinates. Nearest neighbor value is returned.
304  double GetZBufferValue( int x, int y );
305 
306 private:
307  vtkVolumeRayCastMapper(const vtkVolumeRayCastMapper&) VTK_DELETE_FUNCTION;
308  void operator=(const vtkVolumeRayCastMapper&) VTK_DELETE_FUNCTION;
309 };
310 #endif // VTK_LEGACY_REMOVE
311 #endif
312 
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:50
vtkEncodedGradientEstimator * GradientEstimator
Abstract class for a volume mapper.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
void ReportReferences(vtkGarbageCollector *) override
A class for performing multithreaded execution.
maintain a list of planes
abstract specification for renderers
Definition: vtkRenderer.h:63
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
Detect and break reference loops.
helper class that draws the image to the screen
Timer support and logging.
Definition: vtkTimerLog.h:80
vtkVolumeRayCastFunction * VolumeRayCastFunction
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
virtual float GetGradientMagnitudeScale()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE.
a simple class to control print indentation
Definition: vtkIndent.h:39
a superclass for ray casting functions
VTK_THREAD_RETURN_TYPE VolumeRayCastMapper_CastRays(void *arg)
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
Superclass for gradient estimation.
A slow but accurate mapper for rendering volumes.
Compute shading tables for encoded normals.
virtual float GetGradientMagnitudeScale(int)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Values needed by the volume.
virtual void Render(vtkRenderer *ren, vtkVolume *vol)=0
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
#define VTK_THREAD_RETURN_TYPE
virtual void ReleaseGraphicsResources(vtkWindow *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
static vtkAlgorithm * New()
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
virtual float GetGradientMagnitudeBias(int)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Values needed by the volume.
vtkRayCastImageDisplayHelper * ImageDisplayHelper
vtkEncodedGradientShader * GradientShader
virtual float GetGradientMagnitudeBias()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE.