You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OpenMesh is a versatile halfedge-based data structure for representing and manipulating polygon meshes.
The OpenMesh Python bindings are are tightly integrated with numpy and are implemented using pybind11.
Example
importopenmeshasomimportnumpyasnpmesh=om.TriMesh()
# add a a couple of vertices to the meshvh0=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])
# add a couple of faces to the meshfh0=mesh.add_face(vh0, vh1, vh2)
fh1=mesh.add_face(vh1, vh3, vh4)
fh2=mesh.add_face(vh0, vh3, vh1)
# add another face to the mesh, this time using a listvh_list= [vh2, vh1, vh4]
fh3=mesh.add_face(vh_list)
# 0 ==== 2# |\ 0 /|# | \ / |# |2 1 3|# | / \ |# |/ 1 \|# 3 ==== 4# get the point with vertex handle vh0point=mesh.point(vh0)
# get all points of the meshpoint_array=mesh.points()
# translate the mesh along the x-axispoint_array+=np.array([1, 0, 0])
# write and read meshesom.write_mesh('test.off', mesh)
mesh_2=om.read_trimesh('test_off')
For further examples see the documentation or refer to the unit tests.
Installation
Using pip
pip install openmesh
Prebuilt Binaries
We provide prebuilt wheels for manual installation with pip for the following configurations: