Skip to content

Commit

Permalink
Add conditional mesh import/export to python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
occivink committed Oct 9, 2024
1 parent fe66db4 commit 3667ccd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion bindings/python/manifold3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#include "manifold/cross_section.h"
#include "manifold/manifold.h"
#include "manifold/polygon.h"
#ifdef MANIFOLD_EXPORT
#include "manifold/meshIO.h"
#endif
#include "nanobind/nanobind.h"
#include "nanobind/ndarray.h"
#include "nanobind/operators.h"
Expand All @@ -27,6 +30,7 @@
#include "nanobind/stl/pair.h"
#include "nanobind/stl/tuple.h"
#include "nanobind/stl/vector.h"
#include "nanobind/stl/string.h"

namespace nb = nanobind;
using namespace manifold;
Expand Down Expand Up @@ -570,7 +574,20 @@ NB_MODULE(manifold3d, m) {
.def_ro("run_index", &MeshGL::runIndex)
.def_ro("run_original_id", &MeshGL::runOriginalID)
.def_ro("face_id", &MeshGL::faceID)
.def("merge", &MeshGL::Merge, mesh_gl__merge);
.def("merge", &MeshGL::Merge, mesh_gl__merge)
#ifdef MANIFOLD_EXPORT
.def(
"export_mesh",
[](const MeshGL &self, const std::string &filename) {
ExportMesh(filename, self, {});
},
nb::arg("filename"))
.def_static("import_mesh",
[](const std::string &filename) -> MeshGL {
return ImportMesh(filename);
}, nb::arg("filename"))
#endif
;

nb::enum_<Manifold::Error>(m, "Error")
.value("NoError", Manifold::Error::NoError)
Expand Down

0 comments on commit 3667ccd

Please sign in to comment.