hybridmesh.HybridMesh.cut_with_plane#
- HybridMesh.cut_with_plane(p, n, side='+', closed=False)#
Cut a HybridMesh with a plane.
This operation splits a hybrid 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. This function modifies elements that intersect with the plane by slicing them, possibly generating new elements along the cut.
Supports line, surface and volumetric meshes. Field data is preserved except when working with only tri3 meshes and
closed=True.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 sections 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. This option is only supported if all elements areeltype='tri3'.
Returns#
- Mesh or HybridMesh
A new mesh corresponding to the portion of the original mesh lying on the selected side of the cutting plane.
Examples#
>>> from hellotriangle import shapes >>> M = shapes.rectangle(div=1, eltype="tri3") >>> N = shapes.rectangle(div=1, eltype="quad4").trl([1, 0, 0]) >>> H = HybridMesh.from_meshes([M, N], fuse=True) >>> half = H.cut_with_plane([0.0, 0.5, 0.0], [0.0, 1.0, 0.0]) >>> print(half) HybridMesh: n_nodes: 7, n_elems: 3 Block 0: n_elems: 1, plexitude: 3, eltype: tri3 Block 1: n_elems: 2, plexitude: 4, eltype: quad4