From 6d614dd364a3134076f05941ab9d8dbf6547d275 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 2 Nov 2020 17:09:27 +0100
Subject: [PATCH] various little simplifications

---
 Core/Computation/ParticleLayoutComputation.cpp | 15 ++++++---------
 Core/Computation/ParticleLayoutComputation.h   |  3 +--
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/Core/Computation/ParticleLayoutComputation.cpp b/Core/Computation/ParticleLayoutComputation.cpp
index 4df104ffc71..0a0b7e0ee24 100644
--- a/Core/Computation/ParticleLayoutComputation.cpp
+++ b/Core/Computation/ParticleLayoutComputation.cpp
@@ -22,24 +22,21 @@ ParticleLayoutComputation::ParticleLayoutComputation(const ProcessedLayout* p_la
                                                      const SimulationOptions& options,
                                                      bool polarized)
     : m_layout(p_layout)
+    , m_region_map(p_layout->regionMap())
 {
     LayoutStrategyBuilder builder(p_layout, options, polarized);
     m_strategy.reset(builder.releaseStrategy());
-    m_region_map = p_layout->regionMap();
-    m_surface_density = p_layout->surfaceDensity();
 }
 
 ParticleLayoutComputation::~ParticleLayoutComputation() = default;
 
 void ParticleLayoutComputation::compute(SimulationElement& elem) const
 {
-    double alpha_f = elem.getAlphaMean();
-    size_t n_layers = m_layout->numberOfSlices();
-    if (n_layers > 1 && alpha_f < 0) {
-        return; // zero for transmission with multilayers (n>1)
-    } else {
-        elem.addIntensity(m_strategy->evaluate(elem) * m_surface_density);
-    }
+    const double alpha_f = elem.getAlphaMean();
+    const size_t n_layers = m_layout->numberOfSlices();
+    if (n_layers > 1 && alpha_f < 0)
+        return; // zero for transmission with multilayers (n>1) # TODO: support transmission GISAS
+    elem.addIntensity(m_strategy->evaluate(elem) * m_layout->surfaceDensity());
 }
 
 void ParticleLayoutComputation::mergeRegionMap(
diff --git a/Core/Computation/ParticleLayoutComputation.h b/Core/Computation/ParticleLayoutComputation.h
index 3380b36c737..bd25b1f59d1 100644
--- a/Core/Computation/ParticleLayoutComputation.h
+++ b/Core/Computation/ParticleLayoutComputation.h
@@ -44,8 +44,7 @@ public:
 private:
     const ProcessedLayout* m_layout;
     std::unique_ptr<const IInterferenceFunctionStrategy> m_strategy;
-    double m_surface_density;
-    std::map<size_t, std::vector<HomogeneousRegion>> m_region_map;
+    const std::map<size_t, std::vector<HomogeneousRegion>> m_region_map;
 };
 
 #endif // BORNAGAIN_CORE_COMPUTATION_PARTICLELAYOUTCOMPUTATION_H
-- 
GitLab