From ea8639f523eee4fcc99f61fa22c3d1c2db5f25c5 Mon Sep 17 00:00:00 2001
From: Mikhail Svechnikov <m.svechnikov@fz-juelich.de>
Date: Mon, 11 Mar 2024 18:42:03 +0100
Subject: [PATCH] add comments

---
 Resample/Processed/ReSample.cpp | 5 +++--
 Resample/Slice/SliceStack.h     | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/Resample/Processed/ReSample.cpp b/Resample/Processed/ReSample.cpp
index 6163eef8e77..a6be39ca434 100644
--- a/Resample/Processed/ReSample.cpp
+++ b/Resample/Processed/ReSample.cpp
@@ -143,7 +143,7 @@ SliceStack slicify(const MultiLayer& sample, bool useAvgMaterials)
         const ZLimits& particle_span = particle_spans[i];
 
         // if no slicing is needed, create single slice for the layer
-        if (!particle_span.isFinite()) {
+        if (!particle_span.isFinite()) { // also if layer contains no particles
             if (i == nLayers - 1)
                 tl = 0.0;
             if (i == 0)
@@ -168,10 +168,11 @@ SliceStack slicify(const MultiLayer& sample, bool useAvgMaterials)
         }
         // middle or bottom layer
         else {
+            ASSERT(top <= 0);
             if (top < 0) {
                 result.addSlice(-top, *material, roughness);
                 result.addNSlices(nSlices, top - bottom, *material);
-            } else {
+            } else { // top == 0
                 result.addNSlices(nSlices, top - bottom, *material, roughness);
             }
             // middle layer
diff --git a/Resample/Slice/SliceStack.h b/Resample/Slice/SliceStack.h
index 958aba805e8..e2902274ef0 100644
--- a/Resample/Slice/SliceStack.h
+++ b/Resample/Slice/SliceStack.h
@@ -48,6 +48,8 @@ public:
 
     SliceStack setBField(const R3& externalField);
 
+    // the name "bottom roughness" refers to the normal top roughness of a slice, but from the point
+    // of view of the inverted stack used in the recurrence relation computation algorithm.
     const LayerRoughness* bottomRoughness(size_t i_slice) const;
 
     RoughnessModel roughnessModel() const { return m_roughness_model; }
-- 
GitLab