VTK  9.4.20250102
vtkOpenGLBatchedPolyDataMapper.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
3
18#ifndef vtkOpenGLBatchedPolyDataMapper_h
19#define vtkOpenGLBatchedPolyDataMapper_h
20
22
23#include "vtkColor.h" // class uses vtkColor
24#include "vtkNew.h" // for ivar
25#include "vtkOpenGLCompositePolyDataMapperDelegator.h" // for struct BatchElement
26#include "vtkRenderingOpenGL2Module.h" // for export macro
27#include "vtkSmartPointer.h" // for arg
28#include "vtk_glad.h" // for OpenGL defs
29
30#include <cstdint> // for std::uintptr_t
31#include <memory> // for shared_ptr
32
33VTK_ABI_NAMESPACE_BEGIN
35class vtkPolyData;
36
37class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLBatchedPolyDataMapper : public vtkOpenGLPolyDataMapper
38{
39public:
42 void PrintSelf(ostream& os, vtkIndent indent) override;
43
45
50 void AddBatchElement(unsigned int flatIndex, BatchElement&& batchElement);
54
58 std::vector<vtkPolyData*> GetRenderedList() const;
60
64 void RenderPiece(vtkRenderer* renderer, vtkActor* actor) override;
67
73 vtkHardwareSelector* sel, std::vector<unsigned int>& pixeloffsets, vtkProp* prop) override;
74
76 GLBatchElement* glBatchElement, std::vector<unsigned int>& mypixels);
77
82
83protected:
86
87 void RenderPieceDraw(vtkRenderer* renderer, vtkActor* actor) override;
88 void UpdateCameraShiftScale(vtkRenderer* renderer, vtkActor* actoror) override;
89
93 void DrawIBO(vtkRenderer* renderer, vtkActor* actoror, int primType, vtkOpenGLHelper& CellBO,
94 GLenum mode, int pointSize);
95
99 virtual void SetShaderValues(
100 vtkShaderProgram* prog, GLBatchElement* glBatchElement, size_t primOffset);
101
106 void UpdateShaders(vtkOpenGLHelper& cellBO, vtkRenderer* renderer, vtkActor* actor) override;
107
113 std::map<vtkShader::Type, vtkShader*> shaders, vtkRenderer* renderer, vtkActor* actor) override;
114
118 bool GetNeedToRebuildBufferObjects(vtkRenderer* renderer, vtkActor* actor) override;
119
123 void BuildBufferObjects(vtkRenderer* renderer, vtkActor* actor) override;
124 virtual void AppendOneBufferObject(vtkRenderer* renderer, vtkActor* actor,
125 GLBatchElement* glBatchElement, vtkIdType& vertexOffset, std::vector<unsigned char>& colors,
126 std::vector<float>& norms);
127
132 vtkPolyData* poly, std::vector<unsigned int> (&indices)[4], vtkIdType offset) override;
133
140
141 // Reference to CPDM
142 vtkCompositePolyDataMapper* Parent = nullptr;
143 // Maps an address of a vtkPolyData to its rendering attributes.
144 std::map<std::uintptr_t, std::unique_ptr<GLBatchElement>> VTKPolyDataToGLBatchElement;
145 std::map<unsigned int, std::uintptr_t> FlatIndexToPolyData;
146 // Index arrays for vert, line, poly, strip, edge, stripedge
147 std::vector<unsigned int> IndexArray[PrimitiveEnd];
148 // Whether primitive IDs are used
150 // Whether override color is used for a vtkPolyData
152 // Reference to the current selector.
154 // used by the hardware selector
155 std::vector<std::vector<unsigned int>> PickPixels;
156 // cached array map
157 std::map<vtkAbstractArray*, vtkDataArray*> ColorArrayMap;
158
159private:
161 void operator=(const vtkOpenGLBatchedPolyDataMapper&) = delete;
162};
163
164VTK_ABI_NAMESPACE_END
165#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
a class that renders hierarchical polygonal data
general representation of visualization data
a simple class to control print indentation
Definition vtkIndent.h:108
An OpenGL mapper for batched rendering of vtkPolyData.
std::vector< vtkPolyData * > GetRenderedList() const
Accessor to the ordered list of PolyData that we last drew.
void ClearBatchElements()
API to add and query a GLBatchElement instance per vtkPolyData.
std::vector< std::vector< unsigned int > > PickPixels
void ReplaceShaderColor(std::map< vtkShader::Type, vtkShader * > shaders, vtkRenderer *renderer, vtkActor *actor) override
Perform string replacements on the shader templates, called from ReplaceShaderValues.
std::map< unsigned int, std::uintptr_t > FlatIndexToPolyData
BatchElement * GetBatchElement(vtkPolyData *polydata)
API to add and query a GLBatchElement instance per vtkPolyData.
void RenderPiece(vtkRenderer *renderer, vtkActor *actor) override
Implemented by sub classes.
void UpdateShaders(vtkOpenGLHelper &cellBO, vtkRenderer *renderer, vtkActor *actor) override
Make sure appropriate shaders are defined, compiled and bound.
void BuildSelectionIBO(vtkPolyData *poly, std::vector< unsigned int >(&indices)[4], vtkIdType offset) override
Build the selection IBOs, called by UpdateBufferObjects.
virtual void AppendOneBufferObject(vtkRenderer *renderer, vtkActor *actor, GLBatchElement *glBatchElement, vtkIdType &vertexOffset, std::vector< unsigned char > &colors, std::vector< float > &norms)
void RenderPieceDraw(vtkRenderer *renderer, vtkActor *actor) override
Implemented by sub classes.
void AddBatchElement(unsigned int flatIndex, BatchElement &&batchElement)
API to add and query a GLBatchElement instance per vtkPolyData.
void DrawIBO(vtkRenderer *renderer, vtkActor *actoror, int primType, vtkOpenGLHelper &CellBO, GLenum mode, int pointSize)
Draws primitives.
std::map< vtkAbstractArray *, vtkDataArray * > ColorArrayMap
int CanUseTextureMapForColoring(vtkDataObject *) override
Returns if we can use texture maps for scalar coloring.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void BuildBufferObjects(vtkRenderer *renderer, vtkActor *actor) override
Build the VBO/IBO, called by UpdateBufferObjects.
vtkMTimeType GetMTime() override
Returns the maximum of our and Parent vtkCompositePolyDataMapper's MTime.
void ProcessSelectorPixelBuffers(vtkHardwareSelector *sel, std::vector< unsigned int > &pixeloffsets, vtkProp *prop) override
allows a mapper to update a selections color buffers Called from a prop which in turn is called from ...
static vtkOpenGLBatchedPolyDataMapper * New()
virtual void SetShaderValues(vtkShaderProgram *prog, GLBatchElement *glBatchElement, size_t primOffset)
Applies rendering attributes for the corresponding polydata in the glBatchElement.
~vtkOpenGLBatchedPolyDataMapper() override
void UpdateCameraShiftScale(vtkRenderer *renderer, vtkActor *actoror) override
virtual void ProcessCompositePixelBuffers(vtkHardwareSelector *sel, vtkProp *prop, GLBatchElement *glBatchElement, std::vector< unsigned int > &mypixels)
std::map< std::uintptr_t, std::unique_ptr< GLBatchElement > > VTKPolyDataToGLBatchElement
bool GetNeedToRebuildBufferObjects(vtkRenderer *renderer, vtkActor *actor) override
Does the VBO/IBO need to be rebuilt.
void SetParent(vtkCompositePolyDataMapper *parent)
vtkCompositePolyDataMapperDelegator::BatchElement BatchElement
PolyDataMapper using OpenGL to render.
concrete dataset represents vertices, lines, polygons, and triangle strips
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:66
abstract specification for renderers
The ShaderProgram uses one or more Shader objects.
int vtkIdType
Definition vtkType.h:315
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270