mesh.Mesh.cut_with_plane#
- Mesh.cut_with_plane(p, n, side='+', closed=False)#
Cut a triangular Mesh with a plane.
This operation splits a mesh by a plane defined by a point and a normal vector. It returns the portion of the mesh lying on the selected side of the plane. Unlike
clip_with_plane(), this function modifies elements that intersect with the plane by slicing them, possibly generating new triangles along the cut.Parameters#
- parray_like of shape (3,)
A point lying on the cutting plane.
- narray_like of shape (3,)
The normal vector defining the cutting plane.
- side: ‘+’ | ‘-’
Default (‘+’) is to return the elements at the positive side of the plane, as defined by the normal vector.
- closedbool
Whether to fill (cap) the open section created by cutting the mesh. If
True, a new set of triangles is generated along the cutting plane to close the opening, preserving watertightness if the original mesh was closed.
Returns#
- Mesh
A new mesh corresponding to the portion of the original mesh lying on the selected side of the cutting plane.
Notes#
This method is only implemented for meshes with
eltype='tri3'.See Also#
clip_with_plane(): Similar operation, but only keeps complete elements on one side of the plane without modifying or generating new ones.
Examples#
>>> cube = Mesh(eltype='hex8').border_mesh().convert('tri3') >>> half = cube.cut_with_plane([0.5, 0.0, 0.0], [1.0, 0.0, 0.0]) >>> print(half) Mesh: n_nodes: 12, n_elems: 14, plexitude: 3, level: 2, eltype: tri3 BBox: [0.5 0. 0. ], [1. 1. 1.] Size: [0.5 1. 1. ] Length: 4.0 Area: 3.0
>>> half_closed = cube.cut_with_plane([0.5, 0.0, 0.0], ... [1.0, 0.0, 0.0], ... side='-', ... closed=True) >>> print(half_closed) Mesh: n_nodes: 12, n_elems: 20, plexitude: 3, level: 2, eltype: tri3 BBox: [0. 0. 0.], [0.5 1. 1. ] Size: [0.5 1. 1. ] Length: 0.0 Area: 4.0