PyUtil.h
Go to the documentation of this file.
00001 #ifndef __PYUTIL_H__
00002 #define __PYUTIL_H__
00003 
00004 template<class T>
00005 void VectorToPyList(const T& v, boost::python::list &l)
00006 {
00007     for (int i=0; i<v.size(); i++){
00008         l.append(boost::python::object(v[i]));
00009     }
00010 }
00011 
00012 static void Matrix33ToPyList(const hrp::Matrix33& M, boost::python::list &l)
00013 {
00014     for (int i=0; i<3; i++){
00015         for (int j=0; j<3; j++){
00016             l.append(boost::python::object(M(i,j)));
00017         }
00018     }
00019 }
00020 
00021 template<class T>
00022 void PyListToVector(PyObject *pyo, T& v)
00023 {
00024     for (int i=0; i<PySequence_Size(pyo); i++) {
00025         v[i] = boost::python::extract<double>(PySequence_GetItem(pyo, i));
00026     }
00027 }
00028 
00029 static void PyListToMatrix33(PyObject *pyo, hrp::Matrix33& M)
00030 {
00031     for (int i=0; i<9; i++) {
00032         M(i/3, i%3) = boost::python::extract<double>(PySequence_GetItem(pyo, i));
00033     }
00034 }
00035 
00036 #endif


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Wed May 15 2019 05:02:18