edges method

Iterable<(Point, Point)> edges()

Returns all Voronoi edges as pairs of points.

Implementation

Iterable<(Point, Point)> edges() sync* {
  final seen = <String>{};

  for (int t = 0; t < delaunay.trianglesLength; t++) {
    for (int j = 0; j < 3; j++) {
      final e = t * 3 + j;
      final opposite = delaunay.halfedges[e];

      if (opposite < 0) continue;
      if (opposite < e) continue; // Avoid duplicates

      final t2 = opposite ~/ 3;
      if (t >= circumcenters.length || t2 >= circumcenters.length) continue;

      final p1 = circumcenters[t];
      final p2 = circumcenters[t2];

      final key = '${t}_$t2';
      if (seen.contains(key)) continue;
      seen.add(key);

      yield (p1, p2);
    }
  }
}