VAPOR3 3.9.4
WireFrameRenderer.h
Go to the documentation of this file.
1//---------------- ----------------------------------------------------------
2//
3// Copyright (C) 2018
4// University Corporation for Atmospheric Research
5// All Rights Reserved
6//
7//----------------------------------------------------------------------------
8
9#ifndef WIREFRAMERENDERER_H
10#define WIREFRAMERENDERER_H
11
12#include <vapor/glutil.h> // Must be included first!!!
13#include <utility>
14#include <vapor/DataMgr.h>
15#include <vapor/utils.h>
16#include <vapor/Renderer.h>
17#include <vapor/Texture.h>
18
19namespace VAPoR {
20
26
28public:
33 WireFrameRenderer(const ParamsMgr *pm, string winName, string dataSetName, string instName, DataMgr *dataMgr);
34
35 static string GetClassType() { return ("WireFrame"); }
36
38 //
40
41protected:
43 virtual int _initializeGL();
44
46 virtual int _paintGL(bool fast);
47
48private:
49 GLuint _VAO, _VBO, _EBO;
50 unsigned int _nIndices;
51 Texture1D _lutTexture;
52 bool _GPUOutOfMemory;
53
54 struct VertexData;
55 struct {
56 string varName;
58 size_t ts;
59 int level;
60 int lod;
61 std::vector<double> boxMin, boxMax;
62
63 } _cacheParams;
64
65 // Helper class to keep track of which cell edges have been drawn so
66 // we can avoid duplicate draws.
67 //
68 class DrawList {
69 public:
70 // maxEntries is the maximum number of unique cell nodes.
71 // maxLinesPerVertex is the *expected* max valence (degree) of any
72 // node (vertex). If a node has more than maxLinesPerVertex edges
73 // only the first maxLinesPerVertex edges will be recorded in
74 // DrawList. Hence, queries to edges with DrawList::InList will
75 // return false once maxLinesPerVertex has been exceeded
76 //
77 DrawList(GLuint maxEntries, size_t maxLinesPerVertex)
78 : _drawList(maxEntries * maxLinesPerVertex, (std::numeric_limits<GLuint>::max)()), _maxEntries(maxEntries), _maxLinesPerVertex(maxLinesPerVertex)
79 {
80 }
81
82 bool InList(GLuint idx0, GLuint idx1)
83 {
84 VAssert(idx0 < _maxEntries);
85 VAssert(idx1 < _maxEntries);
86
87 if (idx1 < idx0) { std::swap(idx1, idx0); }
88
89 for (int i = 0; i < _maxLinesPerVertex; i++) {
90 if (_drawList[idx0 * _maxLinesPerVertex + i] == idx1) { return (true); }
91 if (_drawList[idx0 * _maxLinesPerVertex + i] == (std::numeric_limits<GLuint>::max)()) {
92 _drawList[idx0 * _maxLinesPerVertex + i] = idx1;
93 return (false);
94 }
95 }
96 return (false);
97 }
98
99 private:
100 vector<GLuint> _drawList;
101 const size_t _maxEntries;
102 const size_t _maxLinesPerVertex;
103 };
104
105 void _buildCacheVertices(const Grid *grid, const Grid *heightGrid, vector<GLuint> &nodeMap, bool *GPUOutOfMemory) const;
106
107 size_t _buildCacheConnectivity(const Grid *grid, const vector<GLuint> &nodeMap, bool *GPUOutOfMemory) const;
108
109 int _buildCache();
110 bool _isCacheDirty() const;
111 void _saveCacheParams();
112 void _drawCell(const GLuint *cellNodeIndices, int n, bool layered, const std::vector<GLuint> &nodeMap, GLuint invalidIndex, std::vector<unsigned int> &indices, DrawList &drawList) const;
113
114 void _clearCache() { _cacheParams.varName.clear(); }
115};
116
117}; // namespace VAPoR
118
119#endif
#define VAssert(expr)
Definition: VAssert.h:9
A cache based data reader.
Definition: DataMgr.h:110
A singleton class for managing Params instances.
Definition: ParamsMgr.h:53
A class that performs rendering in a Visualizer.
Definition: Renderer.h:121
WireFrameRenderer(const ParamsMgr *pm, string winName, string dataSetName, string instName, DataMgr *dataMgr)
static string GetClassType()
virtual int _initializeGL()
virtual ~WireFrameRenderer()
Destructor.
std::vector< double > boxMax
virtual int _paintGL(bool fast)
All OpenGL rendering is performed in the pure virtual paintGL method.
#define RENDER_API
Definition: common.h:78