12#include <boost/python/class.hpp>
13#include <boost/python/enum.hpp>
14#include <boost/python/list.hpp>
15#include <boost/python/make_constructor.hpp>
16#include <boost/python/register_ptr_to_python.hpp>
17#include <boost/python/scope.hpp>
18#include <boost/python/stl_iterator.hpp>
28std::vector<std::string> getSymmetryOperationStrings(
const Group &self) {
31 std::vector<std::string> pythonSymOps;
32 pythonSymOps.reserve(symOps.size());
33 std::transform(symOps.cbegin(), symOps.cend(), std::back_inserter(pythonSymOps),
34 [](
const auto &symOp) { return symOp.identifier(); });
39Group_sptr constructGroupFromString(
const std::string &initializerString) {
40 return std::const_pointer_cast<Group>(GroupFactory::create<Group>(initializerString));
43Group_sptr constructGroupFromVector(
const std::vector<SymmetryOperation> &symOps) {
44 return std::const_pointer_cast<Group>(GroupFactory::create<Group>(symOps));
47Group_sptr constructGroupFromPythonList(
const boost::python::list &symOpList) {
48 std::vector<SymmetryOperation> operations;
50 for (
int i = 0; i < len(symOpList); ++i) {
51 operations.emplace_back(boost::python::extract<SymmetryOperation>(symOpList[i]));
54 return std::const_pointer_cast<Group>(GroupFactory::create<Group>(operations));
57bool isInvariantDefault(
const Group &self,
const boost::python::object &tensor) {
61bool isInvariantTolerance(
const Group &self,
const boost::python::object &tensor,
double tolerance) {
68 register_ptr_to_python<std::shared_ptr<Group>>();
70 enum_<Group::CoordinateSystem>(
"CoordinateSystem")
74 enum_<Group::GroupAxiom>(
"GroupAxiom")
80 class_<Group, boost::noncopyable>(
"Group", no_init)
82 make_constructor(&constructGroupFromString, default_call_policies(), (arg(
"symmetryOperationString"))),
83 "Construct a group from the provided initializer string.")
85 make_constructor(&constructGroupFromVector, default_call_policies(), (arg(
"symmetryOperationVector"))),
86 "Construct a group from the provided symmetry operation list.")
88 make_constructor(&constructGroupFromPythonList, default_call_policies(), (arg(
"symmetryOperationList"))),
89 "Construct a group from a python generated symmetry operation list.")
90 .def(
"getOrder", &
Group::order, arg(
"self"),
"Returns the order of the group.")
92 "Returns the type of coordinate system to distinguish groups with "
93 "hexagonal system definition.")
95 "Returns the symmetry operations contained in the group.")
96 .def(
"getSymmetryOperationStrings", &getSymmetryOperationStrings, arg(
"self"),
97 "Returns the x,y,z-strings for the contained symmetry operations.")
99 "Checks whether a SymmetryOperation is included in Group.")
101 .def(
"isInvariant", &isInvariantDefault, (arg(
"self"), arg(
"tensor")),
102 "Returns true if the tensor is not changed by the group's symmetry "
103 "operations with a tolerance of 1e-8.")
104 .def(
"isInvariant", &isInvariantTolerance, (arg(
"self"), arg(
"tensor"), arg(
"tolerance")),
105 "Returns true if the tensor is not changed by the group's symmetry "
106 "operations with the given tolerance.")
108 "Checks whether the contained symmetry "
109 "operations fulfill the group axioms.")
111 "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.
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...