VTK  9.3.1
vtkVolumeInputHelper.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
18 #ifndef vtkVolumeInputHelper_h
19 #define vtkVolumeInputHelper_h
20 #include <map>
21 
23 #include "vtkRenderingVolumeOpenGL2Module.h" // For export macro
24 #include "vtkSmartPointer.h" // For SmartPointer
25 #include "vtkTimeStamp.h" // For TimeStamp
26 
27 VTK_ABI_NAMESPACE_BEGIN
32 class vtkRenderer;
33 class vtkShaderProgram;
34 class vtkVolume;
35 class vtkVolumeTexture;
36 class vtkWindow;
37 
38 class VTKRENDERINGVOLUMEOPENGL2_EXPORT vtkVolumeInputHelper
39 {
40 public:
41  vtkVolumeInputHelper() = default;
43 
44  void RefreshTransferFunction(
45  vtkRenderer* ren, int uniformIndex, int blendMode, float samplingDist);
46  void ForceTransferInit();
47 
48  void ActivateTransferFunction(vtkShaderProgram* prog, int blendMode);
49  void DeactivateTransferFunction(int blendMode);
50 
51  void ReleaseGraphicsResources(vtkWindow* window);
52 
54  vtkVolume* Volume = nullptr;
55 
61  {
62  INVALID = 0,
63  INDEPENDENT = 1,
64  LA = 2,
65  RGBA = 4
66  };
67  int ComponentMode = INDEPENDENT;
68 
78 
82  std::map<int, std::string> RGBTablesMap;
83  std::map<int, std::string> OpacityTablesMap;
84  std::map<int, std::string> GradientOpacityTablesMap;
85  std::map<int, std::string> TransferFunctions2DMap;
86 
92  int ColorRangeType = 0; // vtkGPUVolumeRayCastMapper::SCALAR
93  int ScalarOpacityRangeType = 0; // vtkGPUVolumeRayCastMapper::SCALAR
94  int GradientOpacityRangeType = 0; // vtkGPUVolumeRayCastMapper::SCALAR
95 
101 
102 protected:
103  void InitializeTransferFunction(vtkRenderer* ren, int index);
104 
105  void CreateTransferFunction1D(vtkRenderer* ren, int index);
106  void CreateTransferFunction2D(vtkRenderer* ren, int index);
107 
108  void UpdateTransferFunctions(vtkRenderer* ren, int blendMode, float samplingDist);
109  int UpdateOpacityTransferFunction(
110  vtkRenderer* ren, vtkVolume* vol, unsigned int component, int blendMode, float samplingDist);
111  int UpdateColorTransferFunction(vtkRenderer* ren, vtkVolume* vol, unsigned int component);
112  int UpdateGradientOpacityTransferFunction(
113  vtkRenderer* ren, vtkVolume* vol, unsigned int component, float samplingDist);
114  void UpdateTransferFunction2D(vtkRenderer* ren, unsigned int component);
115 
116  void ReleaseGraphicsTransfer1D(vtkWindow* window);
117  void ReleaseGraphicsTransfer2D(vtkWindow* window);
118 
120  bool InitializeTransfer = true;
121 };
122 
123 VTK_ABI_NAMESPACE_END
124 #endif // vtkVolumeInputHelper_h
125 // VTK-HeaderTest-Exclude: vtkVolumeInputHelper.h
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:39
std::map< int, std::string > GradientOpacityTablesMap
vtkSmartPointer< vtkOpenGLVolumeLookupTables< vtkOpenGLVolumeGradientOpacityTable > > GradientOpacityTables
Transfer function internal structures and helpers.
Creates and manages the volume texture rendered by vtkOpenGLGPUVolumeRayCastMapper.
vtkSmartPointer< vtkOpenGLVolumeLookupTables< vtkOpenGLVolumeRGBTable > > RGBTables
Convenience container for internal structures specific to a volume input.
std::map< int, std::string > OpacityTablesMap
vtkSmartPointer< vtkOpenGLVolumeLookupTables< vtkOpenGLVolumeTransferFunction2D > > TransferFunctions2D
record modification and/or execution time
Definition: vtkTimeStamp.h:24
abstract specification for renderers
Definition: vtkRenderer.h:61
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
ComponentMode
Defines the various component modes supported by vtkGPUVolumeRayCastMapper.
vtkSmartPointer< vtkOpenGLVolumeLookupTables< vtkOpenGLVolumeOpacityTable > > OpacityTables
std::map< int, std::string > RGBTablesMap
Maps uniform texture variable names to its corresponding texture unit.
vtkSmartPointer< vtkVolumeTexture > Texture
std::string GradientCacheName
Stores the uniform variable name where the gradient will be stored for this input in the fragment sha...
The ShaderProgram uses one or more Shader objects.
std::map< int, std::string > TransferFunctions2DMap