GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 46.9% 105 / 0 / 224
Functions: 45.1% 23 / 0 / 51
Branches: 40.9% 79 / 0 / 193

src/model/ShadingSurface.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 "ShadingSurface.hpp"
7 #include "ShadingSurface_Impl.hpp"
8
9 #include "Model.hpp"
10 #include "Model_Impl.hpp"
11 #include "ShadingSurfaceGroup.hpp"
12 #include "ShadingSurfaceGroup_Impl.hpp"
13 #include "ConstructionBase.hpp"
14 #include "ConstructionBase_Impl.hpp"
15 #include "Space.hpp"
16 #include "Space_Impl.hpp"
17 #include "SpaceType.hpp"
18 #include "SpaceType_Impl.hpp"
19 #include "Building.hpp"
20 #include "Building_Impl.hpp"
21 #include "DefaultConstructionSet.hpp"
22 #include "DefaultConstructionSet_Impl.hpp"
23 #include "Schedule.hpp"
24 #include "Schedule_Impl.hpp"
25 #include "DaylightingDeviceShelf.hpp"
26 #include "DaylightingDeviceShelf_Impl.hpp"
27
28 #include <utilities/idd/OS_ShadingSurface_FieldEnums.hxx>
29 #include <utilities/idd/IddEnums.hxx>
30
31 #include "../utilities/core/Assert.hpp"
32
33 namespace openstudio {
34 namespace model {
35
36 namespace detail {
37
38 2399 ShadingSurface_Impl::ShadingSurface_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
39 2399 : PlanarSurface_Impl(idfObject, model, keepHandle) {
40
4/6
✓ Branch 1 taken 2399 times.
✓ Branch 4 taken 2399 times.
✓ Branch 7 taken 2399 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2399 times.
✗ Branch 13 not taken.
2399 OS_ASSERT(idfObject.iddObject().type() == ShadingSurface::iddObjectType());
41 2399 }
42
43 295 ShadingSurface_Impl::ShadingSurface_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
44 295 : PlanarSurface_Impl(other, model, keepHandle) {
45
4/6
✓ Branch 1 taken 295 times.
✓ Branch 4 taken 295 times.
✓ Branch 7 taken 295 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 295 times.
✗ Branch 13 not taken.
295 OS_ASSERT(other.iddObject().type() == ShadingSurface::iddObjectType());
46 295 }
47
48 1147 ShadingSurface_Impl::ShadingSurface_Impl(const ShadingSurface_Impl& other, Model_Impl* model, bool keepHandle)
49 1147 : PlanarSurface_Impl(other, model, keepHandle) {}
50
51 145 boost::optional<ParentObject> ShadingSurface_Impl::parent() const {
52 145 boost::optional<ParentObject> result;
53
2/2
✓ Branch 1 taken 145 times.
✓ Branch 4 taken 145 times.
145 result = this->shadingSurfaceGroup();
54 145 return result;
55 ✗ }
56
57 682 std::vector<ModelObject> ShadingSurface_Impl::children() const {
58 682 std::vector<ModelObject> result;
59
60 // solar collectors?
61
62 682 return result;
63 }
64
65 3 bool ShadingSurface_Impl::setParent(ParentObject& newParent) {
66 3 bool result = false;
67
1/1
✓ Branch 1 taken 3 times.
3 OptionalShadingSurfaceGroup shadingSurfaceGroup = newParent.optionalCast<ShadingSurfaceGroup>();
68
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (shadingSurfaceGroup) {
69
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 result = this->setShadingSurfaceGroup(*shadingSurfaceGroup);
70 }
71 3 return result;
72 3 }
73
74 3 const std::vector<std::string>& ShadingSurface_Impl::outputVariableNames() const {
75
3/4
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
3 static const std::vector<std::string> result;
76 3 return result;
77 }
78
79 ✗ IddObjectType ShadingSurface_Impl::iddObjectType() const {
80 ✗ return ShadingSurface::iddObjectType();
81 }
82
83 ✗ std::vector<ScheduleTypeKey> ShadingSurface_Impl::getScheduleTypeKeys(const Schedule& schedule) const {
84 ✗ std::vector<ScheduleTypeKey> result;
85 ✗ UnsignedVector fieldIndices = getSourceIndices(schedule.handle());
86 ✗ UnsignedVector::const_iterator b(fieldIndices.begin());
87 ✗ UnsignedVector::const_iterator e(fieldIndices.end());
88 ✗ if (std::find(b, e, OS_ShadingSurfaceFields::TransmittanceScheduleName) != e) {
89 ✗ result.push_back(ScheduleTypeKey("ShadingSurface", "Transmittance"));
90 }
91 ✗ return result;
92 ✗ }
93
94 ✗ bool ShadingSurface_Impl::subtractFromGrossArea() const {
95 ✗ return false;
96 }
97
98 915 boost::optional<std::pair<ConstructionBase, int>> ShadingSurface_Impl::constructionWithSearchDistance() const {
99 915 boost::optional<std::pair<ConstructionBase, int>> result;
100
101 boost::optional<ConstructionBase> construction =
102
2/2
✓ Branch 1 taken 915 times.
✓ Branch 4 taken 915 times.
915 getObject<ModelObject>().getModelObjectTarget<ConstructionBase>(OS_ShadingSurfaceFields::ConstructionName);
103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 915 times.
915 if (construction) {
104 ✗ return std::make_pair(*construction, 0);
105 }
106
107
1/1
✓ Branch 1 taken 915 times.
915 boost::optional<ShadingSurfaceGroup> shadingSurfaceGroup = this->shadingSurfaceGroup();
108
1/2
✓ Branch 0 taken 915 times.
✗ Branch 1 not taken.
915 if (shadingSurfaceGroup) {
109
110 // check the space
111
2/2
✓ Branch 1 taken 915 times.
✓ Branch 4 taken 915 times.
915 boost::optional<Space> space = shadingSurfaceGroup->space();
112
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 614 times.
915 if (space) {
113
3/3
✓ Branch 1 taken 301 times.
✓ Branch 4 taken 301 times.
✓ Branch 7 taken 301 times.
301 result = space->getDefaultConstructionWithSearchDistance(this->getObject<ShadingSurface>());
114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 301 times.
301 if (result) {
115 ✗ return result;
116 }
117 }
118
119 // check the building
120
2/2
✓ Branch 1 taken 915 times.
✓ Branch 4 taken 915 times.
915 boost::optional<Building> building = this->model().building();
121
1/2
✓ Branch 0 taken 915 times.
✗ Branch 1 not taken.
915 if (building) {
122
123
2/2
✓ Branch 1 taken 915 times.
✓ Branch 4 taken 915 times.
915 boost::optional<DefaultConstructionSet> defaultConstructionSet = building->defaultConstructionSet();
124
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 557 times.
915 if (defaultConstructionSet) {
125
3/3
✓ Branch 1 taken 358 times.
✓ Branch 4 taken 358 times.
✓ Branch 7 taken 358 times.
358 construction = defaultConstructionSet->getDefaultConstruction(this->getObject<ShadingSurface>());
126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358 times.
358 if (construction) {
127 ✗ return std::make_pair(*construction, 4);
128 }
129 }
130
131 // check the building's space type
132
2/2
✓ Branch 1 taken 915 times.
✓ Branch 4 taken 915 times.
915 boost::optional<SpaceType> spaceType = building->spaceType();
133
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 732 times.
915 if (spaceType) {
134
2/2
✓ Branch 1 taken 183 times.
✓ Branch 4 taken 183 times.
183 defaultConstructionSet = spaceType->defaultConstructionSet();
135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 183 times.
183 if (defaultConstructionSet) {
136 ✗ construction = defaultConstructionSet->getDefaultConstruction(this->getObject<ShadingSurface>());
137 ✗ if (construction) {
138 ✗ return std::make_pair(*construction, 5);
139 }
140 }
141 }
142 915 }
143 915 }
144
145 915 return result;
146 915 }
147
148 ✗ bool ShadingSurface_Impl::isConstructionDefaulted() const {
149 ✗ return isEmpty(OS_ShadingSurfaceFields::ConstructionName);
150 }
151
152 ✗ bool ShadingSurface_Impl::setConstruction(const ConstructionBase& construction) {
153 ✗ return this->setPointer(OS_ShadingSurfaceFields::ConstructionName, construction.handle());
154 }
155
156 ✗ void ShadingSurface_Impl::resetConstruction() {
157 ✗ setString(OS_ShadingSurfaceFields::ConstructionName, "");
158 ✗ }
159
160 548 boost::optional<PlanarSurfaceGroup> ShadingSurface_Impl::planarSurfaceGroup() const {
161
2/2
✓ Branch 1 taken 548 times.
✓ Branch 4 taken 548 times.
548 return boost::optional<PlanarSurfaceGroup>(this->shadingSurfaceGroup());
162 }
163
164 382 boost::optional<Space> ShadingSurface_Impl::space() const {
165 382 boost::optional<Space> result;
166
1/1
✓ Branch 1 taken 382 times.
382 boost::optional<ShadingSurfaceGroup> shadingSurfaceGroup = this->shadingSurfaceGroup();
167
1/2
✓ Branch 0 taken 382 times.
✗ Branch 1 not taken.
382 if (shadingSurfaceGroup) {
168
2/2
✓ Branch 1 taken 382 times.
✓ Branch 4 taken 382 times.
382 result = shadingSurfaceGroup->space();
169 }
170 764 return result;
171 382 }
172
173 ✗ boost::optional<double> ShadingSurface_Impl::numberofVertices() const {
174 ✗ return getDouble(OS_ShadingSurfaceFields::NumberofVertices, true);
175 }
176
177 ✗ bool ShadingSurface_Impl::isNumberofVerticesDefaulted() const {
178 ✗ return isEmpty(OS_ShadingSurfaceFields::NumberofVertices);
179 }
180
181 1 bool ShadingSurface_Impl::isNumberofVerticesAutocalculated() const {
182 1 bool result = false;
183
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<std::string> value = getString(OS_ShadingSurfaceFields::NumberofVertices, true);
184
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (value) {
185
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
2 result = openstudio::istringEqual(value.get(), "Autocalculate");
186 }
187 1 return result;
188 1 }
189
190 ✗ bool ShadingSurface_Impl::setNumberofVertices(boost::optional<double> numberofVertices) {
191 ✗ bool result = false;
192 ✗ if (numberofVertices) {
193 ✗ result = setDouble(OS_ShadingSurfaceFields::NumberofVertices, numberofVertices.get());
194 } else {
195 ✗ result = setString(OS_ShadingSurfaceFields::NumberofVertices, "");
196 }
197 ✗ return result;
198 }
199
200 ✗ bool ShadingSurface_Impl::setNumberofVertices(double numberofVertices) {
201 ✗ bool result = setDouble(OS_ShadingSurfaceFields::NumberofVertices, numberofVertices);
202 ✗ return result;
203 }
204
205 ✗ void ShadingSurface_Impl::resetNumberofVertices() {
206 ✗ bool result = setString(OS_ShadingSurfaceFields::NumberofVertices, "");
207 ✗ OS_ASSERT(result);
208 ✗ }
209
210 1 void ShadingSurface_Impl::autocalculateNumberofVertices() {
211
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ShadingSurfaceFields::NumberofVertices, "Autocalculate");
212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
213 1 }
214
215 3663 boost::optional<ShadingSurfaceGroup> ShadingSurface_Impl::shadingSurfaceGroup() const {
216 3663 boost::optional<ShadingSurfaceGroup> result;
217
1/1
✓ Branch 1 taken 3663 times.
3663 OptionalWorkspaceObject object = this->getTarget(OS_ShadingSurfaceFields::ShadingSurfaceGroupName);
218
2/2
✓ Branch 0 taken 3662 times.
✓ Branch 1 taken 1 time.
3663 if (object) {
219
2/2
✓ Branch 1 taken 3662 times.
✓ Branch 4 taken 3662 times.
3662 result = object->optionalCast<ShadingSurfaceGroup>();
220 }
221 7326 return result;
222 3663 }
223
224 2228 bool ShadingSurface_Impl::setShadingSurfaceGroup(const ShadingSurfaceGroup& shadingSurfaceGroup) {
225
2/2
✓ Branch 1 taken 2228 times.
✓ Branch 4 taken 2228 times.
2228 return this->setPointer(OS_ShadingSurfaceFields::ShadingSurfaceGroupName, shadingSurfaceGroup.handle());
226 }
227
228 ✗ void ShadingSurface_Impl::resetShadingSurfaceGroup() {
229 ✗ bool ok = setString(OS_ShadingSurfaceFields::ShadingSurfaceGroupName, "");
230 ✗ OS_ASSERT(ok);
231 ✗ }
232
233 407 boost::optional<Schedule> ShadingSurface_Impl::transmittanceSchedule() const {
234 407 boost::optional<Schedule> result;
235
1/1
✓ Branch 1 taken 407 times.
407 OptionalWorkspaceObject object = this->getTarget(OS_ShadingSurfaceFields::TransmittanceScheduleName);
236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 407 times.
407 if (object) {
237 ✗ result = object->optionalCast<Schedule>();
238 }
239 814 return result;
240 407 }
241
242 ✗ bool ShadingSurface_Impl::setTransmittanceSchedule(Schedule& transmittanceSchedule) {
243 ✗ bool result = setSchedule(OS_ShadingSurfaceFields::TransmittanceScheduleName, "ShadingSurface", "Transmittance", transmittanceSchedule);
244 ✗ return result;
245 }
246
247 ✗ void ShadingSurface_Impl::resetTransmittanceSchedule() {
248 ✗ bool test = this->setString(OS_ShadingSurfaceFields::TransmittanceScheduleName, "");
249 ✗ OS_ASSERT(test);
250 ✗ }
251
252 ✗ boost::optional<DaylightingDeviceShelf> ShadingSurface_Impl::daylightingDeviceShelf() const {
253 ✗ std::vector<DaylightingDeviceShelf> sources = getObject<ModelObject>().getModelObjectSources<DaylightingDeviceShelf>();
254 ✗ if (sources.empty()) {
255 ✗ return boost::none;
256 }
257 ✗ if (sources.size() > 1) {
258 ✗ LOG(Error, "ShadingSurface is referenced by more than one DaylightingDeviceShelf, returning first");
259 }
260 ✗ return sources[0];
261 ✗ }
262
263 ✗ boost::optional<ModelObject> ShadingSurface_Impl::shadingSurfaceGroupAsModelObject() const {
264 ✗ OptionalModelObject result;
265 ✗ OptionalShadingSurfaceGroup intermediate = shadingSurfaceGroup();
266 ✗ if (intermediate) {
267 ✗ result = *intermediate;
268 }
269 ✗ return result;
270 ✗ }
271
272 ✗ boost::optional<ModelObject> ShadingSurface_Impl::transmittanceScheduleAsModelObject() const {
273 ✗ OptionalModelObject result;
274 ✗ OptionalSchedule intermediate = transmittanceSchedule();
275 ✗ if (intermediate) {
276 ✗ result = *intermediate;
277 }
278 ✗ return result;
279 ✗ }
280
281 ✗ bool ShadingSurface_Impl::setShadingSurfaceGroupAsModelObject(const boost::optional<ModelObject>& modelObject) {
282 ✗ if (modelObject) {
283 ✗ OptionalShadingSurfaceGroup intermediate = modelObject->optionalCast<ShadingSurfaceGroup>();
284 ✗ if (intermediate) {
285 ✗ return setShadingSurfaceGroup(*intermediate);
286 } else {
287 ✗ return false;
288 }
289 ✗ } else {
290 ✗ resetShadingSurfaceGroup();
291 }
292 ✗ return true;
293 }
294
295 ✗ bool ShadingSurface_Impl::setTransmittanceScheduleAsModelObject(const boost::optional<ModelObject>& modelObject) {
296 ✗ if (modelObject) {
297 ✗ OptionalSchedule intermediate = modelObject->optionalCast<Schedule>();
298 ✗ if (intermediate) {
299 ✗ Schedule schedule(*intermediate);
300 ✗ return setTransmittanceSchedule(schedule);
301 ✗ } else {
302 ✗ return false;
303 }
304 ✗ } else {
305 ✗ resetTransmittanceSchedule();
306 }
307 ✗ return true;
308 }
309
310 } // namespace detail
311
312 2101 ShadingSurface::ShadingSurface(const std::vector<Point3d>& vertices, const Model& model)
313 2101 : PlanarSurface(ShadingSurface::iddObjectType(), vertices, model) {
314
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 2101 times.
✗ Branch 5 not taken.
2101 OS_ASSERT(getImpl<detail::ShadingSurface_Impl>());
315 2101 }
316
317 14799 IddObjectType ShadingSurface::iddObjectType() {
318
1/1
✓ Branch 1 taken 14799 times.
14799 IddObjectType result(IddObjectType::OS_ShadingSurface);
319 14799 return result;
320 }
321
322 ✗ boost::optional<double> ShadingSurface::numberofVertices() const {
323 ✗ return getImpl<detail::ShadingSurface_Impl>()->numberofVertices();
324 }
325
326 ✗ bool ShadingSurface::isNumberofVerticesDefaulted() const {
327 ✗ return getImpl<detail::ShadingSurface_Impl>()->isNumberofVerticesDefaulted();
328 }
329
330 1 bool ShadingSurface::isNumberofVerticesAutocalculated() const {
331
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ShadingSurface_Impl>()->isNumberofVerticesAutocalculated();
332 }
333
334 ✗ bool ShadingSurface::setNumberofVertices(boost::optional<double> numberofVertices) {
335 ✗ return getImpl<detail::ShadingSurface_Impl>()->setNumberofVertices(numberofVertices);
336 }
337
338 ✗ bool ShadingSurface::setNumberofVertices(double numberofVertices) {
339 ✗ return getImpl<detail::ShadingSurface_Impl>()->setNumberofVertices(numberofVertices);
340 }
341
342 ✗ void ShadingSurface::resetNumberofVertices() {
343 ✗ getImpl<detail::ShadingSurface_Impl>()->resetNumberofVertices();
344 ✗ }
345
346 1 void ShadingSurface::autocalculateNumberofVertices() {
347
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ShadingSurface_Impl>()->autocalculateNumberofVertices();
348 1 }
349
350 1673 boost::optional<ShadingSurfaceGroup> ShadingSurface::shadingSurfaceGroup() const {
351
1/1
✓ Branch 3 taken 1673 times.
1673 return getImpl<detail::ShadingSurface_Impl>()->shadingSurfaceGroup();
352 }
353
354 2225 bool ShadingSurface::setShadingSurfaceGroup(const ShadingSurfaceGroup& shadingSurfaceGroup) {
355
1/1
✓ Branch 3 taken 2225 times.
2225 return getImpl<detail::ShadingSurface_Impl>()->setShadingSurfaceGroup(shadingSurfaceGroup);
356 }
357
358 ✗ void ShadingSurface::resetShadingSurfaceGroup() {
359 ✗ getImpl<detail::ShadingSurface_Impl>()->resetShadingSurfaceGroup();
360 ✗ }
361
362 407 boost::optional<Schedule> ShadingSurface::transmittanceSchedule() const {
363
1/1
✓ Branch 3 taken 407 times.
407 return getImpl<detail::ShadingSurface_Impl>()->transmittanceSchedule();
364 }
365
366 ✗ bool ShadingSurface::setTransmittanceSchedule(Schedule& transmittanceSchedule) {
367 ✗ return getImpl<detail::ShadingSurface_Impl>()->setTransmittanceSchedule(transmittanceSchedule);
368 }
369
370 ✗ void ShadingSurface::resetTransmittanceSchedule() {
371 ✗ getImpl<detail::ShadingSurface_Impl>()->resetTransmittanceSchedule();
372 ✗ }
373
374 ✗ boost::optional<DaylightingDeviceShelf> ShadingSurface::daylightingDeviceShelf() const {
375 ✗ return getImpl<detail::ShadingSurface_Impl>()->daylightingDeviceShelf();
376 }
377
378 /// @cond
379
1/1
✓ Branch 3 taken 12954 times.
12954 ShadingSurface::ShadingSurface(std::shared_ptr<detail::ShadingSurface_Impl> impl) : PlanarSurface(std::move(impl)) {}
380 /// @endcond
381
382 } // namespace model
383 } // namespace openstudio
384