Skip to content

Commit

Permalink
Refs #10135. Exporting SymmetryOperation and -Factory to Python
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wedel committed Sep 11, 2014
1 parent 745a87e commit e7718f2
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
Expand Up @@ -26,6 +26,8 @@ set ( EXPORT_FILES
src/Exports/Object.cpp
src/Exports/PointGroup.cpp
src/Exports/PointGroupFactory.cpp
src/Exports/SymmetryOperation.cpp
src/Exports/SymmetryOperationFactory.cpp
)

set ( SRC_FILES
Expand Down
@@ -0,0 +1,35 @@

#include "MantidGeometry/Crystal/SymmetryOperation.h"
#include "MantidPythonInterface/kernel/Converters/PyObjectToV3D.h"
#include "MantidPythonInterface/kernel/Converters/PyObjectToMatrix.h"

#include <boost/python/class.hpp>
#include <boost/python/enum.hpp>
#include <boost/python/scope.hpp>
#include <boost/python/list.hpp>
#include <boost/python/register_ptr_to_python.hpp>

using Mantid::Geometry::SymmetryOperation;

using namespace boost::python;

namespace //<unnamed>
{
using namespace Mantid::PythonInterface;

Mantid::Kernel::V3D applyToVector(SymmetryOperation & self, const object& hkl)
{
return self.apply<Mantid::Kernel::V3D>(Converters::PyObjectToV3D(hkl)());
}
}

void export_SymmetryOperation()
{
register_ptr_to_python<boost::shared_ptr<const SymmetryOperation> >();

class_<SymmetryOperation, boost::noncopyable>("SymmetryOperation", no_init)
.def("order", &SymmetryOperation::order)
.def("identifier", &SymmetryOperation::identifier)
.def("apply", &applyToVector);
}

@@ -0,0 +1,21 @@
#include "MantidGeometry/Crystal/SymmetryOperationFactory.h"
#include "MantidPythonInterface/kernel/PythonObjectInstantiator.h"

#include <boost/python/class.hpp>

using namespace Mantid::Geometry;
using namespace boost::python;

void export_SymmetryOperationFactory()
{

class_<SymmetryOperationFactoryImpl,boost::noncopyable>("SymmetryOperationFactoryImpl", no_init)
.def("exists", &SymmetryOperationFactoryImpl::exists)
.def("createSymOp", &SymmetryOperationFactoryImpl::createSymOp)
.def("getKeys", &SymmetryOperationFactoryImpl::getKeys, "Returns all registered symmetry operations")
.def("Instance", &SymmetryOperationFactory::Instance, return_value_policy<reference_existing_object>(),
"Returns a reference to the SymmetryOperationFactory singleton")
.staticmethod("Instance")
;
}

0 comments on commit e7718f2

Please sign in to comment.