Utilities.hh 483 Bytes
Newer Older
Alexander Dielen's avatar
Alexander Dielen committed
1
2
3
4
#ifndef OPENMESH_PYTHON_UTILITIES_HH
#define OPENMESH_PYTHON_UTILITIES_HH

#include <pybind11/pybind11.h>
5
6
#include <pybind11/numpy.h>

Alexander Dielen's avatar
Alexander Dielen committed
7
8
9
10
11
namespace py = pybind11;


template<class dtype>
py::capsule free_when_done(dtype *data) {
12
	return py::capsule(data, [](void *f) {
Alexander Dielen's avatar
Alexander Dielen committed
13
14
15
16
17
		dtype *ptr = reinterpret_cast<dtype *>(f);
		delete[] ptr;
	});
}

18
19
20
21
22
template<class dtype>
py::array_t<dtype, py::array::c_style | py::array::forcecast> make_c_style(py::array_t<dtype> _arr) {
	return _arr;
}

Alexander Dielen's avatar
Alexander Dielen committed
23
#endif