src/energyplus/GeometryTranslator.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 "GeometryTranslator.hpp" | ||
| 7 | #include "MapFields.hpp" | ||
| 8 | |||
| 9 | #include "../model/Building.hpp" | ||
| 10 | #include "../model/Space.hpp" | ||
| 11 | #include "../model/Surface.hpp" | ||
| 12 | #include "../model/SubSurface.hpp" | ||
| 13 | #include "../model/ShadingSurface.hpp" | ||
| 14 | |||
| 15 | #include "../utilities/geometry/Geometry.hpp" | ||
| 16 | #include "../utilities/geometry/Point3d.hpp" | ||
| 17 | #include "../utilities/geometry/Vector3d.hpp" | ||
| 18 | |||
| 19 | #include "../utilities/core/Assert.hpp" | ||
| 20 | #include "../utilities/core/Optional.hpp" | ||
| 21 | #include "../utilities/core/Containers.hpp" | ||
| 22 | |||
| 23 | #include "../utilities/idd/IddEnums.hpp" | ||
| 24 | #include <utilities/idd/IddEnums.hxx> | ||
| 25 | #include <utilities/idd/GlobalGeometryRules_FieldEnums.hxx> | ||
| 26 | #include <utilities/idd/Building_FieldEnums.hxx> | ||
| 27 | #include <utilities/idd/Zone_FieldEnums.hxx> | ||
| 28 | #include <utilities/idd/BuildingSurface_Detailed_FieldEnums.hxx> | ||
| 29 | #include <utilities/idd/FenestrationSurface_Detailed_FieldEnums.hxx> | ||
| 30 | #include <utilities/idd/Daylighting_Controls_FieldEnums.hxx> | ||
| 31 | #include <utilities/idd/Daylighting_ReferencePoint_FieldEnums.hxx> | ||
| 32 | #include <utilities/idd/Output_IlluminanceMap_FieldEnums.hxx> | ||
| 33 | #include <utilities/idd/Wall_Detailed_FieldEnums.hxx> | ||
| 34 | #include <utilities/idd/RoofCeiling_Detailed_FieldEnums.hxx> | ||
| 35 | #include <utilities/idd/Floor_Detailed_FieldEnums.hxx> | ||
| 36 | #include <utilities/idd/Wall_Exterior_FieldEnums.hxx> | ||
| 37 | #include <utilities/idd/Wall_Adiabatic_FieldEnums.hxx> | ||
| 38 | #include <utilities/idd/Wall_Underground_FieldEnums.hxx> | ||
| 39 | #include <utilities/idd/Wall_Interzone_FieldEnums.hxx> | ||
| 40 | #include <utilities/idd/Roof_FieldEnums.hxx> | ||
| 41 | #include <utilities/idd/Ceiling_Adiabatic_FieldEnums.hxx> | ||
| 42 | #include <utilities/idd/Ceiling_Interzone_FieldEnums.hxx> | ||
| 43 | #include <utilities/idd/Floor_GroundContact_FieldEnums.hxx> | ||
| 44 | #include <utilities/idd/Floor_Adiabatic_FieldEnums.hxx> | ||
| 45 | #include <utilities/idd/Floor_Interzone_FieldEnums.hxx> | ||
| 46 | #include <utilities/idd/Window_FieldEnums.hxx> | ||
| 47 | #include <utilities/idd/Door_FieldEnums.hxx> | ||
| 48 | #include <utilities/idd/GlazedDoor_FieldEnums.hxx> | ||
| 49 | #include <utilities/idd/Window_Interzone_FieldEnums.hxx> | ||
| 50 | #include <utilities/idd/Door_Interzone_FieldEnums.hxx> | ||
| 51 | #include <utilities/idd/GlazedDoor_Interzone_FieldEnums.hxx> | ||
| 52 | #include <utilities/idd/Shading_Site_FieldEnums.hxx> | ||
| 53 | #include <utilities/idd/Shading_Building_FieldEnums.hxx> | ||
| 54 | #include <utilities/idd/Shading_Overhang_FieldEnums.hxx> | ||
| 55 | #include <utilities/idd/Shading_Overhang_Projection_FieldEnums.hxx> | ||
| 56 | #include <utilities/idd/Shading_Fin_FieldEnums.hxx> | ||
| 57 | #include <utilities/idd/Shading_Fin_Projection_FieldEnums.hxx> | ||
| 58 | #include <utilities/idd/Shading_Site_Detailed_FieldEnums.hxx> | ||
| 59 | #include <utilities/idd/Shading_Building_Detailed_FieldEnums.hxx> | ||
| 60 | #include <utilities/idd/Shading_Zone_Detailed_FieldEnums.hxx> | ||
| 61 | |||
| 62 | #include "../utilities/idf/WorkspaceObject.hpp" | ||
| 63 | #include "../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 64 | |||
| 65 | #include <algorithm> | ||
| 66 | |||
| 67 | using openstudio::IddObjectType; | ||
| 68 | using openstudio::GlobalGeometryRulesFields; | ||
| 69 | using openstudio::OptionalString; | ||
| 70 | using openstudio::OptionalDouble; | ||
| 71 | using openstudio::WorkspaceObject; | ||
| 72 | using openstudio::degToRad; | ||
| 73 | |||
| 74 | namespace openstudio { | ||
| 75 | namespace energyplus { | ||
| 76 | |||
| 77 | /// test equality of coordinate systems | ||
| 78 | 927 | bool equal(const CoordinateSystem& left, const CoordinateSystem& right) { | |
| 79 | 927 | bool result = false; | |
| 80 |
2/3✓ Branch 1 taken 14 times.
✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
|
927 | switch (left.value()) { |
| 81 | 14 | case CoordinateSystem::Absolute: | |
| 82 |
1/1✓ Branch 1 taken 14 times.
|
14 | result = (right == CoordinateSystem::Absolute); |
| 83 | 14 | break; | |
| 84 | 913 | case CoordinateSystem::Relative: | |
| 85 |
1/1✓ Branch 1 taken 913 times.
|
913 | result = (right == CoordinateSystem::Relative); |
| 86 | 913 | break; | |
| 87 | } | ||
| 88 | 927 | return result; | |
| 89 | } | ||
| 90 | |||
| 91 | /// constructor with an EnergyPlus Workspace | ||
| 92 | 253 | GeometryTranslator::GeometryTranslator(const openstudio::Workspace& workspace) : m_workspace(workspace) {} | |
| 93 | |||
| 94 | /// convert workspace to given coordinate systems | ||
| 95 | /// all geometry will be converted to upper-left-corner, counterclockwise | ||
| 96 | /// all simple geometry will be converted to detailed geometry | ||
| 97 | 253 | bool GeometryTranslator::convert(const CoordinateSystem& detailedSystem, const CoordinateSystem& daylightingSystem) { | |
| 98 | 253 | bool result = true; | |
| 99 | |||
| 100 | IddObjectTypeVector translatedTypes = {IddObjectType::Building, | ||
| 101 | IddObjectType::Zone, | ||
| 102 | IddObjectType::BuildingSurface_Detailed, | ||
| 103 | IddObjectType::Wall_Detailed, | ||
| 104 | IddObjectType::Wall_Exterior, | ||
| 105 | IddObjectType::Wall_Adiabatic, | ||
| 106 | IddObjectType::Wall_Underground, | ||
| 107 | IddObjectType::Wall_Interzone, | ||
| 108 | IddObjectType::RoofCeiling_Detailed, | ||
| 109 | IddObjectType::Roof, | ||
| 110 | IddObjectType::Ceiling_Adiabatic, | ||
| 111 | IddObjectType::Ceiling_Interzone, | ||
| 112 | IddObjectType::Floor_Detailed, | ||
| 113 | IddObjectType::Floor_GroundContact, | ||
| 114 | IddObjectType::Floor_Adiabatic, | ||
| 115 | IddObjectType::Floor_Interzone, | ||
| 116 | IddObjectType::Shading_Site, | ||
| 117 | IddObjectType::Shading_Site_Detailed, | ||
| 118 | IddObjectType::Shading_Building, | ||
| 119 | IddObjectType::Shading_Building_Detailed, | ||
| 120 | IddObjectType::Shading_Zone_Detailed, | ||
| 121 | IddObjectType::Shading_Overhang, | ||
| 122 | IddObjectType::Shading_Overhang_Projection, | ||
| 123 | IddObjectType::Shading_Fin, | ||
| 124 | IddObjectType::Shading_Fin_Projection, | ||
| 125 | IddObjectType::FenestrationSurface_Detailed, | ||
| 126 | IddObjectType::Window, | ||
| 127 | IddObjectType::Window_Interzone, | ||
| 128 | IddObjectType::Door, | ||
| 129 | IddObjectType::GlazedDoor, | ||
| 130 | IddObjectType::Door_Interzone, | ||
| 131 | IddObjectType::GlazedDoor_Interzone, | ||
| 132 | IddObjectType::Daylighting_Controls, | ||
| 133 | IddObjectType::Daylighting_ReferencePoint, | ||
| 134 |
1/1✓ Branch 1 taken 253 times.
|
506 | IddObjectType::Output_IlluminanceMap}; |
| 135 | |||
| 136 |
1/1✓ Branch 3 taken 253 times.
|
253 | bool skipConvert = !std::any_of(translatedTypes.cbegin(), translatedTypes.cend(), |
| 137 |
1/1✓ Branch 1 taken 5410 times.
|
5410 | [this](const auto& iddObjectType) { return !m_workspace.getObjectsByType(iddObjectType).empty(); }); |
| 138 | |||
| 139 |
2/2✓ Branch 0 taken 150 times.
✓ Branch 1 taken 103 times.
|
253 | if (skipConvert) { |
| 140 | 150 | return true; | |
| 141 | } | ||
| 142 | |||
| 143 | // current geometry rules | ||
| 144 |
1/1✓ Branch 1 taken 103 times.
|
103 | GlobalGeometryRules currentRules = globalGeometryRules(); |
| 145 | |||
| 146 | // convert to counter clockwise vertex entry direction | ||
| 147 |
2/3✓ Branch 1 taken 103 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 103 times.
|
103 | if (currentRules.ved == VertexEntryDirection::Clockwise) { |
| 148 | ✗ | result = result && reverseAllDetailedVertices(); | |
| 149 | } | ||
| 150 | |||
| 151 | // change from current detailed system to new detailed system | ||
| 152 |
1/1✓ Branch 1 taken 103 times.
|
103 | CoordinateChange detailedCoordChange = CoordinateChange::NoChange; |
| 153 |
8/10✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 6 taken 100 times.
✓ Branch 7 taken 3 times.
✓ Branch 9 taken 100 times.
✓ Branch 12 taken 100 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 100 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 103 times.
|
103 | if (equal(currentRules.detailedSystem, CoordinateSystem::Relative) && equal(detailedSystem, CoordinateSystem::Absolute)) { |
| 154 | ✗ | detailedCoordChange = CoordinateChange::RelativeToAbsolute; | |
| 155 |
9/10✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 100 times.
✓ Branch 9 taken 3 times.
✓ Branch 12 taken 3 times.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 3 times.
✓ Branch 17 taken 100 times.
|
103 | } else if (equal(currentRules.detailedSystem, CoordinateSystem::Absolute) && equal(detailedSystem, CoordinateSystem::Relative)) { |
| 156 |
1/1✓ Branch 1 taken 3 times.
|
3 | detailedCoordChange = CoordinateChange::AbsoluteToRelative; |
| 157 | } | ||
| 158 | |||
| 159 | // change from current daylighting system to new daylighting system | ||
| 160 |
1/1✓ Branch 1 taken 103 times.
|
103 | CoordinateChange daylightingCoordChange = CoordinateChange::NoChange; |
| 161 |
8/10✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 6 taken 101 times.
✓ Branch 7 taken 2 times.
✓ Branch 9 taken 101 times.
✓ Branch 12 taken 101 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 101 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 103 times.
|
103 | if (equal(currentRules.daylightingSystem, CoordinateSystem::Relative) && equal(daylightingSystem, CoordinateSystem::Absolute)) { |
| 162 | ✗ | daylightingCoordChange = CoordinateChange::RelativeToAbsolute; | |
| 163 |
9/10✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 101 times.
✓ Branch 9 taken 2 times.
✓ Branch 12 taken 2 times.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✓ Branch 17 taken 101 times.
|
103 | } else if (equal(currentRules.daylightingSystem, CoordinateSystem::Absolute) && equal(daylightingSystem, CoordinateSystem::Relative)) { |
| 164 |
1/1✓ Branch 1 taken 2 times.
|
2 | daylightingCoordChange = CoordinateChange::AbsoluteToRelative; |
| 165 | } | ||
| 166 | |||
| 167 | // change from current simple system to current detailed system | ||
| 168 |
1/1✓ Branch 1 taken 103 times.
|
103 | CoordinateChange rectangularCoordChange = CoordinateChange::NoChange; |
| 169 |
8/10✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 6 taken 101 times.
✓ Branch 7 taken 2 times.
✓ Branch 9 taken 101 times.
✓ Branch 12 taken 101 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 101 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 103 times.
|
103 | if (equal(currentRules.rectangularSystem, CoordinateSystem::Relative) && equal(detailedSystem, CoordinateSystem::Absolute)) { |
| 170 | ✗ | rectangularCoordChange = CoordinateChange::RelativeToAbsolute; | |
| 171 |
9/10✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 101 times.
✓ Branch 9 taken 2 times.
✓ Branch 12 taken 2 times.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✓ Branch 17 taken 101 times.
|
103 | } else if (equal(currentRules.rectangularSystem, CoordinateSystem::Absolute) && equal(detailedSystem, CoordinateSystem::Relative)) { |
| 172 |
1/1✓ Branch 1 taken 2 times.
|
2 | rectangularCoordChange = CoordinateChange::AbsoluteToRelative; |
| 173 | } | ||
| 174 | |||
| 175 | // transform detailed geometry from the current system to the new system | ||
| 176 | // do first to avoid transforming new detailed surfaces from simple geom twice | ||
| 177 |
3/5✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 103 times.
✓ Branch 5 taken 103 times.
✗ Branch 6 not taken.
|
103 | result = result && convertDetailedGeometry(detailedCoordChange); |
| 178 | |||
| 179 | // transform daylighting geometry from the current system to the new system | ||
| 180 |
3/5✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 103 times.
✓ Branch 5 taken 103 times.
✗ Branch 6 not taken.
|
103 | result = result && convertDaylightingGeometry(daylightingCoordChange); |
| 181 | |||
| 182 | // convert simple surfaces to detailed in the current system | ||
| 183 |
3/5✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 103 times.
✓ Branch 5 taken 103 times.
✗ Branch 6 not taken.
|
103 | result = result && convertSimpleSurfaces(rectangularCoordChange); |
| 184 | |||
| 185 | // convert simple subsurfaces to detailed in the current system | ||
| 186 |
3/5✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 103 times.
✓ Branch 5 taken 103 times.
✗ Branch 6 not taken.
|
103 | result = result && convertSimpleSubSurfaces(); |
| 187 | |||
| 188 | // convert simple shading to detailed in the current system | ||
| 189 |
3/5✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 103 times.
✓ Branch 5 taken 103 times.
✗ Branch 6 not taken.
|
103 | result = result && convertSimpleShading(rectangularCoordChange); |
| 190 | |||
| 191 | // apply starting vertex position rule | ||
| 192 |
3/5✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 103 times.
✓ Branch 5 taken 103 times.
✗ Branch 6 not taken.
|
103 | result = result && applyUpperLeftCornerRule(); |
| 193 | |||
| 194 | // set GlobalGeometryRules to the new rules | ||
| 195 | 103 | result = result | |
| 196 |
5/7✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 103 times.
✓ Branch 6 taken 103 times.
✓ Branch 9 taken 103 times.
✓ Branch 11 taken 103 times.
✗ Branch 12 not taken.
|
103 | && setGlobalGeometryRules(StartingVertexPosition::UpperLeftCorner, VertexEntryDirection::Counterclockwise, detailedSystem, |
| 197 | daylightingSystem, detailedSystem); | ||
| 198 | |||
| 199 | 103 | return result; | |
| 200 | 253 | } | |
| 201 | |||
| 202 | // get the current GlobalGeometryRules | ||
| 203 | 103 | GeometryTranslator::GlobalGeometryRules GeometryTranslator::globalGeometryRules() const { | |
| 204 |
1/1✓ Branch 1 taken 103 times.
|
103 | GlobalGeometryRules result; |
| 205 | |||
| 206 | // Start with defaults, then try to specialize | ||
| 207 |
1/1✓ Branch 1 taken 103 times.
|
103 | result.svp = StartingVertexPosition::UpperLeftCorner; |
| 208 |
1/1✓ Branch 1 taken 103 times.
|
103 | result.ved = VertexEntryDirection::Counterclockwise; |
| 209 |
1/1✓ Branch 1 taken 103 times.
|
103 | result.detailedSystem = CoordinateSystem::Relative; |
| 210 |
1/1✓ Branch 1 taken 103 times.
|
103 | result.daylightingSystem = CoordinateSystem::Relative; |
| 211 |
1/1✓ Branch 1 taken 103 times.
|
103 | result.rectangularSystem = CoordinateSystem::Relative; |
| 212 | |||
| 213 | // get the GlobalGeometryRules | ||
| 214 |
2/2✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
|
103 | WorkspaceObjectVector objects = m_workspace.getObjectsByType(IddObjectType::GlobalGeometryRules); |
| 215 |
2/2✓ Branch 1 taken 30 times.
✓ Branch 2 taken 73 times.
|
103 | if (objects.size() != 1) { |
| 216 |
5/5✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
✓ Branch 7 taken 30 times.
✓ Branch 10 taken 30 times.
✓ Branch 13 taken 30 times.
|
30 | LOG(Warn, "Could not find GlobalGeometryRules object, assuming defaults"); |
| 217 | 30 | return result; | |
| 218 | } | ||
| 219 | // get current geometry rules | ||
| 220 |
1/1✓ Branch 2 taken 73 times.
|
73 | WorkspaceObject globalGeometryRules = objects[0]; |
| 221 | |||
| 222 | // I don't really like this try/catch, but the alternative is to explicitly check the IDD Enums (choices), which is a bit less future proof. | ||
| 223 | // I'm going to use a try-catch per field instead of for the all block so it's less subject to failures | ||
| 224 |
2/3✓ Branch 1 taken 73 times.
✓ Branch 3 taken 73 times.
✗ Branch 4 not taken.
|
146 | if (OptionalString strSvp = globalGeometryRules.getString(GlobalGeometryRulesFields::StartingVertexPosition, true)) { |
| 225 | try { | ||
| 226 |
2/2✓ Branch 1 taken 73 times.
✓ Branch 4 taken 73 times.
|
73 | result.svp = StartingVertexPosition(strSvp.get()); |
| 227 | ✗ | } catch (...) { | |
| 228 | ✗ | LOG(Error, "Could not read required property 'Starting Vertex Position' for GlobalGeometryRules"); | |
| 229 | ✗ | } | |
| 230 | } else { | ||
| 231 | ✗ | LOG(Error, "Missing required property 'Starting Vertex Position' for GlobalGeometryRules"); | |
| 232 | 73 | } | |
| 233 | |||
| 234 |
2/3✓ Branch 1 taken 73 times.
✓ Branch 3 taken 73 times.
✗ Branch 4 not taken.
|
146 | if (OptionalString strVed = globalGeometryRules.getString(GlobalGeometryRulesFields::VertexEntryDirection, true)) { |
| 235 | try { | ||
| 236 |
2/2✓ Branch 1 taken 73 times.
✓ Branch 4 taken 73 times.
|
73 | result.ved = VertexEntryDirection(*strVed); |
| 237 | ✗ | } catch (...) { | |
| 238 | ✗ | LOG(Error, "Could not read required property 'Vertex Entry Direction' for GlobalGeometryRules"); | |
| 239 | ✗ | } | |
| 240 | } else { | ||
| 241 | ✗ | LOG(Error, "Missing required property 'Vertex Entry Direction' for GlobalGeometryRules"); | |
| 242 | 73 | } | |
| 243 | |||
| 244 |
2/3✓ Branch 1 taken 73 times.
✓ Branch 3 taken 73 times.
✗ Branch 4 not taken.
|
146 | if (OptionalString strDetailedSystem = globalGeometryRules.getString(GlobalGeometryRulesFields::CoordinateSystem, true)) { |
| 245 |
18/28✓ Branch 1 taken 73 times.
✓ Branch 4 taken 73 times.
✓ Branch 7 taken 73 times.
✓ Branch 9 taken 71 times.
✓ Branch 10 taken 2 times.
✓ Branch 12 taken 71 times.
✓ Branch 15 taken 71 times.
✓ Branch 18 taken 71 times.
✓ Branch 20 taken 1 time.
✓ Branch 21 taken 70 times.
✓ Branch 22 taken 71 times.
✓ Branch 23 taken 2 times.
✓ Branch 25 taken 71 times.
✓ Branch 26 taken 2 times.
✓ Branch 27 taken 73 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 73 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 3 times.
✓ Branch 33 taken 70 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
|
361 | if (openstudio::istringEqual("Absolute", *strDetailedSystem) || openstudio::istringEqual("World", *strDetailedSystem)) { |
| 246 |
1/1✓ Branch 1 taken 3 times.
|
3 | result.detailedSystem = CoordinateSystem::Absolute; |
| 247 | } else { | ||
| 248 |
1/1✓ Branch 1 taken 70 times.
|
70 | result.detailedSystem = CoordinateSystem::Relative; |
| 249 | } | ||
| 250 | } else { | ||
| 251 | ✗ | LOG(Error, "Missing required property 'Coordinate System' for GlobalGeometryRules"); | |
| 252 | 73 | } | |
| 253 | |||
| 254 | // These two have defaults in IDD, so it shouldn't fail | ||
| 255 | 73 | if (OptionalString strDaylightingSystem = | |
| 256 |
2/3✓ Branch 1 taken 73 times.
✓ Branch 3 taken 73 times.
✗ Branch 4 not taken.
|
146 | globalGeometryRules.getString(GlobalGeometryRulesFields::DaylightingReferencePointCoordinateSystem, true)) { |
| 257 | try { | ||
| 258 |
2/2✓ Branch 1 taken 73 times.
✓ Branch 4 taken 73 times.
|
73 | result.daylightingSystem = CoordinateSystem(*strDaylightingSystem); |
| 259 | ✗ | } catch (...) { | |
| 260 | ✗ | LOG(Error, "Could not read property 'Daylighting Reference Point Coordinate System' for GlobalGeometryRules"); | |
| 261 | ✗ | } | |
| 262 | } else { | ||
| 263 | ✗ | LOG(Error, "Missing property 'Daylighting Reference Point Coordinate System' for GlobalGeometryRules"); | |
| 264 | 73 | } | |
| 265 | |||
| 266 |
2/3✓ Branch 1 taken 73 times.
✓ Branch 3 taken 73 times.
✗ Branch 4 not taken.
|
146 | if (OptionalString strRectangularSystem = globalGeometryRules.getString(GlobalGeometryRulesFields::RectangularSurfaceCoordinateSystem, true)) { |
| 267 | try { | ||
| 268 |
2/2✓ Branch 1 taken 73 times.
✓ Branch 4 taken 73 times.
|
73 | result.rectangularSystem = CoordinateSystem(*strRectangularSystem); |
| 269 | ✗ | } catch (...) { | |
| 270 | ✗ | LOG(Error, "Could not read property 'Rectangular Surface Coordinate System' for GlobalGeometryRules"); | |
| 271 | ✗ | } | |
| 272 | } else { | ||
| 273 | ✗ | LOG(Error, "Missing property 'Rectangular Surface Coordinate System' for GlobalGeometryRules"); | |
| 274 | 73 | } | |
| 275 | |||
| 276 | 73 | return result; | |
| 277 | 103 | } | |
| 278 | |||
| 279 | // set the GlobalGeometryRules, only changes the object does not transform geometry | ||
| 280 | 103 | bool GeometryTranslator::setGlobalGeometryRules(const StartingVertexPosition& svp, const VertexEntryDirection& ved, | |
| 281 | const CoordinateSystem& detailedSystem, const CoordinateSystem& daylightingSystem, | ||
| 282 | const CoordinateSystem& rectangularSystem) { | ||
| 283 | 103 | bool result = true; | |
| 284 | |||
| 285 | // get the GlobalGeometryRules | ||
| 286 |
2/2✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
|
103 | WorkspaceObjectVector objects = m_workspace.getObjectsByType(IddObjectType::GlobalGeometryRules); |
| 287 |
2/2✓ Branch 1 taken 30 times.
✓ Branch 2 taken 73 times.
|
103 | if (objects.empty()) { |
| 288 |
3/3✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
✓ Branch 7 taken 30 times.
|
30 | m_workspace.addObject(IdfObject(IddObjectType::GlobalGeometryRules)); |
| 289 |
2/2✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
|
30 | objects = m_workspace.getObjectsByType(IddObjectType::GlobalGeometryRules); |
| 290 | } | ||
| 291 |
1/1✓ Branch 2 taken 103 times.
|
103 | WorkspaceObject globalGeometryRules = objects[0]; |
| 292 | |||
| 293 | // after conversion, set GlobalGeometryRules | ||
| 294 |
5/10✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 103 times.
✓ Branch 6 taken 103 times.
✓ Branch 8 taken 103 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 103 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
103 | result = result && globalGeometryRules.setString(GlobalGeometryRulesFields::StartingVertexPosition, svp.valueName()); |
| 295 |
5/10✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 103 times.
✓ Branch 6 taken 103 times.
✓ Branch 8 taken 103 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 103 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
103 | result = result && globalGeometryRules.setString(GlobalGeometryRulesFields::VertexEntryDirection, ved.valueName()); |
| 296 |
5/10✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 103 times.
✓ Branch 6 taken 103 times.
✓ Branch 8 taken 103 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 103 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
103 | result = result && globalGeometryRules.setString(GlobalGeometryRulesFields::CoordinateSystem, detailedSystem.valueName()); |
| 297 | 103 | result = | |
| 298 |
5/10✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 103 times.
✓ Branch 6 taken 103 times.
✓ Branch 8 taken 103 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 103 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
103 | result && globalGeometryRules.setString(GlobalGeometryRulesFields::DaylightingReferencePointCoordinateSystem, daylightingSystem.valueName()); |
| 299 |
5/10✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 103 times.
✓ Branch 6 taken 103 times.
✓ Branch 8 taken 103 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 103 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
103 | result = result && globalGeometryRules.setString(GlobalGeometryRulesFields::RectangularSurfaceCoordinateSystem, rectangularSystem.valueName()); |
| 300 | |||
| 301 | 103 | return result; | |
| 302 | 103 | } | |
| 303 | |||
| 304 | // get the transformation from building to world | ||
| 305 | 412 | Transformation GeometryTranslator::buildingTransformation() const { | |
| 306 | // get the Building | ||
| 307 |
2/2✓ Branch 1 taken 412 times.
✓ Branch 4 taken 412 times.
|
412 | WorkspaceObjectVector objects = m_workspace.getObjectsByType(IddObjectType::Building); |
| 308 |
2/2✓ Branch 1 taken 116 times.
✓ Branch 2 taken 296 times.
|
412 | if (objects.size() != 1) { |
| 309 |
5/5✓ Branch 1 taken 116 times.
✓ Branch 4 taken 116 times.
✓ Branch 7 taken 116 times.
✓ Branch 10 taken 116 times.
✓ Branch 13 taken 116 times.
|
116 | LOG(Warn, "Could not find Building object, assuming 0 rotation"); |
| 310 |
1/1✓ Branch 1 taken 116 times.
|
116 | return {}; |
| 311 | } | ||
| 312 |
1/1✓ Branch 2 taken 296 times.
|
296 | WorkspaceObject building = objects[0]; |
| 313 | |||
| 314 |
1/1✓ Branch 1 taken 296 times.
|
296 | OptionalDouble northAxis = building.getDouble(BuildingFields::NorthAxis, true); |
| 315 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 296 times.
|
296 | if (!northAxis) { |
| 316 | ✗ | northAxis = 0; | |
| 317 | ✗ | LOG(Warn, "North Axis unknown, using 0"); | |
| 318 | } | ||
| 319 | // rotate negative amount around the z axis, EnergyPlus defines rotation opposite to OpenStudio | ||
| 320 |
4/4✓ Branch 1 taken 296 times.
✓ Branch 4 taken 296 times.
✓ Branch 7 taken 296 times.
✓ Branch 10 taken 296 times.
|
296 | return Transformation::rotation(Vector3d(0, 0, 1), -degToRad(*northAxis)); |
| 321 | 412 | } | |
| 322 | |||
| 323 | // get the transformation from zone to building | ||
| 324 | 15 | Transformation GeometryTranslator::zoneTransformation(const WorkspaceObject& zone) const { | |
| 325 |
4/6✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 15 times.
✗ Branch 13 not taken.
|
15 | OS_ASSERT(zone.iddObject().type() == IddObjectType::Zone); |
| 326 | |||
| 327 |
1/1✓ Branch 1 taken 15 times.
|
15 | OptionalDouble x = zone.getDouble(ZoneFields::XOrigin, true); |
| 328 |
1/1✓ Branch 1 taken 15 times.
|
15 | OptionalDouble y = zone.getDouble(ZoneFields::YOrigin, true); |
| 329 |
1/1✓ Branch 1 taken 15 times.
|
15 | OptionalDouble z = zone.getDouble(ZoneFields::ZOrigin, true); |
| 330 |
4/8✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 15 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15 times.
|
15 | if (!x || !y || !z) { |
| 331 | ✗ | x = 0; | |
| 332 | ✗ | y = 0; | |
| 333 | ✗ | z = 0; | |
| 334 | ✗ | LOG(Error, "Zone origin unknown, using 0, 0, 0"); | |
| 335 | } | ||
| 336 | |||
| 337 | // translation | ||
| 338 |
5/5✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
✓ Branch 13 taken 15 times.
|
15 | Transformation translation = Transformation::translation(Vector3d(*x, *y, *z)); |
| 339 | |||
| 340 |
1/1✓ Branch 1 taken 15 times.
|
15 | OptionalDouble directionOfRelativeNorth = zone.getDouble(ZoneFields::DirectionofRelativeNorth, true); |
| 341 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
|
15 | if (!directionOfRelativeNorth) { |
| 342 | ✗ | directionOfRelativeNorth = 0; | |
| 343 | ✗ | LOG(Error, "Zone direction of relative North unknown, using 0"); | |
| 344 | } | ||
| 345 | |||
| 346 | // rotate negative amount around the z axis, EnergyPlus defines rotation opposite to OpenStudio | ||
| 347 |
4/4✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
|
15 | Transformation rotation = Transformation::rotation(Vector3d(0, 0, 1), -degToRad(*directionOfRelativeNorth)); |
| 348 | |||
| 349 |
1/1✓ Branch 1 taken 15 times.
|
30 | return translation * rotation; |
| 350 | 15 | } | |
| 351 | |||
| 352 | // convert simple shading to detailed in the current system | ||
| 353 | 103 | bool GeometryTranslator::convertSimpleShading(const CoordinateChange& coordChange) { | |
| 354 | // building transformation | ||
| 355 |
1/1✓ Branch 1 taken 103 times.
|
103 | Transformation buildingTransformation = this->buildingTransformation(); |
| 356 | |||
| 357 | // Shading::Site | ||
| 358 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 103 times.
|
111 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Shading_Site)) { |
| 359 | |||
| 360 | // get simple params | ||
| 361 |
1/1✓ Branch 1 taken 8 times.
|
8 | OptionalDouble azimuth = oldObject.getDouble(Shading_SiteFields::AzimuthAngle, true); |
| 362 |
1/1✓ Branch 1 taken 8 times.
|
8 | OptionalDouble tilt = oldObject.getDouble(Shading_SiteFields::TiltAngle, true); |
| 363 |
1/1✓ Branch 1 taken 8 times.
|
8 | OptionalDouble x0 = oldObject.getDouble(Shading_SiteFields::StartingXCoordinate, true); |
| 364 |
1/1✓ Branch 1 taken 8 times.
|
8 | OptionalDouble y0 = oldObject.getDouble(Shading_SiteFields::StartingYCoordinate, true); |
| 365 |
1/1✓ Branch 1 taken 8 times.
|
8 | OptionalDouble z0 = oldObject.getDouble(Shading_SiteFields::StartingZCoordinate, true); |
| 366 |
1/1✓ Branch 1 taken 8 times.
|
8 | OptionalDouble length = oldObject.getDouble(Shading_SiteFields::Length, true); |
| 367 |
1/1✓ Branch 1 taken 8 times.
|
8 | OptionalDouble height = oldObject.getDouble(Shading_SiteFields::Height, true); |
| 368 | |||
| 369 |
8/16✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 8 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 8 times.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 8 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 8 times.
|
8 | if (!azimuth || !tilt || !x0 || !y0 || !z0 || !length || !height) { |
| 370 | ✗ | LOG(Error, "Missing required fields"); | |
| 371 | ✗ | continue; | |
| 372 | ✗ | } | |
| 373 | |||
| 374 | // get vertices | ||
| 375 |
8/8✓ 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.
✓ Branch 16 taken 8 times.
✓ Branch 19 taken 8 times.
✓ Branch 22 taken 8 times.
|
8 | Point3dVector vertices = verticesForAzimuthTiltXYZLengthWidthOrHeight(*azimuth, *tilt, *x0, *y0, *z0, *length, *height); |
| 376 | |||
| 377 | // fields which map directly | ||
| 378 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 379 | {Shading_SiteFields::Name, Shading_Site_DetailedFields::Name}, | ||
| 380 |
1/1✓ Branch 1 taken 8 times.
|
16 | }; |
| 381 | |||
| 382 | // new object | ||
| 383 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
|
8 | IdfObject newObject(IddObjectType::Shading_Site_Detailed); |
| 384 | |||
| 385 | // copy fields over directly | ||
| 386 |
1/1✓ Branch 1 taken 8 times.
|
8 | mapFields(oldObject, newObject, fieldMap); |
| 387 | |||
| 388 | // set other fields | ||
| 389 |
1/1✓ Branch 1 taken 8 times.
|
8 | newObject.setDouble(Shading_Site_DetailedFields::NumberofVertices, 4); |
| 390 | |||
| 391 | // swap old object with new one | ||
| 392 |
1/1✓ Branch 1 taken 8 times.
|
8 | bool ok = m_workspace.swap(oldObject, newObject); |
| 393 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | if (ok) { |
| 394 |
4/6✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 8 times.
✗ Branch 13 not taken.
|
8 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::Shading_Site_Detailed); |
| 395 | // set vertices | ||
| 396 |
1/1✓ Branch 1 taken 8 times.
|
8 | setVertices(Shading_Site_DetailedFields::NumberofVertices + 1, oldObject, vertices); |
| 397 | } else { | ||
| 398 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 399 | ✗ | continue; | |
| 400 | ✗ | } | |
| 401 | |||
| 402 | // remove old object | ||
| 403 | //m_workspace.removeObject(oldObject.handle()); | ||
| 404 | 111 | } | |
| 405 | |||
| 406 | // Shading::Building | ||
| 407 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 103 times.
|
110 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Shading_Building)) { |
| 408 | |||
| 409 | // get transformation | ||
| 410 |
1/1✓ Branch 1 taken 7 times.
|
7 | Transformation t; |
| 411 |
3/3✓ Branch 1 taken 7 times.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 6 times.
|
7 | if (coordChange == CoordinateChange::AbsoluteToRelative) { |
| 412 |
1/1✓ Branch 1 taken 1 time.
|
1 | t = buildingTransformation.inverse(); |
| 413 |
2/3✓ Branch 1 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
|
6 | } else if (coordChange == CoordinateChange::RelativeToAbsolute) { |
| 414 | ✗ | t = buildingTransformation; | |
| 415 | } | ||
| 416 | |||
| 417 | // get simple params | ||
| 418 |
1/1✓ Branch 1 taken 7 times.
|
7 | OptionalDouble azimuth = oldObject.getDouble(Shading_BuildingFields::AzimuthAngle, true); |
| 419 |
1/1✓ Branch 1 taken 7 times.
|
7 | OptionalDouble tilt = oldObject.getDouble(Shading_BuildingFields::TiltAngle, true); |
| 420 |
1/1✓ Branch 1 taken 7 times.
|
7 | OptionalDouble x0 = oldObject.getDouble(Shading_BuildingFields::StartingXCoordinate, true); |
| 421 |
1/1✓ Branch 1 taken 7 times.
|
7 | OptionalDouble y0 = oldObject.getDouble(Shading_BuildingFields::StartingYCoordinate, true); |
| 422 |
1/1✓ Branch 1 taken 7 times.
|
7 | OptionalDouble z0 = oldObject.getDouble(Shading_BuildingFields::StartingZCoordinate, true); |
| 423 |
1/1✓ Branch 1 taken 7 times.
|
7 | OptionalDouble length = oldObject.getDouble(Shading_BuildingFields::Length, true); |
| 424 |
1/1✓ Branch 1 taken 7 times.
|
7 | OptionalDouble height = oldObject.getDouble(Shading_BuildingFields::Height, true); |
| 425 | |||
| 426 |
8/16✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 7 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 7 times.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 7 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 7 times.
|
7 | if (!azimuth || !tilt || !x0 || !y0 || !z0 || !length || !height) { |
| 427 | ✗ | LOG(Error, "Missing required fields"); | |
| 428 | ✗ | continue; | |
| 429 | ✗ | } | |
| 430 | |||
| 431 | // get vertices | ||
| 432 |
8/8✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✓ Branch 10 taken 7 times.
✓ Branch 13 taken 7 times.
✓ Branch 16 taken 7 times.
✓ Branch 19 taken 7 times.
✓ Branch 22 taken 7 times.
|
7 | Point3dVector vertices = verticesForAzimuthTiltXYZLengthWidthOrHeight(*azimuth, *tilt, *x0, *y0, *z0, *length, *height); |
| 433 |
1/1✓ Branch 1 taken 7 times.
|
7 | vertices = t * vertices; |
| 434 | |||
| 435 | // fields which map directly | ||
| 436 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 437 | {Shading_BuildingFields::Name, Shading_Building_DetailedFields::Name}, | ||
| 438 |
1/1✓ Branch 1 taken 7 times.
|
14 | }; |
| 439 | |||
| 440 | // new object | ||
| 441 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
7 | IdfObject newObject(IddObjectType::Shading_Building_Detailed); |
| 442 | |||
| 443 | // copy fields over directly | ||
| 444 |
1/1✓ Branch 1 taken 7 times.
|
7 | mapFields(oldObject, newObject, fieldMap); |
| 445 | |||
| 446 | // set other fields | ||
| 447 |
1/1✓ Branch 1 taken 7 times.
|
7 | newObject.setDouble(Shading_Building_DetailedFields::NumberofVertices, 4); |
| 448 | |||
| 449 | // swap old object with new one | ||
| 450 |
1/1✓ Branch 1 taken 7 times.
|
7 | bool ok = m_workspace.swap(oldObject, newObject); |
| 451 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | if (ok) { |
| 452 |
4/6✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 13 not taken.
|
7 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::Shading_Building_Detailed); |
| 453 | // set vertices | ||
| 454 |
1/1✓ Branch 1 taken 7 times.
|
7 | setVertices(Shading_Building_DetailedFields::NumberofVertices + 1, oldObject, vertices); |
| 455 | } else { | ||
| 456 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 457 | ✗ | continue; | |
| 458 | ✗ | } | |
| 459 | |||
| 460 | // remove old object | ||
| 461 | //m_workspace.removeObject(oldObject.handle()); | ||
| 462 | 110 | } | |
| 463 | |||
| 464 | // Shading:Overhang | ||
| 465 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 103 times.
|
107 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Shading_Overhang)) { |
| 466 | |||
| 467 | // find subSurface | ||
| 468 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalWorkspaceObject subSurface = oldObject.getTarget(Shading_OverhangFields::WindoworDoorName); |
| 469 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
|
4 | if (!subSurface) { |
| 470 | ✗ | LOG(Error, "Could not find subSurface"); | |
| 471 | ✗ | continue; | |
| 472 | ✗ | } | |
| 473 | |||
| 474 | // find surface | ||
| 475 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | OptionalWorkspaceObject surface = subSurface->getTarget(FenestrationSurface_DetailedFields::BuildingSurfaceName); |
| 476 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
|
4 | if (!surface) { |
| 477 | ✗ | LOG(Error, "Could not find surface"); | |
| 478 | ✗ | continue; | |
| 479 | ✗ | } | |
| 480 | |||
| 481 | // get transformation from face coordinates to zone | ||
| 482 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | Point3dVector subSurfaceVerts = getVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, *subSurface); |
| 483 |
1/1✓ Branch 1 taken 4 times.
|
4 | Transformation t = Transformation::alignFace(subSurfaceVerts); |
| 484 | |||
| 485 | // figure out bounds of the subsurface in face coordinates | ||
| 486 | 4 | OptionalDouble xMin; | |
| 487 | 4 | OptionalDouble xMax; | |
| 488 | 4 | OptionalDouble yMin; | |
| 489 | 4 | OptionalDouble yMax; | |
| 490 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 4 times.
|
20 | for (const Point3d& faceVert : t.inverse() * subSurfaceVerts) { |
| 491 | |||
| 492 |
2/4✓ Branch 1 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✗ Branch 7 not taken.
|
16 | OS_ASSERT(std::abs(faceVert.z()) < 0.001); |
| 493 | |||
| 494 |
7/8✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 12 times.
|
16 | if (!xMin || (faceVert.x() < *xMin)) { |
| 495 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | xMin = faceVert.x(); |
| 496 | } | ||
| 497 |
8/8✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 8 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 8 times.
|
16 | if (!xMax || (faceVert.x() > *xMax)) { |
| 498 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
|
8 | xMax = faceVert.x(); |
| 499 | } | ||
| 500 |
8/8✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 9 times.
✓ Branch 12 taken 7 times.
|
16 | if (!yMin || (faceVert.y() < *yMin)) { |
| 501 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | yMin = faceVert.y(); |
| 502 | } | ||
| 503 |
7/8✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 12 times.
|
16 | if (!yMax || (faceVert.y() > *yMax)) { |
| 504 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | yMax = faceVert.y(); |
| 505 | } | ||
| 506 | 4 | } | |
| 507 |
5/10✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 4 times.
|
4 | if (!xMin || !xMax || !yMin || !yMax) { |
| 508 | ✗ | LOG(Error, "Cannot determine sub surface bounds"); | |
| 509 | ✗ | continue; | |
| 510 | ✗ | } | |
| 511 | |||
| 512 | // simple params | ||
| 513 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble height = oldObject.getDouble(Shading_OverhangFields::HeightaboveWindoworDoor, true); |
| 514 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble tilt = oldObject.getDouble(Shading_OverhangFields::TiltAnglefromWindow_Door, true); |
| 515 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble leftOffset = oldObject.getDouble(Shading_OverhangFields::LeftextensionfromWindow_DoorWidth, true); |
| 516 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble rightOffset = oldObject.getDouble(Shading_OverhangFields::RightextensionfromWindow_DoorWidth, true); |
| 517 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble depth = oldObject.getDouble(Shading_OverhangFields::Depth, true); |
| 518 |
6/12✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 4 times.
|
4 | if (!height || !tilt || !leftOffset || !rightOffset || !depth) { |
| 519 | ✗ | LOG(Error, "Missing required fields"); | |
| 520 | ✗ | continue; | |
| 521 | ✗ | } | |
| 522 | |||
| 523 |
2/3✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
|
4 | if (*depth == 0) { |
| 524 | ✗ | LOG(Error, "Zero depth surface not allowed"); | |
| 525 | ✗ | continue; | |
| 526 | ✗ | } | |
| 527 | |||
| 528 | // vertices | ||
| 529 |
1/1✓ Branch 1 taken 4 times.
|
4 | openstudio::Point3dVector faceVertices(4); |
| 530 |
11/11✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 16 taken 4 times.
✓ Branch 19 taken 4 times.
✓ Branch 22 taken 4 times.
✓ Branch 25 taken 4 times.
✓ Branch 28 taken 4 times.
✓ Branch 31 taken 4 times.
|
4 | faceVertices[0] = Point3d(*xMax + *rightOffset, *yMax + *height + *depth * std::cos(degToRad(*tilt)), *depth * std::sin(degToRad(*tilt))); |
| 531 |
5/5✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
|
4 | faceVertices[1] = Point3d(*xMax + *rightOffset, *yMax + *height, 0.0); |
| 532 |
5/5✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
|
4 | faceVertices[2] = Point3d(*xMin - *leftOffset, *yMax + *height, 0.0); |
| 533 |
11/11✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 16 taken 4 times.
✓ Branch 19 taken 4 times.
✓ Branch 22 taken 4 times.
✓ Branch 25 taken 4 times.
✓ Branch 28 taken 4 times.
✓ Branch 31 taken 4 times.
|
4 | faceVertices[3] = Point3d(*xMin - *leftOffset, *yMax + *height + *depth * std::cos(degToRad(*tilt)), *depth * std::sin(degToRad(*tilt))); |
| 534 | |||
| 535 | // transform vertices | ||
| 536 |
1/1✓ Branch 1 taken 4 times.
|
4 | faceVertices = t * faceVertices; |
| 537 | |||
| 538 | // add new object | ||
| 539 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | IdfObject newObject(IddObjectType::Shading_Zone_Detailed); |
| 540 | |||
| 541 | // fields which map directly | ||
| 542 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 543 | {Shading_OverhangFields::Name, Shading_Zone_DetailedFields::Name}, | ||
| 544 |
1/1✓ Branch 1 taken 4 times.
|
8 | }; |
| 545 | |||
| 546 | // copy fields over directly | ||
| 547 |
1/1✓ Branch 1 taken 4 times.
|
4 | mapFields(oldObject, newObject, fieldMap); |
| 548 | |||
| 549 | // set other fields | ||
| 550 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
4 | newObject.setString(Shading_Zone_DetailedFields::BaseSurfaceName, surface->name().get()); |
| 551 |
1/1✓ Branch 1 taken 4 times.
|
4 | newObject.setDouble(Shading_Zone_DetailedFields::NumberofVertices, 4); |
| 552 | |||
| 553 | // swap old object with new one | ||
| 554 |
1/1✓ Branch 1 taken 4 times.
|
4 | bool ok = m_workspace.swap(oldObject, newObject, false); |
| 555 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (ok) { |
| 556 |
4/6✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 13 not taken.
|
4 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::Shading_Zone_Detailed); |
| 557 | // set vertices | ||
| 558 |
1/1✓ Branch 1 taken 4 times.
|
4 | setVertices(Shading_Zone_DetailedFields::NumberofVertices + 1, oldObject, faceVertices); |
| 559 | } else { | ||
| 560 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 561 | ✗ | continue; | |
| 562 | ✗ | } | |
| 563 | |||
| 564 | // remove old object | ||
| 565 | //m_workspace.removeObject(oldObject.handle()); | ||
| 566 | 107 | } | |
| 567 | |||
| 568 | // Shading:Overhang:Projection | ||
| 569 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 103 times.
|
106 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Shading_Overhang_Projection)) { |
| 570 | |||
| 571 | // find subSurface | ||
| 572 |
1/1✓ Branch 1 taken 3 times.
|
3 | OptionalWorkspaceObject subSurface = oldObject.getTarget(Shading_Overhang_ProjectionFields::WindoworDoorName); |
| 573 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (!subSurface) { |
| 574 | ✗ | LOG(Error, "Could not find subSurface"); | |
| 575 | ✗ | continue; | |
| 576 | ✗ | } | |
| 577 | |||
| 578 | // find surface | ||
| 579 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | OptionalWorkspaceObject surface = subSurface->getTarget(FenestrationSurface_DetailedFields::BuildingSurfaceName); |
| 580 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (!surface) { |
| 581 | ✗ | LOG(Error, "Could not find surface"); | |
| 582 | ✗ | continue; | |
| 583 | ✗ | } | |
| 584 | |||
| 585 | // get transformation from face coordinates to zone | ||
| 586 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | Point3dVector subSurfaceVerts = getVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, *subSurface); |
| 587 |
1/1✓ Branch 1 taken 3 times.
|
3 | Transformation t = Transformation::alignFace(subSurfaceVerts); |
| 588 | |||
| 589 | // figure out bounds of the subsurface in face coordinates | ||
| 590 | 3 | OptionalDouble xMin; | |
| 591 | 3 | OptionalDouble xMax; | |
| 592 | 3 | OptionalDouble yMin; | |
| 593 | 3 | OptionalDouble yMax; | |
| 594 |
4/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 12 taken 12 times.
✓ Branch 13 taken 3 times.
|
15 | for (const Point3d& faceVert : t.inverse() * subSurfaceVerts) { |
| 595 | |||
| 596 |
2/4✓ Branch 1 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 7 not taken.
|
12 | OS_ASSERT(std::abs(faceVert.z()) < 0.001); |
| 597 | |||
| 598 |
7/8✓ Branch 1 taken 9 times.
✓ Branch 2 taken 3 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 9 times.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 9 times.
|
12 | if (!xMin || (faceVert.x() < *xMin)) { |
| 599 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | xMin = faceVert.x(); |
| 600 | } | ||
| 601 |
8/8✓ Branch 1 taken 9 times.
✓ Branch 2 taken 3 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 6 times.
|
12 | if (!xMax || (faceVert.x() > *xMax)) { |
| 602 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | xMax = faceVert.x(); |
| 603 | } | ||
| 604 |
8/8✓ Branch 1 taken 9 times.
✓ Branch 2 taken 3 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 6 times.
|
12 | if (!yMin || (faceVert.y() < *yMin)) { |
| 605 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | yMin = faceVert.y(); |
| 606 | } | ||
| 607 |
7/8✓ Branch 1 taken 9 times.
✓ Branch 2 taken 3 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 9 times.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 9 times.
|
12 | if (!yMax || (faceVert.y() > *yMax)) { |
| 608 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | yMax = faceVert.y(); |
| 609 | } | ||
| 610 | 3 | } | |
| 611 |
5/10✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 3 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 3 times.
|
3 | if (!xMin || !xMax || !yMin || !yMax) { |
| 612 | ✗ | LOG(Error, "Cannot determine sub surface bounds"); | |
| 613 | ✗ | continue; | |
| 614 | ✗ | } | |
| 615 | |||
| 616 | // simple params | ||
| 617 |
1/1✓ Branch 1 taken 3 times.
|
3 | OptionalDouble height = oldObject.getDouble(Shading_Overhang_ProjectionFields::HeightaboveWindoworDoor, true); |
| 618 |
1/1✓ Branch 1 taken 3 times.
|
3 | OptionalDouble tilt = oldObject.getDouble(Shading_Overhang_ProjectionFields::TiltAnglefromWindow_Door, true); |
| 619 |
1/1✓ Branch 1 taken 3 times.
|
3 | OptionalDouble leftOffset = oldObject.getDouble(Shading_Overhang_ProjectionFields::LeftextensionfromWindow_DoorWidth, true); |
| 620 |
1/1✓ Branch 1 taken 3 times.
|
3 | OptionalDouble rightOffset = oldObject.getDouble(Shading_Overhang_ProjectionFields::RightextensionfromWindow_DoorWidth, true); |
| 621 |
1/1✓ Branch 1 taken 3 times.
|
3 | OptionalDouble projectionFactor = oldObject.getDouble(Shading_Overhang_ProjectionFields::DepthasFractionofWindow_DoorHeight, true); |
| 622 |
6/12✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 3 times.
|
3 | if (!height || !tilt || !leftOffset || !rightOffset || !projectionFactor) { |
| 623 | ✗ | LOG(Error, "Missing required fields"); | |
| 624 | ✗ | continue; | |
| 625 | ✗ | } | |
| 626 | |||
| 627 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
3 | double depth = *projectionFactor * (*yMax - *yMin); |
| 628 | |||
| 629 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (depth == 0) { |
| 630 | ✗ | LOG(Error, "Zero depth surface not allowed"); | |
| 631 | ✗ | continue; | |
| 632 | ✗ | } | |
| 633 | |||
| 634 | // vertices | ||
| 635 |
1/1✓ Branch 1 taken 3 times.
|
3 | openstudio::Point3dVector faceVertices(4); |
| 636 |
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 | faceVertices[0] = Point3d(*xMax + *rightOffset, *yMax + *height + depth * std::cos(degToRad(*tilt)), depth * std::sin(degToRad(*tilt))); |
| 637 |
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 | faceVertices[1] = Point3d(*xMax + *rightOffset, *yMax + *height, 0.0); |
| 638 |
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 | faceVertices[2] = Point3d(*xMin - *leftOffset, *yMax + *height, 0.0); |
| 639 |
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 | faceVertices[3] = Point3d(*xMin - *leftOffset, *yMax + *height + depth * std::cos(degToRad(*tilt)), depth * std::sin(degToRad(*tilt))); |
| 640 | |||
| 641 | // transform vertices | ||
| 642 |
1/1✓ Branch 1 taken 3 times.
|
3 | faceVertices = t * faceVertices; |
| 643 | |||
| 644 | // add new object | ||
| 645 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | IdfObject newObject(IddObjectType::Shading_Zone_Detailed); |
| 646 | |||
| 647 | // fields which map directly | ||
| 648 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 649 | {Shading_Overhang_ProjectionFields::Name, Shading_Zone_DetailedFields::Name}, | ||
| 650 |
1/1✓ Branch 1 taken 3 times.
|
6 | }; |
| 651 | |||
| 652 | // copy fields over directly | ||
| 653 |
1/1✓ Branch 1 taken 3 times.
|
3 | mapFields(oldObject, newObject, fieldMap); |
| 654 | |||
| 655 | // set other fields | ||
| 656 |
4/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
|
3 | newObject.setString(Shading_Zone_DetailedFields::BaseSurfaceName, surface->name().get()); |
| 657 |
1/1✓ Branch 1 taken 3 times.
|
3 | newObject.setDouble(Shading_Zone_DetailedFields::NumberofVertices, 4); |
| 658 | |||
| 659 | // swap old object with new one | ||
| 660 |
1/1✓ Branch 1 taken 3 times.
|
3 | bool ok = m_workspace.swap(oldObject, newObject, false); |
| 661 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (ok) { |
| 662 |
4/6✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 3 times.
✗ Branch 13 not taken.
|
3 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::Shading_Zone_Detailed); |
| 663 | // set vertices | ||
| 664 |
1/1✓ Branch 1 taken 3 times.
|
3 | setVertices(Shading_Zone_DetailedFields::NumberofVertices + 1, oldObject, faceVertices); |
| 665 | } else { | ||
| 666 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 667 | ✗ | continue; | |
| 668 | ✗ | } | |
| 669 | 106 | } | |
| 670 | |||
| 671 | // Shading:Fin | ||
| 672 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 103 times.
|
105 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Shading_Fin)) { |
| 673 | |||
| 674 | // find subSurface | ||
| 675 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalWorkspaceObject subSurface = oldObject.getTarget(Shading_FinFields::WindoworDoorName); |
| 676 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!subSurface) { |
| 677 | ✗ | LOG(Error, "Could not find subSurface"); | |
| 678 | ✗ | continue; | |
| 679 | ✗ | } | |
| 680 | |||
| 681 | // find surface | ||
| 682 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | OptionalWorkspaceObject surface = subSurface->getTarget(FenestrationSurface_DetailedFields::BuildingSurfaceName); |
| 683 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!surface) { |
| 684 | ✗ | LOG(Error, "Could not find surface"); | |
| 685 | ✗ | continue; | |
| 686 | ✗ | } | |
| 687 | |||
| 688 | // get transformation from face coordinates to zone | ||
| 689 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | Point3dVector subSurfaceVerts = getVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, *subSurface); |
| 690 |
1/1✓ Branch 1 taken 2 times.
|
2 | Transformation t = Transformation::alignFace(subSurfaceVerts); |
| 691 | |||
| 692 | // figure out bounds of the subsurface in face coordinates | ||
| 693 | 2 | OptionalDouble xMin; | |
| 694 | 2 | OptionalDouble xMax; | |
| 695 | 2 | OptionalDouble yMin; | |
| 696 | 2 | OptionalDouble yMax; | |
| 697 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 12 taken 8 times.
✓ Branch 13 taken 2 times.
|
10 | for (const Point3d& faceVert : t.inverse() * subSurfaceVerts) { |
| 698 | |||
| 699 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 7 not taken.
|
8 | OS_ASSERT(std::abs(faceVert.z()) < 0.001); |
| 700 | |||
| 701 |
7/8✓ Branch 1 taken 6 times.
✓ Branch 2 taken 2 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 6 times.
|
8 | if (!xMin || (faceVert.x() < *xMin)) { |
| 702 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | xMin = faceVert.x(); |
| 703 | } | ||
| 704 |
8/8✓ Branch 1 taken 6 times.
✓ Branch 2 taken 2 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✓ Branch 9 taken 2 times.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 4 times.
|
8 | if (!xMax || (faceVert.x() > *xMax)) { |
| 705 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | xMax = faceVert.x(); |
| 706 | } | ||
| 707 |
8/8✓ Branch 1 taken 6 times.
✓ Branch 2 taken 2 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✓ Branch 9 taken 2 times.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 4 times.
|
8 | if (!yMin || (faceVert.y() < *yMin)) { |
| 708 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | yMin = faceVert.y(); |
| 709 | } | ||
| 710 |
7/8✓ Branch 1 taken 6 times.
✓ Branch 2 taken 2 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 6 times.
|
8 | if (!yMax || (faceVert.y() > *yMax)) { |
| 711 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | yMax = faceVert.y(); |
| 712 | } | ||
| 713 | 2 | } | |
| 714 |
5/10✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
|
2 | if (!xMin || !xMax || !yMin || !yMax) { |
| 715 | ✗ | LOG(Error, "Cannot determine sub surface bounds"); | |
| 716 | ✗ | continue; | |
| 717 | ✗ | } | |
| 718 | |||
| 719 | // simple params | ||
| 720 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble leftOffset = oldObject.getDouble(Shading_FinFields::LeftExtensionfromWindow_Door, true); |
| 721 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble leftAbove = oldObject.getDouble(Shading_FinFields::LeftDistanceAboveTopofWindow, true); |
| 722 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble leftBelow = oldObject.getDouble(Shading_FinFields::LeftDistanceBelowBottomofWindow, true); |
| 723 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble leftTilt = oldObject.getDouble(Shading_FinFields::LeftTiltAnglefromWindow_Door, true); |
| 724 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble leftDepth = oldObject.getDouble(Shading_FinFields::LeftDepth, true); |
| 725 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble rightOffset = oldObject.getDouble(Shading_FinFields::RightExtensionfromWindow_Door, true); |
| 726 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble rightAbove = oldObject.getDouble(Shading_FinFields::RightDistanceAboveTopofWindow, true); |
| 727 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble rightBelow = oldObject.getDouble(Shading_FinFields::RightDistanceBelowBottomofWindow, true); |
| 728 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble rightTilt = oldObject.getDouble(Shading_FinFields::RightTiltAnglefromWindow_Door, true); |
| 729 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble rightDepth = oldObject.getDouble(Shading_FinFields::RightDepth, true); |
| 730 | |||
| 731 |
8/16✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 2 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 2 times.
✗ Branch 24 not taken.
|
4 | if (!leftOffset || !leftAbove || !leftBelow || !leftTilt || !leftDepth || !rightOffset || !rightAbove || !rightBelow || !rightTilt |
| 732 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
|
4 | || !rightDepth) { |
| 733 | ✗ | LOG(Error, "Missing required fields"); | |
| 734 | ✗ | continue; | |
| 735 | ✗ | } | |
| 736 | |||
| 737 |
5/8✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
|
2 | if (*leftDepth == 0 || *rightDepth == 0) { |
| 738 | ✗ | LOG(Error, "Zero depth surface not allowed"); | |
| 739 | ✗ | continue; | |
| 740 | ✗ | } | |
| 741 | |||
| 742 | // left vertices | ||
| 743 |
1/1✓ Branch 1 taken 2 times.
|
2 | openstudio::Point3dVector leftVertices(4); |
| 744 | 2 | leftVertices[0] = | |
| 745 |
11/11✓ 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.
✓ Branch 28 taken 2 times.
✓ Branch 31 taken 2 times.
|
4 | Point3d(*xMin - *leftOffset + *leftDepth * std::cos(degToRad(*leftTilt)), *yMax + *leftAbove, *leftDepth * std::sin(degToRad(*leftTilt))); |
| 746 | 2 | leftVertices[1] = | |
| 747 |
11/11✓ 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.
✓ Branch 28 taken 2 times.
✓ Branch 31 taken 2 times.
|
4 | Point3d(*xMin - *leftOffset + *leftDepth * std::cos(degToRad(*leftTilt)), *yMin - *leftBelow, *leftDepth * std::sin(degToRad(*leftTilt))); |
| 748 |
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 | leftVertices[2] = Point3d(*xMin - *leftOffset, *yMin - *leftBelow, 0.0); |
| 749 |
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 | leftVertices[3] = Point3d(*xMin - *leftOffset, *yMax + *leftAbove, 0.0); |
| 750 | |||
| 751 | // right vertices | ||
| 752 |
1/1✓ Branch 1 taken 2 times.
|
2 | openstudio::Point3dVector rightVertices(4); |
| 753 |
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.
|
4 | rightVertices[0] = Point3d(*xMax + *rightOffset + *rightDepth * std::cos(degToRad(*rightTilt)), *yMax + *rightAbove, |
| 754 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
4 | *rightDepth * std::sin(degToRad(*rightTilt))); |
| 755 |
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.
|
4 | rightVertices[1] = Point3d(*xMax + *rightOffset + *rightDepth * std::cos(degToRad(*rightTilt)), *yMin - *rightBelow, |
| 756 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
4 | *rightDepth * std::sin(degToRad(*rightTilt))); |
| 757 |
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 | rightVertices[2] = Point3d(*xMax + *rightOffset, *yMin - *rightBelow, 0.0); |
| 758 |
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 | rightVertices[3] = Point3d(*xMax + *rightOffset, *yMax + *rightAbove, 0.0); |
| 759 | |||
| 760 | // transform vertices | ||
| 761 |
1/1✓ Branch 1 taken 2 times.
|
2 | leftVertices = t * leftVertices; |
| 762 |
1/1✓ Branch 1 taken 2 times.
|
2 | rightVertices = t * rightVertices; |
| 763 | |||
| 764 | // add two new objects | ||
| 765 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | IdfObject leftObject(IddObjectType::Shading_Zone_Detailed); |
| 766 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | IdfObject rightObject(IddObjectType::Shading_Zone_Detailed); |
| 767 | |||
| 768 | // // fields which map directly | ||
| 769 | // std::vector<std::pair<unsigned, unsigned>> fieldMap; | ||
| 770 | // // copy fields over directly | ||
| 771 | // mapFields(oldObject, leftObject, fieldMap); | ||
| 772 | // mapFields(oldObject, rightObject, fieldMap); | ||
| 773 | |||
| 774 | // set other fields | ||
| 775 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | leftObject.setString(Shading_Zone_DetailedFields::Name, oldObject.name().get() + " Left"); |
| 776 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | leftObject.setString(Shading_Zone_DetailedFields::BaseSurfaceName, surface->name().get()); |
| 777 |
1/1✓ Branch 1 taken 2 times.
|
2 | leftObject.setDouble(Shading_Zone_DetailedFields::NumberofVertices, 4); |
| 778 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | rightObject.setString(Shading_Zone_DetailedFields::Name, oldObject.name().get() + " Right"); |
| 779 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | rightObject.setString(Shading_Zone_DetailedFields::BaseSurfaceName, surface->name().get()); |
| 780 |
1/1✓ Branch 1 taken 2 times.
|
2 | rightObject.setDouble(Shading_Zone_DetailedFields::NumberofVertices, 4); |
| 781 | |||
| 782 | // swap old object with left one | ||
| 783 |
1/1✓ Branch 1 taken 2 times.
|
2 | bool ok = m_workspace.swap(oldObject, leftObject, false); |
| 784 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (ok) { |
| 785 |
4/6✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 13 not taken.
|
2 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::Shading_Zone_Detailed); |
| 786 | // set vertices | ||
| 787 |
1/1✓ Branch 1 taken 2 times.
|
2 | setVertices(Shading_Zone_DetailedFields::NumberofVertices + 1, oldObject, leftVertices); |
| 788 | } else { | ||
| 789 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 790 | ✗ | continue; | |
| 791 | ✗ | } | |
| 792 | |||
| 793 | // add right object | ||
| 794 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalWorkspaceObject w = m_workspace.addObject(rightObject); |
| 795 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (w) { |
| 796 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | setVertices(Shading_Zone_DetailedFields::NumberofVertices + 1, *w, rightVertices); |
| 797 | } else { | ||
| 798 | ✗ | LOG(Error, "Workspace object add failed"); | |
| 799 | ✗ | continue; | |
| 800 | ✗ | } | |
| 801 | 105 | } | |
| 802 | |||
| 803 | // Shading:Fin:Projection | ||
| 804 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 1 time.
✓ Branch 12 taken 103 times.
|
104 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Shading_Fin_Projection)) { |
| 805 | |||
| 806 | // find subSurface | ||
| 807 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalWorkspaceObject subSurface = oldObject.getTarget(Shading_Fin_ProjectionFields::WindoworDoorName); |
| 808 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!subSurface) { |
| 809 | ✗ | LOG(Error, "Could not find subSurface"); | |
| 810 | ✗ | continue; | |
| 811 | ✗ | } | |
| 812 | |||
| 813 | // find surface | ||
| 814 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | OptionalWorkspaceObject surface = subSurface->getTarget(FenestrationSurface_DetailedFields::BuildingSurfaceName); |
| 815 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!surface) { |
| 816 | ✗ | LOG(Error, "Could not find surface"); | |
| 817 | ✗ | continue; | |
| 818 | ✗ | } | |
| 819 | |||
| 820 | // get transformation from face coordinates to zone | ||
| 821 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | Point3dVector subSurfaceVerts = getVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, *subSurface); |
| 822 |
1/1✓ Branch 1 taken 1 time.
|
1 | Transformation t = Transformation::alignFace(subSurfaceVerts); |
| 823 | |||
| 824 | // figure out bounds of the subsurface in face coordinates | ||
| 825 | 1 | OptionalDouble xMin; | |
| 826 | 1 | OptionalDouble xMax; | |
| 827 | 1 | OptionalDouble yMin; | |
| 828 | 1 | OptionalDouble yMax; | |
| 829 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 12 taken 4 times.
✓ Branch 13 taken 1 time.
|
5 | for (const Point3d& faceVert : t.inverse() * subSurfaceVerts) { |
| 830 | |||
| 831 |
2/4✓ Branch 1 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 7 not taken.
|
4 | OS_ASSERT(std::abs(faceVert.z()) < 0.001); |
| 832 | |||
| 833 |
7/8✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1 time.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 1 time.
✓ Branch 12 taken 3 times.
|
4 | if (!xMin || (faceVert.x() < *xMin)) { |
| 834 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | xMin = faceVert.x(); |
| 835 | } | ||
| 836 |
8/8✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1 time.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 9 taken 1 time.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 2 times.
|
4 | if (!xMax || (faceVert.x() > *xMax)) { |
| 837 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | xMax = faceVert.x(); |
| 838 | } | ||
| 839 |
8/8✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1 time.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 9 taken 1 time.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 2 times.
|
4 | if (!yMin || (faceVert.y() < *yMin)) { |
| 840 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | yMin = faceVert.y(); |
| 841 | } | ||
| 842 |
7/8✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1 time.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 1 time.
✓ Branch 12 taken 3 times.
|
4 | if (!yMax || (faceVert.y() > *yMax)) { |
| 843 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | yMax = faceVert.y(); |
| 844 | } | ||
| 845 | 1 | } | |
| 846 |
5/10✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 time.
|
1 | if (!xMin || !xMax || !yMin || !yMax) { |
| 847 | ✗ | LOG(Error, "Cannot determine sub surface bounds"); | |
| 848 | ✗ | continue; | |
| 849 | ✗ | } | |
| 850 | |||
| 851 | // simple params | ||
| 852 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble leftOffset = oldObject.getDouble(Shading_Fin_ProjectionFields::LeftExtensionfromWindow_Door, true); |
| 853 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble leftAbove = oldObject.getDouble(Shading_Fin_ProjectionFields::LeftDistanceAboveTopofWindow, true); |
| 854 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble leftBelow = oldObject.getDouble(Shading_Fin_ProjectionFields::LeftDistanceBelowBottomofWindow, true); |
| 855 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble leftTilt = oldObject.getDouble(Shading_Fin_ProjectionFields::LeftTiltAnglefromWindow_Door, true); |
| 856 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble leftProjection = oldObject.getDouble(Shading_Fin_ProjectionFields::LeftDepthasFractionofWindow_DoorWidth, true); |
| 857 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble rightOffset = oldObject.getDouble(Shading_Fin_ProjectionFields::RightExtensionfromWindow_Door, true); |
| 858 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble rightAbove = oldObject.getDouble(Shading_Fin_ProjectionFields::RightDistanceAboveTopofWindow, true); |
| 859 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble rightBelow = oldObject.getDouble(Shading_Fin_ProjectionFields::RightDistanceBelowBottomofWindow, true); |
| 860 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble rightTilt = oldObject.getDouble(Shading_Fin_ProjectionFields::RightTiltAnglefromWindow_Door, true); |
| 861 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble rightProjection = oldObject.getDouble(Shading_Fin_ProjectionFields::RightDepthasFractionofWindow_DoorWidth, true); |
| 862 | |||
| 863 |
8/16✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 time.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 time.
✗ Branch 18 not taken.
✓ Branch 20 taken 1 time.
✗ Branch 21 not taken.
✓ Branch 23 taken 1 time.
✗ Branch 24 not taken.
|
2 | if (!leftOffset || !leftAbove || !leftBelow || !leftTilt || !leftProjection || !rightOffset || !rightAbove || !rightBelow || !rightTilt |
| 864 |
3/6✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 time.
|
2 | || !rightProjection) { |
| 865 | ✗ | LOG(Error, "Missing required fields"); | |
| 866 | ✗ | continue; | |
| 867 | ✗ | } | |
| 868 | |||
| 869 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | double leftDepth = *leftProjection * (*yMax - *yMin); |
| 870 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | double rightDepth = *rightProjection * (*yMax - *yMin); |
| 871 | |||
| 872 |
2/4✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
|
1 | if (leftDepth == 0 || rightDepth == 0) { |
| 873 | ✗ | LOG(Error, "Zero depth surface not allowed"); | |
| 874 | ✗ | continue; | |
| 875 | ✗ | } | |
| 876 | |||
| 877 | // left vertices | ||
| 878 |
1/1✓ Branch 1 taken 1 time.
|
1 | openstudio::Point3dVector leftVertices(4); |
| 879 | 1 | leftVertices[0] = | |
| 880 |
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 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
|
2 | Point3d(*xMin - *leftOffset + leftDepth * std::cos(degToRad(*leftTilt)), *yMax + *leftAbove, leftDepth * std::sin(degToRad(*leftTilt))); |
| 881 | 1 | leftVertices[1] = | |
| 882 |
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 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
|
2 | Point3d(*xMin - *leftOffset + leftDepth * std::cos(degToRad(*leftTilt)), *yMin - *leftBelow, leftDepth * std::sin(degToRad(*leftTilt))); |
| 883 |
5/5✓ 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.
|
1 | leftVertices[2] = Point3d(*xMin - *leftOffset, *yMin - *leftBelow, 0.0); |
| 884 |
5/5✓ 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.
|
1 | leftVertices[3] = Point3d(*xMin - *leftOffset, *yMax + *leftAbove, 0.0); |
| 885 | |||
| 886 | // right vertices | ||
| 887 |
1/1✓ Branch 1 taken 1 time.
|
1 | openstudio::Point3dVector rightVertices(4); |
| 888 | 1 | rightVertices[0] = | |
| 889 |
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 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
|
2 | Point3d(*xMax + *rightOffset + rightDepth * std::cos(degToRad(*rightTilt)), *yMax + *rightAbove, rightDepth * std::sin(degToRad(*rightTilt))); |
| 890 | 1 | rightVertices[1] = | |
| 891 |
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 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
|
2 | Point3d(*xMax + *rightOffset + rightDepth * std::cos(degToRad(*rightTilt)), *yMin - *rightBelow, rightDepth * std::sin(degToRad(*rightTilt))); |
| 892 |
5/5✓ 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.
|
1 | rightVertices[2] = Point3d(*xMax + *rightOffset, *yMin - *rightBelow, 0.0); |
| 893 |
5/5✓ 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.
|
1 | rightVertices[3] = Point3d(*xMax + *rightOffset, *yMax + *rightAbove, 0.0); |
| 894 | |||
| 895 | // transform vertices | ||
| 896 |
1/1✓ Branch 1 taken 1 time.
|
1 | leftVertices = t * leftVertices; |
| 897 |
1/1✓ Branch 1 taken 1 time.
|
1 | rightVertices = t * rightVertices; |
| 898 | |||
| 899 | // add two new objects | ||
| 900 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | IdfObject leftObject(IddObjectType::Shading_Zone_Detailed); |
| 901 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | IdfObject rightObject(IddObjectType::Shading_Zone_Detailed); |
| 902 | |||
| 903 | // // fields which map directly | ||
| 904 | // std::vector<std::pair<unsigned, unsigned>> fieldMap; | ||
| 905 | // // copy fields over directly | ||
| 906 | // mapFields(oldObject, leftObject, fieldMap); | ||
| 907 | // mapFields(oldObject, rightObject, fieldMap); | ||
| 908 | |||
| 909 | // set other fields | ||
| 910 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | leftObject.setString(Shading_Zone_DetailedFields::Name, oldObject.name().get() + " Left"); |
| 911 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | leftObject.setString(Shading_Zone_DetailedFields::BaseSurfaceName, surface->name().get()); |
| 912 |
1/1✓ Branch 1 taken 1 time.
|
1 | leftObject.setDouble(Shading_Zone_DetailedFields::NumberofVertices, 4); |
| 913 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | rightObject.setString(Shading_Zone_DetailedFields::Name, oldObject.name().get() + " Right"); |
| 914 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | rightObject.setString(Shading_Zone_DetailedFields::BaseSurfaceName, surface->name().get()); |
| 915 |
1/1✓ Branch 1 taken 1 time.
|
1 | rightObject.setDouble(Shading_Zone_DetailedFields::NumberofVertices, 4); |
| 916 | |||
| 917 | // swap old object with left one | ||
| 918 |
1/1✓ Branch 1 taken 1 time.
|
1 | bool ok = m_workspace.swap(oldObject, leftObject); |
| 919 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (ok) { |
| 920 |
4/6✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 13 not taken.
|
1 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::Shading_Zone_Detailed); |
| 921 | // set vertices | ||
| 922 |
1/1✓ Branch 1 taken 1 time.
|
1 | setVertices(Shading_Zone_DetailedFields::NumberofVertices + 1, oldObject, leftVertices); |
| 923 | } else { | ||
| 924 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 925 | ✗ | continue; | |
| 926 | ✗ | } | |
| 927 | |||
| 928 | // add right object | ||
| 929 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalWorkspaceObject w = m_workspace.addObject(rightObject); |
| 930 | 1 | OptionalWorkspaceObject workspaceObject; | |
| 931 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (w) { |
| 932 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | workspaceObject = m_workspace.getObject(w->handle()); |
| 933 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (workspaceObject) { |
| 934 | // set vertices | ||
| 935 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | setVertices(Shading_Zone_DetailedFields::NumberofVertices + 1, *w, rightVertices); |
| 936 | } else { | ||
| 937 | ✗ | LOG(Error, "Workspace object add failed"); | |
| 938 | ✗ | continue; | |
| 939 | ✗ | } | |
| 940 | } else { | ||
| 941 | ✗ | LOG(Error, "Workspace object add failed"); | |
| 942 | ✗ | continue; | |
| 943 | ✗ | } | |
| 944 | 104 | } | |
| 945 | |||
| 946 | 103 | return true; | |
| 947 | 103 | } | |
| 948 | |||
| 949 | // convert simple subsurfaces to detailed in the current system | ||
| 950 | 103 | bool GeometryTranslator::convertSimpleSubSurfaces() { | |
| 951 | // Window | ||
| 952 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 11 times.
✓ Branch 12 taken 103 times.
|
114 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Window)) { |
| 953 | |||
| 954 | // find surface | ||
| 955 |
1/1✓ Branch 1 taken 11 times.
|
11 | OptionalWorkspaceObject surface = oldObject.getTarget(WindowFields::BuildingSurfaceName); |
| 956 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
|
11 | if (!surface) { |
| 957 | ✗ | LOG(Error, "Could not find surface"); | |
| 958 | ✗ | continue; | |
| 959 | ✗ | } | |
| 960 | |||
| 961 | // get transformation from face coordinates to zone | ||
| 962 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | Transformation t = Transformation::alignFace(getVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, *surface)); |
| 963 | |||
| 964 | // simple params | ||
| 965 |
1/1✓ Branch 1 taken 11 times.
|
11 | OptionalDouble x0 = oldObject.getDouble(WindowFields::StartingXCoordinate, true); |
| 966 |
1/1✓ Branch 1 taken 11 times.
|
11 | OptionalDouble z0 = oldObject.getDouble(WindowFields::StartingZCoordinate, true); |
| 967 |
1/1✓ Branch 1 taken 11 times.
|
11 | OptionalDouble length = oldObject.getDouble(WindowFields::Length, true); |
| 968 |
1/1✓ Branch 1 taken 11 times.
|
11 | OptionalDouble height = oldObject.getDouble(WindowFields::Height, true); |
| 969 |
5/10✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 11 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 11 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 11 times.
|
11 | if (!x0 || !z0 || !length || !height) { |
| 970 | ✗ | LOG(Error, "Missing required fields"); | |
| 971 | ✗ | continue; | |
| 972 | ✗ | } | |
| 973 | |||
| 974 | // vertices | ||
| 975 |
1/1✓ Branch 1 taken 11 times.
|
11 | openstudio::Point3dVector faceVertices(4); |
| 976 |
4/4✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
|
11 | faceVertices[0] = Point3d(*x0, *z0 + *height, 0.0); |
| 977 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | faceVertices[1] = Point3d(*x0, *z0, 0.0); |
| 978 |
4/4✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
|
11 | faceVertices[2] = Point3d(*x0 + *length, *z0, 0.0); |
| 979 |
5/5✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
✓ Branch 13 taken 11 times.
|
11 | faceVertices[3] = Point3d(*x0 + *length, *z0 + *height, 0.0); |
| 980 | |||
| 981 | // transform vertices | ||
| 982 |
1/1✓ Branch 1 taken 11 times.
|
11 | faceVertices = t * faceVertices; |
| 983 | |||
| 984 | // add new object | ||
| 985 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | IdfObject newObject(IddObjectType::FenestrationSurface_Detailed); |
| 986 | |||
| 987 | // fields which map directly | ||
| 988 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 989 | {WindowFields::Name, FenestrationSurface_DetailedFields::Name}, | ||
| 990 | {WindowFields::ConstructionName, FenestrationSurface_DetailedFields::ConstructionName}, | ||
| 991 | {WindowFields::BuildingSurfaceName, FenestrationSurface_DetailedFields::BuildingSurfaceName}, | ||
| 992 | {WindowFields::FrameandDividerName, FenestrationSurface_DetailedFields::FrameandDividerName}, | ||
| 993 | {WindowFields::Multiplier, FenestrationSurface_DetailedFields::Multiplier}, | ||
| 994 |
1/1✓ Branch 1 taken 11 times.
|
22 | }; |
| 995 | |||
| 996 | // copy fields over directly | ||
| 997 |
1/1✓ Branch 1 taken 11 times.
|
11 | mapFields(oldObject, newObject, fieldMap); |
| 998 | |||
| 999 | // set other fields | ||
| 1000 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
22 | newObject.setString(FenestrationSurface_DetailedFields::SurfaceType, "Window"); |
| 1001 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
22 | newObject.setString(FenestrationSurface_DetailedFields::OutsideBoundaryConditionObject, ""); |
| 1002 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | newObject.setString(FenestrationSurface_DetailedFields::ViewFactortoGround, ""); |
| 1003 |
1/1✓ Branch 1 taken 11 times.
|
11 | newObject.setDouble(FenestrationSurface_DetailedFields::NumberofVertices, 4); |
| 1004 | |||
| 1005 | // swap old object with new one | ||
| 1006 |
1/1✓ Branch 1 taken 11 times.
|
11 | bool ok = m_workspace.swap(oldObject, newObject); |
| 1007 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | if (ok) { |
| 1008 |
4/6✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 11 times.
✗ Branch 13 not taken.
|
11 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::FenestrationSurface_Detailed); |
| 1009 | // set vertices | ||
| 1010 |
1/1✓ Branch 1 taken 11 times.
|
11 | setVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, oldObject, faceVertices); |
| 1011 | } else { | ||
| 1012 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 1013 | ✗ | continue; | |
| 1014 | ✗ | } | |
| 1015 | 114 | } | |
| 1016 | |||
| 1017 | // Door | ||
| 1018 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 103 times.
|
106 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Door)) { |
| 1019 | |||
| 1020 | // find surface | ||
| 1021 |
1/1✓ Branch 1 taken 3 times.
|
3 | OptionalWorkspaceObject surface = oldObject.getTarget(DoorFields::BuildingSurfaceName); |
| 1022 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (!surface) { |
| 1023 | ✗ | LOG(Error, "Could not find surface"); | |
| 1024 | ✗ | continue; | |
| 1025 | ✗ | } | |
| 1026 | |||
| 1027 | // get transformation from face coordinates to zone | ||
| 1028 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
3 | Transformation t = Transformation::alignFace(getVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, *surface)); |
| 1029 | |||
| 1030 | // simple params | ||
| 1031 |
1/1✓ Branch 1 taken 3 times.
|
3 | OptionalDouble x0 = oldObject.getDouble(DoorFields::StartingXCoordinate, true); |
| 1032 |
1/1✓ Branch 1 taken 3 times.
|
3 | OptionalDouble z0 = oldObject.getDouble(DoorFields::StartingZCoordinate, true); |
| 1033 |
1/1✓ Branch 1 taken 3 times.
|
3 | OptionalDouble length = oldObject.getDouble(DoorFields::Length, true); |
| 1034 |
1/1✓ Branch 1 taken 3 times.
|
3 | OptionalDouble height = oldObject.getDouble(DoorFields::Height, true); |
| 1035 |
5/10✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 3 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 3 times.
|
3 | if (!x0 || !z0 || !length || !height) { |
| 1036 | ✗ | LOG(Error, "Missing required fields"); | |
| 1037 | ✗ | continue; | |
| 1038 | ✗ | } | |
| 1039 | |||
| 1040 | // vertices | ||
| 1041 |
1/1✓ Branch 1 taken 3 times.
|
3 | openstudio::Point3dVector faceVertices(4); |
| 1042 |
4/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
|
3 | faceVertices[0] = Point3d(*x0, *z0 + *height, 0.0); |
| 1043 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
3 | faceVertices[1] = Point3d(*x0, *z0, 0.0); |
| 1044 |
4/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
|
3 | faceVertices[2] = Point3d(*x0 + *length, *z0, 0.0); |
| 1045 |
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 | faceVertices[3] = Point3d(*x0 + *length, *z0 + *height, 0.0); |
| 1046 | |||
| 1047 | // transform vertices | ||
| 1048 |
1/1✓ Branch 1 taken 3 times.
|
3 | faceVertices = t * faceVertices; |
| 1049 | |||
| 1050 | // add new object | ||
| 1051 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | IdfObject newObject(IddObjectType::FenestrationSurface_Detailed); |
| 1052 | |||
| 1053 | // fields which map directly | ||
| 1054 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 1055 | {DoorFields::Name, FenestrationSurface_DetailedFields::Name}, | ||
| 1056 | {DoorFields::ConstructionName, FenestrationSurface_DetailedFields::ConstructionName}, | ||
| 1057 | {DoorFields::BuildingSurfaceName, FenestrationSurface_DetailedFields::BuildingSurfaceName}, | ||
| 1058 | {DoorFields::Multiplier, FenestrationSurface_DetailedFields::Multiplier}, | ||
| 1059 |
1/1✓ Branch 1 taken 3 times.
|
6 | }; |
| 1060 | |||
| 1061 | // copy fields over directly | ||
| 1062 |
1/1✓ Branch 1 taken 3 times.
|
3 | mapFields(oldObject, newObject, fieldMap); |
| 1063 | |||
| 1064 | // set other fields | ||
| 1065 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
6 | newObject.setString(FenestrationSurface_DetailedFields::SurfaceType, "Door"); |
| 1066 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
6 | newObject.setString(FenestrationSurface_DetailedFields::OutsideBoundaryConditionObject, ""); |
| 1067 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | newObject.setString(FenestrationSurface_DetailedFields::ViewFactortoGround, ""); |
| 1068 |
1/1✓ Branch 1 taken 3 times.
|
3 | newObject.setDouble(FenestrationSurface_DetailedFields::NumberofVertices, 4); |
| 1069 | |||
| 1070 | // swap old object with new one | ||
| 1071 |
1/1✓ Branch 1 taken 3 times.
|
3 | bool ok = m_workspace.swap(oldObject, newObject); |
| 1072 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (ok) { |
| 1073 |
4/6✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 3 times.
✗ Branch 13 not taken.
|
3 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::FenestrationSurface_Detailed); |
| 1074 | // set vertices | ||
| 1075 |
1/1✓ Branch 1 taken 3 times.
|
3 | setVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, oldObject, faceVertices); |
| 1076 | } else { | ||
| 1077 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 1078 | ✗ | continue; | |
| 1079 | ✗ | } | |
| 1080 | 106 | } | |
| 1081 | |||
| 1082 | // GlazedDoor | ||
| 1083 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 1 time.
✓ Branch 12 taken 103 times.
|
104 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::GlazedDoor)) { |
| 1084 | |||
| 1085 | // find surface | ||
| 1086 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalWorkspaceObject surface = oldObject.getTarget(GlazedDoorFields::BuildingSurfaceName); |
| 1087 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!surface) { |
| 1088 | ✗ | LOG(Error, "Could not find surface"); | |
| 1089 | ✗ | continue; | |
| 1090 | ✗ | } | |
| 1091 | |||
| 1092 | // get transformation from face coordinates to zone | ||
| 1093 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | Transformation t = Transformation::alignFace(getVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, *surface)); |
| 1094 | |||
| 1095 | // simple params | ||
| 1096 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble x0 = oldObject.getDouble(GlazedDoorFields::StartingXCoordinate, true); |
| 1097 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble z0 = oldObject.getDouble(GlazedDoorFields::StartingZCoordinate, true); |
| 1098 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble length = oldObject.getDouble(GlazedDoorFields::Length, true); |
| 1099 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble height = oldObject.getDouble(GlazedDoorFields::Height, true); |
| 1100 |
5/10✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 time.
|
1 | if (!x0 || !z0 || !length || !height) { |
| 1101 | ✗ | LOG(Error, "Missing required fields"); | |
| 1102 | ✗ | continue; | |
| 1103 | ✗ | } | |
| 1104 | |||
| 1105 | // vertices | ||
| 1106 |
1/1✓ Branch 1 taken 1 time.
|
1 | openstudio::Point3dVector faceVertices(4); |
| 1107 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | faceVertices[0] = Point3d(*x0, *z0 + *height, 0.0); |
| 1108 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | faceVertices[1] = Point3d(*x0, *z0, 0.0); |
| 1109 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | faceVertices[2] = Point3d(*x0 + *length, *z0, 0.0); |
| 1110 |
5/5✓ 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.
|
1 | faceVertices[3] = Point3d(*x0 + *length, *z0 + *height, 0.0); |
| 1111 | |||
| 1112 | // transform vertices | ||
| 1113 |
1/1✓ Branch 1 taken 1 time.
|
1 | faceVertices = t * faceVertices; |
| 1114 | |||
| 1115 | // add new object | ||
| 1116 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | IdfObject newObject(IddObjectType::FenestrationSurface_Detailed); |
| 1117 | |||
| 1118 | // fields which map directly | ||
| 1119 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 1120 | {GlazedDoorFields::Name, FenestrationSurface_DetailedFields::Name}, | ||
| 1121 | {GlazedDoorFields::ConstructionName, FenestrationSurface_DetailedFields::ConstructionName}, | ||
| 1122 | {GlazedDoorFields::BuildingSurfaceName, FenestrationSurface_DetailedFields::BuildingSurfaceName}, | ||
| 1123 | {GlazedDoorFields::FrameandDividerName, FenestrationSurface_DetailedFields::FrameandDividerName}, | ||
| 1124 | {GlazedDoorFields::Multiplier, FenestrationSurface_DetailedFields::Multiplier}, | ||
| 1125 |
1/1✓ Branch 1 taken 1 time.
|
2 | }; |
| 1126 | |||
| 1127 | // copy fields over directly | ||
| 1128 |
1/1✓ Branch 1 taken 1 time.
|
1 | mapFields(oldObject, newObject, fieldMap); |
| 1129 | |||
| 1130 | // set other fields | ||
| 1131 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | newObject.setString(FenestrationSurface_DetailedFields::SurfaceType, "GlassDoor"); |
| 1132 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | newObject.setString(FenestrationSurface_DetailedFields::OutsideBoundaryConditionObject, ""); |
| 1133 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | newObject.setString(FenestrationSurface_DetailedFields::ViewFactortoGround, ""); |
| 1134 |
1/1✓ Branch 1 taken 1 time.
|
1 | newObject.setDouble(FenestrationSurface_DetailedFields::NumberofVertices, 4); |
| 1135 | |||
| 1136 | // swap old object with new one | ||
| 1137 |
1/1✓ Branch 1 taken 1 time.
|
1 | bool ok = m_workspace.swap(oldObject, newObject); |
| 1138 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (ok) { |
| 1139 |
4/6✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 13 not taken.
|
1 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::FenestrationSurface_Detailed); |
| 1140 | // set vertices | ||
| 1141 |
1/1✓ Branch 1 taken 1 time.
|
1 | setVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, oldObject, faceVertices); |
| 1142 | } else { | ||
| 1143 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 1144 | ✗ | continue; | |
| 1145 | ✗ | } | |
| 1146 | 104 | } | |
| 1147 | |||
| 1148 | // Window:Interzone | ||
| 1149 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 5 times.
✓ Branch 12 taken 103 times.
|
108 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Window_Interzone)) { |
| 1150 | |||
| 1151 | // find surface | ||
| 1152 |
1/1✓ Branch 1 taken 5 times.
|
5 | OptionalWorkspaceObject surface = oldObject.getTarget(Window_InterzoneFields::BuildingSurfaceName); |
| 1153 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
|
5 | if (!surface) { |
| 1154 | ✗ | LOG(Error, "Could not find surface"); | |
| 1155 | ✗ | continue; | |
| 1156 | ✗ | } | |
| 1157 | |||
| 1158 | // get transformation from face coordinates to zone | ||
| 1159 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | Transformation t = Transformation::alignFace(getVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, *surface)); |
| 1160 | |||
| 1161 | // simple params | ||
| 1162 |
1/1✓ Branch 1 taken 5 times.
|
5 | OptionalDouble x0 = oldObject.getDouble(Window_InterzoneFields::StartingXCoordinate, true); |
| 1163 |
1/1✓ Branch 1 taken 5 times.
|
5 | OptionalDouble z0 = oldObject.getDouble(Window_InterzoneFields::StartingZCoordinate, true); |
| 1164 |
1/1✓ Branch 1 taken 5 times.
|
5 | OptionalDouble length = oldObject.getDouble(Window_InterzoneFields::Length, true); |
| 1165 |
1/1✓ Branch 1 taken 5 times.
|
5 | OptionalDouble height = oldObject.getDouble(Window_InterzoneFields::Height, true); |
| 1166 |
5/10✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 5 times.
|
5 | if (!x0 || !z0 || !length || !height) { |
| 1167 | ✗ | LOG(Error, "Missing required fields"); | |
| 1168 | ✗ | continue; | |
| 1169 | ✗ | } | |
| 1170 | |||
| 1171 | // vertices | ||
| 1172 |
1/1✓ Branch 1 taken 5 times.
|
5 | openstudio::Point3dVector faceVertices(4); |
| 1173 |
4/4✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 10 taken 5 times.
|
5 | faceVertices[0] = Point3d(*x0, *z0 + *height, 0.0); |
| 1174 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | faceVertices[1] = Point3d(*x0, *z0, 0.0); |
| 1175 |
4/4✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 10 taken 5 times.
|
5 | faceVertices[2] = Point3d(*x0 + *length, *z0, 0.0); |
| 1176 |
5/5✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 10 taken 5 times.
✓ Branch 13 taken 5 times.
|
5 | faceVertices[3] = Point3d(*x0 + *length, *z0 + *height, 0.0); |
| 1177 | |||
| 1178 | // transform vertices | ||
| 1179 |
1/1✓ Branch 1 taken 5 times.
|
5 | faceVertices = t * faceVertices; |
| 1180 | |||
| 1181 | // add new object | ||
| 1182 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
5 | IdfObject newObject(IddObjectType::FenestrationSurface_Detailed); |
| 1183 | |||
| 1184 | // fields which map directly | ||
| 1185 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 1186 | {Window_InterzoneFields::Name, FenestrationSurface_DetailedFields::Name}, | ||
| 1187 | {Window_InterzoneFields::ConstructionName, FenestrationSurface_DetailedFields::ConstructionName}, | ||
| 1188 | {Window_InterzoneFields::BuildingSurfaceName, FenestrationSurface_DetailedFields::BuildingSurfaceName}, | ||
| 1189 | {Window_InterzoneFields::OutsideBoundaryConditionObject, FenestrationSurface_DetailedFields::OutsideBoundaryConditionObject}, | ||
| 1190 | {Window_InterzoneFields::Multiplier, FenestrationSurface_DetailedFields::Multiplier}, | ||
| 1191 |
1/1✓ Branch 1 taken 5 times.
|
10 | }; |
| 1192 | |||
| 1193 | // copy fields over directly | ||
| 1194 |
1/1✓ Branch 1 taken 5 times.
|
5 | mapFields(oldObject, newObject, fieldMap); |
| 1195 | |||
| 1196 | // set other fields | ||
| 1197 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
10 | newObject.setString(FenestrationSurface_DetailedFields::SurfaceType, "Window"); |
| 1198 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
5 | newObject.setString(FenestrationSurface_DetailedFields::ViewFactortoGround, ""); |
| 1199 |
1/1✓ Branch 1 taken 5 times.
|
5 | newObject.setDouble(FenestrationSurface_DetailedFields::NumberofVertices, 4); |
| 1200 | |||
| 1201 | // swap old object with new one | ||
| 1202 |
1/1✓ Branch 1 taken 5 times.
|
5 | bool ok = m_workspace.swap(oldObject, newObject); |
| 1203 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if (ok) { |
| 1204 |
4/6✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 13 not taken.
|
5 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::FenestrationSurface_Detailed); |
| 1205 | // set vertices | ||
| 1206 |
1/1✓ Branch 1 taken 5 times.
|
5 | setVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, oldObject, faceVertices); |
| 1207 | } else { | ||
| 1208 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 1209 | ✗ | continue; | |
| 1210 | ✗ | } | |
| 1211 | 108 | } | |
| 1212 | |||
| 1213 | // Door:Interzone | ||
| 1214 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 1 time.
✓ Branch 12 taken 103 times.
|
104 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Door_Interzone)) { |
| 1215 | |||
| 1216 | // find surface | ||
| 1217 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalWorkspaceObject surface = oldObject.getTarget(Door_InterzoneFields::BuildingSurfaceName); |
| 1218 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!surface) { |
| 1219 | ✗ | LOG(Error, "Could not find surface"); | |
| 1220 | ✗ | continue; | |
| 1221 | ✗ | } | |
| 1222 | |||
| 1223 | // get transformation from face coordinates to zone | ||
| 1224 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | Transformation t = Transformation::alignFace(getVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, *surface)); |
| 1225 | |||
| 1226 | // simple params | ||
| 1227 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble x0 = oldObject.getDouble(Door_InterzoneFields::StartingXCoordinate, true); |
| 1228 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble z0 = oldObject.getDouble(Door_InterzoneFields::StartingZCoordinate, true); |
| 1229 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble length = oldObject.getDouble(Door_InterzoneFields::Length, true); |
| 1230 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble height = oldObject.getDouble(Door_InterzoneFields::Height, true); |
| 1231 |
5/10✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 time.
|
1 | if (!x0 || !z0 || !length || !height) { |
| 1232 | ✗ | LOG(Error, "Missing required fields"); | |
| 1233 | ✗ | continue; | |
| 1234 | ✗ | } | |
| 1235 | |||
| 1236 | // vertices | ||
| 1237 |
1/1✓ Branch 1 taken 1 time.
|
1 | openstudio::Point3dVector faceVertices(4); |
| 1238 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | faceVertices[0] = Point3d(*x0, *z0 + *height, 0.0); |
| 1239 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | faceVertices[1] = Point3d(*x0, *z0, 0.0); |
| 1240 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | faceVertices[2] = Point3d(*x0 + *length, *z0, 0.0); |
| 1241 |
5/5✓ 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.
|
1 | faceVertices[3] = Point3d(*x0 + *length, *z0 + *height, 0.0); |
| 1242 | |||
| 1243 | // transform vertices | ||
| 1244 |
1/1✓ Branch 1 taken 1 time.
|
1 | faceVertices = t * faceVertices; |
| 1245 | |||
| 1246 | // add new object | ||
| 1247 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | IdfObject newObject(IddObjectType::FenestrationSurface_Detailed); |
| 1248 | |||
| 1249 | // fields which map directly | ||
| 1250 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 1251 | {Door_InterzoneFields::Name, FenestrationSurface_DetailedFields::Name}, | ||
| 1252 | {Door_InterzoneFields::ConstructionName, FenestrationSurface_DetailedFields::ConstructionName}, | ||
| 1253 | {Door_InterzoneFields::BuildingSurfaceName, FenestrationSurface_DetailedFields::BuildingSurfaceName}, | ||
| 1254 | {Door_InterzoneFields::OutsideBoundaryConditionObject, FenestrationSurface_DetailedFields::OutsideBoundaryConditionObject}, | ||
| 1255 | {Door_InterzoneFields::Multiplier, FenestrationSurface_DetailedFields::Multiplier}, | ||
| 1256 |
1/1✓ Branch 1 taken 1 time.
|
2 | }; |
| 1257 | |||
| 1258 | // copy fields over directly | ||
| 1259 |
1/1✓ Branch 1 taken 1 time.
|
1 | mapFields(oldObject, newObject, fieldMap); |
| 1260 | |||
| 1261 | // set other fields | ||
| 1262 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | newObject.setString(FenestrationSurface_DetailedFields::SurfaceType, "Door"); |
| 1263 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | newObject.setString(FenestrationSurface_DetailedFields::ViewFactortoGround, ""); |
| 1264 |
1/1✓ Branch 1 taken 1 time.
|
1 | newObject.setDouble(FenestrationSurface_DetailedFields::NumberofVertices, 4); |
| 1265 | |||
| 1266 | // swap old object with new one | ||
| 1267 |
1/1✓ Branch 1 taken 1 time.
|
1 | bool ok = m_workspace.swap(oldObject, newObject); |
| 1268 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (ok) { |
| 1269 |
4/6✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 13 not taken.
|
1 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::FenestrationSurface_Detailed); |
| 1270 | // set vertices | ||
| 1271 |
1/1✓ Branch 1 taken 1 time.
|
1 | setVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, oldObject, faceVertices); |
| 1272 | } else { | ||
| 1273 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 1274 | ✗ | continue; | |
| 1275 | ✗ | } | |
| 1276 | 104 | } | |
| 1277 | |||
| 1278 | // GlazedDoor:Interzone | ||
| 1279 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 1 time.
✓ Branch 12 taken 103 times.
|
104 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::GlazedDoor_Interzone)) { |
| 1280 | |||
| 1281 | // find surface | ||
| 1282 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalWorkspaceObject surface = oldObject.getTarget(GlazedDoor_InterzoneFields::BuildingSurfaceName); |
| 1283 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!surface) { |
| 1284 | ✗ | LOG(Error, "Could not find surface"); | |
| 1285 | ✗ | continue; | |
| 1286 | ✗ | } | |
| 1287 | |||
| 1288 | // get transformation from face coordinates to zone | ||
| 1289 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | Transformation t = Transformation::alignFace(getVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, *surface)); |
| 1290 | |||
| 1291 | // simple params | ||
| 1292 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble x0 = oldObject.getDouble(GlazedDoor_InterzoneFields::StartingXCoordinate, true); |
| 1293 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble z0 = oldObject.getDouble(GlazedDoor_InterzoneFields::StartingZCoordinate, true); |
| 1294 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble length = oldObject.getDouble(GlazedDoor_InterzoneFields::Length, true); |
| 1295 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble height = oldObject.getDouble(GlazedDoor_InterzoneFields::Height, true); |
| 1296 |
5/10✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 time.
|
1 | if (!x0 || !z0 || !length || !height) { |
| 1297 | ✗ | LOG(Error, "Missing required fields"); | |
| 1298 | ✗ | continue; | |
| 1299 | ✗ | } | |
| 1300 | |||
| 1301 | // vertices | ||
| 1302 |
1/1✓ Branch 1 taken 1 time.
|
1 | openstudio::Point3dVector faceVertices(4); |
| 1303 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | faceVertices[0] = Point3d(*x0, *z0 + *height, 0.0); |
| 1304 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | faceVertices[1] = Point3d(*x0, *z0, 0.0); |
| 1305 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | faceVertices[2] = Point3d(*x0 + *length, *z0, 0.0); |
| 1306 |
5/5✓ 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.
|
1 | faceVertices[3] = Point3d(*x0 + *length, *z0 + *height, 0.0); |
| 1307 | |||
| 1308 | // transform vertices | ||
| 1309 |
1/1✓ Branch 1 taken 1 time.
|
1 | faceVertices = t * faceVertices; |
| 1310 | |||
| 1311 | // add new object | ||
| 1312 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | IdfObject newObject(IddObjectType::FenestrationSurface_Detailed); |
| 1313 | |||
| 1314 | // fields which map directly | ||
| 1315 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 1316 | {GlazedDoor_InterzoneFields::Name, FenestrationSurface_DetailedFields::Name}, | ||
| 1317 | {GlazedDoor_InterzoneFields::ConstructionName, FenestrationSurface_DetailedFields::ConstructionName}, | ||
| 1318 | {GlazedDoor_InterzoneFields::BuildingSurfaceName, FenestrationSurface_DetailedFields::BuildingSurfaceName}, | ||
| 1319 | {GlazedDoor_InterzoneFields::OutsideBoundaryConditionObject, FenestrationSurface_DetailedFields::OutsideBoundaryConditionObject}, | ||
| 1320 | {GlazedDoor_InterzoneFields::Multiplier, FenestrationSurface_DetailedFields::Multiplier}, | ||
| 1321 |
1/1✓ Branch 1 taken 1 time.
|
2 | }; |
| 1322 | |||
| 1323 | // copy fields over directly | ||
| 1324 |
1/1✓ Branch 1 taken 1 time.
|
1 | mapFields(oldObject, newObject, fieldMap); |
| 1325 | |||
| 1326 | // set other fields | ||
| 1327 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | newObject.setString(FenestrationSurface_DetailedFields::SurfaceType, "GlassDoor"); |
| 1328 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | newObject.setString(FenestrationSurface_DetailedFields::ViewFactortoGround, ""); |
| 1329 |
1/1✓ Branch 1 taken 1 time.
|
1 | newObject.setDouble(FenestrationSurface_DetailedFields::NumberofVertices, 4); |
| 1330 | |||
| 1331 | // swap old object with new one | ||
| 1332 |
1/1✓ Branch 1 taken 1 time.
|
1 | bool ok = m_workspace.swap(oldObject, newObject); |
| 1333 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (ok) { |
| 1334 |
4/6✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 13 not taken.
|
1 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::FenestrationSurface_Detailed); |
| 1335 | // set vertices | ||
| 1336 |
1/1✓ Branch 1 taken 1 time.
|
1 | setVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, oldObject, faceVertices); |
| 1337 | } else { | ||
| 1338 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 1339 | ✗ | continue; | |
| 1340 | ✗ | } | |
| 1341 | 104 | } | |
| 1342 | 103 | return true; | |
| 1343 | } | ||
| 1344 | |||
| 1345 | // convert simple surfaces to detailed in the current system | ||
| 1346 | 103 | bool GeometryTranslator::convertSimpleSurfaces(const CoordinateChange& coordChange) { | |
| 1347 | |||
| 1348 | // building transformation | ||
| 1349 |
1/1✓ Branch 1 taken 103 times.
|
103 | Transformation buildingTransformation = this->buildingTransformation(); |
| 1350 | |||
| 1351 | // Wall::Detailed | ||
| 1352 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 103 times.
|
105 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Wall_Detailed)) { |
| 1353 | |||
| 1354 | // find zone | ||
| 1355 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalWorkspaceObject zone = oldObject.getTarget(Wall_DetailedFields::ZoneName); |
| 1356 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!zone) { |
| 1357 | ✗ | LOG(Error, "Could not find zone"); | |
| 1358 | ✗ | continue; | |
| 1359 | ✗ | } | |
| 1360 | |||
| 1361 | // get transformation | ||
| 1362 |
1/1✓ Branch 1 taken 2 times.
|
2 | Transformation t; |
| 1363 |
2/3✓ Branch 1 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
2 | if (coordChange == CoordinateChange::AbsoluteToRelative) { |
| 1364 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1365 | ✗ | t = zoneTransformation.inverse() * buildingTransformation.inverse(); | |
| 1366 |
2/3✓ Branch 2 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
|
2 | } else if (coordChange == CoordinateChange::RelativeToAbsolute) { |
| 1367 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1368 | ✗ | t = buildingTransformation * zoneTransformation; | |
| 1369 | ✗ | } | |
| 1370 | |||
| 1371 | // get vertices | ||
| 1372 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | Point3dVector vertices = t * getVertices(Wall_DetailedFields::NumberofVertices + 1, oldObject); |
| 1373 | |||
| 1374 | // new object | ||
| 1375 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | IdfObject newObject(IddObjectType::BuildingSurface_Detailed); |
| 1376 | |||
| 1377 | // fields which map directly | ||
| 1378 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 1379 | {Wall_DetailedFields::Name, BuildingSurface_DetailedFields::Name}, | ||
| 1380 | {Wall_DetailedFields::ConstructionName, BuildingSurface_DetailedFields::ConstructionName}, | ||
| 1381 | {Wall_DetailedFields::ZoneName, BuildingSurface_DetailedFields::ZoneName}, | ||
| 1382 | {Wall_DetailedFields::OutsideBoundaryCondition, BuildingSurface_DetailedFields::OutsideBoundaryCondition}, | ||
| 1383 | {Wall_DetailedFields::OutsideBoundaryConditionObject, BuildingSurface_DetailedFields::OutsideBoundaryConditionObject}, | ||
| 1384 | {Wall_DetailedFields::SunExposure, BuildingSurface_DetailedFields::SunExposure}, | ||
| 1385 | {Wall_DetailedFields::WindExposure, BuildingSurface_DetailedFields::WindExposure}, | ||
| 1386 | {Wall_DetailedFields::ViewFactortoGround, BuildingSurface_DetailedFields::ViewFactortoGround}, | ||
| 1387 | {Wall_DetailedFields::NumberofVertices, BuildingSurface_DetailedFields::NumberofVertices}, | ||
| 1388 |
1/1✓ Branch 1 taken 2 times.
|
4 | }; |
| 1389 | |||
| 1390 | // copy fields over directly | ||
| 1391 |
1/1✓ Branch 1 taken 2 times.
|
2 | mapFields(oldObject, newObject, fieldMap); |
| 1392 | |||
| 1393 | // set other fields | ||
| 1394 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | newObject.setString(BuildingSurface_DetailedFields::SurfaceType, "Wall"); |
| 1395 | |||
| 1396 | // swap old object with new one | ||
| 1397 |
1/1✓ Branch 1 taken 2 times.
|
2 | bool ok = m_workspace.swap(oldObject, newObject); |
| 1398 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (ok) { |
| 1399 |
4/6✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 13 not taken.
|
2 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::BuildingSurface_Detailed); |
| 1400 | // set vertices | ||
| 1401 |
1/1✓ Branch 1 taken 2 times.
|
2 | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, oldObject, vertices); |
| 1402 | } else { | ||
| 1403 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 1404 | ✗ | continue; | |
| 1405 | ✗ | } | |
| 1406 | |||
| 1407 | // remove old object | ||
| 1408 | //m_workspace.removeObject(oldObject); | ||
| 1409 | 105 | } | |
| 1410 | |||
| 1411 | // RoofCeiling::Detailed | ||
| 1412 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 103 times.
|
105 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::RoofCeiling_Detailed)) { |
| 1413 | |||
| 1414 | // find zone | ||
| 1415 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalWorkspaceObject zone = oldObject.getTarget(Wall_DetailedFields::ZoneName); |
| 1416 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!zone) { |
| 1417 | ✗ | LOG(Error, "Could not find zone"); | |
| 1418 | ✗ | continue; | |
| 1419 | ✗ | } | |
| 1420 | |||
| 1421 | // get transformation | ||
| 1422 |
1/1✓ Branch 1 taken 2 times.
|
2 | Transformation t; |
| 1423 |
2/3✓ Branch 1 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
2 | if (coordChange == CoordinateChange::AbsoluteToRelative) { |
| 1424 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1425 | ✗ | t = zoneTransformation.inverse() * buildingTransformation.inverse(); | |
| 1426 |
2/3✓ Branch 2 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
|
2 | } else if (coordChange == CoordinateChange::RelativeToAbsolute) { |
| 1427 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1428 | ✗ | t = buildingTransformation * zoneTransformation; | |
| 1429 | ✗ | } | |
| 1430 | |||
| 1431 | // get vertices | ||
| 1432 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | Point3dVector vertices = t * getVertices(RoofCeiling_DetailedFields::NumberofVertices + 1, oldObject); |
| 1433 | |||
| 1434 | // new object | ||
| 1435 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | IdfObject newObject(IddObjectType::BuildingSurface_Detailed); |
| 1436 | |||
| 1437 | // fields which map directly | ||
| 1438 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 1439 | {RoofCeiling_DetailedFields::Name, BuildingSurface_DetailedFields::Name}, | ||
| 1440 | {RoofCeiling_DetailedFields::ConstructionName, BuildingSurface_DetailedFields::ConstructionName}, | ||
| 1441 | {RoofCeiling_DetailedFields::ZoneName, BuildingSurface_DetailedFields::ZoneName}, | ||
| 1442 | {RoofCeiling_DetailedFields::OutsideBoundaryCondition, BuildingSurface_DetailedFields::OutsideBoundaryCondition}, | ||
| 1443 | {RoofCeiling_DetailedFields::OutsideBoundaryConditionObject, BuildingSurface_DetailedFields::OutsideBoundaryConditionObject}, | ||
| 1444 | {RoofCeiling_DetailedFields::SunExposure, BuildingSurface_DetailedFields::SunExposure}, | ||
| 1445 | {RoofCeiling_DetailedFields::WindExposure, BuildingSurface_DetailedFields::WindExposure}, | ||
| 1446 | {RoofCeiling_DetailedFields::ViewFactortoGround, BuildingSurface_DetailedFields::ViewFactortoGround}, | ||
| 1447 | {RoofCeiling_DetailedFields::NumberofVertices, BuildingSurface_DetailedFields::NumberofVertices}, | ||
| 1448 |
1/1✓ Branch 1 taken 2 times.
|
4 | }; |
| 1449 | |||
| 1450 | // copy fields over directly | ||
| 1451 |
1/1✓ Branch 1 taken 2 times.
|
2 | mapFields(oldObject, newObject, fieldMap); |
| 1452 | |||
| 1453 | // set other fields | ||
| 1454 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | newObject.setString(BuildingSurface_DetailedFields::SurfaceType, "Roof"); |
| 1455 | |||
| 1456 | // swap old object with new one | ||
| 1457 |
1/1✓ Branch 1 taken 2 times.
|
2 | bool ok = m_workspace.swap(oldObject, newObject); |
| 1458 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (ok) { |
| 1459 |
4/6✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 13 not taken.
|
2 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::BuildingSurface_Detailed); |
| 1460 | // set vertices | ||
| 1461 |
1/1✓ Branch 1 taken 2 times.
|
2 | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, oldObject, vertices); |
| 1462 | } else { | ||
| 1463 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 1464 | ✗ | continue; | |
| 1465 | ✗ | } | |
| 1466 | |||
| 1467 | // remove old object | ||
| 1468 | //m_workspace.removeObject(oldObject); | ||
| 1469 | 105 | } | |
| 1470 | |||
| 1471 | // Floor::Detailed | ||
| 1472 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 103 times.
|
105 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Floor_Detailed)) { |
| 1473 | |||
| 1474 | // find zone | ||
| 1475 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalWorkspaceObject zone = oldObject.getTarget(Floor_DetailedFields::ZoneName); |
| 1476 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!zone) { |
| 1477 | ✗ | LOG(Error, "Could not find zone"); | |
| 1478 | ✗ | continue; | |
| 1479 | ✗ | } | |
| 1480 | |||
| 1481 | // get transformation | ||
| 1482 |
1/1✓ Branch 1 taken 2 times.
|
2 | Transformation t; |
| 1483 |
2/3✓ Branch 1 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
2 | if (coordChange == CoordinateChange::AbsoluteToRelative) { |
| 1484 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1485 | ✗ | t = zoneTransformation.inverse() * buildingTransformation.inverse(); | |
| 1486 |
2/3✓ Branch 2 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
|
2 | } else if (coordChange == CoordinateChange::RelativeToAbsolute) { |
| 1487 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1488 | ✗ | t = buildingTransformation * zoneTransformation; | |
| 1489 | ✗ | } | |
| 1490 | |||
| 1491 | // get vertices | ||
| 1492 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | Point3dVector vertices = t * getVertices(Floor_DetailedFields::NumberofVertices + 1, oldObject); |
| 1493 | |||
| 1494 | // new object | ||
| 1495 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | IdfObject newObject(IddObjectType::BuildingSurface_Detailed); |
| 1496 | |||
| 1497 | // fields which map directly | ||
| 1498 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 1499 | {Floor_DetailedFields::Name, BuildingSurface_DetailedFields::Name}, | ||
| 1500 | {Floor_DetailedFields::ConstructionName, BuildingSurface_DetailedFields::ConstructionName}, | ||
| 1501 | {Floor_DetailedFields::ZoneName, BuildingSurface_DetailedFields::ZoneName}, | ||
| 1502 | {Floor_DetailedFields::OutsideBoundaryCondition, BuildingSurface_DetailedFields::OutsideBoundaryCondition}, | ||
| 1503 | {Floor_DetailedFields::OutsideBoundaryConditionObject, BuildingSurface_DetailedFields::OutsideBoundaryConditionObject}, | ||
| 1504 | {Floor_DetailedFields::SunExposure, BuildingSurface_DetailedFields::SunExposure}, | ||
| 1505 | {Floor_DetailedFields::WindExposure, BuildingSurface_DetailedFields::WindExposure}, | ||
| 1506 | {Floor_DetailedFields::ViewFactortoGround, BuildingSurface_DetailedFields::ViewFactortoGround}, | ||
| 1507 | {Floor_DetailedFields::NumberofVertices, BuildingSurface_DetailedFields::NumberofVertices}, | ||
| 1508 |
1/1✓ Branch 1 taken 2 times.
|
4 | }; |
| 1509 | |||
| 1510 | // copy fields over directly | ||
| 1511 |
1/1✓ Branch 1 taken 2 times.
|
2 | mapFields(oldObject, newObject, fieldMap); |
| 1512 | |||
| 1513 | // set other fields | ||
| 1514 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | newObject.setString(BuildingSurface_DetailedFields::SurfaceType, "Floor"); |
| 1515 | |||
| 1516 | // swap old object with new one | ||
| 1517 |
1/1✓ Branch 1 taken 2 times.
|
2 | bool ok = m_workspace.swap(oldObject, newObject); |
| 1518 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (ok) { |
| 1519 |
4/6✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 13 not taken.
|
2 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::BuildingSurface_Detailed); |
| 1520 | // set vertices | ||
| 1521 |
1/1✓ Branch 1 taken 2 times.
|
2 | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, oldObject, vertices); |
| 1522 | } else { | ||
| 1523 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 1524 | ✗ | continue; | |
| 1525 | ✗ | } | |
| 1526 | |||
| 1527 | // remove old object | ||
| 1528 | //m_workspace.removeObject(oldObject); | ||
| 1529 | 105 | } | |
| 1530 | |||
| 1531 | // Wall:Exterior | ||
| 1532 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 12 times.
✓ Branch 12 taken 103 times.
|
115 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Wall_Exterior)) { |
| 1533 | |||
| 1534 | // find zone | ||
| 1535 |
1/1✓ Branch 1 taken 12 times.
|
12 | OptionalWorkspaceObject zone = oldObject.getTarget(Wall_ExteriorFields::ZoneName); |
| 1536 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
|
12 | if (!zone) { |
| 1537 | ✗ | LOG(Error, "Could not find zone"); | |
| 1538 | ✗ | continue; | |
| 1539 | ✗ | } | |
| 1540 | |||
| 1541 | // get simple params | ||
| 1542 |
1/1✓ Branch 1 taken 12 times.
|
12 | OptionalDouble azimuth = oldObject.getDouble(Wall_ExteriorFields::AzimuthAngle, true); |
| 1543 |
1/1✓ Branch 1 taken 12 times.
|
12 | OptionalDouble tilt = oldObject.getDouble(Wall_ExteriorFields::TiltAngle, true); |
| 1544 |
1/1✓ Branch 1 taken 12 times.
|
12 | OptionalDouble x0 = oldObject.getDouble(Wall_ExteriorFields::StartingXCoordinate, true); |
| 1545 |
1/1✓ Branch 1 taken 12 times.
|
12 | OptionalDouble y0 = oldObject.getDouble(Wall_ExteriorFields::StartingYCoordinate, true); |
| 1546 |
1/1✓ Branch 1 taken 12 times.
|
12 | OptionalDouble z0 = oldObject.getDouble(Wall_ExteriorFields::StartingZCoordinate, true); |
| 1547 |
1/1✓ Branch 1 taken 12 times.
|
12 | OptionalDouble length = oldObject.getDouble(Wall_ExteriorFields::Length, true); |
| 1548 |
1/1✓ Branch 1 taken 12 times.
|
12 | OptionalDouble height = oldObject.getDouble(Wall_ExteriorFields::Height, true); |
| 1549 | |||
| 1550 |
8/16✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 12 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 12 times.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 12 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 12 times.
|
12 | if (!azimuth || !tilt || !x0 || !y0 || !z0 || !length || !height) { |
| 1551 | ✗ | LOG(Error, "Missing required fields"); | |
| 1552 | ✗ | continue; | |
| 1553 | ✗ | } | |
| 1554 | |||
| 1555 | // get transformation | ||
| 1556 |
1/1✓ Branch 1 taken 12 times.
|
12 | Transformation t; |
| 1557 |
2/3✓ Branch 1 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
|
12 | if (coordChange == CoordinateChange::AbsoluteToRelative) { |
| 1558 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1559 | ✗ | t = zoneTransformation.inverse() * buildingTransformation.inverse(); | |
| 1560 |
2/3✓ Branch 2 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
|
12 | } else if (coordChange == CoordinateChange::RelativeToAbsolute) { |
| 1561 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1562 | ✗ | t = buildingTransformation * zoneTransformation; | |
| 1563 | ✗ | } | |
| 1564 | |||
| 1565 | // get vertices | ||
| 1566 |
9/9✓ 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.
|
12 | Point3dVector vertices = t * verticesForAzimuthTiltXYZLengthWidthOrHeight(*azimuth, *tilt, *x0, *y0, *z0, *length, *height); |
| 1567 | |||
| 1568 | // add new object | ||
| 1569 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | IdfObject newObject(IddObjectType::BuildingSurface_Detailed); |
| 1570 | |||
| 1571 | // fields which map directly | ||
| 1572 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 1573 | {Wall_ExteriorFields::Name, BuildingSurface_DetailedFields::Name}, | ||
| 1574 | {Wall_ExteriorFields::ConstructionName, BuildingSurface_DetailedFields::ConstructionName}, | ||
| 1575 | {Wall_ExteriorFields::ZoneName, BuildingSurface_DetailedFields::ZoneName}, | ||
| 1576 |
1/1✓ Branch 1 taken 12 times.
|
24 | }; |
| 1577 | |||
| 1578 | // copy fields over directly | ||
| 1579 |
1/1✓ Branch 1 taken 12 times.
|
12 | mapFields(oldObject, newObject, fieldMap); |
| 1580 | |||
| 1581 | // set other fields | ||
| 1582 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
24 | newObject.setString(BuildingSurface_DetailedFields::SurfaceType, "Wall"); |
| 1583 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
24 | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryCondition, "Outdoors"); |
| 1584 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
24 | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryConditionObject, ""); |
| 1585 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
24 | newObject.setString(BuildingSurface_DetailedFields::SunExposure, "SunExposed"); |
| 1586 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
24 | newObject.setString(BuildingSurface_DetailedFields::WindExposure, "WindExposed"); |
| 1587 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | newObject.setString(BuildingSurface_DetailedFields::ViewFactortoGround, ""); |
| 1588 |
1/1✓ Branch 1 taken 12 times.
|
12 | newObject.setDouble(BuildingSurface_DetailedFields::NumberofVertices, 4); |
| 1589 | |||
| 1590 | // swap old object with new one | ||
| 1591 |
1/1✓ Branch 1 taken 12 times.
|
12 | bool ok = m_workspace.swap(oldObject, newObject); |
| 1592 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | if (ok) { |
| 1593 |
4/6✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 12 times.
✗ Branch 13 not taken.
|
12 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::BuildingSurface_Detailed); |
| 1594 | // set vertices | ||
| 1595 |
1/1✓ Branch 1 taken 12 times.
|
12 | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, oldObject, vertices); |
| 1596 | } else { | ||
| 1597 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 1598 | ✗ | continue; | |
| 1599 | ✗ | } | |
| 1600 | |||
| 1601 | // remove old object | ||
| 1602 | //m_workspace.removeObject(oldObject); | ||
| 1603 | 115 | } | |
| 1604 | |||
| 1605 | // Wall:Adiabatic | ||
| 1606 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 103 times.
|
105 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Wall_Adiabatic)) { |
| 1607 | |||
| 1608 | // find zone | ||
| 1609 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalWorkspaceObject zone = oldObject.getTarget(Wall_AdiabaticFields::ZoneName); |
| 1610 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!zone) { |
| 1611 | ✗ | LOG(Error, "Could not find zone"); | |
| 1612 | ✗ | continue; | |
| 1613 | ✗ | } | |
| 1614 | |||
| 1615 | // get simple params | ||
| 1616 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble azimuth = oldObject.getDouble(Wall_AdiabaticFields::AzimuthAngle, true); |
| 1617 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble tilt = oldObject.getDouble(Wall_AdiabaticFields::TiltAngle, true); |
| 1618 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble x0 = oldObject.getDouble(Wall_AdiabaticFields::StartingXCoordinate, true); |
| 1619 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble y0 = oldObject.getDouble(Wall_AdiabaticFields::StartingYCoordinate, true); |
| 1620 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble z0 = oldObject.getDouble(Wall_AdiabaticFields::StartingZCoordinate, true); |
| 1621 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble length = oldObject.getDouble(Wall_AdiabaticFields::Length, true); |
| 1622 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble height = oldObject.getDouble(Wall_AdiabaticFields::Height, true); |
| 1623 | |||
| 1624 |
8/16✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 2 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 2 times.
|
2 | if (!azimuth || !tilt || !x0 || !y0 || !z0 || !length || !height) { |
| 1625 | ✗ | LOG(Error, "Missing required fields"); | |
| 1626 | ✗ | continue; | |
| 1627 | ✗ | } | |
| 1628 | |||
| 1629 | // get transformation | ||
| 1630 |
1/1✓ Branch 1 taken 2 times.
|
2 | Transformation t; |
| 1631 |
2/3✓ Branch 1 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
2 | if (coordChange == CoordinateChange::AbsoluteToRelative) { |
| 1632 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1633 | ✗ | t = zoneTransformation.inverse() * buildingTransformation.inverse(); | |
| 1634 |
2/3✓ Branch 2 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
|
2 | } else if (coordChange == CoordinateChange::RelativeToAbsolute) { |
| 1635 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1636 | ✗ | t = buildingTransformation * zoneTransformation; | |
| 1637 | ✗ | } | |
| 1638 | |||
| 1639 | // get vertices | ||
| 1640 |
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 | Point3dVector vertices = t * verticesForAzimuthTiltXYZLengthWidthOrHeight(*azimuth, *tilt, *x0, *y0, *z0, *length, *height); |
| 1641 | |||
| 1642 | // add new object | ||
| 1643 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | IdfObject newObject(IddObjectType::BuildingSurface_Detailed); |
| 1644 | |||
| 1645 | // fields which map directly | ||
| 1646 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 1647 | {Wall_AdiabaticFields::Name, BuildingSurface_DetailedFields::Name}, | ||
| 1648 | {Wall_AdiabaticFields::ConstructionName, BuildingSurface_DetailedFields::ConstructionName}, | ||
| 1649 | {Wall_AdiabaticFields::ZoneName, BuildingSurface_DetailedFields::ZoneName}, | ||
| 1650 |
1/1✓ Branch 1 taken 2 times.
|
4 | }; |
| 1651 | |||
| 1652 | // copy fields over directly | ||
| 1653 |
1/1✓ Branch 1 taken 2 times.
|
2 | mapFields(oldObject, newObject, fieldMap); |
| 1654 | |||
| 1655 | // set other fields | ||
| 1656 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::SurfaceType, "Wall"); |
| 1657 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryCondition, "Adiabatic"); |
| 1658 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryConditionObject, ""); |
| 1659 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::SunExposure, "NoSun"); |
| 1660 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::WindExposure, "NoWind"); |
| 1661 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | newObject.setString(BuildingSurface_DetailedFields::ViewFactortoGround, ""); |
| 1662 |
1/1✓ Branch 1 taken 2 times.
|
2 | newObject.setDouble(BuildingSurface_DetailedFields::NumberofVertices, 4); |
| 1663 | |||
| 1664 | // swap old object with new one | ||
| 1665 |
1/1✓ Branch 1 taken 2 times.
|
2 | bool ok = m_workspace.swap(oldObject, newObject); |
| 1666 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (ok) { |
| 1667 |
4/6✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 13 not taken.
|
2 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::BuildingSurface_Detailed); |
| 1668 | // set vertices | ||
| 1669 |
1/1✓ Branch 1 taken 2 times.
|
2 | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, oldObject, vertices); |
| 1670 | } else { | ||
| 1671 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 1672 | ✗ | continue; | |
| 1673 | ✗ | } | |
| 1674 | |||
| 1675 | // remove old object | ||
| 1676 | //m_workspace.removeObject(oldObject); | ||
| 1677 | 105 | } | |
| 1678 | |||
| 1679 | // Wall:Underground | ||
| 1680 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 103 times.
|
107 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Wall_Underground)) { |
| 1681 | |||
| 1682 | // find zone | ||
| 1683 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalWorkspaceObject zone = oldObject.getTarget(Wall_UndergroundFields::ZoneName); |
| 1684 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
|
4 | if (!zone) { |
| 1685 | ✗ | LOG(Error, "Could not find zone"); | |
| 1686 | ✗ | continue; | |
| 1687 | ✗ | } | |
| 1688 | |||
| 1689 | // get simple params | ||
| 1690 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble azimuth = oldObject.getDouble(Wall_UndergroundFields::AzimuthAngle, true); |
| 1691 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble tilt = oldObject.getDouble(Wall_UndergroundFields::TiltAngle, true); |
| 1692 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble x0 = oldObject.getDouble(Wall_UndergroundFields::StartingXCoordinate, true); |
| 1693 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble y0 = oldObject.getDouble(Wall_UndergroundFields::StartingYCoordinate, true); |
| 1694 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble z0 = oldObject.getDouble(Wall_UndergroundFields::StartingZCoordinate, true); |
| 1695 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble length = oldObject.getDouble(Wall_UndergroundFields::Length, true); |
| 1696 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble height = oldObject.getDouble(Wall_UndergroundFields::Height, true); |
| 1697 | |||
| 1698 |
8/16✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 4 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 4 times.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 4 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 4 times.
|
4 | if (!azimuth || !tilt || !x0 || !y0 || !z0 || !length || !height) { |
| 1699 | ✗ | LOG(Error, "Missing required fields"); | |
| 1700 | ✗ | continue; | |
| 1701 | ✗ | } | |
| 1702 | |||
| 1703 | // get transformation | ||
| 1704 |
1/1✓ Branch 1 taken 4 times.
|
4 | Transformation t; |
| 1705 |
2/3✓ Branch 1 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
|
4 | if (coordChange == CoordinateChange::AbsoluteToRelative) { |
| 1706 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1707 | ✗ | t = zoneTransformation.inverse() * buildingTransformation.inverse(); | |
| 1708 |
2/3✓ Branch 2 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
|
4 | } else if (coordChange == CoordinateChange::RelativeToAbsolute) { |
| 1709 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1710 | ✗ | t = buildingTransformation * zoneTransformation; | |
| 1711 | ✗ | } | |
| 1712 | |||
| 1713 | // get vertices | ||
| 1714 |
9/9✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 16 taken 4 times.
✓ Branch 19 taken 4 times.
✓ Branch 22 taken 4 times.
✓ Branch 25 taken 4 times.
|
4 | Point3dVector vertices = t * verticesForAzimuthTiltXYZLengthWidthOrHeight(*azimuth, *tilt, *x0, *y0, *z0, *length, *height); |
| 1715 | |||
| 1716 | // add new object | ||
| 1717 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | IdfObject newObject(IddObjectType::BuildingSurface_Detailed); |
| 1718 | |||
| 1719 | // fields which map directly | ||
| 1720 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 1721 | {Wall_UndergroundFields::Name, BuildingSurface_DetailedFields::Name}, | ||
| 1722 | {Wall_UndergroundFields::ConstructionName, BuildingSurface_DetailedFields::ConstructionName}, | ||
| 1723 | {Wall_UndergroundFields::ZoneName, BuildingSurface_DetailedFields::ZoneName}, | ||
| 1724 |
1/1✓ Branch 1 taken 4 times.
|
8 | }; |
| 1725 | |||
| 1726 | // copy fields over directly | ||
| 1727 |
1/1✓ Branch 1 taken 4 times.
|
4 | mapFields(oldObject, newObject, fieldMap); |
| 1728 | |||
| 1729 | // set other fields | ||
| 1730 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | newObject.setString(BuildingSurface_DetailedFields::SurfaceType, "Wall"); |
| 1731 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryCondition, "Ground"); |
| 1732 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryConditionObject, ""); |
| 1733 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | newObject.setString(BuildingSurface_DetailedFields::SunExposure, "NoSun"); |
| 1734 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | newObject.setString(BuildingSurface_DetailedFields::WindExposure, "NoWind"); |
| 1735 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::ViewFactortoGround, ""); |
| 1736 |
1/1✓ Branch 1 taken 4 times.
|
4 | newObject.setDouble(BuildingSurface_DetailedFields::NumberofVertices, 4); |
| 1737 | |||
| 1738 | // swap old object with new one | ||
| 1739 |
1/1✓ Branch 1 taken 4 times.
|
4 | bool ok = m_workspace.swap(oldObject, newObject); |
| 1740 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (ok) { |
| 1741 |
4/6✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 13 not taken.
|
4 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::BuildingSurface_Detailed); |
| 1742 | // set vertices | ||
| 1743 |
1/1✓ Branch 1 taken 4 times.
|
4 | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, oldObject, vertices); |
| 1744 | } else { | ||
| 1745 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 1746 | ✗ | continue; | |
| 1747 | ✗ | } | |
| 1748 | |||
| 1749 | // remove old object | ||
| 1750 | //m_workspace.removeObject(oldObject); | ||
| 1751 | 107 | } | |
| 1752 | |||
| 1753 | // Wall:Interzone | ||
| 1754 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 5 times.
✓ Branch 12 taken 103 times.
|
108 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Wall_Interzone)) { |
| 1755 | |||
| 1756 | // find zone | ||
| 1757 |
1/1✓ Branch 1 taken 5 times.
|
5 | OptionalWorkspaceObject zone = oldObject.getTarget(Wall_InterzoneFields::ZoneName); |
| 1758 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
|
5 | if (!zone) { |
| 1759 | ✗ | LOG(Error, "Could not find zone"); | |
| 1760 | ✗ | continue; | |
| 1761 | ✗ | } | |
| 1762 | |||
| 1763 | // get simple params | ||
| 1764 |
1/1✓ Branch 1 taken 5 times.
|
5 | OptionalDouble azimuth = oldObject.getDouble(Wall_InterzoneFields::AzimuthAngle, true); |
| 1765 |
1/1✓ Branch 1 taken 5 times.
|
5 | OptionalDouble tilt = oldObject.getDouble(Wall_InterzoneFields::TiltAngle, true); |
| 1766 |
1/1✓ Branch 1 taken 5 times.
|
5 | OptionalDouble x0 = oldObject.getDouble(Wall_InterzoneFields::StartingXCoordinate, true); |
| 1767 |
1/1✓ Branch 1 taken 5 times.
|
5 | OptionalDouble y0 = oldObject.getDouble(Wall_InterzoneFields::StartingYCoordinate, true); |
| 1768 |
1/1✓ Branch 1 taken 5 times.
|
5 | OptionalDouble z0 = oldObject.getDouble(Wall_InterzoneFields::StartingZCoordinate, true); |
| 1769 |
1/1✓ Branch 1 taken 5 times.
|
5 | OptionalDouble length = oldObject.getDouble(Wall_InterzoneFields::Length, true); |
| 1770 |
1/1✓ Branch 1 taken 5 times.
|
5 | OptionalDouble height = oldObject.getDouble(Wall_InterzoneFields::Height, true); |
| 1771 | |||
| 1772 |
8/16✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 5 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 5 times.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 5 times.
|
5 | if (!azimuth || !tilt || !x0 || !y0 || !z0 || !length || !height) { |
| 1773 | ✗ | LOG(Error, "Missing required fields"); | |
| 1774 | ✗ | continue; | |
| 1775 | ✗ | } | |
| 1776 | |||
| 1777 | // get transformation | ||
| 1778 |
1/1✓ Branch 1 taken 5 times.
|
5 | Transformation t; |
| 1779 |
2/3✓ Branch 1 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
|
5 | if (coordChange == CoordinateChange::AbsoluteToRelative) { |
| 1780 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1781 | ✗ | t = zoneTransformation.inverse() * buildingTransformation.inverse(); | |
| 1782 |
2/3✓ Branch 2 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
|
5 | } else if (coordChange == CoordinateChange::RelativeToAbsolute) { |
| 1783 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1784 | ✗ | t = buildingTransformation * zoneTransformation; | |
| 1785 | ✗ | } | |
| 1786 | |||
| 1787 | // get vertices | ||
| 1788 |
9/9✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 10 taken 5 times.
✓ Branch 13 taken 5 times.
✓ Branch 16 taken 5 times.
✓ Branch 19 taken 5 times.
✓ Branch 22 taken 5 times.
✓ Branch 25 taken 5 times.
|
5 | Point3dVector vertices = t * verticesForAzimuthTiltXYZLengthWidthOrHeight(*azimuth, *tilt, *x0, *y0, *z0, *length, *height); |
| 1789 | |||
| 1790 | // new object | ||
| 1791 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
5 | IdfObject newObject(IddObjectType::BuildingSurface_Detailed); |
| 1792 | |||
| 1793 | // fields which map directly | ||
| 1794 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 1795 | {Wall_InterzoneFields::Name, BuildingSurface_DetailedFields::Name}, | ||
| 1796 | {Wall_InterzoneFields::ConstructionName, BuildingSurface_DetailedFields::ConstructionName}, | ||
| 1797 | {Wall_InterzoneFields::ZoneName, BuildingSurface_DetailedFields::ZoneName}, | ||
| 1798 | {Wall_InterzoneFields::OutsideBoundaryConditionObject, BuildingSurface_DetailedFields::OutsideBoundaryConditionObject}, | ||
| 1799 |
1/1✓ Branch 1 taken 5 times.
|
10 | }; |
| 1800 | |||
| 1801 | // copy fields over directly | ||
| 1802 |
1/1✓ Branch 1 taken 5 times.
|
5 | mapFields(oldObject, newObject, fieldMap); |
| 1803 | |||
| 1804 | // set other fields | ||
| 1805 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
10 | newObject.setString(BuildingSurface_DetailedFields::SurfaceType, "Wall"); |
| 1806 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
10 | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryCondition, "Zone"); |
| 1807 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
10 | newObject.setString(BuildingSurface_DetailedFields::SunExposure, "NoSun"); |
| 1808 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
10 | newObject.setString(BuildingSurface_DetailedFields::WindExposure, "NoWind"); |
| 1809 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
5 | newObject.setString(BuildingSurface_DetailedFields::ViewFactortoGround, ""); |
| 1810 |
1/1✓ Branch 1 taken 5 times.
|
5 | newObject.setDouble(BuildingSurface_DetailedFields::NumberofVertices, 4); |
| 1811 | |||
| 1812 | // swap old object with new one | ||
| 1813 |
1/1✓ Branch 1 taken 5 times.
|
5 | bool ok = m_workspace.swap(oldObject, newObject); |
| 1814 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if (ok) { |
| 1815 |
4/6✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 13 not taken.
|
5 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::BuildingSurface_Detailed); |
| 1816 | // set vertices | ||
| 1817 |
1/1✓ Branch 1 taken 5 times.
|
5 | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, oldObject, vertices); |
| 1818 | } else { | ||
| 1819 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 1820 | ✗ | continue; | |
| 1821 | ✗ | } | |
| 1822 | |||
| 1823 | // remove old object | ||
| 1824 | //m_workspace.removeObject(oldObject); | ||
| 1825 | 108 | } | |
| 1826 | |||
| 1827 | // Roof | ||
| 1828 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 103 times.
|
107 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Roof)) { |
| 1829 | |||
| 1830 | // find zone | ||
| 1831 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalWorkspaceObject zone = oldObject.getTarget(RoofFields::ZoneName); |
| 1832 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
|
4 | if (!zone) { |
| 1833 | ✗ | LOG(Error, "Could not find zone"); | |
| 1834 | ✗ | continue; | |
| 1835 | ✗ | } | |
| 1836 | |||
| 1837 | // get simple params | ||
| 1838 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble azimuth = oldObject.getDouble(RoofFields::AzimuthAngle, true); |
| 1839 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble tilt = oldObject.getDouble(RoofFields::TiltAngle, true); |
| 1840 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble x0 = oldObject.getDouble(RoofFields::StartingXCoordinate, true); |
| 1841 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble y0 = oldObject.getDouble(RoofFields::StartingYCoordinate, true); |
| 1842 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble z0 = oldObject.getDouble(RoofFields::StartingZCoordinate, true); |
| 1843 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble length = oldObject.getDouble(RoofFields::Length, true); |
| 1844 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble width = oldObject.getDouble(RoofFields::Width, true); |
| 1845 | |||
| 1846 |
8/16✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 4 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 4 times.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 4 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 4 times.
|
4 | if (!azimuth || !tilt || !x0 || !y0 || !z0 || !length || !width) { |
| 1847 | ✗ | LOG(Error, "Missing required fields"); | |
| 1848 | ✗ | continue; | |
| 1849 | ✗ | } | |
| 1850 | |||
| 1851 | // get transformation | ||
| 1852 |
1/1✓ Branch 1 taken 4 times.
|
4 | Transformation t; |
| 1853 |
2/3✓ Branch 1 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
|
4 | if (coordChange == CoordinateChange::AbsoluteToRelative) { |
| 1854 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1855 | ✗ | t = zoneTransformation.inverse() * buildingTransformation.inverse(); | |
| 1856 |
2/3✓ Branch 2 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
|
4 | } else if (coordChange == CoordinateChange::RelativeToAbsolute) { |
| 1857 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1858 | ✗ | t = buildingTransformation * zoneTransformation; | |
| 1859 | ✗ | } | |
| 1860 | |||
| 1861 | // get vertices | ||
| 1862 |
9/9✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 16 taken 4 times.
✓ Branch 19 taken 4 times.
✓ Branch 22 taken 4 times.
✓ Branch 25 taken 4 times.
|
4 | Point3dVector vertices = t * verticesForAzimuthTiltXYZLengthWidthOrHeight(*azimuth, *tilt, *x0, *y0, *z0, *length, *width); |
| 1863 | |||
| 1864 | // add new object | ||
| 1865 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | IdfObject newObject(IddObjectType::BuildingSurface_Detailed); |
| 1866 | |||
| 1867 | // fields which map directly | ||
| 1868 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 1869 | {RoofFields::Name, BuildingSurface_DetailedFields::Name}, | ||
| 1870 | {RoofFields::ConstructionName, BuildingSurface_DetailedFields::ConstructionName}, | ||
| 1871 | {RoofFields::ZoneName, BuildingSurface_DetailedFields::ZoneName}, | ||
| 1872 |
1/1✓ Branch 1 taken 4 times.
|
8 | }; |
| 1873 | |||
| 1874 | // copy fields over directly | ||
| 1875 |
1/1✓ Branch 1 taken 4 times.
|
4 | mapFields(oldObject, newObject, fieldMap); |
| 1876 | |||
| 1877 | // set other fields | ||
| 1878 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | newObject.setString(BuildingSurface_DetailedFields::SurfaceType, "Roof"); |
| 1879 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryCondition, "Outdoors"); |
| 1880 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryConditionObject, ""); |
| 1881 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | newObject.setString(BuildingSurface_DetailedFields::SunExposure, "SunExposed"); |
| 1882 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | newObject.setString(BuildingSurface_DetailedFields::WindExposure, "WindExposed"); |
| 1883 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::ViewFactortoGround, ""); |
| 1884 |
1/1✓ Branch 1 taken 4 times.
|
4 | newObject.setDouble(BuildingSurface_DetailedFields::NumberofVertices, 4); |
| 1885 | |||
| 1886 | // swap old object with new one | ||
| 1887 |
1/1✓ Branch 1 taken 4 times.
|
4 | bool ok = m_workspace.swap(oldObject, newObject); |
| 1888 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (ok) { |
| 1889 |
4/6✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 13 not taken.
|
4 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::BuildingSurface_Detailed); |
| 1890 | // set vertices | ||
| 1891 |
1/1✓ Branch 1 taken 4 times.
|
4 | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, oldObject, vertices); |
| 1892 | } else { | ||
| 1893 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 1894 | ✗ | continue; | |
| 1895 | ✗ | } | |
| 1896 | |||
| 1897 | // remove old object | ||
| 1898 | //m_workspace.removeObject(oldObject); | ||
| 1899 | 107 | } | |
| 1900 | |||
| 1901 | // Ceiling:Adiabatic | ||
| 1902 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 103 times.
|
105 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Ceiling_Adiabatic)) { |
| 1903 | |||
| 1904 | // find zone | ||
| 1905 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalWorkspaceObject zone = oldObject.getTarget(Ceiling_AdiabaticFields::ZoneName); |
| 1906 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!zone) { |
| 1907 | ✗ | LOG(Error, "Could not find zone"); | |
| 1908 | ✗ | continue; | |
| 1909 | ✗ | } | |
| 1910 | |||
| 1911 | // get simple params | ||
| 1912 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble azimuth = oldObject.getDouble(Ceiling_AdiabaticFields::AzimuthAngle, true); |
| 1913 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble tilt = oldObject.getDouble(Ceiling_AdiabaticFields::TiltAngle, true); |
| 1914 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble x0 = oldObject.getDouble(Ceiling_AdiabaticFields::StartingXCoordinate, true); |
| 1915 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble y0 = oldObject.getDouble(Ceiling_AdiabaticFields::StartingYCoordinate, true); |
| 1916 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble z0 = oldObject.getDouble(Ceiling_AdiabaticFields::StartingZCoordinate, true); |
| 1917 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble length = oldObject.getDouble(Ceiling_AdiabaticFields::Length, true); |
| 1918 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble width = oldObject.getDouble(Ceiling_AdiabaticFields::Width, true); |
| 1919 | |||
| 1920 |
8/16✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 2 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 2 times.
|
2 | if (!azimuth || !tilt || !x0 || !y0 || !z0 || !length || !width) { |
| 1921 | ✗ | LOG(Error, "Missing required fields"); | |
| 1922 | ✗ | continue; | |
| 1923 | ✗ | } | |
| 1924 | |||
| 1925 | // get transformation | ||
| 1926 |
1/1✓ Branch 1 taken 2 times.
|
2 | Transformation t; |
| 1927 |
2/3✓ Branch 1 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
2 | if (coordChange == CoordinateChange::AbsoluteToRelative) { |
| 1928 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1929 | ✗ | t = zoneTransformation.inverse() * buildingTransformation.inverse(); | |
| 1930 |
2/3✓ Branch 2 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
|
2 | } else if (coordChange == CoordinateChange::RelativeToAbsolute) { |
| 1931 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 1932 | ✗ | t = buildingTransformation * zoneTransformation; | |
| 1933 | ✗ | } | |
| 1934 | |||
| 1935 | // get vertices | ||
| 1936 |
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 | Point3dVector vertices = t * verticesForAzimuthTiltXYZLengthWidthOrHeight(*azimuth, *tilt, *x0, *y0, *z0, *length, *width); |
| 1937 | |||
| 1938 | // add new object | ||
| 1939 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | IdfObject newObject(IddObjectType::BuildingSurface_Detailed); |
| 1940 | |||
| 1941 | // fields which map directly | ||
| 1942 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 1943 | {Ceiling_AdiabaticFields::Name, BuildingSurface_DetailedFields::Name}, | ||
| 1944 | {Ceiling_AdiabaticFields::ConstructionName, BuildingSurface_DetailedFields::ConstructionName}, | ||
| 1945 | {Ceiling_AdiabaticFields::ZoneName, BuildingSurface_DetailedFields::ZoneName}, | ||
| 1946 |
1/1✓ Branch 1 taken 2 times.
|
4 | }; |
| 1947 | |||
| 1948 | // copy fields over directly | ||
| 1949 |
1/1✓ Branch 1 taken 2 times.
|
2 | mapFields(oldObject, newObject, fieldMap); |
| 1950 | |||
| 1951 | // set other fields | ||
| 1952 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::SurfaceType, "Ceiling"); |
| 1953 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryCondition, "Adiabatic"); |
| 1954 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryConditionObject, ""); |
| 1955 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::SunExposure, "NoSun"); |
| 1956 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::WindExposure, "NoWind"); |
| 1957 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | newObject.setString(BuildingSurface_DetailedFields::ViewFactortoGround, ""); |
| 1958 |
1/1✓ Branch 1 taken 2 times.
|
2 | newObject.setDouble(BuildingSurface_DetailedFields::NumberofVertices, 4); |
| 1959 | |||
| 1960 | // swap old object with new one | ||
| 1961 |
1/1✓ Branch 1 taken 2 times.
|
2 | bool ok = m_workspace.swap(oldObject, newObject); |
| 1962 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (ok) { |
| 1963 |
4/6✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 13 not taken.
|
2 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::BuildingSurface_Detailed); |
| 1964 | // set vertices | ||
| 1965 |
1/1✓ Branch 1 taken 2 times.
|
2 | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, oldObject, vertices); |
| 1966 | } else { | ||
| 1967 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 1968 | ✗ | continue; | |
| 1969 | ✗ | } | |
| 1970 | |||
| 1971 | // remove old object | ||
| 1972 | //m_workspace.removeObject(oldObject); | ||
| 1973 | 105 | } | |
| 1974 | |||
| 1975 | // Ceiling:Interzone | ||
| 1976 |
3/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 103 times.
|
103 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Ceiling_Interzone)) { |
| 1977 | |||
| 1978 | // find zone | ||
| 1979 | ✗ | OptionalWorkspaceObject zone = oldObject.getTarget(Ceiling_InterzoneFields::ZoneName); | |
| 1980 | ✗ | if (!zone) { | |
| 1981 | ✗ | LOG(Error, "Could not find zone"); | |
| 1982 | ✗ | continue; | |
| 1983 | ✗ | } | |
| 1984 | |||
| 1985 | // get simple params | ||
| 1986 | ✗ | OptionalDouble azimuth = oldObject.getDouble(Ceiling_InterzoneFields::AzimuthAngle, true); | |
| 1987 | ✗ | OptionalDouble tilt = oldObject.getDouble(Ceiling_InterzoneFields::TiltAngle, true); | |
| 1988 | ✗ | OptionalDouble x0 = oldObject.getDouble(Ceiling_InterzoneFields::StartingXCoordinate, true); | |
| 1989 | ✗ | OptionalDouble y0 = oldObject.getDouble(Ceiling_InterzoneFields::StartingYCoordinate, true); | |
| 1990 | ✗ | OptionalDouble z0 = oldObject.getDouble(Ceiling_InterzoneFields::StartingZCoordinate, true); | |
| 1991 | ✗ | OptionalDouble length = oldObject.getDouble(Ceiling_InterzoneFields::Length, true); | |
| 1992 | ✗ | OptionalDouble width = oldObject.getDouble(Ceiling_InterzoneFields::Width, true); | |
| 1993 | |||
| 1994 | ✗ | if (!azimuth || !tilt || !x0 || !y0 || !z0 || !length || !width) { | |
| 1995 | ✗ | LOG(Error, "Missing required fields"); | |
| 1996 | ✗ | continue; | |
| 1997 | ✗ | } | |
| 1998 | |||
| 1999 | // get transformation | ||
| 2000 | ✗ | Transformation t; | |
| 2001 | ✗ | if (coordChange == CoordinateChange::AbsoluteToRelative) { | |
| 2002 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 2003 | ✗ | t = zoneTransformation.inverse() * buildingTransformation.inverse(); | |
| 2004 | ✗ | } else if (coordChange == CoordinateChange::RelativeToAbsolute) { | |
| 2005 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 2006 | ✗ | t = buildingTransformation * zoneTransformation; | |
| 2007 | ✗ | } | |
| 2008 | |||
| 2009 | // get vertices | ||
| 2010 | ✗ | Point3dVector vertices = t * verticesForAzimuthTiltXYZLengthWidthOrHeight(*azimuth, *tilt, *x0, *y0, *z0, *length, *width); | |
| 2011 | |||
| 2012 | // add new object | ||
| 2013 | ✗ | IdfObject newObject(IddObjectType::BuildingSurface_Detailed); | |
| 2014 | |||
| 2015 | // fields which map directly | ||
| 2016 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 2017 | {Ceiling_InterzoneFields::Name, BuildingSurface_DetailedFields::Name}, | ||
| 2018 | {Ceiling_InterzoneFields::ConstructionName, BuildingSurface_DetailedFields::ConstructionName}, | ||
| 2019 | {Ceiling_InterzoneFields::ZoneName, BuildingSurface_DetailedFields::ZoneName}, | ||
| 2020 | {Ceiling_InterzoneFields::OutsideBoundaryConditionObject, BuildingSurface_DetailedFields::OutsideBoundaryConditionObject}, | ||
| 2021 | ✗ | }; | |
| 2022 | |||
| 2023 | // copy fields over directly | ||
| 2024 | ✗ | mapFields(oldObject, newObject, fieldMap); | |
| 2025 | |||
| 2026 | // set other fields | ||
| 2027 | ✗ | newObject.setString(BuildingSurface_DetailedFields::SurfaceType, "Ceiling"); | |
| 2028 | ✗ | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryCondition, "Zone"); | |
| 2029 | ✗ | newObject.setString(BuildingSurface_DetailedFields::SunExposure, "NoSun"); | |
| 2030 | ✗ | newObject.setString(BuildingSurface_DetailedFields::WindExposure, "NoWind"); | |
| 2031 | ✗ | newObject.setString(BuildingSurface_DetailedFields::ViewFactortoGround, ""); | |
| 2032 | ✗ | newObject.setDouble(BuildingSurface_DetailedFields::NumberofVertices, 4); | |
| 2033 | |||
| 2034 | // swap old object with new one | ||
| 2035 | ✗ | bool ok = m_workspace.swap(oldObject, newObject); | |
| 2036 | ✗ | if (ok) { | |
| 2037 | ✗ | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::BuildingSurface_Detailed); | |
| 2038 | // set vertices | ||
| 2039 | ✗ | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, oldObject, vertices); | |
| 2040 | } else { | ||
| 2041 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 2042 | ✗ | continue; | |
| 2043 | ✗ | } | |
| 2044 | |||
| 2045 | // remove old object | ||
| 2046 | //m_workspace.removeObject(oldObject); | ||
| 2047 | 103 | } | |
| 2048 | |||
| 2049 | // Floor:GroundContact | ||
| 2050 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 103 times.
|
107 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Floor_GroundContact)) { |
| 2051 | |||
| 2052 | // find zone | ||
| 2053 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalWorkspaceObject zone = oldObject.getTarget(Floor_GroundContactFields::ZoneName); |
| 2054 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
|
4 | if (!zone) { |
| 2055 | ✗ | LOG(Error, "Could not find zone"); | |
| 2056 | ✗ | continue; | |
| 2057 | ✗ | } | |
| 2058 | |||
| 2059 | // get simple params | ||
| 2060 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble azimuth = oldObject.getDouble(Floor_GroundContactFields::AzimuthAngle, true); |
| 2061 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble tilt = oldObject.getDouble(Floor_GroundContactFields::TiltAngle, true); |
| 2062 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble x0 = oldObject.getDouble(Floor_GroundContactFields::StartingXCoordinate, true); |
| 2063 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble y0 = oldObject.getDouble(Floor_GroundContactFields::StartingYCoordinate, true); |
| 2064 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble z0 = oldObject.getDouble(Floor_GroundContactFields::StartingZCoordinate, true); |
| 2065 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble length = oldObject.getDouble(Floor_GroundContactFields::Length, true); |
| 2066 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble width = oldObject.getDouble(Floor_GroundContactFields::Width, true); |
| 2067 | |||
| 2068 |
8/16✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 4 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 4 times.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 4 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 4 times.
|
4 | if (!azimuth || !tilt || !x0 || !y0 || !z0 || !length || !width) { |
| 2069 | ✗ | LOG(Error, "Missing required fields"); | |
| 2070 | ✗ | continue; | |
| 2071 | ✗ | } | |
| 2072 | |||
| 2073 | // get transformation | ||
| 2074 |
1/1✓ Branch 1 taken 4 times.
|
4 | Transformation t; |
| 2075 |
2/3✓ Branch 1 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
|
4 | if (coordChange == CoordinateChange::AbsoluteToRelative) { |
| 2076 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 2077 | ✗ | t = zoneTransformation.inverse() * buildingTransformation.inverse(); | |
| 2078 |
2/3✓ Branch 2 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
|
4 | } else if (coordChange == CoordinateChange::RelativeToAbsolute) { |
| 2079 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 2080 | ✗ | t = buildingTransformation * zoneTransformation; | |
| 2081 | ✗ | } | |
| 2082 | |||
| 2083 | // get vertices | ||
| 2084 |
9/9✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 16 taken 4 times.
✓ Branch 19 taken 4 times.
✓ Branch 22 taken 4 times.
✓ Branch 25 taken 4 times.
|
4 | Point3dVector vertices = t * verticesForAzimuthTiltXYZLengthWidthOrHeight(*azimuth, *tilt, *x0, *y0, *z0, *length, *width); |
| 2085 | |||
| 2086 | // add new object | ||
| 2087 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | IdfObject newObject(IddObjectType::BuildingSurface_Detailed); |
| 2088 | |||
| 2089 | // fields which map directly | ||
| 2090 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 2091 | {Floor_GroundContactFields::Name, BuildingSurface_DetailedFields::Name}, | ||
| 2092 | {Floor_GroundContactFields::ConstructionName, BuildingSurface_DetailedFields::ConstructionName}, | ||
| 2093 | {Floor_GroundContactFields::ZoneName, BuildingSurface_DetailedFields::ZoneName}, | ||
| 2094 |
1/1✓ Branch 1 taken 4 times.
|
8 | }; |
| 2095 | |||
| 2096 | // copy fields over directly | ||
| 2097 |
1/1✓ Branch 1 taken 4 times.
|
4 | mapFields(oldObject, newObject, fieldMap); |
| 2098 | |||
| 2099 | // set other fields | ||
| 2100 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | newObject.setString(BuildingSurface_DetailedFields::SurfaceType, "Floor"); |
| 2101 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryCondition, "Ground"); |
| 2102 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryConditionObject, ""); |
| 2103 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | newObject.setString(BuildingSurface_DetailedFields::SunExposure, "NoSun"); |
| 2104 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | newObject.setString(BuildingSurface_DetailedFields::WindExposure, "NoWind"); |
| 2105 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::ViewFactortoGround, ""); |
| 2106 |
1/1✓ Branch 1 taken 4 times.
|
4 | newObject.setDouble(BuildingSurface_DetailedFields::NumberofVertices, 4); |
| 2107 | |||
| 2108 | // swap old object with new one | ||
| 2109 |
1/1✓ Branch 1 taken 4 times.
|
4 | bool ok = m_workspace.swap(oldObject, newObject); |
| 2110 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (ok) { |
| 2111 |
4/6✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 13 not taken.
|
4 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::BuildingSurface_Detailed); |
| 2112 | // set vertices | ||
| 2113 |
1/1✓ Branch 1 taken 4 times.
|
4 | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, oldObject, vertices); |
| 2114 | } else { | ||
| 2115 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 2116 | ✗ | continue; | |
| 2117 | ✗ | } | |
| 2118 | |||
| 2119 | // remove old object | ||
| 2120 | //m_workspace.removeObject(oldObject); | ||
| 2121 | 107 | } | |
| 2122 | |||
| 2123 | // Floor:Adiabatic | ||
| 2124 |
3/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 103 times.
|
103 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Floor_Adiabatic)) { |
| 2125 | |||
| 2126 | // find zone | ||
| 2127 | ✗ | OptionalWorkspaceObject zone = oldObject.getTarget(Floor_AdiabaticFields::ZoneName); | |
| 2128 | ✗ | if (!zone) { | |
| 2129 | ✗ | LOG(Error, "Could not find zone"); | |
| 2130 | ✗ | continue; | |
| 2131 | ✗ | } | |
| 2132 | |||
| 2133 | // get simple params | ||
| 2134 | ✗ | OptionalDouble azimuth = oldObject.getDouble(Floor_AdiabaticFields::AzimuthAngle, true); | |
| 2135 | ✗ | OptionalDouble tilt = oldObject.getDouble(Floor_AdiabaticFields::TiltAngle, true); | |
| 2136 | ✗ | OptionalDouble x0 = oldObject.getDouble(Floor_AdiabaticFields::StartingXCoordinate, true); | |
| 2137 | ✗ | OptionalDouble y0 = oldObject.getDouble(Floor_AdiabaticFields::StartingYCoordinate, true); | |
| 2138 | ✗ | OptionalDouble z0 = oldObject.getDouble(Floor_AdiabaticFields::StartingZCoordinate, true); | |
| 2139 | ✗ | OptionalDouble length = oldObject.getDouble(Floor_AdiabaticFields::Length, true); | |
| 2140 | ✗ | OptionalDouble width = oldObject.getDouble(Floor_AdiabaticFields::Width, true); | |
| 2141 | |||
| 2142 | ✗ | if (!azimuth || !tilt || !x0 || !y0 || !z0 || !length || !width) { | |
| 2143 | ✗ | LOG(Error, "Missing required fields"); | |
| 2144 | ✗ | continue; | |
| 2145 | ✗ | } | |
| 2146 | |||
| 2147 | // get transformation | ||
| 2148 | ✗ | Transformation t; | |
| 2149 | ✗ | if (coordChange == CoordinateChange::AbsoluteToRelative) { | |
| 2150 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 2151 | ✗ | t = zoneTransformation.inverse() * buildingTransformation.inverse(); | |
| 2152 | ✗ | } else if (coordChange == CoordinateChange::RelativeToAbsolute) { | |
| 2153 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 2154 | ✗ | t = buildingTransformation * zoneTransformation; | |
| 2155 | ✗ | } | |
| 2156 | |||
| 2157 | // get vertices | ||
| 2158 | ✗ | Point3dVector vertices = t * verticesForAzimuthTiltXYZLengthWidthOrHeight(*azimuth, *tilt, *x0, *y0, *z0, *length, *width); | |
| 2159 | |||
| 2160 | // add new object | ||
| 2161 | ✗ | IdfObject newObject(IddObjectType::BuildingSurface_Detailed); | |
| 2162 | |||
| 2163 | // fields which map directly | ||
| 2164 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 2165 | {Floor_AdiabaticFields::Name, BuildingSurface_DetailedFields::Name}, | ||
| 2166 | {Floor_AdiabaticFields::ConstructionName, BuildingSurface_DetailedFields::ConstructionName}, | ||
| 2167 | {Floor_AdiabaticFields::ZoneName, BuildingSurface_DetailedFields::ZoneName}, | ||
| 2168 | ✗ | }; | |
| 2169 | |||
| 2170 | // copy fields over directly | ||
| 2171 | ✗ | mapFields(oldObject, newObject, fieldMap); | |
| 2172 | |||
| 2173 | // set other fields | ||
| 2174 | ✗ | newObject.setString(BuildingSurface_DetailedFields::SurfaceType, "Floor"); | |
| 2175 | ✗ | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryCondition, "Adiabatic"); | |
| 2176 | ✗ | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryConditionObject, ""); | |
| 2177 | ✗ | newObject.setString(BuildingSurface_DetailedFields::SunExposure, "NoSun"); | |
| 2178 | ✗ | newObject.setString(BuildingSurface_DetailedFields::WindExposure, "NoWind"); | |
| 2179 | ✗ | newObject.setString(BuildingSurface_DetailedFields::ViewFactortoGround, ""); | |
| 2180 | ✗ | newObject.setDouble(BuildingSurface_DetailedFields::NumberofVertices, 4); | |
| 2181 | |||
| 2182 | // swap old object with new one | ||
| 2183 | ✗ | bool ok = m_workspace.swap(oldObject, newObject); | |
| 2184 | ✗ | if (ok) { | |
| 2185 | ✗ | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::BuildingSurface_Detailed); | |
| 2186 | // set vertices | ||
| 2187 | ✗ | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, oldObject, vertices); | |
| 2188 | } else { | ||
| 2189 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 2190 | ✗ | continue; | |
| 2191 | ✗ | } | |
| 2192 | |||
| 2193 | // remove old object | ||
| 2194 | //m_workspace.removeObject(oldObject); | ||
| 2195 | 103 | } | |
| 2196 | |||
| 2197 | // Floor:Interzone | ||
| 2198 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 103 times.
|
105 | for (WorkspaceObject& oldObject : m_workspace.getObjectsByType(IddObjectType::Floor_Interzone)) { |
| 2199 | |||
| 2200 | // find zone | ||
| 2201 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalWorkspaceObject zone = oldObject.getTarget(Floor_InterzoneFields::ZoneName); |
| 2202 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!zone) { |
| 2203 | ✗ | LOG(Error, "Could not find zone"); | |
| 2204 | ✗ | continue; | |
| 2205 | ✗ | } | |
| 2206 | |||
| 2207 | // get simple params | ||
| 2208 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble azimuth = oldObject.getDouble(Floor_InterzoneFields::AzimuthAngle, true); |
| 2209 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble tilt = oldObject.getDouble(Floor_InterzoneFields::TiltAngle, true); |
| 2210 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble x0 = oldObject.getDouble(Floor_InterzoneFields::StartingXCoordinate, true); |
| 2211 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble y0 = oldObject.getDouble(Floor_InterzoneFields::StartingYCoordinate, true); |
| 2212 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble z0 = oldObject.getDouble(Floor_InterzoneFields::StartingZCoordinate, true); |
| 2213 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble length = oldObject.getDouble(Floor_InterzoneFields::Length, true); |
| 2214 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble width = oldObject.getDouble(Floor_InterzoneFields::Width, true); |
| 2215 | |||
| 2216 |
8/16✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 2 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 2 times.
|
2 | if (!azimuth || !tilt || !x0 || !y0 || !z0 || !length || !width) { |
| 2217 | ✗ | LOG(Error, "Missing required fields"); | |
| 2218 | ✗ | continue; | |
| 2219 | ✗ | } | |
| 2220 | |||
| 2221 | // get transformation | ||
| 2222 |
1/1✓ Branch 1 taken 2 times.
|
2 | Transformation t; |
| 2223 |
2/3✓ Branch 1 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
2 | if (coordChange == CoordinateChange::AbsoluteToRelative) { |
| 2224 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 2225 | ✗ | t = zoneTransformation.inverse() * buildingTransformation.inverse(); | |
| 2226 |
2/3✓ Branch 2 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
|
2 | } else if (coordChange == CoordinateChange::RelativeToAbsolute) { |
| 2227 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 2228 | ✗ | t = buildingTransformation * zoneTransformation; | |
| 2229 | ✗ | } | |
| 2230 | |||
| 2231 | // get vertices | ||
| 2232 |
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 | Point3dVector vertices = t * verticesForAzimuthTiltXYZLengthWidthOrHeight(*azimuth, *tilt, *x0, *y0, *z0, *length, *width); |
| 2233 | |||
| 2234 | // add new object | ||
| 2235 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | IdfObject newObject(IddObjectType::BuildingSurface_Detailed); |
| 2236 | |||
| 2237 | // fields which map directly | ||
| 2238 | std::vector<std::pair<unsigned, unsigned>> fieldMap{ | ||
| 2239 | {Floor_InterzoneFields::Name, BuildingSurface_DetailedFields::Name}, | ||
| 2240 | {Floor_InterzoneFields::ConstructionName, BuildingSurface_DetailedFields::ConstructionName}, | ||
| 2241 | {Floor_InterzoneFields::ZoneName, BuildingSurface_DetailedFields::ZoneName}, | ||
| 2242 | {Floor_InterzoneFields::OutsideBoundaryConditionObject, BuildingSurface_DetailedFields::OutsideBoundaryConditionObject}, | ||
| 2243 |
1/1✓ Branch 1 taken 2 times.
|
4 | }; |
| 2244 | |||
| 2245 | // copy fields over directly | ||
| 2246 |
1/1✓ Branch 1 taken 2 times.
|
2 | mapFields(oldObject, newObject, fieldMap); |
| 2247 | |||
| 2248 | // set other fields | ||
| 2249 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::SurfaceType, "Floor"); |
| 2250 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryCondition, "Zone"); |
| 2251 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::SunExposure, "NoSun"); |
| 2252 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | newObject.setString(BuildingSurface_DetailedFields::WindExposure, "NoWind"); |
| 2253 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | newObject.setString(BuildingSurface_DetailedFields::ViewFactortoGround, ""); |
| 2254 |
1/1✓ Branch 1 taken 2 times.
|
2 | newObject.setDouble(BuildingSurface_DetailedFields::NumberofVertices, 4); |
| 2255 | |||
| 2256 | // swap old object with new one | ||
| 2257 |
1/1✓ Branch 1 taken 2 times.
|
2 | bool ok = m_workspace.swap(oldObject, newObject); |
| 2258 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (ok) { |
| 2259 |
4/6✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 13 not taken.
|
2 | OS_ASSERT(oldObject.iddObject().type() == IddObjectType::BuildingSurface_Detailed); |
| 2260 | // set vertices | ||
| 2261 |
1/1✓ Branch 1 taken 2 times.
|
2 | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, oldObject, vertices); |
| 2262 | } else { | ||
| 2263 | ✗ | LOG(Error, "Workspace object swap failed"); | |
| 2264 | ✗ | continue; | |
| 2265 | ✗ | } | |
| 2266 | |||
| 2267 | // remove old object | ||
| 2268 | //m_workspace.removeObject(oldObject); | ||
| 2269 | 105 | } | |
| 2270 | |||
| 2271 | 103 | return true; | |
| 2272 | 103 | } | |
| 2273 | |||
| 2274 | // transform daylighting geometry from the current system to the new system | ||
| 2275 | 103 | bool GeometryTranslator::convertDaylightingGeometry(const CoordinateChange& daylightingCoordChange) { | |
| 2276 | 103 | bool result = true; | |
| 2277 | |||
| 2278 |
1/1✓ Branch 1 taken 103 times.
|
103 | Transformation buildingTransformation = this->buildingTransformation(); |
| 2279 | |||
| 2280 | // Daylighting controls | ||
| 2281 | // TODO: transform glare angle | ||
| 2282 | // for (WorkspaceObject daylightingControl : m_workspace.getObjectsByType(IddObjectType::Daylighting_Controls)) { | ||
| 2283 | // } | ||
| 2284 | |||
| 2285 | // daylighting reference points | ||
| 2286 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 18 times.
✓ Branch 12 taken 103 times.
|
121 | for (WorkspaceObject& daylightingPoint : m_workspace.getObjectsByType(IddObjectType::Daylighting_ReferencePoint)) { |
| 2287 |
3/3✓ Branch 1 taken 18 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 16 times.
|
18 | if (daylightingCoordChange != CoordinateChange::NoChange) { |
| 2288 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalWorkspaceObject zone = daylightingPoint.getTarget(Daylighting_ReferencePointFields::ZoneorSpaceName); |
| 2289 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!zone) { |
| 2290 | ✗ | LOG(Error, "Could not find zone"); | |
| 2291 | ✗ | continue; | |
| 2292 | ✗ | } | |
| 2293 | |||
| 2294 |
1/1✓ Branch 1 taken 2 times.
|
2 | Transformation t; |
| 2295 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | if (daylightingCoordChange == CoordinateChange::AbsoluteToRelative) { |
| 2296 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | Transformation zoneTransformation = this->zoneTransformation(*zone); |
| 2297 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | t = zoneTransformation.inverse() * buildingTransformation.inverse(); |
| 2298 |
0/3✗ Branch 2 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
2 | } else if (daylightingCoordChange == CoordinateChange::RelativeToAbsolute) { |
| 2299 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 2300 | ✗ | t = buildingTransformation * zoneTransformation; | |
| 2301 | ✗ | } | |
| 2302 | |||
| 2303 | // transform sensor points | ||
| 2304 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble x = daylightingPoint.getDouble(Daylighting_ReferencePointFields::XCoordinateofReferencePoint, true); |
| 2305 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble y = daylightingPoint.getDouble(Daylighting_ReferencePointFields::YCoordinateofReferencePoint, true); |
| 2306 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble z = daylightingPoint.getDouble(Daylighting_ReferencePointFields::ZCoordinateofReferencePoint, true); |
| 2307 |
4/8✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
6 | if (x && y && z) { |
| 2308 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | Point3d point(*x, *y, *z); |
| 2309 |
1/1✓ Branch 1 taken 2 times.
|
2 | point = t * point; |
| 2310 |
4/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
|
2 | result = result && daylightingPoint.setDouble(Daylighting_ReferencePointFields::XCoordinateofReferencePoint, point.x()); |
| 2311 |
4/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
|
2 | result = result && daylightingPoint.setDouble(Daylighting_ReferencePointFields::YCoordinateofReferencePoint, point.y()); |
| 2312 |
4/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
|
2 | result = result && daylightingPoint.setDouble(Daylighting_ReferencePointFields::ZCoordinateofReferencePoint, point.z()); |
| 2313 | 2 | } | |
| 2314 | 2 | } | |
| 2315 | 103 | } | |
| 2316 | |||
| 2317 | // output illuminance map | ||
| 2318 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 103 times.
|
111 | for (WorkspaceObject& illuminanceMap : m_workspace.getObjectsByType(IddObjectType::Output_IlluminanceMap)) { |
| 2319 |
3/3✓ Branch 1 taken 8 times.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 7 times.
|
8 | if (daylightingCoordChange != CoordinateChange::NoChange) { |
| 2320 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalWorkspaceObject zone = illuminanceMap.getTarget(Output_IlluminanceMapFields::ZoneorSpaceName); |
| 2321 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!zone) { |
| 2322 | ✗ | LOG(Error, "Could not find zone"); | |
| 2323 | ✗ | continue; | |
| 2324 | ✗ | } | |
| 2325 | |||
| 2326 |
1/1✓ Branch 1 taken 1 time.
|
1 | Transformation t; |
| 2327 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
|
1 | if (daylightingCoordChange == CoordinateChange::AbsoluteToRelative) { |
| 2328 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | Transformation zoneTransformation = this->zoneTransformation(*zone); |
| 2329 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | t = zoneTransformation.inverse() * buildingTransformation.inverse(); |
| 2330 |
0/3✗ Branch 2 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
1 | } else if (daylightingCoordChange == CoordinateChange::RelativeToAbsolute) { |
| 2331 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 2332 | ✗ | t = buildingTransformation * zoneTransformation; | |
| 2333 | ✗ | } | |
| 2334 | |||
| 2335 | // transform min/max points | ||
| 2336 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble xmin = illuminanceMap.getDouble(Output_IlluminanceMapFields::XMinimumCoordinate, true); |
| 2337 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble ymin = illuminanceMap.getDouble(Output_IlluminanceMapFields::YMinimumCoordinate, true); |
| 2338 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble xmax = illuminanceMap.getDouble(Output_IlluminanceMapFields::XMaximumCoordinate, true); |
| 2339 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble ymax = illuminanceMap.getDouble(Output_IlluminanceMapFields::YMaximumCoordinate, true); |
| 2340 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble z = illuminanceMap.getDouble(Output_IlluminanceMapFields::Zheight, true); |
| 2341 |
6/12✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
|
5 | if (xmin && ymin && xmax && ymax && z) { |
| 2342 | |||
| 2343 | // do not know which point will be min and max in new coord system | ||
| 2344 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | Point3d p1(*xmin, *ymin, *z); |
| 2345 |
1/1✓ Branch 1 taken 1 time.
|
1 | p1 = t * p1; |
| 2346 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | Point3d p2(*xmax, *ymin, *z); |
| 2347 |
1/1✓ Branch 1 taken 1 time.
|
1 | p2 = t * p2; |
| 2348 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | Point3d p3(*xmin, *ymax, *z); |
| 2349 |
1/1✓ Branch 1 taken 1 time.
|
1 | p3 = t * p3; |
| 2350 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | Point3d p4(*xmax, *ymax, *z); |
| 2351 |
1/1✓ Branch 1 taken 1 time.
|
1 | p4 = t * p4; |
| 2352 | |||
| 2353 |
5/5✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 16 taken 1 time.
|
1 | xmin = std::min(std::min(std::min(p1.x(), p2.x()), p3.x()), p4.x()); |
| 2354 |
5/5✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 16 taken 1 time.
|
1 | ymin = std::min(std::min(std::min(p1.y(), p2.y()), p3.y()), p4.y()); |
| 2355 |
5/5✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 16 taken 1 time.
|
1 | xmax = std::max(std::max(std::max(p1.x(), p2.x()), p3.x()), p4.x()); |
| 2356 |
5/5✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 16 taken 1 time.
|
1 | ymax = std::max(std::max(std::max(p1.y(), p2.y()), p3.y()), p4.y()); |
| 2357 | |||
| 2358 |
4/6✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 time.
✓ Branch 6 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
|
1 | result = result && illuminanceMap.setDouble(Output_IlluminanceMapFields::XMinimumCoordinate, *xmin); |
| 2359 |
4/6✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 time.
✓ Branch 6 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
|
1 | result = result && illuminanceMap.setDouble(Output_IlluminanceMapFields::YMinimumCoordinate, *ymin); |
| 2360 |
4/6✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 time.
✓ Branch 6 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
|
1 | result = result && illuminanceMap.setDouble(Output_IlluminanceMapFields::XMaximumCoordinate, *xmax); |
| 2361 |
4/6✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 time.
✓ Branch 6 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
|
1 | result = result && illuminanceMap.setDouble(Output_IlluminanceMapFields::YMaximumCoordinate, *ymax); |
| 2362 |
4/6✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 time.
✓ Branch 6 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
|
1 | result = result && illuminanceMap.setDouble(Output_IlluminanceMapFields::Zheight, p1.z()); |
| 2363 | 1 | } | |
| 2364 | 1 | } | |
| 2365 | 103 | } | |
| 2366 | |||
| 2367 | 103 | return result; | |
| 2368 | 103 | } | |
| 2369 | |||
| 2370 | // transform detailed geometry from the current system to the new system | ||
| 2371 | 103 | bool GeometryTranslator::convertDetailedGeometry(const CoordinateChange& detailedCoordChange) { | |
| 2372 | 103 | bool result = true; | |
| 2373 | |||
| 2374 |
1/1✓ Branch 1 taken 103 times.
|
103 | Transformation buildingTransformation = this->buildingTransformation(); |
| 2375 | |||
| 2376 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 382 times.
✓ Branch 12 taken 103 times.
|
485 | for (WorkspaceObject& surface : m_workspace.getObjectsByType(IddObjectType::BuildingSurface_Detailed)) { |
| 2377 |
1/1✓ Branch 1 taken 382 times.
|
382 | Point3dVector vertices = getVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, surface); |
| 2378 |
2/2✓ Branch 1 taken 382 times.
✓ Branch 4 taken 382 times.
|
764 | surface.setString(BuildingSurface_DetailedFields::NumberofVertices, "Autocalculate"); |
| 2379 |
3/3✓ Branch 1 taken 382 times.
✓ Branch 4 taken 17 times.
✓ Branch 5 taken 365 times.
|
382 | if (detailedCoordChange != CoordinateChange::NoChange) { |
| 2380 |
1/1✓ Branch 1 taken 17 times.
|
17 | OptionalWorkspaceObject zone = surface.getTarget(BuildingSurface_DetailedFields::ZoneName); |
| 2381 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 2 taken 12 times.
|
17 | if (!zone) { |
| 2382 |
5/5✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 10 taken 5 times.
✓ Branch 13 taken 5 times.
|
5 | LOG(Error, "Could not find zone"); |
| 2383 | 5 | continue; | |
| 2384 | 5 | } | |
| 2385 | |||
| 2386 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | Transformation zoneTransformation = this->zoneTransformation(*zone); |
| 2387 | |||
| 2388 |
2/3✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
|
12 | if (detailedCoordChange == CoordinateChange::AbsoluteToRelative) { |
| 2389 |
4/4✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
|
12 | vertices = zoneTransformation.inverse() * buildingTransformation.inverse() * vertices; |
| 2390 |
1/1✓ Branch 1 taken 12 times.
|
12 | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, surface, vertices); |
| 2391 | ✗ | } else if (detailedCoordChange == CoordinateChange::RelativeToAbsolute) { | |
| 2392 | ✗ | vertices = buildingTransformation * zoneTransformation * vertices; | |
| 2393 | ✗ | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, surface, vertices); | |
| 2394 | } | ||
| 2395 | 17 | } | |
| 2396 | 485 | } | |
| 2397 | |||
| 2398 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 110 times.
✓ Branch 12 taken 103 times.
|
213 | for (WorkspaceObject& subsurface : m_workspace.getObjectsByType(IddObjectType::FenestrationSurface_Detailed)) { |
| 2399 |
1/1✓ Branch 1 taken 110 times.
|
110 | Point3dVector vertices = getVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, subsurface); |
| 2400 |
2/2✓ Branch 1 taken 110 times.
✓ Branch 4 taken 110 times.
|
220 | subsurface.setString(FenestrationSurface_DetailedFields::NumberofVertices, "Autocalculate"); |
| 2401 |
2/3✓ Branch 1 taken 110 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 110 times.
|
110 | if (detailedCoordChange != CoordinateChange::NoChange) { |
| 2402 | ✗ | OptionalWorkspaceObject surface = subsurface.getTarget(FenestrationSurface_DetailedFields::BuildingSurfaceName); | |
| 2403 | ✗ | if (!surface) { | |
| 2404 | ✗ | LOG(Error, "Could not find surface"); | |
| 2405 | ✗ | continue; | |
| 2406 | ✗ | } | |
| 2407 | ✗ | OptionalWorkspaceObject zone = surface->getTarget(BuildingSurface_DetailedFields::ZoneName); | |
| 2408 | ✗ | if (!zone) { | |
| 2409 | ✗ | LOG(Error, "Could not find zone"); | |
| 2410 | ✗ | continue; | |
| 2411 | ✗ | } | |
| 2412 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 2413 | ✗ | if (detailedCoordChange == CoordinateChange::AbsoluteToRelative) { | |
| 2414 | ✗ | vertices = zoneTransformation.inverse() * buildingTransformation.inverse() * vertices; | |
| 2415 | ✗ | setVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, subsurface, vertices); | |
| 2416 | ✗ | } else if (detailedCoordChange == CoordinateChange::RelativeToAbsolute) { | |
| 2417 | ✗ | vertices = buildingTransformation * zoneTransformation * vertices; | |
| 2418 | ✗ | setVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, subsurface, vertices); | |
| 2419 | } | ||
| 2420 | ✗ | } | |
| 2421 | 213 | } | |
| 2422 | |||
| 2423 |
3/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 103 times.
|
103 | for (WorkspaceObject& zoneShading : m_workspace.getObjectsByType(IddObjectType::Shading_Zone_Detailed)) { |
| 2424 | ✗ | Point3dVector vertices = getVertices(Shading_Zone_DetailedFields::NumberofVertices + 1, zoneShading); | |
| 2425 | ✗ | zoneShading.setString(Shading_Zone_DetailedFields::NumberofVertices, "Autocalculate"); | |
| 2426 | ✗ | if (detailedCoordChange != CoordinateChange::NoChange) { | |
| 2427 | ✗ | OptionalWorkspaceObject zoneSurface = zoneShading.getTarget(Shading_Zone_DetailedFields::BaseSurfaceName); | |
| 2428 | ✗ | if (!zoneSurface) { | |
| 2429 | ✗ | LOG(Error, "Could not find zone surface"); | |
| 2430 | ✗ | continue; | |
| 2431 | ✗ | } | |
| 2432 | ✗ | OptionalWorkspaceObject zone = zoneSurface->getTarget(BuildingSurface_DetailedFields::ZoneName); | |
| 2433 | ✗ | if (!zone) { | |
| 2434 | ✗ | LOG(Error, "Could not find zone"); | |
| 2435 | ✗ | continue; | |
| 2436 | ✗ | } | |
| 2437 | |||
| 2438 | ✗ | Transformation zoneTransformation = this->zoneTransformation(*zone); | |
| 2439 | |||
| 2440 | ✗ | if (detailedCoordChange == CoordinateChange::AbsoluteToRelative) { | |
| 2441 | ✗ | vertices = zoneTransformation.inverse() * buildingTransformation.inverse() * vertices; | |
| 2442 | ✗ | setVertices(Shading_Zone_DetailedFields::NumberofVertices + 1, zoneShading, vertices); | |
| 2443 | ✗ | } else if (detailedCoordChange == CoordinateChange::RelativeToAbsolute) { | |
| 2444 | ✗ | vertices = buildingTransformation * zoneTransformation * vertices; | |
| 2445 | ✗ | setVertices(Shading_Zone_DetailedFields::NumberofVertices + 1, zoneShading, vertices); | |
| 2446 | } | ||
| 2447 | ✗ | } | |
| 2448 | 103 | } | |
| 2449 | |||
| 2450 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 103 times.
|
107 | for (WorkspaceObject& buildingShading : m_workspace.getObjectsByType(IddObjectType::Shading_Building_Detailed)) { |
| 2451 |
1/1✓ Branch 1 taken 4 times.
|
4 | Point3dVector vertices = getVertices(Shading_Building_DetailedFields::NumberofVertices + 1, buildingShading); |
| 2452 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | buildingShading.setString(Shading_Building_DetailedFields::NumberofVertices, "Autocalculate"); |
| 2453 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 3 times.
|
4 | if (detailedCoordChange != CoordinateChange::NoChange) { |
| 2454 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
|
1 | if (detailedCoordChange == CoordinateChange::AbsoluteToRelative) { |
| 2455 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | vertices = buildingTransformation.inverse() * vertices; |
| 2456 |
1/1✓ Branch 1 taken 1 time.
|
1 | setVertices(Shading_Building_DetailedFields::NumberofVertices + 1, buildingShading, vertices); |
| 2457 | ✗ | } else if (detailedCoordChange == CoordinateChange::RelativeToAbsolute) { | |
| 2458 | ✗ | vertices = buildingTransformation * vertices; | |
| 2459 | ✗ | setVertices(Shading_Building_DetailedFields::NumberofVertices + 1, buildingShading, vertices); | |
| 2460 | } | ||
| 2461 | } | ||
| 2462 | 107 | } | |
| 2463 | |||
| 2464 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 103 times.
|
107 | for (WorkspaceObject& siteShading : m_workspace.getObjectsByType(IddObjectType::Shading_Site_Detailed)) { |
| 2465 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
12 | siteShading.setString(Shading_Site_DetailedFields::NumberofVertices, "Autocalculate"); |
| 2466 | 103 | } | |
| 2467 | |||
| 2468 | 103 | return result; | |
| 2469 | 103 | } | |
| 2470 | |||
| 2471 | // get vertices for a surface | ||
| 2472 | 1695 | openstudio::Point3dVector getVertices(unsigned firstVertex, const IdfObject& surface) { | |
| 2473 | 1695 | Point3dVector result; | |
| 2474 |
1/1✓ Branch 1 taken 1695 times.
|
1695 | unsigned numFields = surface.numFields(); |
| 2475 | 1695 | unsigned numVertexFields = numFields - firstVertex; | |
| 2476 | 1695 | unsigned numVertices = numVertexFields / 3; // integer division | |
| 2477 | |||
| 2478 | // check that at least three vertices | ||
| 2479 |
2/4✓ Branch 0 taken 1695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1695 times.
✗ Branch 3 not taken.
|
1695 | if ((numVertexFields % 3) == 0 && numVertices >= 3) { |
| 2480 | |||
| 2481 |
2/2✓ Branch 0 taken 6759 times.
✓ Branch 1 taken 1695 times.
|
8454 | for (unsigned vertexIndex = 0; vertexIndex < numVertices; ++vertexIndex) { |
| 2482 |
1/1✓ Branch 1 taken 6759 times.
|
6759 | OptionalDouble x = surface.getDouble(firstVertex + 3 * vertexIndex + 0); |
| 2483 |
1/1✓ Branch 1 taken 6759 times.
|
6759 | OptionalDouble y = surface.getDouble(firstVertex + 3 * vertexIndex + 1); |
| 2484 |
1/1✓ Branch 1 taken 6759 times.
|
6759 | OptionalDouble z = surface.getDouble(firstVertex + 3 * vertexIndex + 2); |
| 2485 | |||
| 2486 |
4/8✓ Branch 0 taken 6759 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6759 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6759 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6759 times.
✗ Branch 7 not taken.
|
20277 | if (x && y && z) { |
| 2487 |
5/5✓ Branch 1 taken 6759 times.
✓ Branch 4 taken 6759 times.
✓ Branch 7 taken 6759 times.
✓ Branch 10 taken 6759 times.
✓ Branch 13 taken 6759 times.
|
6759 | result.push_back(Point3d(*x, *y, *z)); |
| 2488 | } else { | ||
| 2489 | ✗ | LOG_FREE(Error, "openstudio.energyplus.GeometryTranslator", | |
| 2490 | "Could not read vertex " << vertexIndex << " at indices " << firstVertex + 3 * vertexIndex + 0 << " to " | ||
| 2491 | << firstVertex + 3 * vertexIndex + 2); | ||
| 2492 | } | ||
| 2493 | } | ||
| 2494 | 1695 | } else { | |
| 2495 | ✗ | LOG_FREE(Error, "openstudio.energyplus.GeometryTranslator", "Fewer than 3 vertices detected for surface '" << surface.nameString() << "'"); | |
| 2496 | } | ||
| 2497 | |||
| 2498 | 1695 | return result; | |
| 2499 | ✗ | } | |
| 2500 | |||
| 2501 | // set vertices for a surface, only detailed surfaces are supported | ||
| 2502 | 695 | bool setVertices(unsigned firstVertex, WorkspaceObject& surface, const openstudio::Point3dVector& vertices) { | |
| 2503 | 695 | bool result = true; | |
| 2504 | |||
| 2505 | // delete current fields, cannot currently delete all so leave first 3 vertices | ||
| 2506 |
3/3✓ Branch 1 taken 3104 times.
✓ Branch 5 taken 2409 times.
✓ Branch 6 taken 695 times.
|
3104 | while (!surface.popExtensibleGroup().empty()) { |
| 2507 | } | ||
| 2508 | |||
| 2509 | // preallocate enough space for all vertices | ||
| 2510 |
2/2✓ Branch 2 taken 2773 times.
✓ Branch 3 taken 695 times.
|
3468 | while ((surface.numFields() - firstVertex) / 3 < vertices.size()) { |
| 2511 |
2/2✓ Branch 1 taken 2773 times.
✓ Branch 4 taken 2773 times.
|
8319 | surface.pushExtensibleGroup(StringVector(3)); |
| 2512 | } | ||
| 2513 | |||
| 2514 | // set the vertices | ||
| 2515 |
2/2✓ Branch 1 taken 2773 times.
✓ Branch 2 taken 695 times.
|
3468 | for (unsigned vertexIndex = 0; vertexIndex < vertices.size(); ++vertexIndex) { |
| 2516 |
1/2✗ Branch 3 not taken.
✓ Branch 4 taken 2773 times.
|
2773 | if (!surface.setDouble(firstVertex + 3 * vertexIndex + 0, vertices[vertexIndex].x())) { |
| 2517 | ✗ | LOG_FREE(Error, "openstudio.energyplus.GeometryTranslator", | |
| 2518 | "Could not set field index " << firstVertex + 3 * vertexIndex + 0 << " to " << vertices[vertexIndex].x()); | ||
| 2519 | ✗ | result = false; | |
| 2520 | } | ||
| 2521 |
1/2✗ Branch 3 not taken.
✓ Branch 4 taken 2773 times.
|
2773 | if (!surface.setDouble(firstVertex + 3 * vertexIndex + 1, vertices[vertexIndex].y())) { |
| 2522 | ✗ | LOG_FREE(Error, "openstudio.energyplus.GeometryTranslator", | |
| 2523 | "Could not set field index " << firstVertex + 3 * vertexIndex + 1 << " to " << vertices[vertexIndex].y()); | ||
| 2524 | ✗ | result = false; | |
| 2525 | } | ||
| 2526 |
1/2✗ Branch 3 not taken.
✓ Branch 4 taken 2773 times.
|
2773 | if (!surface.setDouble(firstVertex + 3 * vertexIndex + 2, vertices[vertexIndex].z())) { |
| 2527 | ✗ | LOG_FREE(Error, "openstudio.energyplus.GeometryTranslator", | |
| 2528 | "Could not set field index " << firstVertex + 3 * vertexIndex + 2 << " to " << vertices[vertexIndex].z()); | ||
| 2529 | ✗ | result = false; | |
| 2530 | } | ||
| 2531 | } | ||
| 2532 | |||
| 2533 | 695 | return result; | |
| 2534 | } | ||
| 2535 | |||
| 2536 | // reverse all detailed vertices | ||
| 2537 | ✗ | bool GeometryTranslator::reverseAllDetailedVertices() { | |
| 2538 | // BuildingSurface:Detailed | ||
| 2539 | ✗ | for (WorkspaceObject& object : m_workspace.getObjectsByType(IddObjectType::BuildingSurface_Detailed)) { | |
| 2540 | ✗ | Point3dVector vertices = getVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, object); | |
| 2541 | ✗ | std::reverse(vertices.begin(), vertices.end()); | |
| 2542 | ✗ | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, object, vertices); | |
| 2543 | ✗ | } | |
| 2544 | |||
| 2545 | // Wall:Detailed | ||
| 2546 | ✗ | for (WorkspaceObject& object : m_workspace.getObjectsByType(IddObjectType::Wall_Detailed)) { | |
| 2547 | ✗ | Point3dVector vertices = getVertices(Wall_DetailedFields::NumberofVertices + 1, object); | |
| 2548 | ✗ | std::reverse(vertices.begin(), vertices.end()); | |
| 2549 | ✗ | setVertices(Wall_DetailedFields::NumberofVertices + 1, object, vertices); | |
| 2550 | ✗ | } | |
| 2551 | |||
| 2552 | // RoofCeiling:Detailed | ||
| 2553 | ✗ | for (WorkspaceObject& object : m_workspace.getObjectsByType(IddObjectType::RoofCeiling_Detailed)) { | |
| 2554 | ✗ | Point3dVector vertices = getVertices(RoofCeiling_DetailedFields::NumberofVertices + 1, object); | |
| 2555 | ✗ | std::reverse(vertices.begin(), vertices.end()); | |
| 2556 | ✗ | setVertices(RoofCeiling_DetailedFields::NumberofVertices + 1, object, vertices); | |
| 2557 | ✗ | } | |
| 2558 | |||
| 2559 | // Floor:Detailed | ||
| 2560 | ✗ | for (WorkspaceObject& object : m_workspace.getObjectsByType(IddObjectType::Floor_Detailed)) { | |
| 2561 | ✗ | Point3dVector vertices = getVertices(Floor_DetailedFields::NumberofVertices + 1, object); | |
| 2562 | ✗ | std::reverse(vertices.begin(), vertices.end()); | |
| 2563 | ✗ | setVertices(Floor_DetailedFields::NumberofVertices + 1, object, vertices); | |
| 2564 | ✗ | } | |
| 2565 | |||
| 2566 | // FenestrationSurface:Detailed | ||
| 2567 | ✗ | for (WorkspaceObject& object : m_workspace.getObjectsByType(IddObjectType::FenestrationSurface_Detailed)) { | |
| 2568 | ✗ | Point3dVector vertices = getVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, object); | |
| 2569 | ✗ | std::reverse(vertices.begin(), vertices.end()); | |
| 2570 | ✗ | setVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, object, vertices); | |
| 2571 | ✗ | } | |
| 2572 | |||
| 2573 | // Shading:Site:Detailed | ||
| 2574 | ✗ | for (WorkspaceObject& object : m_workspace.getObjectsByType(IddObjectType::Shading_Site_Detailed)) { | |
| 2575 | ✗ | Point3dVector vertices = getVertices(Shading_Site_DetailedFields::NumberofVertices + 1, object); | |
| 2576 | ✗ | std::reverse(vertices.begin(), vertices.end()); | |
| 2577 | ✗ | setVertices(Shading_Site_DetailedFields::NumberofVertices + 1, object, vertices); | |
| 2578 | ✗ | } | |
| 2579 | |||
| 2580 | // Shading:Building:Detailed | ||
| 2581 | ✗ | for (WorkspaceObject& object : m_workspace.getObjectsByType(IddObjectType::Shading_Building_Detailed)) { | |
| 2582 | ✗ | Point3dVector vertices = getVertices(Shading_Building_DetailedFields::NumberofVertices + 1, object); | |
| 2583 | ✗ | std::reverse(vertices.begin(), vertices.end()); | |
| 2584 | ✗ | setVertices(Shading_Building_DetailedFields::NumberofVertices + 1, object, vertices); | |
| 2585 | ✗ | } | |
| 2586 | |||
| 2587 | // Shading:Zone:Detailed | ||
| 2588 | ✗ | for (WorkspaceObject& object : m_workspace.getObjectsByType(IddObjectType::Shading_Zone_Detailed)) { | |
| 2589 | ✗ | Point3dVector vertices = getVertices(Shading_Zone_DetailedFields::NumberofVertices + 1, object); | |
| 2590 | ✗ | std::reverse(vertices.begin(), vertices.end()); | |
| 2591 | ✗ | setVertices(Shading_Zone_DetailedFields::NumberofVertices + 1, object, vertices); | |
| 2592 | ✗ | } | |
| 2593 | |||
| 2594 | ✗ | return true; | |
| 2595 | } | ||
| 2596 | |||
| 2597 | // apply upper left corner rule to all detailed vertices | ||
| 2598 | 103 | bool GeometryTranslator::applyUpperLeftCornerRule() { | |
| 2599 | // BuildingSurface:Detailed | ||
| 2600 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 423 times.
✓ Branch 12 taken 103 times.
|
526 | for (WorkspaceObject& object : m_workspace.getObjectsByType(IddObjectType::BuildingSurface_Detailed)) { |
| 2601 |
1/1✓ Branch 1 taken 423 times.
|
423 | Point3dVector vertices = getVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, object); |
| 2602 |
2/2✓ Branch 1 taken 423 times.
✓ Branch 4 taken 423 times.
|
423 | setVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, object, reorderULC(vertices)); |
| 2603 | 526 | } | |
| 2604 | |||
| 2605 | // Wall:Detailed | ||
| 2606 |
3/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 103 times.
|
103 | for (WorkspaceObject& object : m_workspace.getObjectsByType(IddObjectType::Wall_Detailed)) { |
| 2607 | ✗ | Point3dVector vertices = getVertices(Wall_DetailedFields::NumberofVertices + 1, object); | |
| 2608 | ✗ | setVertices(Wall_DetailedFields::NumberofVertices + 1, object, reorderULC(vertices)); | |
| 2609 | 103 | } | |
| 2610 | |||
| 2611 | // RoofCeiling:Detailed | ||
| 2612 |
3/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 103 times.
|
103 | for (WorkspaceObject& object : m_workspace.getObjectsByType(IddObjectType::RoofCeiling_Detailed)) { |
| 2613 | ✗ | Point3dVector vertices = getVertices(RoofCeiling_DetailedFields::NumberofVertices + 1, object); | |
| 2614 | ✗ | setVertices(RoofCeiling_DetailedFields::NumberofVertices + 1, object, reorderULC(vertices)); | |
| 2615 | 103 | } | |
| 2616 | |||
| 2617 | // Floor:Detailed | ||
| 2618 |
3/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 103 times.
|
103 | for (WorkspaceObject& object : m_workspace.getObjectsByType(IddObjectType::Floor_Detailed)) { |
| 2619 | ✗ | Point3dVector vertices = getVertices(Floor_DetailedFields::NumberofVertices + 1, object); | |
| 2620 | ✗ | setVertices(Floor_DetailedFields::NumberofVertices + 1, object, reorderULC(vertices)); | |
| 2621 | 103 | } | |
| 2622 | |||
| 2623 | // FenestrationSurface:Detailed | ||
| 2624 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 132 times.
✓ Branch 12 taken 103 times.
|
235 | for (WorkspaceObject& object : m_workspace.getObjectsByType(IddObjectType::FenestrationSurface_Detailed)) { |
| 2625 |
1/1✓ Branch 1 taken 132 times.
|
132 | Point3dVector vertices = getVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, object); |
| 2626 |
2/2✓ Branch 1 taken 132 times.
✓ Branch 4 taken 132 times.
|
132 | setVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, object, reorderULC(vertices)); |
| 2627 | 235 | } | |
| 2628 | |||
| 2629 | // Shading:Site:Detailed | ||
| 2630 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 12 times.
✓ Branch 12 taken 103 times.
|
115 | for (WorkspaceObject& object : m_workspace.getObjectsByType(IddObjectType::Shading_Site_Detailed)) { |
| 2631 |
1/1✓ Branch 1 taken 12 times.
|
12 | Point3dVector vertices = getVertices(Shading_Site_DetailedFields::NumberofVertices + 1, object); |
| 2632 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | setVertices(Shading_Site_DetailedFields::NumberofVertices + 1, object, reorderULC(vertices)); |
| 2633 | 115 | } | |
| 2634 | |||
| 2635 | // Shading:Building:Detailed | ||
| 2636 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 11 times.
✓ Branch 12 taken 103 times.
|
114 | for (WorkspaceObject& object : m_workspace.getObjectsByType(IddObjectType::Shading_Building_Detailed)) { |
| 2637 |
1/1✓ Branch 1 taken 11 times.
|
11 | Point3dVector vertices = getVertices(Shading_Building_DetailedFields::NumberofVertices + 1, object); |
| 2638 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | setVertices(Shading_Building_DetailedFields::NumberofVertices + 1, object, reorderULC(vertices)); |
| 2639 | 114 | } | |
| 2640 | |||
| 2641 | // Shading:Zone:Detailed | ||
| 2642 |
4/4✓ Branch 1 taken 103 times.
✓ Branch 4 taken 103 times.
✓ Branch 11 taken 13 times.
✓ Branch 12 taken 103 times.
|
116 | for (WorkspaceObject& object : m_workspace.getObjectsByType(IddObjectType::Shading_Zone_Detailed)) { |
| 2643 |
1/1✓ Branch 1 taken 13 times.
|
13 | Point3dVector vertices = getVertices(Shading_Zone_DetailedFields::NumberofVertices + 1, object); |
| 2644 |
2/2✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
|
13 | setVertices(Shading_Zone_DetailedFields::NumberofVertices + 1, object, reorderULC(vertices)); |
| 2645 | 116 | } | |
| 2646 | |||
| 2647 | 103 | return true; | |
| 2648 | } | ||
| 2649 | |||
| 2650 | // convert azimuth, tilt, starting x, y, z, length, and width to vertices | ||
| 2651 | // azimuth and tilt are in degrees | ||
| 2652 | 56 | openstudio::Point3dVector verticesForAzimuthTiltXYZLengthWidthOrHeight(double azimuth, double tilt, double x0, double y0, double z0, double length, | |
| 2653 | double widthOrHeight) { | ||
| 2654 |
1/1✓ Branch 1 taken 56 times.
|
56 | openstudio::Point3dVector result(4); |
| 2655 | |||
| 2656 |
1/1✓ Branch 1 taken 56 times.
|
56 | openstudio::Vector xpts(4, 0.0); |
| 2657 |
1/1✓ Branch 1 taken 56 times.
|
56 | xpts[2] = length; |
| 2658 |
1/1✓ Branch 1 taken 56 times.
|
56 | xpts[3] = length; |
| 2659 | |||
| 2660 |
1/1✓ Branch 1 taken 56 times.
|
56 | openstudio::Vector ypts(4, 0.0); |
| 2661 |
1/1✓ Branch 1 taken 56 times.
|
56 | ypts[0] = widthOrHeight; |
| 2662 |
1/1✓ Branch 1 taken 56 times.
|
56 | ypts[3] = widthOrHeight; |
| 2663 | |||
| 2664 | // code copied out of EnergyPlus does not seem to make sense given the documentation in | ||
| 2665 | // InputOutput reference | ||
| 2666 |
1/1✓ Branch 1 taken 56 times.
|
56 | double cosAzimuth = std::cos(degToRad(azimuth)); |
| 2667 |
1/1✓ Branch 1 taken 56 times.
|
56 | double sinAzimuth = std::sin(degToRad(azimuth)); |
| 2668 |
1/1✓ Branch 1 taken 56 times.
|
56 | double cosTilt = std::cos(degToRad(tilt)); |
| 2669 |
1/1✓ Branch 1 taken 56 times.
|
56 | double sinTilt = std::sin(degToRad(tilt)); |
| 2670 | |||
| 2671 |
2/2✓ Branch 0 taken 224 times.
✓ Branch 1 taken 56 times.
|
280 | for (unsigned i = 0; i < 4; ++i) { |
| 2672 |
2/2✓ Branch 1 taken 224 times.
✓ Branch 4 taken 224 times.
|
224 | double x = x0 - cosAzimuth * xpts[i] - cosTilt * sinAzimuth * ypts[i]; |
| 2673 |
2/2✓ Branch 1 taken 224 times.
✓ Branch 4 taken 224 times.
|
224 | double y = y0 + sinAzimuth * xpts[i] - cosTilt * cosAzimuth * ypts[i]; |
| 2674 |
1/1✓ Branch 1 taken 224 times.
|
224 | double z = z0 + sinTilt * ypts[i]; |
| 2675 |
1/1✓ Branch 1 taken 224 times.
|
224 | result[i] = Point3d(x, y, z); |
| 2676 | } | ||
| 2677 | |||
| 2678 | 112 | return result; | |
| 2679 | 56 | } | |
| 2680 | |||
| 2681 | } // namespace energyplus | ||
| 2682 | } // namespace openstudio | ||
| 2683 |