VTK  9.5.20250619
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#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
32
33VTK_ABI_NAMESPACE_BEGIN
35class vtkRenderWindow;
37
38class VTKRENDERINGVOLUME_EXPORT VTK_MARSHALAUTO vtkGPUVolumeRayCastMapper : public vtkVolumeMapper
39{
40public:
43 void PrintSelf(ostream& os, vtkIndent indent) override;
44
46
52 vtkSetClampMacro(AutoAdjustSampleDistances, vtkTypeBool, 0, 1);
53 vtkGetMacro(AutoAdjustSampleDistances, vtkTypeBool);
54 vtkBooleanMacro(AutoAdjustSampleDistances, vtkTypeBool);
56
57 std::vector<int> GetPorts() { return this->Ports; }
58 void SetPorts(std::vector<int> ports) { this->Ports = ports; }
59
61
66 vtkSetClampMacro(LockSampleDistanceToInputSpacing, vtkTypeBool, 0, 1);
67 vtkGetMacro(LockSampleDistanceToInputSpacing, vtkTypeBool);
68 vtkBooleanMacro(LockSampleDistanceToInputSpacing, vtkTypeBool);
70
72
77 vtkSetClampMacro(UseJittering, vtkTypeBool, 0, 1);
78 vtkGetMacro(UseJittering, vtkTypeBool);
79 vtkBooleanMacro(UseJittering, vtkTypeBool);
81
83
91 vtkSetClampMacro(UseDepthPass, vtkTypeBool, 0, 1);
92 vtkGetMacro(UseDepthPass, vtkTypeBool);
93 vtkBooleanMacro(UseDepthPass, vtkTypeBool);
95
103
105
111 vtkSetMacro(SampleDistance, float);
112 vtkGetMacro(SampleDistance, float);
114
116
123 vtkSetClampMacro(ImageSampleDistance, float, 0.1f, 100.0f);
124 vtkGetMacro(ImageSampleDistance, float);
126
128
132 vtkSetClampMacro(MinimumImageSampleDistance, float, 0.1f, 100.0f);
133 vtkGetMacro(MinimumImageSampleDistance, float);
135
137
141 vtkSetClampMacro(MaximumImageSampleDistance, float, 0.1f, 100.0f);
142 vtkGetMacro(MaximumImageSampleDistance, float);
144
146
159 vtkSetMacro(FinalColorWindow, float);
160 vtkGetMacro(FinalColorWindow, float);
161 vtkSetMacro(FinalColorLevel, float);
162 vtkGetMacro(FinalColorLevel, float);
164
166
171 vtkSetMacro(MaxMemoryInBytes, vtkIdType);
172 vtkGetMacro(MaxMemoryInBytes, vtkIdType);
174
176
181 vtkSetClampMacro(MaxMemoryFraction, float, 0.1f, 1.0f);
182 vtkGetMacro(MaxMemoryFraction, float);
184
186
194 vtkSetMacro(ReportProgress, bool);
195 vtkGetMacro(ReportProgress, bool);
197
204 virtual int IsRenderSupported(
205 vtkRenderWindow* vtkNotUsed(window), vtkVolumeProperty* vtkNotUsed(property))
206 {
207 return 0;
208 }
209
210 void CreateCanonicalView(vtkRenderer* ren, vtkVolume* volume, vtkImageData* image, int blend_mode,
211 double viewDirection[3], double viewUp[3]);
212
214
235 vtkGetObjectMacro(MaskInput, vtkImageData);
237
238 enum
239 {
240 BinaryMaskType = 0,
241 LabelMapMaskType
242 };
243
245
249 vtkSetMacro(MaskType, int);
250 vtkGetMacro(MaskType, int);
254
256
264 vtkSetClampMacro(MaskBlendFactor, float, 0.0f, 1.0f);
265 vtkGetMacro(MaskBlendFactor, float);
267
269
276 vtkSetClampMacro(GlobalIlluminationReach, float, 0.0f, 1.0f);
277 vtkGetMacro(GlobalIlluminationReach, float);
279
281
292 vtkSetClampMacro(VolumetricScatteringBlending, float, 0.0f, 2.0f);
293 vtkGetMacro(VolumetricScatteringBlending, float);
295
297
311 vtkSetMacro(RenderToImage, vtkTypeBool);
312 vtkGetMacro(RenderToImage, vtkTypeBool);
313 vtkBooleanMacro(RenderToImage, vtkTypeBool);
315
317
322 vtkSetMacro(DepthImageScalarType, int);
323 vtkGetMacro(DepthImageScalarType, int);
328
330
341 vtkSetMacro(ClampDepthToBackface, vtkTypeBool);
342 vtkGetMacro(ClampDepthToBackface, vtkTypeBool);
343 vtkBooleanMacro(ClampDepthToBackface, vtkTypeBool);
345
352 virtual void GetDepthImage(vtkImageData*) {}
353
360 virtual void GetColorImage(vtkImageData*) {}
361
366 void Render(vtkRenderer*, vtkVolume*) override;
367
372 virtual void GPURender(vtkRenderer*, vtkVolume*) {}
373
381
394 virtual void GetReductionRatio(double ratio[3]) = 0;
395
397 {
398 SCALAR = 0, // default
399 NATIVE
400 };
401
403
419 vtkSetMacro(ColorRangeType, int);
420 vtkGetMacro(ColorRangeType, int);
421 vtkSetMacro(ScalarOpacityRangeType, int);
422 vtkGetMacro(ScalarOpacityRangeType, int);
423 vtkSetMacro(GradientOpacityRangeType, int);
424 vtkGetMacro(GradientOpacityRangeType, int);
426
427 vtkDataSet* GetInput() override { return this->GetInput(0); }
428
430
434 void RemoveInputConnection(int port, vtkAlgorithmOutput* input) override;
435 void RemoveInputConnection(int port, int idx) override;
436 void SetInputConnection(int port, vtkAlgorithmOutput* input) override;
438 {
439 this->SetInputConnection(0, input);
440 }
442
447
449
450 double* GetBoundsFromPort(int port) VTK_SIZEHINT(6);
451
453
456 vtkSetStringMacro(Transfer2DYAxisArray);
457 vtkGetStringMacro(Transfer2DYAxisArray);
459
460protected:
463
472 int FillInputPortInformation(int port, vtkInformation* info) override;
473
485 void TransformInput(int port);
486
488
499 int ValidateInput(vtkVolumeProperty* property, int port);
501
503
508 void CloneInput(vtkDataSet* input, int port);
510
511 // Special version of render called during the creation
512 // of a canonical view.
514
515 // Methods called by the AMR Volume Mapper.
516 virtual void PreRender(vtkRenderer* ren, vtkVolume* vol, double datasetBounds[6],
517 double scalarRange[2], int numberOfScalarComponents, unsigned int numberOfLevels) = 0;
518
519 // \pre input is up-to-date
520 virtual void RenderBlock(vtkRenderer* ren, vtkVolume* vol, unsigned int level) = 0;
521
522 virtual void PostRender(vtkRenderer* ren, int numberOfScalarComponents) = 0;
523 vtkDataSet* GetInput(int port) override;
524
530 void SetCellFlag(int cellFlag);
531 void RemovePortInternal(int port);
532
538
539 // Render to texture mode flag
541
542 // Depth image scalar type
544
545 // Clamp depth values to the depth of the face at which the ray
546 // exits the volume
548
549 // Enable / disable stochastic jittering
551
552 // Secondary rays ambient/global adjustment coefficient
553 float GlobalIlluminationReach = 0.0;
554
555 float VolumetricScatteringBlending = 0.0;
556
557 // Enable / disable two pass rendering
560
561 // The distance between sample points along the ray
563
567
570
571 // 1 if we are generating the canonical image, 0 otherwise
574
576
580 vtkSetClampMacro(AMRMode, vtkTypeBool, 0, 1);
581 vtkGetMacro(AMRMode, vtkTypeBool);
582 vtkBooleanMacro(AMRMode, vtkTypeBool);
584
588
590
591 // Transfer function range type
595
596 // Point data or cell data (or field data, not handled) ?
598
612
613 using DataMap = std::unordered_map<int, vtkDataSet*>;
615 vtkDataSet* FindData(int port, DataMap& container);
616
617 double ClippedCroppingRegionPlanes[6];
618
621
623 std::vector<int> Ports;
624 std::vector<int> RemovedPorts;
626
632
639
640private:
642 void operator=(const vtkGPUVolumeRayCastMapper&) = delete;
643};
644
645VTK_ABI_NAMESPACE_END
646#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:165
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.
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.
void SetPorts(std::vector< int > ports)
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.
virtual int IsRenderSupported(vtkRenderWindow *window, vtkVolumeProperty *property)
Based on hardware and properties, we may or may not be able to render using 3D texture mapping.
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)
void SetDepthPassContourValues(vtkContourValues *)
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:108
Store vtkAlgorithm input/output information.
create a window for renderers to draw into
abstract specification for renderers
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:130
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
int vtkTypeBool
Definition vtkABI.h:64
int vtkIdType
Definition vtkType.h:332
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO