ADMesh、STL 操作库的 Python 绑定
项目描述
该模块为ADMesh库提供绑定。它允许您以二进制或 ASCII STL 格式操作 3D 模型,并在必要时对其进行部分修复。
安装
有适用于 Linux 和 macOS X 的轮子。您需要做的就是:
pip install admesh
如果您的平台不受上述支持,则需要安装 C ADMesh库。
此版本专为 ADMesh 0.98.x 设计。按照那里的说明进行操作。然后,您可以像往常一样使用以下方法之一安装它:
./setup.py install
python3 setup.py install # for Python 3
pip install admesh # install directly from PyPI
如果您的 ADMesh 库位于非标准位置,您必须告诉编译器和链接器在哪里查找:
LDFLAGS='-L/path/to/library' CFLAGS='-I/path/to/header' ./setup.py install
用法
使用提供的Stl类。
import admesh
# load an STL file
stl = admesh.Stl('file.stl')
# observe the available methods
help(stl)
# read the stats
stl.stats
# see how many facets are there
len(stl)
# walk the facets
for facet in stl:
# get the normal
facet['normal']
# walk the vertices
for vertex in facet['vertex']:
# read the coordinates
vertex['x']
vertex['y']
vertex['z']
# add another set of facets
# every facet is a tuple (vertices, normal) or a dict
stl.add_facets([
(((0, 0, 0), (0, 1, 0), (0, 0, 1)), (1, 0, 0)),
{'vertex': [{'x': 0, 'y': 0, 'z': 0},
{'x': 1, 'y': 0, 'z': 0},
{'x': 0, 'y': 0, 'z': 1}],
'normal': {'x': 0, 'y': 1, 'z': 0}},
])
请注意,所有 C ADMesh 函数都以stl_前缀开头,而该模块的 Python 方法则不是。另请注意,并非所有 C ADMesh 功能都提供,因为有些需要更复杂的方法并且被认为不值得。如果您缺少某些功能,请创建新问题。
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
admesh-0.98.9.tar.gz
(16.5 kB
查看哈希)
内置发行版
admesh-0.98.9-cp37-cp37m-manylinux1_i686.whl
(188.3 kB
查看哈希)
admesh-0.98.9-cp36-cp36m-manylinux1_i686.whl
(187.8 kB
查看哈希)
admesh-0.98.9-cp35-cp35m-manylinux1_i686.whl
(186.9 kB
查看哈希)
admesh-0.98.9-cp34-cp34m-manylinux1_i686.whl
(189.3 kB
查看哈希)
admesh-0.98.9-cp27-cp27m-manylinux1_i686.whl
(168.9 kB
查看哈希)