pyvista.voxelize#
- voxelize( )[ソース]#
メッシュをUnstructuredGrid. にボクセライズします.
- パラメータ:
- mesh
pyvista.DataSet
ボクセライズするメッシュ.
- density
float
| 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.
- mesh
- 戻り値:
pyvista.UnstructuredGrid
元のメッシュのボクセル化された非構造化グリッド.
参考
pyvista.voxelize_volume
Similar function that returns a
pyvista.RectilinearGrid
with cell data.pyvista.DataSetFilters.voxelize_binary_mask
Similar function that returns a
pyvista.ImageData
with point data.
備考
バージョン0.39.0以前では,このメソッドは構造化された座標の順序を不適切に扱っていた.
例
等密度のボクセル化メッシュを作成します.
>>> import pyvista as pv >>> from pyvista import examples >>> mesh = examples.download_bunny_coarse().clean() >>> vox = pv.voxelize(mesh, density=0.01) >>> vox.plot(show_edges=True)
不均等な密度次元を使用してボクセル化メッシュを作成します.
>>> vox = pv.voxelize(mesh, density=[0.01, 0.005, 0.002]) >>> vox.plot(show_edges=True)
Create an equal density voxel volume without enclosing input mesh.
>>> vox = pv.voxelize(mesh, density=0.01) >>> vox = vox.select_enclosed_points(mesh, tolerance=0.0) >>> vox.plot(scalars='SelectedPoints', show_edges=True)
Create an equal density voxel volume enclosing input mesh.
>>> vox = pv.voxelize(mesh, density=0.01, enclosed=True) >>> vox = vox.select_enclosed_points(mesh, tolerance=0.0) >>> vox.plot(scalars='SelectedPoints', show_edges=True)
Create a voxelized mesh that does not fit the input mesh's bounds. Notice the cropped rectangular box.
>>> mesh = pv.Cube(x_length=0.25) >>> vox = pv.voxelize(mesh=mesh, density=0.2) >>> pl = pv.Plotter() >>> _ = pl.add_mesh(mesh=vox, show_edges=True, color='yellow') >>> _ = pl.add_mesh(mesh=mesh, show_edges=True, line_width=5, opacity=0.4) >>> pl.show()
Create a voxelized mesh that fits the input mesh's bounds. The rectangular mesh is now complete. Notice that the voxel size was updated to fit the bounds in the first direction.
>>> vox = pv.voxelize(mesh=mesh, density=0.2, fit_bounds=True) >>> pl = pv.Plotter() >>> _ = pl.add_mesh(mesh=vox, show_edges=True, color='yellow') >>> _ = pl.add_mesh(mesh=mesh, show_edges=True, line_width=5, opacity=0.4) >>> pl.show()