eliminateHoles function

dynamic eliminateHoles(
  1. dynamic data,
  2. dynamic holeIndices,
  3. dynamic outerNode,
  4. dynamic dim,
)

Implementation

eliminateHoles(data, holeIndices, outerNode, dim) {
  var queue = [];
  late int start;
  late int end;
  Node? list;

  for (int i = 0, len = holeIndices.length; i < len; i++) {
    start = holeIndices[i] * dim;
    end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
    list = linkedList(data, start, end, dim, false);
    if (list == list?.next) list?.steiner = true;
    queue.add(getLeftmost(list!));
  }

  queue.sort((a, b) => compareX(a, b));

  // process holes from left to right
  for (int i = 0; i < queue.length; i++) {
    eliminateHole(queue[i], outerNode);
    outerNode = filterPoints(outerNode, outerNode.next);
  }

  return outerNode;
}