diff --git a/Core/Aggregate/ILayout.h b/Core/Aggregate/ILayout.h index 2d5d419fe76181a3df9941b93d6f59262cf6f05a..c3cde085ea539485a012a4cb7430023d986ab36c 100644 --- a/Core/Aggregate/ILayout.h +++ b/Core/Aggregate/ILayout.h @@ -45,6 +45,9 @@ public: //! and generates new particles if an IAbstractParticle denotes a collection virtual SafePointerVector<IParticle> particles() const = 0; + //! Returns the interference function + virtual const IInterferenceFunction* interferenceFunction() const = 0; + /// Get total abundance of all particles virtual double getTotalAbundance() const = 0; diff --git a/Core/Aggregate/ParticleLayout.cpp b/Core/Aggregate/ParticleLayout.cpp index 2d627d79707be35109b2d84c8fe01374e15ad51a..9992bfc75303f715b49d841d7c633129723b9cf7 100644 --- a/Core/Aggregate/ParticleLayout.cpp +++ b/Core/Aggregate/ParticleLayout.cpp @@ -133,6 +133,11 @@ SafePointerVector<IParticle> ParticleLayout::particles() const return particle_vector; } +const IInterferenceFunction *ParticleLayout::interferenceFunction() const +{ + return mP_interference_function.get(); +} + double ParticleLayout::getTotalAbundance() const { double result = 0.0; diff --git a/Core/Aggregate/ParticleLayout.h b/Core/Aggregate/ParticleLayout.h index 4813d18d08bec73c8e9deb4c638965bb33e3f289..90259c12c6e7122e2b1a2a7c9e3eee16a80b4659 100644 --- a/Core/Aggregate/ParticleLayout.h +++ b/Core/Aggregate/ParticleLayout.h @@ -45,6 +45,8 @@ public: SafePointerVector<IParticle> particles() const final override; + const IInterferenceFunction* interferenceFunction() const final override; + double getTotalAbundance() const final override; void setInterferenceFunction(const IInterferenceFunction& interference_function); diff --git a/Core/Multilayer/LayoutStrategyBuilder.cpp b/Core/Multilayer/LayoutStrategyBuilder.cpp index 8faa607c9dad8364c8dd91c1e5dc229012373284..0adf69e0ddeb2d271b84b82a98ffd4646036ab86 100644 --- a/Core/Multilayer/LayoutStrategyBuilder.cpp +++ b/Core/Multilayer/LayoutStrategyBuilder.cpp @@ -64,11 +64,7 @@ void LayoutStrategyBuilder::createStrategy() SafePointerVector<class FormFactorCoherentSum> ff_wrappers = collectFormFactorList(); // TODO: this needs to be updated (no dynamic_cast or unnecessary accessors) - const IInterferenceFunction* p_iff { nullptr }; - for (auto p_child : mp_layout->getChildren()) { - if ( (p_iff = dynamic_cast<const IInterferenceFunction*>(p_child)) ) - break; - } + const IInterferenceFunction* p_iff = mp_layout->interferenceFunction(); checkInterferenceFunction(p_iff); switch (mp_layout->getApproximation())