From 508276703b9bbd39244d60127159e1ffc032c341 Mon Sep 17 00:00:00 2001 From: Object905 Date: Sun, 15 Nov 2026 12:35:21 +0300 Subject: [PATCH] prefer grid nodes over endpoint snapping and round axis-aligned crossings A rounded crossing near an endpoint was snapped to it, splitting the other segment there without checking how far that moved the segment. With integer inputs, segments could be bent by a unit or more, and boolean results could lie outside their operands (e.g. a box minus a sliver returned a triangle outside the box). - Snap to the endpoint only if it is at least as close to the line of the segment being split as the rounded crossing is to both lines; otherwise use the rounded crossing, i.e. the nearest grid node. - Round crossings on axis-aligned segments to nearest instead of truncating, keeping the truncated result on ties. Add regression tests and update expectations that relied on the bent segments, after checking them against an f64 reference. The issue 91 owner input no longer yields a hole, so replace it with one that does and that still fails without that fix. Co-Authored-By: Claude Opus 5.5 --- iOverlay/src/split/cross_solver.rs | 107 +- iOverlay/src/string/slice.rs | 25 +- iOverlay/tests/boolean/test_129.json | 156 +- iOverlay/tests/boolean/test_130.json | 501 ++----- iOverlay/tests/boolean/test_131.json | 92 +- iOverlay/tests/boolean/test_132.json | 136 +- iOverlay/tests/boolean/test_133.json | 152 +- iOverlay/tests/boolean/test_82.json | 123 +- iOverlay/tests/boolean/test_96.json | 2008 ++++---------------------- iOverlay/tests/fragment_tests.rs | 3 +- iOverlay/tests/issue_91_tests.rs | 45 +- iOverlay/tests/simplify_tests.rs | 7 +- iOverlay/tests/slice_tests.rs | 9 +- 13 files changed, 923 insertions(+), 2441 deletions(-) diff --git a/iOverlay/src/split/cross_solver.rs b/iOverlay/src/split/cross_solver.rs index 2a0f3f5b..05b32944 100644 --- a/iOverlay/src/split/cross_solver.rs +++ b/iOverlay/src/split/cross_solver.rs @@ -190,22 +190,26 @@ impl CrossSolver { let r1 = ra1.min(rb1); if r0 <= r1 { - let p = if ra0 < rb0 { target.a } else { target.b }; + let e = if ra0 < rb0 { target.a } else { target.b }; // ignore if it's a clean point - if Triangle::is_not_line(other.a, p, other.b) { + if Triangle::is_not_line(other.a, e, other.b) + && Self::is_closer_than_grid_node(other, e, target, p) + { return Some(CrossResult { - point: p, + point: e, cross_type: CrossType::TargetEnd, is_round: true, }); } } else { - let p = if ra1 < rb1 { other.a } else { other.b }; + let e = if ra1 < rb1 { other.a } else { other.b }; // ignore if it's a clean point - if Triangle::is_not_line(target.a, p, target.b) { + if Triangle::is_not_line(target.a, e, target.b) + && Self::is_closer_than_grid_node(target, e, other, p) + { return Some(CrossResult { - point: p, + point: e, cross_type: CrossType::OtherEnd, is_round: true, }); @@ -220,6 +224,46 @@ impl CrossSolver { }) } + /// Whether snapping to the endpoint `e` of `owner` bends `segment` no more than splitting + /// both segments at the rounded crossing `p` moves them. + /// + /// Snapping a crossing to an endpoint of one segment splits the other segment there, which + /// moves it by the endpoint's distance from its line. The rounded crossing moves each + /// segment by its distance from that segment's line. Prefer the grid node unless the + /// endpoint is at least as close. + #[inline] + fn is_closer_than_grid_node( + segment: &XSegment, + e: IntPoint, + owner: &XSegment, + p: IntPoint, + ) -> bool { + let snap = Self::sqr_line_distance(segment, e); + let grid = Self::sqr_line_distance(segment, p).max(Self::sqr_line_distance(owner, p)); + snap <= grid + } + + /// Squared distance from `p` to the line through `segment`. + #[inline] + fn sqr_line_distance(segment: &XSegment, p: IntPoint) -> f64 { + let v = segment.b - segment.a; + let cross = v.cross_product(p - segment.a).to_f64(); + cross * cross / segment.a.sqr_distance(segment.b).to_f64() + } + + /// Divides, rounding to the nearest integer, with ties toward zero. + /// + /// Truncating would move a crossing on an axis-aligned segment by up to a unit. Rounding + /// ties toward zero, i.e. toward the segment's first endpoint, keeps the truncated result + /// whenever it is one of the two nearest integers. + #[inline] + fn divide_round_half_toward_zero(numerator: I::Wide, divisor: I::Wide) -> I::Wide { + let n = numerator.unsigned_abs(); + let d = divisor.unsigned_abs(); + let q = (n + ((d - ::UInt::ONE) >> 1)) / d; + numerator.signum() * divisor.signum() * I::Wide::from_uint(q) + } + fn cross_point(target: &XSegment, other: &XSegment) -> IntPoint { // edges are not parallel // Input coordinates follow the N-bit range documented in core::integer. @@ -282,11 +326,11 @@ impl CrossSolver { if a1x == I::Wide::ZERO { // dxB is not zero because it will be parallel case and it's impossible x0 = I::Wide::ZERO; - y0 = xy_b / dx_b; + y0 = Self::divide_round_half_toward_zero(xy_b, dx_b); } else if a1y == I::Wide::ZERO { // dyB is not zero because it will be parallel case and it's impossible y0 = I::Wide::ZERO; - x0 = -xy_b / dy_b; + x0 = Self::divide_round_half_toward_zero(-xy_b, dy_b); } else { // divider let div = a1y * dx_b - a1x * dy_b; @@ -325,16 +369,48 @@ mod tests { #[test] fn snapping_compares_squared_distance_directly_with_the_threshold() { - let target = XSegment::new(IntPoint::new(0, 0), IntPoint::new(5, 5)); - let other = XSegment::new(IntPoint::new(0, 3), IntPoint::new(5, -2)); - // The rounded crossing is (2, 2). Its nearest endpoint is (0, 3), + let target = XSegment::new(IntPoint::new(0, 0), IntPoint::new(6, 3)); + let other = XSegment::new(IntPoint::new(0, -1), IntPoint::new(5, 3)); + // The crossing (3 1/3, 1 2/3) rounds to (3, 2). Its nearest endpoint is (5, 3), // at squared distance 5. A threshold of 4 must not be squared again. + // Snapping moves the target by 3/√45 ≈ 0.45, less than the rounded crossing moves the + // other segment, 3/√41 ≈ 0.47, so it is allowed. let crossing = CrossSolver::cross(&target, &other, 4).unwrap(); assert!(matches!(crossing.cross_type, CrossType::Pure)); - assert_eq!(crossing.point, IntPoint::new(2, 2)); + assert_eq!(crossing.point, IntPoint::new(3, 2)); let snapped = CrossSolver::cross(&target, &other, 5).unwrap(); assert!(matches!(snapped.cross_type, CrossType::OtherEnd)); - assert_eq!(snapped.point, other.a); + assert_eq!(snapped.point, other.b); + } + + #[test] + fn snapping_prefers_a_closer_grid_node() { + // The crossing (1, 2 1/11) rounds to (1, 2), a unit from the endpoint (0, 2) of the + // target. Snapping to (0, 2) would bend the vertical segment a unit off its line, while + // (1, 2) is within 1/11 of both lines. + let target = XSegment::new(IntPoint::new(0, 2), IntPoint::new(11, 3)); + let other = XSegment::new(IntPoint::new(1, 1), IntPoint::new(1, 4)); + for radius_squared in [1, 2, 4, 16] { + let crossing = CrossSolver::cross(&target, &other, radius_squared).unwrap(); + assert!(matches!(crossing.cross_type, CrossType::Pure)); + assert_eq!(crossing.point, IntPoint::new(1, 2)); + } + } + + #[test] + fn axis_aligned_crossings_are_rounded() { + // The crossing is (-1.25, -1); truncating relative to the first endpoint gave (-2, -1). + let horizontal = XSegment::new(IntPoint::new(-2, -1), IntPoint::new(-1, -1)); + let other = XSegment::new(IntPoint::new(-2, 2), IntPoint::new(-1, -2)); + assert_eq!( + CrossSolver::cross_point(&horizontal, &other), + IntPoint::new(-1, -1) + ); + + // The same, transposed. + let vertical = XSegment::new(IntPoint::new(-1, -2), IntPoint::new(-1, -1)); + let other = XSegment::new(IntPoint::new(-2, -2), IntPoint::new(2, 1)); + assert_eq!(CrossSolver::cross_point(&vertical, &other), IntPoint::new(-1, -1)); } #[test] @@ -376,9 +452,10 @@ mod tests { b: point(hi, b1), }; let result = CrossSolver::::cross_point(&a, &b); - // For a horizontal target x is truncated, not rounded. + // For a horizontal target x is rounded with ties toward a0. let expected_x = if a0 == a1 { - lo as i128 + (hi as i128 - lo as i128) * n.abs() / d.abs() + let product = (hi as i128 - lo as i128) * n.abs(); + lo as i128 + (product + (d.abs() - 1) / 2) / d.abs() } else { expected_x }; diff --git a/iOverlay/src/string/slice.rs b/iOverlay/src/string/slice.rs index 1e882625..a344a9ba 100644 --- a/iOverlay/src/string/slice.rs +++ b/iOverlay/src/string/slice.rs @@ -318,10 +318,27 @@ mod tests { FillRule::NonZero, ); - assert_eq!(shapes.len(), 3); - assert_eq!(shapes[0][0].len(), 5); - assert_eq!(shapes[1][0].len(), 3); - assert_eq!(shapes[2][0].len(), 3); + // The line crosses the edges at (0.5, 2) and (1.5, 2), which round to (0, 2) and (1, 2). + // The top-left part, a triangle half a unit wide, collapses onto the left edge. The + // crossing isn't snapped to the vertex (1, 1), a unit away from the line. + assert_eq!( + shapes, + vec![ + vec![vec![ + IntPoint::new(2, 0), + IntPoint::new(2, 2), + IntPoint::new(1, 2), + IntPoint::new(1, 1), + IntPoint::new(0, 2), + IntPoint::new(0, 0), + ]], + vec![vec![ + IntPoint::new(1, 2), + IntPoint::new(2, 2), + IntPoint::new(2, 3) + ]], + ] + ); } #[test] diff --git a/iOverlay/tests/boolean/test_129.json b/iOverlay/tests/boolean/test_129.json index e9ef3b23..d92a13ed 100644 --- a/iOverlay/tests/boolean/test_129.json +++ b/iOverlay/tests/boolean/test_129.json @@ -51,6 +51,22 @@ [ -1, -2 + ], + [ + 0, + -1 + ], + [ + 0, + -2 + ], + [ + 1, + -1 + ], + [ + 0, + -1 ] ] ] @@ -61,12 +77,24 @@ [ [ [ - -2, + -1, + -3 + ], + [ + -1, + -2 + ], + [ + 0, + -1 + ], + [ + 0, 0 ], [ 1, - -1 + 2 ], [ 1, @@ -79,14 +107,6 @@ [ 2, -3 - ], - [ - -1, - -3 - ], - [ - -1, - -2 ] ] ] @@ -101,11 +121,11 @@ 0 ], [ - 1, + 0, 0 ], [ - 1, + 0, -1 ] ] @@ -117,13 +137,37 @@ [ [ [ - -2, - 0 + -1, + -3 + ], + [ + -1, + -2 + ], + [ + 0, + -1 + ], + [ + 0, + -2 ], [ 1, -1 ], + [ + 0, + -1 + ], + [ + 0, + 0 + ], + [ + 1, + 0 + ], [ 1, 3 @@ -135,14 +179,6 @@ [ 2, -3 - ], - [ - -1, - -3 - ], - [ - -1, - -2 ] ] ] @@ -150,6 +186,38 @@ ], "intersect": [ [ + [ + [ + [ + 0, + -2 + ], + [ + 0, + -1 + ], + [ + 1, + -1 + ] + ] + ], + [ + [ + [ + 0, + 0 + ], + [ + 1, + 2 + ], + [ + 1, + 0 + ] + ] + ] ] ], "subject": [ @@ -161,14 +229,46 @@ 0 ], [ - 1, + 0, 0 ], + [ + 0, + -1 + ] + ] + ], + [ + [ + [ + 0, + -2 + ], + [ + 0, + -1 + ], [ 1, -1 ] ] + ], + [ + [ + [ + 0, + 0 + ], + [ + 1, + 2 + ], + [ + 1, + 0 + ] + ] ] ] ], @@ -205,9 +305,13 @@ 0 ], [ - 1, + 0, 0 ], + [ + 1, + 2 + ], [ 1, 3 @@ -227,6 +331,10 @@ [ -1, -2 + ], + [ + 0, + -1 ] ] ] diff --git a/iOverlay/tests/boolean/test_130.json b/iOverlay/tests/boolean/test_130.json index 6bca5363..2ffbc938 100644 --- a/iOverlay/tests/boolean/test_130.json +++ b/iOverlay/tests/boolean/test_130.json @@ -1,72 +1,5 @@ { "union" : [ - [ - [ - [ - [-5, 5], [3, 2], [5, 0], [3, -1], [2, -2], [2, -3], [1, -2], [0, 0] - ] - ], - [ - [ - [-2, -3], [1, -2], [-1, -3] - ] - ], - [ - [ - [2, -3], [3, -1], [5, -5] - ] - ] - ], - [ - [ - [ - [ - -5, - 5 - ], - [ - 3, - 2 - ], - [ - 5, - 0 - ], - [ - 3, - -1 - ], - [ - 2, - -3 - ], - [ - 1, - -2 - ], - [ - 0, - 0 - ] - ] - ], - [ - [ - [ - -2, - -3 - ], - [ - 1, - -2 - ], - [ - -1, - -3 - ] - ] - ] - ], [ [ [ @@ -78,6 +11,10 @@ 3, 2 ], + [ + 3, + 1 + ], [ 5, 0 @@ -86,104 +23,74 @@ 3, -1 ], + [ + 2, + -1 + ], [ 2, -3 ], + [ + 1, + -2 + ], [ 0, 0 ] ] + ], + [ + [ + [ + -2, + -3 + ], + [ + 1, + -2 + ], + [ + -1, + -3 + ] + ] ] ] ], "fillRule" : 1, "subject" : [ - [ - [ - [ - [ - -2, - -3 - ], - [ - 1, - -2 - ], - [ - -1, - -3 - ] - ] - ], - [ - [ - [ - 0, - 2 - ], - [ - 3, - 2 - ], - [ - 5, - 0 - ], - [ - 3, - -1 - ] - ] - ], - [ - [ - [ - 2, - -2 - ], - [ - 2, - -1 - ], - [ - 3, - -1 - ] - ] - ] - ], [ [ [ [ - 0, - 2 - ], - [ - 3, - 2 + -2, + -3 ], [ - 5, - 0 + 1, + -2 ], [ - 3, - -1 + -1, + -3 ] ] ], [ [ [ - 2, - -3 + 0, + 2 ], [ - 2, - -1 + 3, + 1 + ], + [ + 5, + 0 ], [ 3, @@ -194,24 +101,6 @@ ] ], "intersect" : [ - [ - [ - [ - [ - 0, - 2 - ], - [ - 3, - 2 - ], - [ - 3, - -1 - ] - ] - ] - ], [ [ [ @@ -221,7 +110,7 @@ ], [ 3, - 2 + 1 ], [ 3, @@ -256,94 +145,6 @@ ] ], "xor" : [ - [ - [ - [ - [-5, 5], [3, 2], [0, 2], [3, -1], [2, -2], [2, -3], [1, -2], [0, 0] - ] - ], - [ - [ - [-2, -3], [1, -2], [-1, -3] - ] - ], - [ - [ - [2, -3], [3, -1], [5, -5] - ] - ], - [ - [ - [3, -1], [3, 2], [5, 0] - ] - ] - ], - [ - [ - [ - [ - -5, - 5 - ], - [ - 3, - 2 - ], - [ - 0, - 2 - ], - [ - 3, - -1 - ], - [ - 2, - -3 - ], - [ - 1, - -2 - ], - [ - 0, - 0 - ] - ] - ], - [ - [ - [ - -2, - -3 - ], - [ - 1, - -2 - ], - [ - -1, - -3 - ] - ] - ], - [ - [ - [ - 3, - -1 - ], - [ - 3, - 2 - ], - [ - 5, - 0 - ] - ] - ] - ], [ [ [ @@ -355,6 +156,10 @@ 3, 2 ], + [ + 3, + 1 + ], [ 0, 2 @@ -363,16 +168,40 @@ 3, -1 ], + [ + 2, + -1 + ], [ 2, -3 ], + [ + 1, + -2 + ], [ 0, 0 ] ] ], + [ + [ + [ + -2, + -3 + ], + [ + 1, + -2 + ], + [ + -1, + -3 + ] + ] + ], [ [ [ @@ -381,7 +210,7 @@ ], [ 3, - 2 + 1 ], [ 5, @@ -392,64 +221,6 @@ ] ], "inverseDifference" : [ - [ - [ - [ - [-5, 5], [3, 2], [0, 2], [3, -1], [2, -1], [2, -3], [1, -2], [0, 0] - ] - ], - [ - [ - [2, -3], [3, -1], [5, -5] - ] - ] - ], - [ - [ - [ - [ - -5, - 5 - ], - [ - 3, - 2 - ], - [ - 0, - 2 - ], - [ - 3, - -1 - ], - [ - 2, - -1 - ], - [ - 2, - -2 - ], - [ - 3, - -1 - ], - [ - 2, - -3 - ], - [ - 1, - -2 - ], - [ - 0, - 0 - ] - ] - ] - ], [ [ [ @@ -461,6 +232,10 @@ 3, 2 ], + [ + 3, + 1 + ], [ 0, 2 @@ -477,6 +252,10 @@ 2, -3 ], + [ + 1, + -2 + ], [ 0, 0 @@ -486,60 +265,6 @@ ] ], "clip" : [ - [ - [ - [ - [-5, 5], [3, 2], [3, -1], [2, -1], [2, -3], [1, -2], [0, 0] - ] - ], - [ - [ - [2, -3], [3, -1], [5, -5] - ] - ] - ], - [ - [ - [ - [ - -5, - 5 - ], - [ - 3, - 2 - ], - [ - 3, - -1 - ], - [ - 2, - -1 - ], - [ - 2, - -2 - ], - [ - 3, - -1 - ], - [ - 2, - -3 - ], - [ - 1, - -2 - ], - [ - 0, - 0 - ] - ] - ] - ], [ [ [ @@ -563,6 +288,10 @@ 2, -3 ], + [ + 1, + -2 + ], [ 0, 0 @@ -572,70 +301,20 @@ ] ], "difference" : [ - [ - [ - [ - [ - -2, - -3 - ], - [ - 1, - -2 - ], - [ - -1, - -3 - ] - ] - ], - [ - [ - [ - 2, - -2 - ], - [ - 2, - -1 - ], - [ - 3, - -1 - ] - ] - ], - [ - [ - [ - 3, - -1 - ], - [ - 3, - 2 - ], - [ - 5, - 0 - ] - ] - ] - ], [ [ [ [ - 2, + -2, -3 ], [ - 2, - -1 + 1, + -2 ], [ - 3, - -1 + -1, + -3 ] ] ], @@ -647,7 +326,7 @@ ], [ 3, - 2 + 1 ], [ 5, diff --git a/iOverlay/tests/boolean/test_131.json b/iOverlay/tests/boolean/test_131.json index 9f30ac79..d2b20d80 100644 --- a/iOverlay/tests/boolean/test_131.json +++ b/iOverlay/tests/boolean/test_131.json @@ -27,24 +27,32 @@ -1, 5 ], + [ + 3, + 4 + ], [ 4, 4 ], [ - 2, + 3, 3 ], [ - 5, - 2 + 2, + 3 ], [ 2, - 0 + -1 ], [ - 2, + 1, + -3 + ], + [ + 1, -1 ], [ @@ -56,16 +64,16 @@ [ [ [ - 1, - -3 + 2, + 0 ], [ - 1, - -2 + 3, + 3 ], [ - 2, - -1 + 5, + 2 ] ] ] @@ -84,7 +92,7 @@ -1 ], [ - 2, + 1, -1 ], [ @@ -107,6 +115,10 @@ 2, 3 ], + [ + 3, + 3 + ], [ 5, 2 @@ -172,36 +184,36 @@ -1, 5 ], + [ + 3, + 4 + ], [ 4, 4 ], [ - 2, + 3, 3 ], [ 2, - -1 + 3 ], [ - 0, + 2, -1 - ] - ] - ], - [ - [ + ], [ 1, -3 ], [ 1, - -2 + -1 ], [ - 2, + 0, -1 ] ] @@ -237,7 +249,7 @@ 0 ], [ - 2, + 3, 3 ], [ @@ -257,7 +269,7 @@ -1 ], [ - 2, + 1, -1 ], [ @@ -265,6 +277,22 @@ -2 ] ] + ], + [ + [ + [ + 2, + 0 + ], + [ + 2, + 3 + ], + [ + 3, + 3 + ] + ] ] ] ], @@ -276,14 +304,22 @@ -1, 5 ], + [ + 3, + 4 + ], [ 4, 4 ], [ - 2, + 3, 3 ], + [ + 2, + 0 + ], [ 2, -1 @@ -320,12 +356,16 @@ -1, 5 ], + [ + 3, + 4 + ], [ 4, 4 ], [ - 2, + 3, 3 ], [ diff --git a/iOverlay/tests/boolean/test_132.json b/iOverlay/tests/boolean/test_132.json index 4afbd098..22b5be09 100644 --- a/iOverlay/tests/boolean/test_132.json +++ b/iOverlay/tests/boolean/test_132.json @@ -11,9 +11,25 @@ -3, 4 ], + [ + -3, + 1 + ] + ] + ], + [ + [ [ -3, 0 + ], + [ + -3, + 1 + ], + [ + -2, + 0 ] ] ] @@ -62,6 +78,22 @@ ], [ -3, + 1 + ] + ] + ], + [ + [ + [ + -3, + 0 + ], + [ + -3, + 1 + ], + [ + -2, 0 ] ] @@ -73,7 +105,7 @@ 2 ], [ - 1, + 0, 3 ], [ @@ -97,6 +129,22 @@ -3 ] ] + ], + [ + [ + [ + 0, + 3 + ], + [ + 1, + 5 + ], + [ + 1, + 3 + ] + ] ] ] ], @@ -114,6 +162,22 @@ ], [ -3, + 1 + ] + ] + ], + [ + [ + [ + -3, + 0 + ], + [ + -3, + 1 + ], + [ + -2, 0 ] ] @@ -125,7 +189,7 @@ 2 ], [ - 1, + 0, 3 ], [ @@ -149,6 +213,22 @@ -3 ] ] + ], + [ + [ + [ + 0, + 3 + ], + [ + 1, + 5 + ], + [ + 1, + 3 + ] + ] ] ] ], @@ -161,7 +241,7 @@ 2 ], [ - 1, + 0, 3 ], [ @@ -185,6 +265,22 @@ -3 ] ] + ], + [ + [ + [ + 0, + 3 + ], + [ + 1, + 5 + ], + [ + 1, + 3 + ] + ] ] ] ], @@ -224,9 +320,25 @@ -3, 4 ], + [ + -3, + 1 + ] + ] + ], + [ + [ [ -3, 0 + ], + [ + -3, + 1 + ], + [ + -2, + 0 ] ] ] @@ -242,7 +354,7 @@ 2 ], [ - 1, + 0, 3 ], [ @@ -266,6 +378,22 @@ -3 ] ] + ], + [ + [ + [ + 0, + 3 + ], + [ + 1, + 5 + ], + [ + 1, + 3 + ] + ] ] ] ] diff --git a/iOverlay/tests/boolean/test_133.json b/iOverlay/tests/boolean/test_133.json index cff13f5b..24c1129b 100644 --- a/iOverlay/tests/boolean/test_133.json +++ b/iOverlay/tests/boolean/test_133.json @@ -6,32 +6,6 @@ ] ], "subject" : [ - [ - [ - [ - [ - 0, - 2 - ], - [ - 4, - 3 - ], - [ - 4, - -1 - ], - [ - 3, - -3 - ], - [ - 3, - 0 - ] - ] - ] - ], [ [ [ @@ -39,6 +13,10 @@ 0, 2 ], + [ + 3, + 3 + ], [ 4, 3 @@ -46,6 +24,14 @@ [ 4, -1 + ], + [ + 3, + -1 + ], + [ + 3, + 0 ] ] ] @@ -81,32 +67,6 @@ ] ], "union" : [ - [ - [ - [ - [ - 0, - 2 - ], - [ - 4, - 3 - ], - [ - 4, - -1 - ], - [ - 3, - -3 - ], - [ - 3, - 0 - ] - ] - ] - ], [ [ [ @@ -114,6 +74,10 @@ 0, 2 ], + [ + 3, + 3 + ], [ 4, 3 @@ -121,38 +85,20 @@ [ 4, -1 + ], + [ + 3, + -1 + ], + [ + 3, + 0 ] ] ] ] ], "xor" : [ - [ - [ - [ - [ - 0, - 2 - ], - [ - 4, - 3 - ], - [ - 4, - -1 - ], - [ - 3, - -3 - ], - [ - 3, - 0 - ] - ] - ] - ], [ [ [ @@ -160,6 +106,10 @@ 0, 2 ], + [ + 3, + 3 + ], [ 4, 3 @@ -167,38 +117,20 @@ [ 4, -1 + ], + [ + 3, + -1 + ], + [ + 3, + 0 ] ] ] ] ], "difference" : [ - [ - [ - [ - [ - 0, - 2 - ], - [ - 4, - 3 - ], - [ - 4, - -1 - ], - [ - 3, - -3 - ], - [ - 3, - 0 - ] - ] - ] - ], [ [ [ @@ -206,6 +138,10 @@ 0, 2 ], + [ + 3, + 3 + ], [ 4, 3 @@ -213,6 +149,14 @@ [ 4, -1 + ], + [ + 3, + -1 + ], + [ + 3, + 0 ] ] ] diff --git a/iOverlay/tests/boolean/test_82.json b/iOverlay/tests/boolean/test_82.json index 98497800..6a189e0e 100644 --- a/iOverlay/tests/boolean/test_82.json +++ b/iOverlay/tests/boolean/test_82.json @@ -12,7 +12,7 @@ -2048 ], [ - 7759, + 7758, -15582 ] ] @@ -20,24 +20,6 @@ ] ], "clip" : [ - [ - [ - [ - [ - 0, - -2048 - ], - [ - 1024, - -2048 - ], - [ - 7759, - -15582 - ] - ] - ] - ], [ [ [ @@ -56,34 +38,20 @@ [ 7759, -15582 - ] - ] - ] - ] - ], - "union" : [ - [ - [ - [ - [ - -20480, - 0 ], [ - 0, - -2048 - ], - [ - 1024, - -2048 + 7759, + -15583 ], [ - 7759, + 7758, -15582 ] ] ] - ], + ] + ], + "union" : [ [ [ [ @@ -106,6 +74,14 @@ [ 7759, -15582 + ], + [ + 7759, + -15583 + ], + [ + 7758, + -15582 ] ] ] @@ -124,7 +100,7 @@ -2048 ], [ - 7759, + 7758, -15582 ] ] @@ -144,26 +120,20 @@ -15575 ] ] - ] - ], - [ + ], [ [ [ - -20480, - 0 - ], - [ - 0, - -2048 + 7758, + -15582 ], [ - 1024, - -2048 + 7759, + -15582 ], [ 7759, - -15582 + -15583 ] ] ] @@ -171,9 +141,6 @@ ], "fillRule" : 0, "intersect" : [ - [ - - ], [ [ [ @@ -188,30 +155,16 @@ [ 7759, -15582 - ] - ] - ] - ] - ], - "subject" : [ - [ - [ - [ - [ - -20480, - 0 - ], - [ - 0, - -2048 ], [ - 7759, + 7758, -15582 ] ] ] - ], + ] + ], + "subject" : [ [ [ [ @@ -230,6 +183,10 @@ [ 7759, -15582 + ], + [ + 7758, + -15582 ] ] ] @@ -264,26 +221,24 @@ -2048 ], [ - 7759, - -15582 + 7755, + -15575 ] ] - ] - ], - [ + ], [ [ [ - 0, - -2048 + 7758, + -15582 ], [ - 1024, - -2048 + 7759, + -15582 ], [ - 7755, - -15575 + 7759, + -15583 ] ] ] diff --git a/iOverlay/tests/boolean/test_96.json b/iOverlay/tests/boolean/test_96.json index 2239da1a..0a559b38 100644 --- a/iOverlay/tests/boolean/test_96.json +++ b/iOverlay/tests/boolean/test_96.json @@ -60,116 +60,6 @@ ] ], "subject" : [ - [ - [ - [ - [ - -1136, - -48 - ], - [ - -940, - 404 - ], - [ - -922, - 444 - ], - [ - -746, - 858 - ], - [ - -270, - 987 - ], - [ - -228, - 999 - ], - [ - -226, - 999 - ], - [ - 205, - 1118 - ], - [ - 603, - 827 - ], - [ - 638, - 802 - ], - [ - 640, - 800 - ], - [ - 1002, - 537 - ], - [ - 1023, - 44 - ], - [ - 1025, - 1 - ], - [ - 1025, - -1 - ], - [ - 1045, - -449 - ], - [ - 672, - -772 - ], - [ - 640, - -800 - ], - [ - 638, - -802 - ], - [ - 300, - -1097 - ], - [ - -184, - -1007 - ], - [ - -226, - -999 - ], - [ - -229, - -999 - ], - [ - -670, - -919 - ], - [ - -902, - -483 - ], - [ - -922, - -444 - ] - ] - ] - ], [ [ [ @@ -182,110 +72,12 @@ 404 ], [ - -922, + -923, 444 ], - [ - -746, - 858 - ], - [ - -270, - 987 - ], - [ - -227, - 998 - ], - [ - 205, - 1118 - ], - [ - 603, - 827 - ], - [ - 638, - 802 - ], - [ - 640, - 800 - ], - [ - 1002, - 537 - ], - [ - 1023, - 44 - ], - [ - 1024, - 0 - ], - [ - 1045, - -449 - ], - [ - 672, - -772 - ], - [ - 640, - -800 - ], - [ - 638, - -802 - ], - [ - 300, - -1097 - ], - [ - -184, - -1007 - ], - [ - -226, - -1000 - ], - [ - -229, - -999 - ], - [ - -670, - -919 - ], - [ - -902, - -483 - ], - [ - -922, - -444 - ] - ] - ] - ], - [ - [ - [ - [ - -1136, - -48 - ], - [ - -940, - 404 - ], [ -922, - 444 + 445 ], [ -746, @@ -296,8 +88,12 @@ 987 ], [ - -227, - 998 + -228, + 999 + ], + [ + -226, + 999 ], [ 205, @@ -324,8 +120,12 @@ 44 ], [ - 1024, - 0 + 1025, + 1 + ], + [ + 1025, + -1 ], [ 1045, @@ -352,8 +152,8 @@ -1007 ], [ - -227, - -998 + -226, + -999 ], [ -229, @@ -369,6 +169,10 @@ ], [ -922, + -445 + ], + [ + -923, -444 ] ] @@ -376,256 +180,6 @@ ] ], "xor" : [ - [ - [ - [ - [ - -2048, - 0 - ], - [ - -922, - 444 - ], - [ - -940, - 404 - ], - [ - -1136, - -48 - ], - [ - -922, - -444 - ] - ] - ], - [ - [ - [ - -1276, - -1601 - ], - [ - -922, - -444 - ], - [ - -902, - -483 - ], - [ - -670, - -919 - ], - [ - -229, - -999 - ] - ] - ], - [ - [ - [ - -1276, - 1601 - ], - [ - -228, - 999 - ], - [ - -270, - 987 - ], - [ - -746, - 858 - ], - [ - -922, - 444 - ] - ] - ], - [ - [ - [ - -229, - -999 - ], - [ - -227, - -998 - ], - [ - -226, - -999 - ] - ] - ], - [ - [ - [ - -228, - 999 - ], - [ - -226, - 999 - ], - [ - -227, - 998 - ] - ] - ], - [ - [ - [ - -226, - -999 - ], - [ - -184, - -1007 - ], - [ - 300, - -1097 - ], - [ - 638, - -802 - ], - [ - 455, - -1996 - ] - ] - ], - [ - [ - [ - -226, - 999 - ], - [ - 455, - 1996 - ], - [ - 638, - 802 - ], - [ - 603, - 827 - ], - [ - 205, - 1118 - ] - ] - ], - [ - [ - [ - 638, - -802 - ], - [ - 638, - -800 - ], - [ - 640, - -800 - ] - ] - ], - [ - [ - [ - 638, - 800 - ], - [ - 638, - 802 - ], - [ - 640, - 800 - ] - ] - ], - [ - [ - [ - 640, - -800 - ], - [ - 672, - -772 - ], - [ - 1045, - -449 - ], - [ - 1025, - -1 - ], - [ - 1845, - -888 - ] - ] - ], - [ - [ - [ - 640, - 800 - ], - [ - 1845, - 888 - ], - [ - 1025, - 1 - ], - [ - 1023, - 44 - ], - [ - 1002, - 537 - ] - ] - ], - [ - [ - [ - 1024, - 0 - ], - [ - 1025, - 1 - ], - [ - 1025, - -1 - ] - ] - ] - ], [ [ [ @@ -634,7 +188,7 @@ 0 ], [ - -922, + -923, 444 ], [ @@ -646,7 +200,7 @@ -48 ], [ - -922, + -923, -444 ] ] @@ -659,7 +213,7 @@ ], [ -922, - -444 + -445 ], [ -902, @@ -682,8 +236,8 @@ 1601 ], [ - -227, - 998 + -228, + 999 ], [ -270, @@ -693,6 +247,38 @@ -746, 858 ], + [ + -922, + 445 + ] + ] + ], + [ + [ + [ + -923, + -444 + ], + [ + -922, + -444 + ], + [ + -922, + -445 + ] + ] + ], + [ + [ + [ + -923, + 444 + ], + [ + -922, + 445 + ], [ -922, 444 @@ -711,31 +297,23 @@ ], [ -226, - -1000 + -999 ] ] ], [ [ [ - -227, - 998 - ], - [ - 455, - 1996 - ], - [ - 638, - 802 + -228, + 999 ], [ - 603, - 827 + -226, + 999 ], [ - 205, - 1118 + -227, + 998 ] ] ], @@ -743,7 +321,7 @@ [ [ -226, - -1000 + -999 ], [ -184, @@ -763,6 +341,30 @@ ] ] ], + [ + [ + [ + -226, + 999 + ], + [ + 455, + 1996 + ], + [ + 638, + 802 + ], + [ + 603, + 827 + ], + [ + 205, + 1118 + ] + ] + ], [ [ [ @@ -810,8 +412,8 @@ -449 ], [ - 1024, - 0 + 1025, + -1 ], [ 1845, @@ -830,8 +432,8 @@ 888 ], [ - 1024, - 0 + 1025, + 1 ], [ 1023, @@ -842,372 +444,72 @@ 537 ] ] - ] - ], - [ + ], [ [ [ - -2048, + 1024, 0 ], [ - -922, - 444 + 1025, + 1 ], [ - -940, - 404 - ], + 1025, + -1 + ] + ] + ] + ] + ], + "intersect" : [ + [ + [ + [ [ -1136, -48 ], [ - -922, - -444 - ] - ] - ], - [ - [ + -940, + 404 + ], [ - -1276, - -1601 + -923, + 444 ], [ -922, - -444 + 444 ], [ - -902, - -483 + -922, + 445 ], [ - -670, - -919 + -746, + 858 ], [ - -229, - -999 - ] - ] - ], - [ - [ + -270, + 987 + ], [ - -1276, - 1601 + -228, + 999 ], [ -227, 998 ], [ - -270, - 987 + -226, + 999 ], [ - -746, - 858 - ], - [ - -922, - 444 - ] - ] - ], - [ - [ - [ - -227, - -998 - ], - [ - -184, - -1007 - ], - [ - 300, - -1097 - ], - [ - 638, - -802 - ], - [ - 455, - -1996 - ] - ] - ], - [ - [ - [ - -227, - 998 - ], - [ - 455, - 1996 - ], - [ - 638, - 802 - ], - [ - 603, - 827 - ], - [ - 205, - 1118 - ] - ] - ], - [ - [ - [ - 638, - -802 - ], - [ - 638, - -800 - ], - [ - 640, - -800 - ] - ] - ], - [ - [ - [ - 638, - 800 - ], - [ - 638, - 802 - ], - [ - 640, - 800 - ] - ] - ], - [ - [ - [ - 640, - -800 - ], - [ - 672, - -772 - ], - [ - 1045, - -449 - ], - [ - 1024, - 0 - ], - [ - 1845, - -888 - ] - ] - ], - [ - [ - [ - 640, - 800 - ], - [ - 1845, - 888 - ], - [ - 1024, - 0 - ], - [ - 1023, - 44 - ], - [ - 1002, - 537 - ] - ] - ] - ] - ], - "intersect" : [ - [ - [ - [ - [ - -1136, - -48 - ], - [ - -940, - 404 - ], - [ - -922, - 444 - ], - [ - -746, - 858 - ], - [ - -270, - 987 - ], - [ - -228, - 999 - ], - [ - -227, - 998 - ], - [ - -226, - 999 - ], - [ - 205, - 1118 - ], - [ - 603, - 827 - ], - [ - 638, - 802 - ], - [ - 638, - 800 - ], - [ - 640, - 800 - ], - [ - 1002, - 537 - ], - [ - 1023, - 44 - ], - [ - 1025, - 1 - ], - [ - 1024, - 0 - ], - [ - 1025, - -1 - ], - [ - 1045, - -449 - ], - [ - 672, - -772 - ], - [ - 640, - -800 - ], - [ - 638, - -800 - ], - [ - 638, - -802 - ], - [ - 300, - -1097 - ], - [ - -184, - -1007 - ], - [ - -226, - -999 - ], - [ - -227, - -998 - ], - [ - -229, - -999 - ], - [ - -670, - -919 - ], - [ - -902, - -483 - ], - [ - -922, - -444 - ] - ] - ] - ], - [ - [ - [ - [ - -1136, - -48 - ], - [ - -940, - 404 - ], - [ - -922, - 444 - ], - [ - -746, - 858 - ], - [ - -270, - 987 - ], - [ - -227, - 998 - ], - [ - 205, - 1118 + 205, + 1118 ], [ 603, @@ -1233,10 +535,18 @@ 1023, 44 ], + [ + 1025, + 1 + ], [ 1024, 0 ], + [ + 1025, + -1 + ], [ 1045, -449 @@ -1267,7 +577,7 @@ ], [ -226, - -1000 + -999 ], [ -227, @@ -1287,116 +597,14 @@ ], [ -922, - -444 - ] - ] - ] - ], - [ - [ - [ - [ - -1136, - -48 - ], - [ - -940, - 404 + -445 ], [ -922, - 444 - ], - [ - -746, - 858 - ], - [ - -270, - 987 - ], - [ - -227, - 998 - ], - [ - 205, - 1118 - ], - [ - 603, - 827 - ], - [ - 638, - 802 - ], - [ - 638, - 800 - ], - [ - 640, - 800 - ], - [ - 1002, - 537 - ], - [ - 1023, - 44 - ], - [ - 1024, - 0 - ], - [ - 1045, - -449 - ], - [ - 672, - -772 - ], - [ - 640, - -800 - ], - [ - 638, - -800 - ], - [ - 638, - -802 - ], - [ - 300, - -1097 - ], - [ - -184, - -1007 - ], - [ - -227, - -998 - ], - [ - -229, - -999 - ], - [ - -670, - -919 - ], - [ - -902, - -483 + -444 ], [ - -922, + -923, -444 ] ] @@ -1465,346 +673,6 @@ ], "fillRule" : 0, "inverseDifference" : [ - [ - [ - [ - [ - -2048, - 0 - ], - [ - -922, - 444 - ], - [ - -940, - 404 - ], - [ - -1136, - -48 - ], - [ - -922, - -444 - ] - ] - ], - [ - [ - [ - -1276, - -1601 - ], - [ - -922, - -444 - ], - [ - -902, - -483 - ], - [ - -670, - -919 - ], - [ - -229, - -999 - ] - ] - ], - [ - [ - [ - -1276, - 1601 - ], - [ - -228, - 999 - ], - [ - -270, - 987 - ], - [ - -746, - 858 - ], - [ - -922, - 444 - ] - ] - ], - [ - [ - [ - -226, - -999 - ], - [ - -184, - -1007 - ], - [ - 300, - -1097 - ], - [ - 638, - -802 - ], - [ - 455, - -1996 - ] - ] - ], - [ - [ - [ - -226, - 999 - ], - [ - 455, - 1996 - ], - [ - 638, - 802 - ], - [ - 603, - 827 - ], - [ - 205, - 1118 - ] - ] - ], - [ - [ - [ - 640, - -800 - ], - [ - 672, - -772 - ], - [ - 1045, - -449 - ], - [ - 1025, - -1 - ], - [ - 1845, - -888 - ] - ] - ], - [ - [ - [ - 640, - 800 - ], - [ - 1845, - 888 - ], - [ - 1025, - 1 - ], - [ - 1023, - 44 - ], - [ - 1002, - 537 - ] - ] - ] - ], - [ - [ - [ - [ - -2048, - 0 - ], - [ - -922, - 444 - ], - [ - -940, - 404 - ], - [ - -1136, - -48 - ], - [ - -922, - -444 - ] - ] - ], - [ - [ - [ - -1276, - -1601 - ], - [ - -922, - -444 - ], - [ - -902, - -483 - ], - [ - -670, - -919 - ], - [ - -229, - -999 - ] - ] - ], - [ - [ - [ - -1276, - 1601 - ], - [ - -227, - 998 - ], - [ - -270, - 987 - ], - [ - -746, - 858 - ], - [ - -922, - 444 - ] - ] - ], - [ - [ - [ - -227, - -998 - ], - [ - -184, - -1007 - ], - [ - 300, - -1097 - ], - [ - 638, - -802 - ], - [ - 455, - -1996 - ] - ] - ], - [ - [ - [ - -227, - 998 - ], - [ - 455, - 1996 - ], - [ - 638, - 802 - ], - [ - 603, - 827 - ], - [ - 205, - 1118 - ] - ] - ], - [ - [ - [ - 640, - -800 - ], - [ - 672, - -772 - ], - [ - 1045, - -449 - ], - [ - 1024, - 0 - ], - [ - 1845, - -888 - ] - ] - ], - [ - [ - [ - 640, - 800 - ], - [ - 1845, - 888 - ], - [ - 1024, - 0 - ], - [ - 1023, - 44 - ], - [ - 1002, - 537 - ] - ] - ] - ], [ [ [ @@ -1813,7 +681,7 @@ 0 ], [ - -922, + -923, 444 ], [ @@ -1825,7 +693,7 @@ -48 ], [ - -922, + -923, -444 ] ] @@ -1838,7 +706,7 @@ ], [ -922, - -444 + -445 ], [ -902, @@ -1861,44 +729,20 @@ 1601 ], [ - -227, - 998 + -228, + 999 ], [ -270, 987 ], [ - -746, - 858 - ], - [ - -922, - 444 - ] - ] - ], - [ - [ - [ - -227, - 998 - ], - [ - 455, - 1996 - ], - [ - 638, - 802 - ], - [ - 603, - 827 + -746, + 858 ], [ - 205, - 1118 + -922, + 445 ] ] ], @@ -1906,7 +750,7 @@ [ [ -226, - -1000 + -999 ], [ -184, @@ -1926,6 +770,30 @@ ] ] ], + [ + [ + [ + -226, + 999 + ], + [ + 455, + 1996 + ], + [ + 638, + 802 + ], + [ + 603, + 827 + ], + [ + 205, + 1118 + ] + ] + ], [ [ [ @@ -1941,8 +809,8 @@ -449 ], [ - 1024, - 0 + 1025, + -1 ], [ 1845, @@ -1961,8 +829,8 @@ 888 ], [ - 1024, - 0 + 1025, + 1 ], [ 1023, @@ -1977,108 +845,6 @@ ] ], "clip" : [ - [ - [ - [ - [ - -2048, - 0 - ], - [ - -922, - 444 - ], - [ - -1276, - 1601 - ], - [ - -228, - 999 - ], - [ - -227, - 998 - ], - [ - -226, - 999 - ], - [ - 455, - 1996 - ], - [ - 638, - 802 - ], - [ - 638, - 800 - ], - [ - 640, - 800 - ], - [ - 1845, - 888 - ], - [ - 1025, - 1 - ], - [ - 1024, - 0 - ], - [ - 1025, - -1 - ], - [ - 1845, - -888 - ], - [ - 640, - -800 - ], - [ - 638, - -800 - ], - [ - 638, - -802 - ], - [ - 455, - -1996 - ], - [ - -226, - -999 - ], - [ - -227, - -998 - ], - [ - -229, - -999 - ], - [ - -1276, - -1601 - ], - [ - -922, - -444 - ] - ] - ] - ], [ [ [ @@ -2087,99 +853,33 @@ 0 ], [ - -922, + -923, 444 ], - [ - -1276, - 1601 - ], - [ - -227, - 998 - ], - [ - 455, - 1996 - ], - [ - 638, - 802 - ], - [ - 638, - 800 - ], - [ - 640, - 800 - ], - [ - 1845, - 888 - ], - [ - 1024, - 0 - ], - [ - 1845, - -888 - ], - [ - 640, - -800 - ], - [ - 638, - -800 - ], - [ - 638, - -802 - ], - [ - 455, - -1996 - ], - [ - -227, - -998 - ], - [ - -229, - -999 - ], - [ - -1276, - -1601 - ], [ -922, - -444 - ] - ] - ] - ], - [ - [ - [ - [ - -2048, - 0 + 444 ], [ -922, - 444 + 445 ], [ -1276, 1601 ], + [ + -228, + 999 + ], [ -227, 998 ], + [ + -226, + 999 + ], [ 455, 1996 @@ -2200,10 +900,18 @@ 1845, 888 ], + [ + 1025, + 1 + ], [ 1024, 0 ], + [ + 1025, + -1 + ], [ 1845, -888 @@ -2226,7 +934,7 @@ ], [ -226, - -1000 + -999 ], [ -227, @@ -2242,6 +950,14 @@ ], [ -922, + -445 + ], + [ + -922, + -444 + ], + [ + -923, -444 ] ] @@ -2249,88 +965,6 @@ ] ], "union" : [ - [ - [ - [ - [ - -2048, - 0 - ], - [ - -922, - 444 - ], - [ - -1276, - 1601 - ], - [ - -228, - 999 - ], - [ - -226, - 999 - ], - [ - 455, - 1996 - ], - [ - 638, - 802 - ], - [ - 640, - 800 - ], - [ - 1845, - 888 - ], - [ - 1025, - 1 - ], - [ - 1025, - -1 - ], - [ - 1845, - -888 - ], - [ - 640, - -800 - ], - [ - 638, - -802 - ], - [ - 455, - -1996 - ], - [ - -226, - -999 - ], - [ - -229, - -999 - ], - [ - -1276, - -1601 - ], - [ - -922, - -444 - ] - ] - ] - ], [ [ [ @@ -2339,16 +973,24 @@ 0 ], [ - -922, + -923, 444 ], + [ + -922, + 445 + ], [ -1276, 1601 ], [ - -227, - 998 + -228, + 999 + ], + [ + -226, + 999 ], [ 455, @@ -2367,8 +1009,12 @@ 888 ], [ - 1024, - 0 + 1025, + 1 + ], + [ + 1025, + -1 ], [ 1845, @@ -2388,7 +1034,7 @@ ], [ -226, - -1000 + -999 ], [ -229, @@ -2400,170 +1046,50 @@ ], [ -922, + -445 + ], + [ + -923, -444 ] ] ] - ], + ] + ], + "difference" : [ [ [ [ [ - -2048, - 0 + -923, + -444 ], [ -922, - 444 - ], - [ - -1276, - 1601 - ], - [ - -227, - 998 - ], - [ - 455, - 1996 - ], - [ - 638, - 802 - ], - [ - 640, - 800 - ], - [ - 1845, - 888 - ], - [ - 1024, - 0 - ], - [ - 1845, - -888 - ], - [ - 640, - -800 - ], - [ - 638, - -802 - ], - [ - 455, - -1996 + -444 ], [ - -227, - -998 - ], + -922, + -445 + ] + ] + ], + [ + [ [ - -229, - -999 + -923, + 444 ], [ - -1276, - -1601 + -922, + 445 ], [ -922, - -444 + 444 ] ] - ] - ] - ], - "difference" : [ - [ - [ - [ - [ - -229, - -999 - ], - [ - -227, - -998 - ], - [ - -226, - -999 - ] - ] - ], - [ - [ - [ - -228, - 999 - ], - [ - -226, - 999 - ], - [ - -227, - 998 - ] - ] - ], - [ - [ - [ - 638, - -802 - ], - [ - 638, - -800 - ], - [ - 640, - -800 - ] - ] - ], - [ - [ - [ - 638, - 800 - ], - [ - 638, - 802 - ], - [ - 640, - 800 - ] - ] - ], - [ - [ - [ - 1024, - 0 - ], - [ - 1025, - 1 - ], - [ - 1025, - -1 - ] - ] - ] - ], - [ + ], [ [ [ @@ -2576,23 +1102,23 @@ ], [ -226, - -1000 + -999 ] ] ], [ [ [ - 638, - -802 + -228, + 999 ], [ - 638, - -800 + -226, + 999 ], [ - 640, - -800 + -227, + 998 ] ] ], @@ -2600,49 +1126,47 @@ [ [ 638, - 800 + -802 ], [ 638, - 802 + -800 ], [ 640, - 800 + -800 ] ] - ] - ], - [ + ], [ [ [ 638, - -802 + 800 ], [ 638, - -800 + 802 ], [ 640, - -800 + 800 ] ] ], [ [ [ - 638, - 800 + 1024, + 0 ], [ - 638, - 802 + 1025, + 1 ], [ - 640, - 800 + 1025, + -1 ] ] ] diff --git a/iOverlay/tests/fragment_tests.rs b/iOverlay/tests/fragment_tests.rs index f3357eb1..f55ca6be 100644 --- a/iOverlay/tests/fragment_tests.rs +++ b/iOverlay/tests/fragment_tests.rs @@ -45,7 +45,8 @@ mod tests { .collect(); for (strategy, shapes, area2) in &results { - assert_eq!(*area2, 7, "{strategy:?} lost part of the filled region"); + // The exact doubled area is 5.6. + assert_eq!(*area2, 6, "{strategy:?} lost part of the filled region"); assert_eq!(shapes, &results[0].1, "{strategy:?} differs from List"); } } diff --git a/iOverlay/tests/issue_91_tests.rs b/iOverlay/tests/issue_91_tests.rs index 3ecff254..34b5d791 100644 --- a/iOverlay/tests/issue_91_tests.rs +++ b/iOverlay/tests/issue_91_tests.rs @@ -15,13 +15,12 @@ const PANIC_INPUT: &[&[[i32; 2]]] = &[ ]; const OWNER_INPUT: &[&[[i32; 2]]] = &[ - &[[-4, 3], [-7, 6], [-4, 6]], - &[[-4, 2], [-1, 5], [-4, 5]], - &[[-3, 2], [-10, 5], [-6, 5]], - &[[-3, 0], [-4, 1], [-1, 0]], - &[[-3, 2], [-3, 5], [-2, 5]], - &[[-4, 2], [-4, 4], [0, 4]], - &[[-2, 1], [-5, 1], [-2, 4]], + &[[0, 0], [-8, 5], [-4, 0]], + &[[-9, 3], [-10, 1], [-10, 0]], + &[[-9, 1], [-10, 3], [-6, 3]], + &[[-7, 0], [-4, 6], [-3, 4]], + &[[-7, 2], [0, 2], [-3, 0]], + &[[-8, 1], [-5, 6], [0, 1]], ]; const HIERARCHY_INPUT: &[&[[i32; 2]]] = &[ @@ -131,24 +130,28 @@ fn check_owner_case(ogc: bool, preserve_collinear: bool, vectors: bool) { } else { overlay.overlay(OverlayRule::Union, FillRule::NonZero) }; - assert_eq!(shapes.len(), squares + 2); + assert_eq!(shapes.len(), squares + 5); assert_hole_owner( &shapes, - &[[-4, 3], [-4, 4], [-3, 2]], + &[[-5, 2], [-4, 3], [-3, 2]], &[ - [-6, 5], - [-10, 5], - [-4, 2], - [-5, 1], - [-2, 1], - [-2, 3], - [0, 4], - [-2, 4], - [-3, 3], - [-3, 5], - [-4, 5], + [-10, 3], + [-9, 2], + [-9, 1], + [-7, 2], + [-8, 1], + [-7, 1], + [-7, 0], + [-6, 1], + [0, 1], + [-3, 4], [-4, 6], - [-7, 6], + [-4, 5], + [-5, 6], + [-6, 4], + [-5, 3], + [-6, 2], + [-6, 3], ], ); } diff --git a/iOverlay/tests/simplify_tests.rs b/iOverlay/tests/simplify_tests.rs index e4387f97..fac8f4f7 100644 --- a/iOverlay/tests/simplify_tests.rs +++ b/iOverlay/tests/simplify_tests.rs @@ -127,10 +127,13 @@ mod tests { graph.extract_shapes(OverlayRule::Subject, &mut buffer) }); - assert_eq!(simple_0.len(), 1); + // The edges cross at (2.25, 0.75), which rounds to (2, 1), so both lobes of the bow + // tie remain. Snapping the crossing to the vertex (3, 1) would drop the upper lobe. + assert_eq!(simple_0.len(), 2); assert_eq!(simple_0[0].len(), 1); + assert_eq!(simple_0[1].len(), 1); - assert_eq!(simple_1.len(), 1); + assert_eq!(simple_1.len(), 2); } #[test] diff --git a/iOverlay/tests/slice_tests.rs b/iOverlay/tests/slice_tests.rs index f3914235..64cf8364 100644 --- a/iOverlay/tests/slice_tests.rs +++ b/iOverlay/tests/slice_tests.rs @@ -322,10 +322,10 @@ mod tests { let result = path.slice_by_lines(&lines, FillRule::NonZero); - assert_eq!(result.len(), 3); + // The vertical line lies outside the triangle, so only the horizontal one splits it. + assert_eq!(result.len(), 2); assert_eq!(result[0].len(), 1); assert_eq!(result[1].len(), 1); - assert_eq!(result[2].len(), 1); } #[test] @@ -340,11 +340,14 @@ mod tests { let result = path.slice_by_lines(&lines, FillRule::NonZero); - assert_eq!(result.len(), 2); + // The first two lines cut a small triangle off the top right corner. + assert_eq!(result.len(), 3); assert_eq!(result[0].len(), 1); assert_eq!(result[0][0].len(), 4); assert_eq!(result[1].len(), 1); assert_eq!(result[1][0].len(), 3); + assert_eq!(result[2].len(), 1); + assert_eq!(result[2][0].len(), 3); } #[test]