VTK  9.6.2
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#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
29
30VTK_ABI_NAMESPACE_BEGIN
32class vtkRenderWindow;
34
35class VTKRENDERINGVOLUME_EXPORT VTK_MARSHALAUTO vtkGPUVolumeRayCastMapper : public vtkVolumeMapper
36{
37public:
40 void PrintSelf(ostream& os, vtkIndent indent) override;
41
43
49 vtkSetClampMacro(AutoAdjustSampleDistances, vtkTypeBool, 0, 1);
53
54 std::vector<int> GetPorts() { return this->Ports; }
55 void SetPorts(std::vector<int> ports) { this->Ports = ports; }
56
58
67
69
74 vtkSetClampMacro(UseJittering, vtkTypeBool, 0, 1);
76 vtkBooleanMacro(UseJittering, vtkTypeBool);
78
80
88 vtkSetClampMacro(UseDepthPass, vtkTypeBool, 0, 1);
90 vtkBooleanMacro(UseDepthPass, vtkTypeBool);
92
100
102
108 vtkSetMacro(SampleDistance, float);
109 vtkGetMacro(SampleDistance, float);
111
113
120 vtkSetClampMacro(ImageSampleDistance, float, 0.1f, 100.0f);
121 vtkGetMacro(ImageSampleDistance, float);
123
125
129 vtkSetClampMacro(MinimumImageSampleDistance, float, 0.1f, 100.0f);
130 vtkGetMacro(MinimumImageSampleDistance, float);
132
134
138 vtkSetClampMacro(MaximumImageSampleDistance, float, 0.1f, 100.0f);
139 vtkGetMacro(MaximumImageSampleDistance, float);
141
143
156 vtkSetMacro(FinalColorWindow, float);
157 vtkGetMacro(FinalColorWindow, float);
158 vtkSetMacro(FinalColorLevel, float);
159 vtkGetMacro(FinalColorLevel, float);
161
163
171
173
178 vtkSetClampMacro(MaxMemoryFraction, float, 0.1f, 1.0f);
179 vtkGetMacro(MaxMemoryFraction, float);
181
183
191 vtkSetMacro(ReportProgress, bool);
192 vtkGetMacro(ReportProgress, bool);
194
201 virtual int IsRenderSupported(
202 vtkRenderWindow* vtkNotUsed(window), vtkVolumeProperty* vtkNotUsed(property))
203 {
204 return 0;
205 }
206
207 void CreateCanonicalView(vtkRenderer* ren, vtkVolume* volume, vtkImageData* image, int blend_mode,
208 double viewDirection[3], double viewUp[3]);
209
211
232 vtkGetObjectMacro(MaskInput, vtkImageData);
234
235 enum
236 {
239 };
240
242
246 vtkSetMacro(MaskType, int);
247 vtkGetMacro(MaskType, int);
251
253
261 vtkSetClampMacro(MaskBlendFactor, float, 0.0f, 1.0f);
262 vtkGetMacro(MaskBlendFactor, float);
264
266
273 vtkSetClampMacro(GlobalIlluminationReach, float, 0.0f, 1.0f);
274 vtkGetMacro(GlobalIlluminationReach, float);
276
278
289 vtkSetClampMacro(VolumetricScatteringBlending, float, 0.0f, 2.0f);
290 vtkGetMacro(VolumetricScatteringBlending, float);
292
294
310 vtkBooleanMacro(RenderToImage, vtkTypeBool);
312
314
319 vtkSetMacro(DepthImageScalarType, int);
320 vtkGetMacro(DepthImageScalarType, int);
325
327
342
349 virtual void GetDepthImage(vtkImageData*) {}
350
357 virtual void GetColorImage(vtkImageData*) {}
358
363 void Render(vtkRenderer*, vtkVolume*) override;
364
369 virtual void GPURender(vtkRenderer*, vtkVolume*) {}
370
378
391 virtual void GetReductionRatio(double ratio[3]) = 0;
392
394 {
395 SCALAR = 0, // default
397 };
398
400
416 vtkSetMacro(ColorRangeType, int);
417 vtkGetMacro(ColorRangeType, int);
418 vtkSetMacro(ScalarOpacityRangeType, int);
419 vtkGetMacro(ScalarOpacityRangeType, int);
420 vtkSetMacro(GradientOpacityRangeType, int);
421 vtkGetMacro(GradientOpacityRangeType, int);
423
424 vtkDataSet* GetInput() override { return this->GetInput(0); }
425
427
431 void RemoveInputConnection(int port, vtkAlgorithmOutput* input) override;
432 void RemoveInputConnection(int port, int idx) override;
433 void SetInputConnection(int port, vtkAlgorithmOutput* input) override;
435 {
436 this->SetInputConnection(0, input);
437 }
438
439
444
446
447 double* GetBoundsFromPort(int port) VTK_SIZEHINT(6);
448
450
453 vtkSetStringMacro(Transfer2DYAxisArray);
454 vtkGetStringMacro(Transfer2DYAxisArray);
456
457protected:
460
469 int FillInputPortInformation(int port, vtkInformation* info) override;
470
482 void TransformInput(int port);
483
485
496 int ValidateInput(vtkVolumeProperty* property, int port);
498
500
505 void CloneInput(vtkDataSet* input, int port);
507
508 // Special version of render called during the creation
509 // of a canonical view.
511
512 // Methods called by the AMR Volume Mapper.
513 virtual void PreRender(vtkRenderer* ren, vtkVolume* vol, double datasetBounds[6],
514 double scalarRange[2], int numberOfScalarComponents, unsigned int numberOfLevels) = 0;
515
516 // \pre input is up-to-date
517 virtual void RenderBlock(vtkRenderer* ren, vtkVolume* vol, unsigned int level) = 0;
518
519 virtual void PostRender(vtkRenderer* ren, int numberOfScalarComponents) = 0;
520 vtkDataSet* GetInput(int port) override;
521
527 void SetCellFlag(int cellFlag);
528 void RemovePortInternal(int port);
529
535
536 // Render to texture mode flag
538
539 // Depth image scalar type
541
542 // Clamp depth values to the depth of the face at which the ray
543 // exits the volume
545
546 // Enable / disable stochastic jittering
548
549 // Secondary rays ambient/global adjustment coefficient
551
553
554 // Enable / disable two pass rendering
557
558 // The distance between sample points along the ray
560
564
567
568 // 1 if we are generating the canonical image, 0 otherwise
571
573
577 vtkSetClampMacro(AMRMode, vtkTypeBool, 0, 1);
578 vtkGetMacro(AMRMode, vtkTypeBool);
579 vtkBooleanMacro(AMRMode, vtkTypeBool);
581
585
587
588 // Transfer function range type
592
593 // Point data or cell data (or field data, not handled) ?
595
609
610 using DataMap = std::unordered_map<int, vtkDataSet*>;
612 vtkDataSet* FindData(int port, DataMap& container);
613
615
618
620 std::vector<int> Ports;
621 std::vector<int> RemovedPorts;
623
629
636
637private:
639 void operator=(const vtkGPUVolumeRayCastMapper&) = delete;
640};
641
642VTK_ABI_NAMESPACE_END
643#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:57
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:29
Store vtkAlgorithm input/output information.
create a window for renderers to draw into
abstract specification for renderers
Definition vtkRenderer.h:61
represents the common properties for rendering a volume.
represents a volume (data & properties) in a rendered scene
Definition vtkVolume.h:41
window superclass for vtkRenderWindow
Definition vtkWindow.h:26
int vtkTypeBool
Definition vtkABI.h:64
int vtkIdType
Definition vtkType.h:368
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO