VTK  9.0.1
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 =========================================================================*/
30 #ifndef vtkGPUVolumeRayCastMapper_h
31 #define vtkGPUVolumeRayCastMapper_h
32 #include <unordered_map> // For std::unordered_map
33 #include <vector> // For std::vector
34 
35 #include "vtkVolumeMapper.h"
36 #include <vtkRenderingVolumeModule.h> // For export macro
37 
38 class vtkContourValues;
39 class vtkRenderWindow;
40 class vtkVolumeProperty;
41 
42 class VTKRENDERINGVOLUME_EXPORT vtkGPUVolumeRayCastMapper : public vtkVolumeMapper
43 {
44 public:
47  void PrintSelf(ostream& os, vtkIndent indent) override;
48 
50 
56  vtkSetClampMacro(AutoAdjustSampleDistances, vtkTypeBool, 0, 1);
57  vtkGetMacro(AutoAdjustSampleDistances, vtkTypeBool);
58  vtkBooleanMacro(AutoAdjustSampleDistances, vtkTypeBool);
60 
62 
67  vtkSetClampMacro(LockSampleDistanceToInputSpacing, vtkTypeBool, 0, 1);
68  vtkGetMacro(LockSampleDistanceToInputSpacing, vtkTypeBool);
69  vtkBooleanMacro(LockSampleDistanceToInputSpacing, vtkTypeBool);
71 
73 
78  vtkSetClampMacro(UseJittering, vtkTypeBool, 0, 1);
79  vtkGetMacro(UseJittering, vtkTypeBool);
80  vtkBooleanMacro(UseJittering, vtkTypeBool);
82 
84 
92  vtkSetClampMacro(UseDepthPass, vtkTypeBool, 0, 1);
93  vtkGetMacro(UseDepthPass, vtkTypeBool);
94  vtkBooleanMacro(UseDepthPass, vtkTypeBool);
96 
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 
283  vtkSetMacro(RenderToImage, vtkTypeBool);
284  vtkGetMacro(RenderToImage, vtkTypeBool);
285  vtkBooleanMacro(RenderToImage, vtkTypeBool);
287 
289 
294  vtkSetMacro(DepthImageScalarType, int);
295  vtkGetMacro(DepthImageScalarType, int);
300 
302 
313  vtkSetMacro(ClampDepthToBackface, vtkTypeBool);
314  vtkGetMacro(ClampDepthToBackface, vtkTypeBool);
315  vtkBooleanMacro(ClampDepthToBackface, vtkTypeBool);
317 
324  virtual void GetDepthImage(vtkImageData*) {}
325 
332  virtual void GetColorImage(vtkImageData*) {}
333 
338  void Render(vtkRenderer*, vtkVolume*) override;
339 
344  virtual void GPURender(vtkRenderer*, vtkVolume*) {}
345 
353 
366  virtual void GetReductionRatio(double ratio[3]) = 0;
367 
369  {
370  SCALAR = 0, // default
371  NATIVE
372  };
373 
375 
391  vtkSetMacro(ColorRangeType, int);
392  vtkGetMacro(ColorRangeType, int);
393  vtkSetMacro(ScalarOpacityRangeType, int);
394  vtkGetMacro(ScalarOpacityRangeType, int);
395  vtkSetMacro(GradientOpacityRangeType, int);
396  vtkGetMacro(GradientOpacityRangeType, int);
398 
399  vtkImageData* GetInput() override { return this->GetInput(0); };
400 
402 
406  void RemoveInputConnection(int port, vtkAlgorithmOutput* input) override;
407  void RemoveInputConnection(int port, int idx) override;
408  void SetInputConnection(int port, vtkAlgorithmOutput* input) override;
410  {
411  this->SetInputConnection(0, input);
412  }
414 
419 
421 
422  double* GetBoundsFromPort(const int port) VTK_SIZEHINT(6);
423 
424 protected:
427 
437 
449  void TransformInput(const int port);
450 
452 
463  int ValidateInput(vtkVolumeProperty* property, const int port);
465 
467 
471  void CloneInputs();
472  void CloneInput(vtkImageData* input, const int port);
474 
475  // Special version of render called during the creation
476  // of a canonical view.
478 
479  // Methods called by the AMR Volume Mapper.
480  virtual void PreRender(vtkRenderer* ren, vtkVolume* vol, double datasetBounds[6],
481  double scalarRange[2], int numberOfScalarComponents, unsigned int numberOfLevels) = 0;
482 
483  // \pre input is up-to-date
484  virtual void RenderBlock(vtkRenderer* ren, vtkVolume* vol, unsigned int level) = 0;
485 
486  virtual void PostRender(vtkRenderer* ren, int numberOfScalarComponents) = 0;
487  vtkImageData* GetInput(const int port) override;
488 
494  void SetCellFlag(int cellFlag);
495  void RemovePortInternal(const int port);
496 
502 
503  // Render to texture mode flag
505 
506  // Depth image scalar type
508 
509  // Clamp depth values to the depth of the face at which the ray
510  // exits the volume
512 
513  // Enable / disable stochastic jittering
515 
516  // Enable / disable two pass rendering
519 
520  // The distance between sample points along the ray
522 
526 
529 
530  // 1 if we are generating the canonical image, 0 otherwise
533 
535 
539  vtkSetClampMacro(AMRMode, vtkTypeBool, 0, 1);
540  vtkGetMacro(AMRMode, vtkTypeBool);
541  vtkBooleanMacro(AMRMode, vtkTypeBool);
543 
546  int MaskType;
547 
549 
550  // Transfer function range type
554 
555  // Point data or cell data (or field data, not handled) ?
556  int CellFlag;
557 
570  virtual void ClipCroppingRegionPlanes();
571 
572  using DataMap = std::unordered_map<int, vtkImageData*>;
574  vtkImageData* FindData(int port, DataMap& container);
575 
576  double ClippedCroppingRegionPlanes[6];
577 
580 
582  std::vector<int> Ports;
583  std::vector<int> RemovedPorts;
585 
591 
592 private:
594  void operator=(const vtkGPUVolumeRayCastMapper&) = delete;
595 };
596 
597 #endif
vtkGPUVolumeRayCastMapper::New
static vtkGPUVolumeRayCastMapper * New()
vtkGPUVolumeRayCastMapper::LockSampleDistanceToInputSpacing
vtkTypeBool LockSampleDistanceToInputSpacing
Definition: vtkGPUVolumeRayCastMapper.h:497
vtkGPUVolumeRayCastMapper::GeneratingCanonicalView
int GeneratingCanonicalView
Definition: vtkGPUVolumeRayCastMapper.h:531
vtkVolumeMapper
Abstract class for a volume mapper.
Definition: vtkVolumeMapper.h:44
vtkGPUVolumeRayCastMapper::GetDepthImage
virtual void GetDepthImage(vtkImageData *)
Low level API to export the depth texture as vtkImageData in RenderToImage mode.
Definition: vtkGPUVolumeRayCastMapper.h:324
vtkGPUVolumeRayCastMapper::PreRender
virtual void PreRender(vtkRenderer *ren, vtkVolume *vol, double datasetBounds[6], double scalarRange[2], int numberOfScalarComponents, unsigned int numberOfLevels)=0
vtkGPUVolumeRayCastMapper::SetMaskInput
void SetMaskInput(vtkImageData *mask)
Optionally, set a mask input.
vtkGPUVolumeRayCastMapper::SetMaskTypeToBinary
void SetMaskTypeToBinary()
vtkVolume
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:45
vtkGPUVolumeRayCastMapper::BigTimeToDraw
double BigTimeToDraw
Definition: vtkGPUVolumeRayCastMapper.h:524
vtkGPUVolumeRayCastMapper::GradientOpacityRangeType
int GradientOpacityRangeType
Definition: vtkGPUVolumeRayCastMapper.h:553
vtkGPUVolumeRayCastMapper::FindData
vtkImageData * FindData(int port, DataMap &container)
vtkGPUVolumeRayCastMapper::DepthImageScalarType
int DepthImageScalarType
Definition: vtkGPUVolumeRayCastMapper.h:507
vtkGPUVolumeRayCastMapper::AutoAdjustSampleDistances
vtkTypeBool AutoAdjustSampleDistances
Definition: vtkGPUVolumeRayCastMapper.h:498
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkGPUVolumeRayCastMapper::MaxMemoryFraction
float MaxMemoryFraction
Definition: vtkGPUVolumeRayCastMapper.h:579
vtkGPUVolumeRayCastMapper::SetCellFlag
void SetCellFlag(int cellFlag)
Called by the AMR Volume Mapper.
vtkX3D::image
@ image
Definition: vtkX3D.h:380
vtkGPUVolumeRayCastMapper::SetDepthImageScalarTypeToUnsignedChar
void SetDepthImageScalarTypeToUnsignedChar()
vtkGPUVolumeRayCastMapper::ValidateRender
int ValidateRender(vtkRenderer *, vtkVolume *)
This method is used by the Render() method to validate everything before attempting to render.
vtkGPUVolumeRayCastMapper::RenderBlock
virtual void RenderBlock(vtkRenderer *ren, vtkVolume *vol, unsigned int level)=0
vtkGPUVolumeRayCastMapper::FinalColorLevel
float FinalColorLevel
Definition: vtkGPUVolumeRayCastMapper.h:528
vtkGPUVolumeRayCastMapper::UseJittering
vtkTypeBool UseJittering
Definition: vtkGPUVolumeRayCastMapper.h:514
vtkGPUVolumeRayCastMapper::SampleDistance
float SampleDistance
Definition: vtkGPUVolumeRayCastMapper.h:521
vtkGPUVolumeRayCastMapper::GetBoundsFromPort
double * GetBoundsFromPort(const int port)
vtkGPUVolumeRayCastMapper::CloneInput
void CloneInput(vtkImageData *input, const int port)
vtkGPUVolumeRayCastMapper::PostRender
virtual void PostRender(vtkRenderer *ren, int numberOfScalarComponents)=0
vtkGPUVolumeRayCastMapper::MaximumImageSampleDistance
float MaximumImageSampleDistance
Definition: vtkGPUVolumeRayCastMapper.h:501
vtkGPUVolumeRayCastMapper::ScalarOpacityRangeType
int ScalarOpacityRangeType
Definition: vtkGPUVolumeRayCastMapper.h:552
vtkGPUVolumeRayCastMapper::ClampDepthToBackface
vtkTypeBool ClampDepthToBackface
Definition: vtkGPUVolumeRayCastMapper.h:511
vtkGPUVolumeRayCastMapper::vtkGPUVolumeRayCastMapper
vtkGPUVolumeRayCastMapper()
vtkGPUVolumeRayCastMapper::FinalColorWindow
float FinalColorWindow
Definition: vtkGPUVolumeRayCastMapper.h:527
vtkGPUVolumeRayCastMapper::MinimumImageSampleDistance
float MinimumImageSampleDistance
Definition: vtkGPUVolumeRayCastMapper.h:500
vtkGPUVolumeRayCastMapper::CanonicalViewImageData
vtkImageData * CanonicalViewImageData
Definition: vtkGPUVolumeRayCastMapper.h:532
vtkGPUVolumeRayCastMapper::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition: vtkGPUVolumeRayCastMapper.h:352
vtkGPUVolumeRayCastMapper::GetInput
vtkImageData * GetInput() override
Definition: vtkGPUVolumeRayCastMapper.h:399
vtkGPUVolumeRayCastMapper::CellFlag
int CellFlag
Definition: vtkGPUVolumeRayCastMapper.h:556
vtkGPUVolumeRayCastMapper::MaskBlendFactor
float MaskBlendFactor
Definition: vtkGPUVolumeRayCastMapper.h:545
vtkGPUVolumeRayCastMapper::SetDepthImageScalarTypeToFloat
void SetDepthImageScalarTypeToFloat()
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
vtkGPUVolumeRayCastMapper::AMRMode
vtkTypeBool AMRMode
Definition: vtkGPUVolumeRayCastMapper.h:548
vtkGPUVolumeRayCastMapper::ValidateInputs
int ValidateInputs()
vtkGPUVolumeRayCastMapper::Render
void Render(vtkRenderer *, vtkVolume *) override
Initialize rendering for this volume.
vtkGPUVolumeRayCastMapper::SetTransformedInput
void SetTransformedInput(vtkImageData *)
vtkGPUVolumeRayCastMapper::GetInput
vtkImageData * GetInput(const int port) override
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:590
vtkGPUVolumeRayCastMapper::ValidateInput
int ValidateInput(vtkVolumeProperty *property, const int port)
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkGPUVolumeRayCastMapper::RenderToImage
vtkTypeBool RenderToImage
Definition: vtkGPUVolumeRayCastMapper.h:504
vtkGPUVolumeRayCastMapper::SetInputConnection
void SetInputConnection(int port, vtkAlgorithmOutput *input) override
Set the connection for the given input port index.
vtkContourValues
helper object to manage setting and generating contour values
Definition: vtkContourValues.h:36
vtkGPUVolumeRayCastMapper::TransformedInputs
DataMap TransformedInputs
Definition: vtkGPUVolumeRayCastMapper.h:584
vtkVolumeMapper.h
vtkGPUVolumeRayCastMapper::TFRangeType
TFRangeType
Definition: vtkGPUVolumeRayCastMapper.h:369
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
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:583
vtkGPUVolumeRayCastMapper
Ray casting performed on the GPU.
Definition: vtkGPUVolumeRayCastMapper.h:43
vtkGPUVolumeRayCastMapper::SetDepthImageScalarTypeToUnsignedShort
void SetDepthImageScalarTypeToUnsignedShort()
vtkGPUVolumeRayCastMapper::ImageSampleDistance
float ImageSampleDistance
Definition: vtkGPUVolumeRayCastMapper.h:499
vtkGPUVolumeRayCastMapper::GetColorImage
virtual void GetColorImage(vtkImageData *)
Low level API to export the color texture as vtkImageData in RenderToImage mode.
Definition: vtkGPUVolumeRayCastMapper.h:332
vtkGPUVolumeRayCastMapper::SetInputConnection
void SetInputConnection(vtkAlgorithmOutput *input) override
Definition: vtkGPUVolumeRayCastMapper.h:409
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:204
vtkGPUVolumeRayCastMapper::DataMap
std::unordered_map< int, vtkImageData * > DataMap
Definition: vtkGPUVolumeRayCastMapper.h:572
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:65
vtkX3D::info
@ info
Definition: vtkX3D.h:382
vtkGPUVolumeRayCastMapper::CanonicalViewRender
void CanonicalViewRender(vtkRenderer *, vtkVolume *)
vtkGPUVolumeRayCastMapper::MaskType
int MaskType
Definition: vtkGPUVolumeRayCastMapper.h:546
vtkGPUVolumeRayCastMapper::RemoveInputConnection
void RemoveInputConnection(int port, int idx) override
Remove a connection given by index idx.
vtkGPUVolumeRayCastMapper::RemovePortInternal
void RemovePortInternal(const int port)
vtkGPUVolumeRayCastMapper::SmallVolumeRender
int SmallVolumeRender
Definition: vtkGPUVolumeRayCastMapper.h:523
vtkGPUVolumeRayCastMapper::~vtkGPUVolumeRayCastMapper
~vtkGPUVolumeRayCastMapper() override
vtkAlgorithmOutput
Proxy object to connect input/output ports.
Definition: vtkAlgorithmOutput.h:37
vtkGPUVolumeRayCastMapper::UseDepthPass
vtkTypeBool UseDepthPass
Definition: vtkGPUVolumeRayCastMapper.h:517
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:59
vtkGPUVolumeRayCastMapper::GPURender
virtual void GPURender(vtkRenderer *, vtkVolume *)
Handled in the subclass - the actual render method.
Definition: vtkGPUVolumeRayCastMapper.h:344
vtkGPUVolumeRayCastMapper::SetMaskTypeToLabelMap
void SetMaskTypeToLabelMap()
vtkGPUVolumeRayCastMapper::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Handle inputs.
vtkGPUVolumeRayCastMapper::ColorRangeType
int ColorRangeType
Definition: vtkGPUVolumeRayCastMapper.h:551
vtkGPUVolumeRayCastMapper::RemoveInputConnection
void RemoveInputConnection(int port, vtkAlgorithmOutput *input) override
Add/Remove input connections.
vtkGPUVolumeRayCastMapper::ReportProgress
bool ReportProgress
Definition: vtkGPUVolumeRayCastMapper.h:581
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:85
vtkGPUVolumeRayCastMapper::TransformInput
void TransformInput(const int port)
A transformation is applied (translation) to the input.
vtkGPUVolumeRayCastMapper::SmallTimeToDraw
double SmallTimeToDraw
Definition: vtkGPUVolumeRayCastMapper.h:525
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:541
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:578
vtkGPUVolumeRayCastMapper::GetTransformedInput
vtkImageData * GetTransformedInput(const int port=0)
vtkGPUVolumeRayCastMapper::DepthPassContourValues
vtkContourValues * DepthPassContourValues
Definition: vtkGPUVolumeRayCastMapper.h:518
vtkVolumeProperty
represents the common properties for rendering a volume.
Definition: vtkVolumeProperty.h:75
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:582