VTK
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 <vtkRenderingVolumeModule.h> // For export macro
36 #include "vtkVolumeMapper.h"
37 
38 
39 class vtkContourValues;
40 class vtkRenderWindow;
41 class vtkVolumeProperty;
42 
43 class VTKRENDERINGVOLUME_EXPORT vtkGPUVolumeRayCastMapper : public vtkVolumeMapper
44 {
45 public:
48  void PrintSelf( ostream& os, vtkIndent indent ) override;
49 
51 
57  vtkSetClampMacro( AutoAdjustSampleDistances, vtkTypeBool, 0, 1 );
58  vtkGetMacro( AutoAdjustSampleDistances, vtkTypeBool );
59  vtkBooleanMacro( AutoAdjustSampleDistances, vtkTypeBool );
61 
63 
68  vtkSetClampMacro( LockSampleDistanceToInputSpacing, vtkTypeBool, 0, 1 );
69  vtkGetMacro( LockSampleDistanceToInputSpacing, vtkTypeBool );
70  vtkBooleanMacro( LockSampleDistanceToInputSpacing, vtkTypeBool );
72 
74 
79  vtkSetClampMacro( UseJittering, vtkTypeBool, 0, 1 );
80  vtkGetMacro( UseJittering, vtkTypeBool );
81  vtkBooleanMacro( UseJittering, vtkTypeBool );
83 
85 
93  vtkSetClampMacro( UseDepthPass, vtkTypeBool, 0, 1 );
94  vtkGetMacro( UseDepthPass, vtkTypeBool );
95  vtkBooleanMacro( UseDepthPass, vtkTypeBool );
97 
103  vtkContourValues* GetDepthPassContourValues();
104 
106 
112  vtkSetMacro( SampleDistance, float );
113  vtkGetMacro( SampleDistance, float );
115 
117 
124  vtkSetClampMacro( ImageSampleDistance, float, 0.1f, 100.0f );
125  vtkGetMacro( ImageSampleDistance, float );
127 
129 
133  vtkSetClampMacro( MinimumImageSampleDistance, float, 0.1f, 100.0f );
134  vtkGetMacro( MinimumImageSampleDistance, float );
136 
138 
142  vtkSetClampMacro( MaximumImageSampleDistance, float, 0.1f, 100.0f );
143  vtkGetMacro( MaximumImageSampleDistance, float );
145 
146 
148 
161  vtkSetMacro( FinalColorWindow, float );
162  vtkGetMacro( FinalColorWindow, float );
163  vtkSetMacro( FinalColorLevel, float );
164  vtkGetMacro( FinalColorLevel, float );
166 
168 
173  vtkSetMacro( MaxMemoryInBytes, vtkIdType );
174  vtkGetMacro( MaxMemoryInBytes, vtkIdType );
176 
178 
183  vtkSetClampMacro( MaxMemoryFraction, float, 0.1f, 1.0f );
184  vtkGetMacro( MaxMemoryFraction, float );
186 
188 
196  vtkSetMacro(ReportProgress,bool);
197  vtkGetMacro(ReportProgress,bool);
199 
206  virtual int IsRenderSupported(vtkRenderWindow *vtkNotUsed(window),
207  vtkVolumeProperty *vtkNotUsed(property))
208  {
209  return 0;
210  }
211 
212  void CreateCanonicalView( vtkRenderer *ren,
213  vtkVolume *volume,
215  int blend_mode,
216  double viewDirection[3],
217  double viewUp[3] );
218 
220 
241  void SetMaskInput(vtkImageData *mask);
242  vtkGetObjectMacro(MaskInput, vtkImageData);
244 
245  enum { BinaryMaskType = 0, LabelMapMaskType };
246 
248 
252  vtkSetMacro( MaskType, int );
253  vtkGetMacro( MaskType, int );
254  void SetMaskTypeToBinary();
255  void SetMaskTypeToLabelMap();
257 
259 
267  vtkSetClampMacro(MaskBlendFactor,float,0.0f,1.0f);
268  vtkGetMacro(MaskBlendFactor,float);
270 
272 
286  vtkSetMacro(RenderToImage, vtkTypeBool);
287  vtkGetMacro(RenderToImage, vtkTypeBool);
288  vtkBooleanMacro(RenderToImage, vtkTypeBool);
290 
292 
297  vtkSetMacro(DepthImageScalarType, int);
298  vtkGetMacro(DepthImageScalarType, int);
299  void SetDepthImageScalarTypeToUnsignedChar();
300  void SetDepthImageScalarTypeToUnsignedShort();
301  void SetDepthImageScalarTypeToFloat();
303 
305 
316  vtkSetMacro(ClampDepthToBackface, vtkTypeBool);
317  vtkGetMacro(ClampDepthToBackface, vtkTypeBool);
318  vtkBooleanMacro(ClampDepthToBackface, vtkTypeBool);
320 
327  virtual void GetDepthImage(vtkImageData*) {};
328 
335  virtual void GetColorImage(vtkImageData*) {};
336 
341  void Render( vtkRenderer *, vtkVolume * ) override;
342 
347  virtual void GPURender( vtkRenderer *, vtkVolume *) {}
348 
356 
369  virtual void GetReductionRatio(double ratio[3])=0;
370 
372  {
373  SCALAR = 0, // default
374  NATIVE
375  };
376 
378 
394  vtkSetMacro(ColorRangeType, int);
395  vtkGetMacro(ColorRangeType, int);
396  vtkSetMacro(ScalarOpacityRangeType, int);
397  vtkGetMacro(ScalarOpacityRangeType, int);
398  vtkSetMacro(GradientOpacityRangeType, int);
399  vtkGetMacro(GradientOpacityRangeType, int);
401 
402  vtkImageData* GetInput() override
403  {
404  return this->GetInput(0);
405  };
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 
424  int GetInputCount();
425 
426  vtkImageData* GetTransformedInput(const int port = 0);
427 
428  double* GetBoundsFromPort(const int port) VTK_SIZEHINT(6);
429 
430 protected:
432  ~vtkGPUVolumeRayCastMapper() override;
433 
442  int FillInputPortInformation(int port, vtkInformation* info) override;
443 
455  void TransformInput(const int port);
456 
458 
467  int ValidateRender( vtkRenderer *, vtkVolume * );
468  int ValidateInputs();
469  int ValidateInput(vtkVolumeProperty* property, const int port);
471 
473 
477  void CloneInputs();
478  void CloneInput(vtkImageData* input, const int port);
480 
481  // Special version of render called during the creation
482  // of a canonical view.
483  void CanonicalViewRender( vtkRenderer *, vtkVolume * );
484 
485  // Methods called by the AMR Volume Mapper.
486  virtual void PreRender(vtkRenderer *ren,
487  vtkVolume *vol,
488  double datasetBounds[6],
489  double scalarRange[2],
490  int numberOfScalarComponents,
491  unsigned int numberOfLevels)=0;
492 
493  // \pre input is up-to-date
494  virtual void RenderBlock(vtkRenderer *ren,
495  vtkVolume *vol,
496  unsigned int level)=0;
497 
498  virtual void PostRender(vtkRenderer *ren,
499  int numberOfScalarComponents)=0;
500  vtkImageData* GetInput(const int port) override;
501 
507  void SetCellFlag(int cellFlag);
508  void RemovePortInternal(const int port);
509 
515 
516  // Render to texture mode flag
518 
519  // Depth image scalar type
521 
522  // Clamp depth values to the depth of the face at which the ray
523  // exits the volume
525 
526  // Enable / disable stochastic jittering
528 
529  // Enable / disable two pass rendering
532 
533  // The distance between sample points along the ray
535 
539 
542 
543  // 1 if we are generating the canonical image, 0 otherwise
546 
548 
552  vtkSetClampMacro(AMRMode,vtkTypeBool,0,1);
553  vtkGetMacro(AMRMode,vtkTypeBool);
554  vtkBooleanMacro(AMRMode,vtkTypeBool);
556 
559  int MaskType;
560 
562 
563  // Transfer function range type
567 
568  // Point data or cell data (or field data, not handled) ?
569  int CellFlag;
570 
583  virtual void ClipCroppingRegionPlanes();
584 
585  using DataMap = std::unordered_map<int, vtkImageData*>;
586  void SetTransformedInput(vtkImageData*);
587  vtkImageData* FindData(int port, DataMap& container);
588 
589  double ClippedCroppingRegionPlanes[6];
590 
593 
595  std::vector<int> Ports;
596  std::vector<int> RemovedPorts;
598 
604 
605 private:
607  void operator=(const vtkGPUVolumeRayCastMapper&) = delete;
608 };
609 
610 #endif
vtkGPUVolumeRayCastMapper::LockSampleDistanceToInputSpacing
vtkTypeBool LockSampleDistanceToInputSpacing
Definition: vtkGPUVolumeRayCastMapper.h:510
vtkGPUVolumeRayCastMapper::GeneratingCanonicalView
int GeneratingCanonicalView
Definition: vtkGPUVolumeRayCastMapper.h:544
vtkVolumeMapper
Abstract class for a volume mapper.
Definition: vtkVolumeMapper.h:46
vtkGPUVolumeRayCastMapper::GetDepthImage
virtual void GetDepthImage(vtkImageData *)
Low level API to export the depth texture as vtkImageData in RenderToImage mode.
Definition: vtkGPUVolumeRayCastMapper.h:327
vtkVolume
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:50
vtkAlgorithm::RemoveInputConnection
virtual void RemoveInputConnection(int port, vtkAlgorithmOutput *input)
Remove a connection from the given input port index.
vtkGPUVolumeRayCastMapper::BigTimeToDraw
double BigTimeToDraw
Definition: vtkGPUVolumeRayCastMapper.h:537
vtkGPUVolumeRayCastMapper::GradientOpacityRangeType
int GradientOpacityRangeType
Definition: vtkGPUVolumeRayCastMapper.h:566
vtkGPUVolumeRayCastMapper::DepthImageScalarType
int DepthImageScalarType
Definition: vtkGPUVolumeRayCastMapper.h:520
vtkGPUVolumeRayCastMapper::AutoAdjustSampleDistances
vtkTypeBool AutoAdjustSampleDistances
Definition: vtkGPUVolumeRayCastMapper.h:511
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkGPUVolumeRayCastMapper::MaxMemoryFraction
float MaxMemoryFraction
Definition: vtkGPUVolumeRayCastMapper.h:592
vtkX3D::image
Definition: vtkX3D.h:374
vtkGPUVolumeRayCastMapper::FinalColorLevel
float FinalColorLevel
Definition: vtkGPUVolumeRayCastMapper.h:541
vtkGPUVolumeRayCastMapper::UseJittering
vtkTypeBool UseJittering
Definition: vtkGPUVolumeRayCastMapper.h:527
vtkGPUVolumeRayCastMapper::SampleDistance
float SampleDistance
Definition: vtkGPUVolumeRayCastMapper.h:534
vtkGPUVolumeRayCastMapper::MaximumImageSampleDistance
float MaximumImageSampleDistance
Definition: vtkGPUVolumeRayCastMapper.h:514
vtkGPUVolumeRayCastMapper::ScalarOpacityRangeType
int ScalarOpacityRangeType
Definition: vtkGPUVolumeRayCastMapper.h:565
vtkGPUVolumeRayCastMapper::ClampDepthToBackface
vtkTypeBool ClampDepthToBackface
Definition: vtkGPUVolumeRayCastMapper.h:524
vtkGPUVolumeRayCastMapper::FinalColorWindow
float FinalColorWindow
Definition: vtkGPUVolumeRayCastMapper.h:540
vtkGPUVolumeRayCastMapper::MinimumImageSampleDistance
float MinimumImageSampleDistance
Definition: vtkGPUVolumeRayCastMapper.h:513
vtkGPUVolumeRayCastMapper::CanonicalViewImageData
vtkImageData * CanonicalViewImageData
Definition: vtkGPUVolumeRayCastMapper.h:545
vtkGPUVolumeRayCastMapper::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
Definition: vtkGPUVolumeRayCastMapper.h:355
vtkGPUVolumeRayCastMapper::GetInput
vtkImageData * GetInput() override
Definition: vtkGPUVolumeRayCastMapper.h:402
vtkGPUVolumeRayCastMapper::CellFlag
int CellFlag
Definition: vtkGPUVolumeRayCastMapper.h:569
vtkGPUVolumeRayCastMapper::MaskBlendFactor
float MaskBlendFactor
Definition: vtkGPUVolumeRayCastMapper.h:558
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkGPUVolumeRayCastMapper::AMRMode
vtkTypeBool AMRMode
Definition: vtkGPUVolumeRayCastMapper.h:561
vtkVolumeMapper::FillInputPortInformation
int FillInputPortInformation(int, vtkInformation *) override
Fill the input port information objects for this algorithm.
vtkX3D::level
Definition: vtkX3D.h:395
vtkX3D::port
Definition: vtkX3D.h:447
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:603
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkGPUVolumeRayCastMapper::RenderToImage
vtkTypeBool RenderToImage
Definition: vtkGPUVolumeRayCastMapper.h:517
vtkVolumeMapper::Render
void Render(vtkRenderer *ren, vtkVolume *vol) override=0
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
vtkContourValues
helper object to manage setting and generating contour values
Definition: vtkContourValues.h:35
vtkGPUVolumeRayCastMapper::TransformedInputs
DataMap TransformedInputs
Definition: vtkGPUVolumeRayCastMapper.h:597
vtkVolumeMapper.h
vtkGPUVolumeRayCastMapper::TFRangeType
TFRangeType
Definition: vtkGPUVolumeRayCastMapper.h:371
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkGPUVolumeRayCastMapper::RemovedPorts
std::vector< int > RemovedPorts
Definition: vtkGPUVolumeRayCastMapper.h:596
vtkGPUVolumeRayCastMapper
Ray casting performed on the GPU.
Definition: vtkGPUVolumeRayCastMapper.h:43
vtkGPUVolumeRayCastMapper::ImageSampleDistance
float ImageSampleDistance
Definition: vtkGPUVolumeRayCastMapper.h:512
vtkGPUVolumeRayCastMapper::GetColorImage
virtual void GetColorImage(vtkImageData *)
Low level API to export the color texture as vtkImageData in RenderToImage mode.
Definition: vtkGPUVolumeRayCastMapper.h:335
vtkGPUVolumeRayCastMapper::SetInputConnection
void SetInputConnection(vtkAlgorithmOutput *input) override
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:206
vtkGPUVolumeRayCastMapper::DataMap
std::unordered_map< int, vtkImageData * > DataMap
Definition: vtkGPUVolumeRayCastMapper.h:585
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:86
vtkX3D::info
Definition: vtkX3D.h:376
vtkAlgorithm::New
static vtkAlgorithm * New()
vtkGPUVolumeRayCastMapper::MaskType
int MaskType
Definition: vtkGPUVolumeRayCastMapper.h:559
vtkGPUVolumeRayCastMapper::SmallVolumeRender
int SmallVolumeRender
Definition: vtkGPUVolumeRayCastMapper.h:536
vtkAlgorithmOutput
Proxy object to connect input/output ports.
Definition: vtkAlgorithmOutput.h:39
vtkGPUVolumeRayCastMapper::UseDepthPass
vtkTypeBool UseDepthPass
Definition: vtkGPUVolumeRayCastMapper.h:530
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:63
vtkGPUVolumeRayCastMapper::GPURender
virtual void GPURender(vtkRenderer *, vtkVolume *)
Handled in the subclass - the actual render method.
Definition: vtkGPUVolumeRayCastMapper.h:347
vtkGPUVolumeRayCastMapper::ColorRangeType
int ColorRangeType
Definition: vtkGPUVolumeRayCastMapper.h:564
vtkVolumeMapper::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkGPUVolumeRayCastMapper::ReportProgress
bool ReportProgress
Definition: vtkGPUVolumeRayCastMapper.h:594
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:87
vtkGPUVolumeRayCastMapper::SmallTimeToDraw
double SmallTimeToDraw
Definition: vtkGPUVolumeRayCastMapper.h:538
vtkVolumeMapper::GetInput
virtual vtkImageData * GetInput()
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkGPUVolumeRayCastMapper::MaskInput
vtkImageData * MaskInput
Definition: vtkGPUVolumeRayCastMapper.h:554
vtkGPUVolumeRayCastMapper::MaxMemoryInBytes
vtkIdType MaxMemoryInBytes
Definition: vtkGPUVolumeRayCastMapper.h:591
vtkGPUVolumeRayCastMapper::DepthPassContourValues
vtkContourValues * DepthPassContourValues
Definition: vtkGPUVolumeRayCastMapper.h:531
vtkVolumeProperty
represents the common properties for rendering a volume.
Definition: vtkVolumeProperty.h:68
vtkGPUVolumeRayCastMapper::Ports
std::vector< int > Ports
Definition: vtkGPUVolumeRayCastMapper.h:595