VTK  9.0.1
vtkSmartVolumeMapper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSmartVolumeMapper.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 =========================================================================*/
73 #ifndef vtkSmartVolumeMapper_h
74 #define vtkSmartVolumeMapper_h
75 
76 #include "vtkImageReslice.h" // for VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC
77 #include "vtkRenderingVolumeOpenGL2Module.h" // For export macro
78 #include "vtkVolumeMapper.h"
79 
82 class vtkImageResample;
85 class vtkRenderWindow;
86 class vtkVolume;
87 class vtkVolumeProperty;
88 class vtkImageMagnitude;
89 
90 class VTKRENDERINGVOLUMEOPENGL2_EXPORT vtkSmartVolumeMapper : public vtkVolumeMapper
91 {
92 public:
93  static vtkSmartVolumeMapper* New();
95  void PrintSelf(ostream& os, vtkIndent indent) override;
96 
98 
108  vtkSetMacro(FinalColorWindow, float);
110 
112 
115  vtkGetMacro(FinalColorWindow, float);
117 
119 
126  vtkSetMacro(FinalColorLevel, float);
128 
130 
133  vtkGetMacro(FinalColorLevel, float);
135 
136  // The possible values for the default and current render mode ivars
137  enum
138  {
139  DefaultRenderMode = 0,
140  RayCastRenderMode = 1,
141  GPURenderMode = 2,
142  OSPRayRenderMode = 3,
143  UndefinedRenderMode = 4,
144  InvalidRenderMode = 5
145  };
146 
151  void SetRequestedRenderMode(int mode);
152 
158  void SetRequestedRenderModeToDefault();
159 
165  void SetRequestedRenderModeToRayCast();
166 
172  void SetRequestedRenderModeToGPU();
173 
178  void SetRequestedRenderModeToOSPRay();
179 
181 
184  vtkGetMacro(RequestedRenderMode, int);
186 
191  int GetLastUsedRenderMode();
192 
194 
201  vtkSetMacro(MaxMemoryInBytes, vtkIdType);
202  vtkGetMacro(MaxMemoryInBytes, vtkIdType);
204 
206 
212  vtkSetClampMacro(MaxMemoryFraction, float, 0.1f, 1.0f);
213  vtkGetMacro(MaxMemoryFraction, float);
215 
217 
221  vtkSetClampMacro(InterpolationMode, int, VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC);
222  vtkGetMacro(InterpolationMode, int);
223  void SetInterpolationModeToNearestNeighbor();
224  void SetInterpolationModeToLinear();
225  void SetInterpolationModeToCubic();
227 
233  void CreateCanonicalView(vtkRenderer* ren, vtkVolume* volume, vtkVolume* volume2,
234  vtkImageData* image, int blend_mode, double viewDirection[3], double viewUp[3]);
235 
237 
243  vtkSetClampMacro(InteractiveUpdateRate, double, 1.0e-10, 1.0e10);
245 
247 
252  vtkGetMacro(InteractiveUpdateRate, double);
254 
256 
264  vtkSetClampMacro(InteractiveAdjustSampleDistances, vtkTypeBool, 0, 1);
265  vtkGetMacro(InteractiveAdjustSampleDistances, vtkTypeBool);
266  vtkBooleanMacro(InteractiveAdjustSampleDistances, vtkTypeBool);
268 
270 
279  vtkSetClampMacro(AutoAdjustSampleDistances, vtkTypeBool, 0, 1);
280  vtkGetMacro(AutoAdjustSampleDistances, vtkTypeBool);
281  vtkBooleanMacro(AutoAdjustSampleDistances, vtkTypeBool);
283 
285 
292  vtkSetMacro(SampleDistance, float);
293  vtkGetMacro(SampleDistance, float);
295 
300  void Render(vtkRenderer*, vtkVolume*) override;
301 
308  void ReleaseGraphicsResources(vtkWindow*) override;
309 
311 
319  {
320  DISABLED = -1,
321  MAGNITUDE = 0,
322  COMPONENT = 1,
323  };
324 
325  void SetVectorMode(int mode);
326  vtkGetMacro(VectorMode, int);
327 
328  vtkSetClampMacro(VectorComponent, int, 0, 3);
329  vtkGetMacro(VectorComponent, int);
331 
332 protected:
334  ~vtkSmartVolumeMapper() override;
335 
341  void ConnectMapperInput(vtkVolumeMapper* m);
342 
348  void ConnectFilterInput(vtkImageResample* f);
349 
351 
357 
359 
365 
370 
372 
380 
382 
391 
397 
399 
411 
416  void Initialize(vtkRenderer* ren, vtkVolume* vol);
417 
422  void ComputeRenderMode(vtkRenderer* ren, vtkVolume* vol);
423 
428  vtkGetObjectMacro(GPUMapper, vtkGPUVolumeRayCastMapper);
429 
431 
438 
445 
450 
456 
463 
472 
474 
485 
486 private:
488 
492  void SetupVectorMode(vtkVolume* vol);
498  void ComputeMagnitudeCellData(vtkImageData* input, vtkDataArray* arr);
499  void ComputeMagnitudePointData(vtkImageData* input, vtkDataArray* arr);
501 
503  void operator=(const vtkSmartVolumeMapper&) = delete;
504 
505  vtkOSPRayVolumeInterface* OSPRayMapper;
506 };
507 
508 #endif
vtkVolumeMapper
Abstract class for a volume mapper.
Definition: vtkVolumeMapper.h:43
vtkImageReslice.h
vtkSmartVolumeMapper::VectorComponent
int VectorComponent
Definition: vtkSmartVolumeMapper.h:482
vtkSmartVolumeMapper::FinalColorLevel
float FinalColorLevel
Definition: vtkSmartVolumeMapper.h:355
vtkVolume
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:44
vtkSmartVolumeMapper::SupportStatusCheckTime
vtkTimeStamp SupportStatusCheckTime
Definition: vtkSmartVolumeMapper.h:386
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkFixedPointVolumeRayCastMapper
A fixed point mapper for volumes.
Definition: vtkFixedPointVolumeRayCastMapper.h:103
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkX3D::image
@ image
Definition: vtkX3D.h:380
vtkSmartVolumeMapper::InteractiveUpdateRate
double InteractiveUpdateRate
If the DesiredUpdateRate of the vtkRenderWindow causing the Render is at or above this value,...
Definition: vtkSmartVolumeMapper.h:462
vtkSmartVolumeMapper::GPUSupported
int GPUSupported
Definition: vtkSmartVolumeMapper.h:387
vtkSmartVolumeMapper::RayCastSupported
int RayCastSupported
Definition: vtkSmartVolumeMapper.h:388
vtkMultiBlockVolumeMapper
Mapper to render volumes defined as vtkMultiBlockDataSet.
Definition: vtkMultiBlockVolumeMapper.h:49
vtkSmartVolumeMapper::CurrentRenderMode
int CurrentRenderMode
Definition: vtkSmartVolumeMapper.h:378
vtkImageMagnitude
Colapses components with magnitude function..
Definition: vtkImageMagnitude.h:28
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkSmartVolumeMapper::MaxMemoryFraction
float MaxMemoryFraction
Definition: vtkSmartVolumeMapper.h:363
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkSmartVolumeMapper::AutoAdjustSampleDistances
vtkTypeBool AutoAdjustSampleDistances
Set whether or not the sample distance should be automatically calculated within the internal volume ...
Definition: vtkSmartVolumeMapper.h:455
vtkSmartVolumeMapper::GPULowResMapper
vtkGPUVolumeRayCastMapper * GPULowResMapper
The three potential mappers.
Definition: vtkSmartVolumeMapper.h:428
vtkSmartVolumeMapper::VectorMode
int VectorMode
VectorMode is a special rendering mode for 3-component vectors which makes use of GPURayCastMapper's ...
Definition: vtkSmartVolumeMapper.h:481
vtkSmartVolumeMapper::InterpolationMode
int InterpolationMode
Used for downsampling.
Definition: vtkSmartVolumeMapper.h:369
vtkImageResample
Resamples an image to be larger or smaller.
Definition: vtkImageResample.h:31
vtkVolumeMapper::Render
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...
vtkSmartVolumeMapper::VectorModeType
VectorModeType
VectorMode is a special rendering mode for 3-component vectors which makes use of GPURayCastMapper's ...
Definition: vtkSmartVolumeMapper.h:318
VTK_RESLICE_CUBIC
#define VTK_RESLICE_CUBIC
Definition: vtkImageReslice.h:61
vtkVolumeMapper.h
vtkSmartVolumeMapper::InputDataMagnitude
vtkImageData * InputDataMagnitude
Definition: vtkSmartVolumeMapper.h:409
vtkSmartVolumeMapper::Initialized
int Initialized
Initialization variables.
Definition: vtkSmartVolumeMapper.h:385
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkSmartVolumeMapper
Adaptive volume mapper.
Definition: vtkSmartVolumeMapper.h:90
vtkSmartVolumeMapper::InteractiveAdjustSampleDistances
vtkTypeBool InteractiveAdjustSampleDistances
If the InteractiveAdjustSampleDistances flag is enabled, vtkSmartVolumeMapper interactively sets and ...
Definition: vtkSmartVolumeMapper.h:471
vtkSmartVolumeMapper::GPUMapper
vtkGPUVolumeRayCastMapper * GPUMapper
Definition: vtkSmartVolumeMapper.h:435
vtkGPUVolumeRayCastMapper
Ray casting performed on the GPU.
Definition: vtkGPUVolumeRayCastMapper.h:51
VTK_RESLICE_NEAREST
#define VTK_RESLICE_NEAREST
Definition: vtkImageReslice.h:59
vtkSmartVolumeMapper::InitializedBlendMode
int InitializedBlendMode
We need to keep track of the blend mode we had when we initialized because we need to reinitialize (a...
Definition: vtkSmartVolumeMapper.h:444
vtkSmartVolumeMapper::RequestedRenderMode
int RequestedRenderMode
The requested render mode is used to compute the current render mode.
Definition: vtkSmartVolumeMapper.h:377
vtkSmartVolumeMapper::ImageMagnitude
vtkImageMagnitude * ImageMagnitude
This filter is used to compute the magnitude of 3-component data.
Definition: vtkSmartVolumeMapper.h:408
vtkVolumeMapper::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
Definition: vtkVolumeMapper.h:203
vtkAlgorithm::New
static vtkAlgorithm * New()
vtkSmartVolumeMapper::LowResGPUNecessary
int LowResGPUNecessary
Definition: vtkSmartVolumeMapper.h:389
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:67
vtkSmartVolumeMapper::MagnitudeUploadTime
vtkTimeStamp MagnitudeUploadTime
Definition: vtkSmartVolumeMapper.h:483
vtkOSPRayVolumeInterface
Removes link dependence on optional ospray module.
Definition: vtkOSPRayVolumeInterface.h:33
vtkSmartVolumeMapper::RayCastMapper
vtkFixedPointVolumeRayCastMapper * RayCastMapper
Definition: vtkSmartVolumeMapper.h:436
vtkSmartVolumeMapper::MaxMemoryInBytes
vtkIdType MaxMemoryInBytes
GPU mapper-specific memory ivars.
Definition: vtkSmartVolumeMapper.h:362
vtkVolumeMapper::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkX3D::mode
@ mode
Definition: vtkX3D.h:253
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:93
vtkSmartVolumeMapper::FinalColorWindow
float FinalColorWindow
Window / level ivars.
Definition: vtkSmartVolumeMapper.h:354
vtkSmartVolumeMapper::GPUResampleFilter
vtkImageResample * GPUResampleFilter
This is the resample filter that may be used if we need to create a low resolution version of the vol...
Definition: vtkSmartVolumeMapper.h:396
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkVolumeProperty
represents the common properties for rendering a volume.
Definition: vtkVolumeProperty.h:74
vtkSmartVolumeMapper::SampleDistance
float SampleDistance
The distance between sample points along the ray.
Definition: vtkSmartVolumeMapper.h:449