From e2768981f1c5eb28567e8e83e8eb1b97779a1f72 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 20 Aug 2020 18:28:03 +0200 Subject: [PATCH] implicit conversion from py::tuple to Point<2> --- libsrc/meshing/python_mesh.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index 3641ca15..64e3e0c8 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -163,6 +163,10 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) py::class_> (m, "Point2d") .def(py::init()) + .def(py::init( [] (std::pair xy) + { + return Point<2>{xy.first, xy.second}; + })) .def ("__str__", &ToString>) .def(py::self-py::self) .def(py::self+Vec<2>()) @@ -170,6 +174,8 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) .def("__getitem__", [](Point<2>& self, int index) { return self[index]; }) ; + py::implicitly_convertible>(); + py::class_> (m, "Point3d") .def(py::init()) .def ("__str__", &ToString>)