VTK  9.1.0
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=========================================================================*/
36#ifndef vtkGPUVolumeRayCastMapper_h
37#define vtkGPUVolumeRayCastMapper_h
38#include <unordered_map> // For std::unordered_map
39#include <vector> // For std::vector
40
41#include "vtkRenderingVolumeModule.h" // For export macro
42#include "vtkVolumeMapper.h"
43
45class vtkRenderWindow;
47
48class VTKRENDERINGVOLUME_EXPORT vtkGPUVolumeRayCastMapper : public vtkVolumeMapper
49{
50public:
53 void PrintSelf(ostream& os, vtkIndent indent) override;
54
56
62 vtkSetClampMacro(AutoAdjustSampleDistances, vtkTypeBool, 0, 1);
63 vtkGetMacro(AutoAdjustSampleDistances, vtkTypeBool);
64 vtkBooleanMacro(AutoAdjustSampleDistances, vtkTypeBool);
66
68
73 vtkSetClampMacro(LockSampleDistanceToInputSpacing, vtkTypeBool, 0, 1);
74 vtkGetMacro(LockSampleDistanceToInputSpacing, vtkTypeBool);
75 vtkBooleanMacro(LockSampleDistanceToInputSpacing, vtkTypeBool);
77
79
84 vtkSetClampMacro(UseJittering, vtkTypeBool, 0, 1);
85 vtkGetMacro(UseJittering, vtkTypeBool);
86 vtkBooleanMacro(UseJittering, vtkTypeBool);
88
90
98 vtkSetClampMacro(UseDepthPass, vtkTypeBool, 0, 1);
99 vtkGetMacro(UseDepthPass, vtkTypeBool);
100 vtkBooleanMacro(UseDepthPass, vtkTypeBool);
102
109
111
117 vtkSetMacro(SampleDistance, float);
118 vtkGetMacro(SampleDistance, float);
120
122
129 vtkSetClampMacro(ImageSampleDistance, float, 0.1f, 100.0f);
130 vtkGetMacro(ImageSampleDistance, float);
132
134
138 vtkSetClampMacro(MinimumImageSampleDistance, float, 0.1f, 100.0f);
139 vtkGetMacro(MinimumImageSampleDistance, float);
141
143
147 vtkSetClampMacro(MaximumImageSampleDistance, float, 0.1f, 100.0f);
148 vtkGetMacro(MaximumImageSampleDistance, float);
150
152
165 vtkSetMacro(FinalColorWindow, float);
166 vtkGetMacro(FinalColorWindow, float);
167 vtkSetMacro(FinalColorLevel, float);
168 vtkGetMacro(FinalColorLevel, float);
170
172
177 vtkSetMacro(MaxMemoryInBytes, vtkIdType);
178 vtkGetMacro(MaxMemoryInBytes, vtkIdType);
180
182
187 vtkSetClampMacro(MaxMemoryFraction, float, 0.1f, 1.0f);
188 vtkGetMacro(MaxMemoryFraction, float);
190
192
200 vtkSetMacro(ReportProgress, bool);
201 vtkGetMacro(ReportProgress, bool);
203
210 virtual int IsRenderSupported(
211 vtkRenderWindow* vtkNotUsed(window), vtkVolumeProperty* vtkNotUsed(property))
212 {
213 return 0;
214 }
215
216 void CreateCanonicalView(vtkRenderer* ren, vtkVolume* volume, vtkImageData* image, int blend_mode,
217 double viewDirection[3], double viewUp[3]);
218
220
241 vtkGetObjectMacro(MaskInput, vtkImageData);
243
244 enum
245 {
246 BinaryMaskType = 0,
247 LabelMapMaskType
248 };
249
251
255 vtkSetMacro(MaskType, int);
256 vtkGetMacro(MaskType, int);
260
262
270 vtkSetClampMacro(MaskBlendFactor, float, 0.0f, 1.0f);
271 vtkGetMacro(MaskBlendFactor, float);
273
275
289 vtkSetMacro(RenderToImage, vtkTypeBool);
290 vtkGetMacro(RenderToImage, vtkTypeBool);
291 vtkBooleanMacro(RenderToImage, vtkTypeBool);
293
295
300 vtkSetMacro(DepthImageScalarType, int);
301 vtkGetMacro(DepthImageScalarType, int);
306
308
319 vtkSetMacro(ClampDepthToBackface, vtkTypeBool);
320 vtkGetMacro(ClampDepthToBackface, vtkTypeBool);
321 vtkBooleanMacro(ClampDepthToBackface, vtkTypeBool);
323
330 virtual void GetDepthImage(vtkImageData*) {}
331
338 virtual void GetColorImage(vtkImageData*) {}
339
344 void Render(vtkRenderer*, vtkVolume*) override;
345
350 virtual void GPURender(vtkRenderer*, vtkVolume*) {}
351
359
372 virtual void GetReductionRatio(double ratio[3]) = 0;
373
375 {
376 SCALAR = 0, // default
377 NATIVE
378 };
379
381
397 vtkSetMacro(ColorRangeType, int);
398 vtkGetMacro(ColorRangeType, int);
399 vtkSetMacro(ScalarOpacityRangeType, int);
400 vtkGetMacro(ScalarOpacityRangeType, int);
401 vtkSetMacro(GradientOpacityRangeType, int);
402 vtkGetMacro(GradientOpacityRangeType, int);
404
405 vtkDataSet* GetInput() override { return this->GetInput(0); };
406
408
412 void RemoveInputConnection(int port, vtkAlgorithmOutput* input) override;
413 void RemoveInputConnection(int port, int idx) override;
414 void SetInputConnection(int port, vtkAlgorithmOutput* input) override;
416 {
417 this->SetInputConnection(0, input);
418 }
420
425
426 vtkDataSet* GetTransformedInput(const int port = 0);
427
428 double* GetBoundsFromPort(const int port) VTK_SIZEHINT(6);
429
431
434 vtkSetStringMacro(Transfer2DYAxisArray);
435 vtkGetStringMacro(Transfer2DYAxisArray);
437
438protected:
441
450 int FillInputPortInformation(int port, vtkInformation* info) override;
451
463 void TransformInput(const int port);
464
466
477 int ValidateInput(vtkVolumeProperty* property, const int port);
479
481
486 void CloneInput(vtkDataSet* input, const int port);
488
489 // Special version of render called during the creation
490 // of a canonical view.
492
493 // Methods called by the AMR Volume Mapper.
494 virtual void PreRender(vtkRenderer* ren, vtkVolume* vol, double datasetBounds[6],
495 double scalarRange[2], int numberOfScalarComponents, unsigned int numberOfLevels) = 0;
496
497 // \pre input is up-to-date
498 virtual void RenderBlock(vtkRenderer* ren, vtkVolume* vol, unsigned int level) = 0;
499
500 virtual void PostRender(vtkRenderer* ren, int numberOfScalarComponents) = 0;
501 vtkDataSet* GetInput(const int port) override;
502
508 void SetCellFlag(int cellFlag);
509 void RemovePortInternal(const int port);
510
516
517 // Render to texture mode flag
519
520 // Depth image scalar type
522
523 // Clamp depth values to the depth of the face at which the ray
524 // exits the volume
526
527 // Enable / disable stochastic jittering
529
530 // Enable / disable two pass rendering
533
534 // The distance between sample points along the ray
536
540
543
544 // 1 if we are generating the canonical image, 0 otherwise
547
549
553 vtkSetClampMacro(AMRMode, vtkTypeBool, 0, 1);
554 vtkGetMacro(AMRMode, vtkTypeBool);
555 vtkBooleanMacro(AMRMode, vtkTypeBool);
557
561
563
564 // Transfer function range type
568
569 // Point data or cell data (or field data, not handled) ?
571
585
586 using DataMap = std::unordered_map<int, vtkDataSet*>;
588 vtkDataSet* FindData(int port, DataMap& container);
589
590 double ClippedCroppingRegionPlanes[6];
591
594
596 std::vector<int> Ports;
597 std::vector<int> RemovedPorts;
599
605
612
613private:
615 void operator=(const vtkGPUVolumeRayCastMapper&) = delete;
616};
617
618#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:166
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
Definition: vtkImageData.h:157
a simple class to control print indentation
Definition: vtkIndent.h:113
Store vtkAlgorithm input/output information.
create a window for renderers to draw into
abstract specification for renderers
Definition: vtkRenderer.h:182
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:144
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:332
#define VTK_SIZEHINT(...)