src/gltf/GltfMetaData.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 "GltfMetaData.hpp" | ||
| 7 | |||
| 8 | #include "../model/Model.hpp" | ||
| 9 | |||
| 10 | #include "../model/Building.hpp" | ||
| 11 | #include "../model/Building_Impl.hpp" | ||
| 12 | |||
| 13 | #include "../model/PlanarSurface.hpp" | ||
| 14 | #include "../model/PlanarSurfaceGroup.hpp" | ||
| 15 | #include "../model/BuildingStory.hpp" | ||
| 16 | #include "../model/BuildingStory_Impl.hpp" | ||
| 17 | #include "../model/BuildingUnit.hpp" | ||
| 18 | #include "../model/BuildingUnit_Impl.hpp" | ||
| 19 | #include "../model/ThermalZone.hpp" | ||
| 20 | #include "../model/ThermalZone_Impl.hpp" | ||
| 21 | #include "../model/AirLoopHVAC.hpp" | ||
| 22 | #include "../model/AirLoopHVAC_Impl.hpp" | ||
| 23 | #include "../model/SpaceType.hpp" | ||
| 24 | #include "../model/SpaceType_Impl.hpp" | ||
| 25 | #include "../model/DefaultConstructionSet.hpp" | ||
| 26 | #include "../model/DefaultConstructionSet_Impl.hpp" | ||
| 27 | #include "../model/Space.hpp" | ||
| 28 | #include "../model/Space_Impl.hpp" | ||
| 29 | |||
| 30 | #include <OpenStudio.hxx> | ||
| 31 | |||
| 32 | #include <tiny_gltf.h> | ||
| 33 | |||
| 34 | #include <map> | ||
| 35 | #include <string> | ||
| 36 | |||
| 37 | namespace openstudio { | ||
| 38 | namespace gltf { | ||
| 39 | |||
| 40 |
1/1✓ Branch 2 taken 27 times.
|
27 | GltfMetaData::GltfMetaData() = default; |
| 41 | |||
| 42 |
1/1✓ Branch 2 taken 21 times.
|
21 | GltfMetaData::GltfMetaData(const model::Model& model) { |
| 43 | |||
| 44 | // Generator | ||
| 45 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
42 | setGenerator("OpenStudio"); |
| 46 | // type | ?? | ||
| 47 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | setType("Object"); |
| 48 | // Version | ||
| 49 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | setVersion(openStudioVersion()); |
| 50 | // North Axis | ||
| 51 |
1/1✓ Branch 1 taken 21 times.
|
21 | setNorthAxis(model); |
| 52 | |||
| 53 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | m_glTFBoundingBox = GltfBoundingBox(model.getModelObjects<model::PlanarSurfaceGroup>()); |
| 54 | |||
| 55 | // Building Story Names | ||
| 56 |
1/1✓ Branch 1 taken 21 times.
|
21 | auto buildingStories = model.getConcreteModelObjects<model::BuildingStory>(); |
| 57 |
2/2✓ Branch 5 taken 85 times.
✓ Branch 6 taken 21 times.
|
106 | for (const auto& buildingStory : buildingStories) { |
| 58 |
1/1✓ Branch 1 taken 85 times.
|
85 | m_glTFModelObjectMetaDataVector.emplace_back(buildingStory); |
| 59 |
2/2✓ Branch 1 taken 85 times.
✓ Branch 4 taken 85 times.
|
85 | m_buildingStoryNames.emplace_back(buildingStory.nameString()); |
| 60 | 85 | ++m_buildingStoryCount; | |
| 61 | // TODO: I am matching what the initial implementation was doing, I guess the idea is to have spaces follow the story they belong to | ||
| 62 |
3/3✓ Branch 1 taken 85 times.
✓ Branch 7 taken 757 times.
✓ Branch 8 taken 85 times.
|
842 | for (const auto& space : buildingStory.spaces()) { |
| 63 |
1/1✓ Branch 1 taken 757 times.
|
757 | m_glTFModelObjectMetaDataVector.emplace_back(space); |
| 64 | 757 | ++m_spaceCount; | |
| 65 | 85 | } | |
| 66 | } | ||
| 67 | |||
| 68 |
2/3✓ Branch 1 taken 21 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21 times.
|
21 | for (const auto& buildingUnit : model.getConcreteModelObjects<model::BuildingUnit>()) { |
| 69 | ✗ | m_glTFModelObjectMetaDataVector.emplace_back(buildingUnit); | |
| 70 | ✗ | ++m_buildingUnitCount; | |
| 71 | 21 | } | |
| 72 | |||
| 73 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 7 taken 795 times.
✓ Branch 8 taken 21 times.
|
816 | for (const auto& thermalZone : model.getConcreteModelObjects<model::ThermalZone>()) { |
| 74 |
1/1✓ Branch 1 taken 795 times.
|
795 | m_glTFModelObjectMetaDataVector.emplace_back(thermalZone); |
| 75 | 795 | ++m_thermalZoneCount; | |
| 76 | 21 | } | |
| 77 | |||
| 78 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 7 taken 405 times.
✓ Branch 8 taken 21 times.
|
426 | for (const auto& buildingUnit : model.getConcreteModelObjects<model::SpaceType>()) { |
| 79 |
1/1✓ Branch 1 taken 405 times.
|
405 | m_glTFModelObjectMetaDataVector.emplace_back(buildingUnit); |
| 80 | 405 | ++m_spaceTypeCount; | |
| 81 | 21 | } | |
| 82 | |||
| 83 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 21 times.
|
43 | for (const auto& buildingUnit : model.getConcreteModelObjects<model::DefaultConstructionSet>()) { |
| 84 |
1/1✓ Branch 1 taken 22 times.
|
22 | m_glTFModelObjectMetaDataVector.emplace_back(buildingUnit); |
| 85 | 22 | ++m_constructionSetCount; | |
| 86 | 21 | } | |
| 87 | |||
| 88 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 21 times.
|
27 | for (const auto& buildingUnit : model.getConcreteModelObjects<model::AirLoopHVAC>()) { |
| 89 |
1/1✓ Branch 1 taken 6 times.
|
6 | m_glTFModelObjectMetaDataVector.emplace_back(buildingUnit); |
| 90 | 6 | ++m_airLoopCount; | |
| 91 | 21 | } | |
| 92 | 21 | } | |
| 93 | |||
| 94 | 1 | std::vector<GltfModelObjectMetaData> GltfMetaData::glTFModelObjectMetaDataVector() const { | |
| 95 | 1 | return m_glTFModelObjectMetaDataVector; | |
| 96 | } | ||
| 97 | ✗ | void GltfMetaData::setGlTFModelObjectMetaDataVector(const std::vector<GltfModelObjectMetaData>& glTFModelObjectMetaDataVector) { | |
| 98 | ✗ | m_glTFModelObjectMetaDataVector = glTFModelObjectMetaDataVector; | |
| 99 | ✗ | }; | |
| 100 | |||
| 101 | 1 | GltfBoundingBox GltfMetaData::glTFBoundingBox() const { | |
| 102 | 1 | return m_glTFBoundingBox; | |
| 103 | } | ||
| 104 | ✗ | void GltfMetaData::setGlTFBoundingBox(const GltfBoundingBox& glTFBoundingBox) { | |
| 105 | ✗ | m_glTFBoundingBox = glTFBoundingBox; | |
| 106 | ✗ | }; | |
| 107 | |||
| 108 | 1 | std::vector<std::string> GltfMetaData::buildingStoryNames() const { | |
| 109 | 1 | return m_buildingStoryNames; | |
| 110 | } | ||
| 111 | ✗ | void GltfMetaData::setBuildingStoryNames(const std::vector<std::string>& buildingStoryNames) { | |
| 112 | ✗ | m_buildingStoryNames = buildingStoryNames; | |
| 113 | ✗ | }; | |
| 114 | |||
| 115 | ✗ | void GltfMetaData::setBuildingStoryNames(const std::vector<model::BuildingStory>& buildingStories) { | |
| 116 | ✗ | m_buildingStoryNames.clear(); | |
| 117 | ✗ | m_buildingStoryCount = 0; | |
| 118 | ✗ | for (const auto& buildingStory : buildingStories) { | |
| 119 | ✗ | m_buildingStoryNames.emplace_back(buildingStory.nameString()); | |
| 120 | ✗ | ++m_buildingStoryCount; | |
| 121 | } | ||
| 122 | ✗ | } | |
| 123 | |||
| 124 | 1 | std::string GltfMetaData::generator() const { | |
| 125 | 1 | return m_generator; | |
| 126 | } | ||
| 127 | 21 | void GltfMetaData::setGenerator(const std::string& generator) { | |
| 128 | 21 | m_generator = generator; | |
| 129 | 21 | }; | |
| 130 | |||
| 131 | 1 | std::string GltfMetaData::type() const { | |
| 132 | 1 | return m_type; | |
| 133 | } | ||
| 134 | 21 | void GltfMetaData::setType(const std::string& type) { | |
| 135 | 21 | m_type = type; | |
| 136 | 21 | }; | |
| 137 | |||
| 138 | 1 | std::string GltfMetaData::version() const { | |
| 139 | 1 | return m_version; | |
| 140 | } | ||
| 141 | 21 | void GltfMetaData::setVersion(const std::string& version) { | |
| 142 | 21 | m_version = version; | |
| 143 | 21 | }; | |
| 144 | |||
| 145 | 1 | double GltfMetaData::northAxis() const { | |
| 146 | 1 | return m_northAxis; | |
| 147 | } | ||
| 148 | ✗ | void GltfMetaData::setNorthAxis(double northAxis) { | |
| 149 | ✗ | m_northAxis = northAxis; | |
| 150 | ✗ | }; | |
| 151 | |||
| 152 | 21 | void GltfMetaData::setNorthAxis(const model::Model& model) { | |
| 153 | 21 | m_northAxis = 0.0; | |
| 154 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 3 taken 20 times.
✓ Branch 4 taken 1 time.
|
42 | if (auto building_ = model.getOptionalUniqueModelObject<model::Building>()) { |
| 155 |
2/2✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
|
20 | m_northAxis = -building_->northAxis(); |
| 156 | 21 | } | |
| 157 | 21 | } | |
| 158 | |||
| 159 | 1 | int GltfMetaData::thermalZoneCount() const { | |
| 160 | 1 | return m_thermalZoneCount; | |
| 161 | } | ||
| 162 | ✗ | void GltfMetaData::setThermalZoneCount(int thermalZoneCount) { | |
| 163 | ✗ | m_thermalZoneCount = thermalZoneCount; | |
| 164 | ✗ | }; | |
| 165 | |||
| 166 | 1 | int GltfMetaData::spaceCount() const { | |
| 167 | 1 | return m_spaceCount; | |
| 168 | } | ||
| 169 | ✗ | void GltfMetaData::setSpaceCount(int spaceCount) { | |
| 170 | ✗ | m_spaceCount = spaceCount; | |
| 171 | ✗ | }; | |
| 172 | |||
| 173 | 1 | int GltfMetaData::spaceTypeCount() const { | |
| 174 | 1 | return m_spaceTypeCount; | |
| 175 | } | ||
| 176 | ✗ | void GltfMetaData::setSpaceTypeCount(int spaceTypeCount) { | |
| 177 | ✗ | m_spaceTypeCount = spaceTypeCount; | |
| 178 | ✗ | }; | |
| 179 | |||
| 180 | 1 | int GltfMetaData::constructionSetCount() const { | |
| 181 | 1 | return m_constructionSetCount; | |
| 182 | } | ||
| 183 | ✗ | void GltfMetaData::setConstructionSetCount(int constructionSetCount) { | |
| 184 | ✗ | m_constructionSetCount = constructionSetCount; | |
| 185 | ✗ | }; | |
| 186 | |||
| 187 | 1 | int GltfMetaData::airLoopCount() const { | |
| 188 | 1 | return m_airLoopCount; | |
| 189 | } | ||
| 190 | ✗ | void GltfMetaData::setAirLoopCount(int airLoopCount) { | |
| 191 | ✗ | m_airLoopCount = airLoopCount; | |
| 192 | ✗ | }; | |
| 193 | |||
| 194 | 1 | int GltfMetaData::buildingStoryCount() const { | |
| 195 | 1 | return m_buildingStoryCount; | |
| 196 | } | ||
| 197 | ✗ | void GltfMetaData::setBuildingStoryCount(int buildingStoryCount) { | |
| 198 | ✗ | m_buildingStoryCount = buildingStoryCount; | |
| 199 | ✗ | }; | |
| 200 | |||
| 201 | 21 | std::map<std::string, tinygltf::Value> GltfMetaData::toExtras() const { | |
| 202 | |||
| 203 | // TODO: use an array instead of a map<std::string(int), std::string> | ||
| 204 | 21 | std::map<std::string, tinygltf::Value> modelObjectMetaDataVector; | |
| 205 |
2/2✓ Branch 1 taken 2070 times.
✓ Branch 2 taken 21 times.
|
2091 | for (size_t i = 0; i < m_glTFModelObjectMetaDataVector.size(); ++i) { |
| 206 |
3/3✓ Branch 2 taken 2070 times.
✓ Branch 6 taken 2070 times.
✓ Branch 10 taken 2070 times.
|
2070 | modelObjectMetaDataVector.emplace(std::make_pair(std::to_string(i), tinygltf::Value(m_glTFModelObjectMetaDataVector[i].toExtras()))); |
| 207 | } | ||
| 208 | |||
| 209 | 21 | std::map<std::string, tinygltf::Value> buildingStoryNamesObject; | |
| 210 |
2/2✓ Branch 1 taken 85 times.
✓ Branch 2 taken 21 times.
|
106 | for (size_t i = 0; i < m_buildingStoryNames.size(); ++i) { |
| 211 |
3/3✓ Branch 2 taken 85 times.
✓ Branch 5 taken 85 times.
✓ Branch 9 taken 85 times.
|
85 | buildingStoryNamesObject.emplace(std::make_pair(std::to_string(i), tinygltf::Value(m_buildingStoryNames[i]))); |
| 212 | } | ||
| 213 | |||
| 214 | return { | ||
| 215 | ✗ | {"modelObjectMetaData", tinygltf::Value(modelObjectMetaDataVector)}, | |
| 216 | 42 | {"boundingbox", tinygltf::Value(m_glTFBoundingBox.toExtras())}, | |
| 217 | 21 | {"buildingStoryNames", tinygltf::Value(buildingStoryNamesObject)}, | |
| 218 | 21 | {"generator", tinygltf::Value(m_generator)}, | |
| 219 | 21 | {"type", tinygltf::Value(m_type)}, | |
| 220 | 21 | {"version", tinygltf::Value(m_version)}, | |
| 221 | 21 | {"northAxis", tinygltf::Value(m_northAxis)}, | |
| 222 | // {"thermalZoneCount", tinygltf::Value(m_thermalZoneCount)}, | ||
| 223 | // {"spaceCount", tinygltf::Value(m_spaceCount)}, | ||
| 224 | // {"spaceTypeCount", tinygltf::Value(m_spaceTypeCount)}, | ||
| 225 | // {"constructionSetCount", tinygltf::Value(m_constructionSetCount)}, | ||
| 226 | // {"airLoopCount", tinygltf::Value(m_airLoopCount)}, | ||
| 227 | // {"buildingStoryCount", tinygltf::Value(m_buildingStoryCount)}, | ||
| 228 |
3/5✓ Branch 1 taken 21 times.
✓ Branch 3 taken 147 times.
✓ Branch 4 taken 21 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
210 | }; |
| 229 | 63 | } | |
| 230 | |||
| 231 |
1/1✓ Branch 2 taken 1 time.
|
1 | GltfMetaData::GltfMetaData(const tinygltf::Value& metaDataObj) { |
| 232 | |||
| 233 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
|
2 | if (metaDataObj.Has("modelObjectMetaData")) { |
| 234 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | auto val = metaDataObj.Get("modelObjectMetaData"); |
| 235 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (val.IsObject()) { |
| 236 |
2/2✓ Branch 6 taken 9 times.
✓ Branch 7 taken 1 time.
|
10 | for (const auto& vv : val.Get<std::map<std::string, tinygltf::Value>>()) { |
| 237 |
1/2✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
|
9 | if (vv.second.IsObject()) { |
| 238 | // Constructs in place via GltfModelObjectMetaData(const tinygltf::Value&) ctor | ||
| 239 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | m_glTFModelObjectMetaDataVector.emplace_back(GltfModelObjectMetaData(vv.second)); |
| 240 | |||
| 241 |
1/1✓ Branch 2 taken 9 times.
|
9 | std::string iddObjectTypeStr = m_glTFModelObjectMetaDataVector.back().iddObjectType(); |
| 242 |
3/3✓ Branch 1 taken 9 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 8 times.
|
9 | if (iddObjectTypeStr == "OS:BuildingStory") { |
| 243 | 1 | m_buildingStoryCount++; | |
| 244 |
3/3✓ Branch 1 taken 8 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | } else if (iddObjectTypeStr == "OS:Space") { |
| 245 | 4 | m_spaceCount++; | |
| 246 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 3 times.
|
4 | } else if (iddObjectTypeStr == "OS:ThermalZone") { |
| 247 | 1 | m_thermalZoneCount++; | |
| 248 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 2 times.
|
3 | } else if (iddObjectTypeStr == "OS:SpaceType") { |
| 249 | 1 | m_spaceTypeCount++; | |
| 250 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | } else if (iddObjectTypeStr == "OS:DefaultConstructionSet") { |
| 251 | 1 | m_constructionSetCount++; | |
| 252 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
1 | } else if (iddObjectTypeStr == "OS:AirLoopHVAC") { |
| 253 | 1 | m_airLoopCount++; | |
| 254 | ✗ | } else if (iddObjectTypeStr == "OS:BuildingUnit") { | |
| 255 | ✗ | m_buildingUnitCount++; | |
| 256 | } | ||
| 257 | |||
| 258 | 9 | } else { | |
| 259 | ✗ | LOG(Warn, "metaDataObj has the key 'modelObjectMetaData', it is an Object, but at least one of the subobjects is not an Object"); | |
| 260 | } | ||
| 261 | } | ||
| 262 | } else { | ||
| 263 | ✗ | LOG(Warn, "metaDataObj has the key 'modelObjectMetaData' but it is not an Object"); | |
| 264 | } | ||
| 265 | 1 | } else { | |
| 266 | ✗ | LOG(Debug, "metaDataObj is missing the key 'airWall'"); | |
| 267 | } | ||
| 268 | |||
| 269 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
|
2 | if (metaDataObj.Has("boundingbox")) { |
| 270 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | auto val = metaDataObj.Get("boundingbox"); |
| 271 | // TODO: do I check here, or do I actually let the GltfBoundingBox ctor throw? | ||
| 272 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (val.IsObject()) { |
| 273 |
1/1✓ Branch 1 taken 1 time.
|
1 | m_glTFBoundingBox = GltfBoundingBox(val); |
| 274 | } else { | ||
| 275 | ✗ | LOG(Debug, "metaDataObj has the key 'boundingbox' but it is not a an Object"); | |
| 276 | } | ||
| 277 | 1 | } else { | |
| 278 | ✗ | LOG(Debug, "metaDataObj is missing the key 'boundingbox'"); | |
| 279 | } | ||
| 280 | |||
| 281 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
|
2 | if (metaDataObj.Has("buildingStoryNames")) { |
| 282 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | auto val = metaDataObj.Get("buildingStoryNames"); |
| 283 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (val.IsObject()) { |
| 284 |
2/2✓ Branch 6 taken 1 time.
✓ Branch 7 taken 1 time.
|
2 | for (const auto& vv : val.Get<std::map<std::string, tinygltf::Value>>()) { |
| 285 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (vv.second.IsString()) { |
| 286 |
1/1✓ Branch 2 taken 1 time.
|
1 | m_buildingStoryNames.emplace_back(vv.second.Get<std::string>()); |
| 287 | } else { | ||
| 288 | ✗ | LOG(Warn, "metaDataObj has the key 'buildingStoryNames', it is an Object, but at least one of the subobjects is not a std::string"); | |
| 289 | } | ||
| 290 | } | ||
| 291 | } else { | ||
| 292 | ✗ | LOG(Warn, "metaDataObj has the key 'buildingStoryNames' but it is not an Object"); | |
| 293 | } | ||
| 294 | 1 | } else { | |
| 295 | ✗ | LOG(Debug, "metaDataObj is missing the key 'airWall'"); | |
| 296 | } | ||
| 297 | |||
| 298 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
|
2 | if (metaDataObj.Has("generator")) { |
| 299 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | auto val = metaDataObj.Get("generator"); |
| 300 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (val.IsString()) { |
| 301 |
1/1✓ Branch 2 taken 1 time.
|
1 | m_generator = val.Get<std::string>(); |
| 302 | } else { | ||
| 303 | ✗ | LOG(Debug, "metaDataObj has the key 'generator' but it is not a std::string"); | |
| 304 | } | ||
| 305 | 1 | } else { | |
| 306 | ✗ | LOG(Debug, "metaDataObj is missing the key 'generator'"); | |
| 307 | } | ||
| 308 | |||
| 309 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
|
2 | if (metaDataObj.Has("type")) { |
| 310 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | auto val = metaDataObj.Get("type"); |
| 311 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (val.IsString()) { |
| 312 |
1/1✓ Branch 2 taken 1 time.
|
1 | m_type = val.Get<std::string>(); |
| 313 | } else { | ||
| 314 | ✗ | LOG(Debug, "metaDataObj has the key 'type' but it is not a std::string"); | |
| 315 | } | ||
| 316 | 1 | } else { | |
| 317 | ✗ | LOG(Debug, "metaDataObj is missing the key 'type'"); | |
| 318 | } | ||
| 319 | |||
| 320 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
|
2 | if (metaDataObj.Has("version")) { |
| 321 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | auto val = metaDataObj.Get("version"); |
| 322 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (val.IsString()) { |
| 323 |
1/1✓ Branch 2 taken 1 time.
|
1 | m_version = val.Get<std::string>(); |
| 324 | } else { | ||
| 325 | ✗ | LOG(Debug, "metaDataObj has the key 'version' but it is not a std::string"); | |
| 326 | } | ||
| 327 | 1 | } else { | |
| 328 | ✗ | LOG(Debug, "metaDataObj is missing the key 'version'"); | |
| 329 | } | ||
| 330 | |||
| 331 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
|
2 | if (metaDataObj.Has("northAxis")) { |
| 332 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | auto val = metaDataObj.Get("northAxis"); |
| 333 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (val.IsReal()) { |
| 334 | 1 | m_northAxis = val.Get<double>(); | |
| 335 | } else { | ||
| 336 | ✗ | LOG(Debug, "metaDataObj has the key 'northAxis' but it is not a double"); | |
| 337 | } | ||
| 338 | 1 | } else { | |
| 339 | ✗ | LOG(Debug, "metaDataObj is missing the key 'northAxis'"); | |
| 340 | } | ||
| 341 | |||
| 342 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
|
2 | if (metaDataObj.Has("storyCount")) { |
| 343 | ✗ | auto val = metaDataObj.Get("storyCount"); | |
| 344 | ✗ | if (val.IsInt()) { | |
| 345 | ✗ | m_buildingStoryCount = val.Get<int>(); | |
| 346 | } else { | ||
| 347 | ✗ | LOG(Debug, "metaDataObj has the key 'storyCount' but it is not a int"); | |
| 348 | } | ||
| 349 | ✗ | } else { | |
| 350 |
5/5✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
|
1 | LOG(Debug, "metaDataObj is missing the key 'storyCount'"); |
| 351 | } | ||
| 352 | |||
| 353 | // auto tryGetIntFromkey = [&metaDataObj](const std::string& key) -> boost::optional<double> { | ||
| 354 | // if (metaDataObj.Has(key)) { | ||
| 355 | // auto val = metaDataObj.Get(key); | ||
| 356 | // if (val.IsReal()) { | ||
| 357 | // return val.Get<int>(); | ||
| 358 | // } else { | ||
| 359 | // LOG(Warn, "metaDataObj has the key '" << key << "' but it is not an integer"); | ||
| 360 | // } | ||
| 361 | // } else { | ||
| 362 | // LOG(Debug, "metaDataObj is missing the key '" << key << "'"); | ||
| 363 | // } | ||
| 364 | // return boost::none; | ||
| 365 | // }; | ||
| 366 | |||
| 367 | // if (auto i_ = tryGetIntFromkey("buildingStoryCount")) { | ||
| 368 | // m_buildingStoryCount = i_.get(); | ||
| 369 | // } | ||
| 370 | |||
| 371 | // if (auto i_ = tryGetIntFromkey("thermalZoneCount")) { | ||
| 372 | // m_thermalZoneCount = i_.get(); | ||
| 373 | // } | ||
| 374 | |||
| 375 | // if (auto i_ = tryGetIntFromkey("spaceCount")) { | ||
| 376 | // m_spaceCount = i_.get(); | ||
| 377 | // } | ||
| 378 | |||
| 379 | // if (auto i_ = tryGetIntFromkey("spaceTypeCount")) { | ||
| 380 | // m_spaceTypeCount = i_.get(); | ||
| 381 | // } | ||
| 382 | |||
| 383 | // if (auto i_ = tryGetIntFromkey("constructionSetCount")) { | ||
| 384 | // m_constructionSetCount = i_.get(); | ||
| 385 | // } | ||
| 386 | |||
| 387 | // if (auto i_ = tryGetIntFromkey("airLoopCount")) { | ||
| 388 | // m_airLoopCount = i_.get(); | ||
| 389 | // } | ||
| 390 | |||
| 391 | // if (auto i_ = tryGetIntFromkey("buildingStoryCount")) { | ||
| 392 | // m_buildingStoryCount = i_.get(); | ||
| 393 | // } | ||
| 394 | 1 | } | |
| 395 | |||
| 396 | } // namespace gltf | ||
| 397 | } // namespace openstudio | ||
| 398 |