Skip to content
Snippets Groups Projects
Commit eff5267c authored by marco's avatar marco
Browse files

added exports for std::vector<Vec2>, std::vector<Vec3>

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2550 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 2cc8cb98
No related branches found
No related tags found
No related merge requests found
...@@ -17,10 +17,13 @@ ...@@ -17,10 +17,13 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include <boost/python.hpp> #include <boost/python.hpp>
using namespace boost::python; #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <ost/geom/geom.hh> #include <ost/geom/geom.hh>
using namespace boost::python;
const Real Vec2_getitem(const geom::Vec2& v, int i) {return v[i];} const Real Vec2_getitem(const geom::Vec2& v, int i) {return v[i];}
void Vec2_setitem(geom::Vec2& v,const int i,const Real val) {v[i]=val;} void Vec2_setitem(geom::Vec2& v,const int i,const Real val) {v[i]=val;}
...@@ -54,6 +57,8 @@ void export_Vec2() ...@@ -54,6 +57,8 @@ void export_Vec2()
.def("GetY", &Vec2::GetY) .def("GetY", &Vec2::GetY)
.add_property("x", &Vec2::GetX, &Vec2::SetX) .add_property("x", &Vec2::GetX, &Vec2::SetX)
.add_property("y", &Vec2::GetY, &Vec2::SetY) .add_property("y", &Vec2::GetY, &Vec2::SetY)
; ;
class_<Vec2List>("Vec2List", init<>())
.def(vector_indexing_suite<Vec2List>())
;
} }
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include <boost/python.hpp> #include <boost/python.hpp>
using namespace boost::python; #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <ost/geom/geom.hh> #include <ost/geom/geom.hh>
using namespace boost::python;
const Real Vec3_getitem(const geom::Vec3& v, int i) {return v[i];} const Real Vec3_getitem(const geom::Vec3& v, int i) {return v[i];}
void Vec3_setitem(geom::Vec3& v,const int i,const Real val) {v[i]=val;} void Vec3_setitem(geom::Vec3& v,const int i,const Real val) {v[i]=val;}
...@@ -65,4 +65,8 @@ void export_Vec3() ...@@ -65,4 +65,8 @@ void export_Vec3()
; ;
def("Normalize", &NormalizeV3); def("Normalize", &NormalizeV3);
def("Cross", &Cross); def("Cross", &Cross);
class_<Vec3List>("Vec3List", init<>())
.def(vector_indexing_suite<Vec3List>())
;
} }
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <cstddef> // for size_t #include <cstddef> // for size_t
#include <ostream> #include <ostream>
#include <vector>
#include <boost/operators.hpp> #include <boost/operators.hpp>
#include <ost/geom/module_config.hh> #include <ost/geom/module_config.hh>
...@@ -107,6 +107,8 @@ DLLEXPORT_OST_GEOM Vec2 operator/(Real d, const Vec2& v); ...@@ -107,6 +107,8 @@ DLLEXPORT_OST_GEOM Vec2 operator/(Real d, const Vec2& v);
DLLEXPORT_OST_GEOM std::ostream& operator<<(std::ostream&, const Vec2&); DLLEXPORT_OST_GEOM std::ostream& operator<<(std::ostream&, const Vec2&);
typedef std::vector<Vec2> Vec2List;
} // namespace geom } // namespace geom
# endif # endif
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <cstddef> // for size_t #include <cstddef> // for size_t
#include <ostream> #include <ostream>
#include <vector>
#include <boost/operators.hpp> #include <boost/operators.hpp>
#include <ost/geom/module_config.hh> #include <ost/geom/module_config.hh>
...@@ -114,6 +114,8 @@ DLLEXPORT_OST_GEOM Vec3 operator/(Real, const Vec3& v); ...@@ -114,6 +114,8 @@ DLLEXPORT_OST_GEOM Vec3 operator/(Real, const Vec3& v);
DLLEXPORT_OST_GEOM std::ostream& operator<<(std::ostream&, const Vec3&); DLLEXPORT_OST_GEOM std::ostream& operator<<(std::ostream&, const Vec3&);
typedef std::vector<Vec3> Vec3List;
} // namespace geom } // namespace geom
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment