Commit 21610b38 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

disambiguate DepthProbeSimulation::m_depth_eles from ISimulation2D::m_eles

parent 0539cc17
...@@ -135,11 +135,11 @@ void DepthProbeSimulation::setBeamParameters(double lambda, const IAxis& alpha_a ...@@ -135,11 +135,11 @@ void DepthProbeSimulation::setBeamParameters(double lambda, const IAxis& alpha_a
void DepthProbeSimulation::initElementVector() void DepthProbeSimulation::initElementVector()
{ {
m_eles = generateElements(beam()); m_depth_eles = generateElements(beam());
if (!m_cache.empty()) if (!m_cache.empty())
return; return;
m_cache.resize(m_eles.size(), std::valarray<double>(0.0, zAxis()->size())); m_cache.resize(m_depth_eles.size(), std::valarray<double>(0.0, zAxis()->size()));
} }
std::vector<DepthProbeElement> DepthProbeSimulation::generateElements(const Beam& beam) std::vector<DepthProbeElement> DepthProbeSimulation::generateElements(const Beam& beam)
...@@ -163,8 +163,8 @@ std::vector<DepthProbeElement> DepthProbeSimulation::generateElements(const Beam ...@@ -163,8 +163,8 @@ std::vector<DepthProbeElement> DepthProbeSimulation::generateElements(const Beam
std::unique_ptr<IComputation> std::unique_ptr<IComputation>
DepthProbeSimulation::createComputation(const reSample& re_sample, size_t start, size_t n_elements) DepthProbeSimulation::createComputation(const reSample& re_sample, size_t start, size_t n_elements)
{ {
ASSERT(start < m_eles.size() && start + n_elements <= m_eles.size()); ASSERT(start < m_depth_eles.size() && start + n_elements <= m_depth_eles.size());
const auto& begin = m_eles.begin() + static_cast<long>(start); const auto& begin = m_depth_eles.begin() + static_cast<long>(start);
return std::make_unique<DepthProbeComputation>(re_sample, options(), progress(), begin, return std::make_unique<DepthProbeComputation>(re_sample, options(), progress(), begin,
begin + static_cast<long>(n_elements)); begin + static_cast<long>(n_elements));
} }
...@@ -176,7 +176,7 @@ void DepthProbeSimulation::validityCheck() const ...@@ -176,7 +176,7 @@ void DepthProbeSimulation::validityCheck() const
throw std::runtime_error( throw std::runtime_error(
"Error in DepthProbeSimulation::validityCheck: no sample found in the simulation."); "Error in DepthProbeSimulation::validityCheck: no sample found in the simulation.");
const size_t data_size = m_eles.size(); const size_t data_size = m_depth_eles.size();
if (data_size != alphaAxis()->size()) if (data_size != alphaAxis()->size())
throw std::runtime_error( throw std::runtime_error(
"Error in DepthProbeSimulation::validityCheck: length of simulation " "Error in DepthProbeSimulation::validityCheck: length of simulation "
...@@ -185,7 +185,7 @@ void DepthProbeSimulation::validityCheck() const ...@@ -185,7 +185,7 @@ void DepthProbeSimulation::validityCheck() const
void DepthProbeSimulation::checkCache() const void DepthProbeSimulation::checkCache() const
{ {
if (m_eles.size() != m_cache.size()) if (m_depth_eles.size() != m_cache.size())
throw std::runtime_error("Error in DepthProbeSimulation: the sizes of simulation element " throw std::runtime_error("Error in DepthProbeSimulation: the sizes of simulation element "
"vector and of its cache are different"); "vector and of its cache are different");
} }
...@@ -206,7 +206,7 @@ void DepthProbeSimulation::normalize(size_t start_ind, size_t n_elements) ...@@ -206,7 +206,7 @@ void DepthProbeSimulation::normalize(size_t start_ind, size_t n_elements)
{ {
const double beam_intensity = beam().intensity(); const double beam_intensity = beam().intensity();
for (size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) { for (size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) {
auto& element = m_eles[i]; auto& element = m_depth_eles[i];
const double alpha_i = -element.alphaI(); const double alpha_i = -element.alphaI();
const auto* footprint = beam().footprintFactor(); const auto* footprint = beam().footprintFactor();
double intensity_factor = beam_intensity; double intensity_factor = beam_intensity;
...@@ -226,15 +226,15 @@ void DepthProbeSimulation::addBackgroundIntensity(size_t, size_t) ...@@ -226,15 +226,15 @@ void DepthProbeSimulation::addBackgroundIntensity(size_t, size_t)
void DepthProbeSimulation::addDataToCache(double weight) void DepthProbeSimulation::addDataToCache(double weight)
{ {
checkCache(); checkCache();
for (size_t i = 0, size = m_eles.size(); i < size; ++i) for (size_t i = 0, size = m_depth_eles.size(); i < size; ++i)
m_cache[i] += m_eles[i].getIntensities() * weight; m_cache[i] += m_depth_eles[i].getIntensities() * weight;
} }
void DepthProbeSimulation::moveDataFromCache() void DepthProbeSimulation::moveDataFromCache()
{ {
checkCache(); checkCache();
for (size_t i = 0, size = m_eles.size(); i < size; ++i) for (size_t i = 0, size = m_depth_eles.size(); i < size; ++i)
m_eles[i].setIntensities(std::move(m_cache[i])); m_depth_eles[i].setIntensities(std::move(m_cache[i]));
m_cache.clear(); m_cache.clear();
m_cache.shrink_to_fit(); m_cache.shrink_to_fit();
} }
...@@ -250,8 +250,8 @@ std::unique_ptr<Datafield> DepthProbeSimulation::createIntensityData() const ...@@ -250,8 +250,8 @@ std::unique_ptr<Datafield> DepthProbeSimulation::createIntensityData() const
std::vector<double> out(frame->size()); std::vector<double> out(frame->size());
size_t iout = 0; size_t iout = 0;
for (size_t i = 0, size = m_eles.size(); i < size; ++i) for (size_t i = 0, size = m_depth_eles.size(); i < size; ++i)
for (const double v: m_eles[i].getIntensities()) for (const double v: m_depth_eles[i].getIntensities())
out[iout++] = v; out[iout++] = v;
return std::unique_ptr<Datafield>(new Datafield(frame, out)); return std::unique_ptr<Datafield>(new Datafield(frame, out));
......
...@@ -114,7 +114,7 @@ private: ...@@ -114,7 +114,7 @@ private:
std::unique_ptr<IAxis> m_alpha_axis; std::unique_ptr<IAxis> m_alpha_axis;
std::unique_ptr<IAxis> m_z_axis; std::unique_ptr<IAxis> m_z_axis;
std::vector<DepthProbeElement> m_eles; std::vector<DepthProbeElement> m_depth_eles; // TODO remerge with ISimulation2D::m_eles
std::vector<std::valarray<double>> m_cache; std::vector<std::valarray<double>> m_cache;
#endif #endif
}; };
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment