- my @nonint2;
- say "=======";
- while (@nonint) {
- my $c2 = shift @nonint;
- say "[", join(',', @$c1), "] and\n[", join(',', @$c2), "] test for overlap";
- if (($c1->[0] > $c2->[0] && $c1->[0] <= $c2->[1])
- && overlaps_axis($c1, $c2, 1)
- && overlaps_axis($c1, $c2, 2)) {
- my @c = @$c2;
- $c[1] = $c1->[0]-1;
- push @nonint, [ @c ];
- @c = @$c2;
- $c[0] = $c1->[0];
- push @nonint, [ @c ];
- say "split at xmin=$c1->[0] :\n", join(',', @{ $nonint[-2] }), "\n", join(',', @{ $nonint[-1] }) ;
- next;
- }
- if (($c1->[1] >= $c2->[0] && $c1->[1] < $c2->[1])
- && overlaps_axis($c1, $c2, 1)
- && overlaps_axis($c1, $c2, 2)) {
- my @c = @$c2;
- $c[1] = $c1->[1];
- push @nonint, [ @c ];
- @c = @$c2;
- $c[0] = $c1->[1]+1;
- push @nonint, [ @c ];
- say "split at xmax=$c1->[1] :\n", join(',', @{ $nonint[-2] }), "\n", join(',', @{ $nonint[-1] }) ;
- next;
- }
- if (($c1->[2] > $c2->[2] && $c1->[2] <= $c2->[3])
- && overlaps_axis($c1, $c2, 0)
- && overlaps_axis($c1, $c2, 2)) {
- my @c = @$c2;
- $c[3] = $c1->[2]-1;
- push @nonint, [ @c ];
- @c = @$c2;
- $c[2] = $c1->[2];
- push @nonint, [ @c ];
- say "split at ymin=$c1->[2] :\n", join(',', @{ $nonint[-2] }), "\n", join(',', @{ $nonint[-1] }) ;
- next;