VTK  9.2.6
vtkGPUVolumeRayCastMapper.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkGPUVolumeRayCastMapper.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
33#ifndef vtkGPUVolumeRayCastMapper_h
34#define vtkGPUVolumeRayCastMapper_h
35#include <unordered_map> // For std::unordered_map
36#include <vector> // For std::vector
37
38#include "vtkRenderingVolumeModule.h" // For export macro
39#include "vtkVolumeMapper.h"
40
42class vtkRenderWindow;
44
45class VTKRENDERINGVOLUME_EXPORT vtkGPUVolumeRayCastMapper : public vtkVolumeMapper
46{
47public:
50 void PrintSelf(ostream& os, vtkIndent indent) override;
51
53
59 vtkSetClampMacro(AutoAdjustSampleDistances, vtkTypeBool, 0, 1);
60 vtkGetMacro(AutoAdjustSampleDistances, vtkTypeBool);
61 vtkBooleanMacro(AutoAdjustSampleDistances, vtkTypeBool);
63
65
70 vtkSetClampMacro(LockSampleDistanceToInputSpacing, vtkTypeBool, 0, 1);
71 vtkGetMacro(LockSampleDistanceToInputSpacing, vtkTypeBool);
72 vtkBooleanMacro(LockSampleDistanceToInputSpacing, vtkTypeBool);
74
76
81 vtkSetClampMacro(UseJittering, vtkTypeBool, 0, 1);
82 vtkGetMacro(UseJittering, vtkTypeBool);
83 vtkBooleanMacro(UseJittering, vtkTypeBool);
85
87
95 vtkSetClampMacro(UseDepthPass, vtkTypeBool, 0, 1);
96 vtkGetMacro(UseDepthPass, vtkTypeBool);
97 vtkBooleanMacro(UseDepthPass, vtkTypeBool);
99
106
108
114 vtkSetMacro(SampleDistance, float);
115 vtkGetMacro(SampleDistance, float);
117
119
126 vtkSetClampMacro(ImageSampleDistance, float, 0.1f, 100.0f);
127 vtkGetMacro(ImageSampleDistance, float);
129
131
135 vtkSetClampMacro(MinimumImageSampleDistance, float, 0.1f, 100.0f);
136 vtkGetMacro(MinimumImageSampleDistance, float);
138
140
144 vtkSetClampMacro(MaximumImageSampleDistance, float, 0.1f, 100.0f);
145 vtkGetMacro(MaximumImageSampleDistance, float);
147
149
162 vtkSetMacro(FinalColorWindow, float);
163 vtkGetMacro(FinalColorWindow, float);
164 vtkSetMacro(FinalColorLevel, float);
165 vtkGetMacro(FinalColorLevel, float);
167
169
174 vtkSetMacro(MaxMemoryInBytes, vtkIdType);
175 vtkGetMacro(MaxMemoryInBytes, vtkIdType);
177
179
184 vtkSetClampMacro(MaxMemoryFraction, float, 0.1f, 1.0f);
185 vtkGetMacro(MaxMemoryFraction, float);
187
189
197 vtkSetMacro(ReportProgress, bool);
198 vtkGetMacro(ReportProgress, bool);
200
207 virtual int IsRenderSupported(
208 vtkRenderWindow* vtkNotUsed(window), vtkVolumeProperty* vtkNotUsed(property))
209 {
210 return 0;
211 }
212
213 void CreateCanonicalView(vtkRenderer* ren, vtkVolume* volume, vtkImageData* image, int blend_mode,
214 double viewDirection[3], double viewUp[3]);
215
217
238 vtkGetObjectMacro(MaskInput, vtkImageData);
240
241 enum
242 {
243 BinaryMaskType = 0,
244 LabelMapMaskType
245 };
246
248
252 vtkSetMacro(MaskType, int);
253 vtkGetMacro(MaskType, int);
257
259
267 vtkSetClampMacro(MaskBlendFactor, float, 0.0f, 1.0f);
268 vtkGetMacro(MaskBlendFactor, float);
270
272
279 vtkSetClampMacro(GlobalIlluminationReach, float, 0.0f, 1.0f);
280 vtkGetMacro(GlobalIlluminationReach, float);
282
284
295 vtkSetClampMacro(VolumetricScatteringBlending, float, 0.0f, 2.0f);
296 vtkGetMacro(VolumetricScatteringBlending, float);
298
300
314 vtkSetMacro(RenderToImage, vtkTypeBool);
315 vtkGetMacro(RenderToImage, vtkTypeBool);
316 vtkBooleanMacro(RenderToImage, vtkTypeBool);
318
320
325 vtkSetMacro(DepthImageScalarType, int);
326 vtkGetMacro(DepthImageScalarType, int);
331
333
344 vtkSetMacro(ClampDepthToBackface, vtkTypeBool);
345 vtkGetMacro(ClampDepthToBackface, vtkTypeBool);
346 vtkBooleanMacro(ClampDepthToBackface, vtkTypeBool);
348
355 virtual void GetDepthImage(vtkImageData*) {}
356
363 virtual void GetColorImage(vtkImageData*) {}
364
369 void Render(vtkRenderer*, vtkVolume*) override;
370
375 virtual void GPURender(vtkRenderer*, vtkVolume*) {}
376
384
397 virtual void GetReductionRatio(double ratio[3]) = 0;
398
400 {
401 SCALAR = 0, // default
402 NATIVE
403 };
404
406
422 vtkSetMacro(ColorRangeType, int);
423 vtkGetMacro(ColorRangeType, int);
424 vtkSetMacro(ScalarOpacityRangeType, int);
425 vtkGetMacro(ScalarOpacityRangeType, int);
426 vtkSetMacro(GradientOpacityRangeType, int);
427 vtkGetMacro(GradientOpacityRangeType, int);
429
430 vtkDataSet* GetInput() override { return this->GetInput(0); };
431
433
437 void RemoveInputConnection(int port, vtkAlgorithmOutput* input) override;
438 void RemoveInputConnection(int port, int idx) override;
439 void SetInputConnection(int port, vtkAlgorithmOutput* input) override;
441 {
442 this->SetInputConnection(0, input);
443 }
445
450
451 vtkDataSet* GetTransformedInput(const int port = 0);
452
453 double* GetBoundsFromPort(const int port) VTK_SIZEHINT(6);
454
456
459 vtkSetStringMacro(Transfer2DYAxisArray);
460 vtkGetStringMacro(Transfer2DYAxisArray);
462
463protected:
466
475 int FillInputPortInformation(int port, vtkInformation* info) override;
476
488 void TransformInput(const int port);
489
491
502 int ValidateInput(vtkVolumeProperty* property, const int port);
504
506
511 void CloneInput(vtkDataSet* input, const int port);
513
514 // Special version of render called during the creation
515 // of a canonical view.
517
518 // Methods called by the AMR Volume Mapper.
519 virtual void PreRender(vtkRenderer* ren, vtkVolume* vol, double datasetBounds[6],
520 double scalarRange[2], int numberOfScalarComponents, unsigned int numberOfLevels) = 0;
521
522 // \pre input is up-to-date
523 virtual void RenderBlock(vtkRenderer* ren, vtkVolume* vol, unsigned int level) = 0;
524
525 virtual void PostRender(vtkRenderer* ren, int numberOfScalarComponents) = 0;
526 vtkDataSet* GetInput(const int port) override;
527
533 void SetCellFlag(int cellFlag);
534 void RemovePortInternal(const int port);
535
541
542 // Render to texture mode flag
544
545 // Depth image scalar type
547
548 // Clamp depth values to the depth of the face at which the ray
549 // exits the volume
551
552 // Enable / disable stochastic jittering
554
555 // Secondary rays ambient/global adjustment coefficient
556 float GlobalIlluminationReach = 0.0;
557
558 float VolumetricScatteringBlending = 0.0;
559
560 // Enable / disable two pass rendering
563
564 // The distance between sample points along the ray
566
570
573
574 // 1 if we are generating the canonical image, 0 otherwise
577
579
583 vtkSetClampMacro(AMRMode, vtkTypeBool, 0, 1);
584 vtkGetMacro(AMRMode, vtkTypeBool);
585 vtkBooleanMacro(AMRMode, vtkTypeBool);
587
591
593
594 // Transfer function range type
598
599 // Point data or cell data (or field data, not handled) ?
601
615
616 using DataMap = std::unordered_map<int, vtkDataSet*>;
618 vtkDataSet* FindData(int port, DataMap& container);
619
620 double ClippedCroppingRegionPlanes[6];
621
624
626 std::vector<int> Ports;
627 std::vector<int> RemovedPorts;
629
635
642
643private:
645 void operator=(const vtkGPUVolumeRayCastMapper&) = delete;
646};
647
648#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
Ray casting performed on the GPU.
virtual void GetDepthImage(vtkImageData *)
Low level API to export the depth texture as vtkImageData in RenderToImage mode.
vtkDataSet * GetTransformedInput(const int port=0)
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.
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.
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.
void RemovePortInternal(const int port)
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
int ValidateInput(vtkVolumeProperty *property, const int port)
This method is used by the Render() method to validate everything before attempting to render.
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
void Render(vtkRenderer *, vtkVolume *) override
Initialize rendering for this volume.
double * GetBoundsFromPort(const int port)
void TransformInput(const int port)
A transformation is applied (translation) to the input.
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
vtkDataSet * GetInput(const int port) override
Set/Get the input data.
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 CloneInput(vtkDataSet *input, const int port)
Shallow-copy the inputs into a transform-adjusted clone.
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:34
Store vtkAlgorithm input/output information.
create a window for renderers to draw into
abstract specification for renderers
Definition vtkRenderer.h:67
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:45
window superclass for vtkRenderWindow
Definition vtkWindow.h:39
int vtkTypeBool
Definition vtkABI.h:69
int vtkIdType
Definition vtkType.h:332
#define VTK_SIZEHINT(...)