filterPoints function

Node? filterPoints([
  1. Node? start,
  2. Node? end
])

Implementation

Node? filterPoints([Node? start, Node? end]) {
  if (start == null) return start;
  end ??= start;

  Node? p = start;
  bool again = false;

  do {
    again = false;

    if (p?.steiner == null && (equals(p, p?.next) || area(p?.prev, p, p?.next) == 0)) {
      removeNode(p);
      p = end = p?.prev;
      if (p == p?.next) break;
      again = true;
    } else {
      p = p?.next;
    }
  } while (again || p != end);

  return end;
}