VTK  9.0.20200806
vtkCompositePolyDataMapper2Internal.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4 
5  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 
15 #ifndef vtkCompositeMapperHelper2_h
16 #define vtkCompositeMapperHelper2_h
17 
18 #ifndef __VTK_WRAP__
19 
20 #include "vtkColor.h"
22 #include "vtkRenderingOpenGL2Module.h"
23 
24 class vtkPolyData;
26 
27 // this class encapsulates values tied to a
28 // polydata
30 {
31 public:
33  unsigned int FlatIndex;
34  double Opacity;
35  bool IsOpaque;
36  bool Visibility;
43 
44  bool Marked;
45 
46  unsigned int StartVertex;
47  unsigned int NextVertex;
48 
49  // point line poly strip edge stripedge
52 
53  // stores the mapping from vtk cells to gl_PrimitiveId
55 };
56 
57 //===================================================================
58 // We define a helper class that is a subclass of vtkOpenGLPolyDataMapper
59 class VTKRENDERINGOPENGL2_EXPORT vtkCompositeMapperHelper2 : public vtkOpenGLPolyDataMapper
60 {
61 public:
64 
65  void SetParent(vtkCompositePolyDataMapper2* p) { this->Parent = p; }
66 
67  vtkCompositeMapperHelperData* AddData(vtkPolyData* pd, unsigned int flatIndex);
68 
72  void RenderPiece(vtkRenderer* ren, vtkActor* act) override;
73 
74  // keep track of what data is being used as the multiblock
75  // can change
76  void ClearMark();
77  void RemoveUnused();
78  bool GetMarked() { return this->Marked; }
79  void SetMarked(bool v) { this->Marked = v; }
80 
84  std::vector<vtkPolyData*> GetRenderedList() { return this->RenderedList; }
85 
91  vtkHardwareSelector* sel, std::vector<unsigned int>& pixeloffsets, vtkProp* prop) override;
92 
93  virtual void ProcessCompositePixelBuffers(vtkHardwareSelector* sel, vtkProp* prop,
94  vtkCompositeMapperHelperData* hdata, std::vector<unsigned int>& mypixels);
95 
96 protected:
98  std::map<vtkPolyData*, vtkCompositeMapperHelperData*> Data;
99 
100  bool Marked;
101 
102  // handle updating shift scale based on pose changes
103  void UpdateCameraShiftScale(vtkRenderer* ren, vtkActor* actor) override;
104 
105  vtkCompositeMapperHelper2() { this->Parent = nullptr; };
106  ~vtkCompositeMapperHelper2() override;
107 
108  void DrawIBO(vtkRenderer* ren, vtkActor* actor, int primType, vtkOpenGLHelper& CellBO,
109  GLenum mode, int pointSize);
110 
111  virtual void SetShaderValues(
112  vtkShaderProgram* prog, vtkCompositeMapperHelperData* hdata, size_t primOffset);
113 
118  void UpdateShaders(vtkOpenGLHelper& cellBO, vtkRenderer* ren, vtkActor* act) override;
119 
124  void ReplaceShaderColor(
125  std::map<vtkShader::Type, vtkShader*> shaders, vtkRenderer* ren, vtkActor* act) override;
126 
130  void BuildBufferObjects(vtkRenderer* ren, vtkActor* act) override;
131  virtual void AppendOneBufferObject(vtkRenderer* ren, vtkActor* act,
132  vtkCompositeMapperHelperData* hdata, vtkIdType& flat_index, std::vector<unsigned char>& colors,
133  std::vector<float>& norms);
134 
138  void BuildSelectionIBO(
139  vtkPolyData* poly, std::vector<unsigned int> (&indices)[4], vtkIdType offset) override;
140 
147 
148  std::vector<unsigned int> VertexOffsets;
149 
150  // vert line poly strip edge stripedge
151  std::vector<unsigned int> IndexArray[PrimitiveEnd];
152 
153  void RenderPieceDraw(vtkRenderer* ren, vtkActor* act) override;
154 
157 
159 
160  // bookkeeping required by vtkValuePass
161  std::vector<vtkPolyData*> RenderedList;
162 
163  // used by the hardware selector
164  std::vector<std::vector<unsigned int>> PickPixels;
165 
166  std::map<vtkAbstractArray*, vtkDataArray*> ColorArrayMap;
167 
168 private:
170  void operator=(const vtkCompositeMapperHelper2&) = delete;
171 };
172 
173 #endif
174 
175 #endif
176 // VTK-HeaderTest-Exclude: vtkCompositePolyDataMapper2Internal.h
vtkOpenGLPolyDataMapper::BuildBufferObjects
virtual void BuildBufferObjects(vtkRenderer *ren, vtkActor *act)
Build the VBO/IBO, called by UpdateBufferObjects.
vtkCompositeMapperHelperData::NextVertex
unsigned int NextVertex
Definition: vtkCompositePolyDataMapper2Internal.h:47
vtkCompositeMapperHelper2::Data
std::map< vtkPolyData *, vtkCompositeMapperHelperData * > Data
Definition: vtkCompositePolyDataMapper2Internal.h:98
vtkOpenGLPolyDataMapper::BuildSelectionIBO
virtual void BuildSelectionIBO(vtkPolyData *poly, std::vector< unsigned int >(&indices)[4], vtkIdType offset)
Build the selection IBO, called by UpdateBufferObjects.
vtkCompositeMapperHelperData::StartVertex
unsigned int StartVertex
Definition: vtkCompositePolyDataMapper2Internal.h:46
vtkCompositeMapperHelperData::AmbientColor
vtkColor3d AmbientColor
Definition: vtkCompositePolyDataMapper2Internal.h:39
vtkCompositeMapperHelper2::SetParent
void SetParent(vtkCompositePolyDataMapper2 *p)
Definition: vtkCompositePolyDataMapper2Internal.h:65
vtkOpenGLPolyDataMapper::UpdateShaders
virtual void UpdateShaders(vtkOpenGLHelper &cellBO, vtkRenderer *ren, vtkActor *act)
Make sure appropriate shaders are defined, compiled and bound.
vtkIdType
int vtkIdType
Definition: vtkType.h:330
vtkCompositeMapperHelper2::OverideColorUsed
bool OverideColorUsed
Definition: vtkCompositePolyDataMapper2Internal.h:156
vtkCompositeMapperHelperData::FlatIndex
unsigned int FlatIndex
Definition: vtkCompositePolyDataMapper2Internal.h:33
vtkCompositeMapperHelperData::Data
vtkPolyData * Data
Definition: vtkCompositePolyDataMapper2Internal.h:32
vtkCompositeMapperHelperData::SelectionColor
vtkColor3d SelectionColor
Definition: vtkCompositePolyDataMapper2Internal.h:41
vtkCompositeMapperHelperData::NextIndex
unsigned int NextIndex[vtkOpenGLPolyDataMapper::PrimitiveEnd]
Definition: vtkCompositePolyDataMapper2Internal.h:51
vtkOpenGLPolyDataMapper::New
static vtkOpenGLPolyDataMapper * New()
vtkOpenGLPolyDataMapper::RenderPieceDraw
virtual void RenderPieceDraw(vtkRenderer *ren, vtkActor *act)
vtkMapper::CanUseTextureMapForColoring
virtual int CanUseTextureMapForColoring(vtkDataObject *input)
Returns if we can use texture maps for scalar coloring.
vtkCompositeMapperHelper2::SetMarked
void SetMarked(bool v)
Definition: vtkCompositePolyDataMapper2Internal.h:79
vtkCompositePolyDataMapper2
mapper for composite dataset consisting of polygonal data.
Definition: vtkCompositePolyDataMapper2.h:47
vtkCompositeMapperHelperData::SelectionOpacity
double SelectionOpacity
Definition: vtkCompositePolyDataMapper2Internal.h:42
vtkCompositeMapperHelperData
Definition: vtkCompositePolyDataMapper2Internal.h:29
vtkCompositeMapperHelper2::CurrentSelector
vtkHardwareSelector * CurrentSelector
Definition: vtkCompositePolyDataMapper2Internal.h:158
vtkCompositeMapperHelperData::Marked
bool Marked
Definition: vtkCompositePolyDataMapper2Internal.h:44
vtkOpenGLPolyDataMapper::PrimitiveEnd
Definition: vtkOpenGLPolyDataMapper.h:209
vtkCompositeMapperHelper2::Marked
bool Marked
Definition: vtkCompositePolyDataMapper2Internal.h:100
vtkCompositeMapperHelper2
Definition: vtkCompositePolyDataMapper2Internal.h:59
vtkX3D::offset
Definition: vtkX3D.h:444
vtkCompositeMapperHelperData::DiffuseColor
vtkColor3d DiffuseColor
Definition: vtkCompositePolyDataMapper2Internal.h:40
vtkCompositeMapperHelper2::PickPixels
std::vector< std::vector< unsigned int > > PickPixels
Definition: vtkCompositePolyDataMapper2Internal.h:164
vtkShaderProgram
The ShaderProgram uses one or more Shader objects.
Definition: vtkShaderProgram.h:44
vtkHardwareSelector
Definition: vtkHardwareSelector.h:123
vtkColor.h
vtkOpenGLHelper
Definition: vtkOpenGLHelper.h:30
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkCompositeMapperHelperData::CellCellMap
vtkNew< vtkOpenGLCellToVTKCellMap > CellCellMap
Definition: vtkCompositePolyDataMapper2Internal.h:54
vtkCompositeMapperHelperData::Opacity
double Opacity
Definition: vtkCompositePolyDataMapper2Internal.h:34
vtkCompositeMapperHelper2::ColorArrayMap
std::map< vtkAbstractArray *, vtkDataArray * > ColorArrayMap
Definition: vtkCompositePolyDataMapper2Internal.h:166
vtkCompositeMapperHelperData::IsOpaque
bool IsOpaque
Definition: vtkCompositePolyDataMapper2Internal.h:35
vtkNew< vtkOpenGLCellToVTKCellMap >
vtkCompositeMapperHelperData::StartIndex
unsigned int StartIndex[vtkOpenGLPolyDataMapper::PrimitiveEnd]
Definition: vtkCompositePolyDataMapper2Internal.h:50
vtkCompositeMapperHelper2::RenderedList
std::vector< vtkPolyData * > RenderedList
Definition: vtkCompositePolyDataMapper2Internal.h:161
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
vtkCompositeMapperHelperData::Pickability
bool Pickability
Definition: vtkCompositePolyDataMapper2Internal.h:37
vtkOpenGLPolyDataMapper::RenderPiece
void RenderPiece(vtkRenderer *ren, vtkActor *act) override
Implemented by sub classes.
vtkColor3d
Definition: vtkColor.h:246
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:67
vtkCompositeMapperHelperData::Visibility
bool Visibility
Definition: vtkCompositePolyDataMapper2Internal.h:36
vtkOpenGLPolyDataMapper::ProcessSelectorPixelBuffers
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 ...
vtkCompositeMapperHelper2::vtkCompositeMapperHelper2
vtkCompositeMapperHelper2()
Definition: vtkCompositePolyDataMapper2Internal.h:105
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkCompositeMapperHelper2::VertexOffsets
std::vector< unsigned int > VertexOffsets
Definition: vtkCompositePolyDataMapper2Internal.h:148
vtkCompositeMapperHelper2::GetMarked
bool GetMarked()
Definition: vtkCompositePolyDataMapper2Internal.h:78
vtkX3D::mode
Definition: vtkX3D.h:253
vtkCompositeMapperHelper2::Parent
vtkCompositePolyDataMapper2 * Parent
Definition: vtkCompositePolyDataMapper2Internal.h:97
vtkOpenGLPolyDataMapper::ReplaceShaderColor
virtual void ReplaceShaderColor(std::map< vtkShader::Type, vtkShader * > shaders, vtkRenderer *ren, vtkActor *act)
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:59
vtkOpenGLPolyDataMapper.h
vtkOpenGLPolyDataMapper
PolyDataMapper using OpenGL to render.
Definition: vtkOpenGLPolyDataMapper.h:58
vtkCompositeMapperHelperData::OverridesColor
bool OverridesColor
Definition: vtkCompositePolyDataMapper2Internal.h:38
vtkCompositeMapperHelper2::GetRenderedList
std::vector< vtkPolyData * > GetRenderedList()
Accessor to the ordered list of PolyData that we last drew.
Definition: vtkCompositePolyDataMapper2Internal.h:84
vtkCompositeMapperHelper2::PrimIDUsed
bool PrimIDUsed
Definition: vtkCompositePolyDataMapper2Internal.h:155
vtkOpenGLPolyDataMapper::UpdateCameraShiftScale
virtual void UpdateCameraShiftScale(vtkRenderer *ren, vtkActor *actor)