一种通用的基于半边的多边形网格表示与操作数据结构
openmesh的Python项目详细描述
openmesh python绑定
openmesh是一种通用的基于半边的数据结构,用于表示和操作多边形网格。 openmesh python绑定与numpy紧密集成,并使用pybind11实现。
示例
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')
有关更多示例,请参阅文档或参考unit tests。
安装
使用pip
pip install openmesh
预构建的二进制文件
我们提供用于手动安装的预装车轮,对于以下配置,pip
:
Linux
MacOS 10.13
窗口
从源头建设
- 递归地克隆回购协议
cd
到回购目录- 确保激活了正确的virtualenv
pip install -e .