MCPcopy Create free account
hub / github.com/OSVR/OSVR-Core / parse

Method parse

src/osvr/Client/DisplayDescriptorSchema1.cpp:52–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50 }
51
52 void DisplayDescriptor::parse(const std::string &display_description) {
53 auto root = common::jsonParse(display_description);
54 auto const &hmd = root["hmd"];
55 {
56 auto const &fov = hmd["field_of_view"];
57 // Field of view
58 m_monocularHorizontalFOV = util::Angle(
59 fov["monocular_horizontal"].asDouble() * util::degrees);
60 m_monocularVerticalFOV = util::Angle(
61 fov["monocular_vertical"].asDouble() * util::degrees);
62 m_OverlapPercent =
63 fov.get("overlap_percent", 100).asDouble() / 100.0;
64 m_pitchTilt = util::Angle(fov.get("pitch_tilt", 0).asDouble() *
65 util::degrees);
66 }
67 {
68 auto const &devprops = hmd["device"];
69 // Device properties
70 m_vendor = devprops["vendor"].asString();
71 m_model = devprops["model"].asString();
72 m_version = devprops["Version"].asString();
73 m_note = devprops["Note"].asString();
74 // Note that this parameter is redundant and not used.
75 m_NumDisplays = devprops.get("num_displays", 1).asInt();
76 }
77 {
78 auto const &resolutions = hmd["resolutions"];
79 if (resolutions.isNull()) {
80 OSVR_DEV_VERBOSE(
81 "DisplayDescriptor::parse(): ERROR: Couldn't "
82 "find resolutions array!");
83 throw DisplayDescriptorParseException(
84 "Couldn't find resolutions array.");
85 }
86
87 for (auto const &resolution : resolutions) {
88 m_processResolution(resolution);
89 }
90
91 if (m_resolutions.empty()) {
92 // We couldn't find any appropriate resolution entries
93 OSVR_DEV_VERBOSE(
94 "DisplayDescriptor::parse(): ERROR: Couldn't "
95 "find any appropriate resolutions.");
96 return;
97 }
98 }
99
100 {
101 auto const &rendering = hmd["rendering"];
102 m_RightRoll = rendering.get("right_roll", 0).asDouble();
103 m_LeftRoll = rendering.get("left_roll", 0).asDouble();
104 }
105 {
106 auto const &distortion = hmd["distortion"];
107 m_distort.k1_red = distortion.get("k1_red", 0).asDouble();
108 m_distort.k1_green = distortion.get("k1_green", 0).asDouble();
109 m_distort.k1_blue = distortion.get("k1_blue", 0).asDouble();

Callers 15

mainFunction · 0.45
removeCalibrationFunction · 0.45
mainFunction · 0.45
operator()Method · 0.45
parseRoutingDirectiveFunction · 0.45
RouteContainerMethod · 0.45
m_parseMethod · 0.45
TESTFunction · 0.45
operator()Method · 0.45
createYEIFunction · 0.45

Calls 5

jsonParseFunction · 0.85
getMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected