neighbors_to_file
应该将每个三角形面的邻居写入文件neigh.txt
中,并用新行分隔。此网格中的面数为352169,因此neigh.txt
中的预期线数为352169 * 3 =1056507。但是,实际的线数仅为1055697。
import openmesh as om
import os
def neighbors_to_file(mesh):
file = open("neigh.txt","w")
for f in mesh.faces(): # iterate over the mesh's faces
for ff in mesh.ff(f): # iterate over the face's neighbors
file.write(str(ff.idx()))
file.write("\n")
file.close()
path = os.path.join("../meshes", "tr_scan_000.obj")
r_mesh = om.read_trimesh(path)
neighbors_to_file(r_mesh)
据我所知,网格是封闭的,因此那里没有孔。