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/make_constructor.hpp>
17#include <boost/python/register_ptr_to_python.hpp>
18#include <boost/python/scope.hpp>
19#include <boost/python/stl_iterator.hpp>
29std::vector<std::string> getSymmetryOperationStrings(
const Group &self) {
32 std::vector<std::string> pythonSymOps;
33 pythonSymOps.reserve(symOps.size());
34 std::transform(symOps.cbegin(), symOps.cend(), std::back_inserter(pythonSymOps),
35 [](
const auto &symOp) { return symOp.identifier(); });
40Group_sptr constructGroupFromString(
const std::string &initializerString) {
41 return std::const_pointer_cast<Group>(GroupFactory::create<Group>(initializerString));
44Group_sptr constructGroupFromVector(
const std::vector<SymmetryOperation> &symOps) {
45 return std::const_pointer_cast<Group>(GroupFactory::create<Group>(symOps));
48Group_sptr constructGroupFromPythonList(
const boost::python::list &symOpList) {
49 std::vector<SymmetryOperation> operations;
51 for (
int i = 0; i < len(symOpList); ++i) {
52 operations.emplace_back(boost::python::extract<SymmetryOperation>(symOpList[i]));
55 return std::const_pointer_cast<Group>(GroupFactory::create<Group>(operations));
58bool isInvariantDefault(
const Group &self,
const boost::python::object &tensor) {
62bool isInvariantTolerance(
const Group &self,
const boost::python::object &tensor,
double tolerance) {
69 register_ptr_to_python<std::shared_ptr<Group>>();
71 enum_<Group::CoordinateSystem>(
"CoordinateSystem")
75 enum_<Group::GroupAxiom>(
"GroupAxiom")
81 class_<Group, boost::noncopyable>(
"Group", no_init)
83 make_constructor(&constructGroupFromString, default_call_policies(), (arg(
"symmetryOperationString"))),
84 "Construct a group from the provided initializer string.")
86 make_constructor(&constructGroupFromVector, default_call_policies(), (arg(
"symmetryOperationVector"))),
87 "Construct a group from the provided symmetry operation list.")
89 make_constructor(&constructGroupFromPythonList, default_call_policies(), (arg(
"symmetryOperationList"))),
90 "Construct a group from a python generated symmetry operation list.")
91 .def(
"getOrder", &
Group::order, arg(
"self"),
"Returns the order of the group.")
93 "Returns the type of coordinate system to distinguish groups with "
94 "hexagonal system definition.")
96 return_value_policy<copy_const_reference>(),
"Returns the symmetry operations contained in the group.")
97 .def(
"getSymmetryOperationStrings", &getSymmetryOperationStrings, arg(
"self"),
98 "Returns the x,y,z-strings for the contained symmetry operations.")
100 "Checks whether a SymmetryOperation is included in Group.")
102 .def(
"isInvariant", &isInvariantDefault, (arg(
"self"), arg(
"tensor")),
103 "Returns true if the tensor is not changed by the group's symmetry "
104 "operations with a tolerance of 1e-8.")
105 .def(
"isInvariant", &isInvariantTolerance, (arg(
"self"), arg(
"tensor"), arg(
"tolerance")),
106 "Returns true if the tensor is not changed by the group's symmetry "
107 "operations with the given tolerance.")
109 "Checks whether the contained symmetry "
110 "operations fulfill the group axioms.")
112 "Checks if the contained symmetry operations fulfill the specified "
#define GET_POINTER_SPECIALIZATION(TYPE)
The class Group represents a set of symmetry operations (or symmetry group).
bool isGroup() const
Returns whether the group fulfills the four group axioms.
bool isInvariant(const Kernel::DblMatrix &tensor, double tolerance=1e-8) const
Returns true if the tensor is invariant under the group operations.
const std::vector< SymmetryOperation > & getSymmetryOperations() const
Returns a vector with all symmetry operations.
CoordinateSystem getCoordinateSystem() const
Returns the axis system of the group (either orthogonal or hexagonal).
bool fulfillsAxiom(GroupAxiom axiom) const
Checks whether a certain group axiom is fulfilled, can be used as a more fine-grained alternative to ...
bool containsOperation(const SymmetryOperation &operation) const
Returns true if the group contains the supplied operation.
size_t order() const
Returns the order of the group, which is the number of symmetry operations.
Crystallographic symmetry operations are composed of a rotational component, which is represented by ...
std::shared_ptr< Group > Group_sptr
Takes a Python object and if it supports indexing and is two dimensional it attempts to convert it to...