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 
44 class vtkContourValues;
45 class vtkRenderWindow;
46 class vtkVolumeProperty;
47 
48 class VTKRENDERINGVOLUME_EXPORT vtkGPUVolumeRayCastMapper : public vtkVolumeMapper
49 {
50 public:
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 
427 
428  double* GetBoundsFromPort(const int port) VTK_SIZEHINT(6);
429 
431 
434  vtkSetStringMacro(Transfer2DYAxisArray);
435  vtkGetStringMacro(Transfer2DYAxisArray);
437 
438 protected:
441 
451 
463  void TransformInput(const int port);
464 
466 
477  int ValidateInput(vtkVolumeProperty* property, const int port);
479 
481 
485  void CloneInputs();
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 
560  int MaskType;
561 
563 
564  // Transfer function range type
568 
569  // Point data or cell data (or field data, not handled) ?
570  int CellFlag;
571 
584  virtual void ClipCroppingRegionPlanes();
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 
613 private:
615  void operator=(const vtkGPUVolumeRayCastMapper&) = delete;
616 };
617 
618 #endif
vtkGPUVolumeRayCastMapper::New
static vtkGPUVolumeRayCastMapper * New()
vtkGPUVolumeRayCastMapper::LockSampleDistanceToInputSpacing
vtkTypeBool LockSampleDistanceToInputSpacing
Definition: vtkGPUVolumeRayCastMapper.h:511
vtkGPUVolumeRayCastMapper::GeneratingCanonicalView
int GeneratingCanonicalView
Definition: vtkGPUVolumeRayCastMapper.h:545
vtkVolumeMapper
Abstract class for a volume mapper.
Definition: vtkVolumeMapper.h:45
vtkGPUVolumeRayCastMapper::GetDepthImage
virtual void GetDepthImage(vtkImageData *)
Low level API to export the depth texture as vtkImageData in RenderToImage mode.
Definition: vtkGPUVolumeRayCastMapper.h:330
vtkGPUVolumeRayCastMapper::SetTransformedInput
void SetTransformedInput(vtkDataSet *)
vtkGPUVolumeRayCastMapper::PreRender
virtual void PreRender(vtkRenderer *ren, vtkVolume *vol, double datasetBounds[6], double scalarRange[2], int numberOfScalarComponents, unsigned int numberOfLevels)=0
vtkGPUVolumeRayCastMapper::GetInput
vtkDataSet * GetInput(const int port) override
Set/Get the input data.
vtkGPUVolumeRayCastMapper::GetInput
vtkDataSet * GetInput() override
Set/Get the input data.
Definition: vtkGPUVolumeRayCastMapper.h:405
vtkGPUVolumeRayCastMapper::SetMaskInput
void SetMaskInput(vtkImageData *mask)
Optionally, set a mask input.
vtkGPUVolumeRayCastMapper::SetMaskTypeToBinary
void SetMaskTypeToBinary()
Set the mask type, if mask is to be used.
vtkVolume
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:134
vtkGPUVolumeRayCastMapper::BigTimeToDraw
double BigTimeToDraw
Definition: vtkGPUVolumeRayCastMapper.h:538
vtkGPUVolumeRayCastMapper::GradientOpacityRangeType
int GradientOpacityRangeType
Definition: vtkGPUVolumeRayCastMapper.h:567
vtkGPUVolumeRayCastMapper::DepthImageScalarType
int DepthImageScalarType
Definition: vtkGPUVolumeRayCastMapper.h:521
vtkGPUVolumeRayCastMapper::AutoAdjustSampleDistances
vtkTypeBool AutoAdjustSampleDistances
Definition: vtkGPUVolumeRayCastMapper.h:512
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkGPUVolumeRayCastMapper::MaxMemoryFraction
float MaxMemoryFraction
Definition: vtkGPUVolumeRayCastMapper.h:593
vtkGPUVolumeRayCastMapper::FindData
vtkDataSet * FindData(int port, DataMap &container)
vtkGPUVolumeRayCastMapper::SetCellFlag
void SetCellFlag(int cellFlag)
Called by the AMR Volume Mapper.
vtkX3D::image
@ image
Definition: vtkX3D.h:380
vtkGPUVolumeRayCastMapper::SetDepthImageScalarTypeToUnsignedChar
void SetDepthImageScalarTypeToUnsignedChar()
Set/Get the scalar type of the depth texture in RenderToImage mode.
vtkGPUVolumeRayCastMapper::ValidateRender
int ValidateRender(vtkRenderer *, vtkVolume *)
This method is used by the Render() method to validate everything before attempting to render.
vtkGPUVolumeRayCastMapper::DataMap
std::unordered_map< int, vtkDataSet * > DataMap
Definition: vtkGPUVolumeRayCastMapper.h:586
vtkGPUVolumeRayCastMapper::CloneInput
void CloneInput(vtkDataSet *input, const int port)
Shallow-copy the inputs into a transform-adjusted clone.
vtkGPUVolumeRayCastMapper::RenderBlock
virtual void RenderBlock(vtkRenderer *ren, vtkVolume *vol, unsigned int level)=0
vtkGPUVolumeRayCastMapper::FinalColorLevel
float FinalColorLevel
Definition: vtkGPUVolumeRayCastMapper.h:542
vtkGPUVolumeRayCastMapper::UseJittering
vtkTypeBool UseJittering
Definition: vtkGPUVolumeRayCastMapper.h:528
vtkGPUVolumeRayCastMapper::SampleDistance
float SampleDistance
Definition: vtkGPUVolumeRayCastMapper.h:535
vtkGPUVolumeRayCastMapper::GetBoundsFromPort
double * GetBoundsFromPort(const int port)
vtkGPUVolumeRayCastMapper::PostRender
virtual void PostRender(vtkRenderer *ren, int numberOfScalarComponents)=0
vtkGPUVolumeRayCastMapper::MaximumImageSampleDistance
float MaximumImageSampleDistance
Definition: vtkGPUVolumeRayCastMapper.h:515
vtkGPUVolumeRayCastMapper::ScalarOpacityRangeType
int ScalarOpacityRangeType
Definition: vtkGPUVolumeRayCastMapper.h:566
vtkGPUVolumeRayCastMapper::ClampDepthToBackface
vtkTypeBool ClampDepthToBackface
Definition: vtkGPUVolumeRayCastMapper.h:525
vtkGPUVolumeRayCastMapper::vtkGPUVolumeRayCastMapper
vtkGPUVolumeRayCastMapper()
vtkGPUVolumeRayCastMapper::FinalColorWindow
float FinalColorWindow
Definition: vtkGPUVolumeRayCastMapper.h:541
vtkGPUVolumeRayCastMapper::MinimumImageSampleDistance
float MinimumImageSampleDistance
Definition: vtkGPUVolumeRayCastMapper.h:514
vtkGPUVolumeRayCastMapper::CanonicalViewImageData
vtkImageData * CanonicalViewImageData
Definition: vtkGPUVolumeRayCastMapper.h:546
vtkGPUVolumeRayCastMapper::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition: vtkGPUVolumeRayCastMapper.h:358
vtkGPUVolumeRayCastMapper::CellFlag
int CellFlag
Definition: vtkGPUVolumeRayCastMapper.h:570
vtkGPUVolumeRayCastMapper::MaskBlendFactor
float MaskBlendFactor
Definition: vtkGPUVolumeRayCastMapper.h:559
vtkGPUVolumeRayCastMapper::SetDepthImageScalarTypeToFloat
void SetDepthImageScalarTypeToFloat()
Set/Get the scalar type of the depth texture in RenderToImage mode.
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
vtkGPUVolumeRayCastMapper::AMRMode
vtkTypeBool AMRMode
Definition: vtkGPUVolumeRayCastMapper.h:562
vtkGPUVolumeRayCastMapper::ValidateInputs
int ValidateInputs()
This method is used by the Render() method to validate everything before attempting to render.
vtkGPUVolumeRayCastMapper::Render
void Render(vtkRenderer *, vtkVolume *) override
Initialize rendering for this volume.
vtkGPUVolumeRayCastMapper::ClipCroppingRegionPlanes
virtual void ClipCroppingRegionPlanes()
Compute the cropping planes clipped by the bounds of the volume.
vtkGPUVolumeRayCastMapper::GetInputCount
int GetInputCount()
Number of currently active ports.
vtkX3D::level
@ level
Definition: vtkX3D.h:401
vtkX3D::port
@ port
Definition: vtkX3D.h:453
vtkGPUVolumeRayCastMapper::LastInputs
DataMap LastInputs
This is needed only to check if the input data has been changed since the last Render() call.
Definition: vtkGPUVolumeRayCastMapper.h:604
vtkGPUVolumeRayCastMapper::ValidateInput
int ValidateInput(vtkVolumeProperty *property, const int port)
This method is used by the Render() method to validate everything before attempting to render.
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:48
vtkGPUVolumeRayCastMapper::RenderToImage
vtkTypeBool RenderToImage
Definition: vtkGPUVolumeRayCastMapper.h:518
vtkGPUVolumeRayCastMapper::SetInputConnection
void SetInputConnection(int port, vtkAlgorithmOutput *input) override
Add/Remove input connections.
vtkContourValues
helper object to manage setting and generating contour values
Definition: vtkContourValues.h:55
vtkGPUVolumeRayCastMapper::TransformedInputs
DataMap TransformedInputs
Definition: vtkGPUVolumeRayCastMapper.h:598
vtkVolumeMapper.h
vtkGPUVolumeRayCastMapper::TFRangeType
TFRangeType
Definition: vtkGPUVolumeRayCastMapper.h:375
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:157
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkGPUVolumeRayCastMapper::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkGPUVolumeRayCastMapper::RemovedPorts
std::vector< int > RemovedPorts
Definition: vtkGPUVolumeRayCastMapper.h:597
vtkGPUVolumeRayCastMapper
Ray casting performed on the GPU.
Definition: vtkGPUVolumeRayCastMapper.h:49
vtkGPUVolumeRayCastMapper::SetDepthImageScalarTypeToUnsignedShort
void SetDepthImageScalarTypeToUnsignedShort()
Set/Get the scalar type of the depth texture in RenderToImage mode.
vtkGPUVolumeRayCastMapper::ImageSampleDistance
float ImageSampleDistance
Definition: vtkGPUVolumeRayCastMapper.h:513
vtkGPUVolumeRayCastMapper::GetColorImage
virtual void GetColorImage(vtkImageData *)
Low level API to export the color texture as vtkImageData in RenderToImage mode.
Definition: vtkGPUVolumeRayCastMapper.h:338
vtkGPUVolumeRayCastMapper::SetInputConnection
void SetInputConnection(vtkAlgorithmOutput *input) override
Add/Remove input connections.
Definition: vtkGPUVolumeRayCastMapper.h:415
vtkGPUVolumeRayCastMapper::IsRenderSupported
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.
Definition: vtkGPUVolumeRayCastMapper.h:210
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
vtkGPUVolumeRayCastMapper::CreateCanonicalView
void CreateCanonicalView(vtkRenderer *ren, vtkVolume *volume, vtkImageData *image, int blend_mode, double viewDirection[3], double viewUp[3])
vtkAlgorithm::SetInputConnection
virtual void SetInputConnection(int port, vtkAlgorithmOutput *input)
Set the connection for the given input port index.
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:183
vtkX3D::info
@ info
Definition: vtkX3D.h:382
vtkGPUVolumeRayCastMapper::CanonicalViewRender
void CanonicalViewRender(vtkRenderer *, vtkVolume *)
vtkGPUVolumeRayCastMapper::MaskType
int MaskType
Definition: vtkGPUVolumeRayCastMapper.h:560
vtkGPUVolumeRayCastMapper::RemoveInputConnection
void RemoveInputConnection(int port, int idx) override
Add/Remove input connections.
vtkGPUVolumeRayCastMapper::RemovePortInternal
void RemovePortInternal(const int port)
vtkGPUVolumeRayCastMapper::SmallVolumeRender
int SmallVolumeRender
Definition: vtkGPUVolumeRayCastMapper.h:537
vtkGPUVolumeRayCastMapper::~vtkGPUVolumeRayCastMapper
~vtkGPUVolumeRayCastMapper() override
vtkAlgorithmOutput
Proxy object to connect input/output ports.
Definition: vtkAlgorithmOutput.h:66
vtkGPUVolumeRayCastMapper::UseDepthPass
vtkTypeBool UseDepthPass
Definition: vtkGPUVolumeRayCastMapper.h:531
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:182
vtkGPUVolumeRayCastMapper::GPURender
virtual void GPURender(vtkRenderer *, vtkVolume *)
Handled in the subclass - the actual render method.
Definition: vtkGPUVolumeRayCastMapper.h:350
vtkGPUVolumeRayCastMapper::SetMaskTypeToLabelMap
void SetMaskTypeToLabelMap()
Set the mask type, if mask is to be used.
vtkGPUVolumeRayCastMapper::Transfer2DYAxisArray
char * Transfer2DYAxisArray
Define the array used for the Y axis of transfer 2D.
Definition: vtkGPUVolumeRayCastMapper.h:611
vtkGPUVolumeRayCastMapper::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Handle inputs.
vtkGPUVolumeRayCastMapper::ColorRangeType
int ColorRangeType
Definition: vtkGPUVolumeRayCastMapper.h:565
vtkGPUVolumeRayCastMapper::RemoveInputConnection
void RemoveInputConnection(int port, vtkAlgorithmOutput *input) override
Add/Remove input connections.
vtkGPUVolumeRayCastMapper::ReportProgress
bool ReportProgress
Definition: vtkGPUVolumeRayCastMapper.h:595
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:205
vtkGPUVolumeRayCastMapper::TransformInput
void TransformInput(const int port)
A transformation is applied (translation) to the input.
vtkGPUVolumeRayCastMapper::SmallTimeToDraw
double SmallTimeToDraw
Definition: vtkGPUVolumeRayCastMapper.h:539
vtkGPUVolumeRayCastMapper::CloneInputs
void CloneInputs()
Shallow-copy the inputs into a transform-adjusted clone.
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkGPUVolumeRayCastMapper::MaskInput
vtkImageData * MaskInput
Definition: vtkGPUVolumeRayCastMapper.h:555
vtkGPUVolumeRayCastMapper::GetDepthPassContourValues
vtkContourValues * GetDepthPassContourValues()
Return handle to contour values container so that values can be set by the application.
vtkGPUVolumeRayCastMapper::MaxMemoryInBytes
vtkIdType MaxMemoryInBytes
Definition: vtkGPUVolumeRayCastMapper.h:592
vtkGPUVolumeRayCastMapper::GetTransformedInput
vtkDataSet * GetTransformedInput(const int port=0)
vtkGPUVolumeRayCastMapper::DepthPassContourValues
vtkContourValues * DepthPassContourValues
Definition: vtkGPUVolumeRayCastMapper.h:532
vtkVolumeProperty
represents the common properties for rendering a volume.
Definition: vtkVolumeProperty.h:164
vtkGPUVolumeRayCastMapper::GetReductionRatio
virtual void GetReductionRatio(double ratio[3])=0
Return how much the dataset has to be reduced in each dimension to fit on the GPU.
vtkGPUVolumeRayCastMapper::Ports
std::vector< int > Ports
Definition: vtkGPUVolumeRayCastMapper.h:596