mesh.Mesh.chained#
- Mesh.chained(disconnect=None, compact=True)#
Reorder the elements of a line Mesh into connected chains.
Chaining the elements involves reordering them such that the first node of the next element is equal to the last node of the previous. This is especially useful in converting line elements to continuous polylines.
Parameters#
- disconnect: int array_like | str, optional
List of node numbers where the resulting chains should be split. None of the resulting chains will have any of the listed node numbers as an interior node. A chain may start and end at such a node. A special value ‘branch’ will set the disconnect array to all the nodes owned by more than two elements. This will split all chains at branching points.
- compact: bool
If True (default), the returned Mesh will be compacted. If False, the returned Mesh will contain all the nodes present in the input Mesh.
Returns#
- list of Meshes
A list of new
Meshobjects, each representing a single connected chain of line elements. - Each Mesh in the list corresponds to one continuous polyline. - If disconnect is given, the returned Meshes are split at the specified nodes (or branching points if ‘branch’ is used).
Examples#
>>> L1 = Mesh(eltype='line2').subdivide(2) >>> L2 = L1.rotate_z(90.).translate([0., -1., 0.]) >>> L = L1+L2 >>> print(L.elems) [[0 1] [1 2] [3 4] [4 0]] >>> print(L.chained()[0].elems) [[3 4] [4 0] [0 1] [1 2]] >>> L3 = L.chained(disconnect=[0]) >>> print(len(L3)) 2 >>> print(L3[0].n_coords()) 3 >>> L4 = L.chained(disconnect=[0], compact=False)[0] >>> print(L4.n_coords()) 5