Skip to content
Snippets Groups Projects
Commit ddcd9dc0 authored by Van Herck, Walter's avatar Van Herck, Walter
Browse files

Refactor LayerStrategyBuilder: store pointer to ILayout instead of index

parent 3b2453ba
No related branches found
No related tags found
No related merge requests found
......@@ -33,13 +33,13 @@ LayerStrategyBuilder::LayerStrategyBuilder(
const LayerSpecularInfo* specular_info)
: m_sim_params {sim_params}
, mP_specular_info {nullptr}
, m_layout_index {layout_index}
, m_polarized {polarized}
{
mP_layer.reset(decorated_layer.clone());
assert(mP_layer->getNumberOfLayouts() > 0);
assert(specular_info);
mP_specular_info.reset(specular_info->clone());
mp_layout = mP_layer->getLayout(layout_index);
}
LayerStrategyBuilder::~LayerStrategyBuilder()
......@@ -51,10 +51,10 @@ IInterferenceFunctionStrategy* LayerStrategyBuilder::createStrategy() const
assert(mP_layer->getNumberOfLayouts()>0);
SafePointerVector<class FormFactorCoherentSum> ff_wrappers = collectFormFactorList();
std::unique_ptr<class IInterferenceFunction> P_interference_function{
mP_layer->getLayout(m_layout_index)->cloneInterferenceFunction()};
mp_layout->cloneInterferenceFunction()};
IInterferenceFunctionStrategy* p_result = nullptr;
switch (mP_layer->getLayout(m_layout_index)->getApproximation())
switch (mp_layout->getApproximation())
{
case ILayout::DA:
if (m_polarized)
......@@ -91,12 +91,11 @@ SafePointerVector<class FormFactorCoherentSum> LayerStrategyBuilder::collectForm
{
assert(mP_layer->getNumberOfLayouts()>0);
SafePointerVector<class FormFactorCoherentSum> result;
const ILayout* p_layout = mP_layer->getLayout(m_layout_index);
const IMaterial* p_layer_material = mP_layer->getMaterial();
double layout_abundance = p_layout->getTotalAbundance();
double layout_abundance = mp_layout->getTotalAbundance();
if (layout_abundance<=0.0) // TODO: why this can happen? why not throw error?
layout_abundance = 1.0;
for (const IParticle* particle: p_layout->getParticles()) {
for (const IParticle* particle: mp_layout->getParticles()) {
FormFactorCoherentSum* p_ff_coh;
p_ff_coh = createFormFactorCoherentSum(particle, p_layer_material);
p_ff_coh->scaleRelativeAbundance(layout_abundance);
......
......@@ -22,6 +22,7 @@
class FormFactorCoherentSum;
class IInterferenceFunctionStrategy;
class ILayout;
class IMaterial;
class IParticle;
class Layer;
......@@ -52,7 +53,7 @@ private:
std::unique_ptr<class MultiLayer> mP_sample; //!< sample
SimulationOptions m_sim_params; //!< simulation parameters
std::unique_ptr<class LayerSpecularInfo> mP_specular_info; //!< R and T coefficients for DWBA
size_t m_layout_index; //!< index for the layout to be used in the layer
const ILayout* mp_layout; //!< layout
bool m_polarized; //!< polarized computation required?
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment