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
222 
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 
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 );
282  float RetrieveRenderTime( vtkRenderer *ren, vtkVolume *vol );
283 
285 
286  float *ZBuffer;
287  int ZBufferSize[2];
288  int ZBufferOrigin[2];
289 
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 
vtkVolumeRayCastFunction.h
vtkVolumeRayCastMapper::ImageDisplayHelper
vtkRayCastImageDisplayHelper * ImageDisplayHelper
Definition: vtkVolumeRayCastMapper.h:212
vtkVolumeMapper
Abstract class for a volume mapper.
Definition: vtkVolumeMapper.h:49
vtkVolumeRayCastMapper::OldRowBounds
int * OldRowBounds
Definition: vtkVolumeRayCastMapper.h:273
vtkVolumeRayCastMapper::RenderTableEntries
int RenderTableEntries
Definition: vtkVolumeRayCastMapper.h:279
vtkVolumeRayCastMapper::ScalarDataPointer
void * ScalarDataPointer
Definition: vtkVolumeRayCastMapper.h:225
vtkVolume
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:50
vtkVolumeRayCastFunction
a superclass for ray casting functions
Definition: vtkVolumeRayCastFunction.h:136
vtkRayCastImageDisplayHelper
helper class that draws the image to the screen
Definition: vtkRayCastImageDisplayHelper.h:39
vtkVolumeRayCastMapper::PerspectiveTransform
vtkTransform * PerspectiveTransform
Definition: vtkVolumeRayCastMapper.h:246
vtkVolumeMapper::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkX3D::data
Definition: vtkX3D.h:315
vtkVolumeRayCastMapper::WorldSampleDistance
double WorldSampleDistance
Definition: vtkVolumeRayCastMapper.h:223
vtkVolumeRayCastMapper::RenderTimeTable
float * RenderTimeTable
Definition: vtkVolumeRayCastMapper.h:275
vtkVolumeRayCastMapper::RenderTableSize
int RenderTableSize
Definition: vtkVolumeRayCastMapper.h:278
vtkVolumeMapper::ReleaseGraphicsResources
virtual void ReleaseGraphicsResources(vtkWindow *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
Definition: vtkVolumeMapper.h:196
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
vtkAbstractVolumeMapper::GetGradientMagnitudeScale
virtual float GetGradientMagnitudeScale()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE.
Definition: vtkAbstractVolumeMapper.h:115
vtkVolumeRayCastMapper::MaximumImageSampleDistance
double MaximumImageSampleDistance
Definition: vtkVolumeRayCastMapper.h:220
vtkVolumeRayCastMapper::PerspectiveMatrix
vtkMatrix4x4 * PerspectiveMatrix
Definition: vtkVolumeRayCastMapper.h:237
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkVolumeRayCastMapper::MinimumImageSampleDistance
double MinimumImageSampleDistance
Definition: vtkVolumeRayCastMapper.h:219
vtkVolumeRayCastMapper
A slow but accurate mapper for rendering volumes.
Definition: vtkVolumeRayCastMapper.h:71
vtkVolumeRayCastMapper::ImageSampleDistance
double ImageSampleDistance
Definition: vtkVolumeRayCastMapper.h:218
vtkVolumeRayCastMapper::IntermixIntersectingGeometry
int IntermixIntersectingGeometry
Definition: vtkVolumeRayCastMapper.h:284
vtkMultiThreader
A class for performing multithreaded execution.
Definition: vtkMultiThreader.h:96
vtkVolumeRayCastMapper::AutoAdjustSampleDistances
int AutoAdjustSampleDistances
Definition: vtkVolumeRayCastMapper.h:221
vtkEncodedGradientShader
Compute shading tables for encoded normals.
Definition: vtkEncodedGradientShader.h:45
vtkEncodedGradientEstimator
Superclass for gradient estimation.
Definition: vtkEncodedGradientEstimator.h:44
vtkVolumeRayCastMapper::Image
unsigned char * Image
Definition: vtkVolumeRayCastMapper.h:270
vtkVolumeMapper.h
vtkVolumeRayCastMapper::VoxelsTransform
vtkTransform * VoxelsTransform
Definition: vtkVolumeRayCastMapper.h:247
vtkVolumeRayCastMapper::VoxelsToViewMatrix
vtkMatrix4x4 * VoxelsToViewMatrix
Definition: vtkVolumeRayCastMapper.h:240
vtkVolumeRayCastMapper::ViewToWorldMatrix
vtkMatrix4x4 * ViewToWorldMatrix
Definition: vtkVolumeRayCastMapper.h:238
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkVolumeMapper::Render
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...
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
vtkVolumeRayCastMapper::VolumeRayCastFunction
vtkVolumeRayCastFunction * VolumeRayCastFunction
Definition: vtkVolumeRayCastMapper.h:209
vtkVolumeRayCastMapper::ViewToVoxelsMatrix
vtkMatrix4x4 * ViewToVoxelsMatrix
Definition: vtkVolumeRayCastMapper.h:239
vtkVolumeRayCastMapper::GradientEstimator
vtkEncodedGradientEstimator * GradientEstimator
Definition: vtkVolumeRayCastMapper.h:210
vtkVolumeRayCastMapper::RenderRendererTable
vtkRenderer ** RenderRendererTable
Definition: vtkVolumeRayCastMapper.h:277
vtkGarbageCollector
Detect and break reference loops.
Definition: vtkGarbageCollector.h:99
VTK_THREAD_RETURN_TYPE
#define VTK_THREAD_RETURN_TYPE
Definition: vtkSystemIncludes.h:136
vtkVolumeRayCastMapper::GetGradientMagnitudeScale
virtual float GetGradientMagnitudeScale(int)
Definition: vtkVolumeRayCastMapper.h:199
vtkVolumeRayCastDynamicInfo
Definition: vtkVolumeRayCastFunction.h:46
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkVolumeRayCastMapper::VoxelsToViewTransform
vtkTransform * VoxelsToViewTransform
Definition: vtkVolumeRayCastMapper.h:248
vtkVolumeRayCastMapper::RenderVolumeTable
vtkVolume ** RenderVolumeTable
Definition: vtkVolumeRayCastMapper.h:276
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkAlgorithm::New
static vtkAlgorithm * New()
vtkVolumeRayCastMapper::GradientShader
vtkEncodedGradientShader * GradientShader
Definition: vtkVolumeRayCastMapper.h:211
vtkTimerLog
Timer support and logging.
Definition: vtkTimerLog.h:80
vtkAlgorithm::ReportReferences
void ReportReferences(vtkGarbageCollector *) override
VolumeRayCastMapper_CastRays
VTK_THREAD_RETURN_TYPE VolumeRayCastMapper_CastRays(void *arg)
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:63
vtkVolumeRayCastMapper::SampleDistance
double SampleDistance
Definition: vtkVolumeRayCastMapper.h:217
vtkVolumeRayCastMapper::MinimumViewDistance
float MinimumViewDistance
Definition: vtkVolumeRayCastMapper.h:290
vtkPlaneCollection
maintain a list of planes
Definition: vtkPlaneCollection.h:36
vtkVolumeRayCastMapper::ZBuffer
float * ZBuffer
Definition: vtkVolumeRayCastMapper.h:286
vtkVolumeRayCastMapper::RowBounds
int * RowBounds
Definition: vtkVolumeRayCastMapper.h:272
vtkVolumeRayCastMapper::VolumeMatrix
vtkMatrix4x4 * VolumeMatrix
Definition: vtkVolumeRayCastMapper.h:244
vtkVolumeRayCastMapper::GetGradientMagnitudeBias
virtual float GetGradientMagnitudeBias(int)
Definition: vtkVolumeRayCastMapper.h:201
vtkAbstractVolumeMapper::GetGradientMagnitudeBias
virtual float GetGradientMagnitudeBias()
Definition: vtkAbstractVolumeMapper.h:116
vtkVolumeRayCastStaticInfo
Definition: vtkVolumeRayCastFunction.h:70
vtkVolumeRayCastMapper::VoxelsToWorldMatrix
vtkMatrix4x4 * VoxelsToWorldMatrix
Definition: vtkVolumeRayCastMapper.h:242
vtkVolumeRayCastMapper::WorldToVoxelsMatrix
vtkMatrix4x4 * WorldToVoxelsMatrix
Definition: vtkVolumeRayCastMapper.h:241
vtkVolumeRayCastMapper::Threader
vtkMultiThreader * Threader
Definition: vtkVolumeRayCastMapper.h:235
vtkVolumeRayCastMapper::ScalarDataType
int ScalarDataType
Definition: vtkVolumeRayCastMapper.h:224