From 9f9ad8fa2e9693c213c592221c23d2f4ad64db62 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Tue, 12 Apr 2022 07:21:14 +0200 Subject: [PATCH] return mesh.Coordinates returns py::array --- libsrc/meshing/python_mesh.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index d2c85f11..91b14bd3 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -855,23 +855,14 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) py::return_value_policy::reference) .def("Coordinates", [](Mesh & self) { - size_t shape[2] = { self.Points().Size(), size_t(self.GetDimension()) }; - size_t stride[2] = { sizeof(self.Points()[0]), sizeof(double) }; - - return py::memoryview::from_buffer - (&self.Points()[PointIndex::BASE](0), sizeof(double), - py::format_descriptor::value, - { self.Points().Size(), size_t(self.GetDimension()) }, - { sizeof(self.Points()[1]), sizeof(double) } ); - - /* - // how to avoid copying array ? return py::array ( - shape, stride, - &self.Points()[PointIndex::BASE](0) // , borrowed_t{} // how to use borrow ? + py::memoryview::from_buffer + (&self.Points()[PointIndex::BASE](0), sizeof(double), + py::format_descriptor::value, + { self.Points().Size(), size_t(self.GetDimension()) }, + { sizeof(self.Points()[PointIndex::BASE]), sizeof(double) } ) ); - */ }) .def("FaceDescriptor", static_cast (&Mesh::GetFaceDescriptor),