Skip to content
Snippets Groups Projects
Commit 57e9242e authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

.. member m_computable: renamed, and made const

parent faf42125
No related branches found
No related tags found
No related merge requests found
...@@ -94,9 +94,8 @@ std::vector<SpecularSimulationElement> AngularSpecScan::generateSimulationElemen ...@@ -94,9 +94,8 @@ std::vector<SpecularSimulationElement> AngularSpecScan::generateSimulationElemen
const double inc = incs[i][k]; const double inc = incs[i][k];
for (size_t j = 0, size_wls = wls[i].size(); j < size_wls; ++j) { for (size_t j = 0, size_wls = wls[i].size(); j < size_wls; ++j) {
const double wl = wls[i][j]; const double wl = wls[i][j];
result.emplace_back(SpecularSimulationElement(wl, -inc)); result.emplace_back(SpecularSimulationElement(wl, -inc,
if (wl < 0 || inc < 0 || inc > M_PI_2) wl>=0 && inc>=0 && inc<=M_PI_2));
result.back().setCalculationFlag(false); // false = exclude from calculations
} }
} }
} }
......
...@@ -55,16 +55,12 @@ QSpecScan* QSpecScan::clone() const ...@@ -55,16 +55,12 @@ QSpecScan* QSpecScan::clone() const
//! Generates simulation elements for specular simulations //! Generates simulation elements for specular simulations
std::vector<SpecularSimulationElement> QSpecScan::generateSimulationElements() const std::vector<SpecularSimulationElement> QSpecScan::generateSimulationElements() const
{ {
std::vector<SpecularSimulationElement> result;
const std::vector<double> qz = generateQzVector(); const std::vector<double> qz = generateQzVector();
std::vector<SpecularSimulationElement> result;
result.reserve(qz.size()); result.reserve(qz.size());
for (size_t i = 0, size = qz.size(); i < size; ++i) { for (size_t i = 0, size = qz.size(); i < size; ++i)
result.emplace_back(SpecularSimulationElement(-qz[i] / 2.0)); result.emplace_back(SpecularSimulationElement(-qz[i] / 2.0, qz[i]>=0));
if (qz[i] < 0)
result.back().setCalculationFlag(false); // false = exclude from calculations
}
return result; return result;
} }
......
...@@ -15,16 +15,16 @@ ...@@ -15,16 +15,16 @@
#include "Sample/Slice/SpecularSimulationElement.h" #include "Sample/Slice/SpecularSimulationElement.h"
#include "Sample/Slice/KzComputation.h" #include "Sample/Slice/KzComputation.h"
SpecularSimulationElement::SpecularSimulationElement(double kz) SpecularSimulationElement::SpecularSimulationElement(double kz, bool computable)
: m_intensity(0.0), m_calculation_flag(true), : m_intensity(0.0), m_computable(computable),
m_kz_computation([kz](const std::vector<Slice>& slices) { m_kz_computation([kz](const std::vector<Slice>& slices) {
return KzComputation::computeKzFromSLDs(slices, kz); return KzComputation::computeKzFromSLDs(slices, kz);
}) })
{ {
} }
SpecularSimulationElement::SpecularSimulationElement(double wavelength, double alpha) SpecularSimulationElement::SpecularSimulationElement(double wavelength, double alpha, bool computable)
: m_intensity(0.0), m_calculation_flag(true), : m_intensity(0.0), m_computable(computable),
m_kz_computation( m_kz_computation(
[k = vecOfLambdaAlphaPhi(wavelength, alpha, 0.0)](const std::vector<Slice>& slices) { [k = vecOfLambdaAlphaPhi(wavelength, alpha, 0.0)](const std::vector<Slice>& slices) {
return KzComputation::computeKzFromRefIndices(slices, k); return KzComputation::computeKzFromRefIndices(slices, k);
...@@ -34,13 +34,13 @@ SpecularSimulationElement::SpecularSimulationElement(double wavelength, double a ...@@ -34,13 +34,13 @@ SpecularSimulationElement::SpecularSimulationElement(double wavelength, double a
SpecularSimulationElement::SpecularSimulationElement(const SpecularSimulationElement& other) SpecularSimulationElement::SpecularSimulationElement(const SpecularSimulationElement& other)
: m_polarization(other.m_polarization), m_intensity(other.m_intensity), : 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 SpecularSimulationElement::SpecularSimulationElement(SpecularSimulationElement&& other) noexcept
: m_polarization(std::move(other.m_polarization)), m_intensity(other.m_intensity), : 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)) m_kz_computation(std::move(other.m_kz_computation))
{ {
} }
...@@ -71,6 +71,5 @@ void SpecularSimulationElement::swapContent(SpecularSimulationElement& other) ...@@ -71,6 +71,5 @@ void SpecularSimulationElement::swapContent(SpecularSimulationElement& other)
{ {
m_polarization.swapContent(other.m_polarization); m_polarization.swapContent(other.m_polarization);
std::swap(m_intensity, other.m_intensity); std::swap(m_intensity, other.m_intensity);
std::swap(m_calculation_flag, other.m_calculation_flag);
m_kz_computation.swap(other.m_kz_computation); m_kz_computation.swap(other.m_kz_computation);
} }
...@@ -29,8 +29,8 @@ class Slice; ...@@ -29,8 +29,8 @@ class Slice;
class SpecularSimulationElement class SpecularSimulationElement
{ {
public: public:
SpecularSimulationElement(double kz); SpecularSimulationElement(double kz, bool computable);
SpecularSimulationElement(double wavelength, double alpha); SpecularSimulationElement(double wavelength, double alpha, bool computable);
SpecularSimulationElement(const SpecularSimulationElement& other); SpecularSimulationElement(const SpecularSimulationElement& other);
SpecularSimulationElement(SpecularSimulationElement&& other) noexcept; SpecularSimulationElement(SpecularSimulationElement&& other) noexcept;
...@@ -48,9 +48,8 @@ public: ...@@ -48,9 +48,8 @@ public:
double getIntensity() const { return m_intensity; } double getIntensity() const { return m_intensity; }
void setIntensity(double intensity) { m_intensity = intensity; } void setIntensity(double intensity) { m_intensity = intensity; }
//! Set calculation flag (if it's false, zero intensity is assigned to the element) //! Returns 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_computable; }
bool isCalculated() const { return m_calculation_flag; }
//! Returns kz values for Abeles computation of reflection/transition coefficients //! Returns kz values for Abeles computation of reflection/transition coefficients
std::vector<complex_t> produceKz(const std::vector<Slice>& slices); std::vector<complex_t> produceKz(const std::vector<Slice>& slices);
...@@ -60,7 +59,7 @@ private: ...@@ -60,7 +59,7 @@ private:
PolarizationHandler m_polarization; PolarizationHandler m_polarization;
double m_intensity; //!< simulated intensity for detector cell 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; std::function<std::vector<complex_t>(const std::vector<Slice>&)> m_kz_computation;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment