src/utilities/floorspace/FSModel.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 "FSModel.hpp" | ||
| 7 | |||
| 8 | #include "../core/Assert.hpp" | ||
| 9 | #include "../core/Json.hpp" | ||
| 10 | #include "../geometry/Point3d.hpp" | ||
| 11 | #include "../geometry/Vector3d.hpp" | ||
| 12 | #include "../geometry/Geometry.hpp" | ||
| 13 | #include "../geometry/Intersection.hpp" | ||
| 14 | |||
| 15 | namespace openstudio { | ||
| 16 | |||
| 17 | ✗ | FSModel::FSModel(const std::string& json) { | |
| 18 | ✗ | load(json); | |
| 19 | ✗ | } | |
| 20 | |||
| 21 | 29 | void FSModel::load(const std::string& json) { | |
| 22 |
1/1✓ Branch 1 taken 29 times.
|
29 | Json::CharReaderBuilder rbuilder; |
| 23 |
1/1✓ Branch 1 taken 29 times.
|
29 | std::istringstream ss(json); |
| 24 | 29 | std::string formattedErrors; | |
| 25 | // Parse the json string, if this fails we will check to see if a path has been provided | ||
| 26 |
1/1✓ Branch 1 taken 29 times.
|
29 | bool parsingSuccessful = Json::parseFromStream(rbuilder, ss, &m_value, &formattedErrors); |
| 27 | |||
| 28 |
1/2✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
|
29 | if (!parsingSuccessful) { |
| 29 | |||
| 30 | // see if this is a path | ||
| 31 |
1/1✓ Branch 1 taken 29 times.
|
29 | openstudio::path p = toPath(json); |
| 32 |
5/8✓ Branch 1 taken 29 times.
✓ Branch 3 taken 29 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 29 times.
✓ Branch 8 taken 29 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 29 times.
✗ Branch 11 not taken.
|
29 | if (boost::filesystem::exists(p) && boost::filesystem::is_regular_file(p)) { |
| 33 | // open file | ||
| 34 |
2/2✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
|
29 | std::ifstream ifs(openstudio::toSystemFilename(p)); |
| 35 |
1/1✓ Branch 1 taken 29 times.
|
29 | m_value.clear(); |
| 36 | 29 | formattedErrors.clear(); | |
| 37 |
1/1✓ Branch 1 taken 29 times.
|
29 | parsingSuccessful = Json::parseFromStream(rbuilder, ifs, &m_value, &formattedErrors); |
| 38 | 29 | } | |
| 39 | 29 | } | |
| 40 | |||
| 41 |
1/2✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
|
29 | if (parsingSuccessful) { |
| 42 | |||
| 43 |
2/2✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
|
29 | Json::Value project = m_value.get("project", Json::objectValue); |
| 44 |
1/1✓ Branch 1 taken 29 times.
|
29 | m_project.load(project, *this); |
| 45 | |||
| 46 | // Establishes the unit conversion from the project's config property. | ||
| 47 |
1/1✓ Branch 1 taken 29 times.
|
29 | setUnits(); |
| 48 | |||
| 49 | // Load all the space assignment objects so that when the space is loaded | ||
| 50 | // we can find the objects via their ids | ||
| 51 |
9/9✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 8 taken 29 times.
✓ Branch 11 taken 29 times.
✓ Branch 14 taken 547 times.
✓ Branch 17 taken 547 times.
✓ Branch 20 taken 576 times.
✓ Branch 22 taken 547 times.
✓ Branch 23 taken 29 times.
|
1123 | for (const auto& thermalZone : m_value.get("thermal_zones", Json::arrayValue)) { |
| 52 |
1/1✓ Branch 1 taken 547 times.
|
547 | m_thermalZones.emplace_back(thermalZone); |
| 53 | 29 | } | |
| 54 | |||
| 55 |
9/9✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 8 taken 29 times.
✓ Branch 11 taken 29 times.
✓ Branch 14 taken 9 times.
✓ Branch 17 taken 9 times.
✓ Branch 20 taken 38 times.
✓ Branch 22 taken 9 times.
✓ Branch 23 taken 29 times.
|
47 | for (const auto& buildingUnit : m_value.get("building_units", Json::arrayValue)) { |
| 56 |
1/1✓ Branch 1 taken 9 times.
|
9 | m_buildingUnits.emplace_back(buildingUnit); |
| 57 | 29 | } | |
| 58 | |||
| 59 | // TODO: not doing anything yet | ||
| 60 |
6/9✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 8 taken 29 times.
✓ Branch 11 taken 29 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 20 taken 29 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 29 times.
|
29 | for (const auto& buildingType : m_value.get("building_type", Json::arrayValue)) { |
| 61 | ✗ | m_buildingTypes.emplace_back(buildingType); | |
| 62 | 29 | } | |
| 63 | |||
| 64 |
9/9✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 8 taken 29 times.
✓ Branch 11 taken 29 times.
✓ Branch 14 taken 113 times.
✓ Branch 17 taken 113 times.
✓ Branch 20 taken 142 times.
✓ Branch 22 taken 113 times.
✓ Branch 23 taken 29 times.
|
255 | for (const auto& spaceType : m_value.get("space_types", Json::arrayValue)) { |
| 65 |
1/1✓ Branch 1 taken 113 times.
|
113 | m_spaceTypes.emplace_back(spaceType); |
| 66 | 29 | } | |
| 67 | |||
| 68 |
9/9✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 8 taken 29 times.
✓ Branch 11 taken 29 times.
✓ Branch 14 taken 9 times.
✓ Branch 17 taken 9 times.
✓ Branch 20 taken 38 times.
✓ Branch 22 taken 9 times.
✓ Branch 23 taken 29 times.
|
47 | for (const auto& constructionSet : m_value.get("construction_sets", Json::arrayValue)) { |
| 69 |
1/1✓ Branch 1 taken 9 times.
|
9 | m_constructionSets.emplace_back(constructionSet); |
| 70 | 29 | } | |
| 71 | |||
| 72 |
9/9✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 8 taken 29 times.
✓ Branch 11 taken 29 times.
✓ Branch 14 taken 3 times.
✓ Branch 17 taken 3 times.
✓ Branch 20 taken 32 times.
✓ Branch 22 taken 3 times.
✓ Branch 23 taken 29 times.
|
35 | for (const auto& daylightingControlDefinition : m_value.get("daylighting_control_definitions", Json::arrayValue)) { |
| 73 |
1/1✓ Branch 1 taken 3 times.
|
3 | m_daylightingControlDefinitions.emplace_back(daylightingControlDefinition, *this); |
| 74 | 29 | } | |
| 75 | |||
| 76 |
9/9✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 8 taken 29 times.
✓ Branch 11 taken 29 times.
✓ Branch 14 taken 758 times.
✓ Branch 17 taken 758 times.
✓ Branch 20 taken 787 times.
✓ Branch 22 taken 758 times.
✓ Branch 23 taken 29 times.
|
1545 | for (const auto& windowDefinition : m_value.get("window_definitions", Json::arrayValue)) { |
| 77 |
1/1✓ Branch 1 taken 758 times.
|
758 | m_windowDefinitions.emplace_back(windowDefinition, *this); |
| 78 | 29 | } | |
| 79 | |||
| 80 |
9/9✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 8 taken 29 times.
✓ Branch 11 taken 29 times.
✓ Branch 14 taken 5 times.
✓ Branch 17 taken 5 times.
✓ Branch 20 taken 34 times.
✓ Branch 22 taken 5 times.
✓ Branch 23 taken 29 times.
|
39 | for (const auto& doorDefinition : m_value.get("door_definitions", Json::arrayValue)) { |
| 81 |
1/1✓ Branch 1 taken 5 times.
|
5 | m_doorDefinitions.emplace_back(doorDefinition, *this); |
| 82 | 29 | } | |
| 83 | |||
| 84 |
9/9✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 8 taken 29 times.
✓ Branch 11 taken 29 times.
✓ Branch 14 taken 72 times.
✓ Branch 17 taken 72 times.
✓ Branch 20 taken 101 times.
✓ Branch 22 taken 72 times.
✓ Branch 23 taken 29 times.
|
173 | for (const auto& story : m_value.get("stories", Json::arrayValue)) { |
| 85 |
1/1✓ Branch 1 taken 72 times.
|
72 | m_stories.emplace_back(story, *this); |
| 86 | 29 | } | |
| 87 | 29 | } | |
| 88 | 29 | } | |
| 89 | |||
| 90 | 556 | boost::optional<FSThermalZone> FSModel::thermalZone(const std::string& thermalZoneId) const { | |
| 91 | |||
| 92 |
1/2✓ Branch 5 taken 24299 times.
✗ Branch 6 not taken.
|
24299 | for (const auto& zone : m_thermalZones) { |
| 93 |
3/3✓ Branch 1 taken 24299 times.
✓ Branch 4 taken 556 times.
✓ Branch 5 taken 23743 times.
|
24299 | if (zone.id() == thermalZoneId) { |
| 94 |
1/1✓ Branch 1 taken 556 times.
|
556 | return zone; |
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | ✗ | return boost::none; | |
| 99 | } | ||
| 100 | |||
| 101 | 34 | boost::optional<FSBuildingUnit> FSModel::buildingUnit(const std::string& buildingUnitId) const { | |
| 102 | |||
| 103 |
2/2✓ Branch 5 taken 33 times.
✓ Branch 6 taken 3 times.
|
36 | for (const auto& unit : m_buildingUnits) { |
| 104 |
3/3✓ Branch 1 taken 33 times.
✓ Branch 4 taken 31 times.
✓ Branch 5 taken 2 times.
|
33 | if (unit.id() == buildingUnitId) { |
| 105 |
1/1✓ Branch 1 taken 31 times.
|
31 | return unit; |
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | 3 | return boost::none; | |
| 110 | } | ||
| 111 | |||
| 112 | ✗ | boost::optional<FSBuildingType> FSModel::buildingType(const std::string& buildingTypeId) const { | |
| 113 | |||
| 114 | ✗ | for (const auto& type : m_buildingTypes) { | |
| 115 | ✗ | if (type.id() == buildingTypeId) { | |
| 116 | ✗ | return type; | |
| 117 | } | ||
| 118 | } | ||
| 119 | |||
| 120 | ✗ | return boost::none; | |
| 121 | } | ||
| 122 | |||
| 123 | 618 | boost::optional<FSSpaceType> FSModel::spaceType(const std::string& spaceTypeId) const { | |
| 124 | |||
| 125 |
2/2✓ Branch 5 taken 2757 times.
✓ Branch 6 taken 3 times.
|
2760 | for (const auto& spacetype : m_spaceTypes) { |
| 126 |
3/3✓ Branch 1 taken 2757 times.
✓ Branch 4 taken 615 times.
✓ Branch 5 taken 2142 times.
|
2757 | if (spacetype.id() == spaceTypeId) { |
| 127 |
1/1✓ Branch 1 taken 615 times.
|
615 | return spacetype; |
| 128 | } | ||
| 129 | } | ||
| 130 | |||
| 131 | 3 | return boost::none; | |
| 132 | } | ||
| 133 | |||
| 134 | 35 | boost::optional<FSConstructionSet> FSModel::constructionSet(const std::string& constructionSetId) const { | |
| 135 |
2/2✓ Branch 5 taken 36 times.
✓ Branch 6 taken 3 times.
|
39 | for (const auto& constructionSet : m_constructionSets) { |
| 136 |
3/3✓ Branch 1 taken 36 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 4 times.
|
36 | if (constructionSet.id() == constructionSetId) { |
| 137 |
1/1✓ Branch 1 taken 32 times.
|
32 | return constructionSet; |
| 138 | } | ||
| 139 | } | ||
| 140 | |||
| 141 | 3 | return boost::none; | |
| 142 | } | ||
| 143 | |||
| 144 | 11 | boost::optional<FSDaylightingControlDefinition> FSModel::daylightingControlDefinition(const std::string& daylightingControlDefinitionId) const { | |
| 145 |
1/2✓ Branch 5 taken 11 times.
✗ Branch 6 not taken.
|
11 | for (const auto& definition : m_daylightingControlDefinitions) { |
| 146 |
2/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
|
11 | if (definition.id() == daylightingControlDefinitionId) { |
| 147 |
1/1✓ Branch 1 taken 11 times.
|
11 | return definition; |
| 148 | } | ||
| 149 | } | ||
| 150 | |||
| 151 | ✗ | return boost::none; | |
| 152 | } | ||
| 153 | |||
| 154 | 813 | boost::optional<FSWindowDefinition> FSModel::windowDefinition(const std::string& windowDefinitionId) const { | |
| 155 |
1/2✓ Branch 5 taken 56906 times.
✗ Branch 6 not taken.
|
56906 | for (const auto& definition : m_windowDefinitions) { |
| 156 |
3/3✓ Branch 1 taken 56906 times.
✓ Branch 4 taken 813 times.
✓ Branch 5 taken 56093 times.
|
56906 | if (definition.id() == windowDefinitionId) { |
| 157 |
1/1✓ Branch 1 taken 813 times.
|
813 | return definition; |
| 158 | } | ||
| 159 | } | ||
| 160 | ✗ | return boost::none; | |
| 161 | } | ||
| 162 | |||
| 163 | 11 | boost::optional<FSDoorDefinition> FSModel::doorDefinition(const std::string& doorDefinitionId) const { | |
| 164 |
1/2✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
|
18 | for (const auto& definition : m_doorDefinitions) { |
| 165 |
3/3✓ Branch 1 taken 18 times.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 7 times.
|
18 | if (definition.id() == doorDefinitionId) { |
| 166 |
1/1✓ Branch 1 taken 11 times.
|
11 | return definition; |
| 167 | } | ||
| 168 | } | ||
| 169 | ✗ | return boost::none; | |
| 170 | } | ||
| 171 | |||
| 172 | 58 | boost::optional<FSProject> FSModel::project() const { | |
| 173 | 58 | return m_project; | |
| 174 | } | ||
| 175 | |||
| 176 | 9222 | double FSModel::lengthToMeters() const { | |
| 177 | 9222 | return m_lengthToMeters; | |
| 178 | } | ||
| 179 | |||
| 180 | 29 | void FSModel::setUnits() { | |
| 181 | 29 | m_lengthToMeters = 1; | |
| 182 |
15/20✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
✓ Branch 9 taken 15 times.
✓ Branch 10 taken 14 times.
✓ Branch 12 taken 15 times.
✓ Branch 15 taken 15 times.
✓ Branch 18 taken 15 times.
✓ Branch 20 taken 14 times.
✓ Branch 21 taken 1 time.
✓ Branch 22 taken 15 times.
✓ Branch 23 taken 14 times.
✓ Branch 25 taken 29 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 28 times.
✓ Branch 29 taken 1 time.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
|
29 | if (m_project.config().units() == "ip" || m_project.config().units() == "ft") { |
| 183 | 28 | m_lengthToMeters = 0.3048; | |
| 184 | } | ||
| 185 | 29 | } | |
| 186 | |||
| 187 | 29 | std::vector<FSThermalZone> FSModel::thermalZones() const { | |
| 188 | 29 | return m_thermalZones; | |
| 189 | } | ||
| 190 | |||
| 191 | 29 | std::vector<FSBuildingUnit> FSModel::buildingUnits() const { | |
| 192 | 29 | return m_buildingUnits; | |
| 193 | } | ||
| 194 | |||
| 195 | ✗ | std::vector<FSBuildingType> FSModel::buildingTypes() const { | |
| 196 | ✗ | return m_buildingTypes; | |
| 197 | } | ||
| 198 | |||
| 199 | 29 | std::vector<FSSpaceType> FSModel::spaceTypes() const { | |
| 200 | 29 | return m_spaceTypes; | |
| 201 | } | ||
| 202 | |||
| 203 | 29 | std::vector<FSConstructionSet> FSModel::constructionSets() const { | |
| 204 | 29 | return m_constructionSets; | |
| 205 | } | ||
| 206 | |||
| 207 | ✗ | std::vector<FSDaylightingControlDefinition> FSModel::daylightingControlDefinitions() const { | |
| 208 | ✗ | return m_daylightingControlDefinitions; | |
| 209 | } | ||
| 210 | |||
| 211 | ✗ | std::vector<FSWindowDefinition> FSModel::windowDefinitions() const { | |
| 212 | ✗ | return m_windowDefinitions; | |
| 213 | } | ||
| 214 | |||
| 215 | ✗ | std::vector<FSDoorDefinition> FSModel::doorDefinitions() const { | |
| 216 | ✗ | return m_doorDefinitions; | |
| 217 | } | ||
| 218 | |||
| 219 | 29 | std::vector<FSStory> FSModel::stories() const { | |
| 220 | 29 | return m_stories; | |
| 221 | } | ||
| 222 | |||
| 223 | 29 | void FSModel::Accept(FSVisitor& visitor) const { | |
| 224 | 29 | visitor.Dispatch(*this); | |
| 225 | 29 | } | |
| 226 | |||
| 227 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 228 | |||
| 229 | ✗ | FSProject::FSProject(const Json::Value& root, const FSModel& model) { | |
| 230 | ✗ | load(root, model); | |
| 231 | ✗ | } | |
| 232 | |||
| 233 | 29 | void FSProject::load(const Json::Value& root, const FSModel& model) { | |
| 234 | |||
| 235 | // Get config | ||
| 236 |
2/2✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
|
29 | Json::Value config = root.get("config", Json::objectValue); |
| 237 |
1/1✓ Branch 1 taken 29 times.
|
29 | m_config = FSConfig(config); |
| 238 | |||
| 239 |
2/2✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
|
29 | Json::Value ground = root.get("ground", Json::objectValue); |
| 240 |
1/1✓ Branch 1 taken 29 times.
|
29 | m_ground = FSGround(ground, model); |
| 241 | |||
| 242 | // Get north_Axis | ||
| 243 |
3/3✓ Branch 1 taken 29 times.
✓ Branch 3 taken 26 times.
✓ Branch 4 taken 3 times.
|
29 | if (root.isMember("north_axis")) { |
| 244 |
3/3✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
✓ Branch 7 taken 26 times.
|
26 | m_north_axis = root.get("north_axis", m_north_axis).asDouble(); |
| 245 | } else { | ||
| 246 |
1/1✓ Branch 1 taken 3 times.
|
3 | m_north_axis = m_config.northAxis(); |
| 247 | } | ||
| 248 | 29 | } | |
| 249 | |||
| 250 | 29 | double FSProject::northAxis() const { | |
| 251 | 29 | return m_north_axis; | |
| 252 | } | ||
| 253 | |||
| 254 | 44 | FSConfig& FSProject::config() { | |
| 255 | 44 | return m_config; | |
| 256 | } | ||
| 257 | |||
| 258 | 29 | FSGround& FSProject::ground() { | |
| 259 | 29 | return m_ground; | |
| 260 | } | ||
| 261 | |||
| 262 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 263 | |||
| 264 | 29 | FSConfig::FSConfig(const Json::Value& root) { | |
| 265 |
3/3✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
|
29 | m_units = root.get("units", m_units).asString(); |
| 266 |
3/3✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
|
29 | m_unitsEditable = root.get("unitsEditable", m_unitsEditable).asBool(); |
| 267 |
3/3✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
|
29 | m_language = root.get("language", m_language).asString(); |
| 268 |
3/3✓ Branch 1 taken 29 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 25 times.
|
29 | if (root.isMember("north_axis")) { |
| 269 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | m_north_axis = root.get("north_axis", m_north_axis).asDouble(); |
| 270 | } | ||
| 271 | 29 | } | |
| 272 | |||
| 273 | 44 | std::string FSConfig::units() const { | |
| 274 | 44 | return m_units; | |
| 275 | } | ||
| 276 | |||
| 277 | ✗ | std::string FSConfig::language() const { | |
| 278 | ✗ | return m_language; | |
| 279 | } | ||
| 280 | |||
| 281 | ✗ | bool FSConfig::unitsEditable() const { | |
| 282 | ✗ | return m_unitsEditable; | |
| 283 | } | ||
| 284 | |||
| 285 | 3 | double FSConfig::northAxis() const { | |
| 286 | 3 | return m_north_axis; | |
| 287 | } | ||
| 288 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 289 | |||
| 290 | 29 | FSGround::FSGround(const Json::Value& root, const FSModel& model) { | |
| 291 | |||
| 292 |
4/4✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
✓ Branch 10 taken 29 times.
|
29 | m_floor_offset = root.get("floor_offset", 0).asDouble() * model.lengthToMeters(); |
| 293 |
3/3✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
|
29 | m_azimuth_angle = root.get("azimuth_angle", 0).asDouble(); |
| 294 |
3/3✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 29 times.
|
29 | m_tilt_slope = root.get("tilt_slope", 0).asDouble(); |
| 295 | 29 | } | |
| 296 | |||
| 297 | 29 | double FSGround::floorOffset() const { | |
| 298 | 29 | return m_floor_offset; | |
| 299 | } | ||
| 300 | |||
| 301 | ✗ | double FSGround::azimuthAngle() const { | |
| 302 | ✗ | return m_azimuth_angle; | |
| 303 | } | ||
| 304 | |||
| 305 | ✗ | double FSGround::tiltSlope() const { | |
| 306 | ✗ | return m_tilt_slope; | |
| 307 | } | ||
| 308 | |||
| 309 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 310 | |||
| 311 | 3070 | FSBase::FSBase(const Json::Value& root) { | |
| 312 |
2/2✓ Branch 1 taken 3070 times.
✓ Branch 4 taken 3070 times.
|
6140 | assertKeyAndType(root, "name", Json::stringValue); |
| 313 |
3/3✓ Branch 1 taken 3070 times.
✓ Branch 4 taken 3070 times.
✓ Branch 7 taken 3070 times.
|
3070 | m_name = root.get("name", m_name).asString(); |
| 314 | //assertKeyAndType(root, "handle", Json::stringValue); | ||
| 315 |
3/3✓ Branch 1 taken 3070 times.
✓ Branch 4 taken 3070 times.
✓ Branch 7 taken 3070 times.
|
3070 | m_handle = root.get("handle", m_handle).asString(); |
| 316 |
2/2✓ Branch 1 taken 3070 times.
✓ Branch 4 taken 3070 times.
|
6140 | assertKeyAndType(root, "id", Json::stringValue); |
| 317 |
3/3✓ Branch 1 taken 3070 times.
✓ Branch 4 taken 3070 times.
✓ Branch 7 taken 3070 times.
|
3070 | m_id = root.get("id", m_id).asString(); |
| 318 | //assertKeyAndType(root, "color", Json::stringValue); | ||
| 319 |
3/3✓ Branch 1 taken 3070 times.
✓ Branch 4 taken 3070 times.
✓ Branch 7 taken 3070 times.
|
3070 | m_color = root.get("color", "").asString(); |
| 320 | 3070 | } | |
| 321 | |||
| 322 | 2727 | const std::string& FSBase::name() const { | |
| 323 | 2727 | return m_name; | |
| 324 | } | ||
| 325 | |||
| 326 | 1476 | const std::string& FSBase::handle() const { | |
| 327 | 1476 | return m_handle; | |
| 328 | } | ||
| 329 | |||
| 330 | 84060 | const std::string& FSBase::id() const { | |
| 331 | 84060 | return m_id; | |
| 332 | } | ||
| 333 | |||
| 334 | 741 | const std::string& FSBase::color() const { | |
| 335 | 741 | return m_color; | |
| 336 | } | ||
| 337 | |||
| 338 | ✗ | void FSBase::setName(const std::string& name) { | |
| 339 | ✗ | m_name = name; | |
| 340 | ✗ | } | |
| 341 | |||
| 342 | ✗ | void FSBase::setHandle(const std::string& handle) { | |
| 343 | ✗ | m_handle = handle; | |
| 344 | ✗ | } | |
| 345 | |||
| 346 | ✗ | void FSBase::setId(const std::string& id) { | |
| 347 | ✗ | m_id = id; | |
| 348 | ✗ | } | |
| 349 | |||
| 350 | ✗ | void FSBase::setColor(const std::string& color) { | |
| 351 | ✗ | m_color = color; | |
| 352 | ✗ | } | |
| 353 | |||
| 354 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 355 | |||
| 356 | 72 | FSStory::FSStory(const Json::Value& root, const FSModel& model) : FSBase(root) { | |
| 357 | |||
| 358 |
4/4✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 72 times.
✓ Branch 10 taken 72 times.
|
72 | m_below_floor_plenum_height = root.get("below_floor_plenum_height", 0).asDouble() * model.lengthToMeters(); |
| 359 | // Defaults to 3m but also cannot be less than 0.1 | ||
| 360 |
5/5✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 72 times.
✓ Branch 10 taken 72 times.
✓ Branch 13 taken 72 times.
|
72 | m_floor_to_ceiling_height = root.get("floor_to_ceiling_height", 3 / model.lengthToMeters()).asDouble() * model.lengthToMeters(); |
| 361 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
|
72 | if (m_floor_to_ceiling_height < 0.1) { |
| 362 | 2 | m_floor_to_ceiling_height = 3; | |
| 363 | } | ||
| 364 |
4/4✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 72 times.
✓ Branch 10 taken 72 times.
|
72 | m_above_ceiling_plenum_height = root.get("above_ceiling_plenum_height", 0).asDouble() * model.lengthToMeters(); |
| 365 |
3/3✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 72 times.
|
72 | m_image_visible = root.get("image_visible", m_image_visible).asBool(); |
| 366 |
3/3✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 72 times.
|
72 | m_multiplier = std::max(root.get("multiplier", 1).asInt(), 1); // Make sure minimum value is 1 |
| 367 | |||
| 368 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
|
72 | const Json::Value& geometry = root.get("geometry", Json::arrayValue); |
| 369 |
1/1✓ Branch 1 taken 72 times.
|
72 | m_geometry.load(geometry, model); |
| 370 | |||
| 371 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
|
72 | const Json::Value& spaces = root.get("spaces", Json::arrayValue); |
| 372 |
7/7✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 656 times.
✓ Branch 10 taken 656 times.
✓ Branch 13 taken 728 times.
✓ Branch 15 taken 656 times.
✓ Branch 16 taken 72 times.
|
1384 | for (const auto& json_space : spaces) { |
| 373 |
1/1✓ Branch 1 taken 656 times.
|
656 | FSSpace space = FSSpace(json_space, model, *this); |
| 374 |
2/3✓ Branch 1 taken 656 times.
✓ Branch 5 taken 656 times.
✗ Branch 6 not taken.
|
656 | if (space.face().has_value()) { |
| 375 |
1/1✓ Branch 1 taken 656 times.
|
656 | m_spaces.push_back(space); |
| 376 | } | ||
| 377 | 656 | } | |
| 378 | |||
| 379 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
|
72 | const Json::Value& windows = root.get("windows", Json::arrayValue); |
| 380 |
7/7✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 813 times.
✓ Branch 10 taken 813 times.
✓ Branch 13 taken 885 times.
✓ Branch 15 taken 813 times.
✓ Branch 16 taken 72 times.
|
1698 | for (const auto& json_window : windows) { |
| 381 |
1/1✓ Branch 1 taken 813 times.
|
813 | FSWindow window = FSWindow(json_window, model, *this); |
| 382 |
2/3✓ Branch 1 taken 813 times.
✓ Branch 5 taken 813 times.
✗ Branch 6 not taken.
|
813 | if (window.edge().has_value()) { |
| 383 |
1/1✓ Branch 1 taken 813 times.
|
813 | m_windows.push_back(window); |
| 384 | } | ||
| 385 | 813 | } | |
| 386 | |||
| 387 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
|
72 | const Json::Value& doors = root.get("doors", Json::arrayValue); |
| 388 |
7/7✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
✓ Branch 13 taken 83 times.
✓ Branch 15 taken 11 times.
✓ Branch 16 taken 72 times.
|
94 | for (const auto& json_door : doors) { |
| 389 |
1/1✓ Branch 1 taken 11 times.
|
11 | FSDoor door = FSDoor(json_door, model, *this); |
| 390 |
2/3✓ Branch 1 taken 11 times.
✓ Branch 5 taken 11 times.
✗ Branch 6 not taken.
|
11 | if (door.edge().has_value()) { |
| 391 |
1/1✓ Branch 1 taken 11 times.
|
11 | m_doors.push_back(door); |
| 392 | } | ||
| 393 | 11 | } | |
| 394 | |||
| 395 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
|
72 | const Json::Value& shadings = root.get("shading", Json::arrayValue); |
| 396 |
7/7✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 63 times.
✓ Branch 10 taken 63 times.
✓ Branch 13 taken 135 times.
✓ Branch 15 taken 63 times.
✓ Branch 16 taken 72 times.
|
198 | for (const auto& json_shading : shadings) { |
| 397 |
1/1✓ Branch 1 taken 63 times.
|
63 | FSShading shading = FSShading(json_shading, model, *this); |
| 398 |
3/3✓ Branch 1 taken 63 times.
✓ Branch 5 taken 42 times.
✓ Branch 6 taken 21 times.
|
63 | if (shading.face().has_value()) { |
| 399 |
1/1✓ Branch 1 taken 42 times.
|
42 | m_shadings.push_back(shading); |
| 400 | } | ||
| 401 | 63 | } | |
| 402 | 72 | } | |
| 403 | |||
| 404 | 1375 | double FSStory::belowFloorPlenumHeight() const { | |
| 405 | 1375 | return m_below_floor_plenum_height; | |
| 406 | } | ||
| 407 | |||
| 408 | 791 | double FSStory::floorToCeilingHeight() const { | |
| 409 | 791 | return m_floor_to_ceiling_height; | |
| 410 | } | ||
| 411 | |||
| 412 | 722 | double FSStory::aboveCeilingPlenumHeight() const { | |
| 413 | 722 | return m_above_ceiling_plenum_height; | |
| 414 | } | ||
| 415 | |||
| 416 | 144 | double FSStory::floorToFloorHeight() const { | |
| 417 | 144 | return m_below_floor_plenum_height + m_floor_to_ceiling_height + m_above_ceiling_plenum_height; | |
| 418 | } | ||
| 419 | |||
| 420 | // TODO: MUst be calculated as stories are created | ||
| 421 | ✗ | double FSStory::nominalZCoordinate() const { | |
| 422 | ✗ | return m_nominalZCoordinate; | |
| 423 | } | ||
| 424 | |||
| 425 | 656 | int FSStory::multiplier() const { | |
| 426 | 656 | return m_multiplier; | |
| 427 | } | ||
| 428 | |||
| 429 | ✗ | bool FSStory::imageVisible() const { | |
| 430 | ✗ | return m_image_visible; | |
| 431 | } | ||
| 432 | |||
| 433 | 1533 | const FSGeometry& FSStory::geometry() const { | |
| 434 | 1533 | return m_geometry; | |
| 435 | } | ||
| 436 | |||
| 437 | 72 | std::vector<FSSpace> FSStory::spaces() const { | |
| 438 | 72 | return m_spaces; | |
| 439 | } | ||
| 440 | |||
| 441 | 4481 | std::vector<FSWindow> FSStory::windows() const { | |
| 442 | 4481 | return m_windows; | |
| 443 | } | ||
| 444 | |||
| 445 | 4481 | std::vector<FSDoor> FSStory::doors() const { | |
| 446 | 4481 | return m_doors; | |
| 447 | } | ||
| 448 | |||
| 449 | 72 | std::vector<FSShading> FSStory::shadings() const { | |
| 450 | 72 | return m_shadings; | |
| 451 | } | ||
| 452 | |||
| 453 | 72 | void FSStory::Accept(FSVisitor& visitor) const { | |
| 454 | 72 | visitor.Dispatch(*this); | |
| 455 | 72 | } | |
| 456 | |||
| 457 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 458 | |||
| 459 | 678 | FSAssignment::FSAssignment(const Json::Value& root) : FSBase(root) {} | |
| 460 | |||
| 461 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 462 | |||
| 463 | 547 | FSThermalZone::FSThermalZone(const Json::Value& root) : FSAssignment(root) {} | |
| 464 | |||
| 465 | 547 | void FSThermalZone::Accept(FSVisitor& visitor) const { | |
| 466 | 547 | visitor.Dispatch(*this); | |
| 467 | 547 | } | |
| 468 | |||
| 469 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 470 | |||
| 471 | 9 | FSBuildingUnit::FSBuildingUnit(const Json::Value& root) : FSAssignment(root) {} | |
| 472 | |||
| 473 | 9 | void FSBuildingUnit::Accept(FSVisitor& visitor) const { | |
| 474 | 9 | visitor.Dispatch(*this); | |
| 475 | 9 | } | |
| 476 | |||
| 477 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 478 | |||
| 479 | ✗ | FSBuildingType::FSBuildingType(const Json::Value& root) : FSAssignment(root) {} | |
| 480 | |||
| 481 | ✗ | void FSBuildingType::Accept(FSVisitor& visitor) const { | |
| 482 | ✗ | visitor.Dispatch(*this); | |
| 483 | ✗ | } | |
| 484 | |||
| 485 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 486 | |||
| 487 | 113 | FSSpaceType::FSSpaceType(const Json::Value& root) : FSAssignment(root) {} | |
| 488 | |||
| 489 | 113 | void FSSpaceType::Accept(FSVisitor& visitor) const { | |
| 490 | 113 | visitor.Dispatch(*this); | |
| 491 | 113 | } | |
| 492 | |||
| 493 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 494 | |||
| 495 | 9 | FSConstructionSet::FSConstructionSet(const Json::Value& root) : FSAssignment(root) {} | |
| 496 | |||
| 497 | 9 | void FSConstructionSet::Accept(FSVisitor& visitor) const { | |
| 498 | 9 | visitor.Dispatch(*this); | |
| 499 | 9 | } | |
| 500 | |||
| 501 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 502 | |||
| 503 | 656 | FSSpace::FSSpace(const Json::Value& root, const FSModel& model, FSStory& story) | |
| 504 |
1/1✓ Branch 7 taken 656 times.
|
656 | : FSBase(root), m_below_floor_plenum_height(story.belowFloorPlenumHeight()) { |
| 505 | |||
| 506 |
4/4✓ Branch 1 taken 656 times.
✓ Branch 4 taken 656 times.
✓ Branch 7 taken 556 times.
✓ Branch 8 taken 100 times.
|
1968 | if (checkKeyAndType(root, "thermal_zone_id", Json::stringValue)) { |
| 507 |
4/4✓ Branch 1 taken 556 times.
✓ Branch 4 taken 556 times.
✓ Branch 7 taken 556 times.
✓ Branch 10 taken 556 times.
|
556 | m_thermalZone = model.thermalZone(root.get("thermal_zone_id", "").asString()); |
| 508 | } | ||
| 509 | |||
| 510 |
4/4✓ Branch 1 taken 656 times.
✓ Branch 4 taken 656 times.
✓ Branch 7 taken 34 times.
✓ Branch 8 taken 622 times.
|
1968 | if (checkKeyAndType(root, "building_unit_id", Json::stringValue)) { |
| 511 |
4/4✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
✓ Branch 7 taken 34 times.
✓ Branch 10 taken 34 times.
|
34 | m_buildingUnit = model.buildingUnit(root.get("building_unit_id", "").asString()); |
| 512 | } | ||
| 513 | |||
| 514 |
4/4✓ Branch 1 taken 656 times.
✓ Branch 4 taken 656 times.
✓ Branch 7 taken 618 times.
✓ Branch 8 taken 38 times.
|
1968 | if (checkKeyAndType(root, "space_type_id", Json::stringValue)) { |
| 515 |
4/4✓ Branch 1 taken 618 times.
✓ Branch 4 taken 618 times.
✓ Branch 7 taken 618 times.
✓ Branch 10 taken 618 times.
|
618 | m_spaceType = model.spaceType(root.get("space_type_id", "").asString()); |
| 516 | } | ||
| 517 | |||
| 518 |
4/4✓ Branch 1 taken 656 times.
✓ Branch 4 taken 656 times.
✓ Branch 7 taken 35 times.
✓ Branch 8 taken 621 times.
|
1968 | if (checkKeyAndType(root, "construction_set_id", Json::stringValue)) { |
| 519 |
4/4✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
✓ Branch 7 taken 35 times.
✓ Branch 10 taken 35 times.
|
35 | m_constructionSet = model.constructionSet(root.get("construction_set_id", "").asString()); |
| 520 | } | ||
| 521 | |||
| 522 | // Heights are optional, if not defined then the value is inherited from the story, if | ||
| 523 | // defined then the value overrides the value from the story | ||
| 524 | |||
| 525 |
1/1✓ Branch 1 taken 656 times.
|
656 | m_below_floor_plenum_height = story.belowFloorPlenumHeight(); |
| 526 |
4/4✓ Branch 1 taken 656 times.
✓ Branch 4 taken 656 times.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 655 times.
|
1968 | if (checkKeyAndType(root, "below_floor_plenum_height", Json::realValue)) { |
| 527 |
1/1✓ Branch 1 taken 1 time.
|
1 | double defaultValue = m_below_floor_plenum_height / model.lengthToMeters(); |
| 528 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | m_below_floor_plenum_height = root.get("below_floor_plenum_height", defaultValue).asDouble() * model.lengthToMeters(); |
| 529 | } | ||
| 530 | |||
| 531 |
1/1✓ Branch 1 taken 656 times.
|
656 | m_floor_to_ceiling_height = story.floorToCeilingHeight(); |
| 532 |
4/4✓ Branch 1 taken 656 times.
✓ Branch 4 taken 656 times.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 655 times.
|
1968 | if (checkKeyAndType(root, "floor_to_ceiling_height", Json::realValue)) { // Doing this skips null values for exmaple |
| 533 |
1/1✓ Branch 1 taken 1 time.
|
1 | double defaultValue = m_floor_to_ceiling_height / model.lengthToMeters(); |
| 534 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | m_floor_to_ceiling_height = root.get("floor_to_ceiling_height", defaultValue).asDouble() * model.lengthToMeters(); |
| 535 | } | ||
| 536 | |||
| 537 |
1/1✓ Branch 1 taken 656 times.
|
656 | m_above_ceiling_plenum_height = story.aboveCeilingPlenumHeight(); |
| 538 |
4/4✓ Branch 1 taken 656 times.
✓ Branch 4 taken 656 times.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 655 times.
|
1968 | if (checkKeyAndType(root, "above_ceiling_plenum_height", Json::realValue)) { |
| 539 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | double defaultValue = story.aboveCeilingPlenumHeight() / model.lengthToMeters(); |
| 540 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | m_above_ceiling_plenum_height = root.get("above_ceiling_plenum_height", defaultValue).asDouble() * model.lengthToMeters(); |
| 541 | } | ||
| 542 | |||
| 543 |
4/4✓ Branch 1 taken 656 times.
✓ Branch 4 taken 656 times.
✓ Branch 7 taken 656 times.
✓ Branch 10 taken 656 times.
|
656 | m_offset = root.get("floor_offset", 0).asDouble() * model.lengthToMeters(); |
| 544 |
3/3✓ Branch 1 taken 656 times.
✓ Branch 4 taken 656 times.
✓ Branch 7 taken 656 times.
|
656 | m_openToBelow = root.get("open_to_below", false).asBool(); |
| 545 |
4/4✓ Branch 1 taken 656 times.
✓ Branch 4 taken 656 times.
✓ Branch 7 taken 656 times.
✓ Branch 10 taken 656 times.
|
656 | m_multiplier = std::max(root.get("multiplier", story.multiplier()).asInt(), 1); |
| 546 | |||
| 547 | // Get the face. Note: a space must have a face for it to be added to the model | ||
| 548 |
3/4✓ Branch 1 taken 656 times.
✓ Branch 4 taken 656 times.
✓ Branch 7 taken 656 times.
✗ Branch 8 not taken.
|
1968 | if (checkKeyAndType(root, "face_id", Json::stringValue)) { |
| 549 |
3/3✓ Branch 1 taken 656 times.
✓ Branch 4 taken 656 times.
✓ Branch 7 taken 656 times.
|
656 | std::string face_id = root.get("face_id", "").asString(); |
| 550 |
2/2✓ Branch 1 taken 656 times.
✓ Branch 4 taken 656 times.
|
656 | m_face = story.geometry().face(face_id); |
| 551 | 656 | } | |
| 552 | |||
| 553 |
9/9✓ Branch 1 taken 656 times.
✓ Branch 4 taken 656 times.
✓ Branch 8 taken 656 times.
✓ Branch 11 taken 656 times.
✓ Branch 14 taken 11 times.
✓ Branch 17 taken 11 times.
✓ Branch 20 taken 667 times.
✓ Branch 22 taken 11 times.
✓ Branch 23 taken 656 times.
|
667 | for (const auto& daylightingControl : root.get("daylighting_controls", Json::arrayValue)) { |
| 554 |
1/1✓ Branch 1 taken 11 times.
|
11 | m_daylightingControls.emplace_back(daylightingControl, model, story); |
| 555 | 656 | } | |
| 556 | 656 | } | |
| 557 | |||
| 558 | 1226 | boost::optional<FSThermalZone> FSSpace::thermalZone() const { | |
| 559 | 1226 | return m_thermalZone; | |
| 560 | } | ||
| 561 | |||
| 562 | 699 | boost::optional<FSBuildingUnit> FSSpace::buildingUnit() const { | |
| 563 | 699 | return m_buildingUnit; | |
| 564 | } | ||
| 565 | |||
| 566 | 1271 | boost::optional<FSSpaceType> FSSpace::spaceType() const { | |
| 567 | 1271 | return m_spaceType; | |
| 568 | } | ||
| 569 | |||
| 570 | 700 | boost::optional<FSConstructionSet> FSSpace::constructionSet() const { | |
| 571 | 700 | return m_constructionSet; | |
| 572 | } | ||
| 573 | |||
| 574 | 1320 | boost::optional<FSFace> FSSpace::face() const { | |
| 575 | 1320 | return m_face; | |
| 576 | } | ||
| 577 | |||
| 578 | 562 | int FSSpace::multiplier() const { | |
| 579 | 562 | return m_multiplier; | |
| 580 | } | ||
| 581 | |||
| 582 | 1312 | double FSSpace::belowFloorPlenumHeight() const { | |
| 583 | 1312 | return m_below_floor_plenum_height; | |
| 584 | } | ||
| 585 | |||
| 586 | 1312 | double FSSpace::floorToCeilingHeight() const { | |
| 587 | 1312 | return m_floor_to_ceiling_height; | |
| 588 | } | ||
| 589 | |||
| 590 | 1312 | double FSSpace::aboveCeilingHeight() const { | |
| 591 | 1312 | return m_above_ceiling_plenum_height; | |
| 592 | } | ||
| 593 | |||
| 594 | 656 | double FSSpace::offset() const { | |
| 595 | 656 | return m_offset; | |
| 596 | } | ||
| 597 | |||
| 598 | 656 | bool FSSpace::openToBelow() const { | |
| 599 | 656 | return m_openToBelow; | |
| 600 | } | ||
| 601 | |||
| 602 | 664 | std::vector<FSDaylightingControl> FSSpace::daylightingControls() const { | |
| 603 | 664 | return m_daylightingControls; | |
| 604 | } | ||
| 605 | |||
| 606 | 656 | void FSSpace::Accept(FSVisitor& visitor) const { | |
| 607 | 656 | visitor.Dispatch(*this); | |
| 608 | 656 | } | |
| 609 | |||
| 610 | ✗ | void FSSpace::simplifyFace(const FSGeometry& geometry) { | |
| 611 | ✗ | Point3dVector faceVertices; | |
| 612 | ✗ | for (const auto& edgeRef : m_face->edgeRefs()) { | |
| 613 | ✗ | const FSVertex& vertex = edgeRef.getNextVertex(); | |
| 614 | ✗ | faceVertices.emplace_back(Point3d(vertex.x(), vertex.y(), 0)); | |
| 615 | ✗ | } | |
| 616 | |||
| 617 | // Simplify and keep inline vertices, the count should be the same | ||
| 618 | // but if the vertex order has changed then there were overlapping | ||
| 619 | // edges. If this is the case then a new face and new edges are created | ||
| 620 | ✗ | Point3dVector simplifiedVertices = simplify(faceVertices, false, 0.01); | |
| 621 | ✗ | if (!circularEqual(simplifiedVertices, faceVertices)) { | |
| 622 | |||
| 623 | // Now simplify and remove inline vertices giviong us a cleanpolygon to work with | ||
| 624 | ✗ | simplifiedVertices = simplify(faceVertices, true, 0.01); | |
| 625 | // If the number of vertices has changed then we will create new edges | ||
| 626 | // based on the simplified vertices | ||
| 627 | ✗ | if (simplifiedVertices.size() != faceVertices.size()) { | |
| 628 | ✗ | std::vector<FSEdgeReference> edgeRefs; | |
| 629 | // Create new edges for the face | ||
| 630 | ✗ | for (unsigned i = 0; i < simplifiedVertices.size(); i++) { | |
| 631 | ✗ | const Point3d& p1 = simplifiedVertices[i]; | |
| 632 | ✗ | const Point3d& p2 = simplifiedVertices[(i + 1) % simplifiedVertices.size()]; | |
| 633 | |||
| 634 | ✗ | auto v1 = geometry.vertex(p1); | |
| 635 | ✗ | auto v2 = geometry.vertex(p2); | |
| 636 | ✗ | if (v1.has_value() && v2.has_value()) { | |
| 637 | //boost::optional<FSEdge> edge = geometry.getEdge(*v1, *v2); | ||
| 638 | //if (edge == boost::none) | ||
| 639 | // edge = FSEdge (*v1, *v2); | ||
| 640 | //edgeRefs.emplace_back(FSEdgeReference(*edge, 1)); | ||
| 641 | ✗ | FSEdge edge(*v1, *v2); | |
| 642 | ✗ | edgeRefs.emplace_back(std::move(edge), 1); | |
| 643 | ✗ | } | |
| 644 | ✗ | } | |
| 645 | |||
| 646 | // Update the face | ||
| 647 | ✗ | m_face->setEdgeRefs(std::move(edgeRefs)); | |
| 648 | ✗ | } | |
| 649 | // Get a list of windows and doors that were associated with the old edges | ||
| 650 | // Remap these windows and doors to the new edges | ||
| 651 | } | ||
| 652 | ✗ | } | |
| 653 | |||
| 654 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 655 | |||
| 656 | ✗ | FSGeometry::FSGeometry(const Json::Value& root, const FSModel& model) { | |
| 657 | ✗ | load(root, model); | |
| 658 | ✗ | } | |
| 659 | |||
| 660 | 72 | void FSGeometry::load(const Json::Value& root, const FSModel& model) { | |
| 661 |
1/1✓ Branch 1 taken 72 times.
|
72 | FSGeometryBase::load(root); |
| 662 | |||
| 663 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
|
72 | const Json::Value& vertices = root.get("vertices", Json::arrayValue); |
| 664 |
7/7✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 2555 times.
✓ Branch 10 taken 2555 times.
✓ Branch 13 taken 2627 times.
✓ Branch 15 taken 2555 times.
✓ Branch 16 taken 72 times.
|
5182 | for (const auto& vertice : vertices) { |
| 665 |
1/1✓ Branch 1 taken 2555 times.
|
2555 | m_vertices.emplace_back(vertice, model); |
| 666 | } | ||
| 667 | |||
| 668 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
|
72 | const Json::Value& edges = root.get("edges", Json::arrayValue); |
| 669 |
7/7✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 3193 times.
✓ Branch 10 taken 3193 times.
✓ Branch 13 taken 3265 times.
✓ Branch 15 taken 3193 times.
✓ Branch 16 taken 72 times.
|
6458 | for (const auto& edge : edges) { |
| 670 |
1/1✓ Branch 1 taken 3193 times.
|
3193 | m_edges.emplace_back(edge, *this); |
| 671 | } | ||
| 672 | |||
| 673 |
2/2✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
|
72 | const Json::Value& faces = root.get("faces", Json::arrayValue); |
| 674 |
7/7✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 700 times.
✓ Branch 10 taken 700 times.
✓ Branch 13 taken 772 times.
✓ Branch 15 taken 700 times.
✓ Branch 16 taken 72 times.
|
1472 | for (const auto& face : faces) { |
| 675 |
1/1✓ Branch 1 taken 700 times.
|
700 | m_faces.emplace_back(face, *this); |
| 676 | } | ||
| 677 | 72 | } | |
| 678 | |||
| 679 | 6397 | boost::optional<FSVertex> FSGeometry::vertex(const std::string& id) const { | |
| 680 | |||
| 681 |
1/2✓ Branch 5 taken 197421 times.
✗ Branch 6 not taken.
|
197421 | for (const auto& vertex : m_vertices) { |
| 682 |
3/3✓ Branch 1 taken 197421 times.
✓ Branch 4 taken 6397 times.
✓ Branch 5 taken 191024 times.
|
197421 | if (vertex.id() == id) { |
| 683 |
1/1✓ Branch 1 taken 6397 times.
|
6397 | return vertex; |
| 684 | } | ||
| 685 | } | ||
| 686 | |||
| 687 | ✗ | return boost::none; | |
| 688 | } | ||
| 689 | |||
| 690 | ✗ | boost::optional<FSVertex> FSGeometry::vertex(const Point3d& point) const { | |
| 691 | ✗ | double tol = 0.01; | |
| 692 | ✗ | for (const auto& vertex : m_vertices) { | |
| 693 | ✗ | if (std::abs(vertex.x() - point.x()) < tol && std::abs(vertex.y() - point.y()) < tol) { | |
| 694 | ✗ | return vertex; | |
| 695 | } | ||
| 696 | } | ||
| 697 | |||
| 698 | ✗ | return boost::none; | |
| 699 | } | ||
| 700 | |||
| 701 | 5578 | boost::optional<FSEdge> FSGeometry::edge(const std::string& id) const { | |
| 702 | |||
| 703 |
1/2✓ Branch 5 taken 229656 times.
✗ Branch 6 not taken.
|
229656 | for (const auto& edge : m_edges) { |
| 704 |
3/3✓ Branch 1 taken 229656 times.
✓ Branch 4 taken 5578 times.
✓ Branch 5 taken 224078 times.
|
229656 | if (edge.id() == id) { |
| 705 |
1/1✓ Branch 1 taken 5578 times.
|
5578 | return edge; |
| 706 | } | ||
| 707 | } | ||
| 708 | |||
| 709 | ✗ | return boost::none; | |
| 710 | } | ||
| 711 | |||
| 712 | ✗ | boost::optional<FSEdge> FSGeometry::edge(const FSVertex& v1, const FSVertex& v2) const { | |
| 713 | ✗ | for (const auto& edge : m_edges) { | |
| 714 | ✗ | if ((edge.firstVertex().id() == v1.id() && edge.secondVertex().id() == v2.id()) | |
| 715 | ✗ | || (edge.firstVertex().id() == v2.id() && edge.secondVertex().id() == v1.id())) { | |
| 716 | ✗ | return edge; | |
| 717 | } | ||
| 718 | } | ||
| 719 | |||
| 720 | ✗ | return boost::none; | |
| 721 | } | ||
| 722 | |||
| 723 | 698 | boost::optional<FSFace> FSGeometry::face(const std::string& id) const { | |
| 724 | |||
| 725 |
1/2✓ Branch 5 taken 6543 times.
✗ Branch 6 not taken.
|
6543 | for (const auto& face : m_faces) { |
| 726 |
3/3✓ Branch 1 taken 6543 times.
✓ Branch 4 taken 698 times.
✓ Branch 5 taken 5845 times.
|
6543 | if (face.id() == id) { |
| 727 |
1/1✓ Branch 1 taken 698 times.
|
698 | return face; |
| 728 | } | ||
| 729 | } | ||
| 730 | |||
| 731 | ✗ | return boost::none; | |
| 732 | } | ||
| 733 | |||
| 734 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 735 | |||
| 736 | ✗ | FSGeometryBase::FSGeometryBase(const Json::Value& root) { | |
| 737 | ✗ | load(root); | |
| 738 | ✗ | } | |
| 739 | |||
| 740 | 6520 | void FSGeometryBase::load(const Json::Value& root) { | |
| 741 |
3/3✓ Branch 1 taken 6520 times.
✓ Branch 4 taken 6520 times.
✓ Branch 7 taken 6520 times.
|
6520 | m_id = root.get("id", m_id).asString(); |
| 742 | 6520 | } | |
| 743 | |||
| 744 | 433620 | const std::string& FSGeometryBase::id() const { | |
| 745 | 433620 | return m_id; | |
| 746 | } | ||
| 747 | |||
| 748 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 749 | |||
| 750 | 2555 | FSVertex::FSVertex(const Json::Value& root, const FSModel& model) { | |
| 751 |
1/1✓ Branch 1 taken 2555 times.
|
2555 | load(root, model); |
| 752 | 2555 | } | |
| 753 | |||
| 754 | 2555 | void FSVertex::load(const Json::Value& root, const FSModel& model) { | |
| 755 | |||
| 756 | 2555 | FSGeometryBase::load(root); | |
| 757 |
4/4✓ Branch 1 taken 2555 times.
✓ Branch 4 taken 2555 times.
✓ Branch 7 taken 2555 times.
✓ Branch 10 taken 2555 times.
|
2555 | m_x = root.get("x", 0).asDouble() * model.lengthToMeters(); |
| 758 |
4/4✓ Branch 1 taken 2555 times.
✓ Branch 4 taken 2555 times.
✓ Branch 7 taken 2555 times.
✓ Branch 10 taken 2555 times.
|
2555 | m_y = root.get("y", 0).asDouble() * model.lengthToMeters(); |
| 759 | 2555 | } | |
| 760 | |||
| 761 | 201549 | double FSVertex::x() const { | |
| 762 | 201549 | return m_x; | |
| 763 | } | ||
| 764 | |||
| 765 | 201549 | double FSVertex::y() const { | |
| 766 | 201549 | return m_y; | |
| 767 | } | ||
| 768 | |||
| 769 | ✗ | void FSVertex::setX(double x) { | |
| 770 | ✗ | m_x = x; | |
| 771 | ✗ | } | |
| 772 | |||
| 773 | ✗ | void FSVertex::setY(double y) { | |
| 774 | ✗ | m_y = y; | |
| 775 | ✗ | } | |
| 776 | |||
| 777 | ✗ | void FSVertex::setXY(double x, double y) { | |
| 778 | ✗ | m_x = x; | |
| 779 | ✗ | m_y = y; | |
| 780 | ✗ | } | |
| 781 | |||
| 782 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 783 | |||
| 784 | 3193 | FSEdge::FSEdge(const Json::Value& root, const FSGeometry& geometry) { | |
| 785 |
1/1✓ Branch 1 taken 3193 times.
|
3193 | load(root, geometry); |
| 786 | 3193 | } | |
| 787 | |||
| 788 | // cppcheck-suppress constParameterReference | ||
| 789 | ✗ | FSEdge::FSEdge(FSVertex& v1, FSVertex& v2) { | |
| 790 | ✗ | m_vertices.push_back(v1); | |
| 791 | ✗ | m_vertices.push_back(v2); | |
| 792 | ✗ | } | |
| 793 | |||
| 794 | 3193 | void FSEdge::load(const Json::Value& root, const FSGeometry& geometry) { | |
| 795 | |||
| 796 |
1/1✓ Branch 1 taken 3193 times.
|
3193 | FSGeometryBase::load(root); |
| 797 |
2/2✓ Branch 1 taken 3193 times.
✓ Branch 4 taken 3193 times.
|
3193 | const Json::Value& vertexIds = root.get("vertex_ids", Json::arrayValue); |
| 798 |
6/6✓ Branch 1 taken 3193 times.
✓ Branch 4 taken 3193 times.
✓ Branch 7 taken 6386 times.
✓ Branch 10 taken 9579 times.
✓ Branch 12 taken 6386 times.
✓ Branch 13 taken 3193 times.
|
9579 | for (const auto& vertexId : vertexIds) { |
| 799 |
5/5✓ Branch 1 taken 6386 times.
✓ Branch 4 taken 6386 times.
✓ Branch 7 taken 6386 times.
✓ Branch 10 taken 6386 times.
✓ Branch 15 taken 6386 times.
|
6386 | m_vertices.push_back(geometry.vertex(vertexId.asString()).value()); |
| 800 | } | ||
| 801 | 3193 | } | |
| 802 | |||
| 803 | ✗ | std::vector<FSVertex> FSEdge::getVertices() const { | |
| 804 | ✗ | return m_vertices; | |
| 805 | } | ||
| 806 | |||
| 807 | 4502 | const FSVertex& FSEdge::firstVertex() const { | |
| 808 | 4502 | return m_vertices[0]; | |
| 809 | } | ||
| 810 | |||
| 811 | 2580 | const FSVertex& FSEdge::secondVertex() const { | |
| 812 | 2580 | return m_vertices[1]; | |
| 813 | } | ||
| 814 | |||
| 815 | 868 | Vector3d FSEdge::edgeVector() const { | |
| 816 |
3/3✓ Branch 2 taken 868 times.
✓ Branch 6 taken 868 times.
✓ Branch 9 taken 868 times.
|
868 | Point3d pt1(m_vertices[0].x(), m_vertices[0].y(), 0); |
| 817 |
3/3✓ Branch 2 taken 868 times.
✓ Branch 6 taken 868 times.
✓ Branch 9 taken 868 times.
|
868 | Point3d pt2(m_vertices[1].x(), m_vertices[1].y(), 0); |
| 818 |
1/1✓ Branch 1 taken 868 times.
|
1736 | return (pt2 - pt1); |
| 819 | 868 | } | |
| 820 | |||
| 821 | 96040 | Point3d FSEdge::vertex(double alpha) const { | |
| 822 | 96040 | double x = (1.0 - alpha) * m_vertices[0].x() + alpha * m_vertices[1].x(); | |
| 823 | 96040 | double y = (1.0 - alpha) * m_vertices[0].y() + alpha * m_vertices[1].y(); | |
| 824 | 96040 | return {x, y, 0}; | |
| 825 | } | ||
| 826 | |||
| 827 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 828 | |||
| 829 | 700 | FSFace::FSFace(const Json::Value& root, const FSGeometry& geometry) { | |
| 830 |
1/1✓ Branch 1 taken 700 times.
|
700 | load(root, geometry); |
| 831 | 700 | } | |
| 832 | |||
| 833 | 700 | void FSFace::load(const Json::Value& root, const FSGeometry& geometry) { | |
| 834 | |||
| 835 |
1/1✓ Branch 1 taken 700 times.
|
700 | FSGeometryBase::load(root); |
| 836 |
2/2✓ Branch 1 taken 700 times.
✓ Branch 4 taken 700 times.
|
700 | const Json::Value& edgeIds = root.get("edge_ids", Json::arrayValue); |
| 837 |
2/2✓ Branch 1 taken 700 times.
✓ Branch 4 taken 700 times.
|
700 | const Json::Value& edgeOrders = root.get("edge_order", Json::arrayValue); |
| 838 |
3/4✓ Branch 1 taken 700 times.
✓ Branch 4 taken 700 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 700 times.
|
700 | if (edgeIds.size() != edgeOrders.size()) { |
| 839 | ✗ | throw openstudio::Exception(std::string("The number or edge orders does not equal the number of edge ids")); | |
| 840 | } | ||
| 841 | |||
| 842 |
3/3✓ Branch 1 taken 5454 times.
✓ Branch 3 taken 4754 times.
✓ Branch 4 taken 700 times.
|
5454 | for (unsigned int i = 0; i < edgeIds.size(); i++) { |
| 843 |
5/5✓ Branch 1 taken 4754 times.
✓ Branch 4 taken 4754 times.
✓ Branch 7 taken 4754 times.
✓ Branch 10 taken 4754 times.
✓ Branch 13 taken 4754 times.
|
4754 | boost::optional<FSEdge> edge = geometry.edge(edgeIds[i].asString()).value(); |
| 844 |
6/6✓ Branch 1 taken 4754 times.
✓ Branch 4 taken 4754 times.
✓ Branch 7 taken 4754 times.
✓ Branch 10 taken 4754 times.
✓ Branch 13 taken 4754 times.
✓ Branch 16 taken 4754 times.
|
4754 | m_edgeRefs.emplace_back(FSEdgeReference(*edge, edgeOrders[i].asInt())); |
| 845 | 4754 | } | |
| 846 | 700 | } | |
| 847 | |||
| 848 | 766 | std::vector<FSEdgeReference> FSFace::edgeRefs() const { | |
| 849 | 766 | return m_edgeRefs; | |
| 850 | } | ||
| 851 | |||
| 852 | ✗ | void FSFace::setEdgeRefs(std::vector<FSEdgeReference> edgeRefs) { | |
| 853 | ✗ | m_edgeRefs = std::move(edgeRefs); | |
| 854 | ✗ | } | |
| 855 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 856 | |||
| 857 | 4754 | FSEdgeReference::FSEdgeReference(FSEdge edge, int edgeOrder) : m_edge(std::move(edge)), m_edgeOrder(edgeOrder) {} | |
| 858 | |||
| 859 | 608 | const FSEdge& FSEdgeReference::edge() const { | |
| 860 | 608 | return m_edge; | |
| 861 | } | ||
| 862 | |||
| 863 | 304 | int FSEdgeReference::edgeOrder() const { | |
| 864 | 304 | return m_edgeOrder; | |
| 865 | } | ||
| 866 | |||
| 867 | 4822 | const FSVertex& FSEdgeReference::getNextVertex() const { | |
| 868 |
2/2✓ Branch 0 taken 3372 times.
✓ Branch 1 taken 1450 times.
|
4822 | if (m_edgeOrder == 1) { |
| 869 | 3372 | return m_edge.firstVertex(); | |
| 870 | } else { | ||
| 871 | 1450 | return m_edge.secondVertex(); | |
| 872 | } | ||
| 873 | } | ||
| 874 | |||
| 875 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 876 | |||
| 877 | 824 | FSFiller::FSFiller(const Json::Value& root, const FSStory& story) : FSBase(root) { | |
| 878 | |||
| 879 | // Alpha can be a single value or a list | ||
| 880 |
8/9✓ Branch 1 taken 824 times.
✓ Branch 3 taken 824 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 824 times.
✓ Branch 9 taken 824 times.
✓ Branch 11 taken 823 times.
✓ Branch 12 taken 1 time.
✓ Branch 13 taken 823 times.
✓ Branch 14 taken 1 time.
|
824 | if (root.isMember("alpha") && root["alpha"].isConvertibleTo(Json::realValue)) { |
| 881 |
4/4✓ Branch 1 taken 823 times.
✓ Branch 4 taken 823 times.
✓ Branch 7 taken 823 times.
✓ Branch 10 taken 823 times.
|
823 | m_alphas.push_back(root.get("alpha", 0.5).asDouble()); |
| 882 | } else { | ||
| 883 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | Json::Value alphas = root.get("alpha", Json::arrayValue); |
| 884 |
6/6✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 17 times.
✓ Branch 10 taken 18 times.
✓ Branch 12 taken 17 times.
✓ Branch 13 taken 1 time.
|
18 | for (const auto& alpha : alphas) { |
| 885 |
3/3✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
✓ Branch 7 taken 17 times.
|
17 | m_alphas.push_back(alpha.asDouble()); |
| 886 | } | ||
| 887 | 1 | } | |
| 888 | |||
| 889 |
3/4✓ Branch 1 taken 824 times.
✓ Branch 4 taken 824 times.
✓ Branch 7 taken 824 times.
✗ Branch 8 not taken.
|
2472 | if (checkKeyAndType(root, "edge_id", Json::stringValue)) { |
| 890 |
3/3✓ Branch 1 taken 824 times.
✓ Branch 4 taken 824 times.
✓ Branch 7 taken 824 times.
|
824 | std::string edge_id = root.get("edge_id", "").asString(); |
| 891 |
4/4✓ Branch 1 taken 824 times.
✓ Branch 4 taken 824 times.
✓ Branch 7 taken 824 times.
✓ Branch 10 taken 824 times.
|
824 | m_edge = story.geometry().edge(edge_id).value(); |
| 892 | |||
| 893 | // TODO: If edges knew about faces then we could use the edge to get the face | ||
| 894 | // and that would lead us to the space and that would mean we could associate | ||
| 895 | // a window with a space (if we need to). Either wa we need to be able to use | ||
| 896 | // the edge to dind the wall which is the parent surface for the sub-surface | ||
| 897 | 824 | } | |
| 898 | 824 | } | |
| 899 | |||
| 900 | 192904 | boost::optional<FSEdge> FSFiller::edge() const { | |
| 901 | 192904 | return m_edge; | |
| 902 | } | ||
| 903 | |||
| 904 | ✗ | boost::optional<FSSpace> FSFiller::space() const { | |
| 905 | ✗ | return m_space; | |
| 906 | } | ||
| 907 | |||
| 908 | 96866 | std::vector<double> FSFiller::alphas() const { | |
| 909 | 96866 | return m_alphas; | |
| 910 | } | ||
| 911 | |||
| 912 | 96040 | Point3d FSFiller::centerVertex(double alpha) const { | |
| 913 | 96040 | return m_edge->vertex(alpha); | |
| 914 | } | ||
| 915 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 916 | |||
| 917 | 813 | FSWindow::FSWindow(const Json::Value& root, const FSModel& model, FSStory& story) : FSFiller(root, story) { | |
| 918 | |||
| 919 |
3/4✓ Branch 1 taken 813 times.
✓ Branch 4 taken 813 times.
✓ Branch 7 taken 813 times.
✗ Branch 8 not taken.
|
2439 | if (checkKeyAndType(root, "window_definition_id", Json::stringValue)) { |
| 920 |
3/3✓ Branch 1 taken 813 times.
✓ Branch 4 taken 813 times.
✓ Branch 7 taken 813 times.
|
813 | std::string windowDefinitionId = root.get("window_definition_id", "").asString(); |
| 921 |
1/1✓ Branch 1 taken 813 times.
|
813 | m_windowDefinition = model.windowDefinition(windowDefinitionId); |
| 922 | // If the window definition is window to wall ratios then the windows should be centered | ||
| 923 | // on the wall surface so make sure the alpha is 0.5 and then it will be so | ||
| 924 |
1/2✓ Branch 1 taken 813 times.
✗ Branch 2 not taken.
|
813 | if (m_windowDefinition.has_value()) { |
| 925 |
5/5✓ Branch 1 taken 813 times.
✓ Branch 4 taken 813 times.
✓ Branch 7 taken 813 times.
✓ Branch 10 taken 42 times.
✓ Branch 11 taken 771 times.
|
813 | if (m_windowDefinition->windowDefinitionMode() == "Window to Wall Ratio") { |
| 926 | 42 | m_alphas.clear(); | |
| 927 |
1/1✓ Branch 1 taken 42 times.
|
42 | m_alphas.push_back(0.5); |
| 928 | } | ||
| 929 | } | ||
| 930 | 813 | } | |
| 931 | 813 | } | |
| 932 | |||
| 933 | 814 | boost::optional<FSWindowDefinition> FSWindow::windowDefinition() const { | |
| 934 | 814 | return m_windowDefinition; | |
| 935 | } | ||
| 936 | |||
| 937 | ✗ | void FSWindow::Accept(FSVisitor& visitor) const { | |
| 938 | ✗ | visitor.Dispatch(*this); | |
| 939 | ✗ | } | |
| 940 | |||
| 941 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 942 | |||
| 943 | 11 | FSDoor::FSDoor(const Json::Value& root, const FSModel& model, FSStory& story) : FSFiller(root, story) { | |
| 944 | |||
| 945 |
3/4✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✗ Branch 8 not taken.
|
33 | if (checkKeyAndType(root, "door_definition_id", Json::stringValue)) { |
| 946 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | std::string doorDefinitionId = root.get("door_definition_id", "").asString(); |
| 947 |
1/1✓ Branch 1 taken 11 times.
|
11 | m_doorDefinition = model.doorDefinition(doorDefinitionId); |
| 948 | 11 | } | |
| 949 | 11 | } | |
| 950 | |||
| 951 | ✗ | void FSDoor::Accept(FSVisitor& visitor) const { | |
| 952 | ✗ | visitor.Dispatch(*this); | |
| 953 | ✗ | } | |
| 954 | |||
| 955 | 12 | boost::optional<FSDoorDefinition> FSDoor::doorDefinition() const { | |
| 956 | 12 | return m_doorDefinition; | |
| 957 | } | ||
| 958 | |||
| 959 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 960 | |||
| 961 | 63 | FSShading::FSShading(const Json::Value& root, const FSModel& model, const FSStory& story) : FSBase(root) { | |
| 962 | |||
| 963 | // Get the face. Note: a shading must have a face for it to be added to the model | ||
| 964 |
4/4✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 42 times.
✓ Branch 8 taken 21 times.
|
189 | if (checkKeyAndType(root, "face_id", Json::stringValue)) { |
| 965 |
3/3✓ Branch 1 taken 42 times.
✓ Branch 4 taken 42 times.
✓ Branch 7 taken 42 times.
|
42 | std::string face_id = root.get("face_id", "").asString(); |
| 966 |
2/2✓ Branch 1 taken 42 times.
✓ Branch 4 taken 42 times.
|
42 | m_face = story.geometry().face(face_id); |
| 967 | 42 | } | |
| 968 | |||
| 969 | // Heights are optional, if not defined then the value is inherited from the story, if | ||
| 970 | // defined then the value overrides the value from the story | ||
| 971 | |||
| 972 |
1/1✓ Branch 1 taken 63 times.
|
63 | m_below_floor_plenum_height = story.belowFloorPlenumHeight(); |
| 973 |
4/4✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 62 times.
|
189 | if (checkKeyAndType(root, "below_floor_plenum_height", Json::realValue)) { |
| 974 |
1/1✓ Branch 1 taken 1 time.
|
1 | double defaultValue = m_below_floor_plenum_height / model.lengthToMeters(); |
| 975 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | m_below_floor_plenum_height = root.get("below_floor_plenum_height", defaultValue).asDouble() * model.lengthToMeters(); |
| 976 | } | ||
| 977 | |||
| 978 |
1/1✓ Branch 1 taken 63 times.
|
63 | m_floor_to_ceiling_height = story.floorToCeilingHeight(); |
| 979 |
4/4✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 36 times.
✓ Branch 8 taken 27 times.
|
189 | if (checkKeyAndType(root, "floor_to_ceiling_height", Json::realValue)) { // Doing this skips null values for exmaple |
| 980 |
1/1✓ Branch 1 taken 36 times.
|
36 | double defaultValue = m_floor_to_ceiling_height / model.lengthToMeters(); |
| 981 |
4/4✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 7 taken 36 times.
✓ Branch 10 taken 36 times.
|
36 | m_floor_to_ceiling_height = root.get("floor_to_ceiling_height", defaultValue).asDouble() * model.lengthToMeters(); |
| 982 | } | ||
| 983 | |||
| 984 |
1/1✓ Branch 1 taken 63 times.
|
63 | m_above_ceiling_plenum_height = story.aboveCeilingPlenumHeight(); |
| 985 |
4/4✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 61 times.
|
189 | if (checkKeyAndType(root, "above_ceiling_plenum_height", Json::realValue)) { |
| 986 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | double defaultValue = story.aboveCeilingPlenumHeight() / model.lengthToMeters(); |
| 987 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | m_above_ceiling_plenum_height = root.get("above_ceiling_plenum_height", defaultValue).asDouble() * model.lengthToMeters(); |
| 988 | } | ||
| 989 | 63 | } | |
| 990 | |||
| 991 | 114 | boost::optional<FSFace> FSShading::face() const { | |
| 992 | 114 | return m_face; | |
| 993 | } | ||
| 994 | |||
| 995 | 84 | double FSShading::belowFloorPlenumHeight() const { | |
| 996 | 84 | return m_below_floor_plenum_height; | |
| 997 | } | ||
| 998 | |||
| 999 | 84 | double FSShading::floorToCeilingHeight() const { | |
| 1000 | 84 | return m_floor_to_ceiling_height; | |
| 1001 | } | ||
| 1002 | |||
| 1003 | 84 | double FSShading::aboveCeilingPlenumHeight() const { | |
| 1004 | 84 | return m_above_ceiling_plenum_height; | |
| 1005 | } | ||
| 1006 | |||
| 1007 | 42 | void FSShading::Accept(FSVisitor& visitor) const { | |
| 1008 | 42 | visitor.Dispatch(*this); | |
| 1009 | 42 | } | |
| 1010 | |||
| 1011 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 1012 | |||
| 1013 | 11 | FSDaylightingControl::FSDaylightingControl(const Json::Value& root, const FSModel& model, const FSStory& story) : FSBase(root) { | |
| 1014 | |||
| 1015 |
3/4✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✗ Branch 8 not taken.
|
33 | if (checkKeyAndType(root, "vertex_id", Json::stringValue)) { |
| 1016 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | std::string vertex_id = root.get("vertex_id", "").asString(); |
| 1017 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | m_vertex = story.geometry().vertex(vertex_id); |
| 1018 | 11 | } | |
| 1019 | |||
| 1020 |
3/4✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✗ Branch 8 not taken.
|
33 | if (checkKeyAndType(root, "daylighting_control_definition_id", Json::stringValue)) { |
| 1021 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | std::string control_id = root.get("daylighting_control_definition_id", "").asString(); |
| 1022 |
1/1✓ Branch 1 taken 11 times.
|
11 | m_definition = model.daylightingControlDefinition(control_id); |
| 1023 | 11 | } | |
| 1024 | 11 | } | |
| 1025 | |||
| 1026 | ✗ | boost::optional<FSVertex> FSDaylightingControl::vertex() const { | |
| 1027 | ✗ | return m_vertex; | |
| 1028 | } | ||
| 1029 | |||
| 1030 | 11 | Point3d FSDaylightingControl::point() const { | |
| 1031 |
3/6✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
|
11 | if (m_vertex.has_value() && m_definition.has_value()) { |
| 1032 | 11 | return {m_vertex->x(), m_vertex->y(), m_definition->height()}; | |
| 1033 | } | ||
| 1034 | ✗ | return {0.0, 0.0, 0.0}; | |
| 1035 | } | ||
| 1036 | |||
| 1037 | 11 | boost::optional<FSDaylightingControlDefinition> FSDaylightingControl::definition() const { | |
| 1038 | 11 | return m_definition; | |
| 1039 | } | ||
| 1040 | |||
| 1041 | 11 | void FSDaylightingControl::Accept(FSVisitor& visitor) const { | |
| 1042 | 11 | visitor.Dispatch(*this); | |
| 1043 | 11 | } | |
| 1044 | |||
| 1045 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 1046 | |||
| 1047 | 3 | FSDaylightingControlDefinition::FSDaylightingControlDefinition(const Json::Value& root, const FSModel& model) : FSBase(root) { | |
| 1048 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
3 | m_illuminanceSetpoint = root.get("illuminance_Setpoint", 300).asDouble(); |
| 1049 |
4/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
|
3 | m_height = root.get("height", 0).asDouble() * model.lengthToMeters(); |
| 1050 | 3 | } | |
| 1051 | |||
| 1052 | 11 | double FSDaylightingControlDefinition::illuminanceSetpoint() const { | |
| 1053 | 11 | return m_illuminanceSetpoint; | |
| 1054 | } | ||
| 1055 | |||
| 1056 | 11 | double FSDaylightingControlDefinition::height() const { | |
| 1057 | 11 | return m_height; | |
| 1058 | } | ||
| 1059 | |||
| 1060 | ✗ | void FSDaylightingControlDefinition::Accept(FSVisitor& visitor) const { | |
| 1061 | ✗ | visitor.Dispatch(*this); | |
| 1062 | ✗ | } | |
| 1063 | |||
| 1064 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 1065 | |||
| 1066 | 758 | FSWindowDefinition::FSWindowDefinition(const Json::Value& root, const FSModel& model) : FSBase(root) { | |
| 1067 | |||
| 1068 | // Property can be window_definition_mode or window_definition_type | ||
| 1069 |
4/4✓ Branch 1 taken 758 times.
✓ Branch 4 taken 758 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 752 times.
|
2274 | if (checkKeyAndType(root, "window_definition_type", Json::stringValue)) { |
| 1070 |
3/3✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
|
6 | m_windowDefinitionMode = root.get("window_definition_type", "Single Window").asString(); |
| 1071 | } else { | ||
| 1072 |
2/2✓ Branch 1 taken 752 times.
✓ Branch 4 taken 752 times.
|
1504 | assertKeyAndType(root, "window_definition_mode", Json::stringValue); |
| 1073 |
3/3✓ Branch 1 taken 752 times.
✓ Branch 4 taken 752 times.
✓ Branch 7 taken 752 times.
|
752 | m_windowDefinitionMode = root.get("window_definition_mode", "Single Window").asString(); |
| 1074 | } | ||
| 1075 |
3/3✓ Branch 1 taken 758 times.
✓ Branch 4 taken 758 times.
✓ Branch 7 taken 758 times.
|
758 | m_windowType = root.get("window_type", "Fixed").asString(); |
| 1076 |
6/6✓ Branch 1 taken 758 times.
✓ Branch 4 taken 758 times.
✓ Branch 7 taken 758 times.
✓ Branch 10 taken 758 times.
✓ Branch 15 taken 757 times.
✓ Branch 16 taken 1 time.
|
758 | if (root.get("window_type", "Fixed").asString() == "Fixed") { |
| 1077 |
1/1✓ Branch 1 taken 757 times.
|
757 | m_windowType = "FixedWindow"; |
| 1078 |
5/6✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 15 taken 1 time.
✗ Branch 16 not taken.
|
1 | } else if (root.get("window_type", "Fixed").asString() == "Operable") { |
| 1079 |
1/1✓ Branch 1 taken 1 time.
|
1 | m_windowType = "OperableWindow"; |
| 1080 | } | ||
| 1081 |
3/3✓ Branch 1 taken 758 times.
✓ Branch 4 taken 758 times.
✓ Branch 7 taken 758 times.
|
758 | m_wwr = root.get("wwr", 0.5).asDouble(); |
| 1082 |
4/4✓ Branch 1 taken 758 times.
✓ Branch 4 taken 758 times.
✓ Branch 7 taken 758 times.
✓ Branch 10 taken 758 times.
|
758 | m_sillHeight = root.get("sill_height", 0).asDouble() * model.lengthToMeters(); |
| 1083 |
4/4✓ Branch 1 taken 758 times.
✓ Branch 4 taken 758 times.
✓ Branch 7 taken 758 times.
✓ Branch 10 taken 758 times.
|
758 | m_windowSpacing = root.get("window_spacing", 0).asDouble() * model.lengthToMeters(); |
| 1084 |
4/4✓ Branch 1 taken 758 times.
✓ Branch 4 taken 758 times.
✓ Branch 7 taken 758 times.
✓ Branch 10 taken 758 times.
|
758 | m_height = root.get("height", 0).asDouble() * model.lengthToMeters(); |
| 1085 |
4/4✓ Branch 1 taken 758 times.
✓ Branch 4 taken 758 times.
✓ Branch 7 taken 758 times.
✓ Branch 10 taken 758 times.
|
758 | m_width = root.get("width", 0).asDouble() * model.lengthToMeters(); |
| 1086 |
3/3✓ Branch 1 taken 758 times.
✓ Branch 4 taken 758 times.
✓ Branch 7 taken 758 times.
|
758 | m_overhangProjectionFactor = root.get("overhang_projection_factor", 0).asDouble(); |
| 1087 |
3/3✓ Branch 1 taken 758 times.
✓ Branch 4 taken 758 times.
✓ Branch 7 taken 758 times.
|
758 | m_finProjectionFactor = root.get("fin_projection_factor", 0).asDouble(); |
| 1088 | 758 | } | |
| 1089 | |||
| 1090 | 1712 | std::string FSWindowDefinition::windowDefinitionMode() const { | |
| 1091 | 1712 | return m_windowDefinitionMode; | |
| 1092 | } | ||
| 1093 | |||
| 1094 | 42 | double FSWindowDefinition::wwr() const { | |
| 1095 | 42 | return m_wwr; | |
| 1096 | } | ||
| 1097 | |||
| 1098 | 814 | double FSWindowDefinition::sillHeight() const { | |
| 1099 | 814 | return m_sillHeight; | |
| 1100 | } | ||
| 1101 | |||
| 1102 | ✗ | double FSWindowDefinition::windowSpacing() const { | |
| 1103 | ✗ | return m_windowSpacing; | |
| 1104 | } | ||
| 1105 | |||
| 1106 | 772 | double FSWindowDefinition::height() const { | |
| 1107 | 772 | return m_height; | |
| 1108 | } | ||
| 1109 | |||
| 1110 | 772 | double FSWindowDefinition::width() const { | |
| 1111 | 772 | return m_width; | |
| 1112 | } | ||
| 1113 | |||
| 1114 | 830 | std::string FSWindowDefinition::windowType() const { | |
| 1115 | 830 | return m_windowType; | |
| 1116 | } | ||
| 1117 | |||
| 1118 | 867 | double FSWindowDefinition::overhangProjectionFactor() const { | |
| 1119 | 867 | return m_overhangProjectionFactor; | |
| 1120 | } | ||
| 1121 | |||
| 1122 | 830 | double FSWindowDefinition::finProjectionFactor() const { | |
| 1123 | 830 | return m_finProjectionFactor; | |
| 1124 | } | ||
| 1125 | |||
| 1126 | ✗ | void FSWindowDefinition::Accept(FSVisitor& visitor) const { | |
| 1127 | ✗ | visitor.Dispatch(*this); | |
| 1128 | ✗ | } | |
| 1129 | |||
| 1130 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 1131 | |||
| 1132 | 5 | FSDoorDefinition::FSDoorDefinition(const Json::Value& root, const FSModel& model) : FSBase(root) { | |
| 1133 |
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 | m_height = root.get("height", 2 / model.lengthToMeters()).asDouble() * model.lengthToMeters(); |
| 1134 |
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 | m_width = root.get("width", 1 / model.lengthToMeters()).asDouble() * model.lengthToMeters(); |
| 1135 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | m_doorType = root.get("door_type", "Door").asString(); |
| 1136 | 5 | } | |
| 1137 | |||
| 1138 | 12 | double FSDoorDefinition::height() const { | |
| 1139 | 12 | return m_height; | |
| 1140 | } | ||
| 1141 | |||
| 1142 | 12 | double FSDoorDefinition::width() const { | |
| 1143 | 12 | return m_width; | |
| 1144 | } | ||
| 1145 | |||
| 1146 | 12 | const std::string& FSDoorDefinition::doorType() const { | |
| 1147 | 12 | return m_doorType; | |
| 1148 | } | ||
| 1149 | |||
| 1150 | ✗ | void FSDoorDefinition::Accept(FSVisitor& visitor) const { | |
| 1151 | ✗ | visitor.Dispatch(*this); | |
| 1152 | ✗ | } | |
| 1153 | |||
| 1154 | /////////////////////////////////////////////////////////////////////////////////// | ||
| 1155 | |||
| 1156 | } // namespace openstudio | ||
| 1157 |