triangulatePolygon

pyslm.support.triangulatePolygon(section, closed=False)

Function triangulates polygons generated natively by PyClipper, from pyclipper.PyPolyNode objects. This is specifically used to optimally generate the polygon triangulations using an external triangulation library Mapbox using the Ear Clipping algorithm - see Mapbox and the Ear-Cut PyPi package .

By using the pyclipper.PyPolyNode object, ClipperLib automatically generates a polygon hierarchy tree for separating both external contours and internal holes, which can be passed directly to the earcut algorithm. Otherwise, this requires passing all paths and sorting these to identify interior holes.

Parameters:
  • section – A pyclipper.PyPolyNode object containing a collection of polygons

  • closed (Optional[bool]) – If the polygo is already closed

Return type:

Tuple[ndarray, ndarray]

Returns:

A tuple of vertices and faces generated from the triangulation