VTK  9.2.6
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 =========================================================================*/
76 #ifndef vtkSmartVolumeMapper_h
77 #define vtkSmartVolumeMapper_h
78 
79 #include "vtkImageReslice.h" // for VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC
80 #include "vtkRenderingVolumeOpenGL2Module.h" // For export macro
81 #include "vtkVolumeMapper.h"
82 
85 class vtkImageResample;
88 class vtkRenderWindow;
89 class vtkVolume;
90 class vtkVolumeProperty;
91 class vtkImageMagnitude;
92 
93 class VTKRENDERINGVOLUMEOPENGL2_EXPORT vtkSmartVolumeMapper : public vtkVolumeMapper
94 {
95 public:
96  static vtkSmartVolumeMapper* New();
98  void PrintSelf(ostream& os, vtkIndent indent) override;
99 
101 
111  vtkSetMacro(FinalColorWindow, float);
113 
115 
118  vtkGetMacro(FinalColorWindow, float);
120 
122 
129  vtkSetMacro(FinalColorLevel, float);
131 
133 
136  vtkGetMacro(FinalColorLevel, float);
138 
139  // The possible values for the default and current render mode ivars
140  enum
141  {
142  DefaultRenderMode = 0,
143  RayCastRenderMode = 1,
144  GPURenderMode = 2,
145  OSPRayRenderMode = 3,
146  UndefinedRenderMode = 4,
147  InvalidRenderMode = 5
148  };
149 
154  void SetRequestedRenderMode(int mode);
155 
161  void SetRequestedRenderModeToDefault();
162 
168  void SetRequestedRenderModeToRayCast();
169 
175  void SetRequestedRenderModeToGPU();
176 
181  void SetRequestedRenderModeToOSPRay();
182 
184 
187  vtkGetMacro(RequestedRenderMode, int);
189 
194  int GetLastUsedRenderMode();
195 
197 
204  vtkSetMacro(MaxMemoryInBytes, vtkIdType);
205  vtkGetMacro(MaxMemoryInBytes, vtkIdType);
207 
209 
215  vtkSetClampMacro(MaxMemoryFraction, float, 0.1f, 1.0f);
216  vtkGetMacro(MaxMemoryFraction, float);
218 
220 
224  vtkSetClampMacro(InterpolationMode, int, VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC);
225  vtkGetMacro(InterpolationMode, int);
226  void SetInterpolationModeToNearestNeighbor();
227  void SetInterpolationModeToLinear();
228  void SetInterpolationModeToCubic();
230 
236  void CreateCanonicalView(vtkRenderer* ren, vtkVolume* volume, vtkVolume* volume2,
237  vtkImageData* image, int blend_mode, double viewDirection[3], double viewUp[3]);
238 
240 
246  vtkSetClampMacro(InteractiveUpdateRate, double, 1.0e-10, 1.0e10);
248 
250 
255  vtkGetMacro(InteractiveUpdateRate, double);
257 
259 
267  vtkSetClampMacro(InteractiveAdjustSampleDistances, vtkTypeBool, 0, 1);
268  vtkGetMacro(InteractiveAdjustSampleDistances, vtkTypeBool);
269  vtkBooleanMacro(InteractiveAdjustSampleDistances, vtkTypeBool);
271 
273 
282  vtkSetClampMacro(AutoAdjustSampleDistances, vtkTypeBool, 0, 1);
283  vtkGetMacro(AutoAdjustSampleDistances, vtkTypeBool);
284  vtkBooleanMacro(AutoAdjustSampleDistances, vtkTypeBool);
286 
288 
295  vtkSetMacro(SampleDistance, float);
296  vtkGetMacro(SampleDistance, float);
298 
300 
306  vtkSetClampMacro(GlobalIlluminationReach, float, 0.0f, 1.0f);
307  vtkGetMacro(GlobalIlluminationReach, float);
309 
311 
317  vtkSetClampMacro(VolumetricScatteringBlending, float, 0.0f, 2.0f);
318  vtkGetMacro(VolumetricScatteringBlending, float);
320 
325  void Render(vtkRenderer*, vtkVolume*) override;
326 
333  void ReleaseGraphicsResources(vtkWindow*) override;
334 
336 
344  {
345  DISABLED = -1,
346  MAGNITUDE = 0,
347  COMPONENT = 1,
348  };
349 
350  void SetVectorMode(int mode);
351  vtkGetMacro(VectorMode, int);
352 
353  vtkSetClampMacro(VectorComponent, int, 0, 3);
354  vtkGetMacro(VectorComponent, int);
356 
358 
361  vtkSetStringMacro(Transfer2DYAxisArray);
362  vtkGetStringMacro(Transfer2DYAxisArray);
364 
365 protected:
367  ~vtkSmartVolumeMapper() override;
368 
374  void ConnectMapperInput(vtkVolumeMapper* m);
375 
381  void ConnectFilterInput(vtkImageResample* f);
382 
384 
390 
392 
398 
403 
405 
413 
415 
424 
430 
432 
444 
449  void Initialize(vtkRenderer* ren, vtkVolume* vol);
450 
455  void ComputeRenderMode(vtkRenderer* ren, vtkVolume* vol);
456 
461  vtkGetObjectMacro(GPUMapper, vtkGPUVolumeRayCastMapper);
462 
464 
471 
478 
483 
487  float GlobalIlluminationReach = 0.0;
488 
492  float VolumetricScatteringBlending = 0.0;
493 
499 
506 
515 
517 
528 
530 
537 
544 
545 private:
547 
551  void SetupVectorMode(vtkVolume* vol);
557  void ComputeMagnitudeCellData(vtkDataSet* input, vtkDataArray* arr);
558  void ComputeMagnitudePointData(vtkDataSet* input, vtkDataArray* arr);
560 
562  void operator=(const vtkSmartVolumeMapper&) = delete;
563 
564  vtkOSPRayVolumeInterface* OSPRayMapper;
565 };
566 
567 #endif
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:50
#define VTK_RESLICE_NEAREST
Abstract class for a volume mapper.
int VectorComponent
VectorMode is a special rendering mode for 3-component vectors which makes use of GPURayCastMapper's ...
vtkDataSet * LastInput
Keep a cache of the last input to the mapper so that input data changes can be propagated to the resa...
#define VTK_RESLICE_CUBIC
Adaptive volume mapper.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
int RayCastSupported
Initialization variables.
record modification and/or execution time
Definition: vtkTimeStamp.h:35
vtkTimeStamp SupportStatusCheckTime
Initialization variables.
Resamples an image to be larger or smaller.
int LowResGPUNecessary
Initialization variables.
vtkFixedPointVolumeRayCastMapper * RayCastMapper
The three potential mappers.
vtkTypeBool InteractiveAdjustSampleDistances
If the InteractiveAdjustSampleDistances flag is enabled, vtkSmartVolumeMapper interactively sets and ...
vtkGPUVolumeRayCastMapper * GPULowResMapper
The three potential mappers.
abstract specification for renderers
Definition: vtkRenderer.h:72
int RequestedRenderMode
The requested render mode is used to compute the current render mode.
int vtkIdType
Definition: vtkType.h:332
vtkImageResample * GPUResampleFilter
This is the resample filter that may be used if we need to create a low resolution version of the vol...
float SampleDistance
The distance between sample points along the ray.
vtkIdType MaxMemoryInBytes
GPU mapper-specific memory ivars.
Mapper to render volumes defined as vtkMultiBlockDataSet.
int VectorMode
VectorMode is a special rendering mode for 3-component vectors which makes use of GPURayCastMapper's ...
vtkImageMagnitude * ImageMagnitude
This filter is used to compute the magnitude of 3-component data.
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...
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
VectorModeType
VectorMode is a special rendering mode for 3-component vectors which makes use of GPURayCastMapper's ...
float FinalColorLevel
Window / level ivars.
char * Transfer2DYAxisArray
Define the array used for the Y axis of transfer 2D.
a simple class to control print indentation
Definition: vtkIndent.h:39
double InteractiveUpdateRate
If the DesiredUpdateRate of the vtkRenderWindow causing the Render is at or above this value...
vtkTypeBool AutoAdjustSampleDistances
Set whether or not the sample distance should be automatically calculated within the internal volume ...
topologically and geometrically regular array of data
Definition: vtkImageData.h:53
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
int CurrentRenderMode
The requested render mode is used to compute the current render mode.
represents the common properties for rendering a volume.
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
create a window for renderers to draw into
Removes link dependence on optional ospray module.
vtkTimeStamp MagnitudeUploadTime
VectorMode is a special rendering mode for 3-component vectors which makes use of GPURayCastMapper's ...
vtkGPUVolumeRayCastMapper * GPUMapper
The three potential mappers.
int InitializedBlendMode
We need to keep track of the blend mode we had when we initialized because we need to reinitialize (a...
int Initialized
Initialization variables.
int GPUSupported
Initialization variables.
static vtkAlgorithm * New()
vtkImageData * InputDataMagnitude
This filter is used to compute the magnitude of 3-component data.
float MaxMemoryFraction
GPU mapper-specific memory ivars.
int InterpolationMode
Used for downsampling.
Ray casting performed on the GPU.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
float FinalColorWindow
Window / level ivars.
vtkDataSet * LastFilterInput
Keep a cache of the last input to the mapper so that input data changes can be propagated to the resa...