From 76c74f53c4acb8749ba9a4ce72c6e84c38508dfb Mon Sep 17 00:00:00 2001 From: Nicolas Predella Date: Mon, 13 Jul 2026 13:41:33 +0300 Subject: [PATCH] up --- core/slice.py | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/core/slice.py b/core/slice.py index 0e8cf5c..a81a075 100644 --- a/core/slice.py +++ b/core/slice.py @@ -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)