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 11#include " pybind11/pybind11.h"
22#include " pybind11/stl.h"
33#include " pybind11/numpy.h"
4+ #include < cstring>
45
56// Use double precision for better python integration.
67#define TINYOBJLOADER_USE_DOUBLE
@@ -114,7 +115,13 @@ PYBIND11_MODULE(tinyobjloader, tobj_module)
114115
115116 py::class_<mesh_t >(tobj_module, " mesh_t" )
116117 .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+ });
118125
119126 py::class_<lines_t >(tobj_module, " lines_t" )
120127 .def (py::init<>());
You can’t perform that action at this time.
0 commit comments