src/model/MaterialPropertyGlazingSpectralData.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 "MaterialPropertyGlazingSpectralData.hpp" | ||
| 7 | #include "MaterialPropertyGlazingSpectralData_Impl.hpp" | ||
| 8 | #include "ModelExtensibleGroup.hpp" | ||
| 9 | |||
| 10 | #include <utilities/idd/IddEnums.hxx> | ||
| 11 | #include <utilities/idd/OS_MaterialProperty_GlazingSpectralData_FieldEnums.hxx> | ||
| 12 | |||
| 13 | #include "../utilities/core/Assert.hpp" | ||
| 14 | |||
| 15 | namespace openstudio { | ||
| 16 | namespace model { | ||
| 17 | |||
| 18 | namespace detail { | ||
| 19 | |||
| 20 | 7 | MaterialPropertyGlazingSpectralData_Impl::MaterialPropertyGlazingSpectralData_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 21 | 7 | : ResourceObject_Impl(idfObject, model, keepHandle) { | |
| 22 |
4/6✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 13 not taken.
|
7 | OS_ASSERT(idfObject.iddObject().type() == MaterialPropertyGlazingSpectralData::iddObjectType()); |
| 23 | 7 | } | |
| 24 | |||
| 25 | ✗ | MaterialPropertyGlazingSpectralData_Impl::MaterialPropertyGlazingSpectralData_Impl(const openstudio::detail::WorkspaceObject_Impl& other, | |
| 26 | ✗ | Model_Impl* model, bool keepHandle) | |
| 27 | ✗ | : ResourceObject_Impl(other, model, keepHandle) { | |
| 28 | ✗ | OS_ASSERT(other.iddObject().type() == MaterialPropertyGlazingSpectralData::iddObjectType()); | |
| 29 | ✗ | } | |
| 30 | |||
| 31 | 1 | MaterialPropertyGlazingSpectralData_Impl::MaterialPropertyGlazingSpectralData_Impl(const MaterialPropertyGlazingSpectralData_Impl& other, | |
| 32 | 1 | Model_Impl* model, bool keepHandle) | |
| 33 | 1 | : ResourceObject_Impl(other, model, keepHandle) {} | |
| 34 | |||
| 35 | ✗ | const std::vector<std::string>& MaterialPropertyGlazingSpectralData_Impl::outputVariableNames() const { | |
| 36 | ✗ | static const std::vector<std::string> result; | |
| 37 | ✗ | return result; | |
| 38 | } | ||
| 39 | |||
| 40 | ✗ | IddObjectType MaterialPropertyGlazingSpectralData_Impl::iddObjectType() const { | |
| 41 | ✗ | return MaterialPropertyGlazingSpectralData::iddObjectType(); | |
| 42 | } | ||
| 43 | |||
| 44 | 7 | std::vector<SpectralDataField> MaterialPropertyGlazingSpectralData_Impl::spectralDataFields() const { | |
| 45 | 7 | std::vector<SpectralDataField> result; | |
| 46 | |||
| 47 |
4/4✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 12 taken 10 times.
✓ Branch 13 taken 7 times.
|
17 | for (const ModelExtensibleGroup& group : castVector<ModelExtensibleGroup>(extensibleGroups())) { |
| 48 |
1/1✓ Branch 1 taken 10 times.
|
10 | OptionalDouble wavelength = group.getDouble(OS_MaterialProperty_GlazingSpectralDataExtensibleFields::Wavelength); |
| 49 |
1/1✓ Branch 1 taken 10 times.
|
10 | OptionalDouble transmittance = group.getDouble(OS_MaterialProperty_GlazingSpectralDataExtensibleFields::Transmittance); |
| 50 |
1/1✓ Branch 1 taken 10 times.
|
10 | OptionalDouble frontReflectance = group.getDouble(OS_MaterialProperty_GlazingSpectralDataExtensibleFields::FrontReflectance); |
| 51 |
1/1✓ Branch 1 taken 10 times.
|
10 | OptionalDouble backReflectance = group.getDouble(OS_MaterialProperty_GlazingSpectralDataExtensibleFields::BackReflectance); |
| 52 | |||
| 53 |
5/10✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10 times.
✗ Branch 9 not taken.
|
40 | if (wavelength && transmittance && frontReflectance && backReflectance) { |
| 54 |
6/6✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
✓ Branch 10 taken 10 times.
✓ Branch 13 taken 10 times.
✓ Branch 16 taken 10 times.
|
10 | result.push_back(SpectralDataField(*wavelength, *transmittance, *frontReflectance, *backReflectance)); |
| 55 | } else { | ||
| 56 | ✗ | LOG(Error, "Could not read SpectralDataField " << group.groupIndex() << " in " << briefDescription() << "."); | |
| 57 | } | ||
| 58 | 7 | } | |
| 59 | |||
| 60 | 7 | return result; | |
| 61 | ✗ | } | |
| 62 | |||
| 63 | 1 | bool MaterialPropertyGlazingSpectralData_Impl::setSpectralDataFields(const std::vector<SpectralDataField>& spectralDataFields) { | |
| 64 |
1/1✓ Branch 1 taken 1 time.
|
1 | std::vector<SpectralDataField> originalFields = this->spectralDataFields(); |
| 65 | |||
| 66 | 1 | bool result = true; | |
| 67 | |||
| 68 |
1/1✓ Branch 1 taken 1 time.
|
1 | clearExtensibleGroups(false); |
| 69 |
2/2✓ Branch 5 taken 3 times.
✓ Branch 6 taken 1 time.
|
4 | for (const auto& spectralDataField : spectralDataFields) { |
| 70 |
4/7✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
|
3 | if (!(result && addSpectralDataField(spectralDataField))) { |
| 71 | ✗ | result = false; | |
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (!result) { |
| 76 | ✗ | clearExtensibleGroups(false); | |
| 77 | ✗ | for (const auto& spectralDataField : originalFields) { | |
| 78 | ✗ | addSpectralDataField(spectralDataField); | |
| 79 | } | ||
| 80 | } | ||
| 81 | |||
| 82 | 1 | return result; | |
| 83 | 1 | } | |
| 84 | |||
| 85 | 5 | bool MaterialPropertyGlazingSpectralData_Impl::addSpectralDataField(const SpectralDataField& spectralDataField) { | |
| 86 | 5 | std::vector<std::string> values; | |
| 87 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | values.push_back(toString(spectralDataField.wavelength())); |
| 88 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | values.push_back(toString(spectralDataField.transmittance())); |
| 89 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | values.push_back(toString(spectralDataField.frontReflectance())); |
| 90 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | values.push_back(toString(spectralDataField.backReflectance())); |
| 91 | |||
| 92 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
5 | auto group = pushExtensibleGroup(values, false).cast<ModelExtensibleGroup>(); |
| 93 | |||
| 94 |
1/1✓ Branch 1 taken 5 times.
|
10 | return (!group.empty()); |
| 95 | 5 | } | |
| 96 | |||
| 97 | 1 | bool MaterialPropertyGlazingSpectralData_Impl::addSpectralDataField(double wavelength, double transmittance, double frontReflectance, | |
| 98 | double backReflectance) { | ||
| 99 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | return addSpectralDataField(SpectralDataField(wavelength, transmittance, frontReflectance, backReflectance)); |
| 100 | } | ||
| 101 | |||
| 102 | ✗ | void MaterialPropertyGlazingSpectralData_Impl::resetSpectralDataFields() { | |
| 103 | ✗ | clearExtensibleGroups(false); | |
| 104 | ✗ | } | |
| 105 | |||
| 106 | } // namespace detail | ||
| 107 | |||
| 108 | 13 | SpectralDataField::SpectralDataField(double wavelength, double transmittance, double frontReflectance, double backReflectance) | |
| 109 | 13 | : m_wavelength(wavelength), m_transmittance(transmittance), m_frontReflectance(frontReflectance), m_backReflectance(backReflectance) {} | |
| 110 | |||
| 111 | 5 | double SpectralDataField::wavelength() const { | |
| 112 | 5 | return m_wavelength; | |
| 113 | } | ||
| 114 | |||
| 115 | 5 | double SpectralDataField::transmittance() const { | |
| 116 | 5 | return m_transmittance; | |
| 117 | } | ||
| 118 | |||
| 119 | 5 | double SpectralDataField::frontReflectance() const { | |
| 120 | 5 | return m_frontReflectance; | |
| 121 | } | ||
| 122 | |||
| 123 | 5 | double SpectralDataField::backReflectance() const { | |
| 124 | 5 | return m_backReflectance; | |
| 125 | } | ||
| 126 | |||
| 127 | 7 | MaterialPropertyGlazingSpectralData::MaterialPropertyGlazingSpectralData(const Model& model) | |
| 128 | 7 | : ResourceObject(MaterialPropertyGlazingSpectralData::iddObjectType(), model) { | |
| 129 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 5 not taken.
|
7 | OS_ASSERT(getImpl<detail::MaterialPropertyGlazingSpectralData_Impl>()); |
| 130 | 7 | } | |
| 131 | |||
| 132 | 7744 | IddObjectType MaterialPropertyGlazingSpectralData::iddObjectType() { | |
| 133 |
1/1✓ Branch 1 taken 7744 times.
|
7744 | return {IddObjectType::OS_MaterialProperty_GlazingSpectralData}; |
| 134 | } | ||
| 135 | |||
| 136 | 6 | std::vector<SpectralDataField> MaterialPropertyGlazingSpectralData::spectralDataFields() const { | |
| 137 |
1/1✓ Branch 3 taken 6 times.
|
6 | return getImpl<detail::MaterialPropertyGlazingSpectralData_Impl>()->spectralDataFields(); |
| 138 | } | ||
| 139 | |||
| 140 | 1 | bool MaterialPropertyGlazingSpectralData::setSpectralDataFields(const std::vector<SpectralDataField>& spectralDataFields) { | |
| 141 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::MaterialPropertyGlazingSpectralData_Impl>()->setSpectralDataFields(spectralDataFields); |
| 142 | } | ||
| 143 | |||
| 144 | 1 | bool MaterialPropertyGlazingSpectralData::addSpectralDataField(const SpectralDataField& spectralDataField) { | |
| 145 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::MaterialPropertyGlazingSpectralData_Impl>()->addSpectralDataField(spectralDataField); |
| 146 | } | ||
| 147 | |||
| 148 | 1 | bool MaterialPropertyGlazingSpectralData::addSpectralDataField(double wavelength, double transmittance, double frontReflectance, | |
| 149 | double backReflectance) { | ||
| 150 |
1/1✓ Branch 3 taken 1 time.
|
2 | return getImpl<detail::MaterialPropertyGlazingSpectralData_Impl>()->addSpectralDataField(wavelength, transmittance, frontReflectance, |
| 151 | 2 | backReflectance); | |
| 152 | } | ||
| 153 | |||
| 154 | ✗ | void MaterialPropertyGlazingSpectralData::resetSpectralDataFields() { | |
| 155 | ✗ | getImpl<detail::MaterialPropertyGlazingSpectralData_Impl>()->resetSpectralDataFields(); | |
| 156 | ✗ | } | |
| 157 | |||
| 158 | /// @cond | ||
| 159 | 13 | MaterialPropertyGlazingSpectralData::MaterialPropertyGlazingSpectralData(std::shared_ptr<detail::MaterialPropertyGlazingSpectralData_Impl> impl) | |
| 160 |
1/1✓ Branch 3 taken 13 times.
|
13 | : ResourceObject(std::move(impl)) {} |
| 161 | /// @endcond | ||
| 162 | |||
| 163 | } // namespace model | ||
| 164 | } // namespace openstudio | ||
| 165 |