python - 写入文件:行数不匹配
问题描述
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)
据我所知,网格是封闭的,因此那里没有孔。
解决方案
推荐阅读
- mongodb - 聚合和展开数组,但保留顶级键
- java - java.lang.NoClassDefFoundError: okhttp3/ConnectionPool Eclipse 错误
- javascript - React plotly 条形图:颜色条取决于 x 值
- kotlin - 传递 lambda 作为扩展方法
- python-3.x - 如何删除附加到数据框中变量值的不需要的字符
- html - 如何为 Quasar 中的一行项目添加超链接?
- kotlin - 通过实现委托类访问外部类的干净方式
- sql-server - 如何从 Google Cloud Compute Engine 连接本地 SQL Server 数据库实例
- arrays - 如何直接修改 Julia 库 Flux 中的权重值?
- r - 使用 ggbiplot 在 R 中可视化具有大量变量的 PCA