Mantid
Loading...
Searching...
No Matches
Framework
Geometry
src
Crystal
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 +
7
#include "
MantidGeometry/Crystal/HKLGenerator.h
"
8
9
namespace
Mantid::Geometry
{
10
11
using namespace
Kernel;
12
14
HKLGenerator::HKLGenerator
(
const
Kernel::V3D
&hklMin,
const
Kernel::V3D
&hklMax)
15
: m_hklMin(hklMin), m_hklMax(hklMax),
m_size
(getSize(m_hklMin, m_hklMax)), m_begin(getBeginIterator()),
16
m_end(getEndIterator()) {}
17
20
HKLGenerator::HKLGenerator
(
const
Kernel::V3D
&hklMinMax)
21
: m_hklMin(hklMinMax * -1), m_hklMax(hklMinMax),
m_size
(getSize(m_hklMin, m_hklMax)), m_begin(getBeginIterator()),
22
m_end(getEndIterator()) {}
23
25
HKLGenerator::HKLGenerator
(
int
hMinMax,
int
kMinMax,
int
lMinMax) : m_hklMax(hMinMax, kMinMax, lMinMax) {
26
m_hklMin
=
m_hklMax
* -1;
27
m_size
=
getSize
(
m_hklMin
,
m_hklMax
);
28
29
m_begin
=
getBeginIterator
();
30
m_end
=
getEndIterator
();
31
}
32
35
HKLGenerator::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;
38
m_size
=
getSize
(
m_hklMin
,
m_hklMax
);
39
40
m_begin
=
getBeginIterator
();
41
m_end
=
getEndIterator
();
42
}
43
45
size_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
51
HKLGenerator::const_iterator
HKLGenerator::getBeginIterator
()
const
{
52
return
HKLGenerator::const_iterator
(
m_hklMin
,
m_hklMax
);
53
}
54
56
HKLGenerator::const_iterator
HKLGenerator::getEndIterator
()
const
{
return
HKLGenerator::const_iterator
(
getEndHKL
()); }
57
59
V3D
HKLGenerator::getEndHKL
()
const
{
return
V3D
(
m_hklMax
.
X
() + 1,
m_hklMin
.
Y
(),
m_hklMin
.
Z
()); }
60
62
HKLGenerator::const_iterator::const_iterator
()
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
66
HKLGenerator::const_iterator::const_iterator
(
const
V3D
¤t)
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
71
HKLGenerator::const_iterator::const_iterator
(
const
V3D
&hklMin,
const
V3D
&hklMax)
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
78
void
HKLGenerator::const_iterator::increment
() {
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
m_size
size_t m_size
Maximum size of the store.
Definition
EstimateFitParameters.cpp:111
HKLGenerator.h
Mantid::Geometry::HKLGenerator::const_iterator
The const_iterator class.
Definition
HKLGenerator.h:97
Mantid::Geometry::HKLGenerator::const_iterator::const_iterator
const_iterator()
Default constructor, requirement from boost::iterator_facade.
Definition
HKLGenerator.cpp:62
Mantid::Geometry::HKLGenerator::const_iterator::increment
void increment()
Increments HKL, l moves fastest, h moves slowest, wrapping around at the max for each index.
Definition
HKLGenerator.cpp:78
Mantid::Geometry::HKLGenerator::m_begin
const_iterator m_begin
Definition
HKLGenerator.h:160
Mantid::Geometry::HKLGenerator::getSize
size_t getSize(const Kernel::V3D &min, const Kernel::V3D &max) const
Returns the number of indices between min and max.
Definition
HKLGenerator.cpp:45
Mantid::Geometry::HKLGenerator::m_end
const_iterator m_end
Definition
HKLGenerator.h:161
Mantid::Geometry::HKLGenerator::HKLGenerator
HKLGenerator(const Kernel::V3D &hklMin, const Kernel::V3D &hklMax)
Constructs a generator that creates all indices from hklMin to hklMax.
Definition
HKLGenerator.cpp:14
Mantid::Geometry::HKLGenerator::m_hklMin
Kernel::V3D m_hklMin
Definition
HKLGenerator.h:155
Mantid::Geometry::HKLGenerator::getEndIterator
const_iterator getEndIterator() const
Constructs an iterator that points to an HKL one past the maximum.
Definition
HKLGenerator.cpp:56
Mantid::Geometry::HKLGenerator::m_size
size_t m_size
Definition
HKLGenerator.h:158
Mantid::Geometry::HKLGenerator::getEndHKL
Kernel::V3D getEndHKL() const
Returns the HKL "one past the maximum".
Definition
HKLGenerator.cpp:59
Mantid::Geometry::HKLGenerator::getBeginIterator
const_iterator getBeginIterator() const
Constructs an iterator that points to the beginning of the sequence.
Definition
HKLGenerator.cpp:51
Mantid::Geometry::HKLGenerator::m_hklMax
Kernel::V3D m_hklMax
Definition
HKLGenerator.h:156
Mantid::Geometry::UnitCell
Class to implement unit cell of crystals.
Definition
UnitCell.h:44
Mantid::Kernel::V3D
Class for 3D vectors.
Definition
V3D.h:34
Mantid::Kernel::V3D::X
constexpr double X() const noexcept
Get x.
Definition
V3D.h:238
Mantid::Kernel::V3D::Y
constexpr double Y() const noexcept
Get y.
Definition
V3D.h:239
Mantid::Kernel::V3D::Z
constexpr double Z() const noexcept
Get z.
Definition
V3D.h:240
Mantid::Geometry
Definition
AbsorptionCorrection.h:23
Mantid::Geometry::Z
@ Z
Definition
ReferenceFrame.h:16
Mantid::Geometry::X
@ X
Definition
ReferenceFrame.h:16
Mantid::Geometry::Y
@ Y
Definition
ReferenceFrame.h:16
Generated by
1.9.8