forked from Kitware/VTK
/
vtkCompositePolyDataMapper2Internal.h
147 lines (119 loc) · 4.31 KB
/
vtkCompositePolyDataMapper2Internal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// this class encapsulates values tied to a
// polydata
class vtkCompositeMapperHelperData
{
public:
vtkPolyData *Data;
unsigned int FlatIndex;
double Opacity;
bool Visibility;
bool Pickability;
bool OverridesColor;
vtkColor3d AmbientColor;
vtkColor3d DiffuseColor;
bool Marked;
unsigned int StartVertex;
unsigned int NextVertex;
// point line poly strip edge stripedge
unsigned int StartIndex[vtkOpenGLPolyDataMapper::PrimitiveEnd];
unsigned int NextIndex[vtkOpenGLPolyDataMapper::PrimitiveEnd];
// Point Line Poly Strip end
size_t PrimOffsets[5];
bool Different(
vtkCompositeMapperHelperData *next,
vtkHardwareSelector *selector,
int primType)
{
return
(selector &&
selector->GetCurrentPass() ==
vtkHardwareSelector::COMPOSITE_INDEX_PASS) ||
this->Opacity != next->Opacity ||
this->Visibility != next->Visibility ||
this->Pickability != next->Pickability ||
this->OverridesColor != next->OverridesColor ||
this->AmbientColor != next->AmbientColor ||
this->DiffuseColor != next->DiffuseColor ||
(primType >= 0 && primType <= 3 &&
this->PrimOffsets[primType+1] != next->PrimOffsets[primType]);
}
};
//===================================================================
// We define a helper class that is a subclass of vtkOpenGLPolyDataMapper
class VTKRENDERINGOPENGL2_EXPORT vtkCompositeMapperHelper2 : public vtkOpenGLPolyDataMapper
{
public:
static vtkCompositeMapperHelper2* New();
vtkTypeMacro(vtkCompositeMapperHelper2, vtkOpenGLPolyDataMapper);
void SetParent(vtkCompositePolyDataMapper2 *p) {
this->Parent = p; }
vtkCompositeMapperHelperData *AddData(vtkPolyData *pd, unsigned int flatIndex);
// Description:
// Implemented by sub classes. Actual rendering is done here.
void RenderPiece(vtkRenderer *ren, vtkActor *act) override;
// keep track of what data is being used as the multiblock
// can change
void ClearMark();
void RemoveUnused();
bool GetMarked() { return this->Marked; }
void SetMarked(bool v) { this->Marked = v; }
/**
* Accessor to the ordered list of PolyData that we last drew.
*/
std::vector<vtkPolyData*> GetRenderedList(){ return this->RenderedList; }
protected:
vtkCompositePolyDataMapper2 *Parent;
std::map<vtkPolyData *, vtkCompositeMapperHelperData *> Data;
bool Marked;
vtkCompositeMapperHelper2()
{
this->Parent = nullptr;
};
~vtkCompositeMapperHelper2() override;
void DrawIBO(
vtkRenderer* ren, vtkActor *actor,
int primType,
vtkOpenGLHelper &CellBO,
GLenum mode,
int pointSize);
void SetShaderValues(
vtkShaderProgram *prog,
vtkCompositeMapperHelperData *hdata,
size_t primOffset);
// Description:
// Perform string replacments on the shader templates, called from
// ReplaceShaderValues
void ReplaceShaderColor(
std::map<vtkShader::Type, vtkShader *> shaders,
vtkRenderer *ren, vtkActor *act) override;
// Description:
// Determine if the buffer objects need to be rebuilt
bool GetNeedToRebuildBufferObjects(vtkRenderer *ren, vtkActor *act) override;
// Description:
// Build the VBO/IBO, called by UpdateBufferObjects
void BuildBufferObjects(vtkRenderer *ren, vtkActor *act) override;
virtual void AppendOneBufferObject(vtkRenderer *ren,
vtkActor *act, vtkCompositeMapperHelperData *hdata,
unsigned int &flat_index,
std::vector<unsigned char> &colors,
std::vector<float> &norms);
// Description:
// Returns if we can use texture maps for scalar coloring. Note this doesn't
// say we "will" use scalar coloring. It says, if we do use scalar coloring,
// we will use a texture. Always off for this mapper.
int CanUseTextureMapForColoring(vtkDataObject*) override;
std::vector<unsigned int> VertexOffsets;
// vert line poly strip edge stripedge
std::vector<unsigned int> IndexArray[PrimitiveEnd];
void RenderPieceDraw(vtkRenderer *ren, vtkActor *act) override;
bool PrimIDUsed;
bool OverideColorUsed;
vtkHardwareSelector *CurrentSelector;
double CurrentAmbientIntensity;
double CurrentDiffuseIntensity;
std::vector<vtkPolyData*> RenderedList;
private:
vtkCompositeMapperHelper2(const vtkCompositeMapperHelper2&) = delete;
void operator=(const vtkCompositeMapperHelper2&) = delete;
};
// VTK-HeaderTest-Exclude: vtkCompositePolyDataMapper2Internal.h