src/model/FloorspaceReverseTranslator.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 "FloorspaceReverseTranslator.hpp" | ||
| 7 | #include "FloorspaceReverseTranslator_Impl.hpp" | ||
| 8 | |||
| 9 | #include "FileOperations.hpp" | ||
| 10 | #include "RenderingColor.hpp" | ||
| 11 | #include "ConstructionBase.hpp" | ||
| 12 | #include "ConstructionBase_Impl.hpp" | ||
| 13 | #include "ThermalZone.hpp" | ||
| 14 | #include "ThermalZone_Impl.hpp" | ||
| 15 | #include "SpaceType.hpp" | ||
| 16 | #include "SpaceType_Impl.hpp" | ||
| 17 | #include "Building.hpp" | ||
| 18 | #include "Building_Impl.hpp" | ||
| 19 | #include "BuildingStory.hpp" | ||
| 20 | #include "BuildingStory_Impl.hpp" | ||
| 21 | #include "BuildingUnit.hpp" | ||
| 22 | #include "BuildingUnit_Impl.hpp" | ||
| 23 | #include "Construction.hpp" | ||
| 24 | #include "Construction_Impl.hpp" | ||
| 25 | #include "ConstructionAirBoundary.hpp" | ||
| 26 | #include "ConstructionAirBoundary_Impl.hpp" | ||
| 27 | #include "Surface.hpp" | ||
| 28 | #include "Surface_Impl.hpp" | ||
| 29 | #include "SubSurface.hpp" | ||
| 30 | #include "SubSurface_Impl.hpp" | ||
| 31 | #include "ShadingSurface.hpp" | ||
| 32 | #include "ShadingSurface_Impl.hpp" | ||
| 33 | #include "ShadingSurfaceGroup.hpp" | ||
| 34 | #include "ShadingSurfaceGroup_Impl.hpp" | ||
| 35 | #include "InteriorPartitionSurface.hpp" | ||
| 36 | #include "InteriorPartitionSurface_Impl.hpp" | ||
| 37 | #include "InteriorPartitionSurfaceGroup.hpp" | ||
| 38 | #include "InteriorPartitionSurfaceGroup_Impl.hpp" | ||
| 39 | #include "PlanarSurfaceGroup.hpp" | ||
| 40 | #include "PlanarSurfaceGroup_Impl.hpp" | ||
| 41 | #include "Space.hpp" | ||
| 42 | #include "Space_Impl.hpp" | ||
| 43 | #include "DefaultConstructionSet.hpp" | ||
| 44 | #include "DefaultConstructionSet_Impl.hpp" | ||
| 45 | #include "DaylightingControl.hpp" | ||
| 46 | |||
| 47 | #include "../utilities/core/Assert.hpp" | ||
| 48 | #include "../utilities/core/Compare.hpp" | ||
| 49 | #include "../utilities/geometry/Point3d.hpp" | ||
| 50 | #include "../utilities/geometry/Plane.hpp" | ||
| 51 | #include "../utilities/geometry/BoundingBox.hpp" | ||
| 52 | #include "../utilities/geometry/Transformation.hpp" | ||
| 53 | #include "../utilities/geometry/Geometry.hpp" | ||
| 54 | #include "../utilities/geometry/Intersection.hpp" | ||
| 55 | #include "../utilities/floorspace/FSVisitor.hpp" | ||
| 56 | |||
| 57 | #include <thread> | ||
| 58 | |||
| 59 | #include <cmath> | ||
| 60 | |||
| 61 | namespace openstudio { | ||
| 62 | namespace model { | ||
| 63 | static constexpr auto BELOWFLOORPLENUMPOSTFIX(" Floor Plenum"); | ||
| 64 | static constexpr auto ABOVECEILINGPLENUMPOSTFIX(" Plenum"); | ||
| 65 | static constexpr auto PLENUMSPACETYPENAME("Plenum Space Type"); // DLM: needs to be coordinated with name in Model_Impl::plenumSpaceType() | ||
| 66 | |||
| 67 | // TODO: Creating surfaces for spaces and creatig shading surfaces for building shading have | ||
| 68 | // a lot of code in common but there are significant differences also. At some point we | ||
| 69 | // shoud look into creating some common functions that calculate the vertices | ||
| 70 | |||
| 71 | // A Visitor design pattern class. Each Dispatch method handles creation of OSM | ||
| 72 | // concepts from the FloorspaceJS concepts | ||
| 73 | namespace detail { | ||
| 74 | 29 | FloorspaceReverseTranslator_Impl::FloorspaceReverseTranslator_Impl(Model& model) : m_model(model) {} | |
| 75 | |||
| 76 | /// Mapping between handles referenced in Floorspace (keys) and handles of objects in returned model (values) for last translation | ||
| 77 | /// This handle mapping can be used by the ModelMerger when merging returned model (new handles) with an existing model (existing handles) | ||
| 78 | /// Note that this mapping may not include all objects such as Site, Building, or other objects not specified in the ThreeScene | ||
| 79 | 29 | std::map<UUID, UUID> FloorspaceReverseTranslator_Impl::handleMapping() const { | |
| 80 | 29 | return m_handleMapping; | |
| 81 | } | ||
| 82 | |||
| 83 | // Creates a BuildingUnit | ||
| 84 | 9 | void FloorspaceReverseTranslator_Impl::Dispatch(const FSBuildingUnit& fsEntity) { | |
| 85 |
1/1✓ Branch 1 taken 9 times.
|
9 | BuildingUnit buildingUnit(m_model); |
| 86 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | buildingUnit.setName(fsEntity.name()); |
| 87 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | boost::optional<RenderingColor> renderingColor = RenderingColor::fromColorString(fsEntity.color(), m_model); |
| 88 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 7 times.
|
9 | if (renderingColor.has_value()) { |
| 89 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | buildingUnit.setRenderingColor(*renderingColor); |
| 90 | } | ||
| 91 |
1/1✓ Branch 1 taken 9 times.
|
9 | MapHandles(fsEntity, buildingUnit); |
| 92 | 9 | } | |
| 93 | |||
| 94 | ✗ | void FloorspaceReverseTranslator_Impl::Dispatch(const FSBuildingType& entity) { | |
| 95 | // TODO: building_type does not appear to go anywhere | ||
| 96 | ✗ | } | |
| 97 | |||
| 98 | // Config provides units but usints already factored in so no need to do anything here | ||
| 99 | ✗ | void FloorspaceReverseTranslator_Impl::Dispatch(const FSConfig& entity) {} | |
| 100 | |||
| 101 | // Creates a DefaultConstructionSet | ||
| 102 | 9 | void FloorspaceReverseTranslator_Impl::Dispatch(const FSConstructionSet& fsEntity) { | |
| 103 |
1/1✓ Branch 1 taken 9 times.
|
9 | DefaultConstructionSet constructionSet(m_model); |
| 104 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | constructionSet.setName(fsEntity.name()); |
| 105 |
1/1✓ Branch 1 taken 9 times.
|
9 | MapHandles(fsEntity, constructionSet); |
| 106 | 9 | } | |
| 107 | |||
| 108 | // Creates a daylighting control | ||
| 109 | 11 | void FloorspaceReverseTranslator_Impl::Dispatch(const FSDaylightingControl& fsEntity) { | |
| 110 |
1/1✓ Branch 1 taken 11 times.
|
11 | auto definition = fsEntity.definition(); |
| 111 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | if (definition.has_value()) { |
| 112 |
1/1✓ Branch 1 taken 11 times.
|
11 | DaylightingControl osDaylightingControl(m_model); |
| 113 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | osDaylightingControl.setName(fsEntity.name()); |
| 114 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | osDaylightingControl.setIlluminanceSetpoint(definition->illuminanceSetpoint()); |
| 115 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | osDaylightingControl.setPosition(fsEntity.point()); |
| 116 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | osDaylightingControl.setSpace(*m_currentSpace); |
| 117 | |||
| 118 |
3/4✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 8 taken 11 times.
✗ Branch 9 not taken.
|
11 | if (m_currentSpace->thermalZone().has_value()) { |
| 119 |
6/6✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
✓ Branch 15 taken 7 times.
✓ Branch 16 taken 4 times.
|
11 | if (!m_currentSpace->thermalZone()->primaryDaylightingControl().has_value()) { |
| 120 |
4/4✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✓ Branch 10 taken 7 times.
|
7 | m_currentSpace->thermalZone()->setPrimaryDaylightingControl(osDaylightingControl); |
| 121 |
6/6✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 15 taken 3 times.
✓ Branch 16 taken 1 time.
|
4 | } else if (!m_currentSpace->thermalZone()->secondaryDaylightingControl().has_value()) { |
| 122 |
4/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
|
3 | m_currentSpace->thermalZone()->setSecondaryDaylightingControl(osDaylightingControl); |
| 123 | } | ||
| 124 | } | ||
| 125 | |||
| 126 |
1/1✓ Branch 1 taken 11 times.
|
11 | MapHandles(fsEntity, osDaylightingControl); |
| 127 | 11 | } | |
| 128 | 11 | } | |
| 129 | |||
| 130 | ✗ | void FloorspaceReverseTranslator_Impl::Dispatch(const FSDaylightingControlDefinition& entity) {} | |
| 131 | // Door is processed when FSSpace is processed | ||
| 132 | ✗ | void FloorspaceReverseTranslator_Impl::Dispatch(const FSDoor& entity) {} | |
| 133 | ✗ | void FloorspaceReverseTranslator_Impl::Dispatch(const FSDoorDefinition& entity) {} | |
| 134 | ✗ | void FloorspaceReverseTranslator_Impl::Dispatch(const FSGround& entity) {} | |
| 135 | |||
| 136 | 29 | void FloorspaceReverseTranslator_Impl::Dispatch(const FSModel& fsModel) { | |
| 137 |
2/2✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
|
29 | initializeModelObjects(m_model); |
| 138 |
1/1✓ Branch 1 taken 29 times.
|
29 | Building building = m_model.getUniqueModelObject<Building>(); |
| 139 | // set the model's north axis, opposite of the floorspace and threejs convention | ||
| 140 |
3/3✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
|
29 | double northAxis = fsModel.project()->northAxis(); |
| 141 |
1/1✓ Branch 1 taken 29 times.
|
29 | building.setNorthAxis(-northAxis); |
| 142 | |||
| 143 |
3/3✓ Branch 1 taken 29 times.
✓ Branch 8 taken 547 times.
✓ Branch 9 taken 29 times.
|
576 | for (auto& zone : fsModel.thermalZones()) { |
| 144 |
1/1✓ Branch 1 taken 547 times.
|
547 | zone.Accept(*this); |
| 145 | 29 | } | |
| 146 | |||
| 147 |
3/3✓ Branch 1 taken 29 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 29 times.
|
38 | for (auto& unit : fsModel.buildingUnits()) { |
| 148 |
1/1✓ Branch 1 taken 9 times.
|
9 | unit.Accept(*this); |
| 149 | 29 | } | |
| 150 | |||
| 151 |
3/3✓ Branch 1 taken 29 times.
✓ Branch 8 taken 113 times.
✓ Branch 9 taken 29 times.
|
142 | for (auto& type : fsModel.spaceTypes()) { |
| 152 |
1/1✓ Branch 1 taken 113 times.
|
113 | type.Accept(*this); |
| 153 | 29 | } | |
| 154 | |||
| 155 |
3/3✓ Branch 1 taken 29 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 29 times.
|
38 | for (auto& constructionSet : fsModel.constructionSets()) { |
| 156 |
1/1✓ Branch 1 taken 9 times.
|
9 | constructionSet.Accept(*this); |
| 157 | 29 | } | |
| 158 | |||
| 159 | // This is the starting elevation for the stories | ||
| 160 |
4/4✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
✓ Branch 10 taken 29 times.
|
29 | m_currentStoryZ = fsModel.project()->ground().floorOffset(); |
| 161 | |||
| 162 |
3/3✓ Branch 1 taken 29 times.
✓ Branch 8 taken 72 times.
✓ Branch 9 taken 29 times.
|
101 | for (auto& story : fsModel.stories()) { |
| 163 |
1/1✓ Branch 1 taken 72 times.
|
72 | story.Accept(*this); |
| 164 | 29 | } | |
| 165 | 29 | } | |
| 166 | |||
| 167 | // There's no OS equivalent | ||
| 168 | ✗ | void FloorspaceReverseTranslator_Impl::Dispatch(const FSProject& entity) {} | |
| 169 | |||
| 170 | // Creates a building shading group and shading surfaces | ||
| 171 | 42 | void FloorspaceReverseTranslator_Impl::Dispatch(const FSShading& entity) { | |
| 172 |
1/2✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
|
42 | if (m_currentFSStory.has_value()) { |
| 173 | |||
| 174 | 42 | double minZ = m_currentStoryZ; | |
| 175 | 42 | double maxZ = minZ + entity.belowFloorPlenumHeight(); | |
| 176 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 38 times.
|
42 | if (entity.belowFloorPlenumHeight() > 0) { |
| 177 | 4 | createShadingSurfaceGroup(entity, minZ, maxZ, SpaceTypeEnum::BELOWFLOOR); | |
| 178 | } | ||
| 179 | |||
| 180 | 42 | minZ = maxZ; | |
| 181 | 42 | maxZ = minZ + entity.floorToCeilingHeight(); | |
| 182 |
1/2✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
|
42 | if (entity.floorToCeilingHeight() > 0) { |
| 183 | 42 | createShadingSurfaceGroup(entity, minZ, maxZ, SpaceTypeEnum::ABOVEFLOOR); | |
| 184 | } | ||
| 185 | |||
| 186 | 42 | minZ = maxZ; | |
| 187 | 42 | maxZ = minZ + entity.aboveCeilingPlenumHeight(); | |
| 188 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 2 taken 37 times.
|
42 | if (entity.aboveCeilingPlenumHeight() > 0) { |
| 189 | 5 | createShadingSurfaceGroup(entity, minZ, maxZ, SpaceTypeEnum::ABOVECEILING); | |
| 190 | } | ||
| 191 | } | ||
| 192 | 42 | } | |
| 193 | |||
| 194 | 656 | void FloorspaceReverseTranslator_Impl::Dispatch(const FSSpace& space) { | |
| 195 | // Minz and Maxz will define the height and elevation of the surfaces | ||
| 196 | 656 | double minZ = m_currentStoryZ + space.offset(); | |
| 197 | 656 | double maxZ = minZ + space.belowFloorPlenumHeight(); | |
| 198 | |||
| 199 | // The lower of the three spaces gets to be open to below | ||
| 200 | 656 | bool openToBelow = space.openToBelow(); | |
| 201 | // Create up to three spaces depending on the plenum heights | ||
| 202 | // If the Floorspace space is in a thermal zone then thermal zones are created for all three spaces | ||
| 203 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 652 times.
|
656 | if (space.belowFloorPlenumHeight() > 0) { |
| 204 | 4 | createSpace(space, minZ, maxZ, SpaceTypeEnum::BELOWFLOOR, openToBelow); | |
| 205 | 4 | openToBelow = false; | |
| 206 | } | ||
| 207 | |||
| 208 | 656 | minZ = maxZ; | |
| 209 | 656 | maxZ = minZ + space.floorToCeilingHeight(); | |
| 210 |
1/2✓ Branch 1 taken 656 times.
✗ Branch 2 not taken.
|
656 | if (space.floorToCeilingHeight() > 0) { |
| 211 | 656 | createSpace(space, minZ, maxZ, SpaceTypeEnum::ABOVEFLOOR, openToBelow); | |
| 212 | 656 | openToBelow = false; | |
| 213 | } | ||
| 214 | |||
| 215 | 656 | minZ = maxZ; | |
| 216 | 656 | maxZ = minZ + space.aboveCeilingHeight(); | |
| 217 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 652 times.
|
656 | if (space.aboveCeilingHeight() > 0) { |
| 218 | 4 | createSpace(space, minZ, maxZ, SpaceTypeEnum::ABOVECEILING, openToBelow); | |
| 219 | 4 | openToBelow = false; | |
| 220 | } | ||
| 221 | 656 | } | |
| 222 | |||
| 223 | 113 | void FloorspaceReverseTranslator_Impl::Dispatch(const FSSpaceType& fsEntity) { | |
| 224 |
1/1✓ Branch 1 taken 113 times.
|
113 | SpaceType spaceType(m_model); |
| 225 |
2/2✓ Branch 1 taken 113 times.
✓ Branch 4 taken 113 times.
|
113 | spaceType.setName(fsEntity.name()); |
| 226 |
2/2✓ Branch 1 taken 113 times.
✓ Branch 4 taken 113 times.
|
113 | boost::optional<RenderingColor> renderingColor = RenderingColor::fromColorString(fsEntity.color(), m_model); |
| 227 |
2/2✓ Branch 1 taken 88 times.
✓ Branch 2 taken 25 times.
|
113 | if (renderingColor.has_value()) { |
| 228 |
2/2✓ Branch 1 taken 88 times.
✓ Branch 4 taken 88 times.
|
88 | spaceType.setRenderingColor(*renderingColor); |
| 229 | } | ||
| 230 | |||
| 231 |
1/1✓ Branch 1 taken 113 times.
|
113 | MapHandles(fsEntity, spaceType); |
| 232 | 113 | } | |
| 233 | |||
| 234 | // Creates a BuildingStory and its contents | ||
| 235 | 72 | void FloorspaceReverseTranslator_Impl::Dispatch(const FSStory& fsEntity) { | |
| 236 |
1/1✓ Branch 1 taken 72 times.
|
72 | BuildingStory buildingStory(m_model); |
| 237 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
|
72 | buildingStory.setName(fsEntity.name()); |
| 238 |
1/1✓ Branch 1 taken 72 times.
|
72 | buildingStory.setNominalZCoordinate(m_currentStoryZ); |
| 239 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
|
72 | buildingStory.setNominalFloortoCeilingHeight(fsEntity.floorToCeilingHeight()); |
| 240 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
|
72 | buildingStory.setNominalFloortoFloorHeight(fsEntity.floorToFloorHeight()); |
| 241 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
|
72 | boost::optional<RenderingColor> renderingColor = RenderingColor::fromColorString(fsEntity.color(), m_model); |
| 242 |
2/2✓ Branch 1 taken 49 times.
✓ Branch 2 taken 23 times.
|
72 | if (renderingColor.has_value()) { |
| 243 |
2/2✓ Branch 1 taken 49 times.
✓ Branch 4 taken 49 times.
|
49 | buildingStory.setRenderingColor(*renderingColor); |
| 244 | } | ||
| 245 |
1/1✓ Branch 1 taken 72 times.
|
72 | m_currentStory = buildingStory; |
| 246 |
1/1✓ Branch 1 taken 72 times.
|
72 | m_currentFSStory = fsEntity; |
| 247 | |||
| 248 | // Create space and surfaces | ||
| 249 |
3/3✓ Branch 1 taken 72 times.
✓ Branch 8 taken 656 times.
✓ Branch 9 taken 72 times.
|
728 | for (const auto& space : fsEntity.spaces()) { |
| 250 |
1/1✓ Branch 1 taken 656 times.
|
656 | space.Accept(*this); |
| 251 | 72 | } | |
| 252 | |||
| 253 | // Create shading | ||
| 254 |
3/3✓ Branch 1 taken 72 times.
✓ Branch 8 taken 42 times.
✓ Branch 9 taken 72 times.
|
114 | for (const auto& shading : fsEntity.shadings()) { |
| 255 |
1/1✓ Branch 1 taken 42 times.
|
42 | shading.Accept(*this); |
| 256 | 72 | } | |
| 257 | |||
| 258 | // Increment story elevation for the next story | ||
| 259 |
1/1✓ Branch 1 taken 72 times.
|
72 | m_currentStoryZ += fsEntity.floorToFloorHeight(); |
| 260 | |||
| 261 |
1/1✓ Branch 1 taken 72 times.
|
72 | MapHandles(fsEntity, buildingStory); |
| 262 | |||
| 263 | 72 | m_currentStory = boost::none; | |
| 264 | 72 | } | |
| 265 | |||
| 266 | 547 | void FloorspaceReverseTranslator_Impl::Dispatch(const FSThermalZone& fsEntity) { | |
| 267 |
1/1✓ Branch 1 taken 547 times.
|
547 | ThermalZone thermalZone(m_model); |
| 268 |
2/2✓ Branch 1 taken 547 times.
✓ Branch 4 taken 547 times.
|
547 | thermalZone.setName(fsEntity.name()); |
| 269 |
2/2✓ Branch 1 taken 547 times.
✓ Branch 4 taken 547 times.
|
547 | boost::optional<RenderingColor> renderingColor = RenderingColor::fromColorString(fsEntity.color(), m_model); |
| 270 |
2/2✓ Branch 0 taken 515 times.
✓ Branch 1 taken 32 times.
|
547 | if (renderingColor) { |
| 271 |
2/2✓ Branch 1 taken 515 times.
✓ Branch 4 taken 515 times.
|
515 | thermalZone.setRenderingColor(*renderingColor); |
| 272 | } | ||
| 273 | |||
| 274 |
1/1✓ Branch 1 taken 547 times.
|
547 | MapHandles(fsEntity, thermalZone); |
| 275 | 547 | } | |
| 276 | |||
| 277 | ✗ | void FloorspaceReverseTranslator_Impl::Dispatch(const FSWindow& entity) {} | |
| 278 | ✗ | void FloorspaceReverseTranslator_Impl::Dispatch(const FSWindowDefinition& entity) {} | |
| 279 | |||
| 280 | // Maps the handle in the floorspace model (if defined) to the handle of the object created in the open studio model | ||
| 281 | 1476 | void FloorspaceReverseTranslator_Impl::MapHandles(const FSBase& fsEntity, const ModelObject& modelObject) { | |
| 282 |
2/2✓ Branch 1 taken 1476 times.
✓ Branch 4 taken 1476 times.
|
1476 | UUID handle = toUUID(fsEntity.handle()); |
| 283 |
2/2✓ Branch 1 taken 105 times.
✓ Branch 2 taken 1371 times.
|
1476 | if (!handle.isNull()) { |
| 284 |
2/2✓ Branch 1 taken 105 times.
✓ Branch 4 taken 105 times.
|
105 | m_handleMapping[handle] = modelObject.handle(); |
| 285 | } | ||
| 286 | 1476 | } | |
| 287 | |||
| 288 | 1277 | std::string FloorspaceReverseTranslator_Impl::getPlenumPostfix(SpaceTypeEnum spaceType) { | |
| 289 |
3/4✓ Branch 0 taken 12 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 1254 times.
✗ Branch 3 not taken.
|
1277 | switch (spaceType) { |
| 290 | 12 | case SpaceTypeEnum::ABOVECEILING: | |
| 291 |
1/1✓ Branch 1 taken 12 times.
|
24 | return ABOVECEILINGPLENUMPOSTFIX; |
| 292 | 11 | case SpaceTypeEnum::BELOWFLOOR: | |
| 293 |
1/1✓ Branch 1 taken 11 times.
|
22 | return BELOWFLOORPLENUMPOSTFIX; |
| 294 | 1254 | case SpaceTypeEnum::ABOVEFLOOR: | |
| 295 |
1/1✓ Branch 1 taken 1254 times.
|
2508 | return ""; |
| 296 | } | ||
| 297 | |||
| 298 | ✗ | return ""; | |
| 299 | } | ||
| 300 | |||
| 301 | 51 | void FloorspaceReverseTranslator_Impl::createShadingSurfaceGroup(const FSShading& fsEntity, double minZ, double maxZ, SpaceTypeEnum spaceType) { | |
| 302 |
1/1✓ Branch 1 taken 51 times.
|
51 | auto face = fsEntity.face(); |
| 303 |
1/2✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
|
51 | if (face.has_value()) { |
| 304 |
1/1✓ Branch 1 taken 51 times.
|
51 | ShadingSurfaceGroup osShadingGroup(m_model); |
| 305 |
4/4✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
✓ Branch 7 taken 51 times.
✓ Branch 10 taken 51 times.
|
51 | osShadingGroup.setName(fsEntity.name() + getPlenumPostfix(spaceType)); |
| 306 |
2/2✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
|
51 | osShadingGroup.setShadingSurfaceType("Building"); |
| 307 | |||
| 308 | 51 | Point3dVector faceVertices; | |
| 309 |
4/4✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
✓ Branch 10 taken 304 times.
✓ Branch 11 taken 51 times.
|
355 | for (const auto& edgeRef : face->edgeRefs()) { |
| 310 |
1/1✓ Branch 1 taken 304 times.
|
304 | const FSVertex& vertex = edgeRef.getNextVertex(); |
| 311 |
4/4✓ Branch 1 taken 304 times.
✓ Branch 4 taken 304 times.
✓ Branch 7 taken 304 times.
✓ Branch 10 taken 304 times.
|
304 | faceVertices.emplace_back(Point3d(vertex.x(), vertex.y(), minZ)); |
| 312 | 51 | } | |
| 313 | |||
| 314 | // Get the original orientation pf the face vertices | ||
| 315 |
1/1✓ Branch 1 taken 51 times.
|
51 | boost::optional<Vector3d> outwardNormal = getOutwardNormal(faceVertices); |
| 316 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
|
51 | if (!outwardNormal) { |
| 317 | //LOG(Error, "Cannot compute outwardNormal for floorPrint."); | ||
| 318 | ✗ | return; | |
| 319 | } | ||
| 320 | |||
| 321 | // We need the face to be oriented anti-clockwise to guarantee that vertical | ||
| 322 | // surfaces are generated correctly. If the orientation is reversed then | ||
| 323 | // we will reverse the sense of the edge when extracting vertices | ||
| 324 |
2/2✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
|
51 | bool reversed = outwardNormal->z() < 0; |
| 325 | |||
| 326 |
1/1✓ Branch 1 taken 51 times.
|
51 | createFloorShading(osShadingGroup, faceVertices, minZ); |
| 327 |
1/1✓ Branch 1 taken 51 times.
|
51 | createRoofShading(osShadingGroup, faceVertices, maxZ); |
| 328 | |||
| 329 | // Create wall surfaces | ||
| 330 |
4/4✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
✓ Branch 11 taken 304 times.
✓ Branch 12 taken 51 times.
|
355 | for (const auto& edgeRef : face->edgeRefs()) { |
| 331 |
1/1✓ Branch 1 taken 304 times.
|
304 | createWallShading(osShadingGroup, fsEntity, edgeRef, minZ, maxZ, reversed); |
| 332 | 51 | } | |
| 333 | |||
| 334 |
1/1✓ Branch 1 taken 51 times.
|
51 | MapHandles(fsEntity, osShadingGroup); |
| 335 | 51 | } | |
| 336 | 51 | } | |
| 337 | |||
| 338 | 51 | void FloorspaceReverseTranslator_Impl::createFloorShading(ShadingSurfaceGroup& osGroup, Point3dVector& faceVertices, double z) { | |
| 339 |
1/2✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
|
51 | if (orientVerticesForFloor(faceVertices)) { |
| 340 | 51 | createShadingSurface(osGroup, faceVertices, z); | |
| 341 | } | ||
| 342 | 51 | } | |
| 343 | |||
| 344 | 51 | void FloorspaceReverseTranslator_Impl::createRoofShading(ShadingSurfaceGroup& osGroup, Point3dVector& faceVertices, double z) { | |
| 345 |
1/2✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
|
51 | if (orientVerticesForRoof(faceVertices)) { |
| 346 | 51 | createShadingSurface(osGroup, faceVertices, z); | |
| 347 | } | ||
| 348 | 51 | } | |
| 349 | |||
| 350 | // TODO: fsShading unused | ||
| 351 | 304 | void FloorspaceReverseTranslator_Impl::createWallShading(ShadingSurfaceGroup& osGroup, const FSShading& fsShading, const FSEdgeReference& edgeRef, | |
| 352 | double minZ, double maxZ, bool reversed) { | ||
| 353 | |||
| 354 | 304 | Point3dVector wallVertices; | |
| 355 |
2/2✓ Branch 1 taken 304 times.
✓ Branch 4 taken 304 times.
|
304 | const FSVertex& v1 = edgeRef.edge().firstVertex(); |
| 356 |
2/2✓ Branch 1 taken 304 times.
✓ Branch 4 taken 304 times.
|
304 | const FSVertex& v2 = edgeRef.edge().secondVertex(); |
| 357 | |||
| 358 | // Get the edge order (v1..v2 or v2..v1) and reverse if necessary to ensure | ||
| 359 | // the wall surface is oriented correctly | ||
| 360 |
1/1✓ Branch 1 taken 304 times.
|
304 | int edgeOrder = edgeRef.edgeOrder(); |
| 361 |
4/4✓ Branch 0 taken 291 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 102 times.
|
304 | if (edgeOrder == 1 && reversed) { |
| 362 | 189 | edgeOrder = 0; | |
| 363 |
4/4✓ Branch 0 taken 13 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 6 times.
|
115 | } else if (edgeOrder == 0 && reversed) { |
| 364 | 7 | edgeOrder = 1; | |
| 365 | } | ||
| 366 | |||
| 367 |
2/2✓ Branch 0 taken 109 times.
✓ Branch 1 taken 195 times.
|
304 | if (edgeOrder == 1) { |
| 368 |
4/4✓ Branch 1 taken 109 times.
✓ Branch 4 taken 109 times.
✓ Branch 7 taken 109 times.
✓ Branch 10 taken 109 times.
|
109 | wallVertices.push_back(Point3d(v2.x(), v2.y(), maxZ)); |
| 369 |
4/4✓ Branch 1 taken 109 times.
✓ Branch 4 taken 109 times.
✓ Branch 7 taken 109 times.
✓ Branch 10 taken 109 times.
|
109 | wallVertices.push_back(Point3d(v1.x(), v1.y(), maxZ)); |
| 370 |
4/4✓ Branch 1 taken 109 times.
✓ Branch 4 taken 109 times.
✓ Branch 7 taken 109 times.
✓ Branch 10 taken 109 times.
|
109 | wallVertices.push_back(Point3d(v1.x(), v1.y(), minZ)); |
| 371 |
4/4✓ Branch 1 taken 109 times.
✓ Branch 4 taken 109 times.
✓ Branch 7 taken 109 times.
✓ Branch 10 taken 109 times.
|
109 | wallVertices.push_back(Point3d(v2.x(), v2.y(), minZ)); |
| 372 | } else { | ||
| 373 |
4/4✓ Branch 1 taken 195 times.
✓ Branch 4 taken 195 times.
✓ Branch 7 taken 195 times.
✓ Branch 10 taken 195 times.
|
195 | wallVertices.push_back(Point3d(v1.x(), v1.y(), maxZ)); |
| 374 |
4/4✓ Branch 1 taken 195 times.
✓ Branch 4 taken 195 times.
✓ Branch 7 taken 195 times.
✓ Branch 10 taken 195 times.
|
195 | wallVertices.push_back(Point3d(v2.x(), v2.y(), maxZ)); |
| 375 |
4/4✓ Branch 1 taken 195 times.
✓ Branch 4 taken 195 times.
✓ Branch 7 taken 195 times.
✓ Branch 10 taken 195 times.
|
195 | wallVertices.push_back(Point3d(v2.x(), v2.y(), minZ)); |
| 376 |
4/4✓ Branch 1 taken 195 times.
✓ Branch 4 taken 195 times.
✓ Branch 7 taken 195 times.
✓ Branch 10 taken 195 times.
|
195 | wallVertices.push_back(Point3d(v1.x(), v1.y(), minZ)); |
| 377 | } | ||
| 378 | |||
| 379 |
1/1✓ Branch 1 taken 304 times.
|
304 | ShadingSurface surface(wallVertices, m_model); |
| 380 |
2/2✓ Branch 2 taken 304 times.
✓ Branch 5 taken 304 times.
|
304 | surface.setName("Face " + std::to_string(m_nSurfaces++)); |
| 381 |
1/1✓ Branch 1 taken 304 times.
|
304 | surface.setShadingSurfaceGroup(osGroup); |
| 382 | 304 | } | |
| 383 | |||
| 384 | 102 | void FloorspaceReverseTranslator_Impl::createShadingSurface(ShadingSurfaceGroup& osGroup, Point3dVector& faceVertices, double z) { | |
| 385 | 102 | Point3dVector vertices; | |
| 386 |
2/2✓ Branch 4 taken 608 times.
✓ Branch 5 taken 102 times.
|
710 | for (const auto& vert : faceVertices) { |
| 387 |
4/4✓ Branch 1 taken 608 times.
✓ Branch 4 taken 608 times.
✓ Branch 7 taken 608 times.
✓ Branch 10 taken 608 times.
|
608 | vertices.emplace_back(Point3d(vert.x(), vert.y(), z)); |
| 388 | } | ||
| 389 | |||
| 390 |
1/1✓ Branch 1 taken 102 times.
|
102 | ShadingSurface surface(vertices, m_model); |
| 391 |
2/2✓ Branch 2 taken 102 times.
✓ Branch 5 taken 102 times.
|
102 | surface.setName("Face " + std::to_string(m_nSurfaces++)); |
| 392 |
1/1✓ Branch 1 taken 102 times.
|
102 | surface.setShadingSurfaceGroup(osGroup); |
| 393 | 102 | } | |
| 394 | |||
| 395 | // Creates a Space from an FSSpace | ||
| 396 | 664 | void FloorspaceReverseTranslator_Impl::createSpace(const FSSpace& fsEntity, double minZ, double maxZ, SpaceTypeEnum typeOfSpace, | |
| 397 | bool openToBelow) { | ||
| 398 |
1/1✓ Branch 1 taken 664 times.
|
664 | Space osSpace(m_model); |
| 399 |
2/2✓ Branch 1 taken 664 times.
✓ Branch 4 taken 664 times.
|
664 | osSpace.setBuildingStory(*m_currentStory); |
| 400 |
4/4✓ Branch 1 taken 664 times.
✓ Branch 4 taken 664 times.
✓ Branch 7 taken 664 times.
✓ Branch 10 taken 664 times.
|
664 | osSpace.setName(fsEntity.name() + getPlenumPostfix(typeOfSpace)); |
| 401 |
1/1✓ Branch 1 taken 664 times.
|
664 | m_currentSpace = osSpace; |
| 402 | |||
| 403 | // Make the surfaces/sub-surfaces | ||
| 404 |
1/1✓ Branch 1 taken 664 times.
|
664 | createSurfaces(osSpace, fsEntity, minZ, maxZ, typeOfSpace, openToBelow); |
| 405 | |||
| 406 | // Do the assignments | ||
| 407 | // Thermal zones for above floor spaces are already created, here plenum thermal zones will be created | ||
| 408 | // to associated them with the plenum spaces | ||
| 409 |
3/3✓ Branch 1 taken 664 times.
✓ Branch 5 taken 562 times.
✓ Branch 6 taken 102 times.
|
664 | if (fsEntity.thermalZone().has_value()) { |
| 410 |
5/5✓ Branch 1 taken 562 times.
✓ Branch 4 taken 562 times.
✓ Branch 7 taken 562 times.
✓ Branch 10 taken 562 times.
✓ Branch 13 taken 562 times.
|
562 | std::string zoneName = fsEntity.thermalZone()->name() + getPlenumPostfix(typeOfSpace); |
| 411 | // Space is assigned to a thermal zone | ||
| 412 |
1/1✓ Branch 1 taken 562 times.
|
562 | auto zone = m_model.getConcreteModelObjectByName<ThermalZone>(zoneName); |
| 413 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 558 times.
|
562 | if (!zone) { |
| 414 | // Zone does not yet exist so create it | ||
| 415 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | zone = ThermalZone(m_model); |
| 416 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | zone->setName(zoneName); |
| 417 | } | ||
| 418 |
1/2✓ Branch 0 taken 562 times.
✗ Branch 1 not taken.
|
562 | if (zone) { |
| 419 |
1/1✓ Branch 1 taken 562 times.
|
562 | int multiplier = fsEntity.multiplier(); |
| 420 | // Assign the space to the zone and set the multiplier | ||
| 421 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 562 times.
|
562 | if (multiplier == 0) { |
| 422 | ✗ | LOG(Warn, "Muliplier for Space '" << fsEntity.name() << "' is 0, setting to 1"); | |
| 423 | ✗ | multiplier = 1; | |
| 424 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 559 times.
|
562 | } else if (multiplier > 1) { |
| 425 |
8/8✓ 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.
|
3 | LOG(Warn, "Multiplier translation not yet implemented for Space '" << fsEntity.name() << "', setting to 1"); |
| 426 | 3 | multiplier = 1; | |
| 427 | } | ||
| 428 | |||
| 429 |
2/2✓ Branch 1 taken 562 times.
✓ Branch 4 taken 562 times.
|
562 | osSpace.setThermalZone(*zone); |
| 430 |
4/4✓ Branch 1 taken 562 times.
✓ Branch 4 taken 562 times.
✓ Branch 8 taken 551 times.
✓ Branch 9 taken 11 times.
|
562 | if (zone->spaces().size() == 1) { |
| 431 |
2/2✓ Branch 1 taken 551 times.
✓ Branch 4 taken 551 times.
|
551 | zone->setMultiplier(multiplier); |
| 432 | } | ||
| 433 | } | ||
| 434 | 562 | } | |
| 435 | |||
| 436 | // For space type plenum spaces are always added to a space type called 'Plenum Space Type' | ||
| 437 | // regardless of whether the space is associated with a space type. | ||
| 438 |
2/2✓ Branch 0 taken 656 times.
✓ Branch 1 taken 8 times.
|
664 | if (typeOfSpace == SpaceTypeEnum::ABOVEFLOOR) { |
| 439 |
3/3✓ Branch 1 taken 656 times.
✓ Branch 5 taken 615 times.
✓ Branch 6 taken 41 times.
|
656 | if (fsEntity.spaceType().has_value()) { |
| 440 | // The Space type for the main space will already have been created | ||
| 441 |
4/4✓ Branch 1 taken 615 times.
✓ Branch 4 taken 615 times.
✓ Branch 7 taken 615 times.
✓ Branch 10 taken 615 times.
|
615 | auto spaceType = m_model.getConcreteModelObjectByName<SpaceType>(fsEntity.spaceType()->name()); |
| 442 |
1/2✓ Branch 1 taken 615 times.
✗ Branch 2 not taken.
|
615 | if (spaceType.has_value()) { |
| 443 |
2/2✓ Branch 1 taken 615 times.
✓ Branch 4 taken 615 times.
|
615 | osSpace.setSpaceType(*spaceType); |
| 444 | } | ||
| 445 | 615 | } | |
| 446 | } else { | ||
| 447 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
|
16 | auto spaceType = m_model.getConcreteModelObjectByName<SpaceType>(PLENUMSPACETYPENAME); |
| 448 | // The plenum space type might not exist yet as it is created on demand | ||
| 449 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 2 taken 5 times.
|
8 | if (!spaceType.has_value()) { |
| 450 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | spaceType = SpaceType(m_model); |
| 451 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
9 | spaceType->setName(PLENUMSPACETYPENAME); |
| 452 | } | ||
| 453 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | if (spaceType) { |
| 454 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
|
8 | osSpace.setSpaceType(*spaceType); |
| 455 | } | ||
| 456 | 8 | } | |
| 457 | |||
| 458 | // Plena get assigned to the same construction set | ||
| 459 |
3/3✓ Branch 1 taken 664 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 628 times.
|
664 | if (fsEntity.constructionSet().has_value()) { |
| 460 |
4/4✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 7 taken 36 times.
✓ Branch 10 taken 36 times.
|
36 | auto constructionSet = m_model.getConcreteModelObjectByName<DefaultConstructionSet>(fsEntity.constructionSet()->name()); |
| 461 |
1/2✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
|
36 | if (constructionSet) { |
| 462 |
2/2✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
|
36 | osSpace.setDefaultConstructionSet(*constructionSet); |
| 463 | } | ||
| 464 | 36 | } | |
| 465 | |||
| 466 | // Plenum spaces get assigned to the same buiding unit that the main space is assigned to | ||
| 467 |
3/3✓ Branch 1 taken 664 times.
✓ Branch 5 taken 35 times.
✓ Branch 6 taken 629 times.
|
664 | if (fsEntity.buildingUnit().has_value()) { |
| 468 |
4/4✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
✓ Branch 7 taken 35 times.
✓ Branch 10 taken 35 times.
|
35 | auto unit = m_model.getConcreteModelObjectByName<BuildingUnit>(fsEntity.buildingUnit()->name()); |
| 469 |
1/2✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
|
35 | if (unit) { |
| 470 |
2/2✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
|
35 | osSpace.setBuildingUnit(*unit); |
| 471 | } | ||
| 472 | 35 | } | |
| 473 | |||
| 474 | // Daylighting control and ditto daylighting | ||
| 475 |
3/3✓ Branch 1 taken 664 times.
✓ Branch 8 taken 11 times.
✓ Branch 9 taken 664 times.
|
675 | for (const auto& fsDaylightingControl : fsEntity.daylightingControls()) { |
| 476 |
1/1✓ Branch 1 taken 11 times.
|
11 | fsDaylightingControl.Accept(*this); |
| 477 | 664 | } | |
| 478 | |||
| 479 |
1/1✓ Branch 1 taken 664 times.
|
664 | MapHandles(fsEntity, osSpace); |
| 480 | 664 | } | |
| 481 | |||
| 482 | 664 | void FloorspaceReverseTranslator_Impl::createSurfaces(Space& osSpace, const FSSpace& fsSpace, double minZ, double maxZ, SpaceTypeEnum typeOfSpace, | |
| 483 | bool openToBelow) { | ||
| 484 |
1/1✓ Branch 1 taken 664 times.
|
664 | auto face = fsSpace.face(); |
| 485 |
1/2✓ Branch 1 taken 664 times.
✗ Branch 2 not taken.
|
664 | if (face.has_value()) { |
| 486 | // Iterate over face edges to create the vector of Point3d | ||
| 487 | // make sure points are oriented so the normal is -1 | ||
| 488 | // create the "floor" surface | ||
| 489 | // Reverse the points and add maxz to the points | ||
| 490 | // create the"RoofCeiling" surface | ||
| 491 | // Iterate over edges to create walls | ||
| 492 | // find window aligned to the edge, make sub-surface | ||
| 493 | // find door aligned to the edge, make sub-surface | ||
| 494 | 664 | Point3dVector faceVertices; | |
| 495 |
4/4✓ Branch 1 taken 664 times.
✓ Branch 4 taken 664 times.
✓ Branch 10 taken 4518 times.
✓ Branch 11 taken 664 times.
|
5182 | for (const auto& edgeRef : face->edgeRefs()) { |
| 496 |
1/1✓ Branch 1 taken 4518 times.
|
4518 | const FSVertex& vertex = edgeRef.getNextVertex(); |
| 497 |
4/4✓ Branch 1 taken 4518 times.
✓ Branch 4 taken 4518 times.
✓ Branch 7 taken 4518 times.
✓ Branch 10 taken 4518 times.
|
4518 | faceVertices.emplace_back(Point3d(vertex.x(), vertex.y(), 0)); |
| 498 | 664 | } | |
| 499 | |||
| 500 | // simplify the vertices to remove potential duplicate, colinear points | ||
| 501 | 664 | double tol = 0.001; | |
| 502 | //std::vector<Point3d> testFaceVertices(faceVertices); | ||
| 503 |
1/1✓ Branch 1 taken 664 times.
|
664 | faceVertices = simplify(faceVertices, false, tol); |
| 504 | |||
| 505 | // Get the original orientation pf the face vertices | ||
| 506 |
1/1✓ Branch 1 taken 664 times.
|
664 | boost::optional<Vector3d> outwardNormal = getOutwardNormal(faceVertices); |
| 507 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 664 times.
|
664 | if (!outwardNormal) { |
| 508 | //LOG(Error, "Cannot compute outwardNormal for floorPrint."); | ||
| 509 | ✗ | return; | |
| 510 | } | ||
| 511 | |||
| 512 | // Construct the vertices for the lower face | ||
| 513 |
1/1✓ Branch 1 taken 664 times.
|
664 | createFloorSurface(osSpace, faceVertices, minZ, openToBelow); |
| 514 |
1/1✓ Branch 1 taken 664 times.
|
664 | createRoofSurface(osSpace, faceVertices, maxZ); |
| 515 | |||
| 516 |
2/2✓ Branch 1 taken 4513 times.
✓ Branch 2 taken 664 times.
|
5177 | for (unsigned int i = 0; i < faceVertices.size(); i++) { |
| 517 | 4513 | const Point3d& p1 = faceVertices[i]; | |
| 518 | 4513 | const Point3d& p2 = faceVertices[(i + 1) % faceVertices.size()]; | |
| 519 |
1/1✓ Branch 1 taken 4513 times.
|
4513 | createWallSurface(osSpace, fsSpace, p1, p2, minZ, maxZ, typeOfSpace == SpaceTypeEnum::ABOVEFLOOR); |
| 520 | } | ||
| 521 | 664 | } | |
| 522 | 664 | } | |
| 523 | |||
| 524 | // Creates "Floor" surface | ||
| 525 | 664 | void FloorspaceReverseTranslator_Impl::createFloorSurface(Space& osSpace, Point3dVector& faceVertices, double minZ, bool openToBelow) { | |
| 526 |
1/2✓ Branch 1 taken 664 times.
✗ Branch 2 not taken.
|
664 | if (orientVerticesForFloor(faceVertices)) { |
| 527 |
2/2✓ Branch 1 taken 664 times.
✓ Branch 4 taken 664 times.
|
1992 | createSurface(osSpace, faceVertices, minZ, "Floor", openToBelow); |
| 528 | } | ||
| 529 | 664 | } | |
| 530 | |||
| 531 | // Creates a "RoofCeiling" surface | ||
| 532 | 664 | void FloorspaceReverseTranslator_Impl::createRoofSurface(Space& osSpace, Point3dVector& faceVertices, double maxZ) { | |
| 533 |
1/2✓ Branch 1 taken 664 times.
✗ Branch 2 not taken.
|
664 | if (orientVerticesForRoof(faceVertices)) { |
| 534 |
2/2✓ Branch 1 taken 664 times.
✓ Branch 4 taken 664 times.
|
1328 | createSurface(osSpace, faceVertices, maxZ, "RoofCeiling", false); |
| 535 | } | ||
| 536 | 664 | } | |
| 537 | |||
| 538 | 4513 | void FloorspaceReverseTranslator_Impl::createWallSurface(Space& osSpace, const FSSpace& fsSpace, const Point3d& p1, const Point3d& p2, | |
| 539 | double minZ, double maxZ, bool createSubsurfaces) { | ||
| 540 | 4513 | constexpr double tol = 0.001; | |
| 541 | |||
| 542 | 4513 | Point3dVector wallVertices; | |
| 543 |
1/1✓ Branch 1 taken 4513 times.
|
4513 | wallVertices.reserve(4); |
| 544 |
3/3✓ Branch 1 taken 4513 times.
✓ Branch 4 taken 4513 times.
✓ Branch 7 taken 4513 times.
|
4513 | wallVertices.emplace_back(p2.x(), p2.y(), maxZ); |
| 545 |
3/3✓ Branch 1 taken 4513 times.
✓ Branch 4 taken 4513 times.
✓ Branch 7 taken 4513 times.
|
4513 | wallVertices.emplace_back(p1.x(), p1.y(), maxZ); |
| 546 |
3/3✓ Branch 1 taken 4513 times.
✓ Branch 4 taken 4513 times.
✓ Branch 7 taken 4513 times.
|
4513 | wallVertices.emplace_back(p1.x(), p1.y(), minZ); |
| 547 |
3/3✓ Branch 1 taken 4513 times.
✓ Branch 4 taken 4513 times.
✓ Branch 7 taken 4513 times.
|
4513 | wallVertices.emplace_back(p2.x(), p2.y(), minZ); |
| 548 |
3/5✓ Branch 1 taken 4513 times.
✓ Branch 3 taken 9026 times.
✓ Branch 4 taken 4513 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
18052 | const Point3dVector wallSegment{p1, p2}; |
| 549 | |||
| 550 |
1/1✓ Branch 1 taken 4513 times.
|
4513 | Surface surface(wallVertices, m_model); |
| 551 |
2/2✓ Branch 2 taken 4513 times.
✓ Branch 5 taken 4513 times.
|
4513 | surface.setName("Face " + std::to_string(m_nSurfaces++)); |
| 552 |
1/1✓ Branch 1 taken 4513 times.
|
4513 | surface.setSpace(osSpace); |
| 553 |
2/2✓ Branch 1 taken 4513 times.
✓ Branch 4 taken 4513 times.
|
4513 | surface.setSurfaceType("Wall"); |
| 554 | |||
| 555 |
2/2✓ Branch 0 taken 4481 times.
✓ Branch 1 taken 32 times.
|
4513 | if (createSubsurfaces) { |
| 556 |
1/2✓ Branch 1 taken 4481 times.
✗ Branch 2 not taken.
|
4481 | if (m_currentFSStory.has_value()) { |
| 557 | |||
| 558 | // Create a window subsurface for every window that is on this edge | ||
| 559 |
4/4✓ Branch 1 taken 4481 times.
✓ Branch 4 taken 4481 times.
✓ Branch 11 taken 95964 times.
✓ Branch 12 taken 4481 times.
|
100445 | for (const auto& window : m_currentFSStory->windows()) { |
| 560 | // Get window's x/y position which is the alpha based on its edge | ||
| 561 | // windows can have multiple alphas but we only need one | ||
| 562 |
2/3✓ Branch 1 taken 95964 times.
✓ Branch 5 taken 95964 times.
✗ Branch 6 not taken.
|
95964 | if (window.edge().has_value()) { |
| 563 |
2/2✓ Branch 1 taken 95964 times.
✓ Branch 4 taken 95964 times.
|
95964 | auto edge = *window.edge(); |
| 564 |
1/1✓ Branch 1 taken 95964 times.
|
95964 | const double alpha = window.alphas()[0]; |
| 565 |
1/1✓ Branch 1 taken 95964 times.
|
95964 | const Point3d pp = window.centerVertex(alpha); |
| 566 | |||
| 567 |
3/3✓ Branch 1 taken 95964 times.
✓ Branch 3 taken 814 times.
✓ Branch 4 taken 95150 times.
|
95964 | if (getDistancePointToLineSegment(pp, wallSegment) < tol) { |
| 568 |
1/1✓ Branch 1 taken 814 times.
|
814 | createWindowSubsurface(window, surface, edge, minZ, maxZ); |
| 569 | } | ||
| 570 | 95964 | } | |
| 571 | 4481 | } | |
| 572 | |||
| 573 | // Create a door subsurface for every window that is on this edge | ||
| 574 |
4/4✓ Branch 1 taken 4481 times.
✓ Branch 4 taken 4481 times.
✓ Branch 11 taken 76 times.
✓ Branch 12 taken 4481 times.
|
4557 | for (const auto& door : m_currentFSStory->doors()) { |
| 575 |
2/3✓ Branch 1 taken 76 times.
✓ Branch 5 taken 76 times.
✗ Branch 6 not taken.
|
76 | if (door.edge().has_value()) { |
| 576 |
2/2✓ Branch 1 taken 76 times.
✓ Branch 4 taken 76 times.
|
76 | auto edge = *door.edge(); |
| 577 |
1/1✓ Branch 1 taken 76 times.
|
76 | const double alpha = door.alphas()[0]; |
| 578 |
1/1✓ Branch 1 taken 76 times.
|
76 | const Point3d pp = door.centerVertex(alpha); |
| 579 | |||
| 580 |
3/3✓ Branch 1 taken 76 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 64 times.
|
76 | if (getDistancePointToLineSegment(pp, wallSegment) < tol) { |
| 581 |
1/1✓ Branch 1 taken 12 times.
|
12 | createDoorSubsurface(door, surface, edge, minZ); |
| 582 | } | ||
| 583 | 76 | } | |
| 584 | 4481 | } | |
| 585 | } | ||
| 586 | } | ||
| 587 | 9026 | } | |
| 588 | |||
| 589 | // Creates one or more window subsurfaces along an edge | ||
| 590 | 814 | void FloorspaceReverseTranslator_Impl::createWindowSubsurface(const FSWindow& window, Surface& osSurface, const FSEdge& edge, double minZ, | |
| 591 | double maxZ) { | ||
| 592 | |||
| 593 |
1/1✓ Branch 1 taken 814 times.
|
814 | auto windowDefinition = window.windowDefinition(); |
| 594 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 814 times.
|
814 | if (!windowDefinition.has_value()) { |
| 595 | ✗ | return; | |
| 596 | } | ||
| 597 | |||
| 598 |
1/1✓ Branch 1 taken 814 times.
|
814 | const auto& vertex1 = edge.firstVertex(); |
| 599 |
1/1✓ Branch 1 taken 814 times.
|
814 | const auto& vertex2 = edge.secondVertex(); |
| 600 |
1/1✓ Branch 1 taken 814 times.
|
814 | Vector3d edgeVector = edge.edgeVector(); |
| 601 | |||
| 602 |
1/1✓ Branch 1 taken 814 times.
|
814 | edgeVector.setLength(1.0); |
| 603 |
1/1✓ Branch 1 taken 814 times.
|
814 | Vector3d upVector(0, 0, 1); |
| 604 |
1/1✓ Branch 1 taken 814 times.
|
814 | Vector3d crossVector = upVector.cross(edgeVector); |
| 605 | |||
| 606 |
2/2✓ Branch 1 taken 814 times.
✓ Branch 4 taken 814 times.
|
814 | double sillHeight = windowDefinition->sillHeight(); |
| 607 | 814 | double height = 0.0; | |
| 608 | 814 | double width = 0.0; | |
| 609 |
15/20✓ Branch 1 taken 814 times.
✓ Branch 4 taken 814 times.
✓ Branch 7 taken 814 times.
✓ Branch 9 taken 43 times.
✓ Branch 10 taken 771 times.
✓ Branch 12 taken 43 times.
✓ Branch 15 taken 43 times.
✓ Branch 18 taken 43 times.
✓ Branch 20 taken 1 time.
✓ Branch 21 taken 42 times.
✓ Branch 22 taken 43 times.
✓ Branch 23 taken 771 times.
✓ Branch 25 taken 814 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 772 times.
✓ Branch 29 taken 42 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
|
814 | if ((windowDefinition->windowDefinitionMode() == "Single Window") || (windowDefinition->windowDefinitionMode() == "Repeating Windows")) { |
| 610 |
2/2✓ Branch 1 taken 772 times.
✓ Branch 4 taken 772 times.
|
772 | height = windowDefinition->height(); |
| 611 |
2/2✓ Branch 1 taken 772 times.
✓ Branch 4 taken 772 times.
|
772 | width = windowDefinition->width(); |
| 612 |
4/5✓ Branch 1 taken 42 times.
✓ Branch 4 taken 42 times.
✓ Branch 7 taken 42 times.
✓ Branch 10 taken 42 times.
✗ Branch 11 not taken.
|
42 | } else if (windowDefinition->windowDefinitionMode() == "Window to Wall Ratio") { |
| 613 |
2/2✓ Branch 1 taken 42 times.
✓ Branch 4 taken 42 times.
|
42 | double length = edge.edgeVector().length(); |
| 614 | 42 | width = length - 0.0508; // Allow for 1" either end of the window | |
| 615 | // Area of the wall * wwr gives area of the window divided by width of the window gives height of the window | ||
| 616 |
2/2✓ Branch 1 taken 42 times.
✓ Branch 4 taken 42 times.
|
42 | height = (maxZ - minZ) * length * windowDefinition->wwr() / width; |
| 617 | } | ||
| 618 | |||
| 619 |
3/3✓ Branch 1 taken 814 times.
✓ Branch 8 taken 830 times.
✓ Branch 9 taken 814 times.
|
1644 | for (double alpha : window.alphas()) { |
| 620 | // Calculate the window center from the alpha and sill height | ||
| 621 |
2/2✓ Branch 1 taken 830 times.
✓ Branch 4 taken 830 times.
|
830 | double x = (1.0 - alpha) * vertex1.x() + alpha * vertex2.x(); |
| 622 |
2/2✓ Branch 1 taken 830 times.
✓ Branch 4 taken 830 times.
|
830 | double y = (1.0 - alpha) * vertex1.y() + alpha * vertex2.y(); |
| 623 |
1/1✓ Branch 1 taken 830 times.
|
830 | Point3d windowCenter(x, y, 0); |
| 624 |
1/1✓ Branch 1 taken 830 times.
|
830 | edgeVector.setLength(0.5 * width); |
| 625 |
1/1✓ Branch 1 taken 830 times.
|
830 | Point3d window1 = windowCenter + edgeVector; |
| 626 |
1/1✓ Branch 1 taken 830 times.
|
830 | edgeVector.setLength(-0.5 * width); |
| 627 |
1/1✓ Branch 1 taken 830 times.
|
830 | Point3d window2 = windowCenter + edgeVector; |
| 628 | |||
| 629 | 830 | Point3dVector windowVertices; | |
| 630 |
4/4✓ Branch 1 taken 830 times.
✓ Branch 4 taken 830 times.
✓ Branch 7 taken 830 times.
✓ Branch 10 taken 830 times.
|
830 | windowVertices.push_back(Point3d(window1.x(), window1.y(), minZ + sillHeight + height)); |
| 631 |
4/4✓ Branch 1 taken 830 times.
✓ Branch 4 taken 830 times.
✓ Branch 7 taken 830 times.
✓ Branch 10 taken 830 times.
|
830 | windowVertices.push_back(Point3d(window1.x(), window1.y(), minZ + sillHeight)); |
| 632 |
4/4✓ Branch 1 taken 830 times.
✓ Branch 4 taken 830 times.
✓ Branch 7 taken 830 times.
✓ Branch 10 taken 830 times.
|
830 | windowVertices.push_back(Point3d(window2.x(), window2.y(), minZ + sillHeight)); |
| 633 |
4/4✓ Branch 1 taken 830 times.
✓ Branch 4 taken 830 times.
✓ Branch 7 taken 830 times.
✓ Branch 10 taken 830 times.
|
830 | windowVertices.push_back(Point3d(window2.x(), window2.y(), minZ + sillHeight + height)); |
| 634 | |||
| 635 | // Make sure the sub-surface orientation matches the surface | ||
| 636 |
2/2✓ Branch 1 taken 830 times.
✓ Branch 4 taken 830 times.
|
830 | Plane plane1(osSurface.vertices()); |
| 637 |
1/1✓ Branch 1 taken 830 times.
|
830 | Plane plane2(windowVertices); |
| 638 |
3/3✓ Branch 1 taken 830 times.
✓ Branch 3 taken 362 times.
✓ Branch 4 taken 468 times.
|
830 | if (plane1.reverseEqual(plane2)) { |
| 639 |
1/1✓ Branch 3 taken 362 times.
|
362 | std::reverse(windowVertices.begin(), windowVertices.end()); |
| 640 |
1/1✓ Branch 1 taken 362 times.
|
362 | Point3d temp = window1; |
| 641 |
1/1✓ Branch 1 taken 362 times.
|
362 | window1 = window2; |
| 642 |
1/1✓ Branch 1 taken 362 times.
|
362 | window2 = temp; |
| 643 |
1/1✓ Branch 1 taken 362 times.
|
362 | edgeVector = edgeVector.reverseVector(); |
| 644 |
1/1✓ Branch 1 taken 362 times.
|
362 | crossVector = crossVector.reverseVector(); |
| 645 | 362 | } | |
| 646 | |||
| 647 |
1/1✓ Branch 1 taken 830 times.
|
830 | SubSurface subSurface(windowVertices, m_model); |
| 648 |
2/2✓ Branch 2 taken 830 times.
✓ Branch 5 taken 830 times.
|
830 | subSurface.setName("Face " + std::to_string(m_nSurfaces++)); |
| 649 |
1/1✓ Branch 1 taken 830 times.
|
830 | subSurface.setSurface(osSurface); |
| 650 |
3/3✓ Branch 1 taken 830 times.
✓ Branch 4 taken 830 times.
✓ Branch 7 taken 830 times.
|
830 | subSurface.setSubSurfaceType(windowDefinition->windowType()); |
| 651 | |||
| 652 |
9/10✓ Branch 1 taken 830 times.
✓ Branch 4 taken 830 times.
✓ Branch 6 taken 793 times.
✓ Branch 7 taken 37 times.
✓ Branch 9 taken 793 times.
✓ Branch 12 taken 793 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 793 times.
✓ Branch 16 taken 37 times.
✓ Branch 17 taken 793 times.
|
830 | if (windowDefinition->overhangProjectionFactor() > 0 || windowDefinition->finProjectionFactor() > 0) { |
| 653 |
1/1✓ Branch 1 taken 37 times.
|
37 | ShadingSurfaceGroup shadingGroup(m_model); |
| 654 |
4/4✓ Branch 1 taken 37 times.
✓ Branch 4 taken 37 times.
✓ Branch 7 taken 37 times.
✓ Branch 10 taken 37 times.
|
37 | shadingGroup.setName(*subSurface.name() + " Shading Group"); |
| 655 |
5/5✓ Branch 1 taken 37 times.
✓ Branch 4 taken 37 times.
✓ Branch 7 taken 37 times.
✓ Branch 10 taken 37 times.
✓ Branch 13 taken 37 times.
|
37 | shadingGroup.setSpace(subSurface.surface()->space().value()); |
| 656 |
1/1✓ Branch 1 taken 37 times.
|
37 | shadingGroup.setShadedSubSurface(subSurface); |
| 657 |
2/2✓ Branch 1 taken 37 times.
✓ Branch 4 taken 37 times.
|
37 | shadingGroup.setShadingSurfaceType("Space"); |
| 658 | |||
| 659 |
3/4✓ Branch 1 taken 37 times.
✓ Branch 4 taken 37 times.
✓ Branch 6 taken 37 times.
✗ Branch 7 not taken.
|
37 | if (double factor = windowDefinition->overhangProjectionFactor(); factor > 0) { |
| 660 |
1/1✓ Branch 1 taken 37 times.
|
37 | Vector3d outVector = crossVector; |
| 661 |
1/1✓ Branch 1 taken 37 times.
|
37 | outVector.setLength(factor * height); |
| 662 |
1/1✓ Branch 1 taken 37 times.
|
37 | Point3d window3 = window1 + outVector; |
| 663 |
1/1✓ Branch 1 taken 37 times.
|
37 | Point3d window4 = window2 + outVector; |
| 664 | |||
| 665 | 37 | Point3dVector shadingVertices; | |
| 666 |
4/4✓ Branch 1 taken 37 times.
✓ Branch 4 taken 37 times.
✓ Branch 7 taken 37 times.
✓ Branch 10 taken 37 times.
|
37 | shadingVertices.push_back(Point3d(window1.x(), window1.y(), minZ + sillHeight + height)); |
| 667 |
4/4✓ Branch 1 taken 37 times.
✓ Branch 4 taken 37 times.
✓ Branch 7 taken 37 times.
✓ Branch 10 taken 37 times.
|
37 | shadingVertices.push_back(Point3d(window3.x(), window3.y(), minZ + sillHeight + height)); |
| 668 |
4/4✓ Branch 1 taken 37 times.
✓ Branch 4 taken 37 times.
✓ Branch 7 taken 37 times.
✓ Branch 10 taken 37 times.
|
37 | shadingVertices.push_back(Point3d(window4.x(), window4.y(), minZ + sillHeight + height)); |
| 669 |
4/4✓ Branch 1 taken 37 times.
✓ Branch 4 taken 37 times.
✓ Branch 7 taken 37 times.
✓ Branch 10 taken 37 times.
|
37 | shadingVertices.push_back(Point3d(window2.x(), window2.y(), minZ + sillHeight + height)); |
| 670 | |||
| 671 |
1/1✓ Branch 1 taken 37 times.
|
37 | ShadingSurface shadingSurface(shadingVertices, m_model); |
| 672 |
2/2✓ Branch 2 taken 37 times.
✓ Branch 5 taken 37 times.
|
37 | shadingSurface.setName("Face " + std::to_string(m_nSurfaces++)); |
| 673 |
1/1✓ Branch 1 taken 37 times.
|
37 | shadingSurface.setShadingSurfaceGroup(shadingGroup); |
| 674 | 37 | } | |
| 675 | |||
| 676 |
4/4✓ Branch 1 taken 37 times.
✓ Branch 4 taken 37 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 21 times.
|
37 | if (double factor = windowDefinition->finProjectionFactor(); factor > 0) { |
| 677 |
1/1✓ Branch 1 taken 16 times.
|
16 | Vector3d outVector = crossVector; |
| 678 |
1/1✓ Branch 1 taken 16 times.
|
16 | outVector.setLength(factor * height); |
| 679 |
1/1✓ Branch 1 taken 16 times.
|
16 | Point3d window3 = window1 + outVector; |
| 680 |
1/1✓ Branch 1 taken 16 times.
|
16 | Point3d window4 = window2 + outVector; |
| 681 | |||
| 682 | // Right | ||
| 683 | 16 | Point3dVector rightShadingVertices; | |
| 684 |
4/4✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 10 taken 16 times.
|
16 | rightShadingVertices.push_back(Point3d(window1.x(), window1.y(), minZ + sillHeight + height)); |
| 685 |
4/4✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 10 taken 16 times.
|
16 | rightShadingVertices.push_back(Point3d(window1.x(), window1.y(), minZ + sillHeight)); |
| 686 |
4/4✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 10 taken 16 times.
|
16 | rightShadingVertices.push_back(Point3d(window3.x(), window3.y(), minZ + sillHeight)); |
| 687 |
4/4✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 10 taken 16 times.
|
16 | rightShadingVertices.push_back(Point3d(window3.x(), window3.y(), minZ + sillHeight + height)); |
| 688 | |||
| 689 |
1/1✓ Branch 1 taken 16 times.
|
16 | ShadingSurface shadingSurfaceLeft(rightShadingVertices, m_model); |
| 690 |
2/2✓ Branch 2 taken 16 times.
✓ Branch 5 taken 16 times.
|
16 | shadingSurfaceLeft.setName("Face " + std::to_string(m_nSurfaces++)); |
| 691 |
1/1✓ Branch 1 taken 16 times.
|
16 | shadingSurfaceLeft.setShadingSurfaceGroup(shadingGroup); |
| 692 | |||
| 693 | // Right | ||
| 694 | 16 | Point3dVector leftShadingVertices; | |
| 695 |
4/4✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 10 taken 16 times.
|
16 | leftShadingVertices.push_back(Point3d(window2.x(), window2.y(), minZ + sillHeight + height)); |
| 696 |
4/4✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 10 taken 16 times.
|
16 | leftShadingVertices.push_back(Point3d(window2.x(), window2.y(), minZ + sillHeight)); |
| 697 |
4/4✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 10 taken 16 times.
|
16 | leftShadingVertices.push_back(Point3d(window4.x(), window4.y(), minZ + sillHeight)); |
| 698 |
4/4✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 10 taken 16 times.
|
16 | leftShadingVertices.push_back(Point3d(window4.x(), window4.y(), minZ + sillHeight + height)); |
| 699 | |||
| 700 |
1/1✓ Branch 1 taken 16 times.
|
16 | ShadingSurface shadingSurfaceRight(leftShadingVertices, m_model); |
| 701 |
2/2✓ Branch 2 taken 16 times.
✓ Branch 5 taken 16 times.
|
16 | shadingSurfaceRight.setName("Face " + std::to_string(m_nSurfaces++)); |
| 702 |
1/1✓ Branch 1 taken 16 times.
|
16 | shadingSurfaceRight.setShadingSurfaceGroup(shadingGroup); |
| 703 | 16 | } | |
| 704 | 37 | } | |
| 705 | 1644 | } | |
| 706 | 814 | } | |
| 707 | |||
| 708 | // Creates a door subsurface along an edge | ||
| 709 | 12 | void FloorspaceReverseTranslator_Impl::createDoorSubsurface(const FSDoor& door, Surface& osSurface, const FSEdge& edge, double minZ) { | |
| 710 | |||
| 711 |
1/1✓ Branch 1 taken 12 times.
|
12 | const auto& vertex1 = edge.firstVertex(); |
| 712 |
1/1✓ Branch 1 taken 12 times.
|
12 | const auto& vertex2 = edge.secondVertex(); |
| 713 |
1/1✓ Branch 1 taken 12 times.
|
12 | Vector3d edgeVector = edge.edgeVector(); |
| 714 | |||
| 715 |
1/1✓ Branch 1 taken 12 times.
|
12 | edgeVector.setLength(1.0); |
| 716 |
1/1✓ Branch 1 taken 12 times.
|
12 | Vector3d upVector(0, 0, 1); |
| 717 |
1/1✓ Branch 1 taken 12 times.
|
12 | Vector3d crossVector = upVector.cross(edgeVector); |
| 718 | |||
| 719 |
1/1✓ Branch 1 taken 12 times.
|
12 | auto doorDefinition = door.doorDefinition(); |
| 720 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
|
12 | if (!doorDefinition.has_value()) { |
| 721 | ✗ | return; | |
| 722 | } | ||
| 723 | |||
| 724 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | double height = doorDefinition->height(); |
| 725 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | double width = doorDefinition->width(); |
| 726 | |||
| 727 |
3/3✓ Branch 1 taken 12 times.
✓ Branch 8 taken 12 times.
✓ Branch 9 taken 12 times.
|
24 | for (double alpha : door.alphas()) { |
| 728 | // Calculate the window center from the alpha and sill height | ||
| 729 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | double x = (1.0 - alpha) * vertex1.x() + alpha * vertex2.x(); |
| 730 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | double y = (1.0 - alpha) * vertex1.y() + alpha * vertex2.y(); |
| 731 |
1/1✓ Branch 1 taken 12 times.
|
12 | Point3d windowCenter(x, y, 0); |
| 732 |
1/1✓ Branch 1 taken 12 times.
|
12 | edgeVector.setLength(0.5 * width); |
| 733 |
1/1✓ Branch 1 taken 12 times.
|
12 | Point3d window1 = windowCenter + edgeVector; |
| 734 |
1/1✓ Branch 1 taken 12 times.
|
12 | edgeVector.setLength(-0.5 * width); |
| 735 |
1/1✓ Branch 1 taken 12 times.
|
12 | Point3d window2 = windowCenter + edgeVector; |
| 736 | |||
| 737 | 12 | Point3dVector windowVertices; | |
| 738 |
4/4✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
|
12 | windowVertices.push_back(Point3d(window1.x(), window1.y(), minZ + height)); |
| 739 |
4/4✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
|
12 | windowVertices.push_back(Point3d(window1.x(), window1.y(), minZ)); |
| 740 |
4/4✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
|
12 | windowVertices.push_back(Point3d(window2.x(), window2.y(), minZ)); |
| 741 |
4/4✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
|
12 | windowVertices.push_back(Point3d(window2.x(), window2.y(), minZ + height)); |
| 742 | |||
| 743 | // Make sure the sub-surface orientation matches the surface | ||
| 744 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | Plane plane1(osSurface.vertices()); |
| 745 |
1/1✓ Branch 1 taken 12 times.
|
12 | Plane plane2(windowVertices); |
| 746 |
3/3✓ Branch 1 taken 12 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 11 times.
|
12 | if (plane1.reverseEqual(plane2)) { |
| 747 |
1/1✓ Branch 3 taken 1 time.
|
1 | std::reverse(windowVertices.begin(), windowVertices.end()); |
| 748 | } | ||
| 749 | |||
| 750 |
1/1✓ Branch 1 taken 12 times.
|
12 | SubSurface subSurface(windowVertices, m_model); |
| 751 |
2/2✓ Branch 2 taken 12 times.
✓ Branch 5 taken 12 times.
|
12 | subSurface.setName("Face " + std::to_string(m_nSurfaces++)); |
| 752 |
1/1✓ Branch 1 taken 12 times.
|
12 | subSurface.setSurface(osSurface); |
| 753 |
3/3✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
|
12 | std::string doorType = doorDefinition->doorType(); |
| 754 |
3/3✓ Branch 1 taken 12 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 9 times.
|
12 | if (doorType == "Glass Door") { |
| 755 |
1/1✓ Branch 1 taken 3 times.
|
3 | doorType = "GlassDoor"; |
| 756 |
3/3✓ Branch 1 taken 9 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 7 times.
|
9 | } else if (doorType == "Overhead Door") { |
| 757 |
1/1✓ Branch 1 taken 2 times.
|
2 | doorType = "OverheadDoor"; |
| 758 | } | ||
| 759 |
1/1✓ Branch 1 taken 12 times.
|
12 | subSurface.setSubSurfaceType(doorType); |
| 760 | 24 | } | |
| 761 | 12 | } | |
| 762 | |||
| 763 | 1328 | void FloorspaceReverseTranslator_Impl::createSurface(Space& osSpace, Point3dVector& faceVertices, double z, const std::string& surfaceType, | |
| 764 | bool openToBelow) { | ||
| 765 | 1328 | Point3dVector vertices; | |
| 766 |
2/2✓ Branch 4 taken 9026 times.
✓ Branch 5 taken 1328 times.
|
10354 | for (const auto& vert : faceVertices) { |
| 767 |
4/4✓ Branch 1 taken 9026 times.
✓ Branch 4 taken 9026 times.
✓ Branch 7 taken 9026 times.
✓ Branch 10 taken 9026 times.
|
9026 | vertices.emplace_back(Point3d(vert.x(), vert.y(), z)); |
| 768 | } | ||
| 769 | |||
| 770 |
1/1✓ Branch 1 taken 1328 times.
|
1328 | Surface surface(vertices, m_model); |
| 771 |
2/2✓ Branch 2 taken 1328 times.
✓ Branch 5 taken 1328 times.
|
1328 | surface.setName("Face " + std::to_string(m_nSurfaces++)); |
| 772 |
1/1✓ Branch 1 taken 1328 times.
|
1328 | surface.setSpace(osSpace); |
| 773 |
1/1✓ Branch 1 taken 1328 times.
|
1328 | surface.setSurfaceType(surfaceType); |
| 774 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1327 times.
|
1328 | if (openToBelow) { |
| 775 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | surface.setConstruction(getAirWallConstruction(m_model)); |
| 776 | } | ||
| 777 | 1328 | } | |
| 778 | |||
| 779 | // Ensures the points are oriented correctly for a floor surface, reurns false if the normal cant be calculated | ||
| 780 | 715 | bool FloorspaceReverseTranslator_Impl::orientVerticesForFloor(Point3dVector& points) { | |
| 781 |
1/1✓ Branch 1 taken 715 times.
|
715 | boost::optional<Vector3d> outwardNormal = getOutwardNormal(points); |
| 782 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 715 times.
|
715 | if (!outwardNormal) { |
| 783 | //LOG(Error, "Cannot compute outwardNormal for floorPrint."); | ||
| 784 | ✗ | return false; | |
| 785 | } | ||
| 786 |
4/4✓ Branch 1 taken 715 times.
✓ Branch 4 taken 715 times.
✓ Branch 6 taken 415 times.
✓ Branch 7 taken 300 times.
|
715 | if (outwardNormal->z() > 0) { |
| 787 |
1/1✓ Branch 3 taken 415 times.
|
415 | std::reverse(points.begin(), points.end()); |
| 788 | } | ||
| 789 | 715 | return true; | |
| 790 | 715 | } | |
| 791 | |||
| 792 | 715 | bool FloorspaceReverseTranslator_Impl::orientVerticesForRoof(Point3dVector& points) { | |
| 793 |
1/1✓ Branch 1 taken 715 times.
|
715 | boost::optional<Vector3d> outwardNormal = getOutwardNormal(points); |
| 794 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 715 times.
|
715 | if (!outwardNormal) { |
| 795 | //LOG(Error, "Cannot compute outwardNormal for floorPrint."); | ||
| 796 | ✗ | return false; | |
| 797 | } | ||
| 798 |
3/4✓ Branch 1 taken 715 times.
✓ Branch 4 taken 715 times.
✓ Branch 6 taken 715 times.
✗ Branch 7 not taken.
|
715 | if (outwardNormal->z() < 0) { |
| 799 |
1/1✓ Branch 3 taken 715 times.
|
715 | std::reverse(points.begin(), points.end()); |
| 800 | } | ||
| 801 | 715 | return true; | |
| 802 | 715 | } | |
| 803 | |||
| 804 | 1 | ConstructionAirBoundary FloorspaceReverseTranslator_Impl::getAirWallConstruction(Model& model) { | |
| 805 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | boost::optional<ConstructionAirBoundary> result = model.getConcreteModelObjectByName<ConstructionAirBoundary>("AirWall"); |
| 806 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (!result) { |
| 807 |
1/1✓ Branch 1 taken 1 time.
|
1 | ConstructionAirBoundary airWall(model); |
| 808 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | airWall.setName("AirWall"); |
| 809 | 1 | return airWall; | |
| 810 | 1 | } | |
| 811 | ✗ | OS_ASSERT(result); | |
| 812 | ✗ | return result.get(); | |
| 813 | 1 | } | |
| 814 | } // namespace detail | ||
| 815 | |||
| 816 | //////////////////////////////////////////////////////////////////////////////////////////// | ||
| 817 | |||
| 818 | 30 | FloorspaceReverseTranslator::FloorspaceReverseTranslator() { | |
| 819 |
1/1✓ Branch 1 taken 30 times.
|
30 | m_logSink.setLogLevel(Warn); |
| 820 |
2/2✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
|
30 | m_logSink.setChannelRegex(boost::regex("openstudio\\.model\\.FloorspaceReverseTranslator")); |
| 821 |
1/1✓ Branch 2 taken 30 times.
|
30 | m_logSink.setThreadId(std::this_thread::get_id()); |
| 822 | 30 | } | |
| 823 | |||
| 824 | 29 | boost::optional<Model> FloorspaceReverseTranslator::modelFromFloorspace(const std::string& jsonOrPath) { | |
| 825 |
1/1✓ Branch 1 taken 29 times.
|
29 | FSModel fsModel; |
| 826 |
1/1✓ Branch 1 taken 29 times.
|
29 | fsModel.load(jsonOrPath); |
| 827 | |||
| 828 |
1/1✓ Branch 1 taken 29 times.
|
29 | Model model; |
| 829 |
1/1✓ Branch 1 taken 29 times.
|
29 | detail::FloorspaceReverseTranslator_Impl visitor(model); |
| 830 |
1/1✓ Branch 1 taken 29 times.
|
29 | fsModel.Accept(visitor); |
| 831 | |||
| 832 | // Do some intersections - the logic is lifted form the ThreeJS reverse translator | ||
| 833 |
1/1✓ Branch 1 taken 29 times.
|
29 | DoSurfaceMatchingAndIntersection(model); |
| 834 | |||
| 835 | // Get the handle map | ||
| 836 |
1/1✓ Branch 1 taken 29 times.
|
29 | m_handleMapping = visitor.handleMapping(); |
| 837 | |||
| 838 |
1/1✓ Branch 1 taken 29 times.
|
58 | return model; |
| 839 | 29 | } | |
| 840 | |||
| 841 | //boost::optional<Model> FloorspaceReverseTranslator::modelFromFloorspace(FSModel const& fsModel) { | ||
| 842 | |||
| 843 | // // Reset the log sink before translation | ||
| 844 | // m_logSink.setThreadId(std::this_thread::get_id()); | ||
| 845 | // m_logSink.resetStringStream();ll takes a | ||
| 846 | |||
| 847 | // Model model; | ||
| 848 | // detail::FloorspaceReverseTranslator_Impl visitor(model); | ||
| 849 | // fsModel.Accept(visitor); | ||
| 850 | |||
| 851 | // // Do some intersections - the logic is lifted form the ThreeJS reverse translator | ||
| 852 | // DoSurfaceMatchingAndIntersection(model); | ||
| 853 | |||
| 854 | // // Get the handle map | ||
| 855 | // m_handleMapping = visitor.handleMapping(); | ||
| 856 | |||
| 857 | // return model; | ||
| 858 | //} | ||
| 859 | |||
| 860 | 3 | std::map<UUID, UUID> FloorspaceReverseTranslator::handleMapping() const { | |
| 861 | 3 | return m_handleMapping; | |
| 862 | } | ||
| 863 | |||
| 864 | 29 | void FloorspaceReverseTranslator::DoSurfaceMatchingAndIntersection(Model& model) { | |
| 865 | // Get a list of stories sotted by elevation and name | ||
| 866 |
1/1✓ Branch 1 taken 29 times.
|
29 | std::vector<BuildingStory> stories = SortStoriesByElevationAndName(model); |
| 867 | |||
| 868 | // map of story index to sorted spaces | ||
| 869 | 29 | std::vector<std::vector<Space>> sortedSpaces; | |
| 870 | |||
| 871 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 2 taken 29 times.
|
101 | for (unsigned i = 0; i < stories.size(); ++i) { |
| 872 |
1/1✓ Branch 2 taken 72 times.
|
72 | std::vector<Space> spaces = SortSpacesByAreaAndName(stories[i]); |
| 873 |
1/1✓ Branch 1 taken 72 times.
|
72 | sortedSpaces.push_back(spaces); |
| 874 | 72 | } | |
| 875 | |||
| 876 | // Intersect between stories | ||
| 877 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 2 taken 29 times.
|
101 | for (unsigned i = 0; i < stories.size(); ++i) { |
| 878 | // bounding box for story i in building coordinates | ||
| 879 |
1/1✓ Branch 2 taken 72 times.
|
72 | BoundingBox storyI_BB = stories[i].boundingBoxBuildingCoordinates(); |
| 880 |
2/2✓ Branch 2 taken 72 times.
✓ Branch 5 taken 72 times.
|
72 | std::string namei = *stories[i].name(); |
| 881 | |||
| 882 |
2/2✓ Branch 1 taken 115 times.
✓ Branch 2 taken 72 times.
|
187 | for (unsigned j = i + 1; j < stories.size(); ++j) { |
| 883 |
2/2✓ Branch 2 taken 115 times.
✓ Branch 5 taken 115 times.
|
115 | std::string namej = *stories[j].name(); |
| 884 | |||
| 885 | // check if storyI_BB intersects bounding box for story j in building coordinates | ||
| 886 |
4/4✓ Branch 2 taken 115 times.
✓ Branch 5 taken 115 times.
✓ Branch 7 taken 72 times.
✓ Branch 8 taken 43 times.
|
115 | if (!storyI_BB.intersects(stories[j].boundingBoxBuildingCoordinates())) { |
| 887 | 72 | continue; | |
| 888 | } | ||
| 889 | |||
| 890 | // loop over sorted spaces on story i | ||
| 891 |
2/2✓ Branch 6 taken 518 times.
✓ Branch 7 taken 43 times.
|
561 | for (auto& spaceI : sortedSpaces[i]) { |
| 892 | // bounding box for space on story i in building coordinates | ||
| 893 |
1/1✓ Branch 1 taken 518 times.
|
518 | BoundingBox spaceI_BB = spaceI.boundingBoxBuildingCoordinates(); |
| 894 | // loop over sorted spaces on story j | ||
| 895 |
2/2✓ Branch 6 taken 7757 times.
✓ Branch 7 taken 518 times.
|
8275 | for (auto& spaceJ : sortedSpaces[j]) { |
| 896 | // check if intersects bounding box for space on story j in building coordinates | ||
| 897 |
4/4✓ Branch 1 taken 7757 times.
✓ Branch 4 taken 7757 times.
✓ Branch 6 taken 2311 times.
✓ Branch 7 taken 5446 times.
|
7757 | if (spaceI_BB.intersects(spaceJ.boundingBoxBuildingCoordinates())) { |
| 898 |
1/1✓ Branch 1 taken 2311 times.
|
2311 | spaceI.intersectSurfaces(spaceJ); |
| 899 |
1/1✓ Branch 1 taken 2311 times.
|
2311 | spaceI.matchSurfaces(spaceJ); |
| 900 | } | ||
| 901 | } | ||
| 902 | } | ||
| 903 | 115 | } | |
| 904 | 72 | } | |
| 905 | |||
| 906 | // Intersect within the same story | ||
| 907 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 2 taken 29 times.
|
101 | for (unsigned i = 0; i < stories.size(); ++i) { |
| 908 | 72 | std::vector<Space>& spaces = sortedSpaces[i]; | |
| 909 | |||
| 910 |
2/2✓ Branch 1 taken 664 times.
✓ Branch 2 taken 72 times.
|
736 | for (unsigned j = 0; j < spaces.size(); ++j) { |
| 911 | // bounding box for space j in building coordinates | ||
| 912 |
1/1✓ Branch 2 taken 664 times.
|
664 | BoundingBox spaceJ_BB = spaces[j].boundingBoxBuildingCoordinates(); |
| 913 | |||
| 914 |
2/2✓ Branch 1 taken 5304 times.
✓ Branch 2 taken 664 times.
|
5968 | for (unsigned k = j + 1; k < spaces.size(); ++k) { |
| 915 | // check if space bounding boxes intersect | ||
| 916 |
4/4✓ Branch 2 taken 5304 times.
✓ Branch 5 taken 5304 times.
✓ Branch 7 taken 1440 times.
✓ Branch 8 taken 3864 times.
|
5304 | if (spaceJ_BB.intersects(spaces[k].boundingBoxBuildingCoordinates())) { |
| 917 | // DLM: should not need to intersect on same floor? | ||
| 918 |
1/1✓ Branch 3 taken 1440 times.
|
1440 | spaces[j].intersectSurfaces(spaces[k]); |
| 919 |
1/1✓ Branch 3 taken 1440 times.
|
1440 | spaces[j].matchSurfaces(spaces[k]); |
| 920 | } | ||
| 921 | } | ||
| 922 | } | ||
| 923 | } | ||
| 924 | 29 | } | |
| 925 | |||
| 926 | 29 | std::vector<BuildingStory> FloorspaceReverseTranslator::SortStoriesByElevationAndName(Model& model) { | |
| 927 | 29 | std::vector<BuildingStory> stories = model.getConcreteModelObjects<BuildingStory>(); | |
| 928 |
1/1✓ Branch 3 taken 29 times.
|
29 | std::sort(stories.begin(), stories.end(), [](const BuildingStory& a, const BuildingStory& b) -> bool { |
| 929 |
1/1✓ Branch 1 taken 69 times.
|
69 | boost::optional<double> aZ = a.nominalZCoordinate(); |
| 930 |
1/1✓ Branch 1 taken 69 times.
|
69 | boost::optional<double> bZ = b.nominalZCoordinate(); |
| 931 |
3/6✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
138 | if (aZ && bZ) { |
| 932 |
3/4✓ Branch 1 taken 69 times.
✓ Branch 4 taken 69 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 69 times.
|
69 | if (aZ.get() == bZ.get()) { |
| 933 | ✗ | return a.nameString() < b.nameString(); | |
| 934 | } else { | ||
| 935 |
2/2✓ Branch 1 taken 69 times.
✓ Branch 4 taken 69 times.
|
69 | return aZ.get() < bZ.get(); |
| 936 | } | ||
| 937 | ✗ | } else if (aZ) { | |
| 938 | ✗ | return true; | |
| 939 | ✗ | } else if (bZ) { | |
| 940 | ✗ | return false; | |
| 941 | } | ||
| 942 | ✗ | return a.nameString() < b.nameString(); | |
| 943 | }); | ||
| 944 | |||
| 945 | 29 | return stories; | |
| 946 | ✗ | } | |
| 947 | |||
| 948 | 72 | std::vector<Space> FloorspaceReverseTranslator::SortSpacesByAreaAndName(BuildingStory& story) { | |
| 949 | 72 | std::vector<Space> spaces = story.spaces(); | |
| 950 | |||
| 951 | // sort spaces by floor area then name | ||
| 952 |
1/1✓ Branch 3 taken 72 times.
|
72 | std::sort(spaces.begin(), spaces.end(), [](const Space& a, const Space& b) -> bool { |
| 953 | 3003 | double areaA = a.floorArea(); | |
| 954 | 3003 | double areaB = b.floorArea(); | |
| 955 |
2/2✓ Branch 0 taken 47 times.
✓ Branch 1 taken 2956 times.
|
3003 | if (areaA == areaB) { |
| 956 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
47 | return a.nameString() < b.nameString(); |
| 957 | } | ||
| 958 | 2956 | return areaA < areaB; | |
| 959 | }); | ||
| 960 | |||
| 961 | 72 | return spaces; | |
| 962 | ✗ | } | |
| 963 | |||
| 964 | 14 | std::vector<LogMessage> FloorspaceReverseTranslator::warnings() const { | |
| 965 | 14 | std::vector<LogMessage> result; | |
| 966 | |||
| 967 |
2/3✓ Branch 1 taken 14 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 14 times.
|
14 | for (const LogMessage& logMessage : m_logSink.logMessages()) { |
| 968 | ✗ | if (logMessage.logLevel() == Warn) { | |
| 969 | ✗ | result.push_back(logMessage); | |
| 970 | } | ||
| 971 | 14 | } | |
| 972 | |||
| 973 | 14 | return result; | |
| 974 | ✗ | } | |
| 975 | |||
| 976 | 14 | std::vector<LogMessage> FloorspaceReverseTranslator::errors() const { | |
| 977 | 14 | std::vector<LogMessage> result; | |
| 978 | |||
| 979 |
2/3✓ Branch 1 taken 14 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 14 times.
|
14 | for (const LogMessage& logMessage : m_logSink.logMessages()) { |
| 980 | ✗ | if (logMessage.logLevel() > Warn) { | |
| 981 | ✗ | result.push_back(logMessage); | |
| 982 | } | ||
| 983 | 14 | } | |
| 984 | |||
| 985 | 14 | return result; | |
| 986 | ✗ | } | |
| 987 | |||
| 988 | } // namespace model | ||
| 989 | } // namespace openstudio | ||
| 990 |