{"id":322477,"date":"2021-05-02T15:00:10","date_gmt":"2021-05-02T15:00:10","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=322477"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=322477","title":{"rendered":"\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 3D \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 \u0432 Python \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 OpenMesh"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u0415\u0441\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0438 \u043c\u043e\u0449\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c\u0438 3D \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 \u0438\u043b\u0438 \u043c\u0435\u0448\u0430\u043c\u0438 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/www.graphics.rwth-aachen.de\/media\/openmesh_static\/Documentations\/OpenMesh-6.3-Documentation\/index.html\" rel=\"noopener noreferrer nofollow\">OpenMesh<\/a>.  \u041e\u043d\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 3D \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 \u0438 \u0438\u043c\u0435\u0435\u0442 \u0432\u0435\u0440\u0441\u0438\u044e \u0432 Python. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 3D \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u0443 OpenMesh \u0434\u043b\u044f Python. \u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<h2>\u041d\u0430\u0447\u0430\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u0441 OpenMesh<\/h2>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e OpenMesh \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 C++, \u043d\u043e \u0438\u043c\u0435\u0435\u0442 <a href=\"https:\/\/pypi.org\/project\/openmesh\/\" rel=\"noopener noreferrer nofollow\">\u043e\u0431\u0435\u0440\u0442\u043a\u0443 <\/a>\u043d\u0430 \u044f\u0437\u044b\u043a\u0435 Python, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0438 \u043b\u0435\u0433\u043a\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u0442\u0430 \u043e\u0431\u0435\u0440\u0442\u043a\u0430.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043f\u0430\u043a\u0435\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e pip:<\/p>\n<pre><code>pip install openmesh<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 Python \u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c openmesh<\/p>\n<pre><code>import openmesh as om import numpy as np<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 3D \u043c\u0435\u0448<\/p>\n<pre><code>mesh = om.TriMesh()<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0435\u0440\u0448\u0438\u043d<\/p>\n<pre><code># add a a couple of vertices to the mesh vh0 = mesh.add_vertex([0, 1, 0]) vh1 = mesh.add_vertex([1, 0, 0]) vh2 = mesh.add_vertex([2, 1, 0]) vh3 = mesh.add_vertex([0,-1, 0]) vh4 = mesh.add_vertex([2,-1, 0])<\/code><\/pre>\n<p>\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u043e\u0432<\/p>\n<pre><code>fh0 = mesh.add_face(vh0, vh1, vh2) fh1 = mesh.add_face(vh1, vh3, vh4) fh2 = mesh.add_face(vh0, vh3, vh1)<\/code><\/pre>\n<p>\u0412 OpenMesh \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c VertexHandle. \u041e\u0431\u044a\u0435\u043a\u0442\u044b VertexHandle \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 OpenMesh \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430. <\/p>\n<p>\u0415\u0441\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0447\u0435\u0440\u0435\u0437 \u043f\u0438\u0442\u043e\u043d\u043e\u0432\u0441\u043a\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0435\u0440\u0448\u0438\u043d<\/p>\n<pre><code>vh_list = [vh2, vh1, vh4] fh3 = mesh.add_face(vh_list)<\/code><\/pre>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e OpenMesh \u0442\u0430\u043a\u0436\u0435 \u0432\u0432\u043e\u0434\u0438\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c Half-edge. \u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0435\u0433\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043d\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/www.graphics.rwth-aachen.de\/media\/openmesh_static\/Documentations\/OpenMesh-5.2-Documentation\/a00016.html\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<h2>\u041c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044f \u0441 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 \u0432\u0435\u0440\u0448\u0438\u043d<\/h2>\n<p>\u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u043c\u0443 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b (texture mapping) \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u043e\u0432. \u0427\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u044b <a href=\"https:\/\/help.disguise.one\/Content\/3D-Workflow\/UV-Mapping\/What-is-UV-mapping.html\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b (UV texture coordinates) \u0432\u0435\u0440\u0448\u0438\u043d\u044b:<\/p>\n<pre><code>tc = mesh.texcoord2D(vh)<\/code><\/pre>\n<p>tc \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 tuple. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 <em>u<\/em> \u0438 <em>v<\/em> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 0 \u0438 1 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b<\/p>\n<pre><code>uv_coords = [0.5, 0.2] mesh.set_texcoord2D(vh, uv_coords)<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c vh &#8212; \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0438\u043f\u0430 VertexHandle.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u043e\u0447\u043a\u0443 \u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 \u0432\u0435\u0440\u0448\u0438\u043d\u044b<\/p>\n<pre><code>point = mesh.point(vh)<\/code><\/pre>\n<p>point \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 tuple. \u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0442\u043e\u0447\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 0 \u0438 1<\/p>\n<pre><code>x, y = tc[0], tc[1]<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u0435\u0440\u0448\u0438\u043d \u043c\u043e\u0434\u0435\u043b\u0438<\/p>\n<pre><code>point_array = mesh.points()<\/code><\/pre>\n<p>\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0434\u043b\u044f \u0441\u0434\u0432\u0438\u0433\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0434\u043e\u043b\u044c \u043e\u0441\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 X)<\/p>\n<pre><code>point_array += np.array([1, 0, 0])<\/code><\/pre>\n<h3>\u0412\u0430\u0436\u043d\u044b\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 OpenMesh<\/h3>\n<p>\u041d\u0435 \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c enumerate() \u043f\u0440\u0438 \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u0435\u0440\u0448\u0438\u043d \u0432 \u0446\u0438\u043a\u043b\u0435. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b UV \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0435\u0440\u0448\u0438\u043d.<\/p>\n<p>\u041f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043c\u0435\u0448\u0430 \u0432 \u0444\u0430\u0439\u043b OpenMesh \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0434\u043b\u044f \u0432\u0435\u0440\u0448\u0438\u043d (vt \u0441\u0442\u0440\u043e\u043a\u0438) \u0432 \u0444\u0430\u0439\u043b\u0435 obj. \u0427\u0442\u043e\u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 vertex_tex_coord \u0432 \u043c\u0435\u0442\u043e\u0434 write_mesh (<a href=\"https:\/\/gist.github.com\/zishun\/0ba4f7925a1cd1ece890eb4dee4cd81e\" rel=\"noopener noreferrer nofollow\"><u>\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/u><\/a>):<\/p>\n<pre><code>om.write_mesh(\u2018test_out.obj\u2019, mesh, vertex_tex_coord=True)<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 OpenMesh \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0444\u0430\u0439\u043b \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432 mtl \u0432 \u0444\u0430\u0439\u043b\u0435 obj. \u0414\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 face_color \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u0444\u0430\u0439\u043b\u0430 obj <\/p>\n<pre><code>mesh = openmesh.read_trimesh('test.obj', vertex_tex_coord=True, face_color=True)<\/code><\/pre>\n<p>\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0444\u0430\u0439\u043b<\/p>\n<pre><code>openmesh.write_mesh('test_out.obj', mesh, vertex_tex_coord=True, face_color=True)<\/code><\/pre>\n<p>\u0422\u043e \u0436\u0435 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u0435\u0439. \u0427\u0442\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 obj \u0441 \u043d\u043e\u0440\u043c\u0430\u043b\u044f\u043c\u0438<\/p>\n<pre><code>mesh = openmesh.read_trimesh('test.obj', vertex_normal=True)<\/code><\/pre>\n<p>\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0444\u0430\u0439\u043b<\/p>\n<pre><code>openmesh.write_mesh('test_out.obj', mesh, vertex_normal=True)<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0430\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u0438 \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0435 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 face_color \u0432 \u043e\u0431\u043e\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 read_trimesh \u0438 write_mesh.<\/p>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 OpenMesh \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435: \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0432\u0435\u0440\u0448\u0438\u043d (\u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0441\u0442\u0440\u043e\u043a vt) \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 obj<\/p>\n<pre><code>f 1\/1 2\/2 3\/3<\/code><\/pre>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 obj \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a<\/p>\n<pre><code>f 1\/3 2\/1 3\/2<\/code><\/pre>\n<h2>\u0418\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0446\u0438\u043a\u043b\u044b<\/h2>\n<p>\u0418\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u0432 \u043c\u0435\u0448\u0435<\/p>\n<pre><code>for vh in mesh.vertices():     print(vh.idx())<\/code><\/pre>\n<p>\u0426\u0438\u043a\u043b for \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b vh \u0442\u0438\u043f\u0430 VertexHandle. idx() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u0432\u0435\u0440\u0448\u0438\u043d\u044b.<\/p>\n<p>\u0418\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430\u043c\u0438 \u0438 \u0433\u0440\u0430\u043d\u044f\u043c\u0438<\/p>\n<pre><code># iterate over all edges for eh in mesh.edges():     print eh.idx()  # iterate over all faces for fh in mesh.faces():     print fh.idx()<\/code><\/pre>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0443 \u043d\u0430\u0434 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u0446\u0438\u043a\u043b for \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b fh \u0442\u0438\u043f\u0430 FaceHandle.<\/p>\n<p>\u0418\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0430\u0434 \u0432\u0441\u0435\u043c\u0438 half-edge \u0432 \u043c\u0435\u0448\u0435<\/p>\n<pre><code>for heh in mesh.halfedges():     print heh.idx()<\/code><\/pre>\n<p>\u041d\u0430\u0434 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c\u0438 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439<\/p>\n<pre><code>for vh_n in mesh.vv(vh):     print(vh_n.idx())<\/code><\/pre>\n<p>\u041d\u0430\u0434 \u0433\u0440\u0430\u043d\u044f\u043c\u0438 \u0432\u044b\u0445\u043e\u0434\u044f\u0449\u0438\u043c\u0438 \u0438\u0437 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b<\/p>\n<pre><code>for eh in mesh.ve(vh1):     print eh.idx()<\/code><\/pre>\n<p>\u041d\u0430\u0434 \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430\u043c\u0438, \u0441\u043c\u0435\u0436\u043d\u044b\u043c\u0438 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u043e\u0439<\/p>\n<pre><code>for fh in mesh.vf(vh1):     print fh.idx()<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0441 \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u043e\u043c<\/p>\n<pre><code># iterate over the face's vertices for vh in mesh.fv(fh0):     print vh.idx()     # iterate over the face's halfedges for heh in mesh.fh(fh0):     print heh.idx()  # iterate over the face's edges for eh in mesh.fe(fh0):     print eh.idx()      # iterate over all edge-neighboring faces for fh in mesh.ff(fh0):     print fh.idx()<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0432\u0441\u0435. \u041d\u0435 \u0442\u0430\u043a \u0441\u043b\u043e\u0436\u043d\u043e, \u043d\u0435 \u043f\u0440\u0430\u0432\u0434\u0430 \u043b\u0438. \u0423\u0434\u0430\u0447\u0438 \u0432\u0430\u043c \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 3D \u043c\u0435\u0448\u0430\u043c\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c OpenMesh \u0438 \u0434\u043e \u043d\u043e\u0432\u044b\u0445 \u0432\u0441\u0442\u0440\u0435\u0447.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/552948\/\"> https:\/\/habr.com\/ru\/post\/552948\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u0415\u0441\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0438 \u043c\u043e\u0449\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c\u0438 3D \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 \u0438\u043b\u0438 \u043c\u0435\u0448\u0430\u043c\u0438 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/www.graphics.rwth-aachen.de\/media\/openmesh_static\/Documentations\/OpenMesh-6.3-Documentation\/index.html\" rel=\"noopener noreferrer nofollow\">OpenMesh<\/a>.  \u041e\u043d\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 3D \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 \u0438 \u0438\u043c\u0435\u0435\u0442 \u0432\u0435\u0440\u0441\u0438\u044e \u0432 Python. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 3D \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u0443 OpenMesh \u0434\u043b\u044f Python. \u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<h2>\u041d\u0430\u0447\u0430\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u0441 OpenMesh<\/h2>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e OpenMesh \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 C++, \u043d\u043e \u0438\u043c\u0435\u0435\u0442 <a href=\"https:\/\/pypi.org\/project\/openmesh\/\" rel=\"noopener noreferrer nofollow\">\u043e\u0431\u0435\u0440\u0442\u043a\u0443 <\/a>\u043d\u0430 \u044f\u0437\u044b\u043a\u0435 Python, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0438 \u043b\u0435\u0433\u043a\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u0442\u0430 \u043e\u0431\u0435\u0440\u0442\u043a\u0430.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043f\u0430\u043a\u0435\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e pip:<\/p>\n<pre><code>pip install openmesh<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 Python \u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c openmesh<\/p>\n<pre><code>import openmesh as om import numpy as np<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 3D \u043c\u0435\u0448<\/p>\n<pre><code>mesh = om.TriMesh()<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0435\u0440\u0448\u0438\u043d<\/p>\n<pre><code># add a a couple of vertices to the mesh vh0 = mesh.add_vertex([0, 1, 0]) vh1 = mesh.add_vertex([1, 0, 0]) vh2 = mesh.add_vertex([2, 1, 0]) vh3 = mesh.add_vertex([0,-1, 0]) vh4 = mesh.add_vertex([2,-1, 0])<\/code><\/pre>\n<p>\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u043e\u0432<\/p>\n<pre><code>fh0 = mesh.add_face(vh0, vh1, vh2) fh1 = mesh.add_face(vh1, vh3, vh4) fh2 = mesh.add_face(vh0, vh3, vh1)<\/code><\/pre>\n<p>\u0412 OpenMesh \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c VertexHandle. \u041e\u0431\u044a\u0435\u043a\u0442\u044b VertexHandle \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 OpenMesh \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430. <\/p>\n<p>\u0415\u0441\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0447\u0435\u0440\u0435\u0437 \u043f\u0438\u0442\u043e\u043d\u043e\u0432\u0441\u043a\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0435\u0440\u0448\u0438\u043d<\/p>\n<pre><code>vh_list = [vh2, vh1, vh4] fh3 = mesh.add_face(vh_list)<\/code><\/pre>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e OpenMesh \u0442\u0430\u043a\u0436\u0435 \u0432\u0432\u043e\u0434\u0438\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c Half-edge. \u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0435\u0433\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043d\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/www.graphics.rwth-aachen.de\/media\/openmesh_static\/Documentations\/OpenMesh-5.2-Documentation\/a00016.html\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<h2>\u041c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044f \u0441 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 \u0432\u0435\u0440\u0448\u0438\u043d<\/h2>\n<p>\u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u043c\u0443 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b (texture mapping) \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u043e\u0432. \u0427\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u044b <a href=\"https:\/\/help.disguise.one\/Content\/3D-Workflow\/UV-Mapping\/What-is-UV-mapping.html\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b (UV texture coordinates) \u0432\u0435\u0440\u0448\u0438\u043d\u044b:<\/p>\n<pre><code>tc = mesh.texcoord2D(vh)<\/code><\/pre>\n<p>tc \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 tuple. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 <em>u<\/em> \u0438 <em>v<\/em> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 0 \u0438 1 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b<\/p>\n<pre><code>uv_coords = [0.5, 0.2] mesh.set_texcoord2D(vh, uv_coords)<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c vh &#8212; \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0438\u043f\u0430 VertexHandle.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u043e\u0447\u043a\u0443 \u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 \u0432\u0435\u0440\u0448\u0438\u043d\u044b<\/p>\n<pre><code>point = mesh.point(vh)<\/code><\/pre>\n<p>point \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 tuple. \u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0442\u043e\u0447\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 0 \u0438 1<\/p>\n<pre><code>x, y = tc[0], tc[1]<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u0435\u0440\u0448\u0438\u043d \u043c\u043e\u0434\u0435\u043b\u0438<\/p>\n<pre><code>point_array = mesh.points()<\/code><\/pre>\n<p>\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0434\u043b\u044f \u0441\u0434\u0432\u0438\u0433\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0434\u043e\u043b\u044c \u043e\u0441\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 X)<\/p>\n<pre><code>point_array += np.array([1, 0, 0])<\/code><\/pre>\n<h3>\u0412\u0430\u0436\u043d\u044b\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 OpenMesh<\/h3>\n<p>\u041d\u0435 \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c enumerate() \u043f\u0440\u0438 \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u0435\u0440\u0448\u0438\u043d \u0432 \u0446\u0438\u043a\u043b\u0435. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b UV \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0435\u0440\u0448\u0438\u043d.<\/p>\n<p>\u041f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043c\u0435\u0448\u0430 \u0432 \u0444\u0430\u0439\u043b OpenMesh \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0434\u043b\u044f \u0432\u0435\u0440\u0448\u0438\u043d (vt \u0441\u0442\u0440\u043e\u043a\u0438) \u0432 \u0444\u0430\u0439\u043b\u0435 obj. \u0427\u0442\u043e\u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 vertex_tex_coord \u0432 \u043c\u0435\u0442\u043e\u0434 write_mesh (<a href=\"https:\/\/gist.github.com\/zishun\/0ba4f7925a1cd1ece890eb4dee4cd81e\" rel=\"noopener noreferrer nofollow\"><u>\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/u><\/a>):<\/p>\n<pre><code>om.write_mesh(\u2018test_out.obj\u2019, mesh, vertex_tex_coord=True)<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 OpenMesh \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0444\u0430\u0439\u043b \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432 mtl \u0432 \u0444\u0430\u0439\u043b\u0435 obj. \u0414\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 face_color \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u0444\u0430\u0439\u043b\u0430 obj <\/p>\n<pre><code>mesh = openmesh.read_trimesh('test.obj', vertex_tex_coord=True, face_color=True)<\/code><\/pre>\n<p>\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0444\u0430\u0439\u043b<\/p>\n<pre><code>openmesh.write_mesh('test_out.obj', mesh, vertex_tex_coord=True, face_color=True)<\/code><\/pre>\n<p>\u0422\u043e \u0436\u0435 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u0435\u0439. \u0427\u0442\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 obj \u0441 \u043d\u043e\u0440\u043c\u0430\u043b\u044f\u043c\u0438<\/p>\n<pre><code>mesh = openmesh.read_trimesh('test.obj', vertex_normal=True)<\/code><\/pre>\n<p>\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0444\u0430\u0439\u043b<\/p>\n<pre><code>openmesh.write_mesh('test_out.obj', mesh, vertex_normal=True)<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0430\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u0438 \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0435 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 face_color \u0432 \u043e\u0431\u043e\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 read_trimesh \u0438 write_mesh.<\/p>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 OpenMesh \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435: \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0432\u0435\u0440\u0448\u0438\u043d (\u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0441\u0442\u0440\u043e\u043a vt) \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 obj<\/p>\n<pre><code>f 1\/1 2\/2 3\/3<\/code><\/pre>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 obj \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a<\/p>\n<pre><code>f 1\/3 2\/1 3\/2<\/code><\/pre>\n<h2>\u0418\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0446\u0438\u043a\u043b\u044b<\/h2>\n<p>\u0418\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u0432 \u043c\u0435\u0448\u0435<\/p>\n<pre><code>for vh in mesh.vertices():     print(vh.idx())<\/code><\/pre>\n<p>\u0426\u0438\u043a\u043b for \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b vh \u0442\u0438\u043f\u0430 VertexHandle. idx() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u0432\u0435\u0440\u0448\u0438\u043d\u044b.<\/p>\n<p>\u0418\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430\u043c\u0438 \u0438 \u0433\u0440\u0430\u043d\u044f\u043c\u0438<\/p>\n<pre><code># iterate over all edges for eh in mesh.edges():     print eh.idx()  # iterate over all faces for fh in mesh.faces():     print fh.idx()<\/code><\/pre>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0443 \u043d\u0430\u0434 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u0446\u0438\u043a\u043b for \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b fh \u0442\u0438\u043f\u0430 FaceHandle.<\/p>\n<p>\u0418\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0430\u0434 \u0432\u0441\u0435\u043c\u0438 half-edge \u0432 \u043c\u0435\u0448\u0435<\/p>\n<pre><code>for heh in mesh.halfedges():     print heh.idx()<\/code><\/pre>\n<p>\u041d\u0430\u0434 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c\u0438 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439<\/p>\n<pre><code>for vh_n in mesh.vv(vh):     print(vh_n.idx())<\/code><\/pre>\n<p>\u041d\u0430\u0434 \u0433\u0440\u0430\u043d\u044f\u043c\u0438 \u0432\u044b\u0445\u043e\u0434\u044f\u0449\u0438\u043c\u0438 \u0438\u0437 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b<\/p>\n<pre><code>for eh in mesh.ve(vh1):     print eh.idx()<\/code><\/pre>\n<p>\u041d\u0430\u0434 \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430\u043c\u0438, \u0441\u043c\u0435\u0436\u043d\u044b\u043c\u0438 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u043e\u0439<\/p>\n<pre><code>for fh in mesh.vf(vh1):     print fh.idx()<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0441 \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u043e\u043c<\/p>\n<pre><code># iterate over the face's vertices for vh in mesh.fv(fh0):     print vh.idx()     # iterate over the face's halfedges for heh in mesh.fh(fh0):     print heh.idx()  # iterate over the face's edges for eh in mesh.fe(fh0):     print eh.idx()      # iterate over all edge-neighboring faces for fh in mesh.ff(fh0):     print fh.idx()<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0432\u0441\u0435. \u041d\u0435 \u0442\u0430\u043a \u0441\u043b\u043e\u0436\u043d\u043e, \u043d\u0435 \u043f\u0440\u0430\u0432\u0434\u0430 \u043b\u0438. \u0423\u0434\u0430\u0447\u0438 \u0432\u0430\u043c \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 3D \u043c\u0435\u0448\u0430\u043c\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c OpenMesh \u0438 \u0434\u043e \u043d\u043e\u0432\u044b\u0445 \u0432\u0441\u0442\u0440\u0435\u0447.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/552948\/\"> https:\/\/habr.com\/ru\/post\/552948\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-322477","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322477","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=322477"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322477\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=322477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=322477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=322477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}