%module STSIntegrator %{ #include "STSIntegrator.h" #include "ndarrayobject.h" #include using namespace std; %} %extend ProtoMol::Integrator{ } %init %{ import_array(); %} %rename (ProtoMol_IntegratorDefinition_print) ProtoMol::IntegratorDefinition::print; %include "../base/Real.h" %include "../base/simpleTypes.h" %include "../base/Vector3D.h" %include "../base/AbstractEnumType.h" %include "../base/ConstraintValueType.h" %include "../base/ValueType.h" %include "../base/Value.h" %include "../base/Parameter.h" %include "../base/MakeableDefinition.h" %include "../base/Makeable.h" %include "../base/XSC.h" %include "IntegratorDefinition.h" %include "Integrator.h" %include "StandardIntegrator.h" %include "STSIntegrator.h" %extend ProtoMol::Vector3D{ Vector3D& copy(const Vector3D& rhs) { self->x = rhs.x; self->y = rhs.y; self->z = rhs.z; return (*self); } void val() { printf("[%f %f %f]\n", self->x, self->y, self->z); } void enter() { scanf("%lf %lf %lf", &(self->x), &(self->y), &(self->z)); } Real __getitem__(int oprnd2){ return (*self)[oprnd2]; } void __setitem__(int oprnd2, Real value) { (*self)[oprnd2] = value; } void setX(Real val) { self->x = val; } void setY(Real val) { self->y = val; } void setZ(Real val) { self->z = val; } Real getX() { return self->x; } Real getY() { return self->y; } Real getZ() { return self->z; } void fromArray(PyObject* rhs) { self->x = PyFloat_AsDouble(PySequence_GetItem(rhs, 0)); self->y = PyFloat_AsDouble(PySequence_GetItem(rhs, 1)); self->z = PyFloat_AsDouble(PySequence_GetItem(rhs, 2)); } PyObject* toArray() { int dims[1] = { 3 }; float* vec = new float[3]; vec[0] = self->x; vec[1] = self->y; vec[2] = self->z; PyObject* rhs = PyArray_FromDimsAndData(1,dims,PyArray_FLOAT,(char*)vec); return rhs; } void copyto(PyObject* rhs) { PySequence_SetItem(rhs, 0, Py_BuildValue("f", self->x)); PySequence_SetItem(rhs, 1, Py_BuildValue("f", self->y)); PySequence_SetItem(rhs, 2, Py_BuildValue("f", self->z)); if (PySequence_Size(rhs) > 3) for (unsigned int i = 3; i < PySequence_Size(rhs); i++) PySequence_DelItem(rhs, i); } Vector3D __add__(Vector3D op1, Vector3D op2) { ProtoMol::Vector3D retval; retval.x = op1.x + op2.x; retval.y = op1.y + op2.y; retval.z = op1.z + op2.z; return retval; } Vector3D __sub__(Vector3D op1, Vector3D op2) { ProtoMol::Vector3D retval; retval.x = op1.x - op2.x; retval.y = op1.y - op2.y; retval.z = op1.z - op2.z; return retval; } };