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

Collect region information in LayoutStrategyBuilder

parent 7eb5a333
No related branches found
No related tags found
No related merge requests found
......@@ -78,7 +78,7 @@ void LayoutStrategyBuilder::createStrategy()
}
//! Sets m_formfactor_wrappers, the list of weighted form factors.
SafePointerVector<class FormFactorCoherentSum> LayoutStrategyBuilder::collectFormFactorList() const
SafePointerVector<class FormFactorCoherentSum> LayoutStrategyBuilder::collectFormFactorList()
{
SafePointerVector<class FormFactorCoherentSum> result;
double layout_abundance = mp_layout->getTotalAbundance();
......@@ -92,11 +92,12 @@ SafePointerVector<class FormFactorCoherentSum> LayoutStrategyBuilder::collectFor
//! Returns a new formfactor wrapper for a given particle in given ambient material.
FormFactorCoherentSum* LayoutStrategyBuilder::createFormFactorCoherentSum(
const IParticle* particle) const
const IParticle* particle)
{
std::unique_ptr<FormFactorCoherentSum> P_result(
new FormFactorCoherentSum(particle->abundance()));
auto sliced_ffs = CreateSlicedFormFactors(*particle, *mp_multilayer, m_layer_index);
mergeRegionMap(sliced_ffs.regionMap());
for (size_t i=0; i < sliced_ffs.size(); ++i) {
auto ff_pair = sliced_ffs[i];
std::unique_ptr<IFormFactor> P_ff_framework;
......@@ -119,3 +120,15 @@ FormFactorCoherentSum* LayoutStrategyBuilder::createFormFactorCoherentSum(
}
return P_result.release();
}
void LayoutStrategyBuilder::mergeRegionMap(
const std::map<size_t, std::vector<HomogeneousRegion>>& region_map)
{
for (auto& entry : region_map)
{
size_t layer_index = entry.first;
auto regions = entry.second;
m_region_map[layer_index].insert(m_region_map[layer_index].begin(),
regions.begin(), regions.end());
}
}
......@@ -48,8 +48,9 @@ public:
private:
void createStrategy();
SafePointerVector<class FormFactorCoherentSum> collectFormFactorList() const;
FormFactorCoherentSum* createFormFactorCoherentSum(const IParticle* particle) const;
SafePointerVector<class FormFactorCoherentSum> collectFormFactorList();
FormFactorCoherentSum* createFormFactorCoherentSum(const IParticle* particle);
void mergeRegionMap(const std::map<size_t, std::vector<HomogeneousRegion>>& region_map);
const MultiLayer* mp_multilayer;
const ILayout* mp_layout;
......
......@@ -61,6 +61,11 @@ std::pair<const IFormFactor*, size_t> SlicedFormFactorList::operator[](size_t in
return { m_ff_list[index].first.get(), m_ff_list[index].second };
}
std::map<size_t, std::vector<HomogeneousRegion>> SlicedFormFactorList::regionMap() const
{
return m_region_map;
}
SlicedFormFactorList CreateSlicedFormFactors(const IParticle& particle,
const MultiLayer& multilayer, size_t ref_layer_index)
{
......
......@@ -42,6 +42,8 @@ public:
size_t size() const;
std::pair<const IFormFactor*, size_t> operator[](size_t index) const;
std::map<size_t, std::vector<HomogeneousRegion>> regionMap() const;
private:
std::vector<std::pair<std::unique_ptr<IFormFactor>, size_t>> m_ff_list;
std::map<size_t, std::vector<HomogeneousRegion>> m_region_map;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment