VAPOR3 3.9.4
TwoDDataRenderer.h
Go to the documentation of this file.
1//************************************************************************
2// *
3// Copyright (C) 2008 *
4// University Corporation for Atmospheric Research *
5// All Rights Reserved *
6// *
7//************************************************************************/
8//
9// File: TwoDDataRender.h
10//
11// Author: Alan Norton
12// National Center for Atmospheric Research
13// PO 3000, Boulder, Colorado
14//
15// Date: March 2009
16//
17// Description: Definition of the TwoDDataRenderer class
18//
19#ifndef TWODDATARENDERER_H
20#define TWODDATARENDERER_H
21
22#include <vapor/glutil.h>
23#include <vapor/TwoDRenderer.h>
24#include <vapor/DataMgr.h>
25#include <vapor/GeoImage.h>
26#include <vapor/Grid.h>
27#include <vapor/utils.h>
29
30namespace VAPoR {
31
33public:
34 TwoDDataRenderer(const ParamsMgr *pm, string winName, string dataSetName, string instName, DataMgr *dataMgr);
35
37
38 // Get static string identifier for this render class
39 //
40 static string GetClassType() { return ("TwoDData"); }
41
42protected:
44
45 int _paintGL(bool fast);
46
47 int GetMesh(DataMgr *dataMgr, GLfloat **verts, GLfloat **normals, GLsizei &nverts, GLsizei &width, GLsizei &height, GLuint **indices, GLsizei &nindices, bool &structuredMesh);
48
49 const GLvoid *GetTexture(DataMgr *dataMgr, GLsizei &width, GLsizei &height, GLint &internalFormat, GLenum &format, GLenum &type, size_t &texelSize, bool &gridAligned);
50
51private:
52 class _grid_state_c {
53 public:
54 _grid_state_c() = default;
55 _grid_state_c(size_t numRefLevels, int refLevel, int lod, string hgtVar, string meshName, size_t ts, vector<double> minExts, vector<double> maxExts)
56 : _numRefLevels(numRefLevels), _refLevel(refLevel), _lod(lod), _hgtVar(hgtVar), _meshName(meshName), _ts(ts), _minExts(minExts), _maxExts(maxExts)
57 {
58 }
59
60 void clear()
61 {
62 _numRefLevels = 0;
63 _refLevel = _lod = -1;
64 _hgtVar = _meshName = "";
65 _ts = 0;
66 _minExts.clear();
67 _maxExts.clear();
68 }
69
70 bool operator==(const _grid_state_c &rhs) const
71 {
72 return (_numRefLevels == rhs._numRefLevels && _refLevel == rhs._refLevel && _lod == rhs._lod && _hgtVar == rhs._hgtVar && _meshName == rhs._meshName && _ts == rhs._ts
73 && _minExts == rhs._minExts && _maxExts == rhs._maxExts);
74 }
75 bool operator!=(const _grid_state_c &rhs) const { return (!(*this == rhs)); }
76
77 private:
78 size_t _numRefLevels;
79 int _refLevel;
80 int _lod;
81 string _hgtVar;
82 string _meshName;
83 size_t _ts;
84 vector<double> _minExts;
85 vector<double> _maxExts;
86 };
87
88 class _tex_state_c {
89 public:
90 _tex_state_c() = default;
91 _tex_state_c(int refLevel, int lod, string varname, size_t ts, vector<double> minExts, vector<double> maxExts)
92 : _refLevel(refLevel), _lod(lod), _varname(varname), _ts(ts), _minExts(minExts), _maxExts(maxExts)
93 {
94 }
95
96 void clear()
97 {
98 _refLevel = _lod = -1;
99 _varname = "";
100 _ts = 0;
101 _minExts.clear();
102 _maxExts.clear();
103 }
104
105 bool operator==(const _tex_state_c &rhs) const
106 {
107 return (_refLevel == rhs._refLevel && _lod == rhs._lod && _varname == rhs._varname && _ts == rhs._ts && _minExts == rhs._minExts && _maxExts == rhs._maxExts);
108 }
109 bool operator!=(const _tex_state_c &rhs) const { return (!(*this == rhs)); }
110
111 private:
112 int _refLevel;
113 int _lod;
114 string _varname;
115 size_t _ts;
116 vector<double> _minExts;
117 vector<double> _maxExts;
118 };
119
120 _grid_state_c _grid_state;
121 _tex_state_c _tex_state;
122
123 GLsizei _texWidth;
124 GLsizei _texHeight;
125 size_t _texelSize;
126 SmartBuf _sb_verts;
127 SmartBuf _sb_normals;
128 SmartBuf _sb_indices;
129 SmartBuf _sb_texture;
130 GLsizei _vertsWidth;
131 GLsizei _vertsHeight;
132 GLsizei _nindices;
133 GLsizei _nverts;
134
135 GLuint _cMapTexID;
136 GLfloat *_colormap;
137 size_t _colormapsize;
138
139 bool _gridStateDirty() const;
140
141 void _gridStateClear();
142
143 void _gridStateSet();
144
145 bool _texStateDirty(DataMgr *dataMgr) const;
146
147 void _texStateSet(DataMgr *dataMgr);
148
149 void _texStateClear();
150
151 int _getMeshStructured(DataMgr *dataMgr, const StructuredGrid *g, double defaultZ);
152
153 int _getMeshUnStructured(DataMgr *dataMgr, const Grid *g, double defaultZ);
154
155 int _getMeshUnStructuredHelper(DataMgr *dataMgr, const Grid *g, double defaultZ);
156
157 int _getMeshStructuredDisplaced(DataMgr *dataMgr, const StructuredGrid *g, double defaultZ);
158
159 int _getMeshStructuredPlane(DataMgr *dataMgr, const StructuredGrid *g, double defaultZ);
160
161 const GLvoid *_getTexture(DataMgr *dataMgr);
162
163 int _getOrientation(DataMgr *dataMgr, string varname);
164
165 void _clearCache() { _tex_state.clear(); }
166};
167}; // namespace VAPoR
168
169#endif // TWODDATARENDERER_H
A cache based data reader.
Definition: DataMgr.h:110
A singleton class for managing Params instances.
Definition: ParamsMgr.h:53
const GLvoid * GetTexture(DataMgr *dataMgr, GLsizei &width, GLsizei &height, GLint &internalFormat, GLenum &format, GLenum &type, size_t &texelSize, bool &gridAligned)
TwoDDataRenderer(const ParamsMgr *pm, string winName, string dataSetName, string instName, DataMgr *dataMgr)
static string GetClassType()
int GetMesh(DataMgr *dataMgr, GLfloat **verts, GLfloat **normals, GLsizei &nverts, GLsizei &width, GLsizei &height, GLuint **indices, GLsizei &nindices, bool &structuredMesh)
int _paintGL(bool fast)
All OpenGL rendering is performed in the pure virtual paintGL method.
#define RENDER_API
Definition: common.h:78