VTK  9.7.1
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 "vtkVolumeTexture.h" // For VolumeTexture
62 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
63 
64 VTK_ABI_NAMESPACE_BEGIN
67 class vtkTextureObject;
68 
69 class VTKRENDERINGVOLUMEOPENGL2_EXPORT VTK_MARSHALAUTO vtkOpenGLSurfaceProbeVolumeMapper
71 {
72 public:
75 
77 
81  void SetProbeInputData(vtkPolyData* in);
82  vtkPolyData* GetProbeInput();
83  void SetProbeInputConnection(vtkAlgorithmOutput* algOutput);
85 
87 
90  void SetSourceData(vtkImageData* in);
91  vtkImageData* GetSource();
92  void SetSourceConnection(vtkAlgorithmOutput* algOutput);
94 
102  vtkSetSmartPointerMacro(VolumeTexture, vtkVolumeTexture);
103 
105 
111  double GetWindow() { return this->ScalarRange[1] - this->ScalarRange[0]; }
112  void SetWindow(double window)
113  {
114  double level = this->GetLevel();
115  this->SetScalarRange(level - 0.5 * window, level + 0.5 * window);
116  }
117 
118  double GetLevel() { return 0.5 * (this->ScalarRange[0] + this->ScalarRange[1]); }
119  void SetLevel(double level)
120  {
121  double window = this->GetWindow();
122  this->SetScalarRange(level - 0.5 * window, level + 0.5 * window);
123  }
125 
127 
133  enum class BlendModes : unsigned int
134  {
135  NONE = 0,
136  MAX,
137  MIN,
138  AVERAGE
139  };
140 
141  vtkGetEnumMacro(BlendMode, BlendModes);
142  vtkSetEnumMacro(BlendMode, BlendModes);
143  void SetBlendModeToNone() { this->SetBlendMode(BlendModes::NONE); }
144  void SetBlendModeToMaximumIntensity() { this->SetBlendMode(BlendModes::MAX); }
145  void SetBlendModeToMinimumIntensity() { this->SetBlendMode(BlendModes::MIN); }
146  void SetBlendModeToAverageIntensity() { this->SetBlendMode(BlendModes::AVERAGE); }
148 
150 
153  vtkGetMacro(BlendWidth, double);
154  vtkSetMacro(BlendWidth, double);
156 
157  void RenderPiece(vtkRenderer* ren, vtkActor* act) override;
158 
159  void UpdateShaders(vtkOpenGLHelper& cellBO, vtkRenderer* ren, vtkActor* act) override;
160 
161  using vtkMapper::MapScalars;
167  vtkUnsignedCharArray* MapScalars(vtkDataSet* input, double alpha, int& cellFlag) override;
168 
175  bool HasTranslucentPolygonalGeometry() override;
176 
181  void CreateDefaultLookupTable() override {};
182 
183 protected:
184  int FillInputPortInformation(int port, vtkInformation* info) override;
185 
186  virtual void ReplaceShaderPositionPass(vtkActor* act);
187  virtual void ReplaceShaderProbePass(vtkActor* act);
188  virtual void UpdateShadersProbePass(vtkOpenGLHelper& cellBO, vtkRenderer* ren);
189 
190 private:
193 
194  void CreateTexture(vtkTextureObject*, vtkOpenGLRenderWindow*);
195  void ReplaceActiveFBO(vtkRenderer*);
196  void RestoreActiveFBO(vtkRenderer*);
197 
199 
200  vtkNew<vtkTextureObject> PositionsTextureObject;
201  vtkNew<vtkTextureObject> NormalsTextureObject;
202  vtkSmartPointer<vtkVolumeTexture> VolumeTexture;
203 
204  vtkNew<vtkImageData> TransformedSource;
205 
206  // Internal pass type used for shader updates
207  enum class PassTypes : unsigned int
208  {
209  DEFAULT = 0,
210  POSITION_TEXTURE,
211  PROBE
212  };
213  PassTypes CurrentPass = PassTypes::DEFAULT;
214 
215  // Blend mode
216  BlendModes BlendMode = BlendModes::NONE;
217  double BlendWidth = 1.0;
218 
219  // Saved state
220  bool SavedScissorTestState = false;
221  bool SavedBlendState = false;
222  int SavedViewport[4] = {};
223 };
224 
225 VTK_ABI_NAMESPACE_END
226 #endif
OpenGL rendering window.
PolyDataMapper using OpenGL to render.
void SetWindow(double window)
Convienence methods to set the window and level values used for scalar coloring, which ultimately set...
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
static vtkOpenGLPolyDataMapper * New()
void SetBlendModeToMinimumIntensity()
Set/Get the blend mode.
Store vtkAlgorithm input/output information.
Creates and manages the volume texture rendered by vtkOpenGLGPUVolumeRayCastMapper.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
double GetLevel()
Convienence methods to set the window and level values used for scalar coloring, which ultimately set...
void SetBlendModeToAverageIntensity()
Set/Get the blend mode.
virtual bool HasTranslucentPolygonalGeometry()
Some introspection on the type of data the mapper will render used by props to determine if they shou...
void SetBlendModeToMaximumIntensity()
Set/Get the blend mode.
void SetLevel(double level)
Convienence methods to set the window and level values used for scalar coloring, which ultimately set...
abstract specification for renderers
Definition: vtkRenderer.h:63
virtual void UpdateShaders(vtkOpenGLHelper &cellBO, vtkRenderer *ren, vtkActor *act)
Make sure appropriate shaders are defined, compiled and bound.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
void CreateDefaultLookupTable() override
Defined as no-op to prevent the creation of a default lookup table in GetLookupTable.
Proxy object to connect input/output ports.
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
void RenderPiece(vtkRenderer *ren, vtkActor *act) override
Implemented by sub classes.
virtual void SetScalarRange(double, double)
Specify range in terms of scalar minimum and maximum (smin,smax).
Internal class which encapsulates OpenGL FramebufferObject.
dynamic, self-adjusting array of unsigned char
int FillInputPortInformation(int, vtkInformation *) override
Fill the input port information objects for this algorithm.
abstracts an OpenGL texture object.
#define VTK_MARSHALAUTO
PolyDataMapper colored with probed volume data.
virtual vtkUnsignedCharArray * MapScalars(double alpha)
Map the scalars (if there are any scalars and ScalarVisibility is on) through the lookup table...
double GetWindow()
Convienence methods to set the window and level values used for scalar coloring, which ultimately set...