mergeCuts function
The cuts of one wall merged (spec 08 D8, decision 6): sorted by start; a
cut that starts within wallJoin.linear of the previous merged cut's end
joins it, so two overlapping or touching openings make one gap and no
sliver piece.
Implementation
List<(double, double)> mergeCuts(List<(double, double)> cuts) {
final sorted = [...cuts]..sort((x, y) => x.$1.compareTo(y.$1));
final out = <(double, double)>[];
for (final c in sorted) {
if (out.isNotEmpty && c.$1 <= out.last.$2 + wallJoin.linear) {
out.last = (out.last.$1, math.max(out.last.$2, c.$2));
} else {
out.add(c);
}
}
return out;
}