Skip to content
Snippets Groups Projects
Commit 7ccdf763 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

LayerInterface always has non-nullptr roughness

parent 485a7141
No related branches found
No related tags found
1 merge request!2710Use non-nullptr LayerRoughness to distinguish between real layer interfaces and automated slice interfaces
......@@ -16,10 +16,15 @@
#include "Base/Util/Assert.h"
#include "Sample/Interface/LayerRoughness.h"
LayerInterface::LayerInterface()
: m_top_layer(nullptr)
, m_bottom_layer(nullptr)
LayerInterface::LayerInterface(const Layer* top_layer, const Layer* bottom_layer,
const LayerRoughness* layerRoughness)
: m_top_layer(top_layer)
, m_bottom_layer(bottom_layer)
, m_roughness(layerRoughness)
{
ASSERT(top_layer);
ASSERT(bottom_layer);
ASSERT(layerRoughness);
}
LayerInterface::~LayerInterface() = default;
......@@ -29,35 +34,11 @@ LayerInterface* LayerInterface::clone() const
throw std::runtime_error("LayerInterface::clone -> Not allowed to clone.");
}
LayerInterface* LayerInterface::createInterface(const Layer* top_layer, const Layer* bottom_layer,
const LayerRoughness* roughness)
{
auto* result = new LayerInterface();
result->setLayersTopBottom(top_layer, bottom_layer);
if (roughness)
result->setRoughness(roughness);
return result;
}
void LayerInterface::setRoughness(const LayerRoughness* roughness)
{
m_roughness.reset(roughness);
}
std::vector<const INode*> LayerInterface::nodeChildren() const
{
return std::vector<const INode*>() << m_roughness;
}
//! Sets links to the layers above and below the interface.
void LayerInterface::setLayersTopBottom(const Layer* top_layer, const Layer* bottom_layer)
{
ASSERT(top_layer && bottom_layer);
m_top_layer = top_layer;
m_bottom_layer = bottom_layer;
}
std::string LayerInterface::validate() const
{
return "";
......
......@@ -24,22 +24,17 @@
class Layer;
class LayerRoughness;
//! Interface between two layers, possibly with roughness.
//! Interface between two layers, always with roughness.
class LayerInterface : public ISampleNode {
public:
LayerInterface(const Layer* top_layer, const Layer* bottom_layer,
const LayerRoughness* layerRoughness);
~LayerInterface() override;
LayerInterface* clone() const override;
std::string className() const final { return "LayerInterface"; }
//! Creates rough interface between two layers
static LayerInterface* createInterface(const Layer* top_layer, const Layer* bottom_layer,
const LayerRoughness* roughness);
//! Sets roughness of the interface.
void setRoughness(const LayerRoughness* roughness);
//! Returns roughness of the interface.
const LayerRoughness* roughness() const;
......@@ -52,9 +47,6 @@ public:
std::string validate() const override;
private:
void setLayersTopBottom(const Layer* top_layer, const Layer* bottom_layer);
LayerInterface();
const Layer* m_top_layer; //!< pointer to the layer above interface
const Layer* m_bottom_layer; //!< pointer to the layer below interface
std::unique_ptr<const LayerRoughness> m_roughness; //!< roughness of the interface
......
......@@ -70,10 +70,8 @@ void MultiLayer::addLayerExec(const Layer& layer, const LayerRoughness* roughnes
if (numberOfLayers()) { // not the top layer
const Layer* last_layer = m_layers.back();
const LayerRoughness* new_roughness =
roughness && roughness->sigma() != 0.0 ? roughness->clone() : nullptr;
m_interfaces.push_back(
LayerInterface::createInterface(last_layer, new_layer, new_roughness));
const LayerRoughness* new_roughness = roughness ? roughness->clone() : new LayerRoughness;
m_interfaces.push_back(new LayerInterface(last_layer, new_layer, new_roughness));
} else { // the top layer
if (new_layer->thickness() != 0.0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment