GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 25
Functions: 0.0% 0 / 0 / 1
Branches: 0.0% 0 / 0 / 31

src/radiance/Utils.cpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #include "Utils.hpp"
7
8 #include <cassert>
9 #include <sstream>
10
11 namespace openstudio {
12 namespace radiance {
13
14 ✗ std::vector<double> parseGenDayMtxLine(const std::string& t_line) {
15 ✗ std::stringstream ss(t_line);
16 ✗ std::vector<double> retval(8760);
17
18 ✗ int valuenum = 0;
19 ✗ while (ss.good() && valuenum < 8760) {
20 ✗ std::vector<double> colors(3, 0);
21 ✗ int color = 0;
22 ✗ for (; ss.good() && color < 3; ++color) {
23 ✗ char c = static_cast<char>(ss.peek());
24 ✗ if (c == ' ' || c == '\t') {
25 ✗ ss.ignore();
26 }
27
28 ✗ char p = static_cast<char>(ss.peek());
29 ✗ if (p < '0' || p > '9') {
30 // this is either a nan, or a -nan or a -number, which we cannot handle
31 // and don't care about
32 ✗ colors[color] = 0;
33 // eat the string of whatever it is
34 ✗ std::string str;
35 ✗ ss >> str;
36 ✗ } else {
37 double d;
38 ✗ ss >> d;
39 ✗ colors[color] = d;
40 }
41 }
42
43 assert(color == 3 && "not an even multiple of 3 read");
44 ✗ retval[valuenum] = 179 * ((colors[0] * 0.265) + (colors[1] * 0.67) + (colors[2] * 0.065));
45 ✗ ++valuenum;
46 ✗ }
47
48 ✗ retval.resize(valuenum);
49 ✗ return retval;
50 ✗ }
51
52 } // namespace radiance
53 } // namespace openstudio
54