Skip to content

Extract boundaries

Full example code: examples/meshtools/extract_boundary.py

After obtaining the coords, triangles and scalars of our surface mesh using the parser module, we can call the BoundaryFilter to extract the nodes on each border.

We can exclude small boundaries caused by defects in the surface mesh by passing a minimum amount of points for each boundary.

from opendgm.meshtools import BoundaryFilter

boundaries = BoundaryFilter.get_boundaries(
    coords,
    triangles,
    scalars,
    min_points=5
)

Extending boundaries

The nodes on the border of a cutout often have less clean LAT values. Using the extend method, we can move our boundary away from the actual border zone using the distance parameter. This represents the threshold(s) on the number of mesh triangles nodes have to be removed from the border. This can be either a single int or a inner-outer range.

  • distance = 6: Create a new boundary of nodes at distance 6 triangles from the original boundary
  • distance = [6, 12]: Take all nodes at distance between 6 and 12 triangles from the original boundary
test_bnd = deepcopy(boundaries[0])
test_bnd.extend(coords, triangles, scalars, distance=[6, 12])

Reducing nodes

We can also reduce the number of nodes bssed on spatial distance to allow for cleaner graphs afterwards.

boundaries[3].reduce(2)
test_bnd.reduce(3)

Visualization of our original boundaries, one with the number of nodes reduced. Together with our extended boundary using its scalar values.