Mantid
Loading...
Searching...
No Matches
SymmetryElement.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 +
9
10#include <boost/python/class.hpp>
11#include <boost/python/enum.hpp>
12#include <boost/python/register_ptr_to_python.hpp>
13#include <boost/python/scope.hpp>
14
15using namespace Mantid::Geometry;
16using namespace boost::python;
17
19
20namespace {
22 try {
23 auto &axisElement = dynamic_cast<SymmetryElementWithAxis &>(self);
24 return Mantid::Kernel::V3D(axisElement.getAxis());
25 } catch (std::bad_cast &) {
26 return Mantid::Kernel::V3D(0, 0, 0);
27 }
28}
29
31 try {
32 auto &rotationElement = dynamic_cast<SymmetryElementRotation &>(self);
33 return rotationElement.getRotationSense();
34 } catch (std::bad_cast &) {
36 }
37}
38} // namespace
39
41 register_ptr_to_python<std::shared_ptr<SymmetryElement>>();
42
43 scope symmetryElementScope = class_<SymmetryElement, boost::noncopyable>("SymmetryElement", no_init);
44
45 enum_<SymmetryElementRotation::RotationSense>("RotationSense")
46 .value("Positive", SymmetryElementRotation::Positive)
47 .value("Negative", SymmetryElementRotation::Negative)
48 .value("NoRotation", SymmetryElementRotation::NoRotation);
49
50 class_<SymmetryElement, boost::noncopyable>("SymmetryElement", no_init)
51 .def("getHMSymbol", &SymmetryElement::hmSymbol, arg("self"),
52 "Returns the Hermann-Mauguin symbol for the element.")
53 .def("getAxis", &getAxis, arg("self"),
54 "Returns the symmetry axis or [0,0,0] for "
55 "identiy, inversion and translations.")
56 .def("getRotationSense", &getRotationSense, arg("self"),
57 "Returns the rotation sense of a rotation axis or None"
58 "if the element is not a rotation.");
59}
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition: GetPointer.h:17
void export_SymmetryElement()
SymmetryElementRotation represents rotation-, rotoinversion- and screw-axes.
RotationSense getRotationSense() const
Returns the internally stored rotation sense.
SymmetryElementWithAxis does not represent any symmetry element directly.
SymmetryElement is an interface for representing symmetry elements that occur for example in space an...
std::string hmSymbol() const
Returns the internally stored Hermann-Mauguin symbol.
Class for 3D vectors.
Definition: V3D.h:34