This commit is contained in:
Andras Schmelczer 2026-05-28 21:48:35 +01:00
parent 39ef5c6646
commit c995f12f8b
78 changed files with 4830 additions and 1619 deletions

View file

@ -52,9 +52,17 @@ def compute_voronoi_regions(
if len(unique_pts) == 1:
return {unique_pcs[0]: boundary}
if not boundary.is_valid:
boundary = make_valid(boundary)
pts = np.array(unique_pts)
min_e, min_n = pts.min(axis=0)
max_e, max_n = pts.max(axis=0)
pts_min_e, pts_min_n = pts.min(axis=0)
pts_max_e, pts_max_n = pts.max(axis=0)
boundary_min_e, boundary_min_n, boundary_max_e, boundary_max_n = boundary.bounds
min_e = min(pts_min_e, boundary_min_e)
min_n = min(pts_min_n, boundary_min_n)
max_e = max(pts_max_e, boundary_max_e)
max_n = max(pts_max_n, boundary_max_n)
span = max(max_e - min_e, max_n - min_n, 100)
dummy = np.array(
@ -79,9 +87,6 @@ def compute_voronoi_regions(
n_real = len(pts)
pc_polys: dict[str, list[Polygon]] = defaultdict(list)
if not boundary.is_valid:
boundary = make_valid(boundary)
for i in range(n_real):
region_idx = vor.point_region[i]
region = vor.regions[region_idx]