diff --git a/Device/Scan/AngularSpecScan.cpp b/Device/Scan/AngularSpecScan.cpp index 81a97a364e1571cab66df37d916961c3a1bf605b..ea406befa2ccd0794f7168b51aafd5e17631e098 100644 --- a/Device/Scan/AngularSpecScan.cpp +++ b/Device/Scan/AngularSpecScan.cpp @@ -94,9 +94,8 @@ std::vector<SpecularSimulationElement> AngularSpecScan::generateSimulationElemen const double inc = incs[i][k]; for (size_t j = 0, size_wls = wls[i].size(); j < size_wls; ++j) { const double wl = wls[i][j]; - result.emplace_back(SpecularSimulationElement(wl, -inc)); - if (wl < 0 || inc < 0 || inc > M_PI_2) - result.back().setCalculationFlag(false); // false = exclude from calculations + result.emplace_back(SpecularSimulationElement(wl, -inc, + wl>=0 && inc>=0 && inc<=M_PI_2)); } } } diff --git a/Device/Scan/QSpecScan.cpp b/Device/Scan/QSpecScan.cpp index 1b264b1fc2e2fdbfed72d72199466bbf247e6f22..48dbb8d956e880304f52d2e59ee9b427347f21c7 100644 --- a/Device/Scan/QSpecScan.cpp +++ b/Device/Scan/QSpecScan.cpp @@ -55,16 +55,12 @@ QSpecScan* QSpecScan::clone() const //! Generates simulation elements for specular simulations std::vector<SpecularSimulationElement> QSpecScan::generateSimulationElements() const { - std::vector<SpecularSimulationElement> result; const std::vector<double> qz = generateQzVector(); + std::vector<SpecularSimulationElement> result; result.reserve(qz.size()); - for (size_t i = 0, size = qz.size(); i < size; ++i) { - result.emplace_back(SpecularSimulationElement(-qz[i] / 2.0)); - if (qz[i] < 0) - result.back().setCalculationFlag(false); // false = exclude from calculations - } - + for (size_t i = 0, size = qz.size(); i < size; ++i) + result.emplace_back(SpecularSimulationElement(-qz[i] / 2.0, qz[i]>=0)); return result; } diff --git a/Sample/Slice/SpecularSimulationElement.cpp b/Sample/Slice/SpecularSimulationElement.cpp index 9ae1b1b8c9887d7f3657966a8a335dc632beb3ce..1c1b529ca9af16e26989f328ad9c3102b8df9b7b 100644 --- a/Sample/Slice/SpecularSimulationElement.cpp +++ b/Sample/Slice/SpecularSimulationElement.cpp @@ -15,16 +15,16 @@ #include "Sample/Slice/SpecularSimulationElement.h" #include "Sample/Slice/KzComputation.h" -SpecularSimulationElement::SpecularSimulationElement(double kz) - : m_intensity(0.0), m_calculation_flag(true), +SpecularSimulationElement::SpecularSimulationElement(double kz, bool computable) + : m_intensity(0.0), m_computable(computable), m_kz_computation([kz](const std::vector<Slice>& slices) { return KzComputation::computeKzFromSLDs(slices, kz); }) { } -SpecularSimulationElement::SpecularSimulationElement(double wavelength, double alpha) - : m_intensity(0.0), m_calculation_flag(true), +SpecularSimulationElement::SpecularSimulationElement(double wavelength, double alpha, bool computable) + : m_intensity(0.0), m_computable(computable), m_kz_computation( [k = vecOfLambdaAlphaPhi(wavelength, alpha, 0.0)](const std::vector<Slice>& slices) { return KzComputation::computeKzFromRefIndices(slices, k); @@ -34,13 +34,13 @@ SpecularSimulationElement::SpecularSimulationElement(double wavelength, double a SpecularSimulationElement::SpecularSimulationElement(const SpecularSimulationElement& other) : m_polarization(other.m_polarization), m_intensity(other.m_intensity), - m_calculation_flag(other.m_calculation_flag), m_kz_computation(other.m_kz_computation) + m_computable(other.m_computable), m_kz_computation(other.m_kz_computation) { } SpecularSimulationElement::SpecularSimulationElement(SpecularSimulationElement&& other) noexcept : m_polarization(std::move(other.m_polarization)), m_intensity(other.m_intensity), - m_calculation_flag(other.m_calculation_flag), + m_computable(other.m_computable), m_kz_computation(std::move(other.m_kz_computation)) { } @@ -71,6 +71,5 @@ void SpecularSimulationElement::swapContent(SpecularSimulationElement& other) { m_polarization.swapContent(other.m_polarization); std::swap(m_intensity, other.m_intensity); - std::swap(m_calculation_flag, other.m_calculation_flag); m_kz_computation.swap(other.m_kz_computation); } diff --git a/Sample/Slice/SpecularSimulationElement.h b/Sample/Slice/SpecularSimulationElement.h index 41896cb4826a7c5e3e6b857c0f170cfeb3a887cb..c3c31758700f608b5d12841a6fac8cc62739e4af 100644 --- a/Sample/Slice/SpecularSimulationElement.h +++ b/Sample/Slice/SpecularSimulationElement.h @@ -29,8 +29,8 @@ class Slice; class SpecularSimulationElement { public: - SpecularSimulationElement(double kz); - SpecularSimulationElement(double wavelength, double alpha); + SpecularSimulationElement(double kz, bool computable); + SpecularSimulationElement(double wavelength, double alpha, bool computable); SpecularSimulationElement(const SpecularSimulationElement& other); SpecularSimulationElement(SpecularSimulationElement&& other) noexcept; @@ -48,9 +48,8 @@ public: double getIntensity() const { return m_intensity; } void setIntensity(double intensity) { m_intensity = intensity; } - //! Set calculation flag (if it's false, zero intensity is assigned to the element) - void setCalculationFlag(bool calculation_flag) { m_calculation_flag = calculation_flag; } - bool isCalculated() const { return m_calculation_flag; } + //! Returns calculation flag (if it's false, zero intensity is assigned to the element) + bool isCalculated() const { return m_computable; } //! Returns kz values for Abeles computation of reflection/transition coefficients std::vector<complex_t> produceKz(const std::vector<Slice>& slices); @@ -60,7 +59,7 @@ private: PolarizationHandler m_polarization; double m_intensity; //!< simulated intensity for detector cell - bool m_calculation_flag; + const bool m_computable; std::function<std::vector<complex_t>(const std::vector<Slice>&)> m_kz_computation; };