VTK  9.7.1
vtkSmartVolumeMapper.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
64 #ifndef vtkSmartVolumeMapper_h
65 #define vtkSmartVolumeMapper_h
66 
67 #include "vtkImageReslice.h" // for VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC
68 #include "vtkRenderingVolumeOpenGL2Module.h" // For export macro
69 #include "vtkVolumeMapper.h"
70 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
71 
72 VTK_ABI_NAMESPACE_BEGIN
75 class vtkImageResample;
79 class vtkRenderWindow;
80 class vtkVolume;
81 class vtkVolumeProperty;
82 class vtkImageMagnitude;
83 
84 class VTKRENDERINGVOLUMEOPENGL2_EXPORT VTK_MARSHALAUTO vtkSmartVolumeMapper : public vtkVolumeMapper
85 {
86 public:
87  static vtkSmartVolumeMapper* New();
89  void PrintSelf(ostream& os, vtkIndent indent) override;
90 
92 
102  vtkSetMacro(FinalColorWindow, float);
104 
106 
109  vtkGetMacro(FinalColorWindow, float);
111 
113 
120  vtkSetMacro(FinalColorLevel, float);
122 
124 
127  vtkGetMacro(FinalColorLevel, float);
129 
130  // The possible values for the default and current render mode ivars
131  enum
132  {
133  DefaultRenderMode = 0,
134  RayCastRenderMode = 1,
135  GPURenderMode = 2,
136  OSPRayRenderMode = 3,
137  AnariRenderMode = 4,
138  UndefinedRenderMode = 5,
139  InvalidRenderMode = 6
140  };
141 
146  void SetRequestedRenderMode(int mode);
147 
153  void SetRequestedRenderModeToDefault();
154 
160  void SetRequestedRenderModeToRayCast();
161 
167  void SetRequestedRenderModeToGPU();
168 
173  void SetRequestedRenderModeToOSPRay();
174 
179  void SetRequestedRenderModeToAnari();
180 
182 
185  vtkGetMacro(RequestedRenderMode, int);
187 
192  int GetLastUsedRenderMode();
193 
195 
202  vtkSetMacro(MaxMemoryInBytes, vtkIdType);
203  vtkGetMacro(MaxMemoryInBytes, vtkIdType);
205 
207 
213  vtkSetClampMacro(MaxMemoryFraction, float, 0.1f, 1.0f);
214  vtkGetMacro(MaxMemoryFraction, float);
216 
218 
222  vtkSetClampMacro(InterpolationMode, int, VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC);
223  vtkGetMacro(InterpolationMode, int);
224  void SetInterpolationModeToNearestNeighbor();
225  void SetInterpolationModeToLinear();
226  void SetInterpolationModeToCubic();
228 
234  void CreateCanonicalView(vtkRenderer* ren, vtkVolume* volume, vtkVolume* volume2,
235  vtkImageData* image, int blend_mode, double viewDirection[3], double viewUp[3]);
236 
238 
243  vtkSetClampMacro(UseJittering, vtkTypeBool, 0, 1);
244  vtkGetMacro(UseJittering, vtkTypeBool);
245  vtkBooleanMacro(UseJittering, vtkTypeBool);
247 
249 
255  vtkSetClampMacro(InteractiveUpdateRate, double, 1.0e-10, 1.0e10);
257 
259 
264  vtkGetMacro(InteractiveUpdateRate, double);
266 
268 
276  vtkSetClampMacro(InteractiveAdjustSampleDistances, vtkTypeBool, 0, 1);
277  vtkGetMacro(InteractiveAdjustSampleDistances, vtkTypeBool);
278  vtkBooleanMacro(InteractiveAdjustSampleDistances, vtkTypeBool);
280 
282 
291  vtkSetClampMacro(AutoAdjustSampleDistances, vtkTypeBool, 0, 1);
292  vtkGetMacro(AutoAdjustSampleDistances, vtkTypeBool);
293  vtkBooleanMacro(AutoAdjustSampleDistances, vtkTypeBool);
295 
297 
304  vtkSetMacro(SampleDistance, float);
305  vtkGetMacro(SampleDistance, float);
307 
309 
315  vtkSetClampMacro(GlobalIlluminationReach, float, 0.0f, 1.0f);
316  vtkGetMacro(GlobalIlluminationReach, float);
318 
320 
326  vtkSetClampMacro(VolumetricScatteringBlending, float, 0.0f, 2.0f);
327  vtkGetMacro(VolumetricScatteringBlending, float);
329 
334  void Render(vtkRenderer*, vtkVolume*) override;
335 
342  void ReleaseGraphicsResources(vtkWindow*) override;
343 
345 
353  {
354  DISABLED = -1,
355  MAGNITUDE = 0,
356  COMPONENT = 1,
357  };
358 
359  void SetVectorMode(int mode);
360  vtkGetMacro(VectorMode, int);
361 
362  vtkSetClampMacro(VectorComponent, int, 0, 3);
363  vtkGetMacro(VectorComponent, int);
365 
367 
370  vtkSetStringMacro(Transfer2DYAxisArray);
371  vtkGetStringMacro(Transfer2DYAxisArray);
373 
375 
383  {
384  LowResModeDisabled = 0,
385  LowResModeResample = 1,
386  };
387 
388  vtkSetMacro(LowResMode, int);
389  vtkGetMacro(LowResMode, int)
391 
392 protected:
394  ~vtkSmartVolumeMapper() override;
395 
401  void ConnectMapperInput(vtkVolumeMapper* m);
402 
408  void ConnectFilterInput(vtkImageResample* f);
409 
411 
414  float FinalColorWindow;
415  float FinalColorLevel;
417 
419 
422  vtkIdType MaxMemoryInBytes;
423  float MaxMemoryFraction;
425 
429  int InterpolationMode;
430 
432 
437  int RequestedRenderMode;
438  int CurrentRenderMode;
440 
442 
445  int Initialized;
446  vtkTimeStamp SupportStatusCheckTime;
447  int GPUSupported;
448  int RayCastSupported;
449  int LowResGPUNecessary;
451 
456  vtkImageResample* GPUResampleFilter;
457 
459 
468  vtkImageMagnitude* ImageMagnitude;
469  vtkImageData* InputDataMagnitude;
471 
476  void Initialize(vtkRenderer* ren, vtkVolume* vol);
477 
482  void ComputeRenderMode(vtkRenderer* ren, vtkVolume* vol);
483 
488  vtkGetObjectMacro(GPUMapper, vtkGPUVolumeRayCastMapper);
489 
491 
494  vtkGPUVolumeRayCastMapper* GPULowResMapper;
495  vtkGPUVolumeRayCastMapper* GPUMapper;
498 
504  int InitializedBlendMode;
505 
509  vtkTypeBool UseJittering;
510 
514  float SampleDistance;
515 
519  float GlobalIlluminationReach = 0.0;
520 
524  float VolumetricScatteringBlending = 0.0;
525 
530  vtkTypeBool AutoAdjustSampleDistances;
531 
537  double InteractiveUpdateRate;
538 
546  vtkTypeBool InteractiveAdjustSampleDistances;
547 
549 
556  int VectorMode;
557  int VectorComponent;
558  vtkTimeStamp MagnitudeUploadTime;
560 
562 
566  vtkDataSet* LastInput;
567  vtkDataSet* LastFilterInput;
569 
575  char* Transfer2DYAxisArray;
576 
577  int LowResMode = LowResModeDisabled;
578 
579 private:
581 
585  void SetupVectorMode(vtkVolume* vol);
591  void ComputeMagnitudeCellData(vtkDataSet* input, vtkDataArray* arr);
592  void ComputeMagnitudePointData(vtkDataSet* input, vtkDataArray* arr);
594 
595  vtkSmartVolumeMapper(const vtkSmartVolumeMapper&) = delete;
596  void operator=(const vtkSmartVolumeMapper&) = delete;
597 
598  vtkOSPRayVolumeInterface* OSPRayMapper;
599  vtkAnariVolumeInterface* AnariMapper;
600 };
601 
602 VTK_ABI_NAMESPACE_END
603 #endif
Removes link dependence on optional ANARI module.
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:40
#define VTK_RESLICE_NEAREST
Abstract class for a volume mapper.
#define VTK_RESLICE_CUBIC
Adaptive volume mapper.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
LowResModeType
LowResDisable disables low res mode (default) LowResResample enable low res mode by automatically res...
record modification and/or execution time
Definition: vtkTimeStamp.h:24
Resamples an image to be larger or smaller.
abstract specification for renderers
Definition: vtkRenderer.h:63
int vtkIdType
Definition: vtkType.h:363
Mapper to render volumes defined as vtkMultiBlockDataSet.
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:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
VectorModeType
VectorMode is a special rendering mode for 3-component vectors which makes use of GPURayCastMapper's ...
a simple class to control print indentation
Definition: vtkIndent.h:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
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...
A fixed point mapper for volumes.
create a window for renderers to draw into
Removes link dependence on optional ospray module.
static vtkAlgorithm * New()
#define VTK_MARSHALAUTO
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.