From 797a05fd96b7ad270642eb62530f18978d7782b4 Mon Sep 17 00:00:00 2001
From: Mikhail Svechnikov <m.svechnikov@fz-juelich.de>
Date: Tue, 24 Sep 2024 14:41:26 +0200
Subject: [PATCH] comment zeroRoughness

---
 Sample/Multilayer/Layer.cpp | 3 +++
 Sample/Multilayer/Layer.h   | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/Sample/Multilayer/Layer.cpp b/Sample/Multilayer/Layer.cpp
index 4981351563a..86bc6aa2e44 100644
--- a/Sample/Multilayer/Layer.cpp
+++ b/Sample/Multilayer/Layer.cpp
@@ -38,6 +38,9 @@ Layer::Layer(const Material& material, double thickness, const LayerRoughness* r
     , m_thickness(thickness)
     , m_roughness(roughness ? roughness->clone() : zeroRoughness())
 {
+    // If the roughness is not defined by user, it is equivalent to the situation when roughness is
+    // defined, but has zero rms. To avoid constant nullptr checks in the code and to ease
+    // resampling it was accepted that "Layer" should always have non-null roughness descriptor.
     ASSERT(m_roughness);
     if (thickness < 0.)
         throw std::runtime_error("Layer contructor called with negative thickness");
diff --git a/Sample/Multilayer/Layer.h b/Sample/Multilayer/Layer.h
index c6dd7a5d611..0b551377914 100644
--- a/Sample/Multilayer/Layer.h
+++ b/Sample/Multilayer/Layer.h
@@ -75,7 +75,7 @@ private:
     R3 m_B_field;                                      //!< cached value of magnetic induction
     double m_thickness;                                //!< layer thickness in nanometers
     OwningVector<ParticleLayout> m_layouts;            //!< independent layouts in this layer
-    std::unique_ptr<const LayerRoughness> m_roughness; //!< roughness of the top interface
+    std::unique_ptr<const LayerRoughness> m_roughness; //!< roughness of the top surface. Never null
     unsigned int m_n_slices = 1; //!< number of slices to create for graded layer approach
 #endif                           // SWIG
 };
-- 
GitLab