1

我处理一个大的 .stl 文件,我想使用边界框将其切割成碎片。为此,我使用trimeshpython 包来加载 .stl。

这是用于生成边界框的代码:

box = trimesh.creation.box(extents=[1.5, 1.5, 1.5])
    print(box.facets_origin)
    print(box.facets_normal)

所以我得到了回报:

print(box.facets_origin)
[[-0.75 -0.75  0.75]
 [ 0.75 -0.75 -0.75]
 [-0.75  0.75 -0.75]
 [-0.75 -0.75  0.75]
 [-0.75  0.75  0.75]
 [ 0.75  0.75 -0.75]]

print(box.facets_normal)
 [[-1.  0.  0.]
 [ 0. -1.  0.]
 [ 0.  0. -1.]
 [ 0.  0.  1.]
 [ 0.  1.  0.]
 [ 1.  0.  0.]]

这意味着盒子的重心在 (0, 0, 0)

然后我打算用slice_plane function. 但是,我想更改边界框的质心位置或构面的位置。

如何使用 trimesh 来完成?还是另一个 Python 包?

在此先感谢您的帮助 !

约阿希姆

4

1 回答 1

1

你能不翻译这个盒子吗

mesh.apply_transform(trimesh.transformations.scale_and_translate())

https://github.com/mikedh/trimesh/blob/master/trimesh/transformations.py

于 2021-04-19T13:04:10.500 回答