GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 60.7% 128 / 0 / 211
Functions: 72.4% 42 / 0 / 58
Branches: 51.9% 84 / 0 / 162

src/model/BuildingStory.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 "BuildingStory.hpp"
7 #include "BuildingStory_Impl.hpp"
8
9 #include "Model.hpp"
10 #include "Model_Impl.hpp"
11 #include "SpaceType.hpp"
12 #include "SpaceType_Impl.hpp"
13 #include "Space.hpp"
14 #include "Space_Impl.hpp"
15 #include "DefaultConstructionSet.hpp"
16 #include "DefaultConstructionSet_Impl.hpp"
17 #include "DefaultScheduleSet.hpp"
18 #include "DefaultScheduleSet_Impl.hpp"
19 #include "Schedule.hpp"
20 #include "Schedule_Impl.hpp"
21 #include "RenderingColor.hpp"
22 #include "RenderingColor_Impl.hpp"
23
24 #include <utilities/idd/OS_BuildingStory_FieldEnums.hxx>
25 #include <utilities/idd/IddEnums.hxx>
26
27 #include "../utilities/core/Assert.hpp"
28 #include "../utilities/geometry/BoundingBox.hpp"
29 #include "../utilities/geometry/Point3d.hpp"
30
31 namespace openstudio {
32 namespace model {
33
34 namespace detail {
35
36 685 BuildingStory_Impl::BuildingStory_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
37 685 : ModelObject_Impl(idfObject, model, keepHandle) {
38
4/6
✓ Branch 1 taken 685 times.
✓ Branch 4 taken 685 times.
✓ Branch 7 taken 685 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 685 times.
✗ Branch 13 not taken.
685 OS_ASSERT(idfObject.iddObject().type() == BuildingStory::iddObjectType());
39 685 }
40
41 232 BuildingStory_Impl::BuildingStory_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
42 232 : ModelObject_Impl(other, model, keepHandle) {
43
4/6
✓ Branch 1 taken 232 times.
✓ Branch 4 taken 232 times.
✓ Branch 7 taken 232 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 232 times.
✗ Branch 13 not taken.
232 OS_ASSERT(other.iddObject().type() == BuildingStory::iddObjectType());
44 232 }
45
46 117 BuildingStory_Impl::BuildingStory_Impl(const BuildingStory_Impl& other, Model_Impl* model, bool keepHandle)
47 117 : ModelObject_Impl(other, model, keepHandle) {}
48
49 1 const std::vector<std::string>& BuildingStory_Impl::outputVariableNames() const {
50
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
1 static const std::vector<std::string> result;
51 1 return result;
52 }
53
54 14874 IddObjectType BuildingStory_Impl::iddObjectType() const {
55 14874 return BuildingStory::iddObjectType();
56 }
57
58 804 boost::optional<double> BuildingStory_Impl::nominalZCoordinate() const {
59 804 return getDouble(OS_BuildingStoryFields::NominalZCoordinate, true);
60 }
61
62 299 boost::optional<double> BuildingStory_Impl::nominalFloortoFloorHeight() const {
63
1/1
✓ Branch 1 taken 299 times.
299 boost::optional<double> value = getDouble(OS_BuildingStoryFields::NominalFloortoFloorHeight, true);
64 299 return value;
65 }
66
67 301 boost::optional<double> BuildingStory_Impl::nominalFloortoCeilingHeight() const {
68
1/1
✓ Branch 1 taken 301 times.
301 boost::optional<double> value = getDouble(OS_BuildingStoryFields::NominalFloortoCeilingHeight, true);
69 301 return value;
70 }
71
72 453 openstudio::BoundingBox BuildingStory_Impl::boundingBoxBuildingCoordinates() const {
73 453 BoundingBox result;
74
3/3
✓ Branch 1 taken 453 times.
✓ Branch 7 taken 4738 times.
✓ Branch 8 taken 453 times.
5191 for (const auto& space : spaces()) {
75
3/3
✓ Branch 1 taken 4738 times.
✓ Branch 4 taken 4738 times.
✓ Branch 7 taken 4738 times.
4738 result.addPoints(space.boundingBoxBuildingCoordinates().corners());
76 453 }
77 453 return result;
78 }
79
80 ✗ openstudio::BoundingBox BuildingStory_Impl::boundingBoxSiteCoordinates() const {
81 ✗ BoundingBox result;
82 ✗ for (const auto& space : spaces()) {
83 ✗ result.addPoints(space.boundingBoxSiteCoordinates().corners());
84 ✗ }
85 ✗ return result;
86 }
87
88 355 bool BuildingStory_Impl::setNominalZCoordinate(double nominalZCoordinate) {
89 355 bool result = setDouble(OS_BuildingStoryFields::NominalZCoordinate, nominalZCoordinate);
90
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 355 times.
355 OS_ASSERT(result);
91 355 return result;
92 }
93
94 2 void BuildingStory_Impl::resetNominalZCoordinate() {
95
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 bool result = setString(OS_BuildingStoryFields::NominalZCoordinate, "");
96
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
97 2 }
98
99 353 bool BuildingStory_Impl::setNominalFloortoFloorHeight(double nominalFloortoFloorHeight) {
100 353 bool result = setDouble(OS_BuildingStoryFields::NominalFloortoFloorHeight, nominalFloortoFloorHeight);
101 353 return result;
102 }
103
104 ✗ void BuildingStory_Impl::resetNominalFloortoFloorHeight() {
105 ✗ bool result = setString(OS_BuildingStoryFields::NominalFloortoFloorHeight, "");
106 ✗ OS_ASSERT(result);
107 ✗ }
108
109 177 bool BuildingStory_Impl::setNominalFloortoCeilingHeight(double nominalFloortoCeilingHeight) {
110 177 bool result = setDouble(OS_BuildingStoryFields::NominalFloortoCeilingHeight, nominalFloortoCeilingHeight);
111 177 return result;
112 }
113
114 ✗ void BuildingStory_Impl::resetNominalFloortoCeilingHeight() {
115 ✗ bool result = setString(OS_BuildingStoryFields::NominalFloortoCeilingHeight, "");
116 ✗ OS_ASSERT(result);
117 ✗ }
118
119 38567 boost::optional<DefaultConstructionSet> BuildingStory_Impl::defaultConstructionSet() const {
120
2/2
✓ Branch 1 taken 38567 times.
✓ Branch 4 taken 38567 times.
38567 return getObject<ModelObject>().getModelObjectTarget<DefaultConstructionSet>(OS_BuildingStoryFields::DefaultConstructionSetName);
121 }
122
123 24 bool BuildingStory_Impl::setDefaultConstructionSet(const DefaultConstructionSet& defaultConstructionSet) {
124
2/2
✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
24 return setPointer(OS_BuildingStoryFields::DefaultConstructionSetName, defaultConstructionSet.handle());
125 }
126
127 5 void BuildingStory_Impl::resetDefaultConstructionSet() {
128
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
10 setString(OS_BuildingStoryFields::DefaultConstructionSetName, "");
129 5 }
130
131 53 boost::optional<DefaultScheduleSet> BuildingStory_Impl::defaultScheduleSet() const {
132
2/2
✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
53 return getObject<ModelObject>().getModelObjectTarget<DefaultScheduleSet>(OS_BuildingStoryFields::DefaultScheduleSetName);
133 }
134
135 6 boost::optional<Schedule> BuildingStory_Impl::getDefaultSchedule(const DefaultScheduleType& defaultScheduleType) const {
136 6 boost::optional<Schedule> result;
137 6 boost::optional<DefaultScheduleSet> defaultScheduleSet;
138 6 boost::optional<Building> building;
139 6 boost::optional<SpaceType> spaceType;
140
141 // first check this object
142
1/1
✓ Branch 1 taken 6 times.
6 defaultScheduleSet = this->defaultScheduleSet();
143
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (defaultScheduleSet) {
144
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 result = defaultScheduleSet->getDefaultSchedule(defaultScheduleType);
145
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (result) {
146 2 return result;
147 }
148 }
149
150 // then check building
151
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 building = this->model().building();
152
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (building) {
153
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 defaultScheduleSet = building->defaultScheduleSet();
154
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (defaultScheduleSet) {
155
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 result = defaultScheduleSet->getDefaultSchedule(defaultScheduleType);
156
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if (result) {
157 2 return result;
158 }
159 }
160
161 // then check building's space type
162
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 spaceType = building->spaceType();
163
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (spaceType) {
164
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 defaultScheduleSet = spaceType->defaultScheduleSet();
165
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (defaultScheduleSet) {
166
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 result = defaultScheduleSet->getDefaultSchedule(defaultScheduleType);
167
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (result) {
168 2 return result;
169 }
170 }
171 }
172 }
173
174 ✗ return boost::none;
175 6 }
176
177 1 bool BuildingStory_Impl::setDefaultScheduleSet(const DefaultScheduleSet& defaultScheduleSet) {
178
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 return setPointer(OS_BuildingStoryFields::DefaultScheduleSetName, defaultScheduleSet.handle());
179 }
180
181 ✗ void BuildingStory_Impl::resetDefaultScheduleSet() {
182 ✗ setString(OS_BuildingStoryFields::DefaultScheduleSetName, "");
183 ✗ }
184
185 637 boost::optional<RenderingColor> BuildingStory_Impl::renderingColor() const {
186
2/2
✓ Branch 1 taken 637 times.
✓ Branch 4 taken 637 times.
637 return getObject<ModelObject>().getModelObjectTarget<RenderingColor>(OS_BuildingStoryFields::GroupRenderingName);
187 }
188
189 132 bool BuildingStory_Impl::setRenderingColor(const RenderingColor& renderingColor) {
190
2/2
✓ Branch 1 taken 132 times.
✓ Branch 4 taken 132 times.
132 return setPointer(OS_BuildingStoryFields::GroupRenderingName, renderingColor.handle());
191 }
192
193 ✗ void BuildingStory_Impl::resetRenderingColor() {
194 ✗ setString(OS_BuildingStoryFields::GroupRenderingName, "");
195 ✗ }
196
197 843 std::vector<Space> BuildingStory_Impl::spaces() const {
198
3/3
✓ Branch 1 taken 843 times.
✓ Branch 4 taken 843 times.
✓ Branch 7 taken 843 times.
843 return getObject<ModelObject>().getModelObjectSources<Space>(Space::iddObjectType());
199 }
200
201 ✗ boost::optional<ModelObject> BuildingStory_Impl::defaultConstructionSetAsModelObject() const {
202 ✗ OptionalModelObject result;
203 ✗ OptionalDefaultConstructionSet object = defaultConstructionSet();
204 ✗ if (object) {
205 ✗ result = *object;
206 }
207 ✗ return result;
208 ✗ }
209
210 ✗ boost::optional<ModelObject> BuildingStory_Impl::defaultScheduleSetAsModelObject() const {
211 ✗ OptionalModelObject result;
212 ✗ OptionalDefaultScheduleSet object = defaultScheduleSet();
213 ✗ if (object) {
214 ✗ result = *object;
215 }
216 ✗ return result;
217 ✗ }
218
219 ✗ boost::optional<ModelObject> BuildingStory_Impl::renderingColorAsModelObject() const {
220 ✗ OptionalModelObject result;
221 ✗ OptionalRenderingColor object = renderingColor();
222 ✗ if (object) {
223 ✗ result = *object;
224 }
225 ✗ return result;
226 ✗ }
227
228 ✗ bool BuildingStory_Impl::setDefaultConstructionSetAsModelObject(boost::optional<ModelObject> modelObject) {
229 ✗ if (modelObject) {
230 ✗ OptionalDefaultConstructionSet object = modelObject->optionalCast<DefaultConstructionSet>();
231 ✗ if (object) {
232 ✗ return setDefaultConstructionSet(*object);
233 }
234 ✗ return false;
235 ✗ } else {
236 ✗ resetDefaultConstructionSet();
237 }
238 ✗ return true;
239 }
240
241 ✗ bool BuildingStory_Impl::setDefaultScheduleSetAsModelObject(boost::optional<ModelObject> modelObject) {
242 ✗ if (modelObject) {
243 ✗ OptionalDefaultScheduleSet object = modelObject->optionalCast<DefaultScheduleSet>();
244 ✗ if (object) {
245 ✗ return setDefaultScheduleSet(*object);
246 }
247 ✗ return false;
248 ✗ } else {
249 ✗ resetDefaultScheduleSet();
250 }
251 ✗ return true;
252 }
253
254 ✗ bool BuildingStory_Impl::setRenderingColorAsModelObject(boost::optional<ModelObject> modelObject) {
255 ✗ if (modelObject) {
256 ✗ OptionalRenderingColor object = modelObject->optionalCast<RenderingColor>();
257 ✗ if (object) {
258 ✗ return setRenderingColor(*object);
259 }
260 ✗ return false;
261 ✗ } else {
262 ✗ resetRenderingColor();
263 }
264 ✗ return true;
265 }
266
267 } // namespace detail
268
269 451 BuildingStory::BuildingStory(const Model& model) : ModelObject(BuildingStory::iddObjectType(), model) {
270
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 451 times.
✗ Branch 5 not taken.
451 OS_ASSERT(getImpl<detail::BuildingStory_Impl>());
271 451 }
272
273 25364 IddObjectType BuildingStory::iddObjectType() {
274
1/1
✓ Branch 1 taken 25364 times.
25364 IddObjectType result(IddObjectType::OS_BuildingStory);
275 25364 return result;
276 }
277
278 804 boost::optional<double> BuildingStory::nominalZCoordinate() const {
279
1/1
✓ Branch 3 taken 804 times.
804 return getImpl<detail::BuildingStory_Impl>()->nominalZCoordinate();
280 }
281
282 299 boost::optional<double> BuildingStory::nominalFloortoFloorHeight() const {
283
1/1
✓ Branch 3 taken 299 times.
299 return getImpl<detail::BuildingStory_Impl>()->nominalFloortoFloorHeight();
284 }
285
286 301 boost::optional<double> BuildingStory::nominalFloortoCeilingHeight() const {
287
1/1
✓ Branch 3 taken 301 times.
301 return getImpl<detail::BuildingStory_Impl>()->nominalFloortoCeilingHeight();
288 }
289
290 453 openstudio::BoundingBox BuildingStory::boundingBoxBuildingCoordinates() const {
291
1/1
✓ Branch 3 taken 453 times.
453 return getImpl<detail::BuildingStory_Impl>()->boundingBoxBuildingCoordinates();
292 }
293
294 ✗ openstudio::BoundingBox BuildingStory::boundingBoxSiteCoordinates() const {
295 ✗ return getImpl<detail::BuildingStory_Impl>()->boundingBoxSiteCoordinates();
296 }
297
298 355 bool BuildingStory::setNominalZCoordinate(double nominalZCoordinate) {
299
1/1
✓ Branch 3 taken 355 times.
355 return getImpl<detail::BuildingStory_Impl>()->setNominalZCoordinate(nominalZCoordinate);
300 }
301
302 2 void BuildingStory::resetNominalZCoordinate() {
303
1/1
✓ Branch 3 taken 2 times.
2 getImpl<detail::BuildingStory_Impl>()->resetNominalZCoordinate();
304 2 }
305
306 353 bool BuildingStory::setNominalFloortoFloorHeight(double nominalFloortoFloorHeight) {
307
1/1
✓ Branch 3 taken 353 times.
353 return getImpl<detail::BuildingStory_Impl>()->setNominalFloortoFloorHeight(nominalFloortoFloorHeight);
308 }
309
310 ✗ void BuildingStory::resetNominalFloortoFloorHeight() {
311 ✗ getImpl<detail::BuildingStory_Impl>()->resetNominalFloortoFloorHeight();
312 ✗ }
313
314 177 bool BuildingStory::setNominalFloortoCeilingHeight(double nominalFloortoCeilingHeight) {
315
1/1
✓ Branch 3 taken 177 times.
177 return getImpl<detail::BuildingStory_Impl>()->setNominalFloortoCeilingHeight(nominalFloortoCeilingHeight);
316 }
317
318 ✗ void BuildingStory::resetNominalFloortoCeilingHeight() {
319 ✗ getImpl<detail::BuildingStory_Impl>()->resetNominalFloortoCeilingHeight();
320 ✗ }
321
322 38567 boost::optional<DefaultConstructionSet> BuildingStory::defaultConstructionSet() const {
323
1/1
✓ Branch 3 taken 38567 times.
38567 return getImpl<detail::BuildingStory_Impl>()->defaultConstructionSet();
324 }
325
326 24 bool BuildingStory::setDefaultConstructionSet(const DefaultConstructionSet& defaultConstructionSet) {
327
1/1
✓ Branch 3 taken 24 times.
24 return getImpl<detail::BuildingStory_Impl>()->setDefaultConstructionSet(defaultConstructionSet);
328 }
329
330 5 void BuildingStory::resetDefaultConstructionSet() {
331
1/1
✓ Branch 3 taken 5 times.
5 getImpl<detail::BuildingStory_Impl>()->resetDefaultConstructionSet();
332 5 }
333
334 47 boost::optional<DefaultScheduleSet> BuildingStory::defaultScheduleSet() const {
335
1/1
✓ Branch 3 taken 47 times.
47 return getImpl<detail::BuildingStory_Impl>()->defaultScheduleSet();
336 }
337
338 6 boost::optional<Schedule> BuildingStory::getDefaultSchedule(const DefaultScheduleType& defaultScheduleType) const {
339
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::BuildingStory_Impl>()->getDefaultSchedule(defaultScheduleType);
340 }
341
342 1 bool BuildingStory::setDefaultScheduleSet(const DefaultScheduleSet& defaultScheduleSet) {
343
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::BuildingStory_Impl>()->setDefaultScheduleSet(defaultScheduleSet);
344 }
345
346 ✗ void BuildingStory::resetDefaultScheduleSet() {
347 ✗ getImpl<detail::BuildingStory_Impl>()->resetDefaultScheduleSet();
348 ✗ }
349
350 637 boost::optional<RenderingColor> BuildingStory::renderingColor() const {
351
1/1
✓ Branch 3 taken 637 times.
637 return getImpl<detail::BuildingStory_Impl>()->renderingColor();
352 }
353
354 132 bool BuildingStory::setRenderingColor(const RenderingColor& renderingColor) {
355
1/1
✓ Branch 3 taken 132 times.
132 return getImpl<detail::BuildingStory_Impl>()->setRenderingColor(renderingColor);
356 }
357
358 ✗ void BuildingStory::resetRenderingColor() {
359 ✗ getImpl<detail::BuildingStory_Impl>()->resetRenderingColor();
360 ✗ }
361
362 390 std::vector<Space> BuildingStory::spaces() const {
363
1/1
✓ Branch 3 taken 390 times.
390 return getImpl<detail::BuildingStory_Impl>()->spaces();
364 }
365
366 /// @cond
367
1/1
✓ Branch 3 taken 63287 times.
63287 BuildingStory::BuildingStory(std::shared_ptr<detail::BuildingStory_Impl> impl) : ModelObject(std::move(impl)) {}
368 /// @endcond
369
370 } // namespace model
371 } // namespace openstudio
372