From 17c4ce61826cde38ffea1ac3f9b21ce5e2bd42e6 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Sat, 6 Aug 2016 12:55:59 +0200 Subject: [PATCH 1/2] getitem MeshPoint --- libsrc/meshing/python_mesh.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index b6a9675e..32b8834d 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -105,14 +105,11 @@ DLL_HEADER void ExportNetgenMeshing() .def(bp::init>()) .def("__str__", &ToString) .def("__repr__", &ToString) - .add_property("p", FunctionPointer([](const MeshPoint & self) - { - bp::list l; - l.append ( self[0] ); - l.append ( self[1] ); - l.append ( self[2] ); - return bp::tuple(l); - })) + .def("__getitem__", FunctionPointer([](const MeshPoint & self, int index) { + if(index<0 || index>2) + bp::exec("raise IndexError()\n"); + return self[index]; + })) ; bp::class_("Element3D") From a1496ea6455d93a0ab4291cbb1952d571c442ca3 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Sat, 6 Aug 2016 13:15:21 +0200 Subject: [PATCH 2/2] property --- libsrc/meshing/python_mesh.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index 32b8834d..3bd8b1f1 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -105,6 +105,14 @@ DLL_HEADER void ExportNetgenMeshing() .def(bp::init>()) .def("__str__", &ToString) .def("__repr__", &ToString) + .add_property("p", FunctionPointer([](const MeshPoint & self) + { + bp::list l; + l.append ( self[0] ); + l.append ( self[1] ); + l.append ( self[2] ); + return bp::tuple(l); + })) .def("__getitem__", FunctionPointer([](const MeshPoint & self, int index) { if(index<0 || index>2) bp::exec("raise IndexError()\n");