mymesh.contour.MarchingSquares#

mymesh.contour.MarchingSquares(NodeCoords, NodeConn, NodeValues, threshold=0, interpolation='linear', method='triangle', flip=False, return_anchors=False, cleanup=True)[source]#

Marching squares algorithm for extracting an isocontour from a quadrilateral mesh.

For a two dimensional grid (NodeCoords, NodeConn) with values (NodeValues), Marching Squares will extract the isovalue contour defined by threshold. This can either be used to obtain line segments along the isoline (method=’edge’) or triangles filling the region inside the isoline (method=’triangle’).

Parameters:
  • NodeCoords (array_like) – Node coordinates of a two dimensional quadrilateral grid (e.g. from primitives.Grid2D)

  • NodeConn (array_like) – Node connectivities of a two dimensional grid of rectilinear grid (e.g. from primitives.Grid2D) of quadrilaterals.

  • NodeValues (array_like) – Array of node values corresponding to each node in the mesh.

  • threshold (int, optional) – Isosurface level that defines the boundary, by default 0

  • interpolation (str, optional) –

    Interpolation to interpolate the position of the new nodes along the edges of the input mesh, by default ‘linear’.

    ’midpoint’ - No interpolation is performed, new nodes are placed at the midpoint of edges

    ’linear’ - Bilinear interpolation is performed between adjacent nodes on the input mesh

  • method (str, optional) – Mesh generation method, either ‘edge’ for a line mesh of the boundary or ‘triangle’ for a filled triangular mesh, by default ‘triangle’

  • flip (bool, optional) – Flip the interior/exterior of the mesh, by default False. By default, values less than the threshold are assumed to be the “inside” of the mesh. If the inside is denoted by values greater than the threshold, set flip=True.

  • cleanup (bool, optional) – Determines whether or not to perform mesh cleanup, removing degenerate elements and duplicate nodes, by default True

Returns:

  • NewCoords (np.ndarray) – Numpy array of node coordinates for the contour mesh

  • NewConn (list) – List of node connectivities