VAPOR3 3.9.4
FlowRenderer.h
Go to the documentation of this file.
1#ifndef FLOWRENDERER_H
2#define FLOWRENDERER_H
3
4#include "vapor/glutil.h"
5#include "vapor/Renderer.h"
6#include "vapor/FlowParams.h"
7#include "vapor/GLManager.h"
8#include "vapor/Advection.h"
9#include "vapor/VaporField.h"
10
11#include <glm/glm.hpp>
12
13namespace VAPoR {
14
15class RENDER_API FlowRenderer final : public Renderer {
16public:
17 FlowRenderer(const ParamsMgr *pm, std::string &winName, std::string &dataSetName, std::string &instName, DataMgr *dataMgr);
18
19 // Rule of five
21 FlowRenderer(const FlowRenderer &) = delete;
22 FlowRenderer(const FlowRenderer &&) = delete;
24 FlowRenderer &operator=(const FlowRenderer &&) = delete;
25
26 static std::string GetClassType() { return ("Flow"); }
27
28protected:
29 virtual std::string _getColorbarVariableName() const override;
30
31private:
32 // Define two enums for this class use only
33 enum class FlowStatus {
34 SIMPLE_OUTOFDATE, // When variable name or compression is out of date,
35 TIME_STEP_OOD, // Existing particles are good, but need to advect more
36 UPTODATE // Everything is up-to-date
37 };
38
39 // C++ stuff: pure virtual functions from Renderer
40 int _initializeGL() override;
41 int _paintGL(bool fast) override;
42 void _clearCache() override{};
43
44 // Member variables
45 flow::Advection _advection;
46 flow::VaporField _velocityField;
47 flow::VaporField _colorField;
48 std::vector<float> _colorMap;
49 std::vector<double> _timestamps;
50 float _colorMapRange[3]; // min, max, and their diff
51
52 bool _advectionComplete = false;
53 bool _coloringComplete = false;
54
55 // A few variables to keep the current advection states.
56 // Some of them are initialized to be at an illegal state.
57 int _cache_refinementLevel = 0;
58 int _cache_compressionLevel = 0;
59
60 double _cache_velocityMltp = 1.0;
61 double _cache_firstStepSizeMltp = 1.0;
62 bool _cache_isSteady = false;
63 long _cache_steadyNumOfSteps = 0;
64 size_t _cache_currentTS = 0;
65 std::vector<bool> _cache_periodic{false, false, false};
66 std::vector<float> _cache_rake{0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
67 std::vector<long> _cache_gridNumOfSeeds{5, 5, 5};
68 long _cache_randNumOfSeeds = 5;
69 int _cache_seedInjInterval = 0;
70 int _cache_pastNumOfTimeSteps = 0;
71 long _cache_rakeBiasStrength = 0;
72 double _cache_deltaT = 0.05;
73 FlowSeedMode _cache_seedGenMode = FlowSeedMode::UNIFORM;
74 FlowDir _cache_flowDir = FlowDir::FORWARD;
75 FlowStatus _velocityStatus = FlowStatus::SIMPLE_OUTOFDATE;
76 FlowStatus _colorStatus = FlowStatus::SIMPLE_OUTOFDATE;
77 FlowStatus _renderStatus = FlowStatus::SIMPLE_OUTOFDATE;
78 std::string _cache_rakeBiasVariable;
79 std::string _cache_seedInputFilename;
80 bool _cache_doIntegration;
81 bool _cache_integrationSetAllToFinalValue;
82 float _cache_integrationDistScalar;
83 std::vector<double> _cache_integrationVolume;
84 bool _cache_useFixedAdvectionSteps = false;
85 double _cache_fixedAdvectionStepSize = 0.0;
86
87 // This Advection class is only used in bi-directional advection mode
88 std::unique_ptr<flow::Advection> _2ndAdvection;
89
90 // Member variables for OpenGL
91 const GLint _colorMapTexOffset;
92 ShaderProgram *_shader = nullptr;
93 GLuint _vertexArrayId = 0;
94 GLuint _vertexBufferId = 0;
95 GLuint _colorMapTexId = 0;
96
97 unsigned int _VAO = 0;
98 unsigned int _VBO = 0;
99 vector<int> _streamSizes;
100
101 //
102 // Member functions
103 //
104 int _genSeedsRakeUniform(std::vector<flow::Particle> &seeds) const;
105 int _genSeedsRakeRandom(std::vector<flow::Particle> &seeds) const;
106 int _genSeedsRakeRandomBiased(std::vector<flow::Particle> &seeds) const;
107 int _genSeedsFromList(std::vector<flow::Particle> &seeds) const;
108
109 int _renderFromAnAdvectionLegacy(const flow::Advection *, FlowParams *, bool fast);
110 int _renderAdvection(const flow::Advection *adv);
111 int _renderAdvectionHelper(bool renderDirection = false);
112 void _prepareColormap(FlowParams *);
113 void _particleHelper1(std::vector<float> &vec, const flow::Particle &p, bool singleColor) const;
114 int _drawALineStrip(const float *buf, size_t numOfParts, bool singleColor) const;
115 void _restoreGLState() const;
116 glm::vec3 _getScales();
117
118 // Update values of _cache_* and _state_* member variables.
119 int _updateFlowCacheAndStates(const FlowParams *);
120
121 int _updateAdvectionPeriodicity(flow::Advection *advc);
122
123 int _outputFlowLines();
124
125 void _dupSeedsNewTime(std::vector<flow::Particle> &seeds,
126 size_t firstN, // First N particles to duplicate
127 double newTime) const; // New time to assign to particles
128
129 // Print return code if it's non-zero and compiled in debug mode.
130 void _printNonZero(int rtn, const char *file, const char *func, int line) const;
131
132}; // End of class FlowRenderer
133
134}; // End of namespace VAPoR
135
136#endif
A cache based data reader.
Definition: DataMgr.h:110
static std::string GetClassType()
Definition: FlowRenderer.h:26
FlowRenderer(const FlowRenderer &)=delete
FlowRenderer & operator=(const FlowRenderer &)=delete
FlowRenderer(const FlowRenderer &&)=delete
FlowRenderer(const ParamsMgr *pm, std::string &winName, std::string &dataSetName, std::string &instName, DataMgr *dataMgr)
FlowRenderer & operator=(const FlowRenderer &&)=delete
virtual std::string _getColorbarVariableName() const override
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
FlowSeedMode
Definition: FlowParams.h:15