pyvista_js.PolyData.fill_holes

pyvista_js.PolyData.fill_holes#

PolyData.fill_holes(hole_size: float = 1000.0) PolyData#

Fill holes in a polygonal mesh.

This filter identifies and fills holes in the mesh by locating boundary edges, linking them together into loops, and then triangulating the resulting loops. A hole size threshold controls which holes are filled.

It mirrors the PyVista fill_holes filter API and replicates the behavior of the vtk.js FillHolesFilter example.

Note

The hole filling is computed in JavaScript at render time by finding boundary edges (edges belonging to only one polygon), linking them into loops, and fan-triangulating each loop whose perimeter is smaller than hole_size.

Parameters:

hole_size (float, optional) – The maximum hole size to fill, specified as the length of the perimeter of the hole. Holes with a perimeter larger than this value will not be filled. Default is 1000.0.

Returns:

A new mesh with holes filled.

Return type:

PolyData

Raises:

ValueError – If hole_size is not positive.

Examples

>>> import pyvista_js as pv
>>> sphere = pv.Sphere()
>>> filled = sphere.fill_holes(hole_size=100.0)
>>> isinstance(filled, pv.PolyData)
True

Create a sphere with a hole and fill it:

>>> import pyvista_js as pv
>>> import numpy as np
>>> # Create a sphere with a hole by clipping
>>> sphere = pv.Sphere(radius=1.0)
>>> clipped_sphere = sphere.clip(normal='z', origin=(0, 0, 0.5))
>>> # Fill the hole
>>> filled_sphere = clipped_sphere.fill_holes(hole_size=10.0)
>>> filled_sphere.plot()

Render the filled mesh:

>>> filled.plot()