This commit is contained in:
Nicolas Predella 2026-07-13 13:41:33 +03:00
parent 4dfaa0447e
commit 76c74f53c4

View file

@ -977,26 +977,22 @@ def get_overhang_mask_slice(slice_paths: list[np.ndarray], groups: tuple[int, ..
z = group_map[g][0][0, 2] if group_map[g] and len(group_map[g][0]) > 0 else 0.0
geom_i = layer_geoms[g]
if i == len(sorted_groups) - 1:
# Top layer has no overhang
continue
g_above = sorted_groups[i+1]
geom_above = layer_geoms[g_above]
# Propagate support region downwards: S_i = (S_{i+1} u L_{i+1}) \ L_i
# This propagates the raw support footprint without tolerance shrinkage, avoiding fragmentation.
accumulated = accumulated.union(geom_above).difference(geom_i)
if not accumulated.is_empty:
# Apply tolerance buffering to ensure XY clearance only for the output of the current layer.
geom_i_sub = geom_i.buffer(tolerance) if tolerance > 0 else geom_i
output_geom = accumulated.difference(geom_i_sub)
if not output_geom.is_empty:
result_paths = geometry_to_paths(output_geom, z)
for path in result_paths:
paths_list.append(path)
groups_list.append(g)
# Calculate raw support needed at layer g: union of all layers above g, minus geom_i.
# This prevents boundary mismatches/slivers caused by subtracting and then unioning back the same layers.
if i < len(sorted_groups) - 1:
raw_support = accumulated.difference(geom_i)
if not raw_support.is_empty:
# Apply tolerance clearance only to the output of the current layer.
geom_i_sub = geom_i.buffer(tolerance) if tolerance > 0 else geom_i
output_geom = raw_support.difference(geom_i_sub)
if not output_geom.is_empty:
result_paths = geometry_to_paths(output_geom, z)
for path in result_paths:
paths_list.append(path)
groups_list.append(g)
# Accumulate the union of model layers for the layers below
accumulated = accumulated.union(geom_i)
# Sort output by group index so that paths are ordered bottom-to-top
sorted_indices = np.argsort(groups_list)