[![trimesh](https://trimsh.org/images/logotype-a.svg)](http://trimsh.org)
-----------
[![Build Status](https://travis-ci.org/mikedh/trimesh.svg?branch=master)](https://travis-ci.org/mikedh/trimesh) [![Build status](https://ci.appveyor.com/api/projects/status/j8h3luwvst1tkghl?svg=true)](https://ci.appveyor.com/project/mikedh/trimesh) [![Coverage Status](https://coveralls.io/repos/github/mikedh/trimesh/badge.svg)](https://coveralls.io/github/mikedh/trimesh) [![PyPI version](https://badge.fury.io/py/trimesh.svg)](https://badge.fury.io/py/trimesh) [![Join the chat at https://gitter.im/trimsh/Lobby](https://badges.gitter.im/trimsh/Lobby.svg)](https://gitter.im/trimsh/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Trimesh is a pure Python (2.7- 3.3+) library for loading and using [triangular meshes](https://en.wikipedia.org/wiki/Triangle_mesh) with an emphasis on watertight meshes. The goal of the library is to provide a fully featured and well tested Trimesh object which allows for easy manipulation and analysis, in the style of the Polygon object in the [Shapely library](http://toblerity.org/shapely/manual.html).
The API is mostly stable, but this should not be relied on and is not guaranteed; install a specific version if you plan on deploying something using trimesh as a backend.
Pull requests are hugely appreciated and responded to promptly! If you'd like to contribute, here is an [up to date list of potential enhancements](https://github.com/mikedh/trimesh/issues/199) although things not on that list are also welcome. Also, some [general advice for writing mesh code in Python and Numpy.](https://github.com/mikedh/trimesh/blob/master/trimesh/io/README.md)
## Basic Installation
The minimal requirements to import trimesh are
[numpy](http://www.numpy.org/), [scipy](http://www.scipy.org) and
[networkx](https://networkx.github.io). Installing other packages mentioned adds functionality but is **not required**.
For the easiest install with only these minimal dependencies (slower ray queries, no vector path handling, mesh creation, viewer, etc):
```bash
pip install trimesh
```
For more functionality, the easiest way to get a full `trimesh` install is a [conda environment](https://conda.io/miniconda.html):
```bash
# this will install all soft dependencies available on your current platform
conda install -c conda-forge trimesh
```
Further information is available in the [advanced installation documentation](https://trimsh.org/install.html).
## Quick Start
Here is an example of loading a mesh from file and colorizing its faces. Here is a nicely formatted
[ipython notebook version](https://trimsh.org/examples/quick_start.html) of this example. Also check out the [cross section example](https://trimsh.org/examples/section.html) or possibly the [integration of a function over a mesh example](https://github.com/mikedh/trimesh/blob/master/examples/integrate.ipynb).
```python
import numpy as np
import trimesh
# attach to logger so trimesh messages will be printed to console
trimesh.util.attach_to_log()
# load a file by name or from a buffer
mesh = trimesh.load('../models/featuretype.STL')
# is the current mesh watertight?
mesh.is_watertight
# what's the euler number for the mesh?
mesh.euler_number
# the convex hull is another Trimesh object that is available as a property
# lets compare the volume of our mesh with the volume of its convex hull
np.divide(mesh.volume, mesh.convex_hull.volume)
# since the mesh is watertight, it means there is a
# volumetric center of mass which we can set as the origin for our mesh
mesh.vertices -= mesh.center_mass
# what's the moment of inertia for the mesh?
mesh.moment_inertia
# if there are multiple bodies in the mesh we can split the mesh by
# connected components of face adjacency
# since this example mesh is a single watertight body we get a list of one mesh
mesh.split()
# facets are groups of coplanar adjacent faces
# set each facet to a random color
# colors are 8 bit RGBA by default (n,4) np.uint8
for facet in mesh.facets:
mesh.visual.face_colors[facet] = trimesh.visual.random_color()
# preview mesh in an opengl window if you installed pyglet with pip
mesh.show()
# transform method can be passed a (4,4) matrix and will cleanly apply the transform
mesh.apply_transform(trimesh.transformations.random_rotation_matrix())
# axis aligned bounding box is available
mesh.bounding_box.extents
# a minimum volume oriented bounding box also available
# primitives are subclasses of Trimesh objects which automatically generate
# faces and vertices from data stored in the 'primitive' attribute
mesh.bounding_box_oriented.primitive.extents
mesh.bounding_box_oriented.primitive.transform
# show the mesh appended with its oriented bounding box
# the bounding box is a trimesh.primitives.Box object, which subclasses
# Trimesh and lazily evaluates to fill in vertices and faces when requested
# (press w in viewer to see triangles)
(mesh + mesh.bounding_box_oriented).show()
# bounding spheres and bounding cylinders of meshes are also
# available, and will be the minimum volume version of each
# except in certain degenerate cases, where they will be no worse
# than a least squares fit version of the primitive.
print(mesh.bounding_box_oriented.volume,
mesh.bounding_cylinder.volume,
mesh.bounding_sphere.volume)
```
## Features
* Import meshes from binary/ASCII STL, Wavefront OBJ, ASCII OFF, binary/ASCII PLY, GLTF/GLB 2.0, 3MF, XAML, 3DXML, etc.
* Import and export 2D or 3D vector paths from/to DXF or SVG files
* Export meshes as binary STL, binary PLY, ASCII OFF, GLTF/GLB 2.0, COLLADA, dictionaries, JSON- serializable dictionaries (base64 encoded arrays), MSGPACK- serializable dictionaries (binary string arrays)
* Preview meshes using pyglet
* Preview meshes in- line in jupyter notebooks using three.js
* Automatic hashing of numpy arrays for change tracking (MD5, zlib CRC, and xxhash)
* Internal caching of computed values validated using numpy hashes
* Fast loading of binary files through importers written by defining custom numpy dtypes
* Calculate things like face adjacencies, face angles, vertex defects, etc.
* Calculate cross sections (IE the slicing operation used in 3D printing)
* Split mesh based on face connectivity using networkx, graph-tool, or scipy.sparse
* Calculate mass properties, including volume, center of mass, moment of inertia, and principal components of inertia
* Fix triangle winding and normals to be consistent
* Find convex hulls of meshes
* Compute a rotation/translation/tessellation invariant identifier for meshes
* Determine duplicate meshes from identifier
* Determine if a mesh is watertight, convex, etc.
* Repair single triangle and single quad holes
* Uniformly sample the surface of a mesh
* Ray-mesh queries including location, triangle id, etc.
* Boolean operations on meshes (intersection, union, difference) using OpenSCAD or Blender as backend
* Voxelize watertight meshes
* Subdivide faces of a mesh
* Minimum volume oriented bounding boxes for meshes
* Minimum volume bounding sphere / n-spheres
* Symbolic integration of function(x,y,z) over a triangle
* Calculate nearest point on mesh surface and signed distance
* Determine if a point lies inside or outside of a mesh using signed distance
* Create primitive objects (Box, Cylinder, Sphere, Extrusion) which are subclassed Trimesh objects and have all the same features (inertia, viewers, etc)
* Simple scene graph and transform tree which can be rendered (pyglet window or three.js in a jupyter notebook) or exported.
* Numerous utility functions, such as transforming points, unitizing vectors, tracking arrays for changes, grouping rows, etc.
## Design Use Case
The `trimesh.Trimesh` object is most useful on single body, watertight meshes that represent a volume. The design use case is around analysis of geometry exported from a CAD system into a mesh format, for applications related to robotic
没有合适的资源?快使用搜索试试~ 我知道了~
PyPI 官网下载 | trimesh-2.33.15.tar.gz
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 197 浏览量
2022-01-17
03:06:21
上传
评论
收藏 256KB GZ 举报
温馨提示
共102个文件
py:84个
template:7个
txt:4个
资源来自pypi官网。 资源全名:trimesh-2.33.15.tar.gz
资源详情
资源评论
资源推荐
收起资源包目录
PyPI 官网下载 | trimesh-2.33.15.tar.gz (102个子文件)
setup.cfg 38B
MANIFEST.in 37B
units_to_inches.json 1KB
README.md 9KB
LICENSE.md 1KB
PKG-INFO 11KB
PKG-INFO 11KB
base.py 81KB
transformations.py 68KB
util.py 49KB
path.py 38KB
scene.py 29KB
dxf.py 28KB
graph.py 27KB
creation.py 25KB
voxel.py 21KB
collision.py 21KB
primitives.py 20KB
visual.py 20KB
polygons.py 19KB
grouping.py 19KB
ply.py 18KB
triangles.py 18KB
caching.py 18KB
gltf.py 17KB
proximity.py 17KB
xml_based.py 17KB
load.py 14KB
transforms.py 14KB
viewer.py 14KB
traversal.py 13KB
bounds.py 13KB
intersections.py 13KB
simplify.py 13KB
ray_triangle.py 12KB
points.py 11KB
ray_pyembree.py 11KB
repair.py 10KB
entities.py 10KB
poses.py 10KB
packing.py 9KB
geometry.py 8KB
wavefront.py 8KB
svg_io.py 8KB
stl.py 8KB
rendering.py 7KB
threemf.py 7KB
arc.py 7KB
curvature.py 6KB
inertia.py 6KB
export.py 6KB
convex.py 6KB
openctm.py 6KB
urdf.py 6KB
misc.py 5KB
registration.py 5KB
constants.py 5KB
ray_util.py 5KB
sample.py 4KB
misc.py 4KB
nsphere.py 4KB
comparison.py 4KB
remesh.py 4KB
permutate.py 4KB
load.py 4KB
integrate.py 4KB
units.py 4KB
curve.py 3KB
assimp.py 3KB
raster.py 3KB
generic.py 3KB
viewerJS.py 3KB
setup.py 2KB
intersections.py 2KB
scad.py 2KB
boolean.py 2KB
util.py 2KB
blender.py 2KB
creation.py 2KB
export.py 2KB
vhacd.py 1KB
decomposition.py 901B
__init__.py 698B
__init__.py 573B
__init__.py 183B
__init__.py 73B
__init__.py 61B
__init__.py 33B
version.py 24B
__init__.py 0B
__init__.py 0B
viewer.html.template 68KB
collada.dae.template 4KB
yafaray.xml.template 3KB
dxf.json.template 2KB
blender.py.template 1KB
ply.template 479B
svg.xml.template 252B
SOURCES.txt 2KB
requires.txt 204B
共 102 条
- 1
- 2
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0