Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #10135. Exporting SymmetryOperation and -Factory to Python
- Loading branch information
Michael Wedel
committed
Sep 11, 2014
1 parent
745a87e
commit e7718f2
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Code/Mantid/Framework/PythonInterface/mantid/geometry/src/Exports/SymmetryOperation.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
|
21 changes: 21 additions & 0 deletions
21
...Mantid/Framework/PythonInterface/mantid/geometry/src/Exports/SymmetryOperationFactory.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
; | ||
} | ||
|