subdivide#
- PolyDataFilters.subdivide(nsub, subfilter='linear', inplace=False, progress_bar=False)[source]#
Increase the number of triangles in a single, connected triangular mesh.
Uses one of the following vtk subdivision filters to subdivide a mesh:
vtkButterflySubdivisionFilter
vtkLoopSubdivisionFilter
vtkLinearSubdivisionFilter
Linear subdivision results in the fastest mesh subdivision, but it does not smooth mesh edges, but rather splits each triangle into 4 smaller triangles.
Butterfly and loop subdivision perform smoothing when dividing, and may introduce artifacts into the mesh when dividing.
Note
Subdivision filter sometimes fails for multiple part meshes. The input should be one connected mesh.
- Parameters:
- nsub
int
Number of subdivisions. Each subdivision creates 4 new triangles, so the number of resulting triangles is
nface*4**nsub
wherenface
is the current number of faces.- subfilter
str
,optional
Can be one of the following:
'butterfly'
'loop'
'linear'
- inplacebool,
optional
Updates mesh in-place. Default
False
.- progress_barbool,
optional
Display a progress bar to indicate progress.
- nsub
- Returns:
pyvista.PolyData
Subdivided mesh.
Examples
First, create an example coarse sphere mesh and plot it.
>>> from pyvista import examples >>> import pyvista >>> mesh = pyvista.Sphere(phi_resolution=10, theta_resolution=10) >>> mesh.plot(show_edges=True, line_width=3)
Subdivide the sphere mesh using linear subdivision.
>>> submesh = mesh.subdivide(1, 'linear') >>> submesh.plot(show_edges=True, line_width=3)
Subdivide the sphere mesh using loop subdivision.
>>> submesh = mesh.subdivide(1, 'loop') >>> submesh.plot(show_edges=True, line_width=3)
Subdivide the sphere mesh using butterfly subdivision.
>>> submesh = mesh.subdivide(1, 'butterfly') >>> submesh.plot(show_edges=True, line_width=3)