VAPOR3 3.9.4
BarbRenderer.h
Go to the documentation of this file.
1//**************************************************************
2//
3// Copyright (C) 2017
4// University Corporation for Atmospheric Research
5// All Rights Reserved
6//
7// *************************************************************
8
9#ifndef VAPOR_BARBRENDERER_H
10#define VAPOR_BARBRENDERER_H
11
12#include <vapor/glutil.h> // Must be included first!!!
13#include <vapor/DataMgr.h>
14#include <vapor/utils.h>
15#include <vapor/Renderer.h>
16#include <vapor/Grid.h>
17#include <vapor/BarbParams.h>
18
19namespace VAPoR {
20
26
28public:
29 BarbRenderer(const ParamsMgr *pm, string winName, string dataSetName, string instName, DataMgr *dataMgr);
30
31 virtual ~BarbRenderer();
32
33 static string GetClassType() { return ("Barb"); }
34
35protected:
36 virtual std::string _getColorbarVariableName() const;
37
38private:
39 vector<string> _fieldVariables; // old, used instead of _currentVarname
40 double _vectorScaleFactor;
41 double _maxThickness;
42
43 vector<double> _currentBoxMinExts;
44 vector<double> _currentBoxMaxExts;
45
46 string _currentHgtVar;
47 vector<double> _currentBoxMinExtsTex;
48 vector<double> _currentBoxMaxExtsTex;
49
50 double _maxValue;
51
52 void _getMagnitudeAtPoint(std::vector<VAPoR::Grid *> variables, float point[3]);
53
54 void _recalculateScales(std::vector<VAPoR::Grid *> &varData, int ts);
55
56 double _getDomainHypotenuse(size_t ts) const;
57
58 void _setDefaultLengthAndThicknessScales(size_t ts, const std::vector<VAPoR::Grid *> &varData, const BarbParams *bParams);
59
60 void _getGridRequirements(int &ts, int &refLevel, int &lod, CoordType &minExts, CoordType &maxExts) const;
61
63 virtual int _initializeGL();
64
66 virtual int _paintGL(bool fast);
67
68 int _generateBarbs();
69
70 int _getVectorVarGrids(int ts, int refLevel, int lod, CoordType minExts, CoordType maxExts, std::vector<VAPoR::Grid *> &varData);
71
72 int _getVarGrid(int ts, int refLevel, int lod, string varName, CoordType minExts, CoordType maxExts, std::vector<VAPoR::Grid *> &varData);
73
74 void _setUpLightingAndColor();
75
76 void _reFormatExtents(vector<float> &rakeExts) const;
77
78 void _makeRakeGrid(vector<int> &rakeGrid) const;
79
89 // int performRendering(BarbParams* rParams,
90 // int actualRefLevel,
91 // vector <Grid *> variableData
92 // );
93
94 float _getHeightOffset(Grid *heightVar, float xCoord, float yCoord, bool &missing) const;
95
96 bool _makeCLUT(float clut[1024]) const;
97
98 void _getDirection(float direction[3], std::vector<Grid *> varData, float xCoord, float yCoord, float zCoord, bool &missing) const;
99
100 vector<double> _getScales();
101
102 float _calculateLength(float start[3], float end[3]) const;
103
104 void _makeStartAndEndPoint(float start[3], float end[3], float direction[3]);
105
106 void _getStrides(vector<float> &strides, vector<int> &rakeGrid, vector<float> &rakeExts) const;
107
108 bool _defineBarb(const std::vector<Grid *>, float start[3], float end[3], float *value, bool doColorMapping, const float clut[1024]);
109
110 void _operateOnGrid(vector<Grid *> variableData, bool drawBarb = true);
111
112 bool _getColorMapping(float val, const float clut[256 * 4]);
113
114 float _calculateDirVec(const float start[3], const float end[3], float dirVec[3]);
115
116 void _drawBackOfBarb(const float dirVec[3], const float startVertex[3]) const;
117
118 void _drawCylinderSides(const float nextNormal[3], const float nextVertex[3], const float startNormal[3], const float startVertex[3]) const;
119
120 void _drawBarbHead(const float dirVec[3], const float vertexPoint[3], const float startNormal[3], const float startVertex[3]) const;
121
125 // void drawBarb(const float startPoint[3], const float endPoint[3]);
126 void _drawBarb(const std::vector<Grid *> variableData, const float startPoint[3], bool doColorMapping, const float clut[1024]);
127
128 void _setBarbColor(float value, const float clut[1024], double crange[2]) const;
129
130 struct Barb;
131 void _drawBarb(Barb b, bool doColorMapping, const float clut[1024], double crange[2]);
132
133#ifdef DEBUG
134 _printBackDiameter(const float startVertex[18]) const;
135#endif
136
137 struct {
138 vector<string> fieldVarNames;
141 size_t ts;
142 int level;
143 int lod;
145 float constantColor[3];
147 double opacity;
149 vector<long> grid;
150 vector<double> boxMin, boxMax;
153 float colorSamples[10][3];
154 float alphaSamples[10];
156 } _cacheParams;
157
158 bool _isCacheDirty() const;
159 void _saveCacheParams();
160
161 void _clearCache() { _cacheParams.fieldVarNames.clear(); }
162
163 struct Barb {
164 float startPoint[3];
165 float endPoint[3];
166 float value;
167 float lengthScalar;
168 };
169
170 vector<Barb> _barbCache;
171};
172
173}; // namespace VAPoR
174
175#endif // VAPOR_BARBRENDERER_H
Class that supports drawing Barbs based on 2D or 3D vector field.
Definition: BarbParams.h:15
Class that draws the barbs as specified by BarbParams.
Definition: BarbRenderer.h:27
BarbRenderer(const ParamsMgr *pm, string winName, string dataSetName, string instName, DataMgr *dataMgr)
virtual std::string _getColorbarVariableName() const
virtual ~BarbRenderer()
vector< double > boxMax
Definition: BarbRenderer.h:150
static string GetClassType()
Definition: BarbRenderer.h:33
vector< string > fieldVarNames
Definition: BarbRenderer.h:138
vector< long > grid
Definition: BarbRenderer.h:149
A cache based data reader.
Definition: DataMgr.h:110
Abstract base class for a 2D or 3D structured or unstructured grid.
Definition: Grid.h:56
A singleton class for managing Params instances.
Definition: ParamsMgr.h:53
A class that performs rendering in a Visualizer.
Definition: Renderer.h:121
#define RENDER_API
Definition: common.h:78
std::array< double, 3 > CoordType
Type for specifying floating point coordinates.
Definition: Grid.h:23