Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
363864f4
Commit
363864f4
authored
Sep 17, 2019
by
Martyn Gigg
Browse files
Add method to round single HKL value
Also use std::round over boost::iround in Peak Refs #26829
parent
c805cf06
Changes
4
Hide whitespace changes
Inline
Side-by-side
Framework/DataObjects/src/Peak.cpp
View file @
363864f4
...
...
@@ -15,7 +15,6 @@
#include
"MantidKernel/System.h"
#include
"boost/make_shared.hpp"
#include
<boost/math/special_functions/round.hpp>
#include
<algorithm>
#include
<cctype>
...
...
@@ -807,16 +806,14 @@ void Peak::setHKL(const Mantid::Kernel::V3D &HKL) {
* @param HKL :: vector with integer x,y,z -> h,k,l
*/
void
Peak
::
setIntHKL
(
V3D
HKL
)
{
m_intHKL
=
V3D
(
boost
::
math
::
iround
(
HKL
[
0
]),
boost
::
math
::
iround
(
HKL
[
1
]),
boost
::
math
::
iround
(
HKL
[
2
]));
m_intHKL
=
V3D
(
std
::
round
(
HKL
[
0
]),
std
::
round
(
HKL
[
1
]),
std
::
round
(
HKL
[
2
]));
}
/** Sets the modulated peak structure number
* @param MNP :: modulated peak structure value
*/
void
Peak
::
setIntMNP
(
const
V3D
&
MNP
)
{
m_intMNP
=
V3D
(
boost
::
math
::
iround
(
MNP
[
0
]),
boost
::
math
::
iround
(
MNP
[
1
]),
boost
::
math
::
iround
(
MNP
[
2
]));
m_intMNP
=
V3D
(
std
::
round
(
MNP
[
0
]),
std
::
round
(
MNP
[
1
]),
std
::
round
(
MNP
[
2
]));
}
/** Set sample position
...
...
Framework/Geometry/inc/MantidGeometry/Crystal/IndexingUtils.h
View file @
363864f4
...
...
@@ -147,6 +147,9 @@ public:
double
required_tolerance
,
double
len_tol
,
double
ang_tol
);
/// Round all the components of a HKL objects to the nearest integer
static
void
RoundHKL
(
Kernel
::
V3D
&
hkl
);
/// Round all the components of a list of V3D objects, to the nearest integer
static
void
RoundHKLs
(
std
::
vector
<
Kernel
::
V3D
>
&
hkl_list
);
...
...
Framework/Geometry/src/Crystal/IndexingUtils.cpp
View file @
363864f4
...
...
@@ -2099,6 +2099,16 @@ void IndexingUtils::DiscardDuplicates(std::vector<V3D> &new_list,
directions
.
clear
();
}
/**
Round all of the components of the V3D to the nearest integer.
@param hkl_list Vector of V3D objects whose components will be rounded.
*/
void
IndexingUtils
::
RoundHKL
(
Mantid
::
Kernel
::
V3D
&
hkl
)
{
for
(
size_t
i
=
0
;
i
<
3
;
i
++
)
{
hkl
[
i
]
=
std
::
round
(
hkl
[
i
]);
}
}
/**
Round all of the components of all vectors to the nearest integer. This
is useful when the vectors in the list represent Miller indices. Since
...
...
@@ -2110,9 +2120,7 @@ void IndexingUtils::DiscardDuplicates(std::vector<V3D> &new_list,
*/
void
IndexingUtils
::
RoundHKLs
(
std
::
vector
<
V3D
>
&
hkl_list
)
{
for
(
auto
&
entry
:
hkl_list
)
{
for
(
size_t
i
=
0
;
i
<
3
;
i
++
)
{
entry
[
i
]
=
std
::
round
(
entry
[
i
]);
}
RoundHKL
(
entry
);
}
}
...
...
Framework/Geometry/test/IndexingUtilsTest.h
View file @
363864f4
...
...
@@ -494,6 +494,20 @@ public:
TS_ASSERT_DELTA
(
new_list
[
4
].
norm
(),
9.93006
,
1e-4
);
}
void
test_RoundHKL
()
{
V3D
hkl
(
-
1.234
,
0.345
,
7.5765
);
IndexingUtils
::
RoundHKL
(
hkl
);
TS_ASSERT_EQUALS
(
V3D
(
-
1
,
0
,
8
),
hkl
)
}
void
test_RoundHKLs
()
{
std
::
vector
<
V3D
>
hkls
{
V3D
(
-
1.234
,
0.345
,
7.5765
),
V3D
(
3.5345
,
-
1.346
,
0.2347
)};
IndexingUtils
::
RoundHKLs
(
hkls
);
TS_ASSERT_EQUALS
(
V3D
(
-
1
,
0
,
8
),
hkls
[
0
])
TS_ASSERT_EQUALS
(
V3D
(
4
,
-
1
,
0
),
hkls
[
1
])
}
void
test_ValidIndex
()
{
V3D
hkl
(
0
,
0
,
0
);
TS_ASSERT_EQUALS
(
IndexingUtils
::
ValidIndex
(
hkl
,
0.1
),
false
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment