赞
踩
pip install numpy-stl
import numpy as np from stl import mesh def meshFromStl(mesh_file): # load stl # mesh_file为本地的stl文件,例如"../gripper.stl" mesh_stl = mesh.Mesh.from_file(mesh_file) mesh_vectors = mesh_stl.vectors mesh_points_num = mesh_vectors.shape[0] * mesh_vectors.shape[1] mesh_points = mesh_vectors.reshape([mesh_points_num, 3]) v_array, t_array = np.unique(mesh_points, return_inverse=True, axis=0) t_array = t_array.reshape([len(mesh_vectors), 3]) return v_array, t_array # vertex array, triangles array
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。