GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 61.4% 811 / 0 / 1320
Functions: 73.3% 22 / 0 / 30
Branches: 55.9% 1878 / 0 / 3359

src/radiance/ForwardTranslator.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 "ForwardTranslator.hpp"
7
8 #include "../model/Building.hpp"
9 #include "../model/Building_Impl.hpp"
10 #include "../model/Construction.hpp"
11 #include "../model/DaylightingControl.hpp"
12 #include "../model/GlareSensor.hpp"
13 #include "../model/InteriorPartitionSurfaceGroup.hpp"
14 #include "../model/Model.hpp"
15 #include "../model/Model_Impl.hpp"
16 #include "../model/WeatherFile.hpp"
17 #include "../model/WeatherFile_Impl.hpp"
18 #include "../model/RadianceParameters.hpp"
19 #include "../model/RadianceParameters_Impl.hpp"
20 #include "../model/Site.hpp"
21 #include "../model/Site_Impl.hpp"
22 #include "../model/ShadingSurface.hpp"
23 #include "../model/ShadingSurface_Impl.hpp"
24 #include "../model/ShadingSurfaceGroup.hpp"
25 #include "../model/ShadingSurfaceGroup_Impl.hpp"
26 #include "../model/ShadingControl.hpp"
27 #include "../model/ShadingControl_Impl.hpp"
28 #include "../model/Space.hpp"
29 #include "../model/Space_Impl.hpp"
30 #include "../model/ThermalZone.hpp"
31 #include "../model/WindowPropertyFrameAndDivider.hpp"
32 #include "../model/Facility.hpp"
33 #include "../model/Facility_Impl.hpp"
34 #include "../model/Timestep.hpp"
35 #include "../model/Timestep_Impl.hpp"
36 #include "../model/SpaceItem.hpp"
37 #include "../model/SpaceItem_Impl.hpp"
38 #include "../model/SimulationControl.hpp"
39 #include "../model/SimulationControl_Impl.hpp"
40 #include "../model/RunPeriod.hpp"
41 #include "../model/RunPeriod_Impl.hpp"
42 #include "../model/People.hpp"
43 #include "../model/People_Impl.hpp"
44 #include "../model/Lights.hpp"
45 #include "../model/Lights_Impl.hpp"
46 #include "../model/Luminaire.hpp"
47 #include "../model/Luminaire_Impl.hpp"
48 #include "../model/OutputVariable.hpp"
49 #include "../model/OutputVariable_Impl.hpp"
50
51 #include "../utilities/core/Assert.hpp"
52 #include "../utilities/core/PathHelpers.hpp"
53 #include "../utilities/core/FilesystemHelpers.hpp"
54 #include "../utilities/time/DateTime.hpp"
55 #include "../utilities/geometry/Geometry.hpp"
56 #include "../utilities/geometry/Transformation.hpp"
57 #include "../utilities/geometry/Intersection.hpp"
58 #include "../utilities/bcl/BCL.hpp"
59 #include "../utilities/bcl/RemoteBCL.hpp"
60 #include "../utilities/bcl/LocalBCL.hpp"
61
62 #include <thread>
63
64 #include <boost/lexical_cast.hpp>
65 #include <boost/algorithm/string/regex.hpp>
66 #include <boost/math/constants/constants.hpp>
67
68 #include <radiance/embedded_files.hxx>
69
70 #include <cstring>
71 #include <cmath>
72 #include <sstream>
73 #include <iterator>
74 #include <algorithm>
75 #include <fstream>
76 #include <iomanip>
77 #include <cmath>
78
79 using openstudio::Point3d;
80 using openstudio::Point3dVector;
81 using openstudio::Transformation;
82 using openstudio::model::Building;
83 using openstudio::model::Space;
84 using openstudio::model::Surface;
85 using openstudio::model::SubSurface;
86 using openstudio::model::ShadingSurface;
87 using openstudio::model::ShadingSurfaceGroup;
88 using openstudio::model::InteriorPartitionSurface;
89 using openstudio::model::InteriorPartitionSurfaceGroup;
90 using openstudio::model::OptionalBuilding;
91 using openstudio::model::OptionalSpace;
92 using openstudio::model::OptionalShadingSurfaceGroup;
93 using openstudio::model::OptionalInteriorPartitionSurfaceGroup;
94 using openstudio::model::OptionalSurface;
95
96 using OFSTREAM = openstudio::filesystem::basic_ofstream<char>;
97
98 namespace openstudio {
99 namespace radiance {
100
101 // internal method used to format doubles as strings
102 3627 std::string formatString(double t_d, unsigned t_prec) {
103
1/1
✓ Branch 1 taken 3627 times.
3627 std::stringstream ss;
104
3/3
✓ Branch 3 taken 3627 times.
✓ Branch 6 taken 3627 times.
✓ Branch 9 taken 3627 times.
3627 ss << std::setprecision(t_prec) << std::noshowpoint << std::fixed << t_d;
105
1/1
✓ Branch 1 taken 3627 times.
3627 std::string s = ss.str();
106
107 /*
108 // truncate 0's from the end
109 int i = s.size() - 1;
110 while (i > 0 && s[i] == '0')
111 {
112 --i;
113 }
114
115 if (i > 0)
116 {
117 s.erase(i + 1);
118
119 if (*s.rbegin() == '.')
120 {
121 s.push_back('0');
122 }
123 }
124 */
125
126 7254 return s;
127 3627 }
128
129 // internal method used to format all other types as strings
130 template <typename T>
131 105 std::string formatString(const T& t) {
132 105 return boost::lexical_cast<std::string>(t);
133 }
134
135 // basic constructor
136 6 ForwardTranslator::ForwardTranslator()
137
1/1
✓ Branch 23 taken 6 times.
6 : m_windowGroupId(1) // m_windowGroupId is reserved for uncontrolled
138 {
139
1/1
✓ Branch 1 taken 6 times.
6 m_logSink.setLogLevel(Warn);
140
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 m_logSink.setChannelRegex(boost::regex("openstudio\\.radiance\\.ForwardTranslator"));
141
1/1
✓ Branch 2 taken 6 times.
6 m_logSink.setThreadId(std::this_thread::get_id());
142 6 }
143
144 6 std::vector<openstudio::path> ForwardTranslator::translateModel(const openstudio::path& outPath, const openstudio::model::Model& model) {
145
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 m_model = model.clone(true).cast<openstudio::model::Model>();
146
147
1/1
✓ Branch 1 taken 6 times.
6 m_model.purgeUnusedResourceObjects();
148
149 6 m_logSink.setThreadId(std::this_thread::get_id());
150
151 6 m_logSink.resetStringStream();
152
153 6 clear();
154
155 // TODO: check for shading controls, set m_shadingControls
156
157 6 std::vector<openstudio::path> outfiles;
158
159 // preprocess the model here
160 6 unsigned numSpacesToSimulate = 0;
161
4/4
✓ Branch 1 taken 6 times.
✓ Branch 7 taken 24 times.
✓ Branch 11 taken 24 times.
✓ Branch 12 taken 6 times.
30 for (openstudio::model::Space space : m_model.getConcreteModelObjects<openstudio::model::Space>()) {
162
163 // remove any spaces not associated with a thermal zone
164
1/1
✓ Branch 1 taken 24 times.
24 boost::optional<openstudio::model::ThermalZone> thermalZone = space.thermalZone();
165
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 if (!thermalZone) {
166 ✗ LOG(Error, "Model translation failure; space " << space.name().get() << " is not associated with a ThermalZone, could not be translated.");
167 ✗ space.remove();
168 ✗ continue;
169 ✗ }
170
171 // only allow assigned primary daylighting control points (as defined in thermal zone) through
172
4/4
✓ Branch 1 taken 24 times.
✓ Branch 7 taken 5 times.
✓ Branch 11 taken 5 times.
✓ Branch 12 taken 24 times.
29 for (openstudio::model::DaylightingControl daylightingControl : space.daylightingControls()) {
173
3/3
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 4 times.
5 if (daylightingControl.isPrimaryDaylightingControl()) {
174 // ok
175
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 } else if (daylightingControl.isSecondaryDaylightingControl()) {
176 ✗ LOG(Warn,
177 "Secondary DaylightingControl " << daylightingControl.name().get() << " is not supported by Radiance, it will not be translated.");
178 ✗ daylightingControl.remove();
179 } else {
180
9/9
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 20 taken 1 time.
✓ Branch 23 taken 1 time.
✓ Branch 26 taken 1 time.
1 LOG(Warn, "DaylightingControl " << daylightingControl.name().get()
181 << " is not associated with this Space's ThermalZone, it will not be translated.");
182
1/1
✓ Branch 1 taken 1 time.
1 daylightingControl.remove();
183 }
184 29 }
185
186
1/1
✓ Branch 1 taken 24 times.
24 std::vector<openstudio::model::DaylightingControl> daylightingControls = space.daylightingControls();
187
1/1
✓ Branch 1 taken 24 times.
24 std::vector<openstudio::model::IlluminanceMap> illuminanceMaps = space.illuminanceMaps();
188
1/1
✓ Branch 1 taken 24 times.
24 std::vector<openstudio::model::GlareSensor> glareSensors = space.glareSensors();
189
190
6/6
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 20 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 21 times.
24 if (!daylightingControls.empty() && !illuminanceMaps.empty()) {
191 3 numSpacesToSimulate += 1;
192
193
2/2
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 2 times.
3 if (glareSensors.empty()) {
194
9/9
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 20 taken 1 time.
✓ Branch 23 taken 1 time.
✓ Branch 26 taken 1 time.
1 LOG(Warn, "Space " << space.name().get() << " contains Radiance daylighting objects but no GlareSensor objects.");
195 }
196 }
197 30 }
198
199 // remove unsupported shading controls
200
3/3
✓ Branch 1 taken 6 times.
✓ Branch 8 taken 1 time.
✓ Branch 9 taken 6 times.
7 for (auto& shadingControl : model.getConcreteModelObjects<openstudio::model::ShadingControl>()) {
201
1/1
✓ Branch 1 taken 1 time.
1 std::string shadingType = shadingControl.shadingType();
202 1 bool supported = false;
203
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
2 if (istringEqual("InteriorShade", shadingType)) {
204 ✗ supported = true;
205
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
2 } else if (istringEqual("ExteriorShade", shadingType)) {
206 ✗ supported = false;
207
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
2 } else if (istringEqual("ExteriorScreen", shadingType)) {
208 ✗ supported = false;
209
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
2 } else if (istringEqual("InteriorBlind", shadingType)) {
210 ✗ supported = true;
211
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
2 } else if (istringEqual("ExteriorBlind", shadingType)) {
212 ✗ supported = false;
213
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
2 } else if (istringEqual("BetweenGlassShade", shadingType)) {
214 ✗ supported = false;
215
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
2 } else if (istringEqual("BetweenGlassBlind", shadingType)) {
216 ✗ supported = false;
217
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
2 } else if (istringEqual("SwitchableGlazing", shadingType)) {
218 1 supported = true;
219 ✗ } else if (istringEqual("InteriorDaylightRedirectionDevice", shadingType)) {
220 ✗ supported = true;
221 } else {
222 ✗ supported = false;
223 ✗ LOG(Warn, "Unknown shadingType '" << shadingType << "' found for ShadingControl '" << shadingControl.name().get() << "'");
224 }
225
226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (!supported) {
227 ✗ LOG(Warn, "Removing ShadingControl '" << shadingControl.name().get() << "' with unsupported shadingType '" << shadingType << "'");
228 ✗ shadingControl.remove();
229 ✗ continue;
230 ✗ }
231
232
1/1
✓ Branch 1 taken 1 time.
1 std::string shadingControlType = shadingControl.shadingControlType();
233
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
2 if (istringEqual("AlwaysOff", shadingControlType)) {
234 ✗ LOG(Info, "Removing ShadingControl '" << shadingControl.name().get() << "' with shadingControlType '" << shadingControlType << "'");
235 ✗ continue;
236 ✗ }
237 7 }
238
239
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if (numSpacesToSimulate == 0) {
240
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 LOG(Error, "Model does not contain any spaces configured for Radiance; check illuminance map and daylighting control point assignments.");
241 3 return outfiles;
242 }
243
244 // catch any directory or file related issues here
245 try {
246
247
7/7
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 15 taken 3 times.
✓ Branch 18 taken 3 times.
✓ Branch 21 taken 3 times.
3 LOG(Debug, "Working Directory: " + openstudio::toString(outPath));
248
249
2/3
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
3 if (openstudio::filesystem::exists(outPath)) {
250 ✗ openstudio::filesystem::remove_all(outPath);
251 }
252
253
1/1
✓ Branch 1 taken 3 times.
3 openstudio::filesystem::create_directories(outPath);
254
255 //create radiance dirs for model export
256
1/1
✓ Branch 1 taken 3 times.
3 openstudio::path radDir = outPath;
257
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
6 openstudio::filesystem::create_directory(radDir / openstudio::toPath("scene"));
258
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
6 openstudio::filesystem::create_directory(radDir / openstudio::toPath("scene/glazing"));
259
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
6 openstudio::filesystem::create_directory(radDir / openstudio::toPath("scene/shades"));
260
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
6 openstudio::filesystem::create_directory(radDir / openstudio::toPath("materials"));
261
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
6 openstudio::filesystem::create_directory(radDir / openstudio::toPath("numeric"));
262
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
6 openstudio::filesystem::create_directory(radDir / openstudio::toPath("views"));
263
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
6 openstudio::filesystem::create_directory(radDir / openstudio::toPath("options"));
264
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
6 openstudio::filesystem::create_directory(radDir / openstudio::toPath("bsdf"));
265
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
6 openstudio::filesystem::create_directory(radDir / openstudio::toPath("skies"));
266
267 // get the building
268
1/1
✓ Branch 1 taken 3 times.
3 openstudio::model::Building building = m_model.getUniqueModelObject<openstudio::model::Building>();
269
270 // get the site
271
1/1
✓ Branch 1 taken 3 times.
3 auto site = m_model.getUniqueModelObject<openstudio::model::Site>();
272
273 // get site and building shading
274
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 LOG(Debug, "Processing site/building shading elements...");
275
276 // get building shading
277
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 buildingShadingSurfaceGroups(radDir, building.shadingSurfaceGroups(), outfiles);
278
279 // get site shading
280
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 siteShadingSurfaceGroups(radDir, site.shadingSurfaceGroups(), outfiles);
281
282 // get spaces
283
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 buildingSpaces(radDir, building.spaces(), outfiles);
284
285 // write options files
286 3 std::string dcmatsStringin;
287
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
6 std::ifstream dcmatfilein(openstudio::toSystemFilename(radDir / openstudio::toPath("materials/materials_dc.rad")));
288
289
2/3
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
3 while (dcmatfilein.good()) {
290 ✗ std::string line;
291 ✗ std::getline(dcmatfilein, line);
292 ✗ dcmatsStringin += line;
293 ✗ }
294
295 3 std::vector<std::string> dcmatsArray;
296
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 boost::algorithm::split(dcmatsArray, dcmatsStringin, boost::is_any_of(","));
297
298 3 int totalVectors = dcmatsArray.size();
299
300
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
3 LOG(Debug, "Total aperture headings: " << totalVectors);
301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (totalVectors > 8) {
302 ✗ LOG(Warn, formatString(totalVectors) << " glazing orientations detected (can cause long simulation times if using daylight coefficients).");
303 }
304
305 // std::string dcmatsString = dcmatsStringin.gsub(',', ' ');
306
307 // get Radiance sim settings
308
1/1
✓ Branch 1 taken 3 times.
3 auto radianceParameters = m_model.getUniqueModelObject<openstudio::model::RadianceParameters>();
309
310 // write Radiance options to file(s)
311
312 // view matrix options
313
314
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 openstudio::path vmxoptpath = radDir / openstudio::toPath("options/vmx.opt");
315
1/1
✓ Branch 1 taken 3 times.
3 OFSTREAM vmxopt(vmxoptpath);
316
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 if (vmxopt.is_open()) {
317
1/1
✓ Branch 1 taken 3 times.
3 outfiles.push_back(vmxoptpath);
318
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 vmxopt << "-ab " << (int)radianceParameters.ambientBouncesVMX() << " " << "-ad " << (int)radianceParameters.ambientDivisionsVMX() << " "
319
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 << "-as " << (int)radianceParameters.ambientSupersamples()
320 << " "
321 // << "-c " << (int)radianceParameters.accumulatedRaysperRecord() << " "
322
12/12
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 25 taken 3 times.
✓ Branch 28 taken 3 times.
✓ Branch 31 taken 3 times.
✓ Branch 34 taken 3 times.
3 << "-dj " << radianceParameters.directJitter() << " " << "-dp " << radianceParameters.directPretest() << " " << "-dt "
323
8/8
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
3 << radianceParameters.directThreshold() << " " << "-dc " << radianceParameters.directCertainty() << " " << "-lw "
324
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 << radianceParameters.limitWeightVMX() << " ";
325 } else {
326
327 ✗ LOG(Error, "Cannot open file '" << toString(vmxoptpath) << "' for writing");
328 }
329
330 // daylight matrix options
331
332
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 openstudio::path dmxoptpath = radDir / openstudio::toPath("options/dmx.opt");
333
1/1
✓ Branch 1 taken 3 times.
3 OFSTREAM dmxopt(dmxoptpath);
334
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 if (dmxopt.is_open()) {
335
1/1
✓ Branch 1 taken 3 times.
3 outfiles.push_back(dmxoptpath);
336
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 dmxopt << "-ab " << (int)radianceParameters.ambientBouncesDMX() << " " << "-ad " << (int)radianceParameters.ambientDivisionsDMX() << " "
337
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 << "-as " << (int)radianceParameters.ambientSupersamples()
338 << " "
339 // << "-c " << (int)radianceParameters.accumulatedRaysperRecord() << " "
340
12/12
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 25 taken 3 times.
✓ Branch 28 taken 3 times.
✓ Branch 31 taken 3 times.
✓ Branch 34 taken 3 times.
3 << "-dj " << radianceParameters.directJitter() << " " << "-dp " << radianceParameters.directPretest() << " " << "-dt "
341
8/8
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
3 << radianceParameters.directThreshold() << " " << "-dc " << radianceParameters.directCertainty() << " " << "-lw "
342
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 << radianceParameters.limitWeightDMX() << " ";
343 } else {
344
345 ✗ LOG(Error, "Cannot open file '" << toString(dmxoptpath) << "' for writing");
346 }
347
348 // Tregenza/Klems resolution options
349
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 openstudio::path tregoptpath = radDir / openstudio::toPath("options/treg.opt");
350
1/1
✓ Branch 1 taken 3 times.
3 OFSTREAM tregopt(tregoptpath);
351
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 if (tregopt.is_open()) {
352
1/1
✓ Branch 1 taken 3 times.
3 outfiles.push_back(tregoptpath);
353
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 tregopt << "-c " << (int)radianceParameters.klemsSamplingDensity() << " ";
354
1/1
✓ Branch 1 taken 3 times.
3 tregopt << "-e MF:1 -f tregenza.cal -b tbin -bn Ntbins";
355 //restricted to Klems, user is warned when writing out window groups. 2015.09.13 RPG
356 //if (radianceParameters.skyDiscretizationResolution() == "146"){
357 // tregopt << "-e MF:1 -f tregenza.cal -b tbin -bn Ntbins";
358 //} else if (radianceParameters.skyDiscretizationResolution() == "578"){
359 // tregopt << "-e MF:2 -f reinhart.cal -b rbin -bn Nrbins";
360 //} else if (radianceParameters.skyDiscretizationResolution() == "2306"){
361 // tregopt << "-e MF:4 -f reinhart.cal -b rbin -bn Nrbins";
362 //}
363 // TODO: make these values into a pulldown choice, add support for higher resolution sampling bases and out of bounds
364 } else {
365 ✗ LOG(Error, "Cannot open file '" << toString(tregoptpath) << "' for writing");
366 }
367
368 // write dc sky sampling file
369
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 openstudio::path dcskyfilepath = radDir / openstudio::toPath("skies/dc_sky.rad");
370
1/1
✓ Branch 1 taken 3 times.
3 OFSTREAM skyfile(dcskyfilepath);
371
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 if (skyfile.is_open()) {
372
1/1
✓ Branch 1 taken 3 times.
3 outfiles.push_back(dcskyfilepath);
373 // ground first (P0)!
374
1/1
✓ Branch 1 taken 3 times.
3 skyfile << "#@rfluxmtx h=u u=Y\nvoid glow groundglow\n0\n0\n4\n1 1 1 0\n\ngroundglow source ground\n0\n0\n4\n0 0 -1 180\n";
375
1/1
✓ Branch 1 taken 3 times.
3 skyfile << "#@rfluxmtx h=r1 u=Y\nvoid glow skyglow\n0\n0\n4\n1 1 1 0\n\nskyglow source sky\n0\n0\n4\n0 0 1 180\n";
376
377 } else {
378 ✗ LOG(Error, "Cannot open file '" << toString(dcskyfilepath) << "' for writing");
379 }
380
381 // write sample sky for renderings
382
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 openstudio::path renderskyfilepath = radDir / openstudio::toPath("skies/03211200_clr.sky");
383
1/1
✓ Branch 1 taken 3 times.
3 OFSTREAM renderskyfile(renderskyfilepath);
384
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 if (renderskyfile.is_open()) {
385
1/1
✓ Branch 1 taken 3 times.
3 outfiles.push_back(renderskyfilepath);
386
1/1
✓ Branch 1 taken 3 times.
3 renderskyfile << "# CIE clear sky - Berkeley, CA - March 21 12:00 \n\n";
387
1/1
✓ Branch 1 taken 3 times.
3 renderskyfile << "void light solar\n0\n0\n3 6.92e+06 6.92e+06 6.92e+06\n\n";
388
1/1
✓ Branch 1 taken 3 times.
3 renderskyfile << "solar source sun\n0\n0\n4 0.067845 -0.617210 0.783868 0.5\n\n";
389
1/1
✓ Branch 1 taken 3 times.
3 renderskyfile << "void brightfunc skyfunc\n2 skybr skybright.cal\n0\n7 1 1.16e+01 2.37e+01 6.92e-01 0.067845 -0.617210 0.783868\n\n";
390
1/1
✓ Branch 1 taken 3 times.
3 renderskyfile << "skyfunc glow skyglow\n0\n0\n4 1.000 1.000 1.000 0\n\n";
391
1/1
✓ Branch 1 taken 3 times.
3 renderskyfile << "skyglow source sky\n0\n0\n4 0 0 1 180\n\n";
392
1/1
✓ Branch 1 taken 3 times.
3 renderskyfile << "skyfunc glow groundglow\n0\n0\n4 1.000 1.000 1.000 0\n\n";
393
1/1
✓ Branch 1 taken 3 times.
3 renderskyfile << "groundglow source ground\n0\n0\n4 0 0 -1 180\n\n";
394
395 } else {
396 ✗ LOG(Error, "Cannot open file '" << toString(renderskyfilepath) << "' for writing");
397 }
398
399 // Hi Qual options (illuminance maps)
400
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 openstudio::path mapsoptpath = radDir / openstudio::toPath("options/maps.opt");
401
1/1
✓ Branch 1 taken 3 times.
3 OFSTREAM mapsopt(mapsoptpath);
402
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 if (mapsopt.is_open()) {
403
1/1
✓ Branch 1 taken 3 times.
3 outfiles.push_back(mapsoptpath);
404
1/1
✓ Branch 1 taken 3 times.
3 mapsopt << "-ab 10 -ad 10000 -as 50 -dt 0 -dc 1 -ds 0.05 -lw 0.00001";
405 } else {
406 ✗ LOG(Error, "Cannot open file '" << toString(mapsoptpath) << "' for writing");
407 }
408
409 // the end
410
8/8
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 17 taken 3 times.
✓ Branch 20 taken 3 times.
✓ Branch 23 taken 3 times.
3 LOG(Debug, "Done. Radiance model located at: " << openstudio::toString(radDir) << ".");
411
412
0/2
✗ Branch 38 not taken.
✗ Branch 39 not taken.
3 } catch (const std::exception& e) {
413 ✗ outfiles.clear();
414 ✗ std::string error = e.what();
415 ✗ LOG(Error, error);
416 ✗ }
417
418 3 return outfiles;
419 ✗ }
420
421 6 std::vector<LogMessage> ForwardTranslator::warnings() const {
422 6 std::vector<LogMessage> result;
423
424
3/3
✓ Branch 1 taken 6 times.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 6 times.
11 for (const LogMessage& logMessage : m_logSink.logMessages()) {
425
3/3
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 3 times.
5 if (logMessage.logLevel() == Warn) {
426
1/1
✓ Branch 1 taken 2 times.
2 result.push_back(logMessage);
427 }
428 6 }
429
430 6 return result;
431 ✗ }
432
433 6 std::vector<LogMessage> ForwardTranslator::errors() const {
434 6 std::vector<LogMessage> result;
435
436
3/3
✓ Branch 1 taken 6 times.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 6 times.
11 for (const LogMessage& logMessage : m_logSink.logMessages()) {
437
3/3
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 2 times.
5 if (logMessage.logLevel() > Warn) {
438
1/1
✓ Branch 1 taken 3 times.
3 result.push_back(logMessage);
439 }
440 6 }
441
442 6 return result;
443 ✗ }
444
445 52 openstudio::Point3dVectorVector ForwardTranslator::getPolygons(const openstudio::model::Surface& surface) {
446 52 openstudio::Point3dVectorVector result;
447
448
1/1
✓ Branch 1 taken 52 times.
52 Transformation buildingTransformation;
449
2/2
✓ Branch 1 taken 52 times.
✓ Branch 4 taken 52 times.
52 OptionalBuilding building = surface.model().getOptionalUniqueModelObject<Building>();
450
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 if (building) {
451
2/2
✓ Branch 1 taken 52 times.
✓ Branch 4 taken 52 times.
52 buildingTransformation = building->transformation();
452 }
453
454
1/1
✓ Branch 1 taken 52 times.
52 Transformation spaceTransformation;
455
1/1
✓ Branch 1 taken 52 times.
52 OptionalSpace space = surface.space();
456
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 if (space) {
457
2/2
✓ Branch 1 taken 52 times.
✓ Branch 4 taken 52 times.
52 spaceTransformation = space->transformation();
458 }
459
460 // transformation from space coordinates to face coordinates
461
2/2
✓ Branch 1 taken 52 times.
✓ Branch 4 taken 52 times.
52 Transformation alignFace = Transformation::alignFace(surface.vertices());
462
463 // get the current vertices and convert to face coordinates
464
3/3
✓ Branch 1 taken 52 times.
✓ Branch 4 taken 52 times.
✓ Branch 7 taken 52 times.
52 Point3dVector surfaceFaceVertices = alignFace.inverse() * surface.vertices();
465
466 // boost polygon wants vertices in clockwise order, faceVertices must be reversed, otherFaceVertices already CCW
467
1/1
✓ Branch 3 taken 52 times.
52 std::reverse(surfaceFaceVertices.begin(), surfaceFaceVertices.end());
468
469 // get the current subsurfaces and convert to face coordinates
470 52 std::vector<std::vector<Point3d>> holes;
471
3/3
✓ Branch 1 taken 52 times.
✓ Branch 8 taken 8 times.
✓ Branch 9 taken 52 times.
60 for (const SubSurface& subSurface : surface.subSurfaces()) {
472
3/3
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
8 Point3dVector hole = alignFace.inverse() * subSurface.vertices();
473
1/1
✓ Branch 3 taken 8 times.
8 std::reverse(hole.begin(), hole.end());
474
1/1
✓ Branch 1 taken 8 times.
8 holes.push_back(hole);
475 60 }
476
477 // perform the subtraction
478
1/1
✓ Branch 1 taken 52 times.
52 std::vector<std::vector<Point3d>> faceResult = openstudio::subtract(surfaceFaceVertices, holes, 0.01);
479
480
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 52 times.
52 if (faceResult.empty()) {
481 // DLM: is this an error (fail simulation) or a warning? Should we attempt to put the whole surface in here?
482 ✗ LOG(Warn, "Failed to create surface polygons for Surface '" << surface.nameString() << "'");
483 }
484
485 // convert to absolute coordinates
486
2/2
✓ Branch 5 taken 73 times.
✓ Branch 6 taken 52 times.
125 for (const Point3dVector& face : faceResult) {
487
3/3
✓ Branch 1 taken 73 times.
✓ Branch 4 taken 73 times.
✓ Branch 7 taken 73 times.
73 Point3dVector worldFace = buildingTransformation * spaceTransformation * alignFace * face;
488
1/1
✓ Branch 3 taken 73 times.
73 std::reverse(worldFace.begin(), worldFace.end());
489
1/1
✓ Branch 1 taken 73 times.
73 result.push_back(worldFace);
490 73 }
491
492 104 return result;
493 52 }
494
495 6 openstudio::Point3dVector ForwardTranslator::getPolygon(const openstudio::model::SubSurface& subSurface) {
496
1/1
✓ Branch 1 taken 6 times.
6 Transformation buildingTransformation;
497
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 OptionalBuilding building = subSurface.model().getOptionalUniqueModelObject<Building>();
498
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (building) {
499
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 buildingTransformation = building->transformation();
500 }
501
502
1/1
✓ Branch 1 taken 6 times.
6 Transformation spaceTransformation;
503
1/1
✓ Branch 1 taken 6 times.
6 OptionalSurface surface = subSurface.surface();
504
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (surface) {
505
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 OptionalSpace space = surface->space();
506
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (space) {
507
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 spaceTransformation = space->transformation();
508 }
509 6 } else {
510 ✗ LOG(Warn, "Could not retrieve surface for sub surface '" << subSurface.name() << "'");
511 }
512
513
1/1
✓ Branch 1 taken 6 times.
6 openstudio::Point3dVector vertices = subSurface.vertices();
514
515 // apply frame and divider reveal
516
1/1
✓ Branch 1 taken 6 times.
6 boost::optional<openstudio::model::WindowPropertyFrameAndDivider> frameAndDivider = subSurface.windowPropertyFrameAndDivider();
517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (frameAndDivider) {
518 ✗ if (!frameAndDivider->isOutsideRevealDepthDefaulted()) {
519 ✗ openstudio::Vector3d offset = -frameAndDivider->outsideRevealDepth() * subSurface.outwardNormal();
520
521 ✗ for (openstudio::Point3d& vertex : vertices) {
522 ✗ vertex = vertex + offset;
523 }
524 ✗ }
525 }
526
527 // convert vertices to absolute coordinates
528
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
12 return buildingTransformation * spaceTransformation * vertices;
529 6 }
530
531 9 openstudio::Point3dVector ForwardTranslator::getPolygon(const openstudio::model::ShadingSurface& shadingSurface) {
532
1/1
✓ Branch 1 taken 9 times.
9 Transformation buildingTransformation;
533
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 OptionalBuilding building = shadingSurface.model().getOptionalUniqueModelObject<Building>();
534
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if (building) {
535
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 buildingTransformation = building->transformation();
536 }
537
538
1/1
✓ Branch 1 taken 9 times.
9 Transformation shadingSurfaceGroupTransformation;
539
1/1
✓ Branch 1 taken 9 times.
9 Transformation spaceTransformation;
540
1/1
✓ Branch 1 taken 9 times.
9 OptionalShadingSurfaceGroup shadingSurfaceGroup = shadingSurface.shadingSurfaceGroup();
541
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if (shadingSurfaceGroup) {
542
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 shadingSurfaceGroupTransformation = shadingSurfaceGroup->transformation();
543
544
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 OptionalSpace space = shadingSurfaceGroup->space();
545
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6 times.
9 if (space) {
546
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 spaceTransformation = space->transformation();
547 }
548 9 }
549
550
1/1
✓ Branch 1 taken 9 times.
9 Transformation transformation;
551
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 std::string shadingSurfaceType = shadingSurfaceGroup->shadingSurfaceType();
552
4/4
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 6 times.
18 if (istringEqual("Site", shadingSurfaceType)) {
553
1/1
✓ Branch 1 taken 3 times.
3 transformation = shadingSurfaceGroupTransformation;
554
4/4
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 3 times.
12 } else if (istringEqual("Building", shadingSurfaceType)) {
555
1/1
✓ Branch 1 taken 3 times.
3 transformation = buildingTransformation * shadingSurfaceGroupTransformation;
556
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
6 } else if (istringEqual("Space", shadingSurfaceType)) {
557
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 transformation = buildingTransformation * spaceTransformation * shadingSurfaceGroupTransformation;
558 } else {
559 ✗ LOG(Error, "Unknown shading surface type for shading surface '" << shadingSurface.name() << "'");
560 ✗ return {};
561 }
562
563 // convert vertices to absolute coordinates
564
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 return transformation * shadingSurface.vertices();
565 9 }
566
567 3 openstudio::Point3dVector ForwardTranslator::getPolygon(const openstudio::model::InteriorPartitionSurface& interiorPartitionSurface) {
568
1/1
✓ Branch 1 taken 3 times.
3 Transformation buildingTransformation;
569
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 OptionalBuilding building = interiorPartitionSurface.model().getOptionalUniqueModelObject<Building>();
570
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (building) {
571
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 buildingTransformation = building->transformation();
572 }
573
574
1/1
✓ Branch 1 taken 3 times.
3 Transformation interiorPartitionSurfaceGroupTransformation;
575
1/1
✓ Branch 1 taken 3 times.
3 Transformation spaceTransformation;
576
1/1
✓ Branch 1 taken 3 times.
3 OptionalInteriorPartitionSurfaceGroup interiorPartitionSurfaceGroup = interiorPartitionSurface.interiorPartitionSurfaceGroup();
577
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (interiorPartitionSurfaceGroup) {
578
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 interiorPartitionSurfaceGroupTransformation = interiorPartitionSurfaceGroup->transformation();
579
580
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 OptionalSpace space = interiorPartitionSurfaceGroup->space();
581
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (space) {
582
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 spaceTransformation = space->transformation();
583 }
584 3 }
585
586 // convert vertices to absolute coordinates
587
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
6 return buildingTransformation * spaceTransformation * interiorPartitionSurfaceGroupTransformation * interiorPartitionSurface.vertices();
588 3 }
589
590 ✗ openstudio::Point3dVector ForwardTranslator::getPolygon(const openstudio::model::Luminaire& luminaire) {
591 ✗ Transformation buildingTransformation;
592 ✗ OptionalBuilding building = luminaire.model().getOptionalUniqueModelObject<Building>();
593 ✗ if (building) {
594 ✗ buildingTransformation = building->transformation();
595 }
596
597 ✗ Transformation spaceTransformation;
598 ✗ OptionalSpace space = luminaire.space();
599 ✗ if (space) {
600 ✗ spaceTransformation = space->transformation();
601 }
602
603 ✗ openstudio::Point3dVector triangle;
604 ✗ triangle.push_back(Point3d(0, 0, 0));
605 ✗ triangle.push_back(Point3d(1, 0, 0));
606 ✗ triangle.push_back(Point3d(0, 1, 0));
607
608 // convert vertices to absolute coordinates
609 ✗ return buildingTransformation * spaceTransformation * luminaire.transformation() * triangle;
610 ✗ }
611
612 3 openstudio::Point3d ForwardTranslator::getReferencePoint(const openstudio::model::DaylightingControl& control) {
613
1/1
✓ Branch 1 taken 3 times.
3 Transformation buildingTransformation;
614
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 OptionalBuilding building = control.model().getOptionalUniqueModelObject<Building>();
615
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (building) {
616
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 buildingTransformation = building->transformation();
617 }
618
619
1/1
✓ Branch 1 taken 3 times.
3 Transformation spaceTransformation;
620
1/1
✓ Branch 1 taken 3 times.
3 OptionalSpace space = control.space();
621
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (space) {
622
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 spaceTransformation = space->transformation();
623 }
624
625 // convert to absolute coordinates
626
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
6 return buildingTransformation * spaceTransformation * control.transformation() * Point3d(0, 0, 0);
627 3 }
628
629 3 openstudio::Vector3d ForwardTranslator::getSensorVector(const openstudio::model::DaylightingControl& control) {
630
1/1
✓ Branch 1 taken 3 times.
3 Transformation buildingTransformation;
631
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 OptionalBuilding building = control.model().getOptionalUniqueModelObject<Building>();
632
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (building) {
633
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 buildingTransformation = building->transformation();
634 }
635
636
1/1
✓ Branch 1 taken 3 times.
3 Transformation spaceTransformation;
637
1/1
✓ Branch 1 taken 3 times.
3 OptionalSpace space = control.space();
638
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (space) {
639
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 spaceTransformation = space->transformation();
640 }
641
642 // convert to absolute coordinates
643
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 Point3d endPoint = buildingTransformation * spaceTransformation * control.transformation() * Point3d(0, 0, 1);
644
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 Point3d startPoint = buildingTransformation * spaceTransformation * control.transformation() * Point3d(0, 0, 0);
645
646
1/1
✓ Branch 1 taken 3 times.
6 return (endPoint - startPoint);
647 3 }
648
649 ✗ openstudio::Vector3dVector ForwardTranslator::getViewVectors(const openstudio::model::DaylightingControl& control) {
650 ✗ Transformation buildingTransformation;
651 ✗ OptionalBuilding building = control.model().getOptionalUniqueModelObject<Building>();
652 ✗ if (building) {
653 ✗ buildingTransformation = building->transformation();
654 }
655
656 ✗ Transformation spaceTransformation;
657 ✗ OptionalSpace space = control.space();
658 ✗ if (space) {
659 ✗ spaceTransformation = space->transformation();
660 }
661
662 ✗ openstudio::Vector3dVector result;
663
664 ✗ double pi = boost::math::constants::pi<double>();
665 ✗ unsigned n = control.numberofDaylightingViews();
666 ✗ Point3d startPoint = buildingTransformation * spaceTransformation * control.transformation() * Point3d(0, 0, 0);
667 ✗ for (unsigned i = 0; i < n; ++i) {
668 ✗ double angle = 2.0 * i * pi / (double(n));
669 ✗ Point3d endPoint = buildingTransformation * spaceTransformation * control.transformation() * Point3d(std::sin(angle), std::cos(angle), 0);
670 ✗ result.push_back(endPoint - startPoint);
671 ✗ }
672
673 ✗ return result;
674 ✗ }
675
676 2 openstudio::Vector3dVector ForwardTranslator::getViewVectors(const openstudio::model::GlareSensor& control) {
677
1/1
✓ Branch 1 taken 2 times.
2 Transformation buildingTransformation;
678
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OptionalBuilding building = control.model().getOptionalUniqueModelObject<Building>();
679
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (building) {
680
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 buildingTransformation = building->transformation();
681 }
682
683
1/1
✓ Branch 1 taken 2 times.
2 Transformation spaceTransformation;
684
1/1
✓ Branch 1 taken 2 times.
2 OptionalSpace space = control.space();
685
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (space) {
686
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 spaceTransformation = space->transformation();
687 }
688
689 2 openstudio::Vector3dVector result;
690
691 2 double pi = boost::math::constants::pi<double>();
692
1/1
✓ Branch 1 taken 2 times.
2 unsigned n = control.numberofGlareViewVectors();
693
5/5
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
2 Point3d startPoint = buildingTransformation * spaceTransformation * control.transformation() * Point3d(0, 0, 0);
694
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 for (unsigned i = 0; i < n; ++i) {
695 2 double angle = 2.0 * i * pi / (double(n));
696
5/5
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
2 Point3d endPoint = buildingTransformation * spaceTransformation * control.transformation() * Point3d(std::sin(angle), std::cos(angle), 0);
697
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 result.push_back(endPoint - startPoint);
698 2 }
699
700 4 return result;
701 2 }
702
703 2 openstudio::Point3d ForwardTranslator::getReferencePoint(const openstudio::model::GlareSensor& sensor) {
704
1/1
✓ Branch 1 taken 2 times.
2 Transformation buildingTransformation;
705
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OptionalBuilding building = sensor.model().getOptionalUniqueModelObject<Building>();
706
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (building) {
707
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 buildingTransformation = building->transformation();
708 }
709
710
1/1
✓ Branch 1 taken 2 times.
2 Transformation spaceTransformation;
711
1/1
✓ Branch 1 taken 2 times.
2 OptionalSpace space = sensor.space();
712
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (space) {
713
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 spaceTransformation = space->transformation();
714 }
715
716 // convert to absolute coordinates
717
5/5
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
4 return buildingTransformation * spaceTransformation * sensor.transformation() * Point3d(0, 0, 0);
718 2 }
719
720 ✗ openstudio::Vector3d ForwardTranslator::getSensorVector(const openstudio::model::GlareSensor& sensor) {
721 ✗ Transformation buildingTransformation;
722 ✗ OptionalBuilding building = sensor.model().getOptionalUniqueModelObject<Building>();
723 ✗ if (building) {
724 ✗ buildingTransformation = building->transformation();
725 }
726
727 ✗ Transformation spaceTransformation;
728 ✗ OptionalSpace space = sensor.space();
729 ✗ if (space) {
730 ✗ spaceTransformation = space->transformation();
731 }
732
733 // convert to absolute coordinates
734 ✗ Point3d endPoint = buildingTransformation * spaceTransformation * sensor.transformation() * Point3d(0, 0, 1);
735 ✗ Point3d startPoint = buildingTransformation * spaceTransformation * sensor.transformation() * Point3d(0, 0, 0);
736
737 ✗ return (endPoint - startPoint);
738 ✗ }
739
740 3 openstudio::Point3dVector ForwardTranslator::getReferencePoints(const openstudio::model::IlluminanceMap& map) {
741
1/1
✓ Branch 1 taken 3 times.
3 Transformation buildingTransformation;
742
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 OptionalBuilding building = map.model().getOptionalUniqueModelObject<Building>();
743
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (building) {
744
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 buildingTransformation = building->transformation();
745 }
746
747
1/1
✓ Branch 1 taken 3 times.
3 Transformation spaceTransformation;
748
1/1
✓ Branch 1 taken 3 times.
3 OptionalSpace space = map.space();
749
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (space) {
750
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 spaceTransformation = space->transformation();
751 }
752
753 // convert vertices to absolute coordinates
754
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
6 return buildingTransformation * spaceTransformation * map.transformation() * map.referencePoints();
755 3 }
756
757 ✗ openstudio::Vector3d ForwardTranslator::getSensorVector(const openstudio::model::IlluminanceMap& map) {
758 ✗ Transformation buildingTransformation;
759 ✗ OptionalBuilding building = map.model().getOptionalUniqueModelObject<Building>();
760 ✗ if (building) {
761 ✗ buildingTransformation = building->transformation();
762 }
763
764 ✗ Transformation spaceTransformation;
765 ✗ OptionalSpace space = map.space();
766 ✗ if (space) {
767 ✗ spaceTransformation = space->transformation();
768 }
769
770 // convert to absolute coordinates
771 ✗ return buildingTransformation * spaceTransformation * map.transformation() * Vector3d(0, 0, 1);
772 ✗ }
773
774 6 void ForwardTranslator::clear() {
775 6 m_radMaterials.clear();
776 6 m_radMixMaterials.clear();
777 6 m_radMaterialsDC.clear();
778 6 m_radMaterialsWG0.clear();
779 6 m_radMaterialsSwitchableBase.clear();
780
781 6 m_radDCmats.clear();
782
783 6 m_radSceneFiles.clear();
784
785 6 m_radSpaces.clear();
786 6 m_radSensors.clear();
787 6 m_radGlareSensors.clear();
788 6 m_radMaps.clear();
789 6 m_radMapHandles.clear();
790 6 m_radViewPoints.clear();
791 6 m_radWindowGroups.clear();
792 6 m_radWindowGroupShades.clear();
793 6 }
794
795 3 WindowGroup ForwardTranslator::getWindowGroup(const openstudio::Vector3d& outwardNormal, const model::Space& space,
796 const model::ConstructionBase& construction,
797 const boost::optional<model::ShadingControl>& shadingControl,
798 const openstudio::Point3dVector& polygon) {
799
1/1
✓ Branch 1 taken 3 times.
3 WindowGroup result(outwardNormal, space, construction, shadingControl);
800
801
1/1
✓ Branch 1 taken 3 times.
3 std::stringstream ss;
802
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 ss << "WG" << m_windowGroupId;
803
1/1
✓ Branch 1 taken 3 times.
3 std::string name = ss.str();
804
805 // set the uncontrolled window group name
806
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 if (!shadingControl) {
807
1/1
✓ Branch 1 taken 3 times.
3 name = "WG0";
808 }
809
810
1/1
✓ Branch 1 taken 3 times.
3 result.setName(name);
811
812
1/1
✓ Branch 3 taken 3 times.
3 auto it = std::find(m_windowGroups.begin(), m_windowGroups.end(), result);
813
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3 if (it != m_windowGroups.end()) {
814 ✗ it->addWindowPolygon(polygon);
815 ✗ return *it;
816 }
817
818 // if we made a new group
819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (shadingControl) {
820 ✗ m_windowGroupId += 1;
821 }
822
823
1/1
✓ Branch 1 taken 3 times.
3 result.addWindowPolygon(polygon);
824
1/1
✓ Branch 1 taken 3 times.
3 m_windowGroups.push_back(result);
825 3 return result;
826 3 }
827
828 3 void ForwardTranslator::siteShadingSurfaceGroups(const openstudio::path& t_radDir,
829 const std::vector<openstudio::model::ShadingSurfaceGroup>& radShadingSurfaceGroups,
830 std::vector<openstudio::path>& t_outfiles) {
831
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 8 taken 3 times.
✓ Branch 11 taken 3 times.
✓ Branch 14 taken 3 times.
✓ Branch 17 taken 3 times.
3 LOG(Debug, "site shading groups found: " << radShadingSurfaceGroups.size());
832
833
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 if (!radShadingSurfaceGroups.empty()) {
834 3 std::set<std::string> siteShadingSurfaces;
835
836
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
6 for (const auto& shadingSurfaceGroup : radShadingSurfaceGroups) {
837
1/1
✓ Branch 1 taken 3 times.
3 std::vector<openstudio::model::ShadingSurface> shadingSurfaces = shadingSurfaceGroup.shadingSurfaces();
838
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
6 for (const auto& shadingSurface : shadingSurfaces) {
839 // clean name
840
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 std::string shadingSurface_name = cleanName(shadingSurface.name().get());
841
842
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
3 LOG(Debug, "site shading surface: " << shadingSurface_name);
843
844 // get reflectance
845 3 double interiorVisibleReflectance = 0.25; // default for site shading surfaces
846
2/3
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
6 if (shadingSurface.interiorVisibleAbsorptance()) {
847 ✗ double interiorVisibleAbsorptance = shadingSurface.interiorVisibleAbsorptance().get();
848 ✗ interiorVisibleReflectance = 1.0 - interiorVisibleAbsorptance;
849 }
850
851 3 double exteriorVisibleReflectance = 0.25; // default
852
2/3
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
6 if (shadingSurface.exteriorVisibleAbsorptance()) {
853 ✗ double exteriorVisibleAbsorptance = shadingSurface.exteriorVisibleAbsorptance().get();
854 ✗ exteriorVisibleReflectance = 1.0 - exteriorVisibleAbsorptance;
855 }
856
857 // write (two-sided) material
858 // exterior reflectance for front side
859
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
9 m_radMaterials.insert("void plastic refl_" + formatString(exteriorVisibleReflectance, 3) + "\n0\n0\n5\n"
860
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
12 + formatString(exteriorVisibleReflectance, 3) + " " + formatString(exteriorVisibleReflectance, 3) + " "
861
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
12 + formatString(exteriorVisibleReflectance, 3) + " 0 0\n\n");
862
863 // interior reflectance for back side
864
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
9 m_radMaterials.insert("void plastic refl_" + formatString(interiorVisibleReflectance, 3) + "\n0\n0\n5\n"
865
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
12 + formatString(interiorVisibleReflectance, 3) + " " + formatString(interiorVisibleReflectance, 3) + " "
866
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
12 + formatString(interiorVisibleReflectance, 3) + " 0 0\n\n");
867
868 // roll up into a mixfunc...
869 // void mixfunc overhang
870 // 4 front back if(Rdot,1,0) .
871 // 0
872 // 0
873
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
9 m_radMixMaterials.insert("void mixfunc reflBACK_" + formatString(interiorVisibleReflectance, 3) + "_reflFRONT_"
874
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
12 + formatString(exteriorVisibleReflectance, 3) + "\n4 " + "refl_" + formatString(exteriorVisibleReflectance, 3)
875
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
12 + " " + "refl_" + formatString(interiorVisibleReflectance, 3) + " if(Rdot,1,0) .\n0\n0\n\n");
876
877 // polygon header
878
1/1
✓ Branch 1 taken 3 times.
3 openstudio::Point3dVector polygon = openstudio::radiance::ForwardTranslator::getPolygon(shadingSurface);
879
880
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
6 std::string shadingsurface = "reflBACK_" + formatString(interiorVisibleReflectance, 3) + "_reflFRONT_"
881
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
9 + formatString(exteriorVisibleReflectance, 3) + " polygon " + shadingSurface_name + "\n";
882
4/4
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
✓ Branch 11 taken 3 times.
3 shadingsurface += "0\n0\n" + formatString(polygon.size() * 3) + "\n";
883
884
2/2
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 3 times.
15 for (auto vertex = polygon.begin(); vertex != polygon.end(); ++vertex) {
885
12/12
✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
✓ Branch 9 taken 12 times.
✓ Branch 12 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
✓ Branch 22 taken 12 times.
✓ Branch 25 taken 12 times.
✓ Branch 28 taken 12 times.
✓ Branch 31 taken 12 times.
✓ Branch 34 taken 12 times.
✓ Branch 37 taken 12 times.
12 shadingsurface += formatString(vertex->x()) + " " + formatString(vertex->y()) + " " + formatString(vertex->z()) + "\n";
886 }
887
888
1/1
✓ Branch 1 taken 3 times.
3 siteShadingSurfaces.insert(shadingsurface);
889 3 }
890 3 }
891
892
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 openstudio::path filename = t_radDir / openstudio::toPath("/scene/shading_site.rad");
893
1/1
✓ Branch 1 taken 3 times.
3 OFSTREAM f(filename);
894
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 if (f.is_open()) {
895
1/1
✓ Branch 1 taken 3 times.
3 t_outfiles.push_back(filename);
896
1/1
✓ Branch 1 taken 3 times.
3 m_radSceneFiles.push_back(filename);
897
898
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
6 for (const auto& line : siteShadingSurfaces) {
899
1/1
✓ Branch 1 taken 3 times.
3 f << line;
900 }
901 } else {
902 ✗ LOG(Error, "Cannot open file '" << toString(filename) << "' for writing");
903 }
904 3 }
905 3 }
906
907 3 void ForwardTranslator::buildingShadingSurfaceGroups(const openstudio::path& t_radDir,
908 const std::vector<openstudio::model::ShadingSurfaceGroup>& t_radShadingSurfaceGroups,
909 std::vector<openstudio::path>& t_outfiles) {
910
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 8 taken 3 times.
✓ Branch 11 taken 3 times.
✓ Branch 14 taken 3 times.
✓ Branch 17 taken 3 times.
3 LOG(Debug, "building shading groups found: " << t_radShadingSurfaceGroups.size());
911
912
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 if (!t_radShadingSurfaceGroups.empty()) {
913 3 std::set<std::string> buildingShadingSurfaces;
914
915
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
6 for (const auto& group : t_radShadingSurfaceGroups) {
916
1/1
✓ Branch 1 taken 3 times.
3 std::vector<openstudio::model::ShadingSurface> shadingSurfaces = group.shadingSurfaces();
917
918
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
6 for (const auto& shadingSurface : shadingSurfaces) {
919 // clean name
920
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 std::string shadingSurface_name = cleanName(shadingSurface.name().get());
921
922
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
3 LOG(Debug, "building shading surface: " << shadingSurface_name);
923
924 // get reflectance
925 3 double interiorVisibleReflectance = 0.25; // default for building shading surfaces
926
2/3
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
6 if (shadingSurface.interiorVisibleAbsorptance()) {
927 ✗ double interiorVisibleAbsorptance = shadingSurface.interiorVisibleAbsorptance().get();
928 ✗ interiorVisibleReflectance = 1.0 - interiorVisibleAbsorptance;
929 }
930
931 3 double exteriorVisibleReflectance = 0.25; // default
932
2/3
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
6 if (shadingSurface.exteriorVisibleAbsorptance()) {
933 ✗ double exteriorVisibleAbsorptance = shadingSurface.exteriorVisibleAbsorptance().get();
934 ✗ exteriorVisibleReflectance = 1.0 - exteriorVisibleAbsorptance;
935 }
936
937 // write (two-sided) material
938 // exterior reflectance for front side
939
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
9 m_radMaterials.insert("void plastic refl_" + formatString(exteriorVisibleReflectance, 3) + "\n0\n0\n5\n"
940
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
12 + formatString(exteriorVisibleReflectance, 3) + " " + formatString(exteriorVisibleReflectance, 3) + " "
941
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
12 + formatString(exteriorVisibleReflectance, 3) + " 0 0\n\n");
942
943 // interior reflectance for back side
944
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
9 m_radMaterials.insert("void plastic refl_" + formatString(interiorVisibleReflectance, 3) + "\n0\n0\n5\n"
945
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
12 + formatString(interiorVisibleReflectance, 3) + " " + formatString(interiorVisibleReflectance, 3) + " "
946
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
12 + formatString(interiorVisibleReflectance, 3) + " 0 0\n\n");
947
948 // roll up into a mixfunc...
949 // void mixfunc overhang
950 // 4 front back if(Rdot,1,0) .
951 // 0
952 // 0
953
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
9 m_radMixMaterials.insert("void mixfunc reflBACK_" + formatString(interiorVisibleReflectance, 3) + "_reflFRONT_"
954
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
12 + formatString(exteriorVisibleReflectance, 3) + "\n4 " + "refl_" + formatString(exteriorVisibleReflectance, 3)
955
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
12 + " " + "refl_" + formatString(interiorVisibleReflectance, 3) + " if(Rdot,1,0) .\n0\n0\n\n");
956
957 // start polygon
958
1/1
✓ Branch 1 taken 3 times.
3 openstudio::Point3dVector polygon = openstudio::radiance::ForwardTranslator::getPolygon(shadingSurface);
959
960 // header
961
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
6 std::string shadingsurface = "reflBACK_" + formatString(interiorVisibleReflectance, 3) + "_reflFRONT_"
962
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
9 + formatString(exteriorVisibleReflectance, 3) + " polygon " + shadingSurface_name + "\n";
963
4/4
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
✓ Branch 11 taken 3 times.
3 shadingsurface += "0\n0\n" + formatString(polygon.size() * 3) + "\n";
964
965 //
966
967
2/2
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 3 times.
15 for (const auto& vertex : polygon) {
968
12/12
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
✓ Branch 22 taken 12 times.
✓ Branch 25 taken 12 times.
✓ Branch 28 taken 12 times.
✓ Branch 31 taken 12 times.
✓ Branch 34 taken 12 times.
12 shadingsurface += formatString(vertex.x()) + " " + formatString(vertex.y()) + " " + formatString(vertex.z()) + "\n\n";
969 }
970
971
1/1
✓ Branch 1 taken 3 times.
3 buildingShadingSurfaces.insert(shadingsurface);
972 3 }
973 3 }
974
975
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 openstudio::path filename = t_radDir / openstudio::toPath("scene/shading_building.rad");
976
1/1
✓ Branch 1 taken 3 times.
3 OFSTREAM f(filename);
977
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 if (f.is_open()) {
978
1/1
✓ Branch 1 taken 3 times.
3 t_outfiles.push_back(filename);
979
1/1
✓ Branch 1 taken 3 times.
3 m_radSceneFiles.push_back(filename);
980
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
6 for (const auto& line : buildingShadingSurfaces) {
981
1/1
✓ Branch 1 taken 3 times.
3 f << line;
982 }
983 } else {
984 ✗ LOG(Error, "Cannot open file '" << toString(filename) << "' for writing");
985 }
986 3 }
987 3 }
988
989 3 void ForwardTranslator::buildingSpaces(const openstudio::path& t_radDir, const std::vector<openstudio::model::Space>& t_spaces,
990 std::vector<openstudio::path>& t_outfiles) {
991 3 std::vector<std::string> space_names;
992
993
2/2
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 3 times.
15 for (const auto& space : t_spaces) {
994
3/3
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
12 std::string space_name = cleanName(space.name().get());
995
996
1/1
✓ Branch 1 taken 12 times.
12 space_names.push_back(space_name);
997
6/6
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
12 LOG(Debug, "Processing space: " << space_name);
998
999 // split model into zone-based Radiance .rad files
1000
3/3
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
12 m_radSpaces[space_name] = "#\n# geometry file for space: " + space_name + "\n#\n\n";
1001
1002 // loop over surfaces in space
1003
1004
1/1
✓ Branch 1 taken 12 times.
12 std::vector<openstudio::model::Surface> surfaces = space.surfaces();
1005
1006
2/2
✓ Branch 5 taken 72 times.
✓ Branch 6 taken 12 times.
84 for (const auto& surface : surfaces) {
1007
1008 // skip if air wall
1009
3/3
✓ Branch 1 taken 72 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 48 times.
72 if (surface.isAirWall()) {
1010 24 continue;
1011 }
1012
1013
3/3
✓ Branch 1 taken 48 times.
✓ Branch 4 taken 48 times.
✓ Branch 7 taken 48 times.
48 std::string surface_name = cleanName(surface.name().get());
1014
1015 // add surface to space geometry
1016
4/4
✓ Branch 1 taken 48 times.
✓ Branch 4 taken 48 times.
✓ Branch 7 taken 48 times.
✓ Branch 10 taken 48 times.
48 m_radSpaces[space_name] += "# surface: " + surface_name + "\n";
1017
1018 // set construction of surface
1019
3/3
✓ Branch 1 taken 48 times.
✓ Branch 4 taken 48 times.
✓ Branch 7 taken 48 times.
48 std::string constructionName = surface.getString(2).get();
1020
4/4
✓ Branch 1 taken 48 times.
✓ Branch 4 taken 48 times.
✓ Branch 7 taken 48 times.
✓ Branch 10 taken 48 times.
48 m_radSpaces[space_name] += "# construction: " + constructionName + "\n";
1021
1022 // get reflectances
1023 48 double interiorVisibleReflectance = 0.5; // default for space surfaces
1024
2/3
✓ Branch 1 taken 48 times.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
96 if (surface.interiorVisibleAbsorptance()) {
1025
2/2
✓ Branch 1 taken 48 times.
✓ Branch 4 taken 48 times.
48 double interiorVisibleAbsorptance = surface.interiorVisibleAbsorptance().get();
1026 48 interiorVisibleReflectance = 1.0 - interiorVisibleAbsorptance;
1027 }
1028 48 double exteriorVisibleReflectance = 0.25; // default for space surfaces (exterior)
1029
2/3
✓ Branch 1 taken 48 times.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
96 if (surface.exteriorVisibleAbsorptance()) {
1030
2/2
✓ Branch 1 taken 48 times.
✓ Branch 4 taken 48 times.
48 double exteriorVisibleAbsorptance = surface.exteriorVisibleAbsorptance().get();
1031 48 exteriorVisibleReflectance = 1.0 - exteriorVisibleAbsorptance;
1032 }
1033
1034 // create polygon object
1035
1/1
✓ Branch 1 taken 48 times.
48 openstudio::Point3dVectorVector polygons = openstudio::radiance::ForwardTranslator::getPolygons(surface);
1036
2/2
✓ Branch 5 taken 63 times.
✓ Branch 6 taken 48 times.
111 for (const openstudio::Point3dVector& polygon : polygons) {
1037
1038
2/3
✓ Branch 1 taken 63 times.
✓ Branch 5 taken 63 times.
✗ Branch 6 not taken.
63 if (!surface.adjacentSurface()) {
1039 // 2-sided material
1040
1041 // header
1042
3/3
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
189 m_radSpaces[space_name] += "# reflectance (int) = " + formatString(interiorVisibleReflectance, 3)
1043
5/5
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
✓ Branch 10 taken 63 times.
✓ Branch 13 taken 63 times.
252 + "\n# reflectance (ext) = " + formatString(exteriorVisibleReflectance, 3) + "\n";
1044
1045 // material definition
1046
1047 //interior
1048
4/4
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
✓ Branch 10 taken 63 times.
189 m_radMaterials.insert("void plastic refl_" + formatString(interiorVisibleReflectance, 3) + "\n0\n0\n5\n"
1049
6/6
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
✓ Branch 10 taken 63 times.
✓ Branch 13 taken 63 times.
✓ Branch 16 taken 63 times.
252 + formatString(interiorVisibleReflectance, 3) + " " + formatString(interiorVisibleReflectance, 3) + " "
1050
3/3
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
252 + formatString(interiorVisibleReflectance, 3) + " 0 0\n\n");
1051 //exterior
1052
4/4
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
✓ Branch 10 taken 63 times.
189 m_radMaterials.insert("void plastic refl_" + formatString(exteriorVisibleReflectance, 3) + "\n0\n0\n5\n"
1053
6/6
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
✓ Branch 10 taken 63 times.
✓ Branch 13 taken 63 times.
✓ Branch 16 taken 63 times.
252 + formatString(exteriorVisibleReflectance, 3) + " " + formatString(exteriorVisibleReflectance, 3) + " "
1054
3/3
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
252 + formatString(exteriorVisibleReflectance, 3) + " 0 0\n\n");
1055 // mixfunc
1056
4/4
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
✓ Branch 10 taken 63 times.
189 m_radMixMaterials.insert("void mixfunc reflBACK_" + formatString(interiorVisibleReflectance, 3) + "_reflFRONT_"
1057
6/6
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
✓ Branch 10 taken 63 times.
✓ Branch 13 taken 63 times.
✓ Branch 16 taken 63 times.
252 + formatString(exteriorVisibleReflectance, 3) + "\n4 " + "refl_" + formatString(exteriorVisibleReflectance, 3)
1058
5/5
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
✓ Branch 10 taken 63 times.
✓ Branch 13 taken 63 times.
252 + " " + "refl_" + formatString(interiorVisibleReflectance, 3) + " if(Rdot,1,0) .\n0\n0\n\n");
1059
1060 // polygon reference
1061
4/4
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
✓ Branch 10 taken 63 times.
189 m_radSpaces[space_name] += "reflBACK_" + formatString(interiorVisibleReflectance, 3) + "_reflFRONT_"
1062
5/5
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
✓ Branch 10 taken 63 times.
✓ Branch 13 taken 63 times.
252 + formatString(exteriorVisibleReflectance, 3) + " polygon " + surface_name + "\n0\n0\n"
1063
4/4
✓ Branch 2 taken 63 times.
✓ Branch 5 taken 63 times.
✓ Branch 8 taken 63 times.
✓ Branch 11 taken 63 times.
252 + formatString(polygon.size() * 3) + "\n";
1064 } else {
1065 // interior-only material
1066
1067 // header
1068 ✗ m_radSpaces[space_name] += "# reflectance: " + formatString(interiorVisibleReflectance, 3) + "\n";
1069
1070 // material definition
1071 ✗ m_radMaterials.insert("void plastic refl_" + formatString(interiorVisibleReflectance, 3) + "\n0\n0\n5\n"
1072 ✗ + formatString(interiorVisibleReflectance, 3) + " " + formatString(interiorVisibleReflectance, 3) + " "
1073 ✗ + formatString(interiorVisibleReflectance, 3) + " 0 0\n");
1074
1075 // polygon reference
1076 ✗ m_radSpaces[space_name] += "refl_" + formatString(interiorVisibleReflectance, 3) + " polygon " + surface_name + "\n0\n0\n"
1077 ✗ + formatString(polygon.size() * 3) + "\n";
1078 };
1079
1080 // add polygon vertices
1081
2/2
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 63 times.
315 for (const auto& vertex : polygon) {
1082
13/13
✓ Branch 1 taken 252 times.
✓ Branch 4 taken 252 times.
✓ Branch 7 taken 252 times.
✓ Branch 10 taken 252 times.
✓ Branch 13 taken 252 times.
✓ Branch 16 taken 252 times.
✓ Branch 19 taken 252 times.
✓ Branch 22 taken 252 times.
✓ Branch 25 taken 252 times.
✓ Branch 28 taken 252 times.
✓ Branch 31 taken 252 times.
✓ Branch 34 taken 252 times.
✓ Branch 37 taken 252 times.
252 m_radSpaces[space_name] += formatString(vertex.x()) + " " + formatString(vertex.y()) + " " + formatString(vertex.z()) + "\n";
1083 }
1084
2/2
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
63 m_radSpaces[space_name] += "\n";
1085 }
1086 // end(surface)
1087
1088 // get sub surfaces
1089
1/1
✓ Branch 1 taken 48 times.
48 std::vector<openstudio::model::SubSurface> subSurfaces = surface.subSurfaces();
1090
1091
2/2
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 48 times.
54 for (const auto& subSurface : subSurfaces) {
1092
1093
1/1
✓ Branch 1 taken 6 times.
12 std::string rMaterial = "glass";
1094
1/1
✓ Branch 1 taken 6 times.
12 std::string matString = "";
1095
1/1
✓ Branch 1 taken 6 times.
12 std::string matStringTinted = "";
1096
1/1
✓ Branch 1 taken 6 times.
6 std::string shadeBSDF = "";
1097
1098
1/1
✓ Branch 1 taken 6 times.
6 boost::optional<model::ConstructionBase> construction = subSurface.construction();
1099
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
6 if (!construction) {
1100 ✗ LOG(Error, "SubSurface " << subSurface.name().get()
1101 << " is not associated with a Construction, it cannot not be translated. Radiance model translation failed.");
1102 ✗ continue;
1103 ✗ }
1104
1105
1/1
✓ Branch 1 taken 6 times.
6 boost::optional<model::WindowPropertyFrameAndDivider> frameAndDivider = subSurface.windowPropertyFrameAndDivider();
1106
1107 // get the polygon
1108
1/1
✓ Branch 1 taken 6 times.
6 openstudio::Point3dVector polygon = openstudio::radiance::ForwardTranslator::getPolygon(subSurface);
1109
1110
3/3
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
6 std::string subSurface_name = cleanName(subSurface.name().get());
1111
1112
2/2
✓ Branch 2 taken 6 times.
✓ Branch 5 taken 6 times.
6 std::string subSurfaceUpCase = boost::algorithm::to_upper_copy(subSurface.subSurfaceType());
1113
1114
5/7
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 3 times.
✓ Branch 11 taken 3 times.
✗ Branch 12 not taken.
9 if (subSurfaceUpCase == "FIXEDWINDOW" || subSurfaceUpCase == "OPERABLEWINDOW" || subSurfaceUpCase == "GLASSDOOR"
1115
6/7
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 3 times.
9 || subSurfaceUpCase == "SKYLIGHT") {
1116
2/3
✓ Branch 1 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if (!subSurface.visibleTransmittance()) {
1117 ✗ LOG(Error, "Cannot determine visible transmittance for SubSurface "
1118 << subSurface.name().get() << ", it cannot not be translated. Radiance model translation failed.");
1119 ✗ continue;
1120 ✗ }
1121
1122 // TODO: This is going to need update!
1123 3 boost::optional<model::ShadingControl> shadingControl;
1124
1/1
✓ Branch 1 taken 3 times.
3 auto scs = subSurface.shadingControls();
1125
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
3 if (!scs.empty()) {
1126 ✗ shadingControl = scs[0];
1127 }
1128
1129 // future support for mullion factor
1130 3 double visibleTransmittanceMultiplier = 1.0;
1131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (frameAndDivider) {
1132 // DLM: Rob what should we do here?
1133 // <punt>
1134 ✗ visibleTransmittanceMultiplier = 1.0;
1135 // </punt>
1136 }
1137
1138 // find window group
1139
1/1
✓ Branch 1 taken 3 times.
3 openstudio::Vector3d outwardNormal = surface.outwardNormal();
1140
1141
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 WindowGroup windowGroup = getWindowGroup(outwardNormal, space, *construction, shadingControl, polygon);
1142
1/1
✓ Branch 1 taken 3 times.
3 std::string windowGroup_name = windowGroup.name();
1143
1144 // get the control
1145
1/1
✓ Branch 1 taken 3 times.
3 WindowGroupControl control = windowGroup.windowGroupControl();
1146
1147
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (control.outwardNormal) {
1148
1149
22/22
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 25 taken 3 times.
✓ Branch 28 taken 3 times.
✓ Branch 31 taken 3 times.
✓ Branch 34 taken 3 times.
✓ Branch 37 taken 3 times.
✓ Branch 40 taken 3 times.
✓ Branch 43 taken 3 times.
✓ Branch 46 taken 3 times.
✓ Branch 49 taken 3 times.
✓ Branch 52 taken 3 times.
✓ Branch 55 taken 3 times.
✓ Branch 69 taken 3 times.
✓ Branch 72 taken 3 times.
✓ Branch 75 taken 3 times.
3 LOG(Info, windowGroup.name() + " outward normal:" + formatString(control.outwardNormal->x()) + " "
1150 + formatString(control.outwardNormal->y()) + " " + formatString(control.outwardNormal->z()) + "\n");
1151 }
1152
1153
1/1
✓ Branch 1 taken 3 times.
3 std::string winUpVector = "Z";
1154
2/3
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
3 if (subSurfaceUpCase == "SKYLIGHT") {
1155 ✗ winUpVector = "Y";
1156 }
1157
1158
2/3
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
3 if (m_radWindowGroups.find(windowGroup_name) == m_radWindowGroups.end()) {
1159
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 m_radWindowGroups[windowGroup_name] = "# OpenStudio Window Group: " + windowGroup_name + "\n";
1160
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
3 if (windowGroup_name == "WG0") {
1161
1/1
✓ Branch 1 taken 3 times.
3 m_radWindowGroups[windowGroup_name] +=
1162
1/1
✓ Branch 1 taken 3 times.
3 "# All uncontrolled windows, multiple orientations possible, no hemispherical sampling info.\n\n";
1163 } else {
1164 // 3-phase/rfluxmtx support
1165 // moved to "shade" polygon now 2015.07.23 RPG
1166 }
1167 }
1168
1169
12/12
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 25 taken 3 times.
✓ Branch 35 taken 3 times.
✓ Branch 38 taken 3 times.
✓ Branch 41 taken 3 times.
3 LOG(Info, "found a " + subSurface.subSurfaceType() + " named '" + subSurface_name + "', windowGroup_name = '" + windowGroup_name + "'");
1170
1171 // set transmittance(s)
1172
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 double visibleTransmittance = subSurface.visibleTransmittance().get() * visibleTransmittanceMultiplier;
1173
1174 // convert transmittance(Tn) to transmissivity(tn) for Radiance material
1175 // tn = (std::sqrt(.8402528435+.0072522239*Tn*Tn)-.9166530661)/.0036261119/Tn
1176 // or: tn = 1.0895 * Tn (Thanks, Axel Jacobs! (http://www.jaloxa.eu/resources/radiance/documentation/docs/radiance_cookbook.pdf, p. 21))
1177 3 double tVis = visibleTransmittance;
1178 3 double tn = 0;
1179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (tVis == 0.0) {
1180 ✗ LOG(Warn, subSurface_name << " has transmittance of zero.");
1181 ✗ tn = 0.0;
1182 ✗ LOG(Debug, "Tvis = " << tVis << " (tn = " << tn << ")");
1183 } else {
1184 3 tn = tVis * 1.0895;
1185
9/9
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 25 taken 3 times.
3 LOG(Debug, "Tvis = " << tVis << " (tn = " << tn << ")");
1186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (tVis >= 0.92) {
1187 ✗ LOG(Warn, "glazing material definition in " + space_name + "; Tvis =" + formatString(tVis, 3) + " is very high. Suspect.");
1188 }
1189 }
1190
1191 // get optional switchable glazing material
1192
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<double> visibleTransmittanceTinted = 0.0;
1193 3 double tnTinted = 0.0;
1194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (shadingControl) {
1195 ✗ if (shadingControl->construction()) {
1196 ✗ visibleTransmittanceTinted = shadingControl->construction()->visibleTransmittance();
1197 ✗ LOG(Info, "this is switchable glazing");
1198 ✗ double tintFac = visibleTransmittanceTinted.get() / tVis;
1199 ✗ tnTinted = tn * tintFac;
1200 } else {
1201 // something else
1202 }
1203 }
1204
1205 // make materials for single phase (AKA two-phase, depends on whom you talk to)
1206
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
3 if (construction->isSolarDiffusing()) {
1207 // create Radiance trans material based on transmittance, 100% diffuse (to match E+ performance)
1208 // trans formulae (from "Rendering with Radiance", sec. 5.2.6):
1209 // A7=Ts / ( Td+Ts )
1210 // A6=( Td+Ts ) / ( Rd+Td+Ts )
1211 // A5=Sr
1212 // A4=Rs
1213 // A3=Cb / ( (1-Rs)*(1-A6) )
1214 // A2=Cg / ( (1-Rs)*(1-A6) )
1215 // A1=Cr / ( (1-Rs)*(1-A6) )
1216
1217 // set some constants, let's not get crazy
1218 ✗ double tS = 0.0; // transmitted specularity
1219 // rD = 0.95 // diffuse reflectance (not used for monochromatic trans mats)
1220 ✗ double sR = 0.0; // surface roughness
1221 ✗ double rS = 0.05; // specular reflectance
1222 ✗ double cRGB = (0.95 - tVis);
1223
1224 // trans parameters
1225 ✗ double transA7 = tS / (tVis + tS);
1226 // transA6 = (tn + tS) / (rD + tVis + tS);
1227 ✗ double transA6 = (tn + tS) / (cRGB + tn + tS);
1228 ✗ double transA5 = sR;
1229 ✗ double transA4 = rS;
1230 // transA3 = cRGB / (1-rS)*(1-transA6);
1231 // transA2 = cRGB / (1-rS)*(1-transA6);
1232 // transA1 = cRGB / (1-rS)*(1-transA6);
1233 ✗ double transA3 = cRGB; // monochromatic
1234 ✗ double transA2 = cRGB; // monochromatic
1235 ✗ double transA1 = cRGB; // monochromatic
1236
1237 ✗ rMaterial = "trans";
1238 ✗ matString = "0\n0\n7\n" + formatString(transA1, 3) + " " + formatString(transA2, 3) + " " + formatString(transA3, 3) + " "
1239 ✗ + formatString(transA4, 3) + " " + formatString(transA5, 3) + " " + formatString(transA6, 3) + " "
1240 ✗ + formatString(transA7, 2) + "\n";
1241 //double nTs = 0.0; // transmitted specularity
1242
1243 ✗ if (tVis >= 0.6) {
1244 ✗ LOG(Warn, "dubious glazing material definition in " + space_name + "; Tvis =" + formatString(tVis, 2) + ", yet diffuse? Suspect.");
1245 }
1246
1247 } else {
1248
1249
9/9
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 25 taken 3 times.
3 matString = "0\n0\n3\n" + formatString(tn, 3) + " " + formatString(tn, 3) + " " + formatString(tn, 3) + "\n";
1250
1251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (shadingControl) {
1252 ✗ if (shadingControl->construction()) {
1253 matStringTinted =
1254 ✗ "0\n0\n3\n" + formatString(tnTinted, 3) + " " + formatString(tnTinted, 3) + " " + formatString(tnTinted, 3) + "\n";
1255 }
1256 }
1257 }
1258
1259 // write the window
1260
1261 // write reveal surfaces from window frame and divider, add small (3") inside reveals if no framediv object
1262
1263 3 boost::optional<double> outsideRevealDepth;
1264 3 boost::optional<double> insideRevealDepth;
1265 3 boost::optional<double> insideSillDepth;
1266
1267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (frameAndDivider) {
1268
1269 ✗ if (frameAndDivider->isOutsideRevealDepthDefaulted()) {
1270 ✗ outsideRevealDepth = 0.0;
1271 } else {
1272 ✗ outsideRevealDepth = frameAndDivider->outsideRevealDepth();
1273 }
1274
1275 ✗ if (frameAndDivider->isInsideRevealDepthDefaulted()) {
1276 ✗ insideRevealDepth = 0.05;
1277 } else {
1278 // ensure there's a reasonable minimum to contain the shade/blind
1279 ✗ if (insideRevealDepth < 0.05) {
1280 ✗ insideRevealDepth = 0.05;
1281 ✗ LOG(Warn, "inside reveal depth increased to 0.05 m");
1282 } else {
1283 ✗ insideRevealDepth = frameAndDivider->insideRevealDepth();
1284 }
1285 }
1286
1287 ✗ if (frameAndDivider->isInsideSillDepthDefaulted()) {
1288 ✗ insideSillDepth = 0.05;
1289 } else {
1290 ✗ if (insideSillDepth < 0.05) {
1291 ✗ insideSillDepth = 0.05;
1292 ✗ LOG(Warn, "inside sill depth increased to 0.05 m");
1293 } else {
1294 ✗ insideSillDepth = frameAndDivider->insideSillDepth();
1295 }
1296 }
1297
1298 } else {
1299
1300
1/1
✓ Branch 1 taken 3 times.
3 outsideRevealDepth = 0.0;
1301
1/1
✓ Branch 1 taken 3 times.
3 insideRevealDepth = 0.05;
1302
1/1
✓ Branch 1 taken 3 times.
3 insideSillDepth = 0.05;
1303 }
1304
1305
1/1
✓ Branch 1 taken 3 times.
3 openstudio::Vector3d offset;
1306
1307 // subSurface.outwardNormal not in global coordinate system
1308
1/1
✓ Branch 1 taken 3 times.
3 outwardNormal = subSurface.outwardNormal();
1309
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<Vector3d> optionalOutwardNormal = openstudio::getOutwardNormal(polygon);
1310
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (optionalOutwardNormal) {
1311
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 Vector3d outwardNormal = *optionalOutwardNormal;
1312
1313 3 size_t N = polygon.size();
1314
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for (size_t i = 0; i < N; ++i) {
1315 12 size_t index1 = i;
1316 12 size_t index2 = (i + 1) % N;
1317
1318
4/7
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
12 if (outsideRevealDepth && (*outsideRevealDepth > 0.0)) {
1319 // window polygon is already offset from the wall
1320 ✗ offset = outsideRevealDepth.get() * outwardNormal;
1321 ✗ Point3d vertex1 = polygon[index1];
1322 ✗ Point3d vertex2 = polygon[index1] + offset;
1323 ✗ Point3d vertex3 = polygon[index2] + offset;
1324 ✗ Point3d vertex4 = polygon[index2];
1325
1326 // TODO: get exterior reflectance of surface
1327 ✗ double interiorVisibleReflectance = 0.5;
1328 ✗ double exteriorVisibleReflectance = 0.2;
1329 //polygon header
1330 ✗ m_radSpaces[space_name] += "#--interiorVisibleReflectance = " + formatString(interiorVisibleReflectance, 3) + "\n";
1331 ✗ m_radSpaces[space_name] += "#--exteriorVisibleReflectance = " + formatString(exteriorVisibleReflectance, 3) + "\n";
1332 // write material
1333 ✗ m_radMaterials.insert("void plastic refl_" + formatString(exteriorVisibleReflectance, 3) + "\n0\n0\n5\n"
1334 ✗ + formatString(exteriorVisibleReflectance, 3) + " " + formatString(exteriorVisibleReflectance, 3) + " "
1335 ✗ + formatString(exteriorVisibleReflectance, 3) + " 0 0\n\n");
1336 // write polygon
1337 ✗ m_radSpaces[space_name] +=
1338 ✗ "refl_" + formatString(exteriorVisibleReflectance, 3) + " polygon outside_reveal_" + subSurface_name + std::to_string(i) + "\n";
1339 ✗ m_radSpaces[space_name] += "0\n0\n" + formatString(4 * 3) + "\n";
1340 ✗ m_radSpaces[space_name] += formatString(vertex1.x()) + " " + formatString(vertex1.y()) + " " + formatString(vertex1.z()) + "\n\n";
1341 ✗ m_radSpaces[space_name] += formatString(vertex2.x()) + " " + formatString(vertex2.y()) + " " + formatString(vertex2.z()) + "\n\n";
1342 ✗ m_radSpaces[space_name] += formatString(vertex3.x()) + " " + formatString(vertex3.y()) + " " + formatString(vertex3.z()) + "\n\n";
1343 ✗ m_radSpaces[space_name] += formatString(vertex4.x()) + " " + formatString(vertex4.y()) + " " + formatString(vertex4.z()) + "\n\n";
1344 ✗ }
1345
1346 // make interior sill/reveal surfaces
1347
4/7
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 12 times.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
12 if (insideRevealDepth && (*insideRevealDepth > 0.0)) {
1348
1349 // window polygon is already offset from the wall
1350
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 offset = -insideRevealDepth.get() * outwardNormal;
1351
1/1
✓ Branch 2 taken 12 times.
12 Point3d vertex1 = polygon[index1];
1352
1/1
✓ Branch 2 taken 12 times.
12 Point3d vertex2 = polygon[index1] + offset;
1353
1/1
✓ Branch 2 taken 12 times.
12 Point3d vertex3 = polygon[index2] + offset;
1354
1/1
✓ Branch 2 taken 12 times.
12 Point3d vertex4 = polygon[index2];
1355
1356 // TODO: get exterior reflectance of surface
1357 12 double interiorVisibleReflectance = 0.5;
1358 12 double exteriorVisibleReflectance = 0.2;
1359 //polygon header
1360
5/5
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
12 m_radSpaces[space_name] += "#--interiorVisibleReflectance = " + formatString(interiorVisibleReflectance, 3) + "\n";
1361
5/5
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
12 m_radSpaces[space_name] += "#--exteriorVisibleReflectance = " + formatString(exteriorVisibleReflectance, 3) + "\n";
1362 // write material
1363
4/4
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
36 m_radMaterials.insert("void plastic refl_" + formatString(interiorVisibleReflectance, 3) + "\n0\n0\n5\n"
1364
6/6
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
48 + formatString(interiorVisibleReflectance, 3) + " " + formatString(interiorVisibleReflectance, 3) + " "
1365
3/3
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
48 + formatString(interiorVisibleReflectance, 3) + " 0 0\n\n");
1366 // write polygon
1367
1/1
✓ Branch 1 taken 12 times.
12 m_radSpaces[space_name] +=
1368
8/8
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
✓ Branch 22 taken 12 times.
24 "refl_" + formatString(interiorVisibleReflectance, 3) + " polygon inside_reveal_" + subSurface_name + std::to_string(i) + "\n";
1369
5/5
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
12 m_radSpaces[space_name] += "0\n0\n" + formatString(4 * 3) + "\n";
1370
13/13
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
✓ Branch 22 taken 12 times.
✓ Branch 25 taken 12 times.
✓ Branch 28 taken 12 times.
✓ Branch 31 taken 12 times.
✓ Branch 34 taken 12 times.
✓ Branch 37 taken 12 times.
12 m_radSpaces[space_name] += formatString(vertex1.x()) + " " + formatString(vertex1.y()) + " " + formatString(vertex1.z()) + "\n\n";
1371
13/13
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
✓ Branch 22 taken 12 times.
✓ Branch 25 taken 12 times.
✓ Branch 28 taken 12 times.
✓ Branch 31 taken 12 times.
✓ Branch 34 taken 12 times.
✓ Branch 37 taken 12 times.
12 m_radSpaces[space_name] += formatString(vertex2.x()) + " " + formatString(vertex2.y()) + " " + formatString(vertex2.z()) + "\n\n";
1372
13/13
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
✓ Branch 22 taken 12 times.
✓ Branch 25 taken 12 times.
✓ Branch 28 taken 12 times.
✓ Branch 31 taken 12 times.
✓ Branch 34 taken 12 times.
✓ Branch 37 taken 12 times.
12 m_radSpaces[space_name] += formatString(vertex3.x()) + " " + formatString(vertex3.y()) + " " + formatString(vertex3.z()) + "\n\n";
1373
13/13
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
✓ Branch 22 taken 12 times.
✓ Branch 25 taken 12 times.
✓ Branch 28 taken 12 times.
✓ Branch 31 taken 12 times.
✓ Branch 34 taken 12 times.
✓ Branch 37 taken 12 times.
12 m_radSpaces[space_name] += formatString(vertex4.x()) + " " + formatString(vertex4.y()) + " " + formatString(vertex4.z()) + "\n\n";
1374 12 }
1375
1376
4/7
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 12 times.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
12 if (insideSillDepth && (*insideSillDepth > 0.0)) {
1377
1378 // window polygon is already offset from the wall
1379
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 offset = -insideSillDepth.get() * outwardNormal;
1380
1/1
✓ Branch 2 taken 12 times.
12 Point3d vertex1 = polygon[index1];
1381
1/1
✓ Branch 2 taken 12 times.
12 Point3d vertex2 = polygon[index1] + offset;
1382
1/1
✓ Branch 2 taken 12 times.
12 Point3d vertex3 = polygon[index2] + offset;
1383
1/1
✓ Branch 2 taken 12 times.
12 Point3d vertex4 = polygon[index2];
1384
1385 // TODO: get exterior reflectance of surface
1386 12 double interiorVisibleReflectance = 0.5;
1387 12 double exteriorVisibleReflectance = 0.2;
1388 //polygon header
1389
5/5
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
12 m_radSpaces[space_name] += "#--interiorVisibleReflectance = " + formatString(interiorVisibleReflectance, 3) + "\n";
1390
5/5
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
12 m_radSpaces[space_name] += "#--exteriorVisibleReflectance = " + formatString(exteriorVisibleReflectance, 3) + "\n";
1391 // write material
1392
4/4
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
36 m_radMaterials.insert("void plastic refl_" + formatString(interiorVisibleReflectance, 3) + "\n0\n0\n5\n"
1393
6/6
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
48 + formatString(interiorVisibleReflectance, 3) + " " + formatString(interiorVisibleReflectance, 3) + " "
1394
3/3
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
48 + formatString(interiorVisibleReflectance, 3) + " 0 0\n\n");
1395 // write polygon
1396
1/1
✓ Branch 1 taken 12 times.
12 m_radSpaces[space_name] +=
1397
8/8
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
✓ Branch 22 taken 12 times.
24 "refl_" + formatString(interiorVisibleReflectance, 3) + " polygon inside_sill_" + subSurface_name + std::to_string(i) + "\n";
1398
5/5
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
12 m_radSpaces[space_name] += "0\n0\n" + formatString(4 * 3) + "\n";
1399
13/13
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
✓ Branch 22 taken 12 times.
✓ Branch 25 taken 12 times.
✓ Branch 28 taken 12 times.
✓ Branch 31 taken 12 times.
✓ Branch 34 taken 12 times.
✓ Branch 37 taken 12 times.
12 m_radSpaces[space_name] += formatString(vertex1.x()) + " " + formatString(vertex1.y()) + " " + formatString(vertex1.z()) + "\n\n";
1400
13/13
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
✓ Branch 22 taken 12 times.
✓ Branch 25 taken 12 times.
✓ Branch 28 taken 12 times.
✓ Branch 31 taken 12 times.
✓ Branch 34 taken 12 times.
✓ Branch 37 taken 12 times.
12 m_radSpaces[space_name] += formatString(vertex2.x()) + " " + formatString(vertex2.y()) + " " + formatString(vertex2.z()) + "\n\n";
1401
13/13
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
✓ Branch 22 taken 12 times.
✓ Branch 25 taken 12 times.
✓ Branch 28 taken 12 times.
✓ Branch 31 taken 12 times.
✓ Branch 34 taken 12 times.
✓ Branch 37 taken 12 times.
12 m_radSpaces[space_name] += formatString(vertex3.x()) + " " + formatString(vertex3.y()) + " " + formatString(vertex3.z()) + "\n\n";
1402
13/13
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
✓ Branch 22 taken 12 times.
✓ Branch 25 taken 12 times.
✓ Branch 28 taken 12 times.
✓ Branch 31 taken 12 times.
✓ Branch 34 taken 12 times.
✓ Branch 37 taken 12 times.
12 m_radSpaces[space_name] += formatString(vertex4.x()) + " " + formatString(vertex4.y()) + " " + formatString(vertex4.z()) + "\n\n";
1403 12 }
1404 }
1405 3 }
1406
1407 // finally, write the actual window
1408 // add polygon header (same for all)
1409
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 m_radWindowGroups[windowGroup_name] += "\n# SubSurface = " + subSurface_name + "\n";
1410
8/8
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
3 m_radWindowGroups[windowGroup_name] += "# Tvis = " + formatString(tVis, 3) + " (tn = " + formatString(tn, 3) + ")\n";
1411
1412
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
3 if (windowGroup_name == "WG0") {
1413
1414 //no shades
1415
1416 // add materials
1417
10/10
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 25 taken 3 times.
✓ Branch 28 taken 3 times.
3 m_radMaterials.insert("void " + rMaterial + " glaz_" + rMaterial + "_tn-" + formatString(tn, 3) + "\n" + matString + "\n");
1418
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
3 m_radMaterialsDC.insert("void alias glaz_" + rMaterial + "_tn-" + formatString(tn, 3) + " WG0\n\n");
1419
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
3 m_radMaterialsSwitchableBase.insert("void alias glaz_" + rMaterial + "_tn-" + formatString(tn, 3) + " WG0\n\n");
1420
1421 // write the window polygon
1422
9/9
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 25 taken 3 times.
3 m_radWindowGroups[windowGroup_name] += "glaz_" + rMaterial + "_tn-" + formatString(tn, 3) + " polygon " + subSurface_name + "\n";
1423
5/5
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
✓ Branch 11 taken 3 times.
✓ Branch 14 taken 3 times.
3 m_radWindowGroups[windowGroup_name] += "0\n0\n" + formatString(polygon.size() * 3) + "\n\n";
1424
2/2
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 3 times.
15 for (auto vertex = polygon.rbegin(); vertex != polygon.rend(); ++vertex) {
1425
1/1
✓ Branch 1 taken 12 times.
12 m_radWindowGroups[windowGroup_name] +=
1426
16/16
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
✓ Branch 22 taken 12 times.
✓ Branch 25 taken 12 times.
✓ Branch 28 taken 12 times.
✓ Branch 31 taken 12 times.
✓ Branch 34 taken 12 times.
✓ Branch 37 taken 12 times.
✓ Branch 40 taken 12 times.
✓ Branch 43 taken 12 times.
✓ Branch 46 taken 12 times.
24 "" + formatString(vertex->x()) + " " + formatString(vertex->y()) + " " + formatString(vertex->z()) + "\n";
1427 }
1428
1429 } else {
1430
1431 //has shading control
1432
1433 //add materials
1434 ✗ m_radMaterials.insert("void " + rMaterial + " " + windowGroup_name + "\n" + matString + "\n");
1435 ✗ if (shadingControl) {
1436 ✗ if (shadingControl->construction()) {
1437 ✗ m_radMaterials.insert("void " + rMaterial + " " + windowGroup_name + "_TINTED\n" + matStringTinted + "\n");
1438
1439 // make special mats files for window group
1440 ✗ switchableGroup_wgMats = "void " + rMaterial + " " + windowGroup_name + "\n" + matString + "\n";
1441
1442 ✗ openstudio::path filename = t_radDir / openstudio::toPath("materials") / openstudio::toPath(windowGroup_name + "_clear.mat");
1443 ✗ OFSTREAM file(filename);
1444 ✗ if (file.is_open()) {
1445 ✗ t_outfiles.push_back(filename);
1446 ✗ file << switchableGroup_wgMats;
1447 } else {
1448 ✗ LOG(Error, "Cannot open file '" << toString(filename) << "' for writing");
1449 }
1450
1451 ✗ switchableGroup_wgMats = "void " + rMaterial + " " + windowGroup_name + "_TINTED\n" + matStringTinted + "\n\nvoid alias "
1452 ✗ + windowGroup_name + " " + windowGroup_name + "_TINTED " + "\n\n";
1453 ✗ openstudio::path filename2 = t_radDir / openstudio::toPath("materials") / openstudio::toPath(windowGroup_name + "_tinted.mat");
1454 ✗ OFSTREAM file2(filename2);
1455 ✗ if (file2.is_open()) {
1456 ✗ t_outfiles.push_back(filename2);
1457 ✗ file2 << switchableGroup_wgMats;
1458 } else {
1459 ✗ LOG(Error, "Cannot open file '" << toString(filename2) << "' for writing");
1460 }
1461
1462 ✗ } else {
1463
1464 // make mat for single window group
1465 ✗ std::string wgMat = "";
1466 ✗ wgMat = "void " + rMaterial + " " + windowGroup_name + "\n" + matString + "\n\n";
1467 ✗ openstudio::path wgSingleFilename = t_radDir / openstudio::toPath("materials") / openstudio::toPath(windowGroup_name + ".mat");
1468 ✗ OFSTREAM wgSingleFile(wgSingleFilename);
1469 ✗ if (wgSingleFile.is_open()) {
1470 ✗ t_outfiles.push_back(wgSingleFilename);
1471 ✗ wgSingleFile << wgMat;
1472 } else {
1473 ✗ LOG(Error, "Cannot open file '" << toString(wgSingleFilename) << "' for writing");
1474 }
1475 ✗ }
1476 }
1477 // write the polygon
1478 ✗ m_radWindowGroups[windowGroup_name] += windowGroup_name + " polygon " + subSurface_name + "\n";
1479 ✗ m_radWindowGroups[windowGroup_name] += "0\n0\n" + formatString(polygon.size() * 3) + "\n";
1480 ✗ for (auto vertex = polygon.rbegin(); vertex != polygon.rend(); ++vertex)
1481
1482 {
1483 ✗ m_radWindowGroups[windowGroup_name] +=
1484 ✗ "" + formatString(vertex->x()) + " " + formatString(vertex->y()) + " " + formatString(vertex->z()) + "\n";
1485 }
1486
1487 ✗ if (shadingControl) {
1488 ✗ if (shadingControl->construction()) {
1489
1490 // a construction means it's switchable glazing, so no shade needed,
1491 // but make special materials files for window group calcs.
1492 ✗ m_radMaterialsSwitchableBase.insert("void plastic " + windowGroup_name + "\n0\n0\n5\n0 0 0 0 0\n");
1493 ✗ m_radMaterialsWG0.insert("void plastic " + windowGroup_name + "\n0\n0\n5\n0 0 0 0 0\n");
1494
1495 } else {
1496
1497 // add the shade polygon
1498
1499 ✗ shadeBSDF = windowGroup.interiorShadeBSDF();
1500
1501 ✗ rMaterial = "BSDF";
1502 ✗ matString = "6\n0 bsdf/" + shadeBSDF + " 0 0 1 .\n0\n0\n";
1503
1504 ✗ m_radMaterials.insert("void " + rMaterial + " " + windowGroup_name + "_SHADE\n" + matString + "\n\n");
1505
1506 ✗ m_radMaterialsDC.insert("void light " + windowGroup_name + "_SHADE\n0\n0\n3\n1 1 1\n");
1507 ✗ m_radMaterialsWG0.insert("void plastic " + windowGroup_name + "_SHADE\n0\n0\n5\n0 0 0 0 0\n");
1508 ✗ m_radMaterialsSwitchableBase.insert("void plastic " + windowGroup_name + "_SHADE\n0\n0\n5\n0 0 0 0 0\n");
1509 ✗ m_radMaterialsSwitchableBase.insert("void plastic " + windowGroup_name + "\n0\n0\n5\n0 0 0 0 0\n");
1510
1511 // polygon header
1512 // Forcing Klems basis... RPG 2015.09.13 =(
1513 // user is warned as files are written RPG 2015.12.03
1514 ✗ std::string tempSkyDivs = "kf";
1515
1516 ✗ m_radWindowGroupShades[windowGroup_name] +=
1517 ✗ "#@rfluxmtx h=" + tempSkyDivs + " u=" + winUpVector + " o=output/dc/" + windowGroup_name + ".vmx\n";
1518 ✗ m_radWindowGroupShades[windowGroup_name] += "\n# shade for SubSurface: " + subSurface_name + "\n";
1519
1520 // write the polygon
1521 ✗ m_radWindowGroupShades[windowGroup_name] +=
1522 ✗ windowGroup_name + "_SHADE" + " polygon " + windowGroup_name + "_SHADE_" + subSurface_name + "\n";
1523 ✗ m_radWindowGroupShades[windowGroup_name] += "0\n0\n" + formatString(polygon.size() * 3) + "\n";
1524 ✗ for (auto vertex = polygon.rbegin(); vertex != polygon.rend(); ++vertex)
1525
1526 {
1527
1528 // offset the shade to the interior side of the window
1529 ✗ Point3d offsetVertex = *vertex + (-0.01 * outwardNormal);
1530
1531 ✗ m_radWindowGroupShades[windowGroup_name] +=
1532 ✗ "" + formatString(offsetVertex.x()) + " " + formatString(offsetVertex.y()) + " " + formatString(offsetVertex.z()) + "\n";
1533 ✗ }
1534
1535 // make mat for single window group shade
1536 ✗ std::string wgShadeMat = "";
1537 ✗ wgShadeMat = "void " + rMaterial + " " + windowGroup_name + "_SHADE\n" + matString + "\n\n";
1538 openstudio::path wgSingleFilename =
1539 ✗ t_radDir / openstudio::toPath("materials") / openstudio::toPath(windowGroup_name + "_SHADE.mat");
1540 ✗ OFSTREAM wgSingleFile(wgSingleFilename);
1541 ✗ if (wgSingleFile.is_open()) {
1542 ✗ t_outfiles.push_back(wgSingleFilename);
1543 ✗ wgSingleFile << wgShadeMat;
1544 } else {
1545 ✗ LOG(Error, "Cannot open file '" << toString(wgSingleFilename) << "' for writing");
1546 }
1547
1548 // shade BSDF stuff
1549
1550 // make dir for BSDF files
1551
1552 ✗ openstudio::path bsdfoutpath = t_radDir / openstudio::toPath("bsdf");
1553
1554 // path to write bsdf
1555
1556 ✗ openstudio::path shadeBSDFPath = t_radDir / openstudio::toPath("bsdf") / shadeBSDF;
1557
1558 ✗ if (!exists(shadeBSDFPath)) {
1559
1560 // add BSDF file to the collection of crap to copy up
1561 ✗ t_outfiles.push_back(shadeBSDFPath);
1562
1563 // read BSDF from resource dll
1564 // must be referenced in openstudiocore/src/radiance/radiance.qrc
1565 ✗ const auto defaultFile = ::openstudioradiance::embedded_files::getFileAsString(":/resources/" + shadeBSDF);
1566
1567 // write shade BSDF
1568 ✗ openstudio::filesystem::ofstream outfile(shadeBSDFPath);
1569 ✗ if (!outfile.is_open()) {
1570 ✗ LOG_AND_THROW("Cannot write file to '" << toString(shadeBSDFPath) << "'");
1571 }
1572 ✗ outfile << defaultFile;
1573 ✗ outfile.close();
1574 ✗ }
1575 ✗ }
1576
1577 // always add an airBSDF
1578
1579 ✗ openstudio::path airBSDFPath = t_radDir / openstudio::toPath("bsdf") / openstudio::toPath("air.xml");
1580
1581 ✗ if (!exists(airBSDFPath)) {
1582
1583 // add BSDF file to the collection of crap to copy up
1584 ✗ t_outfiles.push_back(airBSDFPath);
1585
1586 // read BSDF from resource dll
1587 // must be in openstudiocore/src/radiance/radiance.qrc
1588 ✗ const auto defaultFile = ::openstudioradiance::embedded_files::getFileAsString(":/resources/air.xml");
1589
1590 // write shade BSDF
1591 ✗ openstudio::filesystem::ofstream outFileAir(airBSDFPath);
1592 ✗ if (!outFileAir.is_open()) {
1593 ✗ LOG_AND_THROW("Cannot write file to '" << toString(airBSDFPath) << "'");
1594 }
1595 ✗ outFileAir << defaultFile;
1596 ✗ outFileAir.close();
1597 ✗ }
1598 ✗ }
1599 }
1600
1601 //store window group entry for mapping.rad
1602
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
3 if (windowGroup_name == "WG0") {
1603
1604 // simple placeholder for WG0
1605
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 m_radDCmats.insert(windowGroup_name + ",n/a,n/a,n/a,n/a\n");
1606
1607 } else {
1608
1609 ✗ std::string shadeType = "air.xml,";
1610 ✗ if (shadingControl) {
1611 ✗ if (shadingControl->construction()) {
1612 ✗ shadeType = "SWITCHABLE,";
1613 }
1614 }
1615
1616 // window group name, normal, control type, setpoint, unshaded bsdf, and shaded bsdf
1617 ✗ m_radDCmats.insert(windowGroup_name + "," + formatString((control.outwardNormal->x() * -1), 2) + " "
1618 ✗ + formatString((control.outwardNormal->y() * -1), 2) + " " + formatString((control.outwardNormal->z() * -1), 2) + ","
1619 ✗ + windowGroup.shadingControlType() + "," + windowGroup.shadingControlSetpoint() + "," + shadeType + shadeBSDF
1620 ✗ + "\n");
1621 ✗ }
1622
1623
2/3
✓ Branch 10 taken 3 times.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
6 } else if (subSurfaceUpCase == "DOOR") {
1624
1625
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 LOG(Info, "found a door, will set to interior reflectance");
1626
1627
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 double interiorVisibleAbsorptance = subSurface.interiorVisibleAbsorptance().get();
1628
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 double exteriorVisibleAbsorptance = subSurface.exteriorVisibleAbsorptance().get();
1629 3 double interiorVisibleReflectance = 1.0 - interiorVisibleAbsorptance;
1630 3 double exteriorVisibleReflectance = 1.0 - exteriorVisibleAbsorptance;
1631 //polygon header
1632
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 m_radSpaces[space_name] += "#--interiorVisibleReflectance = " + formatString(interiorVisibleReflectance, 3) + "\n";
1633
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 m_radSpaces[space_name] += "#--exteriorVisibleReflectance = " + formatString(exteriorVisibleReflectance) + "\n";
1634 // write material
1635
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
9 m_radMaterials.insert("void plastic refl_" + formatString(interiorVisibleReflectance, 3) + "\n0\n0\n5\n"
1636
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
12 + formatString(interiorVisibleReflectance, 3) + " " + formatString(interiorVisibleReflectance, 3) + " "
1637
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
12 + formatString(interiorVisibleReflectance, 3) + " 0 0\n\n");
1638 // write polygon
1639
7/7
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
3 m_radSpaces[space_name] += "refl_" + formatString(interiorVisibleReflectance, 3) + " polygon " + subSurface_name + "\n";
1640
5/5
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
✓ Branch 11 taken 3 times.
✓ Branch 14 taken 3 times.
3 m_radSpaces[space_name] += "0\n0\n" + formatString(polygon.size() * 3) + "\n\n";
1641
1642
2/2
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 3 times.
15 for (const auto& vertex : polygon) {
1643
13/13
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
✓ Branch 22 taken 12 times.
✓ Branch 25 taken 12 times.
✓ Branch 28 taken 12 times.
✓ Branch 31 taken 12 times.
✓ Branch 34 taken 12 times.
✓ Branch 37 taken 12 times.
12 m_radSpaces[space_name] += formatString(vertex.x()) + " " + formatString(vertex.y()) + " " + formatString(vertex.z()) + "\n\n";
1644 }
1645
1646 ✗ } else if (subSurfaceUpCase == "TUBULARDAYLIGHTDOME") {
1647
1648 ✗ LOG(Error, "subsurface is a tdd dome (not yet implemented in Radiance), model translation halted.");
1649
1650 ✗ } else if (subSurfaceUpCase == "TUBULARDAYLIGHTDIFFUSER") {
1651
1652 ✗ LOG(Error, "subsurface is a tdd diffuser (not yet implemented in Radiance), model translation halted.");
1653 }
1654
1655 6 } //end reveals
1656
1657 48 } // end surfaces
1658
1659 // get shading surfaces
1660
1661
1/1
✓ Branch 1 taken 12 times.
12 std::vector<openstudio::model::ShadingSurfaceGroup> shadingSurfaceGroups = space.shadingSurfaceGroups();
1662
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 12 times.
15 for (const auto& shadingSurfaceGroup : shadingSurfaceGroups) {
1663
1/1
✓ Branch 1 taken 3 times.
3 std::vector<openstudio::model::ShadingSurface> shadingSurfaces = shadingSurfaceGroup.shadingSurfaces();
1664
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
6 for (const auto& shadingSurface : shadingSurfaces) {
1665
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 std::string shadingSurface_name = cleanName(shadingSurface.name().get());
1666
1667 // add surface to zone geometry
1668
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 m_radSpaces[space_name] += "# surface: " + shadingSurface_name + "\n";
1669
1670 // set construction of space shadingSurface
1671
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 std::string constructionName = shadingSurface.getString(2).get();
1672
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 m_radSpaces[space_name] += "# construction: " + constructionName + "\n";
1673
1674 // get reflectance
1675 3 double interiorVisibleReflectance = 0.25; // default for space shading surfaces
1676
2/3
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
6 if (shadingSurface.interiorVisibleAbsorptance()) {
1677 ✗ double interiorVisibleAbsorptance = shadingSurface.interiorVisibleAbsorptance().get();
1678 ✗ interiorVisibleReflectance = 1.0 - interiorVisibleAbsorptance;
1679 }
1680 3 double exteriorVisibleReflectance = 0.25; // default for space shading surfaces
1681
2/3
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
6 if (shadingSurface.exteriorVisibleAbsorptance()) {
1682 ✗ double exteriorVisibleAbsorptance = shadingSurface.exteriorVisibleAbsorptance().get();
1683 ✗ exteriorVisibleReflectance = 1.0 - exteriorVisibleAbsorptance;
1684 }
1685
1686 // write (two-sided) material
1687 // exterior reflectance for front side
1688
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
9 m_radMaterials.insert("void plastic refl_" + formatString(exteriorVisibleReflectance, 3) + "\n0\n0\n5\n"
1689
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
12 + formatString(exteriorVisibleReflectance, 3) + " " + formatString(exteriorVisibleReflectance, 3) + " "
1690
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
12 + formatString(exteriorVisibleReflectance, 3) + " 0 0\n\n");
1691
1692 // interior reflectance for back side
1693
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
9 m_radMaterials.insert("void plastic refl_" + formatString(interiorVisibleReflectance, 3) + "\n0\n0\n5\n"
1694
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
12 + formatString(interiorVisibleReflectance, 3) + " " + formatString(interiorVisibleReflectance, 3) + " "
1695
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
12 + formatString(interiorVisibleReflectance, 3) + " 0 0\n\n");
1696
1697 // mixfunc
1698
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
9 m_radMixMaterials.insert("void mixfunc reflBACK_" + formatString(interiorVisibleReflectance, 3) + "_reflFRONT_"
1699
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
12 + formatString(exteriorVisibleReflectance, 3) + "\n4 " + "refl_" + formatString(exteriorVisibleReflectance, 3)
1700
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
12 + " " + "refl_" + formatString(interiorVisibleReflectance, 3) + " if(Rdot,1,0) .\n0\n0\n\n");
1701
1702 // polygon header
1703
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 m_radSpaces[space_name] += "# exterior visible reflectance: " + formatString(exteriorVisibleReflectance, 3) + "\n";
1704
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 m_radSpaces[space_name] += "# interior visible reflectance: " + formatString(interiorVisibleReflectance, 3) + "\n";
1705
1706 // get / write surface polygon
1707
1708
1/1
✓ Branch 1 taken 3 times.
3 openstudio::Point3dVector polygon = openstudio::radiance::ForwardTranslator::getPolygon(shadingSurface);
1709
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
9 m_radSpaces[space_name] += "reflBACK_" + formatString(interiorVisibleReflectance, 3) + "_reflFRONT_"
1710
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
12 + formatString(exteriorVisibleReflectance, 3) + " polygon " + shadingSurface_name + "\n0\n0\n"
1711
4/4
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
✓ Branch 11 taken 3 times.
12 + formatString(polygon.size() * 3) + "\n";
1712
1713
2/2
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 3 times.
15 for (const auto& vertex : polygon) {
1714
14/14
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
✓ Branch 22 taken 12 times.
✓ Branch 25 taken 12 times.
✓ Branch 28 taken 12 times.
✓ Branch 31 taken 12 times.
✓ Branch 34 taken 12 times.
✓ Branch 37 taken 12 times.
✓ Branch 40 taken 12 times.
12 m_radSpaces[space_name] += "" + formatString(vertex.x()) + " " + formatString(vertex.y()) + " " + formatString(vertex.z()) + "\n";
1715 }
1716
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 m_radSpaces[space_name] += "\n";
1717 3 }
1718 3 } // end shading surfaces
1719
1720 //get the interior partition surfaces
1721
1722
1/1
✓ Branch 1 taken 12 times.
12 std::vector<openstudio::model::InteriorPartitionSurfaceGroup> interiorPartitionSurfaceGroups = space.interiorPartitionSurfaceGroups();
1723
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 12 times.
15 for (const auto& interiorPartitionSurfaceGroup : interiorPartitionSurfaceGroups) {
1724 std::vector<openstudio::model::InteriorPartitionSurface> interiorPartitionSurfaces =
1725
1/1
✓ Branch 1 taken 3 times.
3 interiorPartitionSurfaceGroup.interiorPartitionSurfaces();
1726
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
6 for (const auto& interiorPartitionSurface : interiorPartitionSurfaces) {
1727
1728 // get nice name
1729
1730
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 std::string interiorPartitionSurface_name = cleanName(interiorPartitionSurface.name().get());
1731
1732 // check for construction
1733
1734
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<model::ConstructionBase> construction = interiorPartitionSurface.construction();
1735
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
3 if (!construction) {
1736 ✗ LOG(Warn, "InteriorPartitionSurface " << interiorPartitionSurface.name().get()
1737 << " is not associated with a Construction, it will not be translated.");
1738 ✗ continue;
1739 ✗ }
1740
1741 // add surface to zone geometry
1742
1743
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 m_radSpaces[space_name] += "# surface: " + interiorPartitionSurface_name + "\n";
1744
1745 // set construction of interiorPartitionSurface
1746
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 std::string constructionName = interiorPartitionSurface.getString(1).get();
1747
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 m_radSpaces[space_name] += "# construction: " + constructionName + "\n";
1748
1749 // get reflectance
1750 3 double interiorVisibleReflectance = 0.5; // set some default
1751
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (interiorPartitionSurface.interiorVisibleAbsorptance()) {
1752
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 double interiorVisibleAbsorptance = interiorPartitionSurface.interiorVisibleAbsorptance().get();
1753 3 interiorVisibleReflectance = 1.0 - interiorVisibleAbsorptance;
1754 }
1755
1756 3 double exteriorVisibleReflectance = 0.5; // set some default
1757
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (interiorPartitionSurface.exteriorVisibleAbsorptance()) {
1758
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 double exteriorVisibleAbsorptance = interiorPartitionSurface.exteriorVisibleAbsorptance().get();
1759 3 exteriorVisibleReflectance = 1.0 - exteriorVisibleAbsorptance;
1760 }
1761
1762 // write material
1763
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
9 m_radMaterials.insert("void plastic refl_" + formatString(interiorVisibleReflectance, 3) + "\n0\n0\n5\n"
1764
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
12 + formatString(interiorVisibleReflectance, 3) + " " + formatString(interiorVisibleReflectance, 3) + " "
1765
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
12 + formatString(interiorVisibleReflectance, 3) + " 0 0\n\n");
1766 // polygon header
1767
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 m_radSpaces[space_name] += "#--interiorVisibleReflectance = " + formatString(interiorVisibleReflectance, 3) + "\n";
1768
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 m_radSpaces[space_name] += "#--exteriorVisibleReflectance = " + formatString(exteriorVisibleReflectance) + "\n";
1769 // get / write surface polygon
1770
1771
1/1
✓ Branch 1 taken 3 times.
3 openstudio::Point3dVector polygon = openstudio::radiance::ForwardTranslator::getPolygon(interiorPartitionSurface);
1772
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
9 m_radSpaces[space_name] += "refl_" + formatString(interiorVisibleReflectance, 3) + " polygon " + interiorPartitionSurface_name + "\n0\n0\n"
1773
4/4
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
✓ Branch 11 taken 3 times.
12 + formatString(polygon.size() * 3) + "\n";
1774
2/2
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 3 times.
15 for (const auto& vertex : polygon) {
1775
13/13
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
✓ Branch 16 taken 12 times.
✓ Branch 19 taken 12 times.
✓ Branch 22 taken 12 times.
✓ Branch 25 taken 12 times.
✓ Branch 28 taken 12 times.
✓ Branch 31 taken 12 times.
✓ Branch 34 taken 12 times.
✓ Branch 37 taken 12 times.
12 m_radSpaces[space_name] += formatString(vertex.x()) + " " + formatString(vertex.y()) + " " + formatString(vertex.z()) + "\n\n";
1776 }
1777 3 }
1778 3 } // end interior partitions
1779
1780 // get luminaires
1781 /// \todo fully implement once luminaires are fully supported in model
1782 //std::vector<openstudio::model::Luminaire> luminaires = space.luminaires();
1783 //for (const auto & luminaire : luminaires)
1784 //{
1785 // luminaire_name = luminaire.name.get.gsub(' ', '_').gsub(':', '_')
1786 // polygon = OpenStudio::Radiance::ForwardTranslator::getPolygon(luminaire)
1787 //}
1788
1789 // get daylighting controls
1790
1/1
✓ Branch 1 taken 12 times.
12 std::vector<openstudio::model::DaylightingControl> daylightingControls = space.daylightingControls();
1791
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 12 times.
15 for (const auto& control : daylightingControls) {
1792
1793
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 m_radSensors[space_name] = "";
1794
1795
1/1
✓ Branch 1 taken 3 times.
3 openstudio::Point3d sensor_point = openstudio::radiance::ForwardTranslator::getReferencePoint(control);
1796
1/1
✓ Branch 1 taken 3 times.
3 openstudio::Vector3d sensor_aimVector = openstudio::radiance::ForwardTranslator::getSensorVector(control);
1797
8/8
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
9 m_radSensors[space_name] += formatString(sensor_point.x(), 3) + " " + formatString(sensor_point.y(), 3) + " "
1798
8/8
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
12 + formatString(sensor_point.z(), 3) + " " + formatString(sensor_aimVector.x(), 3) + " "
1799
9/9
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 25 taken 3 times.
12 + formatString(sensor_aimVector.y(), 3) + " " + formatString(sensor_aimVector.z(), 3) + "\n";
1800
1801 // write daylighting controls
1802
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
6 openstudio::path filename = t_radDir / openstudio::toPath("numeric") / openstudio::toPath(space_name + ".sns");
1803
1/1
✓ Branch 1 taken 3 times.
3 OFSTREAM file(filename);
1804
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 if (file.is_open()) {
1805
1/1
✓ Branch 1 taken 3 times.
3 t_outfiles.push_back(filename);
1806
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 file << m_radSensors[space_name];
1807 } else {
1808 ✗ LOG(Error, "Cannot open file '" << toString(filename) << "' for writing");
1809 }
1810
1811 // write daylighting control view file
1812
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 m_radSensorViews[space_name] = "";
1813
9/9
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 25 taken 3 times.
9 m_radSensorViews[space_name] += "rvu -vth -vp " + formatString(sensor_point.x(), 3) + " " + formatString(sensor_point.y(), 3) + " "
1814
8/8
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
12 + formatString(sensor_point.z(), 3) + " -vd " + formatString(sensor_aimVector.x(), 3) + " "
1815
7/7
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
12 + formatString(sensor_aimVector.y(), 3) + " " + formatString(sensor_aimVector.z(), 3)
1816
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 + " -vu 0 1 0 -vh 180 -vv 180 -vo 0 -vs 0 -vl 0\n";
1817
1818
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
6 filename = t_radDir / openstudio::toPath("views") / openstudio::toPath(space_name + "_dc.vfh");
1819
1/1
✓ Branch 1 taken 3 times.
3 OFSTREAM file2(filename);
1820
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 if (file2.is_open()) {
1821
1/1
✓ Branch 1 taken 3 times.
3 t_outfiles.push_back(filename);
1822
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 file2 << m_radSensorViews[space_name];
1823 } else {
1824 ✗ LOG(Error, "Cannot open file '" << toString(filename) << "' for writing");
1825 }
1826
1827
7/7
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
3 LOG(Debug, "Wrote " << space_name << "_dc.vfh");
1828
1829 3 } // end daylighting controls
1830
1831 // get glare sensors
1832
1/1
✓ Branch 1 taken 12 times.
12 std::vector<openstudio::model::GlareSensor> glareSensors = space.glareSensors();
1833
2/2
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 12 times.
14 for (const auto& sensor : glareSensors) {
1834
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 m_radGlareSensors[space_name] = "";
1835
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 m_radGlareSensorViewsVTV[space_name] = "";
1836
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 m_radGlareSensorViewsVTA[space_name] = "";
1837
1838 2 std::string sensor_name;
1839
2/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
4 if (sensor.name()) {
1840
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 sensor_name = cleanName(sensor.name().get());
1841 }
1842
1843
1/1
✓ Branch 1 taken 2 times.
2 openstudio::Point3d sensor_point = openstudio::radiance::ForwardTranslator::getReferencePoint(sensor);
1844 // openstudio::Vector3dVector sensor_viewVector = openstudio::radiance::ForwardTranslator::getViewVectors(*sensor);
1845 //std::string sensor_name = sensor.name();
1846
1/1
✓ Branch 1 taken 2 times.
2 openstudio::Vector3dVector viewVectors = openstudio::radiance::ForwardTranslator::getViewVectors(sensor);
1847 // reverse the order so primary view is listed last in the file
1848
1/1
✓ Branch 1 taken 2 times.
2 std::reverse(std::begin(viewVectors), std::end(viewVectors));
1849
2/2
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
4 for (const Vector3d& viewVector : viewVectors) {
1850
1851 // glare sensor points
1852
8/8
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
6 m_radGlareSensors[space_name] += formatString(sensor_point.x(), 3) + " " + formatString(sensor_point.y(), 3) + " "
1853
8/8
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
8 + formatString(sensor_point.z(), 3) + " " + formatString(viewVector.x(), 3) + " "
1854
9/9
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
8 + formatString(viewVector.y(), 3) + " " + formatString(viewVector.z(), 3) + "\n";
1855
1856 // glare sensor views (perspective)
1857
9/9
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
6 m_radGlareSensorViewsVTV[space_name] += "rvu -vtv -vp " + formatString(sensor_point.x(), 3) + " " + formatString(sensor_point.y(), 3) + " "
1858
8/8
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
8 + formatString(sensor_point.z(), 3) + " -vd " + formatString(viewVector.x(), 3) + " "
1859
7/7
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
8 + formatString(viewVector.y(), 3) + " " + formatString(viewVector.z(), 3)
1860
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 + " -vu 0 0 1 -vh 90 -vv 60 -vo 0 -vs 0 -vl 0\n";
1861
1862 // glare sensor views (fisheye)
1863
9/9
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
6 m_radGlareSensorViewsVTA[space_name] += "rvu -vth -vp " + formatString(sensor_point.x(), 3) + " " + formatString(sensor_point.y(), 3) + " "
1864
8/8
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
8 + formatString(sensor_point.z(), 3) + " -vd " + formatString(viewVector.x(), 3) + " "
1865
7/7
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
8 + formatString(viewVector.y(), 3) + " " + formatString(viewVector.z(), 3)
1866
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
6 + " -vu 0 0 1 -vh 180 -vv 180 -vo 0 -vs 0 -vl 0\n";
1867 }
1868
1869 // write glare sensors
1870
6/6
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
4 openstudio::path filename = t_radDir / openstudio::toPath("numeric") / openstudio::toPath(space_name + "_" + sensor_name + ".glr");
1871
1/1
✓ Branch 1 taken 2 times.
2 OFSTREAM file(filename);
1872
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 if (file.is_open()) {
1873
1/1
✓ Branch 1 taken 2 times.
2 t_outfiles.push_back(filename);
1874
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 file << m_radGlareSensors[space_name];
1875 } else {
1876 ✗ LOG(Error, "Cannot open file '" << toString(filename) << "' for writing");
1877 }
1878
1879
7/7
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
2 LOG(Debug, "Wrote " << space_name << ".glr");
1880
1881 // write glare sensor views (perspective)
1882
6/6
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
4 filename = t_radDir / openstudio::toPath("views") / openstudio::toPath(space_name + "_" + sensor_name + "_gs.vfv");
1883
1/1
✓ Branch 1 taken 2 times.
2 OFSTREAM file2(filename);
1884
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 if (file2.is_open()) {
1885
1/1
✓ Branch 1 taken 2 times.
2 t_outfiles.push_back(filename);
1886
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 file2 << m_radGlareSensorViewsVTV[space_name];
1887 } else {
1888 ✗ LOG(Error, "Cannot open file '" << toString(filename) << "' for writing");
1889 }
1890
1891
9/9
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
2 LOG(Debug, "Wrote " << space_name << "_" << sensor_name << "_gs.vfv");
1892
1893 // write glare sensor views (fisheye)
1894
6/6
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
4 filename = t_radDir / openstudio::toPath("views") / openstudio::toPath(space_name + "_" + sensor_name + "_gs.vfh");
1895
1/1
✓ Branch 1 taken 2 times.
2 OFSTREAM file3(filename);
1896
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 if (file3.is_open()) {
1897
1/1
✓ Branch 1 taken 2 times.
2 t_outfiles.push_back(filename);
1898
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 file3 << m_radGlareSensorViewsVTA[space_name];
1899 } else {
1900 ✗ LOG(Error, "Cannot open file '" << toString(filename) << "' for writing");
1901 }
1902
1903
9/9
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
2 LOG(Debug, "Wrote " << space_name << "_" << sensor_name << "_gs.vfh");
1904
1905 2 } // end glare sensor
1906
1907 // get illuminance map points, write to file
1908
1/1
✓ Branch 1 taken 12 times.
12 std::vector<openstudio::model::IlluminanceMap> illuminanceMaps = space.illuminanceMaps();
1909
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 12 times.
15 for (const auto& map : illuminanceMaps) {
1910
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 m_radMaps[space_name] = "";
1911
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 m_radMapHandles[space_name] = map.handle();
1912
1913 // write map file
1914
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
6 openstudio::path filename = t_radDir / openstudio::toPath("numeric") / openstudio::toPath(space_name + ".map");
1915
1/1
✓ Branch 1 taken 3 times.
3 OFSTREAM file(filename);
1916
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 if (file.is_open()) {
1917
1/1
✓ Branch 1 taken 3 times.
3 t_outfiles.push_back(filename);
1918
1919
1/1
✓ Branch 1 taken 3 times.
3 std::vector<Point3d> referencePoints = openstudio::radiance::ForwardTranslator::getReferencePoints(map);
1920
2/2
✓ Branch 4 taken 300 times.
✓ Branch 5 taken 3 times.
303 for (const auto& point : referencePoints) {
1921
1/1
✓ Branch 1 taken 300 times.
300 m_radMaps[space_name] +=
1922
13/13
✓ Branch 1 taken 300 times.
✓ Branch 4 taken 300 times.
✓ Branch 7 taken 300 times.
✓ Branch 10 taken 300 times.
✓ Branch 13 taken 300 times.
✓ Branch 16 taken 300 times.
✓ Branch 19 taken 300 times.
✓ Branch 22 taken 300 times.
✓ Branch 25 taken 300 times.
✓ Branch 28 taken 300 times.
✓ Branch 31 taken 300 times.
✓ Branch 34 taken 300 times.
✓ Branch 37 taken 300 times.
600 "" + formatString(point.x(), 3) + " " + formatString(point.y(), 3) + " " + formatString(point.z(), 3) + " 0.000 0.000 1.000\n";
1923 }
1924
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 file << m_radMaps[space_name];
1925 3 } else {
1926 ✗ LOG(Error, "Cannot open file '" << toString(filename) << "' for writing");
1927 }
1928
1929
7/7
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
3 LOG(Debug, "wrote " << space_name << ".map");
1930 3 } //end illuminance map
1931
1932 // write geometry
1933
4/4
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
24 openstudio::path filename = t_radDir / openstudio::toPath("scene") / openstudio::toPath(space_name + ".rad");
1934
1/1
✓ Branch 1 taken 12 times.
12 OFSTREAM file(filename);
1935
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 if (file.is_open()) {
1936
1/1
✓ Branch 1 taken 12 times.
12 t_outfiles.push_back(filename);
1937
1/1
✓ Branch 1 taken 12 times.
12 m_radSceneFiles.push_back(filename);
1938
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 file << m_radSpaces[space_name];
1939 } else {
1940 ✗ LOG(Error, "Cannot open file '" << toString(filename) << "' for writing");
1941 }
1942
1943
2/2
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 12 times.
21 for (const auto& windowGroup : m_windowGroups) {
1944
1/1
✓ Branch 1 taken 9 times.
9 std::string windowGroup_name = windowGroup.name();
1945
1946 //write windows (and glazed doors)
1947
2/3
✓ Branch 2 taken 9 times.
✓ Branch 5 taken 9 times.
✗ Branch 6 not taken.
9 if (m_radWindowGroups.find(windowGroup_name) != m_radWindowGroups.end()) {
1948
1949 // get the Radiance parameters... so we have them.
1950
1/1
✓ Branch 1 taken 9 times.
9 auto radianceParameters = m_model.getUniqueModelObject<openstudio::model::RadianceParameters>();
1951
2/3
✓ Branch 1 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
9 if (windowGroup_name != "WG0") {
1952 ✗ if (radianceParameters.skyDiscretizationResolution() == "146") {
1953 ✗ LOG(Info, "writing out window group '" + windowGroup_name + "', using Klems sampling basis.");
1954 ✗ } else if (radianceParameters.skyDiscretizationResolution() == "578") {
1955 ✗ LOG(Warn, "writing out window group '" + windowGroup_name + "', but sampling basis was reset to Klems (145).");
1956 ✗ } else if (radianceParameters.skyDiscretizationResolution() == "2306") {
1957 ✗ LOG(Warn, "writing out window group '" + windowGroup_name + "', but sampling basis was reset to Klems (145).");
1958 }
1959 }
1960
1961
4/4
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 10 taken 9 times.
18 openstudio::path glazefilename = t_radDir / openstudio::toPath("scene/glazing") / openstudio::toPath(windowGroup_name + ".rad");
1962
1/1
✓ Branch 1 taken 9 times.
9 OFSTREAM glazefile(glazefilename);
1963
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 if (glazefile.is_open()) {
1964
1/1
✓ Branch 1 taken 9 times.
9 t_outfiles.push_back(glazefilename);
1965
1/1
✓ Branch 1 taken 9 times.
9 m_radSceneFiles.push_back(glazefilename);
1966
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 glazefile << m_radWindowGroups[windowGroup_name];
1967 } else {
1968 ✗ LOG(Error, "Cannot open file '" << toString(glazefilename) << "' for writing");
1969 }
1970
1971
3/8
✓ Branch 1 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 9 times.
9 if (windowGroup_name != "WG0" && !m_radWindowGroupShades[windowGroup_name].empty()) {
1972 ✗ openstudio::path shadefilename = t_radDir / openstudio::toPath("scene/shades") / openstudio::toPath(windowGroup_name + "_SHADE.rad");
1973 ✗ OFSTREAM shadefile(shadefilename);
1974 ✗ if (shadefile.is_open()) {
1975 ✗ t_outfiles.push_back(shadefilename);
1976 ✗ m_radSceneFiles.push_back(shadefilename);
1977 ✗ shadefile << m_radWindowGroupShades[windowGroup_name];
1978 } else {
1979 ✗ LOG(Error, "Cannot open file '" << toString(shadefilename) << "' for writing");
1980 }
1981 ✗ }
1982
1983 // write window group control points
1984 // only write for controlled window groups
1985
2/3
✓ Branch 1 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
9 if (windowGroup_name != "WG0") {
1986 ✗ openstudio::path filename = t_radDir / openstudio::toPath("numeric") / openstudio::toPath(windowGroup_name + ".pts");
1987 ✗ OFSTREAM file(filename);
1988 ✗ if (file.is_open()) {
1989 ✗ t_outfiles.push_back(filename);
1990 ✗ file << windowGroup.windowGroupPoints();
1991 } else {
1992 ✗ LOG(Error, "Cannot open file '" << toString(filename) << "' for writing");
1993 }
1994 ✗ }
1995 9 }
1996 9 }
1997
1998 // write radiance materials file
1999
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 m_radMaterials.insert("# OpenStudio Materials File\n\n");
2000
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 openstudio::path materialsfilename = t_radDir / openstudio::toPath("materials/materials.rad");
2001
1/1
✓ Branch 1 taken 12 times.
12 OFSTREAM materialsfile(materialsfilename);
2002
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 if (materialsfile.is_open()) {
2003
1/1
✓ Branch 1 taken 12 times.
12 t_outfiles.push_back(materialsfilename);
2004
2/2
✓ Branch 5 taken 66 times.
✓ Branch 6 taken 12 times.
78 for (const auto& line : m_radMaterials) {
2005
1/1
✓ Branch 1 taken 66 times.
66 materialsfile << line;
2006 };
2007
2/2
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 12 times.
48 for (const auto& line : m_radMixMaterials) {
2008
1/1
✓ Branch 1 taken 36 times.
36 materialsfile << line;
2009 };
2010 } else {
2011 ✗ LOG(Error, "Cannot open file '" << toString(materialsfilename) << "' for writing");
2012 }
2013
2014 // write radiance DC vmx materials (lights) file
2015
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 m_radMaterialsDC.insert("# OpenStudio \"vmx\" Materials File\n# controlled windows: material=\"light\", black out all others.\n\nvoid plastic "
2016 "WG0\n0\n0\n5\n0 0 0 0 0\n\n");
2017
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 openstudio::path materials_vmxfilename = t_radDir / openstudio::toPath("materials/materials_vmx.rad");
2018
1/1
✓ Branch 1 taken 12 times.
12 OFSTREAM materials_vmxfile(materials_vmxfilename);
2019
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 if (materials_vmxfile.is_open()) {
2020
1/1
✓ Branch 1 taken 12 times.
12 t_outfiles.push_back(materials_vmxfilename);
2021
2/2
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 12 times.
33 for (const auto& line : m_radMaterialsDC) {
2022
1/1
✓ Branch 1 taken 21 times.
21 materials_vmxfile << line;
2023 };
2024 } else {
2025 ✗ LOG(Error, "Cannot open file '" << toString(materials_vmxfilename) << "' for writing");
2026 }
2027
2028 // write radiance WG0 vmx materials file (blacks out controlled window groups)
2029
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 m_radMaterialsWG0.insert("# OpenStudio \"WG0\" Materials File\n# black out all controlled window groups.\n");
2030
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 openstudio::path materials_WG0filename = t_radDir / openstudio::toPath("materials/materials_WG0.rad");
2031
1/1
✓ Branch 1 taken 12 times.
12 OFSTREAM materials_WG0file(materials_WG0filename);
2032
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 if (materials_WG0file.is_open()) {
2033
1/1
✓ Branch 1 taken 12 times.
12 t_outfiles.push_back(materials_WG0filename);
2034
2/2
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 12 times.
24 for (const auto& line : m_radMaterialsWG0) {
2035
1/1
✓ Branch 1 taken 12 times.
12 materials_WG0file << line;
2036 };
2037 } else {
2038 ✗ LOG(Error, "Cannot open file '" << toString(materials_WG0filename) << "' for writing");
2039 }
2040
2041 // write radiance blackout materials file (blacks out everything)
2042
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 m_radMaterialsSwitchableBase.insert(
2043 "# OpenStudio Blackout Materials File\n# black out all window and shade materials.\n\nvoid plastic WG0\n0\n0\n5\n0 0 0 0 0\n\n");
2044
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 openstudio::path materials_SwitchableBasefilename = t_radDir / openstudio::toPath("materials/materials_blackout.rad");
2045
1/1
✓ Branch 1 taken 12 times.
12 OFSTREAM materials_SwitchableBasefile(materials_SwitchableBasefilename);
2046
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 if (materials_SwitchableBasefile.is_open()) {
2047
1/1
✓ Branch 1 taken 12 times.
12 t_outfiles.push_back(materials_SwitchableBasefilename);
2048
2/2
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 12 times.
33 for (const auto& line : m_radMaterialsSwitchableBase) {
2049
1/1
✓ Branch 1 taken 21 times.
21 materials_SwitchableBasefile << line;
2050 };
2051 } else {
2052 ✗ LOG(Error, "Cannot open file '" << toString(materials_SwitchableBasefilename) << "' for writing");
2053 }
2054
2055 // write radiance vmx materials list
2056 // format of this file is: window group, bsdf, bsdf
2057
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 m_radDCmats.insert("# OpenStudio windowGroup->BSDF \"Mapping\" File\n# windowGroup,inwardNormal,shade control type,shade control "
2058 "setpoint,unshaded bsdf,shaded bsdf\n");
2059
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 openstudio::path materials_dcfilename = t_radDir / openstudio::toPath("bsdf/mapping.rad");
2060
1/1
✓ Branch 1 taken 12 times.
12 OFSTREAM materials_dcfile(materials_dcfilename);
2061
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 if (materials_dcfile.is_open()) {
2062
1/1
✓ Branch 1 taken 12 times.
12 t_outfiles.push_back(materials_dcfilename);
2063
2/2
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 12 times.
33 for (const auto& line : m_radDCmats) {
2064
1/1
✓ Branch 1 taken 21 times.
21 materials_dcfile << line;
2065 };
2066 } else {
2067 ✗ LOG(Error, "Cannot open file '" << toString(materials_dcfilename) << "' for writing");
2068 }
2069
2070 // write complete scene
2071
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 openstudio::path modelfilename = t_radDir / openstudio::toPath("model.rad");
2072
1/1
✓ Branch 1 taken 12 times.
12 OFSTREAM modelfile(modelfilename);
2073
2074
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 if (modelfile.is_open()) {
2075
1/1
✓ Branch 1 taken 12 times.
12 t_outfiles.push_back(modelfilename);
2076
2077
1/1
✓ Branch 3 taken 12 times.
12 std::set<openstudio::path> uniquePaths(m_radSceneFiles.begin(), m_radSceneFiles.end());
2078
2079
2/2
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 12 times.
75 for (const auto& filename : uniquePaths) {
2080
5/5
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
✓ Branch 10 taken 63 times.
✓ Branch 13 taken 63 times.
63 modelfile << "!xform ./" << openstudio::toString(openstudio::relativePath(filename, t_radDir)) << '\n';
2081 }
2082 12 } else {
2083 ✗ LOG(Error, "Cannot open file '" << toString(modelfilename) << "' for writing");
2084 }
2085 12 }
2086 3 }
2087
2088 ✗ boost::optional<openstudio::path> ForwardTranslator::getBSDF(double vlt, double vltSpecular, const std::string& shadeType) {
2089 ✗ std::string searchTerm = "BSDF";
2090 ✗ unsigned tid = 1316; // "Construction Assembly.Fenestration.Window";
2091
2092 ✗ boost::optional<std::string> result;
2093
2094 ✗ openstudio::LocalBCL& localBCL = openstudio::LocalBCL::instance();
2095 ✗ result = getBSDF(localBCL, vlt, vltSpecular, shadeType, searchTerm, tid);
2096 ✗ if (result) {
2097 ✗ return toPath(*result);
2098 }
2099
2100 ✗ openstudio::RemoteBCL remoteBCL;
2101 ✗ result = getBSDF(remoteBCL, vlt, vltSpecular, shadeType, searchTerm, tid);
2102 ✗ if (result) {
2103 ✗ return toPath(*result);
2104 }
2105
2106 ✗ return boost::none;
2107 ✗ }
2108
2109 ✗ boost::optional<std::string> ForwardTranslator::getBSDF(openstudio::LocalBCL& bcl, double vlt, double vltSpecular, const std::string& shadeType,
2110 const std::string& searchTerm, unsigned tid) {
2111 ✗ std::vector<BCLComponent> results = bcl.searchComponents(searchTerm, tid);
2112 ✗ for (const BCLComponent& result : results) {
2113
2114 try {
2115
2116 ✗ if (result.files("xml").empty()) {
2117 ✗ continue;
2118 }
2119
2120 ✗ double vltDiff = std::numeric_limits<double>::max();
2121 ✗ double vltSpecularDiff = std::numeric_limits<double>::max();
2122 ✗ bool shadeTypeMatch = false;
2123 ✗ for (const Attribute& attribute : result.attributes()) {
2124 ✗ std::string attributeName = attribute.name();
2125 ✗ if (istringEqual(attributeName, "Visible Light Transmittance")) {
2126 ✗ vltDiff = std::abs(attribute.valueAsDouble() - vlt);
2127 ✗ } else if (istringEqual(attributeName, "Visible Light Transmittance Specular Percentage")) {
2128 ✗ vltSpecularDiff = std::abs(attribute.valueAsDouble() - vltSpecular);
2129 ✗ } else if (istringEqual(attributeName, "Interior Shade Layer Type")) {
2130 ✗ shadeTypeMatch = istringEqual(attribute.valueAsString(), shadeType);
2131 }
2132 ✗ }
2133
2134 // check if meets criteria
2135 ✗ if (vltDiff <= 0.01 && vltSpecularDiff <= 0.01 && shadeTypeMatch) {
2136 // this one works try to get payload
2137 ✗ std::vector<std::string> files = result.files("xml");
2138 ✗ if (!files.empty()) {
2139 ✗ return files[0];
2140 }
2141 ✗ }
2142
2143 ✗ } catch (const std::exception&) {
2144 // not the right one
2145 ✗ }
2146 }
2147
2148 ✗ return boost::none;
2149 ✗ }
2150
2151 ✗ boost::optional<std::string> ForwardTranslator::getBSDF(openstudio::RemoteBCL& bcl, double vlt, double vltSpecular, const std::string& shadeType,
2152 const std::string& searchTerm, unsigned tid) {
2153 ✗ boost::optional<BCLMetaSearchResult> metaResult = bcl.metaSearchComponentLibrary(searchTerm, tid);
2154 ✗ if (metaResult) {
2155 ✗ unsigned numResults = metaResult->numResults();
2156 ✗ unsigned resultsPerQuery = bcl.resultsPerQuery();
2157 ✗ unsigned numPages = numResults / resultsPerQuery;
2158 ✗ if ((numResults % resultsPerQuery) > 0) {
2159 ✗ ++numPages;
2160 }
2161
2162 ✗ for (unsigned page = 0; page < numPages; ++page) {
2163 ✗ std::vector<BCLSearchResult> results = bcl.searchComponentLibrary(searchTerm, tid, page);
2164 ✗ for (const BCLSearchResult& result : results) {
2165
2166 try {
2167
2168 ✗ bool hasXML = false;
2169 ✗ for (const BCLFile& file : result.files()) {
2170 ✗ if (file.filetype() == "xml") {
2171 ✗ hasXML = true;
2172 }
2173 ✗ }
2174 ✗ if (!hasXML) {
2175 ✗ continue;
2176 }
2177
2178 ✗ double vltDiff = std::numeric_limits<double>::max();
2179 ✗ double vltSpecularDiff = std::numeric_limits<double>::max();
2180 ✗ bool shadeTypeMatch = false;
2181 ✗ for (const Attribute& attribute : result.attributes()) {
2182 ✗ std::string attributeName = attribute.name();
2183 ✗ if (istringEqual(attributeName, "Visible Light Transmittance")) {
2184 ✗ vltDiff = std::abs(attribute.valueAsDouble() - vlt);
2185 ✗ } else if (istringEqual(attributeName, "Visible Light Transmittance Specular Percentage")) {
2186 ✗ vltSpecularDiff = std::abs(attribute.valueAsDouble() - vltSpecular);
2187 ✗ } else if (istringEqual(attributeName, "Interior Shade Layer Type")) {
2188 ✗ shadeTypeMatch = istringEqual(attribute.valueAsString(), shadeType);
2189 }
2190 ✗ }
2191
2192 // check if meets criteria
2193 ✗ if (vltDiff <= 0.01 && vltSpecularDiff <= 1 && shadeTypeMatch) {
2194 // this one works try to get payload
2195 ✗ boost::optional<BCLComponent> component = bcl.getComponent(result.uid());
2196 ✗ if (component) {
2197 ✗ std::vector<std::string> files = component->files("xml");
2198 ✗ if (!files.empty()) {
2199 ✗ return files[0];
2200 }
2201 ✗ }
2202 ✗ }
2203
2204 ✗ } catch (const std::exception&) {
2205 // not the right one
2206 ✗ }
2207 }
2208 ✗ }
2209 }
2210
2211 ✗ return boost::none;
2212 ✗ }
2213
2214 80 std::string cleanName(const std::string& name) {
2215
3/3
✓ Branch 2 taken 80 times.
✓ Branch 5 taken 80 times.
✓ Branch 8 taken 80 times.
160 std::string result = boost::algorithm::replace_all_regex_copy(name, boost::regex("[\\.\\s:]"), std::string("_"));
2216 80 return result;
2217 }
2218
2219 ✗ openstudio::model::Model modelToRadPreProcess(const openstudio::model::Model& model) {
2220 ✗ auto outmodel = model.clone().cast<model::Model>();
2221 ✗ outmodel.purgeUnusedResourceObjects();
2222 ✗ outmodel.getUniqueModelObject<openstudio::model::Building>(); // implicitly create building object
2223 ✗ outmodel.getUniqueModelObject<openstudio::model::Timestep>(); // implicitly create timestep object
2224 ✗ outmodel.getUniqueModelObject<openstudio::model::RunPeriod>(); // implicitly create runperiod object
2225
2226 ✗ std::map<std::string, openstudio::model::ThermalZone> thermalZones;
2227
2228 ✗ std::vector<openstudio::model::Space> spaces = outmodel.getConcreteModelObjects<openstudio::model::Space>();
2229 ✗ for (auto& space : spaces) {
2230 ✗ space.hardApplyConstructions();
2231 ✗ space.hardApplySpaceType(true);
2232 ✗ space.hardApplySpaceLoadSchedules();
2233
2234 // make all surfaces with surface boundary condition adiabatic
2235 ✗ std::vector<openstudio::model::Surface> surfaces = space.surfaces();
2236 ✗ for (auto& surf_it : surfaces) {
2237 ✗ boost::optional<openstudio::model::Surface> adjacentSurface = surf_it.adjacentSurface();
2238 ✗ if (adjacentSurface) {
2239
2240 // make sure to hard apply constructions in other space before messing with surface in other space
2241 ✗ boost::optional<openstudio::model::Space> adjacentSpace = adjacentSurface->space();
2242 ✗ if (adjacentSpace) {
2243 ✗ adjacentSpace->hardApplyConstructions();
2244 }
2245
2246 // resets both surfaces
2247 ✗ surf_it.resetAdjacentSurface();
2248
2249 // set both to adiabatic
2250 ✗ surf_it.setOutsideBoundaryCondition("Adiabatic");
2251 ✗ adjacentSurface->setOutsideBoundaryCondition("Adiabatic");
2252
2253 // remove interior windows
2254 ✗ for (openstudio::model::SubSurface subSurface : surf_it.subSurfaces()) {
2255 ✗ subSurface.remove();
2256 ✗ }
2257 ✗ for (openstudio::model::SubSurface subSurface : adjacentSurface->subSurfaces()) {
2258 ✗ subSurface.remove();
2259 ✗ }
2260 ✗ }
2261 ✗ }
2262
2263 ✗ openstudio::model::Space new_space = space.clone(outmodel).optionalCast<openstudio::model::Space>().get();
2264
2265 ✗ boost::optional<openstudio::model::ThermalZone> thermalZone = space.thermalZone();
2266
2267 ✗ if (thermalZone && thermalZone->name()) {
2268 ✗ if (thermalZones.find(*thermalZone->name()) == thermalZones.end()) {
2269 ✗ openstudio::model::ThermalZone newThermalZone(outmodel);
2270 ✗ newThermalZone.setName(*thermalZone->name());
2271 ✗ newThermalZone.setUseIdealAirLoads(true);
2272 ✗ thermalZones.insert(std::make_pair(*thermalZone->name(), newThermalZone));
2273 ✗ }
2274 ✗ auto itr = thermalZones.find(*thermalZone->name());
2275 ✗ OS_ASSERT(itr != thermalZones.end()); // We just added it above if we needed it
2276 ✗ new_space.setThermalZone(itr->second);
2277 ✗ } else if (thermalZone && !thermalZone->name()) {
2278 ✗ LOG_FREE(Warn, "radiance::modelToRadPreProcess", "Space discovered in un-named thermalZone, not translating");
2279 }
2280 ✗ }
2281
2282 std::vector<openstudio::model::ShadingSurfaceGroup> shadingsurfacegroups =
2283 ✗ outmodel.getConcreteModelObjects<openstudio::model::ShadingSurfaceGroup>();
2284 ✗ for (auto& shadingSurfaceGroup : shadingsurfacegroups) {
2285 ✗ shadingSurfaceGroup.remove();
2286 }
2287
2288 ✗ std::vector<openstudio::model::SpaceItem> spaceitems = outmodel.getModelObjects<openstudio::model::SpaceItem>();
2289 ✗ for (auto& spaceItem : spaceitems) {
2290 ✗ if (spaceItem.optionalCast<openstudio::model::People>()) {
2291 // keep people
2292 ✗ } else if (spaceItem.optionalCast<openstudio::model::Lights>()) {
2293 // keep lights
2294 ✗ } else if (spaceItem.optionalCast<openstudio::model::Luminaire>()) {
2295 // keep luminaires
2296 } else {
2297 ✗ spaceItem.remove();
2298 }
2299 }
2300
2301 ✗ std::vector<openstudio::model::OutputVariable> outputVariables = outmodel.getConcreteModelObjects<openstudio::model::OutputVariable>();
2302 ✗ for (auto& outputVariable : outputVariables) {
2303 ✗ outputVariable.remove();
2304 }
2305
2306 ✗ openstudio::model::OutputVariable outputVariable("Site Exterior Horizontal Sky Illuminance", outmodel);
2307 ✗ outputVariable.setReportingFrequency("Hourly");
2308
2309 ✗ outputVariable = openstudio::model::OutputVariable("Site Exterior Beam Normal Illuminance", outmodel);
2310 ✗ outputVariable.setReportingFrequency("Hourly");
2311
2312 ✗ outputVariable = openstudio::model::OutputVariable("Site Solar Altitude Angle", outmodel);
2313 ✗ outputVariable.setReportingFrequency("Hourly");
2314
2315 ✗ outputVariable = openstudio::model::OutputVariable("Site Solar Azimuth Angle", outmodel);
2316 ✗ outputVariable.setReportingFrequency("Hourly");
2317
2318 ✗ outputVariable = openstudio::model::OutputVariable("Site Sky Diffuse Solar Radiation Luminous Efficacy", outmodel);
2319 ✗ outputVariable.setReportingFrequency("Hourly");
2320
2321 ✗ outputVariable = openstudio::model::OutputVariable("Site Beam Solar Radiation Luminous Efficacy", outmodel);
2322 ✗ outputVariable.setReportingFrequency("Hourly");
2323
2324 ✗ outputVariable = openstudio::model::OutputVariable("Zone People Occupant Count", outmodel);
2325 ✗ outputVariable.setReportingFrequency("Hourly");
2326
2327 ✗ outputVariable = openstudio::model::OutputVariable("Zone Lights Electricity Rate", outmodel);
2328 ✗ outputVariable.setReportingFrequency("Hourly");
2329
2330 // only report weather periods
2331 ✗ auto simulation_control = outmodel.getUniqueModelObject<openstudio::model::SimulationControl>();
2332 ✗ simulation_control.setRunSimulationforSizingPeriods(false);
2333 ✗ simulation_control.setRunSimulationforWeatherFileRunPeriods(true);
2334 ✗ simulation_control.setSolarDistribution("MinimalShadowing");
2335
2336 // purge unused
2337 ✗ outmodel.purgeUnusedResourceObjects();
2338
2339 ✗ return outmodel;
2340 ✗ }
2341
2342 } // namespace radiance
2343 } // namespace openstudio
2344