From 9d6b8676e7c0467963637b0f36ef156668b83c8f Mon Sep 17 00:00:00 2001 From: StephenCzarnecki Date: Tue, 14 Jan 2025 17:30:55 -0500 Subject: [PATCH] Fixes for AddressSanitizer stack-use-after-scope errors. --- .../src/AbsorptancesMultiPane.cpp | 12 +- .../src/EquivalentBSDFLayer.cpp | 12 +- .../src/EquivalentBSDFLayerSingleBand.cpp | 9 +- .../src/MultiLayerInterRef.cpp | 16 ++- .../src/MultiLayerInterRefSingleComponent.cpp | 9 +- src/MultiLayerOptics/src/MultiPaneBSDF.cpp | 8 +- .../src/MultiPaneSampleData.cpp | 9 +- .../src/MultiPaneSpectralSample.cpp | 6 +- src/SingleLayerOptics/src/BSDFIntegrator.cpp | 21 ++-- src/SingleLayerOptics/src/BSDFLayer.cpp | 18 ++- .../units/SingleLayerOpticsUtilities.unit.cpp | 3 +- .../src/MeasuredSampleData.cpp | 18 ++- src/SpectralAveraging/src/SpectralSample.cpp | 50 ++++++--- src/Tarcog/src/CMAWindow.cpp | 105 +++++++++++------- src/Tarcog/src/IGU.cpp | 52 ++++++--- src/Tarcog/src/IGUSolidDeflection.cpp | 3 +- src/Tarcog/src/IGUSolidLayer.cpp | 3 +- src/Tarcog/src/SingleSystem.cpp | 12 +- src/Tarcog/src/SurfacesManager.cpp | 3 +- src/Viewer/src/Geometry2DBeam.cpp | 3 +- 20 files changed, 238 insertions(+), 134 deletions(-) diff --git a/src/MultiLayerOptics/src/AbsorptancesMultiPane.cpp b/src/MultiLayerOptics/src/AbsorptancesMultiPane.cpp index 42a27325..715a0172 100644 --- a/src/MultiLayerOptics/src/AbsorptancesMultiPane.cpp +++ b/src/MultiLayerOptics/src/AbsorptancesMultiPane.cpp @@ -58,8 +58,8 @@ namespace MultiLayerOptics void CAbsorptancesMultiPane::calculateRTCoefficients() { const size_t size{m_T.size()}; - - for(const auto side : EnumSide()) + EnumSide sides; + for(const auto side : sides) { const auto oppositeSide{FenestrationCommon::oppositeSide(side)}; @@ -96,8 +96,9 @@ namespace MultiLayerOptics { // Calculate normalized radiances const auto wv{m_T[0].getXArray()}; - - for(const auto side : EnumSide()) + + EnumSide sides; + for(const auto side : sides) { const size_t size{m_rCoeffs.at(side).size()}; @@ -126,7 +127,8 @@ namespace MultiLayerOptics void CAbsorptancesMultiPane::calculateAbsorptances() { - for(const auto side : EnumSide()) + EnumSide sides; + for(const auto side : sides) { const auto oppositeSide{FenestrationCommon::oppositeSide(side)}; const size_t size{Iminus.at(side).size()}; diff --git a/src/MultiLayerOptics/src/EquivalentBSDFLayer.cpp b/src/MultiLayerOptics/src/EquivalentBSDFLayer.cpp index 863aaa5f..bc0a3260 100644 --- a/src/MultiLayerOptics/src/EquivalentBSDFLayer.cpp +++ b/src/MultiLayerOptics/src/EquivalentBSDFLayer.cpp @@ -103,13 +103,15 @@ namespace MultiLayerOptics void CEquivalentBSDFLayer::calculate() { - for(Side aSide : FenestrationCommon::EnumSide()) + FenestrationCommon::EnumSide sides; + for(Side aSide : sides) { m_TotA[aSide] = CMatrixSeries(m_Layer.size(), m_Lambda.size(), m_CombinedLayerWavelengths.size()); m_TotJSC[aSide] = CMatrixSeries(m_Layer.size(), m_Lambda.size(), m_CombinedLayerWavelengths.size()); - for(PropertySimple aProperty : FenestrationCommon::EnumPropertySimple()) + FenestrationCommon::EnumPropertySimple properties; + for(PropertySimple aProperty : properties) { m_Tot[{aSide, aProperty}] = CMatrixSeries( m_Lambda.size(), m_Lambda.size(), m_CombinedLayerWavelengths.size()); @@ -129,7 +131,8 @@ namespace MultiLayerOptics // getEquivalentLayerAtWavelength is calculation intensive and it will slow down the // execution auto layer{getEquivalentLayerAtWavelength(index)}; - for(auto aSide : FenestrationCommon::EnumSide()) + FenestrationCommon::EnumSide sides; + for(auto aSide : sides) { for(size_t layerNumber = 0; layerNumber < m_Layer.size(); ++layerNumber) { @@ -145,7 +148,8 @@ namespace MultiLayerOptics m_CombinedLayerWavelengths[index], layer.getLayerJSC(layerNumber + 1, aSide)); } - for(auto aProperty : FenestrationCommon::EnumPropertySimple()) + FenestrationCommon::EnumPropertySimple properties; + for(auto aProperty : properties) { m_Tot.at({aSide, aProperty}) .setPropertiesAtIndex(index, diff --git a/src/MultiLayerOptics/src/EquivalentBSDFLayerSingleBand.cpp b/src/MultiLayerOptics/src/EquivalentBSDFLayerSingleBand.cpp index 42c63e05..b542e446 100644 --- a/src/MultiLayerOptics/src/EquivalentBSDFLayerSingleBand.cpp +++ b/src/MultiLayerOptics/src/EquivalentBSDFLayerSingleBand.cpp @@ -123,7 +123,8 @@ namespace MultiLayerOptics std::vector(t_Layer.lambdaVector().size(), 0)); } m_EquivalentLayer = BSDFIntegrator(t_Layer); - for(Side aSide : EnumSide()) + EnumSide sides; + for(Side aSide : sides) { m_A[aSide] = std::vector>(); m_JSC[aSide] = std::vector>(); @@ -187,7 +188,8 @@ namespace MultiLayerOptics std::vector(t_Layer.lambdaVector().size(), 0)); } m_PropertiesCalculated = false; - for(Side aSide : EnumSide()) + EnumSide sides; + for(Side aSide : sides) { m_A.at(aSide).clear(); m_JSC.at(aSide).clear(); @@ -289,7 +291,8 @@ namespace MultiLayerOptics { for(size_t i = 0; i < numberOfLayers; i++) { - for(Side aSide : EnumSide()) + EnumSide sides; + for(Side aSide : sides) { auto AbsFront{m_Layers[i].Abs(aSide)}; auto AbsBack{m_Layers[i].Abs(oppositeSide(aSide))}; diff --git a/src/MultiLayerOptics/src/MultiLayerInterRef.cpp b/src/MultiLayerOptics/src/MultiLayerInterRef.cpp index 94b0b1dd..58e1d4f9 100644 --- a/src/MultiLayerOptics/src/MultiLayerInterRef.cpp +++ b/src/MultiLayerOptics/src/MultiLayerInterRef.cpp @@ -157,12 +157,13 @@ namespace MultiLayerOptics { // Sum of previous two components. Total diffuse energy that gets off the surfaces. CSurfaceEnergy diffSum{}; - - for(EnergyFlow aEnergyFlow : EnumEnergyFlow()) + EnumEnergyFlow energyFlows; + for(EnergyFlow aEnergyFlow : energyFlows) { for(size_t i = 1; i <= m_Layers.size(); ++i) { // Layer indexing goes from one - for(Side aSide : EnumSide()) + EnumSide sides; + for(Side aSide : sides) { Side oppSide = oppositeSide(aSide); // Calculate diffuse energy from direct exterior/interior beam @@ -212,7 +213,8 @@ namespace MultiLayerOptics CSurfaceEnergy aScatter{}; // Calculate total energy scatterred from beam to diffuse - for(EnergyFlow aEnergyFlow : EnumEnergyFlow()) + EnumEnergyFlow energyFlows; + for(EnergyFlow aEnergyFlow : energyFlows) { // In this case numbering goes through gas environments (gaps, interior and exterior) // becase we want to keep interreflectance calculations together @@ -265,11 +267,13 @@ namespace MultiLayerOptics { for(size_t i = 0; i < m_Layers.size(); ++i) { - for(EnergyFlow aEnergyFlow : EnumEnergyFlow()) + EnumEnergyFlow energyFlows; + for(EnergyFlow aEnergyFlow : energyFlows) { double EnergyDirect = 0; double EnergyDiffuse = 0; - for(Side aSide : EnumSide()) + EnumSide sides; + for(Side aSide : sides) { const double Adir = m_Layers[i].getAbsorptance(aSide, ScatteringSimple::Direct, t_Theta, t_Phi); diff --git a/src/MultiLayerOptics/src/MultiLayerInterRefSingleComponent.cpp b/src/MultiLayerOptics/src/MultiLayerInterRefSingleComponent.cpp index 69520f4d..dafe1edd 100644 --- a/src/MultiLayerOptics/src/MultiLayerInterRefSingleComponent.cpp +++ b/src/MultiLayerOptics/src/MultiLayerInterRefSingleComponent.cpp @@ -14,9 +14,11 @@ namespace MultiLayerOptics /////////////////////////////////////////////////////////////////////////////////////////////////////////// CSurfaceEnergy::CSurfaceEnergy() { - for(Side t_Side : EnumSide()) + EnumSide sides; + for(Side t_Side : sides) { - for(EnergyFlow t_EnergyFlow : EnumEnergyFlow()) + EnumEnergyFlow flows; + for(EnergyFlow t_EnergyFlow : flows) { m_IEnergy[std::make_pair(t_Side, t_EnergyFlow)] = std::make_shared>(); @@ -112,7 +114,8 @@ namespace MultiLayerOptics // Even if energy flow comes from one side, it still hits both sides of the layer and // this loop calculates energy absorbed at each side double absTot = 0; - for(Side aSide : EnumSide()) + EnumSide sides; + for(Side aSide : sides) { absTot += m_Layers[Index - 1].getProperty(Property::Abs, aSide) * getEnergyToSurface(Index, aSide, aFlow); diff --git a/src/MultiLayerOptics/src/MultiPaneBSDF.cpp b/src/MultiLayerOptics/src/MultiPaneBSDF.cpp index c5d4efe1..f300e3ab 100644 --- a/src/MultiLayerOptics/src/MultiPaneBSDF.cpp +++ b/src/MultiLayerOptics/src/MultiPaneBSDF.cpp @@ -180,13 +180,15 @@ namespace MultiLayerOptics m_IncomingSolar = calculateIncomingSolar(m_IncomingSpectra, minLambda, maxLambda); - for(Side aSide : FenestrationCommon::EnumSide()) + FenestrationCommon::EnumSide sides; + for(Side aSide : sides) { m_Abs[aSide] = calculateAbsorptance(aSide, minLambda, maxLambda); m_AbsElectricity[aSide] = calculateJSC(aSide, minLambda, maxLambda); std::map, SquareMatrix> aResults; - for(PropertySimple aProperty : FenestrationCommon::EnumPropertySimple()) + FenestrationCommon::EnumPropertySimple properties; + for(PropertySimple aProperty : properties) { aResults[{aSide, aProperty}] = calculateProperties(aSide, aProperty, minLambda, maxLambda); @@ -199,7 +201,7 @@ namespace MultiLayerOptics m_Results.resetCalculatedResults(); - for(const Side aSide : FenestrationCommon::EnumSide()) + for(Side aSide : sides) { calcHemisphericalAbs(aSide); } diff --git a/src/MultiLayerOptics/src/MultiPaneSampleData.cpp b/src/MultiLayerOptics/src/MultiPaneSampleData.cpp index d578affd..ef653db1 100644 --- a/src/MultiLayerOptics/src/MultiPaneSampleData.cpp +++ b/src/MultiLayerOptics/src/MultiPaneSampleData.cpp @@ -99,15 +99,18 @@ namespace MultiLayerOptics (*it)->properties(Property ::R, Side::Back)); } - for(const auto & prop : EnumProperty()) + EnumProperty properties; + for(const auto & prop : properties) { - for(const auto side : EnumSide()) + EnumSide sides; + for(const auto side : sides) { m_Property[std::make_pair(prop, side)] = aEqivalentLayer.getProperties(prop, side); } } - for(const auto side : EnumSide()) + EnumSide sides; + for(const auto side : sides) { m_LayerAbsorptances.at(side).clear(); size_t size = aAbsorptances.numOfLayers(); diff --git a/src/MultiLayerOptics/src/MultiPaneSpectralSample.cpp b/src/MultiLayerOptics/src/MultiPaneSpectralSample.cpp index 3ea07d5a..d72a32f2 100644 --- a/src/MultiLayerOptics/src/MultiPaneSpectralSample.cpp +++ b/src/MultiLayerOptics/src/MultiPaneSpectralSample.cpp @@ -50,7 +50,8 @@ namespace MultiLayerOptics { if(!m_StateCalculated) { - for(const auto side : EnumSide()) + EnumSide sides; + for(const auto side : sides) { CSpectralSample::calculateProperties(integrator, normalizationCoefficient); if(std::dynamic_pointer_cast(m_SampleData) != NULL) @@ -95,7 +96,8 @@ namespace MultiLayerOptics void CMultiPaneSpectralSample::reset() { CSpectralSample::reset(); - for(const auto side : EnumSide()) + EnumSide sides; + for(const auto side : sides) { m_AbsorbedLayersSource.at(side).clear(); } diff --git a/src/SingleLayerOptics/src/BSDFIntegrator.cpp b/src/SingleLayerOptics/src/BSDFIntegrator.cpp index 05116d31..bc7536a0 100644 --- a/src/SingleLayerOptics/src/BSDFIntegrator.cpp +++ b/src/SingleLayerOptics/src/BSDFIntegrator.cpp @@ -13,9 +13,11 @@ namespace SingleLayerOptics m_DirectHemisphericalCalculated(false), m_DiffuseDiffuseCalculated(false) { - for(auto t_Side : EnumSide()) + EnumSide sides; + for(auto t_Side : sides) { - for(auto t_Property : EnumPropertySimple()) + EnumPropertySimple properties; + for(auto t_Property : properties) { m_Matrix[std::make_pair(t_Side, t_Property)] = SquareMatrix(m_DimMatrices); m_DirectHemispherical[std::make_pair(t_Side, t_Property)] = std::vector(m_DimMatrices); @@ -130,9 +132,11 @@ namespace SingleLayerOptics { if(!m_DiffuseDiffuseCalculated) { - for(auto t_Side : EnumSide()) + EnumSide sides; + for(auto t_Side : sides) { - for(auto t_PropertySimple : EnumPropertySimple()) + EnumPropertySimple properties; + for(auto t_PropertySimple : properties) { m_DiffDiff(t_Side, t_PropertySimple) = integrate(getMatrix(t_Side, t_PropertySimple)); @@ -151,9 +155,11 @@ namespace SingleLayerOptics { if(!m_DirectHemisphericalCalculated) { - for(Side t_Side : EnumSide()) + EnumSide sides; + for(auto t_Side : sides) { - for(PropertySimple t_PropertySimple : EnumPropertySimple()) + EnumPropertySimple properties; + for(PropertySimple t_PropertySimple : properties) { m_DirectHemispherical[{t_Side, t_PropertySimple}] = m_Directions.lambdaVector() * m_Matrix.at({t_Side, t_PropertySimple}); @@ -164,7 +170,8 @@ namespace SingleLayerOptics const auto size = m_DirectHemispherical[{Side::Front, PropertySimple::T}].size(); for(size_t i = 0; i < size; ++i) { - for(Side t_Side : EnumSide()) + EnumSide sides; + for(auto t_Side : sides) { m_Abs.at(t_Side).push_back(1.0 - m_DirectHemispherical.at({t_Side, PropertySimple::T})[i] - m_DirectHemispherical.at({t_Side, PropertySimple::R})[i]); diff --git a/src/SingleLayerOptics/src/BSDFLayer.cpp b/src/SingleLayerOptics/src/BSDFLayer.cpp index ac96915e..832473a1 100644 --- a/src/SingleLayerOptics/src/BSDFLayer.cpp +++ b/src/SingleLayerOptics/src/BSDFLayer.cpp @@ -58,7 +58,8 @@ namespace SingleLayerOptics void CBSDFLayer::calculate_dir_dir_wl(size_t wavelengthIndex, BSDFIntegrator & results) { - for(Side aSide : EnumSide()) + EnumSide sides; + for(Side aSide : sides) { const auto & aDirections = m_BSDFHemisphere.getDirections(BSDFDirection::Incoming); size_t size = aDirections.size(); @@ -81,7 +82,8 @@ namespace SingleLayerOptics void CBSDFLayer::calculate_dir_dif_wv(size_t wavelengthIndex, BSDFIntegrator & results) { - for(Side aSide : EnumSide()) + EnumSide sides; + for(Side aSide : sides) { const auto & aDirections = m_BSDFHemisphere.getDirections(BSDFDirection::Incoming); @@ -110,7 +112,8 @@ namespace SingleLayerOptics void CBSDFLayer::calc_dir_dir() { - for(Side t_Side : EnumSide()) + EnumSide sides; + for(Side t_Side : sides) { BSDFDirections aDirections = m_BSDFHemisphere.getDirections(BSDFDirection::Incoming); size_t size = aDirections.size(); @@ -133,7 +136,8 @@ namespace SingleLayerOptics void CBSDFLayer::calc_dir_dir_wv(std::vector & results) { - for(Side aSide : EnumSide()) + EnumSide sides; + for(Side aSide : sides) { const auto & aDirections = m_BSDFHemisphere.getDirections(BSDFDirection::Incoming); size_t size = aDirections.size(); @@ -157,7 +161,8 @@ namespace SingleLayerOptics void CBSDFLayer::calc_dir_dif() { - for(Side aSide : EnumSide()) + EnumSide sides; + for(Side aSide : sides) { const auto & aDirections = m_BSDFHemisphere.getDirections(BSDFDirection::Incoming); @@ -172,7 +177,8 @@ namespace SingleLayerOptics void CBSDFLayer::calc_dir_dif_wv(std::vector & results) { - for(Side aSide : EnumSide()) + EnumSide sides; + for(Side aSide : sides) { const auto & aDirections = m_BSDFHemisphere.getDirections(BSDFDirection::Incoming); diff --git a/src/SingleLayerOptics/tst/units/SingleLayerOpticsUtilities.unit.cpp b/src/SingleLayerOptics/tst/units/SingleLayerOpticsUtilities.unit.cpp index 14978d3f..c47a6b4c 100644 --- a/src/SingleLayerOptics/tst/units/SingleLayerOpticsUtilities.unit.cpp +++ b/src/SingleLayerOptics/tst/units/SingleLayerOpticsUtilities.unit.cpp @@ -10,7 +10,8 @@ TEST_F(TestSingleLayerOpticsUtilities, BSDFDirectionEnumeration) { using SingleLayerOptics::BSDFDirection; std::vector directions; - for(const auto & direction : SingleLayerOptics::EnumBSDFDirection()) + SingleLayerOptics::EnumBSDFDirection dirs; + for(const auto & direction : dirs) { directions.emplace_back(direction); } diff --git a/src/SpectralAveraging/src/MeasuredSampleData.cpp b/src/SpectralAveraging/src/MeasuredSampleData.cpp index 1aab547f..ceba1208 100644 --- a/src/SpectralAveraging/src/MeasuredSampleData.cpp +++ b/src/SpectralAveraging/src/MeasuredSampleData.cpp @@ -40,9 +40,11 @@ namespace SpectralAveraging CSpectralSampleData::CSpectralSampleData() : SampleData(), m_absCalculated(false) { - for(const auto & prop : EnumProperty()) + EnumProperty props; + for(const auto & prop : props) { - for(const auto & side : EnumSide()) + EnumSide sides; + for(const auto & side : sides) { m_Property[std::make_pair(prop, side)] = CSeries(); } @@ -108,9 +110,11 @@ namespace SpectralAveraging // Interpolate current sample data to new wavelengths set void CSpectralSampleData::interpolate(std::vector const & t_Wavelengths) { - for(const auto & prop : EnumProperty()) + EnumProperty props; + for(const auto & prop : props) { - for(const auto & side : EnumSide()) + EnumSide sides; + for(const auto & side : sides) { m_Property[std::make_pair(prop, side)] = m_Property.at(std::make_pair(prop, side)).interpolate(t_Wavelengths); @@ -163,7 +167,8 @@ namespace SpectralAveraging void CSpectralSampleData::cutExtraData(const double minLambda, const double maxLambda) { - for(const auto & side : EnumSide()) + EnumSide sides; + for(const auto & side : sides) { m_Property.at(std::make_pair(Property::T, side)).cutExtraData(minLambda, maxLambda); m_Property.at(std::make_pair(Property::R, side)).cutExtraData(minLambda, maxLambda); @@ -208,7 +213,8 @@ namespace SpectralAveraging void PhotovoltaicSampleData::cutExtraData(double minLambda, double maxLambda) { CSpectralSampleData::cutExtraData(minLambda, maxLambda); - for(const auto & side : EnumSide()) + EnumSide sides; + for(const auto & side : sides) { m_EQE.at(side).cutExtraData(minLambda, maxLambda); } diff --git a/src/SpectralAveraging/src/SpectralSample.cpp b/src/SpectralAveraging/src/SpectralSample.cpp index 96b42a68..0a0dfc60 100644 --- a/src/SpectralAveraging/src/SpectralSample.cpp +++ b/src/SpectralAveraging/src/SpectralSample.cpp @@ -32,9 +32,11 @@ namespace SpectralAveraging m_StateCalculated = t_Sample.m_StateCalculated; m_WavelengthSet = t_Sample.m_WavelengthSet; m_IncomingSource = t_Sample.m_IncomingSource; - for(const auto & prop : EnumProperty()) + EnumProperty properties; + for(const auto & prop : properties) { - for(const auto & side : EnumSide()) + EnumSide sides; + for(const auto & side : sides) { m_EnergySource[std::make_pair(prop, side)] = t_Sample.m_EnergySource.at(std::make_pair(prop, side)); @@ -150,9 +152,11 @@ namespace SpectralAveraging { m_StateCalculated = false; m_IncomingSource = CSeries(); - for(const auto & prop : EnumProperty()) + EnumProperty properties; + for(const auto & prop : properties) { - for(const auto & side : EnumSide()) + EnumSide sides; + for(const auto & side : sides) { m_EnergySource[std::make_pair(prop, side)] = CSeries(); } @@ -185,9 +189,11 @@ namespace SpectralAveraging calculateProperties(integrator, normalizationCoefficient); m_IncomingSource = m_IncomingSource.integrate(integrator, normalizationCoefficient); - for(const auto & prop : EnumProperty()) + EnumProperty properties; + for(const auto & prop : properties) { - for(const auto & side : EnumSide()) + EnumSide sides; + for(const auto & side : sides) { m_EnergySource[std::make_pair(prop, side)] = m_EnergySource.at(std::make_pair(prop, side)) @@ -213,9 +219,11 @@ namespace SpectralAveraging throw std::runtime_error("Sample must have measured data."); } - for(const auto & prop : EnumProperty()) + EnumProperty properties; + for(const auto & prop : properties) { - for(const auto & side : EnumSide()) + EnumSide sides; + for(const auto & side : sides) { m_Property[std::make_pair(prop, side)] = CSeries(); } @@ -230,9 +238,11 @@ namespace SpectralAveraging throw std::runtime_error("Sample must have measured data."); } - for(const auto & prop : EnumProperty()) + EnumProperty properties; + for(const auto & prop : properties) { - for(const auto & side : EnumSide()) + EnumSide sides; + for(const auto & side : sides) { m_Property[std::make_pair(prop, side)] = CSeries(); } @@ -267,9 +277,11 @@ namespace SpectralAveraging { std::ignore = integrator; std::ignore = normalizationCoefficient; - for(const auto & prop : EnumProperty()) + EnumProperty properties; + for(const auto & prop : properties) { - for(const auto & side : EnumSide()) + EnumSide sides; + for(const auto & side : sides) { m_Property[std::make_pair(prop, side)] = m_SampleData->properties(prop, side); // No need to do interpolation if wavelength set is already from the data. @@ -287,9 +299,10 @@ namespace SpectralAveraging } // Calculation of energy balances - for(const auto & prop : EnumProperty()) + for(const auto & prop : properties) { - for(const auto & side : EnumSide()) + EnumSide sides; + for(const auto & side : sides) { m_EnergySource[std::make_pair(prop, side)] = m_Property.at(std::make_pair(prop, side)) * m_IncomingSource; @@ -304,9 +317,11 @@ namespace SpectralAveraging if(m_SourceData.size() == 0) { - for(const auto & prop : EnumProperty()) + EnumProperty properties; + for(const auto & prop : properties) { - for(const auto & side : EnumSide()) + EnumSide sides; + for(const auto & side : sides) { m_Property[{prop, side}] = m_SampleData->properties(prop, side); } @@ -346,7 +361,8 @@ namespace SpectralAveraging double normalizationCoefficient) { CSpectralSample::calculateProperties(integrator, normalizationCoefficient); - for(const auto & side : EnumSide()) + EnumSide sides; + for(const auto & side : sides) { CSeries eqe{getSample()->eqe(side)}; eqe = eqe.interpolate(m_Wavelengths); diff --git a/src/Tarcog/src/CMAWindow.cpp b/src/Tarcog/src/CMAWindow.cpp index 5a7875e9..7de5f3cc 100644 --- a/src/Tarcog/src/CMAWindow.cpp +++ b/src/Tarcog/src/CMAWindow.cpp @@ -171,9 +171,10 @@ namespace CMA void CMAWindowSingleVision::setFrameTop(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameTop(frameData); @@ -183,9 +184,10 @@ namespace CMA void CMAWindowSingleVision::setFrameBottom(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameBottom(frameData); @@ -195,9 +197,10 @@ namespace CMA void CMAWindowSingleVision::setFrameLeft(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameLeft(frameData); @@ -207,9 +210,10 @@ namespace CMA void CMAWindowSingleVision::setFrameRight(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameRight(frameData); @@ -221,9 +225,10 @@ namespace CMA size_t nHorizontal, size_t nVertical) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption) @@ -250,9 +255,10 @@ namespace CMA void CMAWindowDualVisionHorizontal::setFrameTopLeft(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameTopLeft(frameData); @@ -262,9 +268,10 @@ namespace CMA void CMAWindowDualVisionHorizontal::setFrameTopRight(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameTopRight(frameData); @@ -274,9 +281,10 @@ namespace CMA void CMAWindowDualVisionHorizontal::setFrameBottomLeft(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameBottomLeft(frameData); @@ -286,9 +294,10 @@ namespace CMA void CMAWindowDualVisionHorizontal::setFrameBottomRight(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameBottomRight(frameData); @@ -298,9 +307,10 @@ namespace CMA void CMAWindowDualVisionHorizontal::setFrameLeft(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameLeft(frameData); @@ -310,9 +320,10 @@ namespace CMA void CMAWindowDualVisionHorizontal::setFrameRight(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameRight(frameData); @@ -322,9 +333,10 @@ namespace CMA void CMAWindowDualVisionHorizontal::setFrameMeetingRail(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameMeetingRail(frameData); @@ -336,9 +348,10 @@ namespace CMA size_t nHorizontal, size_t nVertical) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption) @@ -434,9 +447,10 @@ namespace CMA void CMAWindowDualVisionVertical::setFrameTop(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameTop(frameData); @@ -446,9 +460,10 @@ namespace CMA void CMAWindowDualVisionVertical::setFrameBottom(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameBottom(frameData); @@ -458,9 +473,10 @@ namespace CMA void CMAWindowDualVisionVertical::setFrameTopLeft(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameTopLeft(frameData); @@ -470,9 +486,10 @@ namespace CMA void CMAWindowDualVisionVertical::setFrameTopRight(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameTopRight(frameData); @@ -482,9 +499,10 @@ namespace CMA void CMAWindowDualVisionVertical::setFrameBottomLeft(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameBottomLeft(frameData); @@ -494,9 +512,10 @@ namespace CMA void CMAWindowDualVisionVertical::setFrameBottomRight(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameBottomRight(frameData); @@ -506,9 +525,10 @@ namespace CMA void CMAWindowDualVisionVertical::setFrameMeetingRail(CMAFrame cmaFrameData) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption).at(glazingOption).setFrameMeetingRail(frameData); @@ -520,9 +540,10 @@ namespace CMA size_t nHorizontal, size_t nVertical) { - for(auto spacerOption : EnumOption()) + EnumOption options; + for(auto spacerOption : options) { - for(auto glazingOption : EnumOption()) + for(auto glazingOption : options) { const auto frameData = cmaFrameData.getFrame(spacerOption, glazingOption); m_Window.at(spacerOption) diff --git a/src/Tarcog/src/IGU.cpp b/src/Tarcog/src/IGU.cpp index 2fa2b49a..d3b19a81 100644 --- a/src/Tarcog/src/IGU.cpp +++ b/src/Tarcog/src/IGU.cpp @@ -50,7 +50,8 @@ namespace Tarcog::ISO15099 CIGU::~CIGU() { - for(std::shared_ptr layer : getSolidLayers()) + auto layers = getSolidLayers(); + for(std::shared_ptr layer : layers) { layer->tearDownConnections(); } @@ -147,7 +148,8 @@ namespace Tarcog::ISO15099 void CIGU::setSolarRadiation(double const t_SolarRadiation) const { - for(auto & layer : getSolidLayers()) + auto layers = getSolidLayers(); + for(auto & layer : layers) { layer->setSolarRadiation(t_SolarRadiation); } @@ -172,7 +174,8 @@ namespace Tarcog::ISO15099 { std::vector aState; - for(auto & layer : getSolidLayers()) + auto layers = getSolidLayers(); + for(auto & layer : layers) { // State must be filled in this exact order. aState.push_back(layer->surfaceTemperature(Side::Front)); @@ -187,7 +190,8 @@ namespace Tarcog::ISO15099 void CIGU::setState(const std::vector & t_State) const { size_t i = 0; - for(const auto & aLayer : getSolidLayers()) + auto layers = getSolidLayers(); + for(const auto & aLayer : layers) { const auto Tf = t_State[4 * i]; const auto Jf = t_State[4 * i + 1]; @@ -202,9 +206,11 @@ namespace Tarcog::ISO15099 { std::vector aTemperatures; - for(auto const & layer : getSolidLayers()) + auto layers = getSolidLayers(); + for(auto & layer : layers) { - for(auto aSide : FenestrationCommon::EnumSide()) + FenestrationCommon::EnumSide sides; + for(auto aSide : sides) { aTemperatures.push_back(layer->surfaceTemperature(aSide)); } @@ -217,9 +223,11 @@ namespace Tarcog::ISO15099 { std::vector aRadiosities; - for(auto const & layer : getSolidLayers()) + auto layers = getSolidLayers(); + for(auto & layer : layers) { - for(auto aSide : FenestrationCommon::EnumSide()) + FenestrationCommon::EnumSide sides; + for(auto aSide : sides) { aRadiosities.push_back(layer->J(aSide)); } @@ -232,7 +240,8 @@ namespace Tarcog::ISO15099 { std::vector aMaxDeflections; - for(auto const & layer : getSolidLayers()) + auto layers = getSolidLayers(); + for(auto & layer : layers) { aMaxDeflections.push_back(layer->getMaxDeflection()); } @@ -244,7 +253,8 @@ namespace Tarcog::ISO15099 { std::vector aMeanDeflections; - for(auto const & layer : getSolidLayers()) + auto layers = getSolidLayers(); + for(auto & layer : layers) { aMeanDeflections.push_back(layer->getMeanDeflection()); } @@ -255,8 +265,8 @@ namespace Tarcog::ISO15099 std::vector CIGU::getMaxGapWidth() const { std::vector aMaxWidths; - - for(auto const & layer : getGapLayers()) + auto gaps = getGapLayers(); + for(auto const & layer : gaps) { aMaxWidths.push_back(layer->getMaxDeflection()); } @@ -268,7 +278,8 @@ namespace Tarcog::ISO15099 { std::vector aMeanWidths; - for(auto const & layer : getGapLayers()) + auto gaps = getGapLayers(); + for(auto const & layer : gaps) { aMeanWidths.push_back(layer->getMeanDeflection()); } @@ -280,7 +291,8 @@ namespace Tarcog::ISO15099 { std::vector aPressures; - for(auto const & layer : getGapLayers()) + auto gaps = getGapLayers(); + for(auto const & layer : gaps) { aPressures.push_back(layer->getPressure()); } @@ -367,9 +379,11 @@ namespace Tarcog::ISO15099 else { size_t Index = 0; - for(auto & aLayer : getSolidLayers()) + auto layers = getSolidLayers(); + for(auto & aLayer : layers) { - for(auto aSide : FenestrationCommon::EnumSide()) + FenestrationCommon::EnumSide sides; + for(auto aSide : sides) { aLayer->initializeStart(aSide, t_Guess[Index]); ++Index; @@ -387,13 +401,15 @@ namespace Tarcog::ISO15099 // Since user might have called IGU previously with different deflection properties resetSurfaceDeflections(); std::vector layerData; - for(const auto & layer : getSolidLayers()) + auto layers = getSolidLayers(); + for(auto & layer : layers) { layerData.emplace_back(layer->getThickness(), layer->density(), layer->youngsModulus()); } std::vector gapData; - for(auto & gap : getGapLayers()) + auto gaps = getGapLayers(); + for(auto const & gap : gaps) { gap->setSealedGapProperties(t_Tini, t_Pini); gapData.emplace_back(gap->getThickness(), t_Tini, t_Pini); diff --git a/src/Tarcog/src/IGUSolidDeflection.cpp b/src/Tarcog/src/IGUSolidDeflection.cpp index 039fd0ab..26fd0896 100644 --- a/src/Tarcog/src/IGUSolidDeflection.cpp +++ b/src/Tarcog/src/IGUSolidDeflection.cpp @@ -59,7 +59,8 @@ namespace Tarcog::ISO15099 const double t_MaxDeflection) : CIGUSolidLayerDeflection(*t_Layer) { - for(Side aSide : FenestrationCommon::EnumSide()) + FenestrationCommon::EnumSide options; + for(Side aSide : options) { m_Surface[aSide]->applyDeflection(t_MeanDeflection, t_MaxDeflection); } diff --git a/src/Tarcog/src/IGUSolidLayer.cpp b/src/Tarcog/src/IGUSolidLayer.cpp index 4165d894..aff27c01 100644 --- a/src/Tarcog/src/IGUSolidLayer.cpp +++ b/src/Tarcog/src/IGUSolidLayer.cpp @@ -107,7 +107,8 @@ namespace Tarcog::ISO15099 void CIGUSolidLayer::applyDeflection(double meanDeflection, double maxDeflection) { - for(auto aSide : FenestrationCommon::EnumSide()) + FenestrationCommon::EnumSide sides; + for(auto aSide : sides) { m_Surface[aSide]->applyDeflection(meanDeflection, maxDeflection); } diff --git a/src/Tarcog/src/SingleSystem.cpp b/src/Tarcog/src/SingleSystem.cpp index 54a769c5..2614a323 100644 --- a/src/Tarcog/src/SingleSystem.cpp +++ b/src/Tarcog/src/SingleSystem.cpp @@ -272,7 +272,8 @@ namespace Tarcog::ISO15099 std::vector CSingleSystem::getSolidEffectiveLayerConductivities() const { std::vector results; - for(const auto & layer : getSolidLayers()) + auto layers = getSolidLayers(); + for(auto & layer : layers) { results.emplace_back(layer->getEffectiveThermalConductivity()); } @@ -282,7 +283,8 @@ namespace Tarcog::ISO15099 std::vector CSingleSystem::getGapEffectiveLayerConductivities() const { std::vector results; - for(const auto & layer : getGapLayers()) + auto gaps = getGapLayers(); + for(auto const & layer : gaps) { results.emplace_back(layer->getEffectiveThermalConductivity()); } @@ -299,11 +301,13 @@ namespace Tarcog::ISO15099 double CSingleSystem::thickness() const { double thickness{0}; - for(const auto & layer : getSolidLayers()) + auto layers = getSolidLayers(); + for(auto & layer : layers) { thickness += layer->getThickness(); } - for(const auto & gap : getGapLayers()) + auto gaps = getGapLayers(); + for(auto const & gap : gaps) { thickness += gap->getThickness(); } diff --git a/src/Tarcog/src/SurfacesManager.cpp b/src/Tarcog/src/SurfacesManager.cpp index 34548f80..84172c84 100644 --- a/src/Tarcog/src/SurfacesManager.cpp +++ b/src/Tarcog/src/SurfacesManager.cpp @@ -12,7 +12,8 @@ namespace Tarcog::ISO15099 SurfacesManager & SurfacesManager::operator=(const SurfacesManager & t_Layer) { - for(auto aSide : FenestrationCommon::EnumSide()) + FenestrationCommon::EnumSide sides; + for(auto aSide : sides) { const auto aSurface = t_Layer.m_Surface.at(aSide); if(aSurface != nullptr) diff --git a/src/Viewer/src/Geometry2DBeam.cpp b/src/Viewer/src/Geometry2DBeam.cpp index 38e7b5b4..6c5e0fd3 100755 --- a/src/Viewer/src/Geometry2DBeam.cpp +++ b/src/Viewer/src/Geometry2DBeam.cpp @@ -301,7 +301,8 @@ namespace Viewer totalHeight += beamRay.rayNormalHeight(); for(const auto & aEnclosure : m_Geometries2D) { - for(const auto & aSegment : aEnclosure.segments()) + auto segments = aEnclosure.segments(); + for(const auto & aSegment : segments) { beamRay.checkSegment(aSegment); }