diff --git a/OpenMesh b/OpenMesh index dbcb0bf50cff107ffacdaed25aca0f159d934967..c36d8a304c5ab2457eb7969ad440c4b1ea74407b 160000 --- a/OpenMesh +++ b/OpenMesh @@ -1 +1 @@ -Subproject commit dbcb0bf50cff107ffacdaed25aca0f159d934967 +Subproject commit c36d8a304c5ab2457eb7969ad440c4b1ea74407b diff --git a/docs/readwrite.rst b/docs/readwrite.rst index 75dffb709c6166366dba9981b2f6dcf5f8da787c..c47743e3de741d25a7f4ac39cab62a1b9dbb51d8 100644 --- a/docs/readwrite.rst +++ b/docs/readwrite.rst @@ -16,3 +16,15 @@ OpenMesh provides functions that read and write meshes from and to files: om.write_mesh(trimesh, "bunny.ply") OpenMesh currently supports five file types: .obj, .off, .ply, .stl and .om + +For writing .obj files there is also support for textures. You can pass the path of a texture image and +optionally the suffix for the material file, default is ".mat", but some programs, e.g. Blender expect ".mtl" as suffix + +.. code:: python + + om.write_mesh( + "out.obj", + trimesh, + texture_file="moon.png", + material_file_extension=".mtl" # default is ".mat", blender needs ".mtl" + ) diff --git a/src/InputOutput.cc b/src/InputOutput.cc index 0c840c0c915a2aa1659bb40f196467b811be8a1c..4eca199a9c5ce2337094c054930c65fa5d0732e2 100644 --- a/src/InputOutput.cc +++ b/src/InputOutput.cc @@ -148,7 +148,9 @@ void def_write_mesh(py::module& m) { bool _face_normal, bool _face_color, bool _color_alpha, - bool _color_float + bool _color_float, + const std::string& _texture_file = "", + const std::string& _material_file_extension = ".mat" ) { OM::IO::Options options; @@ -168,6 +170,8 @@ void def_write_mesh(py::module& m) { if (_color_alpha) options += OM::IO::Options::ColorAlpha; if (_color_float) options += OM::IO::Options::ColorFloat; + options.texture_file = _texture_file; + options.material_file_extension = _material_file_extension; const bool ok = OM::IO::write_mesh(_mesh, _filename, options); @@ -191,7 +195,9 @@ void def_write_mesh(py::module& m) { py::arg("face_normal")=false, py::arg("face_color")=false, py::arg("color_alpha")=false, - py::arg("color_float")=false + py::arg("color_float")=false, + py::arg("texture_file")="", + py::arg("material_file_extension")=".mat" ); } diff --git a/src/Mesh.hh b/src/Mesh.hh index bd8e9105f101d2f0b23b74b81a5b14ba0a1191b5..050c01130af9bfbfe901bf37c4c3d996c82b143d 100644 --- a/src/Mesh.hh +++ b/src/Mesh.hh @@ -719,10 +719,21 @@ void expose_mesh(py::module& m, const char *_name) { _self.status(_h).set_deleted(_val); }) - .def("is_deleted", [](Mesh& _self, OM::HalfedgeHandle _h) { - if (!_self.has_halfedge_status()) return false; - return _self.status(_h).deleted(); - }) + .def("is_locked", [](Mesh& _self, OM::VertexHandle _h) { + if (!_self.has_vertex_status()) return false; + return _self.status(_h).locked(); + }) + + .def("set_locked", [](Mesh& _self, OM::VertexHandle _h, bool _val) { + if (!_self.has_vertex_status()) _self.request_vertex_status(); + _self.status(_h).set_locked(_val); + + }) + + .def("is_deleted", [](Mesh& _self, OM::HalfedgeHandle _h) { + if (!_self.has_halfedge_status()) return false; + return _self.status(_h).deleted(); + }) .def("set_deleted", [](Mesh& _self, OM::HalfedgeHandle _h, bool _val) { if (!_self.has_halfedge_status()) _self.request_halfedge_status();