Mantid
Loading...
Searching...
No Matches
HKLGenerator.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8
9namespace Mantid::Geometry {
10
11using namespace Kernel;
12
15 : m_hklMin(hklMin), m_hklMax(hklMax), m_size(getSize(m_hklMin, m_hklMax)), m_begin(getBeginIterator()),
16 m_end(getEndIterator()) {}
17
21 : m_hklMin(hklMinMax * -1), m_hklMax(hklMinMax), m_size(getSize(m_hklMin, m_hklMax)), m_begin(getBeginIterator()),
22 m_end(getEndIterator()) {}
23
25HKLGenerator::HKLGenerator(int hMinMax, int kMinMax, int lMinMax) : m_hklMax(hMinMax, kMinMax, lMinMax) {
26 m_hklMin = m_hklMax * -1;
28
31}
32
35HKLGenerator::HKLGenerator(const UnitCell &unitCell, double dMin)
36 : m_hklMax(floor(unitCell.a() / dMin), floor(unitCell.b() / dMin), floor(unitCell.c() / dMin)) {
37 m_hklMin = m_hklMax * -1;
39
42}
43
45size_t HKLGenerator::getSize(const V3D &min, const V3D &max) const {
46 V3D diff = (max - min) + V3D(1, 1, 1);
47 return static_cast<size_t>(diff.X() * diff.Y() * diff.Z());
48}
49
53}
54
57
59V3D HKLGenerator::getEndHKL() const { return V3D(m_hklMax.X() + 1, m_hklMin.Y(), m_hklMin.Z()); }
60
63 : m_h(0), m_k(0), m_l(0), m_hkl(V3D(0, 0, 0)), m_hMax(0), m_kMin(0), m_kMax(0), m_lMin(0), m_lMax(0) {}
64
67 : m_h(static_cast<int>(current.X())), m_k(static_cast<int>(current.Y())), m_l(static_cast<int>(current.Z())),
68 m_hkl(current), m_hMax(m_h), m_kMin(m_k), m_kMax(m_k), m_lMin(m_l), m_lMax(m_l) {}
69
72 : m_h(static_cast<int>(hklMin.X())), m_k(static_cast<int>(hklMin.Y())), m_l(static_cast<int>(hklMin.Z())),
73 m_hkl(hklMin), m_hMax(static_cast<int>(hklMax.X())), m_kMin(m_k), m_kMax(static_cast<int>(hklMax.Y())),
74 m_lMin(m_l), m_lMax(static_cast<int>(hklMax.Z())) {}
75
79 ++m_l;
80
81 if (m_l > m_lMax) {
82 m_l = m_lMin;
83
84 ++m_k;
85 if (m_k > m_kMax) {
86 m_k = m_kMin;
87 ++m_h;
88 }
89 }
90
91 m_hkl = V3D(m_h, m_k, m_l);
92}
93
94} // namespace Mantid::Geometry
size_t m_size
Maximum size of the store.
const_iterator()
Default constructor, requirement from boost::iterator_facade.
void increment()
Increments HKL, l moves fastest, h moves slowest, wrapping around at the max for each index.
size_t getSize(const Kernel::V3D &min, const Kernel::V3D &max) const
Returns the number of indices between min and max.
HKLGenerator(const Kernel::V3D &hklMin, const Kernel::V3D &hklMax)
Constructs a generator that creates all indices from hklMin to hklMax.
const_iterator getEndIterator() const
Constructs an iterator that points to an HKL one past the maximum.
Kernel::V3D getEndHKL() const
Returns the HKL "one past the maximum".
const_iterator getBeginIterator() const
Constructs an iterator that points to the beginning of the sequence.
Class to implement unit cell of crystals.
Definition: UnitCell.h:44
Class for 3D vectors.
Definition: V3D.h:34
constexpr double X() const noexcept
Get x.
Definition: V3D.h:232
constexpr double Y() const noexcept
Get y.
Definition: V3D.h:233
constexpr double Z() const noexcept
Get z.
Definition: V3D.h:234