/* Convenience typemaps */ #ifdef SWIGPYTHON /* Make the common point types representable by tuples */ %typemap(in) const Amanith::GPoint2& (Amanith::GPoint2 temp) { temp = Amanith::GPoint2(PyFloat_AsDouble(PyTuple_GetItem($input, 0)), PyFloat_AsDouble(PyTuple_GetItem($input, 1))); $1 = &temp; } %typemap(in) const Amanith::GPoint3& (Amanith::GPoint3 temp) { temp = Amanith::GPoint3(PyFloat_AsDouble(PyTuple_GetItem($input, 0)), PyFloat_AsDouble(PyTuple_GetItem($input, 1)), PyFloat_AsDouble(PyTuple_GetItem($input, 2))); $1 = &temp; } %typemap(in) const Amanith::GPoint4& (Amanith::GPoint4 temp) { temp = Amanith::GPoint4(PyFloat_AsDouble(PyTuple_GetItem($input, 0)), PyFloat_AsDouble(PyTuple_GetItem($input, 1)), PyFloat_AsDouble(PyTuple_GetItem($input, 2)), PyFloat_AsDouble(PyTuple_GetItem($input, 3))); $1 = &temp; } %typecheck(SWIG_TYPECHECK_POINTER) const Amanith::GPoint2& { $1 = (PyTuple_Check($input) && PyTuple_Size($input) == 2) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_POINTER) const Amanith::GPoint3& { $1 = (PyTuple_Check($input) && PyTuple_Size($input) == 3) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_POINTER) const Amanith::GPoint4& { $1 = (PyTuple_Check($input) && PyTuple_Size($input) == 4) ? 1 : 0; } /* Same for vector types */ %typemap(in) const Amanith::GVector2& (Amanith::GVector2 temp) { temp = Amanith::GVector2(PyFloat_AsDouble(PyTuple_GetItem($input, 0)), PyFloat_AsDouble(PyTuple_GetItem($input, 1))); $1 = &temp; } %typemap(in) const Amanith::GVector3& (Amanith::GVector3 temp) { temp = Amanith::GVector3(PyFloat_AsDouble(PyTuple_GetItem($input, 0)), PyFloat_AsDouble(PyTuple_GetItem($input, 1)), PyFloat_AsDouble(PyTuple_GetItem($input, 2))); $1 = &temp; } %typemap(in) const Amanith::GVector4& (Amanith::GVector4 temp) { temp = Amanith::GVector4(PyFloat_AsDouble(PyTuple_GetItem($input, 0)), PyFloat_AsDouble(PyTuple_GetItem($input, 1)), PyFloat_AsDouble(PyTuple_GetItem($input, 2)), PyFloat_AsDouble(PyTuple_GetItem($input, 3))); $1 = &temp; } %typecheck(SWIG_TYPECHECK_POINTER) const Amanith::GVector2& { $1 = (PyTuple_Check($input) && PyTuple_Size($input) == 2) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_POINTER) const Amanith::GVector3& { $1 = (PyTuple_Check($input) && PyTuple_Size($input) == 3) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_POINTER) const Amanith::GVector4& { $1 = (PyTuple_Check($input) && PyTuple_Size($input) == 4) ? 1 : 0; } %typemap(in) Amanith::GReal& (Amanith::GReal temp) { temp = PyFloat_AsDouble($input); $1 = &temp; } %typemap(out) Amanith::GReal& { $result = PyFloat_FromDouble($1); } %apply Amanith::GReal& OUTPUT { Amanith::GReal& } %apply Amanith::GPixelMap& INOUT { Amanith::GPixelMap& } #endif /* SWIGPYTHON */ /* * Things that come in vectors */ %include "std_vector.i" namespace std { %template(GPoint2Vector) vector; %template(GPoint3Vector) vector; %template(GPoint4Vector) vector; %template(GKeyValueVector) vector; %template(GImpExpFeatureVector) vector; %template(GPropertyVector) vector; %template(GProxyStateVector) vector; %template(GRealVector) vector; %template(GHermiteKey1DVector) vector; }