VTK
vtkValuePass.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkValuePass.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 =========================================================================*/
43 #ifndef vtkValuePass_h
44 #define vtkValuePass_h
45 
46 #include "vtkOpenGLRenderPass.h"
47 #include "vtkRenderingOpenGL2Module.h" // For export macro
48 #include "vtkSmartPointer.h" //for ivar
49 
50 class vtkAbstractArray;
51 class vtkActor;
52 class vtkDataArray;
53 class vtkDataObject;
54 class vtkFloatArray;
55 class vtkMapper;
57 class vtkProperty;
58 class vtkRenderer;
59 class vtkRenderWindow;
60 class vtkShaderProgram;
61 
62 class VTKRENDERINGOPENGL2_EXPORT vtkValuePass : public vtkOpenGLRenderPass
63 {
64 public:
65 
66  enum Mode
67  {
68  INVERTIBLE_LUT = 1,
69  FLOATING_POINT = 2
70  };
71 
72  static vtkValuePass *New();
74  void PrintSelf(ostream& os, vtkIndent indent) override;
75 
76  vtkSetMacro(RenderingMode, int);
77  vtkGetMacro(RenderingMode, int);
78  void SetInputArrayToProcess(int fieldAssociation, const char *name);
79  void SetInputArrayToProcess(int fieldAssociation, int fieldId);
80  void SetInputComponentToProcess(int component);
81  void SetScalarRange(double min, double max);
82 
87  void Render(const vtkRenderState *s) override;
88 
94  vtkFloatArray* GetFloatImageDataArray(vtkRenderer* ren);
95 
101  void GetFloatImageData(int const format, int const width, int const height,
102  void* data);
103 
108  int* GetFloatImageExtents();
109 
113  bool IsFloatingPointModeSupported();
114 
115  void ReleaseGraphicsResources(vtkWindow *win) override;
116 
121  void ColorToValue(unsigned char const* color, double const min, double const scale,
122  double& value);
123 
124  protected:
125  vtkValuePass();
126  ~vtkValuePass() override;
127 
129 
138  bool PostReplaceShaderValues(std::string &vertexShader,
139  std::string &geometryShader,
140  std::string &fragmentShader,
141  vtkAbstractMapper *mapper,
142  vtkProp *prop) override;
148  vtkAbstractMapper* mapper, vtkProp* prop,
149  vtkOpenGLVertexArrayObject* VAO = nullptr) override;
159 
164  void BeginPass(vtkRenderer* ren);
165 
169  void EndPass();
170 
175  void RenderOpaqueGeometry(const vtkRenderState *s);
176 
180  void RenderPieceFinish();
181 
185  void RenderPieceStart(vtkDataArray* dataArr, vtkMapper *m);
186 
191  void BeginMapperRender(vtkMapper* mapper, vtkDataArray* dataArray,
192  vtkProperty* property);
193 
197  void EndMapperRender(vtkMapper* mapper, vtkProperty* property);
198 
199  void InitializeBuffers(vtkRenderer* ren);
200 
204  bool UpdateShaders(std::string& VSSource, std::string& FSSource);
205 
209  void BindAttributes(vtkShaderProgram* prog, vtkOpenGLVertexArrayObject* VAO);
210  void BindUniforms(vtkShaderProgram* prog);
211 
213 
216  bool HasWindowSizeChanged(vtkRenderer* ren);
217  bool InitializeFBO(vtkRenderer* ren);
218  void ReleaseFBO(vtkWindow* win);
220 
221  class vtkInternalsFloat;
222  vtkInternalsFloat* ImplFloat;
223 
224  class vtkInternalsInvertible;
225  vtkInternalsInvertible* ImplInv;
226 
227  struct Parameters;
228  Parameters* PassState;
229 
231 
232  private:
233  vtkDataArray* GetCurrentArray(vtkMapper* mapper, Parameters* arrayPar);
234 
235  vtkAbstractArray* GetArrayFromCompositeData(vtkMapper* mapper,
236  Parameters* arrayPar);
237 
238  vtkSmartPointer<vtkAbstractArray> MultiBlocksArray;
239 
240  void PopulateCellCellMap(const vtkRenderState *s);
241 
242  vtkValuePass(const vtkValuePass&) = delete;
243  void operator=(const vtkValuePass&) = delete;
244 };
245 
246 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
represent surface properties of a geometric object
Definition: vtkProperty.h:66
Abstract superclass for all arrays.
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
Parameters * PassState
Definition: vtkValuePass.h:227
abstract specification for renderers
Definition: vtkRenderer.h:63
vtkInternalsFloat * ImplFloat
Definition: vtkValuePass.h:221
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
Context in which a vtkRenderPass will render.
a simple class to control print indentation
Definition: vtkIndent.h:39
The VertexArrayObject class uses, or emulates, vertex array objects.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
Renders geometry using the values of a field array as fragment colors.
Definition: vtkValuePass.h:62
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:86
abstract class specifies interface to map data
create a window for renderers to draw into
virtual void Render(const vtkRenderState *s)=0
Perform rendering according to a render state s.
virtual vtkMTimeType GetShaderStageMTime()
For multi-stage render passes that need to change shader code during a single pass, use this method to notify a mapper that the shader needs to be rebuilt (rather than reuse the last cached shader.
vtkInternalsInvertible * ImplInv
Definition: vtkValuePass.h:224
virtual void ReleaseGraphicsResources(vtkWindow *w)
Release graphics resources and ask components to release their own resources.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual bool SetShaderParameters(vtkShaderProgram *program, vtkAbstractMapper *mapper, vtkProp *prop, vtkOpenGLVertexArrayObject *VAO=nullptr)
Update the uniforms of the shader program.
Abstract render pass with shader modifications.
virtual bool PostReplaceShaderValues(std::string &vertexShader, std::string &geometryShader, std::string &fragmentShader, vtkAbstractMapper *mapper, vtkProp *prop)
Use vtkShaderProgram::Substitute to replace //VTK::XXX:YYY declarations in the shader sources...
general representation of visualization data
Definition: vtkDataObject.h:64
#define max(a, b)
The ShaderProgram uses one or more Shader objects.