File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1
1
#include " pybind11/pybind11.h"
2
2
#include " pybind11/stl.h"
3
3
#include " pybind11/numpy.h"
4
+ #include < cstring>
4
5
5
6
// Use double precision for better python integration.
6
7
#define TINYOBJLOADER_USE_DOUBLE
@@ -114,7 +115,13 @@ PYBIND11_MODULE(tinyobjloader, tobj_module)
114
115
115
116
py::class_<mesh_t >(tobj_module, " mesh_t" )
116
117
.def (py::init<>())
117
- .def_readonly (" indices" , &mesh_t ::indices);
118
+ .def_readonly (" indices" , &mesh_t ::indices)
119
+ .def (" numpy_indices" , [] (mesh_t &instance) {
120
+ auto ret = py::array_t <int >(instance.indices .size () * 3 );
121
+ py::buffer_info buf = ret.request ();
122
+ memcpy (buf.ptr , instance.indices .data (), instance.indices .size () * 3 * sizeof (int ));
123
+ return ret;
124
+ });
118
125
119
126
py::class_<lines_t >(tobj_module, " lines_t" )
120
127
.def (py::init<>());
You can’t perform that action at this time.
0 commit comments