BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
LayerInterface.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/Slice/LayerInterface.cpp
6 //! @brief Implements class LayerInterface.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
16 #include "Base/Types/Exceptions.h"
18 
19 LayerInterface::LayerInterface() : m_topLayer(nullptr), m_bottomLayer(nullptr)
20 {
21  setName("LayerInterface");
22 }
23 
25 
27 {
28  throw Exceptions::NotImplementedException("LayerInterface::clone() -> Not allowed to clone.");
29 }
30 
32  const Layer* bottom_layer)
33 {
34  LayerInterface* result = new LayerInterface();
35  result->setLayersTopBottom(top_layer, bottom_layer);
36  return result;
37 }
38 
40  const Layer* bottom_layer,
41  const LayerRoughness& roughness)
42 {
43  LayerInterface* result = createSmoothInterface(top_layer, bottom_layer);
44  result->setRoughness(roughness);
45  return result;
46 }
47 
49 {
50  m_roughness.reset(roughness.clone());
52 }
53 
54 std::vector<const INode*> LayerInterface::getChildren() const
55 {
56  return std::vector<const INode*>() << m_roughness;
57 }
58 
59 //! Sets links to the layers above and below the interface.
60 
61 void LayerInterface::setLayersTopBottom(const Layer* top_layer, const Layer* bottom_layer)
62 {
63  if (top_layer == nullptr || bottom_layer == nullptr)
64  throw Exceptions::RuntimeErrorException("LayerInterface::setLayersTopBottom() -> Error. "
65  "Attempt to set nullptr.");
66  m_topLayer = top_layer;
67  m_bottomLayer = bottom_layer;
68 }
Defines many exception classes in namespace Exceptionss.
Defines class LayerInterface.
Defines class LayerRoughness.
void registerChild(INode *node)
Definition: INode.cpp:58
void setName(const std::string &name)
Interface between two layers, possibly with roughness.
static LayerInterface * createRoughInterface(const Layer *top_layer, const Layer *bottom_layer, const LayerRoughness &roughness)
Creates rough interface between two layers.
LayerInterface * clone() const
Returns a clone of this ISample object.
static LayerInterface * createSmoothInterface(const Layer *top_layer, const Layer *bottom_layer)
Creates smooth interface between two layers.
virtual ~LayerInterface()
void setLayersTopBottom(const Layer *top_layer, const Layer *bottom_layer)
Sets links to the layers above and below the interface.
std::vector< const INode * > getChildren() const
Returns a vector of children (const).
std::unique_ptr< LayerRoughness > m_roughness
roughness of the interface
const Layer * m_bottomLayer
pointer to the layer below interface
void setRoughness(const LayerRoughness &roughness)
Sets roughness of the interface.
const Layer * m_topLayer
pointer to the layer above interface
A roughness of interface between two layers.
LayerRoughness * clone() const
Returns a clone of this ISample object.
A layer, with thickness (in nanometer) and material.
Definition: Layer.h:28