Mantid
Loading...
Searching...
No Matches
SpaceGroup.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 +
11
12#include <boost/python/class.hpp>
13#include <boost/python/copy_const_reference.hpp>
14#include <boost/python/enum.hpp>
15#include <boost/python/list.hpp>
16#include <boost/python/operators.hpp>
17#include <boost/python/register_ptr_to_python.hpp>
18#include <boost/python/scope.hpp>
19#include <boost/python/self.hpp>
20
23using namespace boost::python;
24
26
27namespace //<unnamed>
28{
29using namespace Mantid::PythonInterface;
30
31boost::python::list getEquivalentPositions(const SpaceGroup &self, const object &point) {
32 const auto &equivalents = self.getEquivalentPositions(Converters::PyObjectToV3D(point)());
33
34 boost::python::list pythonEquivalents;
35 for (const auto &equivalent : equivalents) {
36 pythonEquivalents.append(equivalent);
37 }
38
39 return pythonEquivalents;
40}
41
42bool isAllowedReflection(const SpaceGroup &self, const object &hkl) {
43 const auto &hklV3d = Converters::PyObjectToV3D(hkl)();
44
45 return self.isAllowedReflection(hklV3d);
46}
47
48Mantid::Geometry::Group_sptr getSiteSymmetryGroup(const SpaceGroup &self, const object &position) {
49 const auto &posV3d = Converters::PyObjectToV3D(position)();
50 return std::const_pointer_cast<Group>(self.getSiteSymmetryGroup(posV3d));
51}
52
53std::string __repr__implementation(const SpaceGroup &self) {
54 std::stringstream ss;
55 ss << "SpaceGroupFactory.createSpaceGroup(\"";
56 ss << self.hmSymbol();
57 ss << "\")";
58 return ss.str();
59}
60} // namespace
61
63 register_ptr_to_python<std::shared_ptr<SpaceGroup>>();
64
65 class_<SpaceGroup, boost::noncopyable, bases<Group>>("SpaceGroup", no_init)
66 .def("getNumber", &SpaceGroup::number, arg("self"))
67 .def("getHMSymbol", &SpaceGroup::hmSymbol, arg("self"), return_value_policy<copy_const_reference>())
68 .def("getEquivalentPositions", &getEquivalentPositions, (arg("self"), arg("point")),
69 "Returns an array with all symmetry equivalents of the supplied "
70 "HKL.")
71 .def("isAllowedReflection", &isAllowedReflection, (arg("self"), arg("hkl")),
72 "Returns True if the supplied reflection is allowed with respect to "
73 "space group symmetry operations.")
74 .def("isAllowedUnitCell", &SpaceGroup::isAllowedUnitCell, (arg("self"), arg("cell")),
75 "Returns true if the metric of the cell "
76 "is compatible with the space group.")
77 .def("getPointGroup", &SpaceGroup::getPointGroup, arg("self"), "Returns the point group of the space group.")
78 .def("getSiteSymmetryGroup", &getSiteSymmetryGroup, (arg("self"), arg("position")),
79 "Returns the site symmetry group for supplied point coordinates.")
80 .def(str(self))
81 .def("__repr__", &__repr__implementation);
82}
double position
Definition GetAllEi.cpp:154
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition GetPointer.h:17
void export_SpaceGroup()
The class Group represents a set of symmetry operations (or symmetry group).
Definition Group.h:135
A class for representing space groups, inheriting from Group.
Definition SpaceGroup.h:46
PointGroup_sptr getPointGroup() const
Returns the point group of the space group.
bool isAllowedReflection(const Kernel::V3D &hkl) const
Returns whether the given reflection is allowed or not in this space group.
Group_const_sptr getSiteSymmetryGroup(const Kernel::V3D &position) const
Returns the site symmetry group.
const std::string & hmSymbol() const
Returns the stored Hermann-Mauguin symbol.
bool isAllowedUnitCell(const UnitCell &cell) const
Convenience function for checking compatibility of a cell metric with the space group,...
size_t number() const
Returns the stored space group number.
std::vector< T > getEquivalentPositions(const T &position) const
Definition SpaceGroup.h:53
std::shared_ptr< Group > Group_sptr
Definition Group.h:178
Takes a Python object and if it supports indexing and is of length 3 then it will attempt to convert ...