matplotlib 仅显示来自 stl 文件的部分网格

matplotlib shows only partial mesh from stl file

所以我在我的 stl 文件中存储了这个可爱的吉普车小模型:

为了在我的 jupyter notebook 中显示其 3D 网格,我使用了以下代码段:

from stl import mesh
from mpl_toolkits import mplot3d
from matplotlib import pyplot

tgtMesh = mesh.Mesh.from_file(r'./miljeep.stl')

figure = pyplot.figure()
axes = mplot3d.Axes3D(figure)
axes.add_collection3d(mplot3d.art3d.Poly3DCollection(tgtMesh.vectors))
scale = tgtMesh.points.flatten(-1)
axes.auto_scale_xyz(scale,scale,scale)
pyplot.show()

很遗憾,出现的是这样的:

通过简单的打印,我看到网格中只存储了 (376, 3, 3) 的矢量数组,而正确地,当完全使用 a 显示时,它应该是 (53184, 3, 3)软件在线。

所以这似乎是 matplotlib 或更可能是 numpy-stl 的问题?有人知道吗?

经过一个无所事事的周末,原来是stl文件的问题。

它本身并没有损坏,但是因为它之前使用另一个应用程序从实体模型转换为曲面模型,所以生成的 stl 文件格式不正确,numpy-stl 无法完全解析。

当时的解决方案就是简单地使用另一个应用程序打开 stl 文件(例如 MeshLab),然后再次将其导出为 stl 文件。之后正常显示了,万岁!