注釈
Go to the end をクリックすると完全なサンプルコードをダウンロードできます.
セルの細分化#
単一の接続された3角形メッシュ内の3角形の数を増やします.
pyvista.PolyDataFilters.subdivide()
フィルタは, butterfly , loop , linear の3つの異なるサブディビジョンアルゴリズムを使用してメッシュのセルをサブディバイドします.
from __future__ import annotations
import pyvista as pv
from pyvista import examples
First, let's load a triangulated mesh to subdivide. We can use the
pyvista.DataObjectFilters.triangulate()
filter to ensure the mesh we are
using is purely triangles.
ここで,メッシュをいくつか分割して,結果を比較してみましょう.以下は,さまざまな小区分の比較プロットを作成するヘルパー関数です.
def plot_subdivisions(mesh, a, b):
display_args = dict(show_edges=True, color=True)
p = pv.Plotter(shape=(3, 3))
for i in range(3):
p.subplot(i, 0)
p.add_mesh(mesh, **display_args)
p.add_text('Original Mesh')
def row_plot(row, subfilter):
subs = [a, b]
for i in range(2):
p.subplot(row, i + 1)
p.add_mesh(mesh.subdivide(subs[i], subfilter=subfilter), **display_args)
p.add_text(f'{subfilter} subdivision of {subs[i]}')
row_plot(0, 'linear')
row_plot(1, 'butterfly')
row_plot(2, 'loop')
p.link_views()
p.view_isometric()
return p
1レベルと3レベルの区画を実行します.
plotter = plot_subdivisions(mesh, 1, 3)
plotter.camera_position = cpos
plotter.show()

Total running time of the script: (0 minutes 1.808 seconds)