Commit 742bf0dc authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

ISimulation2D::m_eles now private

parent 004944cb
Pipeline #67046 passed with stage
in 5 minutes and 47 seconds
...@@ -97,7 +97,6 @@ protected: ...@@ -97,7 +97,6 @@ protected:
std::unique_ptr<Beam> m_beam; std::unique_ptr<Beam> m_beam;
std::unique_ptr<IDetector> m_detector; std::unique_ptr<IDetector> m_detector;
std::vector<std::unique_ptr<DiffuseElement>> m_eles;
std::vector<double> m_cache; std::vector<double> m_cache;
std::vector<std::unique_ptr<DiffuseElement>>& elements(); std::vector<std::unique_ptr<DiffuseElement>>& elements();
...@@ -105,6 +104,7 @@ protected: ...@@ -105,6 +104,7 @@ protected:
void element_emplace_back(std::unique_ptr<DiffuseElement>&&); void element_emplace_back(std::unique_ptr<DiffuseElement>&&);
private: private:
std::vector<std::unique_ptr<DiffuseElement>> m_eles;
std::unique_ptr<DetectorContext> m_detector_context; std::unique_ptr<DetectorContext> m_detector_context;
#endif // SWIG #endif // SWIG
}; };
......
...@@ -54,7 +54,7 @@ SimulationResult OffspecSimulation::pack_result() ...@@ -54,7 +54,7 @@ SimulationResult OffspecSimulation::pack_result()
checkInitialization(); checkInitialization();
const IAxis& phi_axis = detector().axis(0); const IAxis& phi_axis = detector().axis(0);
size_t phi_f_size = phi_axis.size(); size_t phi_f_size = phi_axis.size();
ASSERT(phi_f_size * m_intensity_map->size() == m_eles.size()); ASSERT(phi_f_size * m_intensity_map->size() == elements().size());
for (size_t i = 0; i < m_alpha_i_axis->size(); ++i) for (size_t i = 0; i < m_alpha_i_axis->size(); ++i)
transferDetectorImage(i); transferDetectorImage(i);
...@@ -96,7 +96,7 @@ size_t OffspecSimulation::intensityMapSize() const ...@@ -96,7 +96,7 @@ size_t OffspecSimulation::intensityMapSize() const
void OffspecSimulation::initElementVector() void OffspecSimulation::initElementVector()
{ {
m_eles.clear(); elements().clear();
Beam beam2 = beam(); Beam beam2 = beam();
for (size_t i = 0; i < m_alpha_i_axis->size(); ++i) { for (size_t i = 0; i < m_alpha_i_axis->size(); ++i) {
beam2.setInclination(m_alpha_i_axis->bin(i).center()); beam2.setInclination(m_alpha_i_axis->bin(i).center());
...@@ -105,7 +105,7 @@ void OffspecSimulation::initElementVector() ...@@ -105,7 +105,7 @@ void OffspecSimulation::initElementVector()
element_emplace_back(std::move(ele)); element_emplace_back(std::move(ele));
} }
if (m_cache.empty()) if (m_cache.empty())
m_cache.resize(m_eles.size(), 0.0); m_cache.resize(elements().size(), 0.0);
} }
void OffspecSimulation::validateParametrization(const ParameterDistribution& par_distr) const void OffspecSimulation::validateParametrization(const ParameterDistribution& par_distr) const
...@@ -145,7 +145,7 @@ void OffspecSimulation::transferDetectorImage(size_t index) ...@@ -145,7 +145,7 @@ void OffspecSimulation::transferDetectorImage(size_t index)
size_t N = detector_image->size(); size_t N = detector_image->size();
for (size_t i = 0; i < N; ++i) for (size_t i = 0; i < N; ++i)
(*detector_image)[i] = m_eles[index * N + i]->intensity(); (*detector_image)[i] = elements()[index * N + i]->intensity();
detector().applyDetectorResolution(detector_image.get()); detector().applyDetectorResolution(detector_image.get());
size_t y_axis_size = detector().axis(1).size(); size_t y_axis_size = detector().axis(1).size();
for (size_t i = 0; i < N; ++i) for (size_t i = 0; i < N; ++i)
......
...@@ -38,7 +38,7 @@ void ScatteringSimulation::prepareSimulation() ...@@ -38,7 +38,7 @@ void ScatteringSimulation::prepareSimulation()
SimulationResult ScatteringSimulation::pack_result() SimulationResult ScatteringSimulation::pack_result()
{ {
auto* const coordsys = createCoordSystem(); auto* const coordsys = createCoordSystem();
const std::unique_ptr<Datafield> data(detector().createDetectorIntensity(m_eles)); const std::unique_ptr<Datafield> data(detector().createDetectorIntensity(elements()));
return {*data, *coordsys}; return {*data, *coordsys};
} }
...@@ -61,9 +61,10 @@ ICoordSystem* ScatteringSimulation::createCoordSystem() const ...@@ -61,9 +61,10 @@ ICoordSystem* ScatteringSimulation::createCoordSystem() const
void ScatteringSimulation::initElementVector() void ScatteringSimulation::initElementVector()
{ {
elements().clear();
for (auto& ele: generateElements(beam())) for (auto& ele: generateElements(beam()))
element_emplace_back(std::move(ele)); element_emplace_back(std::move(ele));
if (m_cache.empty()) if (m_cache.empty())
m_cache.resize(m_eles.size(), 0.0); m_cache.resize(elements().size(), 0.0);
} }
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