code: function cureLocalIntersections (data, start, triangles, dim) {
    var node = start
    do {
      var a = node.prev,
        b = node.next.next
  
      // a self-intersection where edge (v[i-1],v[i]) intersects (v[i+1],v[i+2])
      if (a.i !== b.i && intersects(data, a.i, node.i, node.next.i, b.i) &&
        locallyInside(data, a, b) && locallyInside(data, b, a)) {
  
        triangles.push(a.i / dim)
        triangles.push(node.i / dim)
        triangles.push(b.i / dim)
  
        // remove two nodes involved
        a.next = b
        b.prev = a
  
        var az = node.prevZ,
          bz = node.nextZ && node.nextZ.nextZ
  
        if (az) {
          az.nextZ = bz
        }
        if (bz) {
          bz.prevZ = az
        }
  
        node = start = b
      }
      node = node.next
    } while (node !== start)
  
    return node
  }
docs: go through all polygon nodes and cure small local self-intersections