Commit 79cb699a authored by Lee-Ping's avatar Lee-Ping
Browse files

Merge branch 'vec3api' of github.com:leeping/openmm into vec3api

parents 6077ee4d 1e9099cd
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include "openmm/Integrator.h" #include "openmm/Integrator.h"
#include "openmm/LangevinIntegrator.h" #include "openmm/LangevinIntegrator.h"
#include "openmm/LocalEnergyMinimizer.h" #include "openmm/LocalEnergyMinimizer.h"
#include "openmm/MonteCarloAnisotropicBarostat.h"
#include "openmm/MonteCarloBarostat.h" #include "openmm/MonteCarloBarostat.h"
#include "openmm/NonbondedForce.h" #include "openmm/NonbondedForce.h"
#include "openmm/Context.h" #include "openmm/Context.h"
......
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
/* Convert python tuple to C++ Vec3 object*/ /* Convert python tuple to C++ Vec3 object*/
%typemap(typecheck) Vec3 {
// typemap -- %typemap(typecheck) Vec3
$1 = (PySequence_Length($input) >= 3 ? 1 : 0);
}
%typemap(in) Vec3 { %typemap(in) Vec3 {
// typemap -- %typemap(in) Vec3 // typemap -- %typemap(in) Vec3
double x, y, z; double x, y, z;
...@@ -50,6 +54,10 @@ ...@@ -50,6 +54,10 @@
$1 = OpenMM::Vec3(x, y, z); $1 = OpenMM::Vec3(x, y, z);
} }
%typemap(typecheck) const Vec3& {
// typemap -- %typemap(typecheck) Vec3
$1 = (PySequence_Length($input) >= 3 ? 1 : 0);
}
%typemap(in) const Vec3& (OpenMM::Vec3 myVec) { %typemap(in) const Vec3& (OpenMM::Vec3 myVec) {
// typemap -- %typemap(in) Vec3 // typemap -- %typemap(in) Vec3
double x, y, z; double x, y, z;
...@@ -70,6 +78,13 @@ ...@@ -70,6 +78,13 @@
myVec = OpenMM::Vec3(x, y, z); myVec = OpenMM::Vec3(x, y, z);
$1 = &myVec; $1 = &myVec;
} }
%typemap(out) Vec3 {
PyObject* mm = PyImport_AddModule("simtk.openmm");
PyObject* vec3 = PyObject_GetAttrString(mm, "Vec3");
PyObject* args = Py_BuildValue("(d,d,d)", ($1)[0], ($1)[1], ($1)[2]);
$result = PyObject_CallObject(vec3, args);
Py_DECREF(args);
}
/* Convert C++ (Vec3&, Vec3&, Vec3&) object to python tuple or tuples */ /* Convert C++ (Vec3&, Vec3&, Vec3&) object to python tuple or tuples */
%typemap(argout) (Vec3& a, Vec3& b, Vec3& c) { %typemap(argout) (Vec3& a, Vec3& b, Vec3& c) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment