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:
76  void PrintSelf( ostream& os, vtkIndent indent );
77 
79 
85  vtkSetMacro( SampleDistance, double );
86  vtkGetMacro( SampleDistance, double );
88 
90 
95  vtkGetObjectMacro( VolumeRayCastFunction, vtkVolumeRayCastFunction );
97 
99 
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 );
161 
163 
167  vtkSetClampMacro( IntermixIntersectingGeometry, int, 0, 1 );
168  vtkGetMacro( IntermixIntersectingGeometry, int );
169  vtkBooleanMacro( IntermixIntersectingGeometry, int );
171 
177 
185 
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 
215 
216  // The distance between sample points along the ray
222 
226 
228  vtkVolume *vol );
229 
232 
234 
236 
243 
245 
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;
274 
280 
281  void StoreRenderTime( vtkRenderer *ren, vtkVolume *vol, float t );
283 
285 
286  float *ZBuffer;
287  int ZBufferSize[2];
288  int ZBufferOrigin[2];
289 
291 
293  float bounds[6] );
294 
296  vtkPlaneCollection *planes );
297 
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 
virtual float GetGradientMagnitudeScale()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE.
virtual float GetGradientMagnitudeBias()
Superclass for gradient estimation.
Compute shading tables for encoded normals.
Detect and break reference loops.
topologically and geometrically regular array of data
Definition: vtkImageData.h:46
a simple class to control print indentation
Definition: vtkIndent.h:40
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:42
A class for performing multithreaded execution.
maintain a list of planes
helper class that draws the image to the screen
abstract specification for renderers
Definition: vtkRenderer.h:64
Timer support and logging.
Definition: vtkTimerLog.h:81
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:61
Abstract class for a volume mapper.
a superclass for ray casting functions
A slow but accurate mapper for rendering volumes.
float RetrieveRenderTime(vtkRenderer *ren, vtkVolume *vol)
void SetNumberOfThreads(int num)
Set/Get the number of threads to use.
void StoreRenderTime(vtkRenderer *ren, vtkVolume *vol, float t)
void ReportReferences(vtkGarbageCollector *) override
void InitializeClippingPlanes(vtkVolumeRayCastStaticInfo *staticInfo, vtkPlaneCollection *planes)
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
virtual float GetGradientMagnitudeBias()
friend VTK_THREAD_RETURN_TYPE VolumeRayCastMapper_CastRays(void *arg)
double GetZBufferValue(int x, int y)
virtual float GetGradientMagnitudeBias(int)
virtual float GetGradientMagnitudeScale(int)
float GetZeroOpacityThreshold(vtkVolume *vol)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Return the scalar value below which all opaci...
int ClipRayAgainstVolume(vtkVolumeRayCastDynamicInfo *dynamicInfo, float bounds[6])
void ReleaseGraphicsResources(vtkWindow *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
void UpdateShadingTables(vtkRenderer *ren, vtkVolume *vol)
void ComputeMatrices(vtkImageData *data, vtkVolume *vol)
virtual void SetGradientEstimator(vtkEncodedGradientEstimator *gradest)
Set / Get the gradient estimator used to estimate normals.
void Render(vtkRenderer *, vtkVolume *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Initialize rendering for this volume.
vtkEncodedGradientEstimator * GradientEstimator
static vtkVolumeRayCastMapper * New()
int ComputeRowBounds(vtkVolume *vol, vtkRenderer *ren)
int ClipRayAgainstClippingPlanes(vtkVolumeRayCastDynamicInfo *dynamicInfo, vtkVolumeRayCastStaticInfo *staticInfo)
vtkVolumeRayCastFunction * VolumeRayCastFunction
virtual void SetVolumeRayCastFunction(vtkVolumeRayCastFunction *)
Get / Set the volume ray cast function.
vtkRayCastImageDisplayHelper * ImageDisplayHelper
vtkEncodedGradientShader * GradientShader
virtual float GetGradientMagnitudeScale()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Values needed by the volume.
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:51
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
@ data
Definition: vtkX3D.h:315
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
#define VTK_THREAD_RETURN_TYPE
VTK_THREAD_RETURN_TYPE VolumeRayCastMapper_CastRays(void *arg)