GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 69.0% 29 / 0 / 42
Functions: 100.0% 1 / 0 / 1
Branches: 54.3% 38 / 0 / 70

src/energyplus/ReverseTranslator/ReverseTranslateShadingZoneDetailed.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 "../ReverseTranslator.hpp"
7 #include "../GeometryTranslator.hpp"
8
9 #include "../../model/ShadingSurface.hpp"
10 #include "../../model/ShadingSurface_Impl.hpp"
11 #include "../../model/ShadingSurfaceGroup.hpp"
12 #include "../../model/ShadingSurfaceGroup_Impl.hpp"
13 #include "../../model/Surface.hpp"
14 #include "../../model/Surface_Impl.hpp"
15 #include "../../model/Space.hpp"
16 #include "../../model/Space_Impl.hpp"
17 #include "../../model/Schedule.hpp"
18 #include "../../model/Schedule_Impl.hpp"
19
20 #include <utilities/idd/Shading_Zone_Detailed_FieldEnums.hxx>
21 #include "../../utilities/idd/IddEnums.hpp"
22 #include <utilities/idd/IddEnums.hxx>
23
24 using namespace openstudio::model;
25
26 namespace openstudio {
27
28 namespace energyplus {
29
30 9 OptionalModelObject ReverseTranslator::translateShadingZoneDetailed(const WorkspaceObject& workspaceObject) {
31
4/5
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 9 times.
9 if (workspaceObject.iddObject().type() != IddObjectType::Shading_Zone_Detailed) {
32 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: Shading:Zone:Detailed");
33 ✗ return boost::none;
34 }
35
36
1/1
✓ Branch 1 taken 9 times.
9 openstudio::Point3dVector vertices = getVertices(Shading_Zone_DetailedFields::NumberofVertices + 1, workspaceObject);
37
38 9 boost::optional<ShadingSurface> shadingSurface;
39 try {
40
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 shadingSurface = ShadingSurface(vertices, m_model);
41 ✗ } catch (const std::exception&) {
42 ✗ LOG(Error, "Cannot create ShadingSurface for object: " << workspaceObject);
43 ✗ return boost::none;
44 ✗ }
45
46
1/1
✓ Branch 1 taken 9 times.
9 OptionalString s = workspaceObject.name();
47
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if (s) {
48
3/3
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
9 shadingSurface->setName(*s);
49 }
50
51
1/1
✓ Branch 1 taken 9 times.
9 OptionalWorkspaceObject target = workspaceObject.getTarget(openstudio::Shading_Zone_DetailedFields::BaseSurfaceName);
52
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if (target) {
53
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
54
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if (modelObject) {
55
3/4
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
18 if (modelObject->optionalCast<Surface>()) {
56
3/3
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
9 OptionalSpace space = modelObject->cast<Surface>().space();
57
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if (space) {
58
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 ShadingSurfaceGroupVector groups = space->shadingSurfaceGroups();
59
2/2
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 5 times.
9 if (groups.empty()) {
60
1/1
✓ Branch 1 taken 4 times.
4 ShadingSurfaceGroup shadingSurfaceGroup(m_model);
61
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 shadingSurfaceGroup.setSpace(*space);
62
1/1
✓ Branch 1 taken 4 times.
4 groups.push_back(shadingSurfaceGroup);
63 4 }
64
2/2
✓ Branch 1 taken 9 times.
✓ Branch 5 taken 9 times.
9 shadingSurface->setShadingSurfaceGroup(groups[0]);
65 9 }
66 9 }
67 }
68 9 }
69
70
1/1
✓ Branch 1 taken 9 times.
9 target = workspaceObject.getTarget(openstudio::Shading_Zone_DetailedFields::TransmittanceScheduleName);
71
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (target) {
72 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
73 ✗ if (modelObject) {
74 ✗ if (OptionalSchedule intermediate = modelObject->optionalCast<Schedule>()) {
75 ✗ Schedule schedule(*intermediate);
76 ✗ shadingSurface->setTransmittanceSchedule(schedule);
77 ✗ }
78 }
79 ✗ }
80
81
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 return shadingSurface.get();
82 9 }
83
84 } // namespace energyplus
85
86 } // namespace openstudio
87