VTK  9.3.0
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
21#ifndef vtkGPUVolumeRayCastMapper_h
22#define vtkGPUVolumeRayCastMapper_h
23#include <unordered_map> // For std::unordered_map
24#include <vector> // For std::vector
25
26#include "vtkRenderingVolumeModule.h" // For export macro
27#include "vtkVolumeMapper.h"
28
29VTK_ABI_NAMESPACE_BEGIN
31class vtkRenderWindow;
33
34class VTKRENDERINGVOLUME_EXPORT vtkGPUVolumeRayCastMapper : public vtkVolumeMapper
35{
36public:
39 void PrintSelf(ostream& os, vtkIndent indent) override;
40
42
48 vtkSetClampMacro(AutoAdjustSampleDistances, vtkTypeBool, 0, 1);
49 vtkGetMacro(AutoAdjustSampleDistances, vtkTypeBool);
50 vtkBooleanMacro(AutoAdjustSampleDistances, vtkTypeBool);
52
54
59 vtkSetClampMacro(LockSampleDistanceToInputSpacing, vtkTypeBool, 0, 1);
60 vtkGetMacro(LockSampleDistanceToInputSpacing, vtkTypeBool);
61 vtkBooleanMacro(LockSampleDistanceToInputSpacing, vtkTypeBool);
63
65
70 vtkSetClampMacro(UseJittering, vtkTypeBool, 0, 1);
71 vtkGetMacro(UseJittering, vtkTypeBool);
72 vtkBooleanMacro(UseJittering, vtkTypeBool);
74
76
84 vtkSetClampMacro(UseDepthPass, vtkTypeBool, 0, 1);
85 vtkGetMacro(UseDepthPass, vtkTypeBool);
86 vtkBooleanMacro(UseDepthPass, vtkTypeBool);
88
95
97
103 vtkSetMacro(SampleDistance, float);
104 vtkGetMacro(SampleDistance, float);
106
108
115 vtkSetClampMacro(ImageSampleDistance, float, 0.1f, 100.0f);
116 vtkGetMacro(ImageSampleDistance, float);
118
120
124 vtkSetClampMacro(MinimumImageSampleDistance, float, 0.1f, 100.0f);
125 vtkGetMacro(MinimumImageSampleDistance, float);
127
129
133 vtkSetClampMacro(MaximumImageSampleDistance, float, 0.1f, 100.0f);
134 vtkGetMacro(MaximumImageSampleDistance, float);
136
138
151 vtkSetMacro(FinalColorWindow, float);
152 vtkGetMacro(FinalColorWindow, float);
153 vtkSetMacro(FinalColorLevel, float);
154 vtkGetMacro(FinalColorLevel, float);
156
158
163 vtkSetMacro(MaxMemoryInBytes, vtkIdType);
164 vtkGetMacro(MaxMemoryInBytes, vtkIdType);
166
168
173 vtkSetClampMacro(MaxMemoryFraction, float, 0.1f, 1.0f);
174 vtkGetMacro(MaxMemoryFraction, float);
176
178
186 vtkSetMacro(ReportProgress, bool);
187 vtkGetMacro(ReportProgress, bool);
189
196 virtual int IsRenderSupported(
197 vtkRenderWindow* vtkNotUsed(window), vtkVolumeProperty* vtkNotUsed(property))
198 {
199 return 0;
200 }
201
202 void CreateCanonicalView(vtkRenderer* ren, vtkVolume* volume, vtkImageData* image, int blend_mode,
203 double viewDirection[3], double viewUp[3]);
204
206
227 vtkGetObjectMacro(MaskInput, vtkImageData);
229
230 enum
231 {
232 BinaryMaskType = 0,
233 LabelMapMaskType
234 };
235
237
241 vtkSetMacro(MaskType, int);
242 vtkGetMacro(MaskType, int);
246
248
256 vtkSetClampMacro(MaskBlendFactor, float, 0.0f, 1.0f);
257 vtkGetMacro(MaskBlendFactor, float);
259
261
268 vtkSetClampMacro(GlobalIlluminationReach, float, 0.0f, 1.0f);
269 vtkGetMacro(GlobalIlluminationReach, float);
271
273
284 vtkSetClampMacro(VolumetricScatteringBlending, float, 0.0f, 2.0f);
285 vtkGetMacro(VolumetricScatteringBlending, float);
287
289
303 vtkSetMacro(RenderToImage, vtkTypeBool);
304 vtkGetMacro(RenderToImage, vtkTypeBool);
305 vtkBooleanMacro(RenderToImage, vtkTypeBool);
307
309
314 vtkSetMacro(DepthImageScalarType, int);
315 vtkGetMacro(DepthImageScalarType, int);
320
322
333 vtkSetMacro(ClampDepthToBackface, vtkTypeBool);
334 vtkGetMacro(ClampDepthToBackface, vtkTypeBool);
335 vtkBooleanMacro(ClampDepthToBackface, vtkTypeBool);
337
344 virtual void GetDepthImage(vtkImageData*) {}
345
352 virtual void GetColorImage(vtkImageData*) {}
353
358 void Render(vtkRenderer*, vtkVolume*) override;
359
364 virtual void GPURender(vtkRenderer*, vtkVolume*) {}
365
373
386 virtual void GetReductionRatio(double ratio[3]) = 0;
387
389 {
390 SCALAR = 0, // default
391 NATIVE
392 };
393
395
411 vtkSetMacro(ColorRangeType, int);
412 vtkGetMacro(ColorRangeType, int);
413 vtkSetMacro(ScalarOpacityRangeType, int);
414 vtkGetMacro(ScalarOpacityRangeType, int);
415 vtkSetMacro(GradientOpacityRangeType, int);
416 vtkGetMacro(GradientOpacityRangeType, int);
418
419 vtkDataSet* GetInput() override { return this->GetInput(0); };
420
422
426 void RemoveInputConnection(int port, vtkAlgorithmOutput* input) override;
427 void RemoveInputConnection(int port, int idx) override;
428 void SetInputConnection(int port, vtkAlgorithmOutput* input) override;
430 {
431 this->SetInputConnection(0, input);
432 }
434
439
441
442 double* GetBoundsFromPort(int port) VTK_SIZEHINT(6);
443
445
448 vtkSetStringMacro(Transfer2DYAxisArray);
449 vtkGetStringMacro(Transfer2DYAxisArray);
451
452protected:
455
464 int FillInputPortInformation(int port, vtkInformation* info) override;
465
477 void TransformInput(int port);
478
480
491 int ValidateInput(vtkVolumeProperty* property, int port);
493
495
500 void CloneInput(vtkDataSet* input, int port);
502
503 // Special version of render called during the creation
504 // of a canonical view.
506
507 // Methods called by the AMR Volume Mapper.
508 virtual void PreRender(vtkRenderer* ren, vtkVolume* vol, double datasetBounds[6],
509 double scalarRange[2], int numberOfScalarComponents, unsigned int numberOfLevels) = 0;
510
511 // \pre input is up-to-date
512 virtual void RenderBlock(vtkRenderer* ren, vtkVolume* vol, unsigned int level) = 0;
513
514 virtual void PostRender(vtkRenderer* ren, int numberOfScalarComponents) = 0;
515 vtkDataSet* GetInput(int port) override;
516
522 void SetCellFlag(int cellFlag);
523 void RemovePortInternal(int port);
524
530
531 // Render to texture mode flag
533
534 // Depth image scalar type
536
537 // Clamp depth values to the depth of the face at which the ray
538 // exits the volume
540
541 // Enable / disable stochastic jittering
543
544 // Secondary rays ambient/global adjustment coefficient
545 float GlobalIlluminationReach = 0.0;
546
547 float VolumetricScatteringBlending = 0.0;
548
549 // Enable / disable two pass rendering
552
553 // The distance between sample points along the ray
555
559
562
563 // 1 if we are generating the canonical image, 0 otherwise
566
568
572 vtkSetClampMacro(AMRMode, vtkTypeBool, 0, 1);
573 vtkGetMacro(AMRMode, vtkTypeBool);
574 vtkBooleanMacro(AMRMode, vtkTypeBool);
576
580
582
583 // Transfer function range type
587
588 // Point data or cell data (or field data, not handled) ?
590
604
605 using DataMap = std::unordered_map<int, vtkDataSet*>;
607 vtkDataSet* FindData(int port, DataMap& container);
608
609 double ClippedCroppingRegionPlanes[6];
610
613
615 std::vector<int> Ports;
616 std::vector<int> RemovedPorts;
618
624
631
632private:
634 void operator=(const vtkGPUVolumeRayCastMapper&) = delete;
635};
636
637VTK_ABI_NAMESPACE_END
638#endif
Proxy object to connect input/output ports.
virtual void SetInputConnection(int port, vtkAlgorithmOutput *input)
Set the connection for the given input port index.
helper object to manage setting and generating contour values
abstract class to specify dataset behavior
Definition vtkDataSet.h:53
Ray casting performed on the GPU.
virtual void GetDepthImage(vtkImageData *)
Low level API to export the depth texture as vtkImageData in RenderToImage mode.
void CloneInput(vtkDataSet *input, int port)
Shallow-copy the inputs into a transform-adjusted clone.
vtkDataSet * GetInput(int port) override
Set/Get the input data.
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.
void CloneInputs()
Shallow-copy the inputs into a transform-adjusted clone.
void SetMaskTypeToLabelMap()
Set the mask type, if mask is to be used.
void RemoveInputConnection(int port, int idx) override
Add/Remove input connections.
double * GetBoundsFromPort(int port)
void SetTransformedInput(vtkDataSet *)
void SetDepthImageScalarTypeToFloat()
Set/Get the scalar type of the depth texture in RenderToImage mode.
virtual void GPURender(vtkRenderer *, vtkVolume *)
Handled in the subclass - the actual render method.
char * Transfer2DYAxisArray
Define the array used for the Y axis of transfer 2D.
int ValidateRender(vtkRenderer *, vtkVolume *)
This method is used by the Render() method to validate everything before attempting to render.
vtkDataSet * GetTransformedInput(int port=0)
virtual void GetColorImage(vtkImageData *)
Low level API to export the color texture as vtkImageData in RenderToImage mode.
vtkDataSet * GetInput() override
Set/Get the input data.
vtkContourValues * GetDepthPassContourValues()
Return handle to contour values container so that values can be set by the application.
void SetInputConnection(vtkAlgorithmOutput *input) override
Add/Remove input connections.
void SetDepthImageScalarTypeToUnsignedShort()
Set/Get the scalar type of the depth texture in RenderToImage mode.
void SetMaskInput(vtkImageData *mask)
Optionally, set a mask input.
~vtkGPUVolumeRayCastMapper() override
virtual void GetReductionRatio(double ratio[3])=0
Return how much the dataset has to be reduced in each dimension to fit on the GPU.
int ValidateInput(vtkVolumeProperty *property, int port)
This method is used by the Render() method to validate everything before attempting to render.
DataMap LastInputs
This is needed only to check if the input data has been changed since the last Render() call.
void CreateCanonicalView(vtkRenderer *ren, vtkVolume *volume, vtkImageData *image, int blend_mode, double viewDirection[3], double viewUp[3])
void SetDepthImageScalarTypeToUnsignedChar()
Set/Get the scalar type of the depth texture in RenderToImage mode.
int ValidateInputs()
This method is used by the Render() method to validate everything before attempting to render.
std::unordered_map< int, vtkDataSet * > DataMap
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
void TransformInput(int port)
A transformation is applied (translation) to the input.
void Render(vtkRenderer *, vtkVolume *) override
Initialize rendering for this volume.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void RemoveInputConnection(int port, vtkAlgorithmOutput *input) override
Add/Remove input connections.
virtual void PreRender(vtkRenderer *ren, vtkVolume *vol, double datasetBounds[6], double scalarRange[2], int numberOfScalarComponents, unsigned int numberOfLevels)=0
virtual void RenderBlock(vtkRenderer *ren, vtkVolume *vol, unsigned int level)=0
void SetInputConnection(int port, vtkAlgorithmOutput *input) override
Add/Remove input connections.
static vtkGPUVolumeRayCastMapper * New()
int GetInputCount()
Number of currently active ports.
virtual void ClipCroppingRegionPlanes()
Compute the cropping planes clipped by the bounds of the volume.
int FillInputPortInformation(int port, vtkInformation *info) override
Handle inputs.
vtkDataSet * FindData(int port, DataMap &container)
void SetMaskTypeToBinary()
Set the mask type, if mask is to be used.
void RemovePortInternal(int port)
virtual void PostRender(vtkRenderer *ren, int numberOfScalarComponents)=0
void SetCellFlag(int cellFlag)
Called by the AMR Volume Mapper.
void CanonicalViewRender(vtkRenderer *, vtkVolume *)
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:29
Store vtkAlgorithm input/output information.
create a window for renderers to draw into
abstract specification for renderers
Definition vtkRenderer.h:59
Abstract class for a volume mapper.
represents the common properties for rendering a volume.
represents a volume (data & properties) in a rendered scene
Definition vtkVolume.h:40
window superclass for vtkRenderWindow
Definition vtkWindow.h:25
int vtkTypeBool
Definition vtkABI.h:64
int vtkIdType
Definition vtkType.h:315
#define VTK_SIZEHINT(...)