GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 55.3% 105 / 0 / 190
Functions: 58.0% 29 / 0 / 50
Branches: 41.2% 66 / 0 / 160

src/model/InteriorPartitionSurfaceGroup.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 "InteriorPartitionSurfaceGroup.hpp"
7 #include "InteriorPartitionSurfaceGroup_Impl.hpp"
8
9 #include "Model.hpp"
10 #include "Model_Impl.hpp"
11 #include "Space.hpp"
12 #include "Space_Impl.hpp"
13 #include "InteriorPartitionSurface.hpp"
14 #include "InteriorPartitionSurface_Impl.hpp"
15
16 #include <utilities/idd/OS_InteriorPartitionSurfaceGroup_FieldEnums.hxx>
17 #include <utilities/idd/IddEnums.hxx>
18
19 #include "../utilities/geometry/Transformation.hpp"
20 #include "../utilities/geometry/Vector3d.hpp"
21 #include "../utilities/geometry/Point3d.hpp"
22 #include "../utilities/geometry/Geometry.hpp"
23 #include "../utilities/geometry/EulerAngles.hpp"
24 #include "../utilities/geometry/BoundingBox.hpp"
25
26 #include "../utilities/core/Assert.hpp"
27
28 namespace openstudio {
29 namespace model {
30
31 namespace detail {
32
33 211 InteriorPartitionSurfaceGroup_Impl::InteriorPartitionSurfaceGroup_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
34 211 : PlanarSurfaceGroup_Impl(idfObject, model, keepHandle) {
35
4/6
✓ Branch 1 taken 211 times.
✓ Branch 4 taken 211 times.
✓ Branch 7 taken 211 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 211 times.
✗ Branch 13 not taken.
211 OS_ASSERT(idfObject.iddObject().type() == InteriorPartitionSurfaceGroup::iddObjectType());
36 211 }
37
38 25 InteriorPartitionSurfaceGroup_Impl::InteriorPartitionSurfaceGroup_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model,
39 25 bool keepHandle)
40 25 : PlanarSurfaceGroup_Impl(other, model, keepHandle) {
41
4/6
✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 25 times.
✗ Branch 13 not taken.
25 OS_ASSERT(other.iddObject().type() == InteriorPartitionSurfaceGroup::iddObjectType());
42 25 }
43
44 72 InteriorPartitionSurfaceGroup_Impl::InteriorPartitionSurfaceGroup_Impl(const InteriorPartitionSurfaceGroup_Impl& other, Model_Impl* model,
45 72 bool keepHandle)
46 72 : PlanarSurfaceGroup_Impl(other, model, keepHandle) {}
47
48 14 boost::optional<ParentObject> InteriorPartitionSurfaceGroup_Impl::parent() const {
49
2/2
✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
14 return boost::optional<ParentObject>(this->space());
50 }
51
52 7 bool InteriorPartitionSurfaceGroup_Impl::setParent(ParentObject& newParent) {
53 7 bool result = false;
54
2/3
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 if (newParent.optionalCast<Space>()) {
55
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 result = this->setSpace(newParent.cast<Space>());
56 }
57 7 return result;
58 }
59
60 154 std::vector<ModelObject> InteriorPartitionSurfaceGroup_Impl::children() const {
61 154 std::vector<ModelObject> result;
62
63
1/1
✓ Branch 1 taken 154 times.
154 std::vector<InteriorPartitionSurface> interiorPartitionSurfaces = this->interiorPartitionSurfaces();
64
1/1
✓ Branch 5 taken 154 times.
154 result.insert(result.end(), interiorPartitionSurfaces.begin(), interiorPartitionSurfaces.end());
65
66 308 return result;
67 154 }
68
69 ✗ std::vector<IddObjectType> InteriorPartitionSurfaceGroup_Impl::allowableChildTypes() const {
70 ✗ std::vector<IddObjectType> result;
71 ✗ result.push_back(IddObjectType::OS_InteriorPartitionSurface);
72 ✗ return result;
73 ✗ }
74
75 1 const std::vector<std::string>& InteriorPartitionSurfaceGroup_Impl::outputVariableNames() const {
76
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;
77 1 return result;
78 }
79
80 1 IddObjectType InteriorPartitionSurfaceGroup_Impl::iddObjectType() const {
81 1 return InteriorPartitionSurfaceGroup::iddObjectType();
82 }
83
84 8 Transformation InteriorPartitionSurfaceGroup_Impl::buildingTransformation() const {
85 8 Transformation transformation;
86
2/3
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
16 if (this->space()) {
87
5/5
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
✓ Branch 13 taken 8 times.
8 transformation = this->space()->transformation() * this->transformation();
88 } else {
89 ✗ transformation = this->transformation();
90 }
91 8 return transformation;
92 ✗ }
93
94 ✗ bool InteriorPartitionSurfaceGroup_Impl::changeTransformation(const openstudio::Transformation& transformation) {
95 ✗ Transformation oldTransformation = this->transformation();
96 ✗ if (!setTransformation(transformation)) {
97 ✗ return false;
98 }
99
100 // go through and update all child points and transformations so that:
101 // (Tnew^-1 * Told) * xold = childTransformation * xold = xnew
102
103 ✗ Transformation childTransformation = transformation.inverse() * oldTransformation;
104
105 ✗ for (auto& interiorPartitionSurface : this->interiorPartitionSurfaces()) {
106 ✗ bool test = interiorPartitionSurface.setVertices(childTransformation * interiorPartitionSurface.vertices());
107 ✗ if (!test) {
108 ✗ LOG(Error, "Could not transform vertices for InteriorPartitionSurface '" << interiorPartitionSurface.name().get() << "'.");
109 }
110 ✗ }
111
112 ✗ return true;
113 ✗ }
114
115 184 BoundingBox InteriorPartitionSurfaceGroup_Impl::boundingBox() const {
116 184 BoundingBox result;
117
3/3
✓ Branch 1 taken 184 times.
✓ Branch 7 taken 184 times.
✓ Branch 8 taken 184 times.
368 for (const auto& interiorPartitionSurface : this->interiorPartitionSurfaces()) {
118
2/2
✓ Branch 1 taken 184 times.
✓ Branch 4 taken 184 times.
184 result.addPoints(interiorPartitionSurface.vertices());
119 184 }
120 184 return result;
121 }
122
123 207 double InteriorPartitionSurfaceGroup_Impl::directionofRelativeNorth() const {
124
1/1
✓ Branch 1 taken 207 times.
207 boost::optional<double> value = getDouble(OS_InteriorPartitionSurfaceGroupFields::DirectionofRelativeNorth, true);
125
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 207 times.
✗ Branch 4 not taken.
207 OS_ASSERT(value);
126
1/1
✓ Branch 1 taken 207 times.
414 return value.get();
127 }
128
129 ✗ bool InteriorPartitionSurfaceGroup_Impl::isDirectionofRelativeNorthDefaulted() const {
130 ✗ return isEmpty(OS_InteriorPartitionSurfaceGroupFields::DirectionofRelativeNorth);
131 }
132
133 207 double InteriorPartitionSurfaceGroup_Impl::xOrigin() const {
134
1/1
✓ Branch 1 taken 207 times.
207 boost::optional<double> value = getDouble(OS_InteriorPartitionSurfaceGroupFields::XOrigin, true);
135
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 207 times.
✗ Branch 4 not taken.
207 OS_ASSERT(value);
136
1/1
✓ Branch 1 taken 207 times.
414 return value.get();
137 }
138
139 ✗ bool InteriorPartitionSurfaceGroup_Impl::isXOriginDefaulted() const {
140 ✗ return isEmpty(OS_InteriorPartitionSurfaceGroupFields::XOrigin);
141 }
142
143 207 double InteriorPartitionSurfaceGroup_Impl::yOrigin() const {
144
1/1
✓ Branch 1 taken 207 times.
207 boost::optional<double> value = getDouble(OS_InteriorPartitionSurfaceGroupFields::YOrigin, true);
145
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 207 times.
✗ Branch 4 not taken.
207 OS_ASSERT(value);
146
1/1
✓ Branch 1 taken 207 times.
414 return value.get();
147 }
148
149 ✗ bool InteriorPartitionSurfaceGroup_Impl::isYOriginDefaulted() const {
150 ✗ return (!getString(OS_InteriorPartitionSurfaceGroupFields::YOrigin, false));
151 }
152
153 207 double InteriorPartitionSurfaceGroup_Impl::zOrigin() const {
154
1/1
✓ Branch 1 taken 207 times.
207 boost::optional<double> value = getDouble(OS_InteriorPartitionSurfaceGroupFields::ZOrigin, true);
155
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 207 times.
✗ Branch 4 not taken.
207 OS_ASSERT(value);
156
1/1
✓ Branch 1 taken 207 times.
414 return value.get();
157 }
158
159 ✗ bool InteriorPartitionSurfaceGroup_Impl::isZOriginDefaulted() const {
160 ✗ return isEmpty(OS_InteriorPartitionSurfaceGroupFields::ZOrigin);
161 }
162
163 35 int InteriorPartitionSurfaceGroup_Impl::multiplier() const {
164
1/1
✓ Branch 1 taken 35 times.
35 boost::optional<int> value = getInt(OS_InteriorPartitionSurfaceGroupFields::Multiplier, true);
165
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 4 not taken.
35 OS_ASSERT(value);
166
1/1
✓ Branch 1 taken 35 times.
70 return value.get();
167 }
168
169 ✗ bool InteriorPartitionSurfaceGroup_Impl::isMultiplierDefaulted() const {
170 ✗ return isEmpty(OS_InteriorPartitionSurfaceGroupFields::Multiplier);
171 }
172
173 35 bool InteriorPartitionSurfaceGroup_Impl::setDirectionofRelativeNorth(double directionofRelativeNorth, bool driverMethod) {
174 35 bool result = setDouble(OS_InteriorPartitionSurfaceGroupFields::DirectionofRelativeNorth, directionofRelativeNorth, driverMethod);
175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 OS_ASSERT(result);
176 35 return result;
177 }
178
179 ✗ void InteriorPartitionSurfaceGroup_Impl::resetDirectionofRelativeNorth() {
180 ✗ bool result = setString(OS_InteriorPartitionSurfaceGroupFields::DirectionofRelativeNorth, "");
181 ✗ OS_ASSERT(result);
182 ✗ }
183
184 35 bool InteriorPartitionSurfaceGroup_Impl::setXOrigin(double xOrigin, bool driverMethod) {
185 35 bool result = setDouble(OS_InteriorPartitionSurfaceGroupFields::XOrigin, xOrigin, driverMethod);
186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 OS_ASSERT(result);
187 35 return result;
188 }
189
190 ✗ void InteriorPartitionSurfaceGroup_Impl::resetXOrigin() {
191 ✗ bool result = setString(OS_InteriorPartitionSurfaceGroupFields::XOrigin, "");
192 ✗ OS_ASSERT(result);
193 ✗ }
194
195 35 bool InteriorPartitionSurfaceGroup_Impl::setYOrigin(double yOrigin, bool driverMethod) {
196 35 bool result = setDouble(OS_InteriorPartitionSurfaceGroupFields::YOrigin, yOrigin, driverMethod);
197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 OS_ASSERT(result);
198 35 return result;
199 }
200
201 ✗ void InteriorPartitionSurfaceGroup_Impl::resetYOrigin() {
202 ✗ bool result = setString(OS_InteriorPartitionSurfaceGroupFields::YOrigin, "");
203 ✗ OS_ASSERT(result);
204 ✗ }
205
206 35 bool InteriorPartitionSurfaceGroup_Impl::setZOrigin(double zOrigin, bool driverMethod) {
207 35 bool result = setDouble(OS_InteriorPartitionSurfaceGroupFields::ZOrigin, zOrigin, driverMethod);
208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 OS_ASSERT(result);
209 35 return result;
210 }
211
212 ✗ void InteriorPartitionSurfaceGroup_Impl::resetZOrigin() {
213 ✗ bool result = setString(OS_InteriorPartitionSurfaceGroupFields::ZOrigin, "");
214 ✗ OS_ASSERT(result);
215 ✗ }
216
217 ✗ bool InteriorPartitionSurfaceGroup_Impl::setMultiplier(int multiplier) {
218 ✗ bool result = setInt(OS_InteriorPartitionSurfaceGroupFields::Multiplier, multiplier);
219 ✗ return result;
220 }
221
222 ✗ void InteriorPartitionSurfaceGroup_Impl::resetMultiplier() {
223 ✗ bool result = setString(OS_InteriorPartitionSurfaceGroupFields::Multiplier, "");
224 ✗ OS_ASSERT(result);
225 ✗ }
226
227 424 boost::optional<Space> InteriorPartitionSurfaceGroup_Impl::space() const {
228 424 boost::optional<Space> result;
229
1/1
✓ Branch 1 taken 424 times.
424 OptionalWorkspaceObject space = getTarget(OS_InteriorPartitionSurfaceGroupFields::SpaceName);
230
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 1 time.
424 if (space) {
231
2/2
✓ Branch 1 taken 423 times.
✓ Branch 4 taken 423 times.
423 result = space->optionalCast<Space>();
232 }
233 848 return result;
234 424 }
235
236 192 bool InteriorPartitionSurfaceGroup_Impl::setSpace(const Space& space) {
237
2/2
✓ Branch 1 taken 192 times.
✓ Branch 4 taken 192 times.
192 return setPointer(OS_InteriorPartitionSurfaceGroupFields::SpaceName, space.handle());
238 }
239
240 ✗ void InteriorPartitionSurfaceGroup_Impl::resetSpace() {
241 ✗ bool ok = setString(OS_InteriorPartitionSurfaceGroupFields::SpaceName, "");
242 ✗ OS_ASSERT(ok);
243 ✗ }
244
245 483 InteriorPartitionSurfaceVector InteriorPartitionSurfaceGroup_Impl::interiorPartitionSurfaces() const {
246
3/3
✓ Branch 1 taken 483 times.
✓ Branch 4 taken 483 times.
✓ Branch 7 taken 483 times.
483 return getObject<ModelObject>().getModelObjectSources<InteriorPartitionSurface>(InteriorPartitionSurface::iddObjectType());
247 }
248
249 ✗ boost::optional<ModelObject> InteriorPartitionSurfaceGroup_Impl::spaceAsModelObject() const {
250 ✗ OptionalModelObject result;
251 ✗ OptionalSpace intermediate = space();
252 ✗ if (intermediate) {
253 ✗ result = *intermediate;
254 }
255 ✗ return result;
256 ✗ }
257
258 ✗ std::vector<ModelObject> InteriorPartitionSurfaceGroup_Impl::interiorPartitionSurfacesAsModelObjects() const {
259 ✗ ModelObjectVector result = castVector<ModelObject>(interiorPartitionSurfaces());
260 ✗ return result;
261 }
262
263 ✗ bool InteriorPartitionSurfaceGroup_Impl::setSpaceAsModelObject(const boost::optional<ModelObject>& modelObject) {
264 ✗ if (modelObject) {
265 ✗ OptionalSpace intermediate = modelObject->optionalCast<Space>();
266 ✗ if (intermediate) {
267 ✗ return setSpace(*intermediate);
268 } else {
269 ✗ return false;
270 }
271 ✗ } else {
272 ✗ resetSpace();
273 }
274 ✗ return true;
275 }
276
277 } // namespace detail
278
279 185 InteriorPartitionSurfaceGroup::InteriorPartitionSurfaceGroup(const Model& model)
280 185 : PlanarSurfaceGroup(InteriorPartitionSurfaceGroup::iddObjectType(), model) {
281
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 185 times.
✗ Branch 5 not taken.
185 OS_ASSERT(getImpl<detail::InteriorPartitionSurfaceGroup_Impl>());
282 185 }
283
284 50189 IddObjectType InteriorPartitionSurfaceGroup::iddObjectType() {
285
1/1
✓ Branch 1 taken 50189 times.
50189 IddObjectType result(IddObjectType::OS_InteriorPartitionSurfaceGroup);
286 50189 return result;
287 }
288
289 35 int InteriorPartitionSurfaceGroup::multiplier() const {
290
1/1
✓ Branch 3 taken 35 times.
35 return getImpl<detail::InteriorPartitionSurfaceGroup_Impl>()->multiplier();
291 }
292
293 ✗ bool InteriorPartitionSurfaceGroup::isMultiplierDefaulted() const {
294 ✗ return getImpl<detail::InteriorPartitionSurfaceGroup_Impl>()->isMultiplierDefaulted();
295 }
296
297 ✗ bool InteriorPartitionSurfaceGroup::setMultiplier(int multiplier) {
298 ✗ return getImpl<detail::InteriorPartitionSurfaceGroup_Impl>()->setMultiplier(multiplier);
299 }
300
301 ✗ void InteriorPartitionSurfaceGroup::resetMultiplier() {
302 ✗ getImpl<detail::InteriorPartitionSurfaceGroup_Impl>()->resetMultiplier();
303 ✗ }
304
305 394 boost::optional<Space> InteriorPartitionSurfaceGroup::space() const {
306
1/1
✓ Branch 3 taken 394 times.
394 return getImpl<detail::InteriorPartitionSurfaceGroup_Impl>()->space();
307 }
308
309 185 bool InteriorPartitionSurfaceGroup::setSpace(const Space& space) {
310
1/1
✓ Branch 3 taken 185 times.
185 return getImpl<detail::InteriorPartitionSurfaceGroup_Impl>()->setSpace(space);
311 }
312
313 ✗ void InteriorPartitionSurfaceGroup::resetSpace() {
314 ✗ getImpl<detail::InteriorPartitionSurfaceGroup_Impl>()->resetSpace();
315 ✗ }
316
317 145 InteriorPartitionSurfaceVector InteriorPartitionSurfaceGroup::interiorPartitionSurfaces() const {
318
1/1
✓ Branch 3 taken 145 times.
145 return getImpl<detail::InteriorPartitionSurfaceGroup_Impl>()->interiorPartitionSurfaces();
319 }
320
321 /// @cond
322 939 InteriorPartitionSurfaceGroup::InteriorPartitionSurfaceGroup(std::shared_ptr<detail::InteriorPartitionSurfaceGroup_Impl> impl)
323
1/1
✓ Branch 3 taken 939 times.
939 : PlanarSurfaceGroup(std::move(impl)) {}
324 /// @endcond
325
326 } // namespace model
327 } // namespace openstudio
328