VTK  9.3.1
vtkGPUVolumeRayCastMapper.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
24 #ifndef vtkGPUVolumeRayCastMapper_h
25 #define vtkGPUVolumeRayCastMapper_h
26 #include <unordered_map> // For std::unordered_map
27 #include <vector> // For std::vector
28 
29 #include "vtkRenderingVolumeModule.h" // For export macro
30 #include "vtkVolumeMapper.h"
31 
32 VTK_ABI_NAMESPACE_BEGIN
33 class vtkContourValues;
34 class vtkRenderWindow;
35 class vtkVolumeProperty;
36 
37 class VTKRENDERINGVOLUME_EXPORT vtkGPUVolumeRayCastMapper : public vtkVolumeMapper
38 {
39 public:
42  void PrintSelf(ostream& os, vtkIndent indent) override;
43 
45 
51  vtkSetClampMacro(AutoAdjustSampleDistances, vtkTypeBool, 0, 1);
52  vtkGetMacro(AutoAdjustSampleDistances, vtkTypeBool);
53  vtkBooleanMacro(AutoAdjustSampleDistances, vtkTypeBool);
55 
57 
62  vtkSetClampMacro(LockSampleDistanceToInputSpacing, vtkTypeBool, 0, 1);
63  vtkGetMacro(LockSampleDistanceToInputSpacing, vtkTypeBool);
64  vtkBooleanMacro(LockSampleDistanceToInputSpacing, vtkTypeBool);
66 
68 
73  vtkSetClampMacro(UseJittering, vtkTypeBool, 0, 1);
74  vtkGetMacro(UseJittering, vtkTypeBool);
75  vtkBooleanMacro(UseJittering, vtkTypeBool);
77 
79 
87  vtkSetClampMacro(UseDepthPass, vtkTypeBool, 0, 1);
88  vtkGetMacro(UseDepthPass, vtkTypeBool);
89  vtkBooleanMacro(UseDepthPass, vtkTypeBool);
91 
97  vtkContourValues* GetDepthPassContourValues();
98 
100 
106  vtkSetMacro(SampleDistance, float);
107  vtkGetMacro(SampleDistance, float);
109 
111 
118  vtkSetClampMacro(ImageSampleDistance, float, 0.1f, 100.0f);
119  vtkGetMacro(ImageSampleDistance, float);
121 
123 
127  vtkSetClampMacro(MinimumImageSampleDistance, float, 0.1f, 100.0f);
128  vtkGetMacro(MinimumImageSampleDistance, float);
130 
132 
136  vtkSetClampMacro(MaximumImageSampleDistance, float, 0.1f, 100.0f);
137  vtkGetMacro(MaximumImageSampleDistance, float);
139 
141 
154  vtkSetMacro(FinalColorWindow, float);
155  vtkGetMacro(FinalColorWindow, float);
156  vtkSetMacro(FinalColorLevel, float);
157  vtkGetMacro(FinalColorLevel, float);
159 
161 
166  vtkSetMacro(MaxMemoryInBytes, vtkIdType);
167  vtkGetMacro(MaxMemoryInBytes, vtkIdType);
169 
171 
176  vtkSetClampMacro(MaxMemoryFraction, float, 0.1f, 1.0f);
177  vtkGetMacro(MaxMemoryFraction, float);
179 
181 
189  vtkSetMacro(ReportProgress, bool);
190  vtkGetMacro(ReportProgress, bool);
192 
199  virtual int IsRenderSupported(
200  vtkRenderWindow* vtkNotUsed(window), vtkVolumeProperty* vtkNotUsed(property))
201  {
202  return 0;
203  }
204 
205  void CreateCanonicalView(vtkRenderer* ren, vtkVolume* volume, vtkImageData* image, int blend_mode,
206  double viewDirection[3], double viewUp[3]);
207 
209 
229  void SetMaskInput(vtkImageData* mask);
230  vtkGetObjectMacro(MaskInput, vtkImageData);
232 
233  enum
234  {
235  BinaryMaskType = 0,
236  LabelMapMaskType
237  };
238 
240 
244  vtkSetMacro(MaskType, int);
245  vtkGetMacro(MaskType, int);
246  void SetMaskTypeToBinary();
247  void SetMaskTypeToLabelMap();
249 
251 
259  vtkSetClampMacro(MaskBlendFactor, float, 0.0f, 1.0f);
260  vtkGetMacro(MaskBlendFactor, float);
262 
264 
271  vtkSetClampMacro(GlobalIlluminationReach, float, 0.0f, 1.0f);
272  vtkGetMacro(GlobalIlluminationReach, float);
274 
276 
287  vtkSetClampMacro(VolumetricScatteringBlending, float, 0.0f, 2.0f);
288  vtkGetMacro(VolumetricScatteringBlending, float);
290 
292 
306  vtkSetMacro(RenderToImage, vtkTypeBool);
307  vtkGetMacro(RenderToImage, vtkTypeBool);
308  vtkBooleanMacro(RenderToImage, vtkTypeBool);
310 
312 
317  vtkSetMacro(DepthImageScalarType, int);
318  vtkGetMacro(DepthImageScalarType, int);
319  void SetDepthImageScalarTypeToUnsignedChar();
320  void SetDepthImageScalarTypeToUnsignedShort();
321  void SetDepthImageScalarTypeToFloat();
323 
325 
336  vtkSetMacro(ClampDepthToBackface, vtkTypeBool);
337  vtkGetMacro(ClampDepthToBackface, vtkTypeBool);
338  vtkBooleanMacro(ClampDepthToBackface, vtkTypeBool);
340 
347  virtual void GetDepthImage(vtkImageData*) {}
348 
355  virtual void GetColorImage(vtkImageData*) {}
356 
361  void Render(vtkRenderer*, vtkVolume*) override;
362 
367  virtual void GPURender(vtkRenderer*, vtkVolume*) {}
368 
376 
389  virtual void GetReductionRatio(double ratio[3]) = 0;
390 
392  {
393  SCALAR = 0, // default
394  NATIVE
395  };
396 
398 
414  vtkSetMacro(ColorRangeType, int);
415  vtkGetMacro(ColorRangeType, int);
416  vtkSetMacro(ScalarOpacityRangeType, int);
417  vtkGetMacro(ScalarOpacityRangeType, int);
418  vtkSetMacro(GradientOpacityRangeType, int);
419  vtkGetMacro(GradientOpacityRangeType, int);
421 
422  vtkDataSet* GetInput() override { return this->GetInput(0); };
423 
425 
429  void RemoveInputConnection(int port, vtkAlgorithmOutput* input) override;
430  void RemoveInputConnection(int port, int idx) override;
431  void SetInputConnection(int port, vtkAlgorithmOutput* input) override;
433  {
434  this->SetInputConnection(0, input);
435  }
437 
441  int GetInputCount();
442 
443  vtkDataSet* GetTransformedInput(int port = 0);
444 
445  double* GetBoundsFromPort(int port) VTK_SIZEHINT(6);
446 
448 
451  vtkSetStringMacro(Transfer2DYAxisArray);
452  vtkGetStringMacro(Transfer2DYAxisArray);
454 
455 protected:
457  ~vtkGPUVolumeRayCastMapper() override;
458 
467  int FillInputPortInformation(int port, vtkInformation* info) override;
468 
480  void TransformInput(int port);
481 
483 
492  int ValidateRender(vtkRenderer*, vtkVolume*);
493  int ValidateInputs();
494  int ValidateInput(vtkVolumeProperty* property, int port);
496 
498 
502  void CloneInputs();
503  void CloneInput(vtkDataSet* input, int port);
505 
506  // Special version of render called during the creation
507  // of a canonical view.
508  void CanonicalViewRender(vtkRenderer*, vtkVolume*);
509 
510  // Methods called by the AMR Volume Mapper.
511  virtual void PreRender(vtkRenderer* ren, vtkVolume* vol, double datasetBounds[6],
512  double scalarRange[2], int numberOfScalarComponents, unsigned int numberOfLevels) = 0;
513 
514  // \pre input is up-to-date
515  virtual void RenderBlock(vtkRenderer* ren, vtkVolume* vol, unsigned int level) = 0;
516 
517  virtual void PostRender(vtkRenderer* ren, int numberOfScalarComponents) = 0;
518  vtkDataSet* GetInput(int port) override;
519 
525  void SetCellFlag(int cellFlag);
526  void RemovePortInternal(int port);
527 
533 
534  // Render to texture mode flag
536 
537  // Depth image scalar type
539 
540  // Clamp depth values to the depth of the face at which the ray
541  // exits the volume
543 
544  // Enable / disable stochastic jittering
546 
547  // Secondary rays ambient/global adjustment coefficient
548  float GlobalIlluminationReach = 0.0;
549 
550  float VolumetricScatteringBlending = 0.0;
551 
552  // Enable / disable two pass rendering
555 
556  // The distance between sample points along the ray
558 
562 
565 
566  // 1 if we are generating the canonical image, 0 otherwise
569 
571 
575  vtkSetClampMacro(AMRMode, vtkTypeBool, 0, 1);
576  vtkGetMacro(AMRMode, vtkTypeBool);
577  vtkBooleanMacro(AMRMode, vtkTypeBool);
579 
582  int MaskType;
583 
585 
586  // Transfer function range type
590 
591  // Point data or cell data (or field data, not handled) ?
592  int CellFlag;
593 
606  virtual void ClipCroppingRegionPlanes();
607 
608  using DataMap = std::unordered_map<int, vtkDataSet*>;
609  void SetTransformedInput(vtkDataSet*);
610  vtkDataSet* FindData(int port, DataMap& container);
611 
612  double ClippedCroppingRegionPlanes[6];
613 
616 
618  std::vector<int> Ports;
619  std::vector<int> RemovedPorts;
621 
627 
634 
635 private:
637  void operator=(const vtkGPUVolumeRayCastMapper&) = delete;
638 };
639 
640 VTK_ABI_NAMESPACE_END
641 #endif
virtual void GPURender(vtkRenderer *, vtkVolume *)
Handled in the subclass - the actual render method.
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
helper object to manage setting and generating contour values
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:39
Abstract class for a volume mapper.
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:52
virtual void GetDepthImage(vtkImageData *)
Low level API to export the depth texture as vtkImageData in RenderToImage mode.
virtual void GetColorImage(vtkImageData *)
Low level API to export the color texture as vtkImageData in RenderToImage mode.
abstract specification for renderers
Definition: vtkRenderer.h:61
int vtkIdType
Definition: vtkType.h:315
std::unordered_map< int, vtkDataSet * > DataMap
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...
Proxy object to connect input/output ports.
int vtkTypeBool
Definition: vtkABI.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
virtual vtkDataSet * GetInput()
Set/Get the input data.
a simple class to control print indentation
Definition: vtkIndent.h:28
int FillInputPortInformation(int, vtkInformation *) override
Fill the input port information objects for this algorithm.
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
virtual void SetInputConnection(int port, vtkAlgorithmOutput *input)
Set the connection for the given input port index.
#define VTK_SIZEHINT(...)
represents the common properties for rendering a volume.
virtual int IsRenderSupported(vtkRenderWindow *vtkNotUsed(window), vtkVolumeProperty *vtkNotUsed(property))
Based on hardware and properties, we may or may not be able to render using 3D texture mapping...
create a window for renderers to draw into
DataMap LastInputs
This is needed only to check if the input data has been changed since the last Render() call...
static vtkAlgorithm * New()
char * Transfer2DYAxisArray
Define the array used for the Y axis of transfer 2D.
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.
void SetInputConnection(vtkAlgorithmOutput *input) override
Add/Remove input connections.
vtkDataSet * GetInput() override
Set/Get the input data.
virtual void RemoveInputConnection(int port, vtkAlgorithmOutput *input)
Remove a connection from the given input port index.