GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 65.0% 104 / 0 / 160
Functions: 48.1% 13 / 0 / 27
Branches: 57.4% 97 / 0 / 169

src/gltf/GltfMaterialData.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 "GltfMaterialData.hpp"
7 #include "GltfUtils.hpp"
8
9 #include "../model/Model.hpp"
10
11 #include "../model/RenderingColor.hpp"
12 #include "../model/ConstructionBase.hpp"
13 #include "../model/ConstructionBase_Impl.hpp"
14 #include "../model/ConstructionAirBoundary.hpp"
15 #include "../model/ConstructionAirBoundary_Impl.hpp"
16 #include "../model/BuildingStory.hpp"
17 #include "../model/BuildingStory_Impl.hpp"
18 #include "../model/BuildingUnit.hpp"
19 #include "../model/BuildingUnit_Impl.hpp"
20 #include "../model/ThermalZone.hpp"
21 #include "../model/ThermalZone_Impl.hpp"
22 #include "../model/AirLoopHVAC.hpp"
23 #include "../model/AirLoopHVAC_Impl.hpp"
24 #include "../model/SpaceType.hpp"
25 #include "../model/SpaceType_Impl.hpp"
26
27 #include <tiny_gltf.h>
28
29 #include <array>
30 #include <string>
31 #include <string_view>
32 #include <iostream>
33
34 namespace openstudio {
35 namespace gltf {
36
37 1498 GltfMaterialData::GltfMaterialData(std::string_view materialName, const model::RenderingColor& color, bool isDoubleSided)
38 1498 : m_materialName(materialName),
39 1498 m_r(color.renderingRedValue()),
40 1498 m_g(color.renderingGreenValue()),
41 1498 m_b(color.renderingBlueValue()),
42 1498 m_a(color.renderingAlphaValue() / 255.0),
43 1498 m_isDoubleSided(isDoubleSided) {}
44
45 1512 std::string GltfMaterialData::materialName() const {
46
1/1
✓ Branch 1 taken 1512 times.
4536 return std::string{m_materialName};
47 }
48 ✗ void GltfMaterialData::setMaterialName(const std::string& materialName) {
49 ✗ m_materialName = materialName;
50 ✗ };
51
52 ✗ int GltfMaterialData::r() const {
53 ✗ return m_r;
54 }
55 ✗ void GltfMaterialData::setR(int r) {
56 ✗ m_r = r;
57 ✗ };
58
59 ✗ int GltfMaterialData::g() const {
60 ✗ return m_g;
61 }
62 ✗ void GltfMaterialData::setG(int g) {
63 ✗ m_g = g;
64 ✗ };
65
66 ✗ int GltfMaterialData::b() const {
67 ✗ return m_b;
68 }
69 ✗ void GltfMaterialData::setB(int b) {
70 ✗ m_b = b;
71 ✗ };
72
73 ✗ double GltfMaterialData::a() const {
74 ✗ return m_a;
75 }
76 ✗ void GltfMaterialData::setA(double a) {
77 ✗ m_a = a;
78 ✗ };
79
80 ✗ bool GltfMaterialData::isDoubleSided() const {
81 ✗ return m_isDoubleSided;
82 }
83 ✗ void GltfMaterialData::setIsDoubleSided(bool isDoubleSided) {
84 ✗ m_isDoubleSided = isDoubleSided;
85 ✗ };
86
87 114 tinygltf::Material GltfMaterialData::toGltf() const {
88
1/1
✓ Branch 1 taken 114 times.
114 tinygltf::Material m;
89
1/1
✓ Branch 1 taken 114 times.
114 m.name = m_materialName;
90
1/1
✓ Branch 1 taken 114 times.
114 tinygltf::PbrMetallicRoughness pbr;
91 // this contains the red, green, blue and alpha components of the main color of the material
92 ✗ pbr.baseColorFactor = {(static_cast<float>(m_r) / 255.0f), (static_cast<float>(m_g) / 255.0f), (static_cast<float>(m_b) / 255.0f),
93
1/1
✓ Branch 1 taken 114 times.
114 static_cast<float>(m_a)};
94 // this indicates that the material should have very minimum reflection characteristics
95 // between that of a metal and non-metal material.
96 114 pbr.metallicFactor = 0.0;
97 // this makes the material to not be perfectly mirror-like, but instead scatter the
98 // reflected light a bit.
99 114 pbr.roughnessFactor = 1.0;
100
1/1
✓ Branch 1 taken 114 times.
114 m.pbrMetallicRoughness = pbr;
101 // emissive texture describes the parts of the object surface that emit light with a certain color
102
1/1
✓ Branch 1 taken 114 times.
114 m.emissiveFactor = {0.01, 0.01, 0.00};
103 // occlusion texture can be used to simulate the effect of objects self-shadowing each other.
104 // m.occlusionTexture = "";
105 // normal map is a texture applied to modulate the surface normal in a way that makes
106 // it possible to simulate finer geometric details without the cost of a higher mesh.
107 // m.normalTexture = "";
108
3/3
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 97 times.
✓ Branch 3 taken 114 times.
114 m.alphaMode = (m_a < 1.0f) ? "BLEND" : "OPAQUE";
109 // alphaCutoff should not be 1.0f else MATERIAL_ALPHA_CUTOFF_INVALID_MODE
110 // Alpha cutoff is supported only for 'MASK' alpha mode
111 114 m.alphaCutoff = 0.5f;
112 114 m.doubleSided = m_isDoubleSided;
113 228 return m;
114 114 }
115
116 // Creates a collection of raw (values: R,G,B,A & isDoubleSided) for all pre-defined GLTF material
117 static constexpr std::array<GltfMaterialData, 56> standardGltfMaterialDatas{{
118 {"Undefined", 255, 255, 255, 1, true},
119
120 {"NormalMaterial", 255, 255, 255, 1, true},
121 {"NormalMaterial_Ext", 255, 255, 255, 1},
122 {"NormalMaterial_Int", 255, 0, 0, 1},
123
124 {"Floor", 140, 140, 140, 1, true},
125 {"Floor_Ext", 128, 128, 128, 1},
126 {"Floor_Int", 191, 191, 191, 1},
127
128 {"Wall", 150, 131, 75, 1, true},
129 {"Wall_Ext", 204, 178, 102, 1},
130 {"Wall_Int", 235, 226, 197, 1},
131
132 {"RoofCeiling", 112, 56, 57, 1, true},
133 {"RoofCeiling_Ext", 153, 76, 76, 1},
134 {"RoofCeiling_Int", 202, 149, 149, 1},
135
136 {"Window", 102, 178, 204, 0.6, true},
137 {"Window_Ext", 102, 178, 204, 0.6},
138 {"Window_Int", 192, 226, 235, 0.6},
139
140 {"Door", 111, 98, 56, 1, true},
141 {"Door_Ext", 153, 133, 76, 1},
142 {"Door_Int", 202, 188, 149, 1},
143
144 {"SiteShading", 55, 90, 109, 1, true},
145 {"SiteShading_Ext", 75, 124, 149, 1},
146 {"SiteShading_Int", 187, 209, 220, 1},
147
148 {"BuildingShading", 83, 56, 111, 1, true},
149 {"BuildingShading_Ext", 113, 76, 153, 1},
150 {"BuildingShading_Int", 216, 203, 229, 1},
151
152 {"SpaceShading", 55, 81, 130, 1, true},
153 {"SpaceShading_Ext", 76, 110, 178, 1},
154 {"SpaceShading_Int", 183, 197, 224, 1},
155
156 {"InteriorPartitionSurface", 117, 138, 105, 1, true},
157 {"InteriorPartitionSurface_Ext", 158, 188, 143, 1},
158 {"InteriorPartitionSurface_Int", 213, 226, 207, 1},
159
160 // start textures for boundary conditions
161 {"Boundary_Surface", 0, 153, 0, 1, true},
162 {"Boundary_Adiabatic", 255, 0, 0, 1, true},
163 {"Boundary_Space", 255, 0, 0, 1, true},
164 {"Boundary_Outdoors", 163, 204, 204, 1, true},
165 {"Boundary_Outdoors_Sun", 40, 204, 204, 1, true},
166 {"Boundary_Outdoors_Wind", 9, 159, 162, 1, true},
167 {"Boundary_Outdoors_SunWind", 68, 119, 161, 1, true},
168 {"Boundary_Ground", 204, 183, 122, 1, true},
169 {"Boundary_Foundation", 117, 30, 122, 1, true},
170 {"Boundary_Groundfcfactormethod", 153, 122, 30, 1, true},
171 {"Boundary_Groundslabpreprocessoraverage", 255, 191, 0, 1, true},
172 {"Boundary_Groundslabpreprocessorcore", 255, 182, 50, 1, true},
173 {"Boundary_Groundslabpreprocessorperimeter", 255, 178, 101, 1, true},
174 {"Boundary_Groundbasementpreprocessoraveragewall", 204, 51, 0, 1, true},
175 {"Boundary_Groundbasementpreprocessoraveragefloor", 204, 81, 40, 1, true},
176 {"Boundary_Groundbasementpreprocessorupperwall", 204, 112, 81, 1, true},
177 {"Boundary_Groundbasementpreprocessorlowerwall", 204, 173, 163, 1, true},
178 {"Boundary_Othersidecoefficients", 63, 63, 63, 1, true},
179 {"Boundary_Othersideconditionsmodel", 153, 0, 76, 1, true},
180
181 // special rendering materials
182 {"SpaceType_Plenum", 192, 192, 192, 0.1, true},
183 {"ThermalZone_Plenum", 192, 192, 192, 0.1, true},
184
185 // special rendering materials, these are components or textures in SketchUp
186 {"DaylightingControl", 102, 178, 204, 0.1, true},
187 {"AirWall", 102, 178, 204, 0.1, true},
188 {"SolarCollector", 255, 255, 255, 1, true},
189 {"Photovoltaic", 255, 255, 255, 0.1, true},
190 }};
191
192 // Static
193 21 std::vector<GltfMaterialData> GltfMaterialData::buildMaterials(const model::Model& model) {
194
195 // We start by putting all standard materials: NOTE: "Undefined" will always be the first one
196
1/1
✓ Branch 3 taken 21 times.
21 std::vector<GltfMaterialData> allMaterials(standardGltfMaterialDatas.begin(), standardGltfMaterialDatas.end());
197
198 21 std::set<std::string> allMaterialNamesSet;
199
200 1492 auto getOrCreateRenderingColor = [&model](auto& object) {
201
4/5
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::BuildingStory>(openstudio::model::BuildingStory&) const:
✓ Branch 1 taken 85 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::BuildingUnit>(openstudio::model::BuildingUnit&) const:
✗ Branch 1 not taken.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::ConstructionBase>(openstudio::model::ConstructionBase&) const:
✓ Branch 1 taken 207 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::SpaceType>(openstudio::model::SpaceType&) const:
✓ Branch 1 taken 405 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::ThermalZone>(openstudio::model::ThermalZone&) const:
✓ Branch 1 taken 795 times.
1492 auto color_ = object.renderingColor();
202
8/10
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::BuildingStory>(openstudio::model::BuildingStory&) const:
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 73 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::BuildingUnit>(openstudio::model::BuildingUnit&) const:
✗ Branch 1 not taken.
✗ Branch 2 not taken.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::ConstructionBase>(openstudio::model::ConstructionBase&) const:
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 147 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::SpaceType>(openstudio::model::SpaceType&) const:
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 388 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::ThermalZone>(openstudio::model::ThermalZone&) const:
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 789 times.
1492 if (!color_) {
203
8/10
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::BuildingStory>(openstudio::model::BuildingStory&) const:
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::BuildingUnit>(openstudio::model::BuildingUnit&) const:
✗ Branch 1 not taken.
✗ Branch 4 not taken.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::ConstructionBase>(openstudio::model::ConstructionBase&) const:
✓ Branch 1 taken 60 times.
✓ Branch 4 taken 60 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::SpaceType>(openstudio::model::SpaceType&) const:
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::ThermalZone>(openstudio::model::ThermalZone&) const:
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
95 color_ = model::RenderingColor(model);
204 // TODO: Uh Oh, taking model as const but mutating objects by adding rendering colors to them...
205
8/10
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::BuildingStory>(openstudio::model::BuildingStory&) const:
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::BuildingUnit>(openstudio::model::BuildingUnit&) const:
✗ Branch 1 not taken.
✗ Branch 4 not taken.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::ConstructionBase>(openstudio::model::ConstructionBase&) const:
✓ Branch 1 taken 60 times.
✓ Branch 4 taken 60 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::SpaceType>(openstudio::model::SpaceType&) const:
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::ThermalZone>(openstudio::model::ThermalZone&) const:
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
95 object.setRenderingColor(color_.get());
206 }
207
8/10
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::BuildingStory>(openstudio::model::BuildingStory&) const:
✓ Branch 1 taken 85 times.
✓ Branch 4 taken 85 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::BuildingUnit>(openstudio::model::BuildingUnit&) const:
✗ Branch 1 not taken.
✗ Branch 4 not taken.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::ConstructionBase>(openstudio::model::ConstructionBase&) const:
✓ Branch 1 taken 207 times.
✓ Branch 4 taken 207 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::SpaceType>(openstudio::model::SpaceType&) const:
✓ Branch 1 taken 405 times.
✓ Branch 4 taken 405 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&)#1}::operator()<openstudio::model::ThermalZone>(openstudio::model::ThermalZone&) const:
✓ Branch 1 taken 795 times.
✓ Branch 4 taken 795 times.
2984 return color_.get();
208 1492 };
209
210 1498 auto getOrCreateMaterial = [&allMaterials, &allMaterialNamesSet](auto& object, const model::RenderingColor& color) {
211
5/6
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::AirLoopHVAC>(openstudio::model::AirLoopHVAC&, openstudio::model::RenderingColor const&) const:
✓ Branch 1 taken 6 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::BuildingStory>(openstudio::model::BuildingStory&, openstudio::model::RenderingColor const&) const:
✓ Branch 1 taken 85 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::BuildingUnit>(openstudio::model::BuildingUnit&, openstudio::model::RenderingColor const&) const:
✗ Branch 1 not taken.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::ConstructionBase>(openstudio::model::ConstructionBase&, openstudio::model::RenderingColor const&) const:
✓ Branch 1 taken 207 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::SpaceType>(openstudio::model::SpaceType&, openstudio::model::RenderingColor const&) const:
✓ Branch 1 taken 405 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::ThermalZone>(openstudio::model::ThermalZone&, openstudio::model::RenderingColor const&) const:
✓ Branch 1 taken 795 times.
1498 std::string materialName = getObjectGLTFMaterialName(object);
212
5/6
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::AirLoopHVAC>(openstudio::model::AirLoopHVAC&, openstudio::model::RenderingColor const&) const:
✓ Branch 1 taken 6 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::BuildingStory>(openstudio::model::BuildingStory&, openstudio::model::RenderingColor const&) const:
✓ Branch 1 taken 85 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::BuildingUnit>(openstudio::model::BuildingUnit&, openstudio::model::RenderingColor const&) const:
✗ Branch 1 not taken.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::ConstructionBase>(openstudio::model::ConstructionBase&, openstudio::model::RenderingColor const&) const:
✓ Branch 1 taken 207 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::SpaceType>(openstudio::model::SpaceType&, openstudio::model::RenderingColor const&) const:
✓ Branch 1 taken 405 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::ThermalZone>(openstudio::model::ThermalZone&, openstudio::model::RenderingColor const&) const:
✓ Branch 1 taken 795 times.
1498 auto [it, hasInserted] = allMaterialNamesSet.insert(materialName);
213
5/12
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::AirLoopHVAC>(openstudio::model::AirLoopHVAC&, openstudio::model::RenderingColor const&) const:
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::BuildingStory>(openstudio::model::BuildingStory&, openstudio::model::RenderingColor const&) const:
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::BuildingUnit>(openstudio::model::BuildingUnit&, openstudio::model::RenderingColor const&) const:
✗ Branch 0 not taken.
✗ Branch 1 not taken.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::ConstructionBase>(openstudio::model::ConstructionBase&, openstudio::model::RenderingColor const&) const:
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::SpaceType>(openstudio::model::SpaceType&, openstudio::model::RenderingColor const&) const:
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::ThermalZone>(openstudio::model::ThermalZone&, openstudio::model::RenderingColor const&) const:
✓ Branch 0 taken 795 times.
✗ Branch 1 not taken.
1498 if (hasInserted) {
214 // instead of creating the material whose node might get not used inshort to avoid
215 // warning "UNUSED_OBJECT". we'll add the material to our allMaterial collection
216 // and whie processing the surface if required we'll create and the node.
217 // createMaterial(materials, color, materialName, true);
218
5/6
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::AirLoopHVAC>(openstudio::model::AirLoopHVAC&, openstudio::model::RenderingColor const&) const:
✓ Branch 1 taken 6 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::BuildingStory>(openstudio::model::BuildingStory&, openstudio::model::RenderingColor const&) const:
✓ Branch 1 taken 85 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::BuildingUnit>(openstudio::model::BuildingUnit&, openstudio::model::RenderingColor const&) const:
✗ Branch 1 not taken.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::ConstructionBase>(openstudio::model::ConstructionBase&, openstudio::model::RenderingColor const&) const:
✓ Branch 1 taken 207 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::SpaceType>(openstudio::model::SpaceType&, openstudio::model::RenderingColor const&) const:
✓ Branch 1 taken 405 times.
auto openstudio::gltf::GltfMaterialData::buildMaterials(openstudio::model::Model const&)::{lambda(auto:1&, openstudio::model::RenderingColor const&)#1}::operator()<openstudio::model::ThermalZone>(openstudio::model::ThermalZone&, openstudio::model::RenderingColor const&) const:
✓ Branch 1 taken 795 times.
1498 allMaterials.emplace_back(materialName, color, true);
219 } else {
220 ✗ LOG_FREE(Debug, "GltfForwardTranslator", "buildMaterials, Key " << materialName << " found in materialList: " << *it);
221 }
222 1498 };
223
224 // make construction materials
225
3/3
✓ Branch 1 taken 21 times.
✓ Branch 8 taken 216 times.
✓ Branch 9 taken 21 times.
237 for (auto& construction : model.getModelObjects<model::ConstructionBase>()) {
226 // If it's ConstructionAirBoundary, we'll later use the standard material "AirWall"
227
3/3
✓ Branch 1 taken 216 times.
✓ Branch 5 taken 207 times.
✓ Branch 6 taken 9 times.
216 if (!construction.optionalCast<model::ConstructionAirBoundary>()) {
228
2/2
✓ Branch 1 taken 207 times.
✓ Branch 4 taken 207 times.
207 getOrCreateMaterial(construction, getOrCreateRenderingColor(construction));
229 }
230 21 }
231
232 // make thermal zone materials
233
3/3
✓ Branch 1 taken 21 times.
✓ Branch 7 taken 795 times.
✓ Branch 8 taken 21 times.
816 for (auto& thermalZone : model.getConcreteModelObjects<model::ThermalZone>()) {
234
2/2
✓ Branch 1 taken 795 times.
✓ Branch 4 taken 795 times.
795 getOrCreateMaterial(thermalZone, getOrCreateRenderingColor(thermalZone));
235 21 }
236
237 // make space type materials
238
3/3
✓ Branch 1 taken 21 times.
✓ Branch 7 taken 405 times.
✓ Branch 8 taken 21 times.
426 for (auto& spaceType : model.getConcreteModelObjects<model::SpaceType>()) {
239
2/2
✓ Branch 1 taken 405 times.
✓ Branch 4 taken 405 times.
405 getOrCreateMaterial(spaceType, getOrCreateRenderingColor(spaceType));
240 21 }
241
242 // make building story materials
243
3/3
✓ Branch 1 taken 21 times.
✓ Branch 7 taken 85 times.
✓ Branch 8 taken 21 times.
106 for (auto& buildingStory : model.getConcreteModelObjects<model::BuildingStory>()) {
244
2/2
✓ Branch 1 taken 85 times.
✓ Branch 4 taken 85 times.
85 getOrCreateMaterial(buildingStory, getOrCreateRenderingColor(buildingStory));
245 21 }
246
247 // make building unit materials
248
2/3
✓ Branch 1 taken 21 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21 times.
21 for (auto& buildingUnit : model.getConcreteModelObjects<model::BuildingUnit>()) {
249 ✗ getOrCreateMaterial(buildingUnit, getOrCreateRenderingColor(buildingUnit));
250 21 }
251
252 // make air loop HVAC materials (AirLoopHVAC doesn't have a renderingColor() method)
253
3/3
✓ Branch 1 taken 21 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 21 times.
27 for (auto& airLoopHVAC : model.getConcreteModelObjects<model::AirLoopHVAC>()) {
254
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 getOrCreateMaterial(airLoopHVAC, model::RenderingColor(model));
255 21 }
256
257 42 return allMaterials;
258 21 }
259
260 ✗ std::ostream& operator<<(std::ostream& out, const GltfMaterialData& gltfMaterialData) {
261 ✗ out << "GltfMaterialData(r=" << gltfMaterialData.r() << ", g=" << gltfMaterialData.g() << ", b=" << gltfMaterialData.b()
262 ✗ << ", a=" << gltfMaterialData.a();
263 ✗ if (gltfMaterialData.isDoubleSided()) {
264 ✗ out << ", Double Sided";
265 }
266 ✗ out << ")";
267 ✗ return out;
268 }
269
270 } // namespace gltf
271 } // namespace openstudio
272