src/model/Construction.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 "Construction.hpp" | ||
| 7 | #include "Construction_Impl.hpp" | ||
| 8 | #include "Model.hpp" | ||
| 9 | |||
| 10 | #include "Material.hpp" | ||
| 11 | #include "Material_Impl.hpp" | ||
| 12 | #include "OpaqueMaterial.hpp" | ||
| 13 | #include "FenestrationMaterial.hpp" | ||
| 14 | #include "ModelPartitionMaterial.hpp" | ||
| 15 | #include "ModelExtensibleGroup.hpp" | ||
| 16 | #include "ShadingMaterial.hpp" | ||
| 17 | #include "ShadingMaterial_Impl.hpp" | ||
| 18 | |||
| 19 | #include <utilities/idd/OS_Construction_FieldEnums.hxx> | ||
| 20 | #include <utilities/idd/IddEnums.hxx> | ||
| 21 | |||
| 22 | #include "../utilities/core/Assert.hpp" | ||
| 23 | |||
| 24 | namespace openstudio { | ||
| 25 | namespace model { | ||
| 26 | |||
| 27 | namespace detail { | ||
| 28 | |||
| 29 | 3156 | Construction_Impl::Construction_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 30 | 3156 | : LayeredConstruction_Impl(idfObject, model, keepHandle) { | |
| 31 |
4/6✓ Branch 1 taken 3156 times.
✓ Branch 4 taken 3156 times.
✓ Branch 7 taken 3156 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 3156 times.
✗ Branch 13 not taken.
|
3156 | OS_ASSERT(idfObject.iddObject().type() == Construction::iddObjectType()); |
| 32 | 3156 | } | |
| 33 | |||
| 34 | 685 | Construction_Impl::Construction_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 35 | 685 | : LayeredConstruction_Impl(other, model, keepHandle) { | |
| 36 |
4/6✓ Branch 1 taken 685 times.
✓ Branch 4 taken 685 times.
✓ Branch 7 taken 685 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 685 times.
✗ Branch 13 not taken.
|
685 | OS_ASSERT(other.iddObject().type() == Construction::iddObjectType()); |
| 37 | 685 | } | |
| 38 | |||
| 39 | 1447 | Construction_Impl::Construction_Impl(const Construction_Impl& other, Model_Impl* model, bool keepHandle) | |
| 40 | 1447 | : LayeredConstruction_Impl(other, model, keepHandle) {} | |
| 41 | |||
| 42 | 12 | const std::vector<std::string>& Construction_Impl::outputVariableNames() const { | |
| 43 |
3/4✓ Branch 0 taken 3 times.
✓ Branch 1 taken 9 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
12 | static const std::vector<std::string> result; |
| 44 | 12 | return result; | |
| 45 | } | ||
| 46 | |||
| 47 | 22946 | IddObjectType Construction_Impl::iddObjectType() const { | |
| 48 | 22946 | return Construction::iddObjectType(); | |
| 49 | } | ||
| 50 | |||
| 51 | 397 | int Construction_Impl::renderingColorIndex() const { | |
| 52 | 397 | return OS_ConstructionFields::SurfaceRenderingName; | |
| 53 | } | ||
| 54 | |||
| 55 | 2 | Construction Construction_Impl::reverseConstruction() const { | |
| 56 |
2/3✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
|
2 | if (this->isSymmetric()) { |
| 57 | ✗ | return this->getObject<Construction>(); | |
| 58 | } | ||
| 59 | |||
| 60 |
1/1✓ Branch 1 taken 2 times.
|
2 | MaterialVector reverseLayers(this->layers()); |
| 61 |
1/1✓ Branch 3 taken 2 times.
|
2 | std::reverse(reverseLayers.begin(), reverseLayers.end()); |
| 62 | |||
| 63 |
1/1✓ Branch 1 taken 2 times.
|
2 | Model model = this->model(); |
| 64 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 8 taken 15 times.
✓ Branch 9 taken 2 times.
|
17 | for (const Construction& other : model.getConcreteModelObjects<Construction>()) { |
| 65 | |||
| 66 |
1/1✓ Branch 1 taken 15 times.
|
15 | MaterialVector layers = other.layers(); |
| 67 |
2/2✓ Branch 2 taken 10 times.
✓ Branch 3 taken 5 times.
|
15 | if (layers.size() != reverseLayers.size()) { |
| 68 | 10 | continue; | |
| 69 | } | ||
| 70 | |||
| 71 | 5 | bool test = true; | |
| 72 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | for (unsigned i = 0; i < layers.size(); ++i) { |
| 73 |
5/5✓ Branch 2 taken 6 times.
✓ Branch 6 taken 6 times.
✓ Branch 9 taken 6 times.
✓ Branch 11 taken 5 times.
✓ Branch 12 taken 1 time.
|
6 | if (layers[i].handle() != reverseLayers[i].handle()) { |
| 74 | 5 | test = false; | |
| 75 | 5 | break; // break out of loop over layers | |
| 76 | } | ||
| 77 | } | ||
| 78 | |||
| 79 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
5 | if (test) { |
| 80 | ✗ | return other; | |
| 81 | } | ||
| 82 | 17 | } | |
| 83 | |||
| 84 | // TODO: this should also copy (and modify) standards information object | ||
| 85 | |||
| 86 | // no match, make one | ||
| 87 |
1/1✓ Branch 1 taken 2 times.
|
2 | Construction result(model); |
| 88 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | result.setName(this->name().get() + " Reversed"); |
| 89 |
1/1✓ Branch 1 taken 2 times.
|
2 | result.setLayers(reverseLayers); |
| 90 | |||
| 91 | 2 | return result; | |
| 92 | 2 | } | |
| 93 | |||
| 94 | } // namespace detail | ||
| 95 | |||
| 96 | 765 | Construction::Construction(const Model& model) : LayeredConstruction(Construction::iddObjectType(), model) { | |
| 97 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 765 times.
✗ Branch 5 not taken.
|
765 | OS_ASSERT(getImpl<detail::Construction_Impl>()); |
| 98 | 765 | } | |
| 99 | |||
| 100 | 1356 | Construction::Construction(const std::vector<OpaqueMaterial>& opaqueMaterials) | |
| 101 |
7/7✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1355 times.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1355 times.
✓ Branch 10 taken 1355 times.
✓ Branch 13 taken 1356 times.
✓ Branch 16 taken 1356 times.
|
1356 | : LayeredConstruction(Construction::iddObjectType(), (opaqueMaterials.empty() ? openstudio::model::Model() : opaqueMaterials.at(0).model())) { |
| 102 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1355 times.
|
1356 | if (opaqueMaterials.empty()) { |
| 103 | // DLM: do not remove, this was only added to a temporary model | ||
| 104 | //this->remove(); | ||
| 105 |
13/13✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
✓ Branch 38 taken 1 time.
✓ Branch 41 taken 1 time.
|
1 | LOG_AND_THROW("Cannot create construction from empty opaque layers."); |
| 106 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1354 times.
|
1355 | } else if (opaqueMaterials.size() > 10) { |
| 107 |
1/1✓ Branch 1 taken 1 time.
|
1 | this->remove(); |
| 108 |
13/13✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
✓ Branch 38 taken 1 time.
✓ Branch 41 taken 1 time.
|
1 | LOG_AND_THROW("Cannot create construction with more than 10 opaque layers."); |
| 109 | } | ||
| 110 | |||
| 111 |
1/1✓ Branch 1 taken 1354 times.
|
1354 | std::vector<Material> materials = castVector<Material>(opaqueMaterials); |
| 112 |
1/1✓ Branch 1 taken 1354 times.
|
1354 | bool ok = setLayers(materials); |
| 113 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 1354 times.
✗ Branch 3 not taken.
|
1354 | OS_ASSERT(ok); |
| 114 | 1356 | } | |
| 115 | |||
| 116 | 339 | Construction::Construction(const std::vector<FenestrationMaterial>& fenestrationMaterials) | |
| 117 | : LayeredConstruction(Construction::iddObjectType(), | ||
| 118 |
7/7✓ Branch 1 taken 1 time.
✓ Branch 2 taken 338 times.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 338 times.
✓ Branch 10 taken 338 times.
✓ Branch 13 taken 339 times.
✓ Branch 16 taken 339 times.
|
339 | (fenestrationMaterials.empty() ? openstudio::model::Model() : fenestrationMaterials.at(0).model())) { |
| 119 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 338 times.
|
339 | if (fenestrationMaterials.empty()) { |
| 120 | // DLM: do not remove, this was only added to a temporary model | ||
| 121 | //this->remove(); | ||
| 122 |
13/13✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
✓ Branch 38 taken 1 time.
✓ Branch 41 taken 1 time.
|
1 | LOG_AND_THROW("Cannot create construction from empty fenestration layers."); |
| 123 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 337 times.
|
338 | } else if (fenestrationMaterials.size() > 8) { |
| 124 |
1/1✓ Branch 1 taken 1 time.
|
1 | this->remove(); |
| 125 |
13/13✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
✓ Branch 38 taken 1 time.
✓ Branch 41 taken 1 time.
|
1 | LOG_AND_THROW("Cannot create construction with more than 8 fenestration layers."); |
| 126 | } | ||
| 127 | |||
| 128 |
1/1✓ Branch 1 taken 337 times.
|
337 | std::vector<Material> materials = castVector<Material>(fenestrationMaterials); |
| 129 |
1/1✓ Branch 1 taken 337 times.
|
337 | bool ok = setLayers(materials); |
| 130 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
✗ Branch 3 not taken.
|
337 | OS_ASSERT(ok); |
| 131 | 339 | } | |
| 132 | |||
| 133 | ✗ | Construction::Construction(const ModelPartitionMaterial& modelPartitionMaterial) | |
| 134 | ✗ | : LayeredConstruction(Construction::iddObjectType(), modelPartitionMaterial.model()) { | |
| 135 | ✗ | bool ok = setLayer(modelPartitionMaterial); | |
| 136 | ✗ | OS_ASSERT(ok); | |
| 137 | ✗ | } | |
| 138 | |||
| 139 | 2 | Construction Construction::reverseConstruction() const { | |
| 140 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::Construction_Impl>()->reverseConstruction(); |
| 141 | } | ||
| 142 | |||
| 143 | 47294 | IddObjectType Construction::iddObjectType() { | |
| 144 |
1/1✓ Branch 1 taken 47294 times.
|
47294 | IddObjectType result(IddObjectType::OS_Construction); |
| 145 | 47294 | return result; | |
| 146 | } | ||
| 147 | |||
| 148 | /// @cond | ||
| 149 |
1/1✓ Branch 3 taken 1569 times.
|
1569 | Construction::Construction(std::shared_ptr<detail::Construction_Impl> impl) : LayeredConstruction(std::move(impl)) {} |
| 150 | /// @endcond | ||
| 151 | |||
| 152 | } // namespace model | ||
| 153 | } // namespace openstudio | ||
| 154 |