- PolyData.boolean_union(other_mesh, tolerance=1e-05, progress_bar=False)#
Perform a boolean union operation on two meshes.
Essentially, boolean union, difference, and intersection are all the same operation. Just different parts of the objects are kept at the end.
The union of two manifold meshes
Bis the mesh which is in
B, or in both
If your boolean operations don’t react the way you think they should (i.e. the wrong parts disappear), one of your meshes probably has its normals pointing inward. Use
PolyDataFilters.plot_normals()to visualize the normals.
The behavior of this filter varies from the
PolyDataFilters.merge()filter. This filter attempts to create a manifold mesh and will not include internal surfaces when two meshes overlap.
Changed in version 0.32.0: Behavior changed to match default VTK behavior.
The result of the boolean operation.
Demonstrate a boolean union with two spheres. Note how the final mesh includes both spheres.
>>> import pyvista >>> sphere_a = pyvista.Sphere() >>> sphere_b = pyvista.Sphere(center=(0.5, 0, 0)) >>> result = sphere_a.boolean_union(sphere_b) >>> pl = pyvista.Plotter() >>> _ = pl.add_mesh(sphere_a, color='r', style='wireframe', line_width=3) >>> _ = pl.add_mesh(sphere_b, color='b', style='wireframe', line_width=3) >>> _ = pl.add_mesh(result, color='tan') >>> pl.camera_position = 'xz' >>> pl.show()
See Boolean Operations for more examples using this filter.