VTK  9.5.20251009
vtkOpenGLSurfaceProbeVolumeMapper.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
55#ifndef vtkOpenGLSurfaceProbeVolumeMapper_h
56#define vtkOpenGLSurfaceProbeVolumeMapper_h
57
58#include "vtkNew.h" // For vtkNew
60#include "vtkRenderingVolumeOpenGL2Module.h" // For export macro
61#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
62
63VTK_ABI_NAMESPACE_BEGIN
68
69class VTKRENDERINGVOLUMEOPENGL2_EXPORT VTK_MARSHALAUTO vtkOpenGLSurfaceProbeVolumeMapper
71{
72public:
75
77
85
87
94
96
102 double GetWindow() { return this->ScalarRange[1] - this->ScalarRange[0]; }
103 void SetWindow(double window)
104 {
105 double level = this->GetLevel();
106 this->SetScalarRange(level - 0.5 * window, level + 0.5 * window);
107 }
108
109 double GetLevel() { return 0.5 * (this->ScalarRange[0] + this->ScalarRange[1]); }
110 void SetLevel(double level)
111 {
112 double window = this->GetWindow();
113 this->SetScalarRange(level - 0.5 * window, level + 0.5 * window);
114 }
116
118
124 enum class BlendModes : unsigned int
125 {
126 NONE = 0,
127 MAX,
128 MIN,
129 AVERAGE
130 };
131
134 void SetBlendModeToNone() { this->SetBlendMode(BlendModes::NONE); }
135 void SetBlendModeToMaximumIntensity() { this->SetBlendMode(BlendModes::MAX); }
136 void SetBlendModeToMinimumIntensity() { this->SetBlendMode(BlendModes::MIN); }
137 void SetBlendModeToAverageIntensity() { this->SetBlendMode(BlendModes::AVERAGE); }
139
141
144 vtkGetMacro(BlendWidth, double);
145 vtkSetMacro(BlendWidth, double);
147
148 void RenderPiece(vtkRenderer* ren, vtkActor* act) override;
149
150 void UpdateShaders(vtkOpenGLHelper& cellBO, vtkRenderer* ren, vtkActor* act) override;
151
158 vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha, int& cellFlag) override;
159
167
172 void CreateDefaultLookupTable() override{};
173
174protected:
175 int FillInputPortInformation(int port, vtkInformation* info) override;
176
180
181private:
184
185 void CreateTexture(vtkTextureObject*, vtkOpenGLRenderWindow*);
186 void ReplaceActiveFBO(vtkRenderer*);
187 void RestoreActiveFBO(vtkRenderer*);
188
190
191 vtkNew<vtkTextureObject> PositionsTextureObject;
192 vtkNew<vtkTextureObject> NormalsTextureObject;
193 vtkNew<vtkVolumeTexture> VolumeTexture;
194
195 vtkNew<vtkImageData> TransformedSource;
196
197 // Internal pass type used for shader updates
198 enum class PassTypes : unsigned int
199 {
200 DEFAULT = 0,
201 POSITION_TEXTURE,
202 PROBE
203 };
204 PassTypes CurrentPass = PassTypes::DEFAULT;
205
206 // Blend mode
207 BlendModes BlendMode = BlendModes::NONE;
208 double BlendWidth = 1.0;
209
210 // Saved state
211 bool SavedScissorTestState = false;
212 bool SavedBlendState = false;
213 int SavedViewport[4] = {};
214};
215
216VTK_ABI_NAMESPACE_END
217#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
Proxy object to connect input/output ports.
abstract class to specify dataset behavior
Definition vtkDataSet.h:166
topologically and geometrically regular array of data
Store vtkAlgorithm input/output information.
virtual vtkUnsignedCharArray * MapScalars(double alpha)
Map the scalars (if there are any scalars and ScalarVisibility is on) through the lookup table,...
virtual void SetScalarRange(double, double)
Specify range in terms of scalar minimum and maximum (smin,smax).
Allocate and hold a VTK object.
Definition vtkNew.h:167
Internal class which encapsulates OpenGL FramebufferObject.
PolyDataMapper using OpenGL to render.
OpenGL rendering window.
PolyDataMapper colored with probed volume data.
void SetBlendModeToMaximumIntensity()
Set/Get the blend mode.
void UpdateShaders(vtkOpenGLHelper &cellBO, vtkRenderer *ren, vtkActor *act) override
Make sure appropriate shaders are defined, compiled and bound.
vtkImageData * GetSource()
Specify the input data to be probed.
vtkPolyData * GetProbeInput()
Specify the input data used for probing (optional).
void SetSourceData(vtkImageData *in)
Specify the input data to be probed.
void SetSourceConnection(vtkAlgorithmOutput *algOutput)
Specify the input data to be probed.
bool HasTranslucentPolygonalGeometry() override
Determine whether this mapper should be invoked on a specific rendering pass.
virtual void UpdateShadersProbePass(vtkOpenGLHelper &cellBO, vtkRenderer *ren)
virtual void ReplaceShaderPositionPass(vtkActor *act)
void SetBlendModeToAverageIntensity()
Set/Get the blend mode.
vtkSetEnumMacro(BlendMode, BlendModes)
Set/Get the blend mode.
vtkUnsignedCharArray * MapScalars(vtkDataSet *input, double alpha, int &cellFlag) override
Map the scalars of the source through the lookup table if any.
virtual void ReplaceShaderProbePass(vtkActor *act)
void SetWindow(double window)
Convienence methods to set the window and level values used for scalar coloring, which ultimately set...
void SetLevel(double level)
Convienence methods to set the window and level values used for scalar coloring, which ultimately set...
void CreateDefaultLookupTable() override
Defined as no-op to prevent the creation of a default lookup table in GetLookupTable.
double GetWindow()
Convienence methods to set the window and level values used for scalar coloring, which ultimately set...
void SetProbeInputConnection(vtkAlgorithmOutput *algOutput)
Specify the input data used for probing (optional).
void RenderPiece(vtkRenderer *ren, vtkActor *act) override
Implemented by sub classes.
double GetLevel()
Convienence methods to set the window and level values used for scalar coloring, which ultimately set...
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
void SetBlendModeToMinimumIntensity()
Set/Get the blend mode.
void SetProbeInputData(vtkPolyData *in)
Specify the input data used for probing (optional).
static vtkOpenGLSurfaceProbeVolumeMapper * New()
vtkGetEnumMacro(BlendMode, BlendModes)
Set/Get the blend mode.
concrete dataset represents vertices, lines, polygons, and triangle strips
abstract specification for renderers
abstracts an OpenGL texture object.
dynamic, self-adjusting array of unsigned char
Creates and manages the volume texture rendered by vtkOpenGLGPUVolumeRayCastMapper.
#define VTK_MARSHALAUTO