写入文件:行数不匹配

时间:2019-05-23 07:06:58

标签: python mesh writetofile

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)

据我所知,网格是封闭的,因此那里没有孔。

0 个答案:

没有答案