diff --git a/Sample/Multilayer/Layer.cpp b/Sample/Multilayer/Layer.cpp index 4981351563ae36c17ba1d93525c582996e9d15ad..86bc6aa2e44fc143fd296a87066841b3acee6bd5 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 c6dd7a5d61126667f2dc9946f593cc0bb94bfd5e..0b5513779142f9a20ea50ffcabb26b7306a009c5 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 };