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 
27 #ifndef vtkVolumeRayCastMapper_h
28 #define vtkVolumeRayCastMapper_h
29 
30 #include "vtkRenderingVolumeModule.h" // For export macro
31 #include "vtkVolumeMapper.h"
32 #include "vtkVolumeRayCastFunction.h" // For vtkVolumeRayCastStaticInfo
33  // and vtkVolumeRayCastDynamicInfo
34 
37 class vtkMatrix4x4;
38 class vtkMultiThreader;
39 class vtkPlaneCollection;
40 class vtkRenderer;
41 class vtkTimerLog;
42 class vtkVolume;
43 class vtkVolumeTransform;
44 class vtkTransform;
46 
47 #if !defined(VTK_LEGACY_REMOVE)
49 
50 // Macro for tri-linear interpolation - do four linear interpolations on
51 // edges, two linear interpolations between pairs of edges, then a final
52 // interpolation between faces
53 #define vtkTrilinFuncMacro(v,x,y,z,a,b,c,d,e,f,g,h) \
54  t00 = a + (x)*(b-a); \
55  t01 = c + (x)*(d-c); \
56  t10 = e + (x)*(f-e); \
57  t11 = g + (x)*(h-g); \
58  t0 = t00 + (y)*(t01-t00); \
59  t1 = t10 + (y)*(t11-t10); \
60  v = t0 + (z)*(t1-t0);
61 
62 // Forward declaration needed for use by friend declaration below.
64 
65 class VTKRENDERINGVOLUME_EXPORT vtkVolumeRayCastMapper : public vtkVolumeMapper
66 {
67 public:
68  static vtkVolumeRayCastMapper *New();
70  void PrintSelf( ostream& os, vtkIndent indent ) VTK_OVERRIDE;
71 
73 
79  vtkSetMacro( SampleDistance, double );
80  vtkGetMacro( SampleDistance, double );
82 
84 
88  virtual void SetVolumeRayCastFunction(vtkVolumeRayCastFunction*);
89  vtkGetObjectMacro( VolumeRayCastFunction, vtkVolumeRayCastFunction );
91 
93 
96  virtual void SetGradientEstimator(vtkEncodedGradientEstimator *gradest);
97  vtkGetObjectMacro( GradientEstimator, vtkEncodedGradientEstimator );
99 
101 
104  vtkGetObjectMacro( GradientShader, vtkEncodedGradientShader );
106 
108 
113  vtkSetClampMacro( ImageSampleDistance, double, 0.1, 100.0 );
114  vtkGetMacro( ImageSampleDistance, double );
116 
118 
122  vtkSetClampMacro( MinimumImageSampleDistance, double, 0.1, 100.0 );
123  vtkGetMacro( MinimumImageSampleDistance, double );
125 
127 
131  vtkSetClampMacro( MaximumImageSampleDistance, double, 0.1, 100.0 );
132  vtkGetMacro( MaximumImageSampleDistance, double );
134 
136 
142  vtkSetClampMacro( AutoAdjustSampleDistances, int, 0, 1 );
143  vtkGetMacro( AutoAdjustSampleDistances, int );
144  vtkBooleanMacro( AutoAdjustSampleDistances, int );
146 
148 
152  void SetNumberOfThreads( int num );
153  int GetNumberOfThreads();
155 
157 
161  vtkSetClampMacro( IntermixIntersectingGeometry, int, 0, 1 );
162  vtkGetMacro( IntermixIntersectingGeometry, int );
163  vtkBooleanMacro( IntermixIntersectingGeometry, int );
165 
170  void Render( vtkRenderer *, vtkVolume * ) VTK_OVERRIDE;
171 
178  void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE;
179 
184  float GetZeroOpacityThreshold( vtkVolume *vol );
185 
187 
191  float GetGradientMagnitudeScale() VTK_OVERRIDE;
192  float GetGradientMagnitudeBias() VTK_OVERRIDE;
193  float GetGradientMagnitudeScale(int) VTK_OVERRIDE
194  {return this->GetGradientMagnitudeScale();};
195  float GetGradientMagnitudeBias(int) VTK_OVERRIDE
196  {return this->GetGradientMagnitudeBias();};
198 
199 protected:
201  ~vtkVolumeRayCastMapper() VTK_OVERRIDE;
202 
207 
208  void ReportReferences(vtkGarbageCollector*) VTK_OVERRIDE;
209 
210  // The distance between sample points along the ray
216 
220 
221  void UpdateShadingTables( vtkRenderer *ren,
222  vtkVolume *vol );
223 
224  void ComputeMatrices( vtkImageData *data, vtkVolume *vol );
225  int ComputeRowBounds( vtkVolume *vol, vtkRenderer *ren );
226 
228 
230 
237 
239 
243 
244  // This is how big the image would be if it covered the entire viewport
245  int ImageViewportSize[2];
246 
247  // This is how big the allocated memory for image is. This may be bigger
248  // or smaller than ImageFullSize - it will be bigger if necessary to
249  // ensure a power of 2, it will be smaller if the volume only covers a
250  // small region of the viewport
251  int ImageMemorySize[2];
252 
253  // This is the size of subregion in ImageSize image that we are using for
254  // the current image. Since ImageSize is a power of 2, there is likely
255  // wasted space in it. This number will be used for things such as clearing
256  // the image if necessary.
257  int ImageInUseSize[2];
258 
259  // This is the location in ImageFullSize image where our ImageSize image
260  // is located.
261  int ImageOrigin[2];
262 
263  // This is the allocated image
264  unsigned char *Image;
265 
266  int *RowBounds;
268 
274 
275  void StoreRenderTime( vtkRenderer *ren, vtkVolume *vol, float t );
276  float RetrieveRenderTime( vtkRenderer *ren, vtkVolume *vol );
277 
279 
280  float *ZBuffer;
281  int ZBufferSize[2];
282  int ZBufferOrigin[2];
283 
285 
286  int ClipRayAgainstVolume( vtkVolumeRayCastDynamicInfo *dynamicInfo,
287  float bounds[6] );
288 
289  void InitializeClippingPlanes( vtkVolumeRayCastStaticInfo *staticInfo,
290  vtkPlaneCollection *planes );
291 
292  int ClipRayAgainstClippingPlanes( vtkVolumeRayCastDynamicInfo *dynamicInfo,
293  vtkVolumeRayCastStaticInfo *staticInfo);
294 
295  // Get the ZBuffer value corresponding to location (x,y) where (x,y)
296  // are indexing into the ImageInUse image. This must be converted to
297  // the zbuffer image coordinates. Nearest neighbor value is returned.
298  double GetZBufferValue( int x, int y );
299 
300 private:
301  vtkVolumeRayCastMapper(const vtkVolumeRayCastMapper&) VTK_DELETE_FUNCTION;
302  void operator=(const vtkVolumeRayCastMapper&) VTK_DELETE_FUNCTION;
303 };
304 #endif // VTK_LEGACY_REMOVE
305 #endif
306 
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:44
vtkEncodedGradientEstimator * GradientEstimator
Abstract class for a volume mapper.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
void ReportReferences(vtkGarbageCollector *) override
A class for performing multithreaded execution.
maintain a list of planes
abstract specification for renderers
Definition: vtkRenderer.h:57
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
Detect and break reference loops.
helper class that draws the image to the screen
void Render(vtkRenderer *ren, vtkVolume *vol) override=0
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Timer support and logging.
Definition: vtkTimerLog.h:85
vtkVolumeRayCastFunction * VolumeRayCastFunction
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
float GetGradientMagnitudeBias(int) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Values needed by the volume.
virtual float GetGradientMagnitudeScale()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE.
a simple class to control print indentation
Definition: vtkIndent.h:33
a superclass for ray casting functions
VTK_THREAD_RETURN_TYPE VolumeRayCastMapper_CastRays(void *arg)
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
Superclass for gradient estimation.
A slow but accurate mapper for rendering volumes.
Compute shading tables for encoded normals.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
#define VTK_THREAD_RETURN_TYPE
static vtkAlgorithm * New()
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkRayCastImageDisplayHelper * ImageDisplayHelper
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkEncodedGradientShader * GradientShader
virtual float GetGradientMagnitudeBias()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE.