hybridmesh.HybridMesh.slice#

HybridMesh.slice(dir=0, n_planes=10, point=None)#

Slice a HybridMesh with one or more planes.

Parameters#

dirint or array_like (3,)

Direction of the normal of the slicing plane(s). If int: 0=x, 1=y, 2=z.

n_planesint

Number of parallel slices (ignored if point is given).

pointarray_like (3,), optional

If provided, perform a single slice through this point.

Returns#

list of Mesh

If point is None → list of slices. Empty slices are returned as empty point meshes.

Mesh

If point is given → single slice. If there is no intersection with the mesh, an empty point mesh is returned.

Examples#

>>> from hellotriangle import shapes
>>> M = shapes.rectangle(div=4, eltype="tri3")

Create multiple parallel slices along the x-direction:

>>> slices = M.slice(dir=0, n_planes=3)
>>> len(slices)
3

Create a single slice through a given point with a custom normal:

>>> S = M.slice(dir=[0.0, 1.0, 0.0], point=[0.0, 0.5, 0.0])
>>> print(S)
Mesh: n_nodes: 5, n_elems: 4, plexitude: 2, level: 1, eltype: line2
  BBox: [0.  0.5 0. ], [1.  0.5 0. ]
  Size: [1. 0. 0.]
  Length: 1.0