pyvista.PolyDataFilters.merge#

PolyDataFilters.merge(
dataset,
merge_points=True,
tolerance=0.0,
inplace=False,
main_has_priority=True,
progress_bar=False,
)[source]#

Merge this mesh with one or more datasets.

Note

The behavior of this filter varies from the PolyDataFilters.boolean_union() filter. This filter does not attempt to create a manifold mesh and will include internal surfaces when two meshes overlap.

Note

The + operator between two meshes uses this filter with the default parameters. When the other mesh is also a pyvista.PolyData, in-place merging via += is similarly possible.

Changed in version 0.39.0: Before version 0.39.0, if all input datasets were of type pyvista.PolyData, the VTK vtkAppendPolyDataFilter and vtkCleanPolyData filters were used to perform merging. Otherwise, DataSetFilters.merge(), which uses the VTK vtkAppendFilter filter, was called. To enhance performance and coherence with merging operations available for other datasets in pyvista, the merging operation has been delegated in 0.39.0 to DataSetFilters.merge() only, irrespectively of input datasets types. This induced that points ordering can be altered compared to previous pyvista versions when merging only PolyData together. To obtain similar results as before 0.39.0 for multiple PolyData, combine PolyDataFilters.append_polydata() and PolyDataFilters.clean().

Parameters:
datasetpyvista.DataSet

PyVista dataset to merge this mesh with.

merge_pointsbool, optional

Merge equivalent points when True.

tolerancefloat, default: 0.0

The absolute tolerance to use to find coincident points when merge_points=True.

inplacebool, default: False

Updates grid inplace when True if the input type is a pyvista.PolyData. For other input meshes the result is a pyvista.UnstructuredGrid which makes in-place operation impossible.

main_has_prioritybool, optional

When this parameter is True and merge_points=True, the arrays of the merging grids will be overwritten by the original main mesh.

progress_barbool, default: False

Display a progress bar to indicate progress.

Returns:
pyvista.DataSet

pyvista.PolyData if dataset is a pyvista.PolyData, otherwise a pyvista.UnstructuredGrid.

Examples

>>> import pyvista as pv
>>> sphere_a = pv.Sphere()
>>> sphere_b = pv.Sphere(center=(0.5, 0, 0))
>>> merged = sphere_a.merge(sphere_b)
>>> merged.plot(style='wireframe', color='lightblue')
../../../_images/pyvista-PolyDataFilters-merge-1_00_00.png