discontinuedPackage jet_cad_floor_plan has been discontinued and replaced by jet_cad_2d_plan.

mergeCuts function

List<(double, double)> mergeCuts(
  1. List<(double, double)> cuts
)

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;
}