注釈
Go to the end to download the full example code.
他のオブジェクトのラップ#
pyvistaを使用すると,次のようないくつかのオブジェクトタイプをラップできます.
`numpy` 配列
`trimesh.Trimesh` メッシュ
VTKオブジェクト
これにより,モジュール性のためにPythonに特別な "両方の世界の最良の部分" なプログラミングが可能になります.pyvistaに何らかの制限がある場合(またはtrimesh),複数のモジュールの最良の機能を使用するようにスクリプトを調整することができます.
多数のランダムなポイントで構成されるポイントクラウドをラップする
import numpy as np
import pyvista as pv
rng = np.random.default_rng(seed=0)
points = rng.random((30, 3))
cloud = pv.wrap(points)
pv.plot(
cloud,
scalars=points[:, 2],
render_points_as_spheres=True,
point_size=50,
opacity=points[:, 0],
cpos='xz',
)

Trimeshのインスタンスをラップする
PolyData (0x7f7036b8ac80)
N Cells: 1
N Points: 3
N Strips: 0
X Bounds: 0.000e+00, 0.000e+00
Y Bounds: 0.000e+00, 1.000e+00
Z Bounds: 0.000e+00, 1.000e+00
N Arrays: 0
vtk.vtkPolyData のインスタンスをラップする
PolyData (0x7f70364269e0)
N Cells: 1
N Points: 1
N Strips: 0
X Bounds: 1.000e+00, 1.000e+00
Y Bounds: 2.000e+00, 2.000e+00
Z Bounds: 3.000e+00, 3.000e+00
N Arrays: 0
Total running time of the script: (0 minutes 0.557 seconds)