pyvista.voxelize_volume

pyvista.voxelize_volume#

voxelize_volume(
mesh,
density=None,
check_surface: bool = True,
enclosed: bool = False,
fit_bounds: bool = False,
)[ソース]#

メッシュをボクセル化して,RectilinearGridボクセルボリュームを作成します.

入力メッシュを包含するボクセルボリュームを作成し,ボリューム内で交差するセルまたは入力メッシュ内に含まれるセルを離散化します. "cell_data" の中の配列 "InsideMesh" は,内部のセルに対して"1"であり,外部のセルに対して "0" です.

パラメータ:
meshpyvista.DataSet

ボクセライズするメッシュ.

densityfloat | array_like[float]

単一フロートが渡された場合のボクセルの均一サイズ.x,y,z方向に値のリストが渡される場合は,デフォルトはメッシュ長の100分の1.

check_surfacebool, default: True

サーフェスの閉合をチェックするかどうかを指定します.オンの場合,アルゴリズムは最初にサーフェスが閉じて多様体であるかどうかをチェックします.サーフェスが閉じていて多様体でない場合,ランタイムエラーが発生します.

enclosedbool, default: False

If True, the voxel bounds will be outside the mesh. If False, the voxel bounds will be at or inside the mesh bounds.

fit_boundsbool, default: False

If enabled, the end bound of the input mesh is used as the end bound of the voxel grid and the density is updated to the closest compatible one. Otherwise, the end bound is excluded. Has no effect if enclosed is enabled.

戻り値:
pyvista.RectilinearGrid

RectilinearGridは,離散化されたセルを持つボクセル化されたボリュームとして機能します.

参考

pyvista.voxelize

Similar function that returns a pyvista.UnstructuredGrid of VOXEL cells.

pyvista.DataSetFilters.voxelize_binary_mask

Similar function that returns a pyvista.ImageData with point data.

pyvista.DataSetFilters.select_enclosed_points

入力メッシュから等密度ボクセルボリュームを作成します.

>>> import pyvista as pv
>>> import numpy as np

PyVistaの例からファイルをロードします.

>>> from pyvista import examples
>>> mesh = examples.download_cow()

等密度ボクセルボリュームを作成し,結果をプロットします.

>>> vox = pv.voxelize_volume(mesh, density=0.15)
>>> cpos = [(15, 3, 15), (0, 0, 0), (0, 0, 0)]
>>> vox.plot(scalars='InsideMesh', show_edges=True, cpos=cpos)
../../../_images/pyvista-voxelize_volume-1_00_00.png

ボクセルボリュームをスライスして, InsideMesh を表示します.

>>> slices = vox.slice_orthogonal()
>>> slices.plot(scalars='InsideMesh', show_edges=True)
../../../_images/pyvista-voxelize_volume-1_01_00.png

不均一な密度の次元からボクセルボリュームを作成し,結果をプロットします.

>>> vox = pv.voxelize_volume(mesh, density=[0.15, 0.15, 0.5])
>>> vox.plot(scalars='InsideMesh', show_edges=True, cpos=cpos)
../../../_images/pyvista-voxelize_volume-1_02_00.png

不均等な密度のボクセルボリュームをスライスして, InsideMesh を表示します.

>>> slices = vox.slice_orthogonal()
>>> slices.plot(scalars='InsideMesh', show_edges=True, cpos=cpos)
../../../_images/pyvista-voxelize_volume-1_03_00.png

Create an equal density voxel volume without enclosing input mesh.

>>> vox = pv.voxelize_volume(mesh, density=0.15)
>>> vox = vox.select_enclosed_points(mesh, tolerance=0.0)
>>> vox.plot(scalars='SelectedPoints', show_edges=True, cpos=cpos)
../../../_images/pyvista-voxelize_volume-1_04_00.png

Create an equal density voxel volume enclosing input mesh.

>>> vox = pv.voxelize_volume(mesh, density=0.15, enclosed=True)
>>> vox = vox.select_enclosed_points(mesh, tolerance=0.0)
>>> vox.plot(scalars='SelectedPoints', show_edges=True, cpos=cpos)
../../../_images/pyvista-voxelize_volume-1_05_00.png

Create an equal density voxel volume that does not fit the input mesh's bounds.

>>> mesh = pv.examples.load_nut()
>>> vox = pv.voxelize_volume(mesh=mesh, density=2.5)
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(mesh=vox, show_edges=True)
>>> _ = pl.add_mesh(mesh=mesh, show_edges=True, opacity=1)
>>> pl.show()
../../../_images/pyvista-voxelize_volume-1_06_00.png

Create an equal density voxel volume that fits the input mesh's bounds.

>>> vox = pv.voxelize_volume(mesh=mesh, density=2.5, fit_bounds=True)
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(mesh=vox, show_edges=True)
>>> _ = pl.add_mesh(mesh=mesh, show_edges=True, opacity=1)
>>> pl.show()
../../../_images/pyvista-voxelize_volume-1_07_00.png