24 std::pair<size_t, size_t> SliceIndexSpan(
const IParticle& particle,
 
   25                                          const std::vector<Slice>& slices, 
double z_ref);
 
   26 size_t TopZToSliceIndex(
double z, 
const std::vector<Slice>& slices);
 
   27 size_t BottomZToSliceIndex(
double z, 
const std::vector<Slice>& slices);
 
   28 double SliceTopZ(
size_t i, 
const std::vector<Slice>& slices);
 
   29 ZLimits SlicesZLimits(
const std::vector<Slice>& slices, 
size_t slice_index);
 
   30 void ScaleRegions(std::vector<HomogeneousRegion>& regions, 
double factor);
 
   34                                                                    const std::vector<Slice>& slices,
 
   39     for (
auto p_particle : particles) {
 
   40         result.addParticle(*p_particle, slices, z_ref);
 
   45 void SlicedFormFactorList::addParticle(
IParticle& particle, 
const std::vector<Slice>& slices,
 
   48     auto slice_indices = SliceIndexSpan(particle, slices, z_ref);
 
   49     bool single_layer = (slice_indices.first == slice_indices.second);
 
   50     for (
size_t i = slice_indices.first; i < slice_indices.second + 1; ++i) {
 
   51         double z_top_i = SliceTopZ(i, slices);
 
   52         kvector_t translation(0.0, 0.0, z_ref - z_top_i);
 
   55         ZLimits limits = single_layer ? 
ZLimits() : SlicesZLimits(slices, i);
 
   57         m_ff_list.emplace_back(std::move(sliced_particle.mP_slicedff), i);
 
   58         double thickness = slices[i].thickness();
 
   60             ScaleRegions(sliced_particle.m_regions, 1 / thickness);
 
   61         m_region_map[i].insert(m_region_map[i].end(), sliced_particle.m_regions.begin(),
 
   62                                sliced_particle.m_regions.end());
 
   67 size_t SlicedFormFactorList::size()
 const 
   69     return m_ff_list.size();
 
   72 std::pair<const IFormFactor*, size_t> SlicedFormFactorList::operator[](
size_t index)
 const 
   75         throw std::out_of_range(
"SlicedFormFactorList::operator[] error: " 
   76                                 "index out of range");
 
   77     return {m_ff_list[index].first.get(), m_ff_list[index].second};
 
   80 std::map<size_t, std::vector<HomogeneousRegion>> SlicedFormFactorList::regionMap()
 const 
   87 std::pair<size_t, size_t> SliceIndexSpan(
const IParticle& particle,
 
   88                                          const std::vector<Slice>& slices, 
double z_ref)
 
   91     double zbottom = bottomTopZ.m_bottom;
 
   92     double ztop = bottomTopZ.m_top;
 
   93     double eps = (ztop - zbottom) * 1e-6; 
 
   95     double zmax = ztop + z_ref - eps;
 
   96     double zmin = zbottom + z_ref + eps;
 
   97     size_t top_index = TopZToSliceIndex(zmax, slices);
 
   98     size_t bottom_index = BottomZToSliceIndex(zmin, slices);
 
   99     if (top_index > bottom_index) 
 
  100         top_index = bottom_index;
 
  101     return {top_index, bottom_index};
 
  104 size_t TopZToSliceIndex(
double z, 
const std::vector<Slice>& slices)
 
  106     auto n_layers = slices.size();
 
  107     if (n_layers < 2 || z > 0.0)
 
  109     double z_layer_bottom = 0.0;
 
  111     while (i_slice + 1 < n_layers) {
 
  113         z_layer_bottom -= slices[i_slice].thickness();
 
  114         if (z > z_layer_bottom)
 
  120 size_t BottomZToSliceIndex(
double z, 
const std::vector<Slice>& slices)
 
  122     auto n_layers = slices.size();
 
  123     if (n_layers < 2 || z >= 0.0)
 
  125     double z_layer_bottom = 0.0;
 
  127     while (i_slice + 1 < n_layers) {
 
  129         z_layer_bottom -= slices[i_slice].thickness();
 
  130         if (z >= z_layer_bottom)
 
  136 double SliceTopZ(
size_t i, 
const std::vector<Slice>& slices)
 
  141     for (
size_t j = 1; j < i; ++j)
 
  142         top_z -= slices[j].thickness();
 
  146 ZLimits SlicesZLimits(
const std::vector<Slice>& slices, 
size_t slice_index)
 
  148     size_t N = slices.size();
 
  151     if (slice_index == 0)
 
  152         return ZLimits({
false, 0}, {
true, 0});
 
  153     if (slice_index == N - 1)
 
  154         return ZLimits({
true, 0}, {
false, 0});
 
  155     double thickness = slices[slice_index].thickness();
 
  156     return ZLimits(-thickness, 0.0);
 
  159 void ScaleRegions(std::vector<HomogeneousRegion>& regions, 
double factor)
 
  161     for (
auto& region : regions)
 
  162         region.m_volume *= factor;
 
Defines interface IParticle.
 
Defines IRotation classes.
 
Defines class SlicedParticle.
 
Pure virtual base class for Particle, ParticleComposition, ParticleCoreShell, MesoCrystal.
 
void translate(kvector_t translation) override final
Translates the particle.
 
virtual SafePointerVector< IParticle > decompose() const
Decompose in constituent IParticle objects.
 
virtual SlicedParticle createSlicedParticle(ZLimits limits) const
Creates a sliced form factor for this particle.
 
virtual ParticleLimits bottomTopZ() const
Top and bottom z-coordinate.
 
Class that contains upper and lower limits of the z-coordinate for the slicing of form factors.