Skip to content
Snippets Groups Projects
Commit 0fcdffa4 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

Move Rotations.* to Vector; minimize dependences of Layer.cpp

parent df202056
No related branches found
No related tags found
No related merge requests found
...@@ -13,9 +13,8 @@ ...@@ -13,9 +13,8 @@
// //
// ************************************************************************** // // ************************************************************************** //
#include "Layer.h"
#include "DecoratedLayerDWBASimulation.h" #include "DecoratedLayerDWBASimulation.h"
#include "MultiLayer.h"
using namespace BornAgain; using namespace BornAgain;
...@@ -34,10 +33,10 @@ Layer::Layer(const Layer& other) : ICompositeSample() ...@@ -34,10 +33,10 @@ Layer::Layer(const Layer& other) : ICompositeSample()
{ {
m_thickness = other.m_thickness; m_thickness = other.m_thickness;
mp_material = 0; mp_material = 0;
if(other.mp_material) mp_material = other.mp_material->clone(); if (other.mp_material)
for (size_t i=0; i<other.getNumberOfLayouts();++i) { mp_material = other.mp_material->clone();
for (size_t i=0; i<other.getNumberOfLayouts();++i)
addLayoutPtr(other.getLayout(i)->clone()); addLayoutPtr(other.getLayout(i)->clone());
}
setNumberOfLayers(other.getNumberOfLayers()); setNumberOfLayers(other.getNumberOfLayers());
initialize(); initialize();
} }
...@@ -56,9 +55,8 @@ Layer* Layer::cloneInvertB() const ...@@ -56,9 +55,8 @@ Layer* Layer::cloneInvertB() const
{ {
Layer *p_clone = new Layer(); Layer *p_clone = new Layer();
p_clone->mp_material = Materials::createInvertedMaterial(this->mp_material); p_clone->mp_material = Materials::createInvertedMaterial(this->mp_material);
for (size_t i=0; i<getNumberOfLayouts(); ++i) { for (size_t i=0; i<getNumberOfLayouts(); ++i)
p_clone->addLayoutPtr(getLayout(i)->cloneInvertB()); p_clone->addLayoutPtr(getLayout(i)->cloneInvertB());
}
p_clone->m_thickness = this->m_thickness; p_clone->m_thickness = this->m_thickness;
p_clone->setNumberOfLayers(getNumberOfLayers()); p_clone->setNumberOfLayers(getNumberOfLayers());
p_clone->init_parameters(); p_clone->init_parameters();
...@@ -118,9 +116,8 @@ void Layer::addLayout(const ILayout &decoration) ...@@ -118,9 +116,8 @@ void Layer::addLayout(const ILayout &decoration)
const ILayout *Layer::getLayout(size_t i) const const ILayout *Layer::getLayout(size_t i) const
{ {
if (i>=m_layouts.size()) { if (i>=m_layouts.size())
return 0; return nullptr;
}
return m_layouts[i]; return m_layouts[i];
} }
...@@ -131,26 +128,23 @@ bool Layer::hasDWBASimulation() const ...@@ -131,26 +128,23 @@ bool Layer::hasDWBASimulation() const
LayerDWBASimulation *Layer::createLayoutSimulation(size_t layout_index) const LayerDWBASimulation *Layer::createLayoutSimulation(size_t layout_index) const
{ {
if(getNumberOfLayouts()==0 || layout_index>=getNumberOfLayouts()) { if (getNumberOfLayouts()==0 || layout_index>=getNumberOfLayouts())
return 0; return nullptr;
}
return new DecoratedLayerDWBASimulation(this, layout_index); return new DecoratedLayerDWBASimulation(this, layout_index);
} }
double Layer::getTotalParticleSurfaceDensity(size_t layout_index) const double Layer::getTotalParticleSurfaceDensity(size_t layout_index) const
{ {
if (getNumberOfLayouts()==0 || layout_index>=getNumberOfLayouts()) { if (getNumberOfLayouts()==0 || layout_index>=getNumberOfLayouts())
return 0.0; return 0.0;
}
return getLayout(layout_index)->getTotalParticleSurfaceDensity(); return getLayout(layout_index)->getTotalParticleSurfaceDensity();
} }
double Layer::getTotalAbundance() const double Layer::getTotalAbundance() const
{ {
double total_abundance = 0.0; double total_abundance = 0.0;
for (size_t i=0; i<getNumberOfLayouts(); ++i) { for (size_t i=0; i<getNumberOfLayouts(); ++i)
total_abundance += getLayout(i)->getTotalAbundance(); total_abundance += getLayout(i)->getTotalAbundance();
}
return total_abundance; return total_abundance;
} }
...@@ -179,8 +173,8 @@ void Layer::print(std::ostream& ostr) const ...@@ -179,8 +173,8 @@ void Layer::print(std::ostream& ostr) const
void Layer::addLayoutPtr(ILayout *layout) void Layer::addLayoutPtr(ILayout *layout)
{ {
if( !layout ) return; if( !layout )
return;
m_layouts.push_back(layout); m_layouts.push_back(layout);
registerChild(layout); registerChild(layout);
} }
......
File moved
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment