GlobeEngine
FlowDataBlueprint.h
Go to the documentation of this file.
1 
9 #ifndef GlobeEngine_FlowDataBlueprint_h
10 #define GlobeEngine_FlowDataBlueprint_h
11 
12 #include <vmmlib/vmmlib.hpp>
13 #include <memory>
14 #include "Jzon.h"
15 #include "BluePrints.h"
16 
17 namespace geFlow {
18 
20  std::vector<size_t> start;
21  std::vector<size_t> count;
22  };
23 
25  std::string name;
28  std::vector<std::string> variables;
29  std::vector<std::string> ordering;
30  };
31 
32  struct ArrowFieldInfo {
33  double arrowlength;
34  std::shared_ptr<ge::ShaderBlueprint> shader;
36  };
37 
39  std::shared_ptr<ge::ShaderBlueprint> shader;
41  };
42 
43  struct VolumeInfo {
44  std::shared_ptr<ge::ShaderBlueprint> shader;
46  };
47 
49  std::string fileName;
50  std::vector<std::string> gridInfo; // long lat variables
51  std::vector<ArrowFieldInfo> arrowFieldInfos;
52  std::vector<AnimatedTextureInfo> animatedTextureInfos;
53  std::vector<VolumeInfo> volumeInfos;
54  };
55 
56  static std::vector<std::string> getStringfieldFromNode(const Jzon::Node& _node)
57  {
58  std::vector<std::string> resVec;
59  int idx = 0;
60  for (Jzon::Node::const_iterator it = _node.begin(); it != _node.end(); ++it) {
61  resVec.push_back(it->second.toString());
62  idx++;
63  }
64  return resVec;
65  }
66 
67  static ClimateDataVariable getClimateDataVariable(const Jzon::Node& _config) {
68  ClimateDataVariable res;
69  res.name = _config.get("name").toString();
70  res.animationIntervall = _config.get("animationIntervall").toDouble();
71  res.timestepsToLoad = _config.get("timesteps").toInt();
72  res.variables = geFlow::getStringfieldFromNode(_config.get("vars"));
73  res.ordering = geFlow::getStringfieldFromNode(_config.get("orderInNetCDF"));
74  return res;
75  }
76 
77  static ArrowFieldInfo getArrowFieldFromJSON(const Jzon::Node& _config) {
78  ArrowFieldInfo res;
79  res.arrowlength = _config.get("arrowlenght").toDouble();
80  res.shader = ge::Blueprint::readShaderContentFromJSONElement(_config.get("shader"));
81  res.ncinfo = geFlow::getClimateDataVariable(_config);
82  return res;
83  }
84 
85  static AnimatedTextureInfo getAnimatedTextureFromJSON(const Jzon::Node& _config) {
86  AnimatedTextureInfo res;
87  res.ncinfo = geFlow::getClimateDataVariable(_config);
88  res.shader = ge::Blueprint::readShaderContentFromJSONElement(_config.get("shader"));
89  return res;
90  }
91 
92  static VolumeInfo getVolumeInfoFromJSON(const Jzon::Node& _config) {
93  VolumeInfo res;
94  res.ncinfo = geFlow::getClimateDataVariable(_config);
95  res.shader = ge::Blueprint::readShaderContentFromJSONElement(_config.get("shader"));
96  return res;
97  }
98 
99  static std::shared_ptr<geFlow::WeatherDataLoadingInfo> getWeatherLoadingInfoFromJSONElement(const Jzon::Node& _config) {
100  std::shared_ptr<geFlow::WeatherDataLoadingInfo> res = std::make_shared<WeatherDataLoadingInfo>();
101  res->fileName = _config.get("url").toString();
102  // read grid info
103  res->gridInfo.push_back(_config.get("grid").get("longitude").toString());
104  res->gridInfo.push_back(_config.get("grid").get("latitude").toString());
105  if (_config.get("grid").get("height")) {
106  res->gridInfo.push_back(_config.get("grid").get("height").toString());
107  }
108  if (_config.get("grid").get("time")) {
109  res->gridInfo.push_back(_config.get("grid").get("time").toString());
110  }
111  // read out arrowfield info
112  if (_config.get("arrowfield")) {
113  res->arrowFieldInfos.push_back(geFlow::getArrowFieldFromJSON(_config.get("arrowfield")));
114  }
115  // read out animated texture info
116  if (_config.get("texture")) {
117  res->animatedTextureInfos.push_back(geFlow::getAnimatedTextureFromJSON(_config.get("texture")));
118 
119  }
120  // read out animated volume info
121  if (_config.get("volume")) {
122  res->volumeInfos.push_back(geFlow::getVolumeInfoFromJSON(_config.get("volume")));
123  }
124  return res;
125  }
126 }
127 #endif
std::vector< AnimatedTextureInfo > animatedTextureInfos
Definition: FlowDataBlueprint.h:52
std::string fileName
Definition: FlowDataBlueprint.h:49
Definition: FlowDataBlueprint.h:32
Definition: FlowDataBlueprint.h:19
std::vector< std::string > gridInfo
Definition: FlowDataBlueprint.h:50
std::shared_ptr< ge::ShaderBlueprint > shader
Definition: FlowDataBlueprint.h:44
ClimateDataVariable ncinfo
Definition: FlowDataBlueprint.h:35
std::string name
Definition: FlowDataBlueprint.h:25
ClimateDataVariable ncinfo
Definition: FlowDataBlueprint.h:40
std::vector< ArrowFieldInfo > arrowFieldInfos
Definition: FlowDataBlueprint.h:51
Definition: ArrowField.h:16
std::vector< std::string > variables
Definition: FlowDataBlueprint.h:28
std::vector< size_t > start
Definition: FlowDataBlueprint.h:20
Definition: FlowDataBlueprint.h:24
std::vector< VolumeInfo > volumeInfos
Definition: FlowDataBlueprint.h:53
std::vector< size_t > count
Definition: FlowDataBlueprint.h:21
static std::shared_ptr< ge::ShaderBlueprint > readShaderContentFromJSONElement(const Jzon::Node &_config)
Definition: BluePrints.cpp:66
Definition: FlowDataBlueprint.h:48
std::vector< std::string > ordering
Definition: FlowDataBlueprint.h:29
Definition: FlowDataBlueprint.h:43
double arrowlength
Definition: FlowDataBlueprint.h:33
Definition: FlowDataBlueprint.h:38
std::shared_ptr< ge::ShaderBlueprint > shader
Definition: FlowDataBlueprint.h:34
int timestepsToLoad
Definition: FlowDataBlueprint.h:26
ClimateDataVariable ncinfo
Definition: FlowDataBlueprint.h:45
std::shared_ptr< ge::ShaderBlueprint > shader
Definition: FlowDataBlueprint.h:39
double animationIntervall
Definition: FlowDataBlueprint.h:27