VTK  9.4.20241103
vtkOpenGLLowMemoryBatchedPolyDataMapper.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
14#ifndef vtkOpenGLLowMemoryBatchedPolyDataMapper_h
15#define vtkOpenGLLowMemoryBatchedPolyDataMapper_h
16
17#include "vtkBoundingBox.h"
19
20#include "vtkColor.h" // class uses vtkColor
21#include "vtkNew.h" // for ivar
22#include "vtkOpenGLCompositePolyDataMapperDelegator.h" // for struct BatchElement
23#include "vtkRenderingOpenGL2Module.h" // for export macro
24#include "vtkSmartPointer.h" // for arg
25#include "vtk_glad.h" // for OpenGL defs
26
27#include <cstdint> // for std::uintptr_t
28#include <memory> // for shared_ptr
29
30VTK_ABI_NAMESPACE_BEGIN
32class vtkPolyData;
33
34class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLLowMemoryBatchedPolyDataMapper
36{
37public:
40 void PrintSelf(ostream& os, vtkIndent indent) override;
41
43
48 {
50 std::size_t CellGroupId;
51 };
52 void AddBatchElement(unsigned int flatIndex, BatchElement&& batchElement);
56
60 std::vector<vtkPolyData*> GetRenderedList() const;
62
66 void RenderPiece(vtkRenderer* renderer, vtkActor* actor) override;
69
75 vtkHardwareSelector* sel, std::vector<unsigned int>& pixeloffsets, vtkProp* prop) override;
76
78 GLBatchElement* glBatchElement, std::vector<unsigned int>& mypixels);
79
84
85protected:
88
89 void RenderPieceDraw(vtkRenderer* renderer, vtkActor* actor) override;
90
91 bool IsDataObjectUpToDate() override;
97 void UpdateShaders(vtkRenderer* renderer, vtkActor* actor) override;
98 void UpdateShiftScale(vtkRenderer* renderer, vtkActor* actor) override;
100 vtkRenderer* renderer, vtkActor* actor, std::string& vsSource, std::string& fsSource) override;
102
107 virtual void SetShaderValues(GLBatchElement* glBatchElement);
108
109 // Reference to CPDM
110 vtkCompositePolyDataMapper* Parent = nullptr;
111 // Maps an address of a vtkPolyData to its rendering attributes.
112 std::map<std::uintptr_t, std::unique_ptr<GLBatchElement>> VTKPolyDataToGLBatchElement;
113 // Whether override color is used for a vtkPolyData
115 // Reference to the current selector.
116 vtkHardwareSelector* CurrentSelector = nullptr;
117 // used by the hardware selector
118 std::vector<std::vector<unsigned int>> PickPixels;
119 // cached array map
120 std::map<vtkAbstractArray*, vtkDataArray*> ColorArrayMap;
121 // cached bbox of all points
123
124private:
126 void operator=(const vtkOpenGLLowMemoryBatchedPolyDataMapper&) = delete;
127};
128
129VTK_ABI_NAMESPACE_END
130#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
Fast, simple class for representing and operating on 3D bounds.
a class that renders hierarchical polygonal data
abstract superclass for arrays of numeric data
general representation of visualization data
a simple class to control print indentation
Definition vtkIndent.h:108
vtkCompositePolyDataMapperDelegator::BatchElement BatchElement
An OpenGL mapper for batched rendering of vtkPolyData.
std::vector< std::vector< unsigned int > > PickPixels
virtual void SetShaderValues(GLBatchElement *glBatchElement)
Applies rendering attributes for the corresponding polydata in the glBatchElement.
bool IsShaderNormalSourceUpToDate(vtkActor *actor) override
std::map< vtkAbstractArray *, vtkDataArray * > ColorArrayMap
void SetParent(vtkCompositePolyDataMapper *parent)
std::vector< vtkPolyData * > GetRenderedList() const
Accessor to the ordered list of PolyData that we last drew.
int CanUseTextureMapForColoring(vtkDataObject *) override
Returns if we can use texture maps for scalar coloring.
void RenderPiece(vtkRenderer *renderer, vtkActor *actor) override
Implemented by sub classes.
void DrawPrimitives(vtkRenderer *renderer, vtkActor *, PrimitiveInformation &primitive)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void AddBatchElement(unsigned int flatIndex, BatchElement &&batchElement)
API to add and query a GLBatchElement instance per vtkPolyData.
std::map< std::uintptr_t, std::unique_ptr< GLBatchElement > > VTKPolyDataToGLBatchElement
vtkMTimeType GetMTime() override
Returns the maximum of our and Parent vtkCompositePolyDataMapper's MTime.
static vtkOpenGLLowMemoryBatchedPolyDataMapper * New()
bool IsShaderColorSourceUpToDate(vtkActor *actor) override
vtkDataArray * GetColors(vtkPolyData *mesh) override
void RenderPieceDraw(vtkRenderer *renderer, vtkActor *actor) override
virtual void ProcessCompositePixelBuffers(vtkHardwareSelector *sel, vtkProp *prop, GLBatchElement *glBatchElement, std::vector< unsigned int > &mypixels)
void UpdateShaders(vtkRenderer *renderer, vtkActor *actor) override
void UpdateShiftScale(vtkRenderer *renderer, vtkActor *actor) override
void ReplaceShaderColor(vtkRenderer *renderer, vtkActor *actor, std::string &vsSource, std::string &fsSource) override
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 ...
bool BindArraysToTextureBuffers(vtkRenderer *renderer, vtkActor *actor, vtkCellGraphicsPrimitiveMap::CellTypeMapperOffsets &offsets) override
BatchElement * GetBatchElement(vtkPolyData *polydata)
API to add and query a GLBatchElement instance per vtkPolyData.
void ClearBatchElements()
API to add and query a GLBatchElement instance per vtkPolyData.
PolyDataMapper using OpenGL to render surface meshes.
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
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270