From 7fdd8b33afc08a856a22a9e06fcbffac40be2872 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 6 Nov 2026 23:13:37 -0800 Subject: [PATCH 1/2] linesweeper: close segments that start at y < 0 are put in order compute_positions keeps the last height it handled for each output segment in last_y and skips a queue entry below that height. last_y started at 0, so a segment starting at y < 0 was skipped at its first entry and its close neighbors were never put in order. With Correctness::ReallyCorrect, two lenses 0.001 apart gave 48 corrected quadratics at dy = 100 and 20 uncorrected cubics at dy = -100. last_y now starts at each segment's start height. README.craft.md and SOURCE.json record the change. --- vendor/linesweeper/README.craft.md | 22 ++++++++---- vendor/linesweeper/SOURCE.json | 6 ++-- vendor/linesweeper/src/position.rs | 56 ++++++++++++++++++++++++++++-- 3 files changed, 73 insertions(+), 11 deletions(-) diff --git a/vendor/linesweeper/README.craft.md b/vendor/linesweeper/README.craft.md index f683ca53de..f723c79cb3 100644 --- a/vendor/linesweeper/README.craft.md +++ b/vendor/linesweeper/README.craft.md @@ -1,15 +1,23 @@ # Local linesweeper 0.5.0 copy -This is the crates.io linesweeper 0.5.0 package (MIT OR Apache-2.0) with some files left out and no -file changed. `.cargo_vcs_info.json` names the commit it was packaged from, +This is the crates.io linesweeper 0.5.0 package (MIT OR Apache-2.0) with some files left out and the +changes listed under Local changes. `.cargo_vcs_info.json` names the commit it was packaged from, `824b0791a750f7b27b8edcbb6c6244d0e629875e`. That commit is not in the GitHub repository the manifest names, which is archived; its README says development moved off GitHub. -Every file here except this one and `SOURCE.json` is byte for byte the file in the `.crate` archive. -`SOURCE.json` records the hash of the `.crate` download (`source_archive_sha256`) and, for every file -kept, the hash in the package (`source_sha256`) and the hash here (`sha256`). `upstream_repository` is -null because no public repository this copy can name holds `upstream_revision`. `local_patches` is -empty. +Every file here except this one, `SOURCE.json` and the files under Local changes is byte for byte the +file in the `.crate` archive. `SOURCE.json` records the hash of the `.crate` download +(`source_archive_sha256`) and, for every file kept, the hash in the package (`source_sha256`) and the +hash here (`sha256`). `upstream_repository` is null because no public repository this copy can name +holds `upstream_revision`. `local_patches` describes each local change. + +## Local changes + +| Change | Code comment label | Touches | Tests | +|---|---|---|---| +| `compute_positions` starts each output segment's `last_y` at the segment's start height instead of 0, so a segment that starts at `y < 0` is not skipped at its first queue entry and close segments there are put in order | `Craft patch (start height)` | `src/position.rs` | `position::tests::correct_positions_at_negative_y` | + +Every change here updates this table and `SOURCE.json` in the same commit. `omitted_files` lists the 43 files of the package left out here, with their hashes: diff --git a/vendor/linesweeper/SOURCE.json b/vendor/linesweeper/SOURCE.json index 9c71e51add..338c9857b3 100644 --- a/vendor/linesweeper/SOURCE.json +++ b/vendor/linesweeper/SOURCE.json @@ -7,7 +7,9 @@ "upstream_repository": null, "upstream_revision": "824b0791a750f7b27b8edcbb6c6244d0e629875e", "upstream_directory": "", - "local_patches": [], + "local_patches": [ + "In `src/position.rs`, `compute_positions` sets each output segment's `last_y` to the segment's start height before queuing it. It started at 0, so a segment starting at `y < 0` was skipped at its first queue entry and close segments there were not put in order: with `Correctness::ReallyCorrect`, two lenses 0.001 apart at `dy = 100` gave 48 corrected quadratics, and the same lenses at `dy = -100` gave 20 uncorrected cubics. `position::tests::correct_positions_at_negative_y` checks both heights." + ], "files": [ { "path": ".cargo_vcs_info.json", "source_sha256": "47fba6a9dbdf445a5c97f783c9be62093035f9d5e5cdc2cf3216ad8259bcd8fc", "source_git_blob": null, "sha256": "47fba6a9dbdf445a5c97f783c9be62093035f9d5e5cdc2cf3216ad8259bcd8fc" }, { "path": ".gitignore", "source_sha256": "88b59092499ae05234330eb7d0b01e953e969caf05261530e3765eef02536cf0", "source_git_blob": null, "sha256": "88b59092499ae05234330eb7d0b01e953e969caf05261530e3765eef02536cf0" }, @@ -41,7 +43,7 @@ { "path": "src/num.rs", "source_sha256": "39ff85da50c500ce91cf6dea81aedc0dcca1db5e7d0506696dde2da118e93a2a", "source_git_blob": null, "sha256": "39ff85da50c500ce91cf6dea81aedc0dcca1db5e7d0506696dde2da118e93a2a" }, { "path": "src/order.rs", "source_sha256": "7e5b04eae8af134abb032e995f1d3c2ac473822923dfee8d463d9ade6ffeb596", "source_git_blob": null, "sha256": "7e5b04eae8af134abb032e995f1d3c2ac473822923dfee8d463d9ade6ffeb596" }, { "path": "src/perturbation.rs", "source_sha256": "fa274a822bbdf65f8e53e403eef78034dd87964b3f1d3134a064df4ec8cef9c5", "source_git_blob": null, "sha256": "fa274a822bbdf65f8e53e403eef78034dd87964b3f1d3134a064df4ec8cef9c5" }, - { "path": "src/position.rs", "source_sha256": "dfa70840805ecccf5b7eb6122921e46ca60c24cb7b3c17f3b55ffc2549368ab0", "source_git_blob": null, "sha256": "dfa70840805ecccf5b7eb6122921e46ca60c24cb7b3c17f3b55ffc2549368ab0" }, + { "path": "src/position.rs", "source_sha256": "dfa70840805ecccf5b7eb6122921e46ca60c24cb7b3c17f3b55ffc2549368ab0", "source_git_blob": null, "sha256": "fa3f09aaa49638b5fec122e27092424669c57d2eb5757fe773b9cad5e8b204b2" }, { "path": "src/segments.rs", "source_sha256": "379f9455120492d237cb5a62b3fc06da018a72e2eb75bbfcd61b4cce501d9bbc", "source_git_blob": null, "sha256": "379f9455120492d237cb5a62b3fc06da018a72e2eb75bbfcd61b4cce501d9bbc" }, { "path": "src/snapshots/linesweeper__tests__empty_horizontals.snap", "source_sha256": "e319881853e889badf6524f19af4cd6f112e8dd71bdc516826f4463134a82244", "source_git_blob": null, "sha256": "e319881853e889badf6524f19af4cd6f112e8dd71bdc516826f4463134a82244" }, { "path": "src/snapshots/linesweeper__tests__two_squares.snap", "source_sha256": "01961e0311a5af3b8f13eb52a2a7112560c47cf86771c04e40475dc6f15a0846", "source_git_blob": null, "sha256": "01961e0311a5af3b8f13eb52a2a7112560c47cf86771c04e40475dc6f15a0846" }, diff --git a/vendor/linesweeper/src/position.rs b/vendor/linesweeper/src/position.rs index f4cbd773d5..68c231693c 100644 --- a/vendor/linesweeper/src/position.rs +++ b/vendor/linesweeper/src/position.rs @@ -384,6 +384,8 @@ pub(crate) fn compute_positions( continue; } out[idx].path.move_to(p); + // Craft patch (start height): a segment that starts at y < 0 is not skipped. + last_y[idx] = p.y; queue.push(HeapEntry { y: p.y.into(), idx }); } @@ -504,9 +506,9 @@ pub(crate) fn compute_positions( #[cfg(test)] mod tests { - use kurbo::{BezPath, CubicBez, Line, PathSeg}; + use kurbo::{BezPath, CubicBez, Line, PathEl, PathSeg}; - use crate::Segments; + use crate::{Segments, sweep::Correctness, topology::Topology}; use super::horizontal_error_weight; @@ -558,4 +560,54 @@ mod tests { let next_y0 = super::approximate(90.03645987646233, y1, &[s0, s1], &segs, 2.5e-7, &mut out); assert_eq!(next_y0, y1); } + + // Counts the path elements of each kind in the correct positions of two + // lenses that run close together, moved down by `dy`. + fn close_lens_elements(dy: f64) -> [usize; 4] { + fn lens(dx: f64, dy: f64) -> BezPath { + let mut p = BezPath::new(); + p.move_to((dx, dy)); + p.curve_to( + (10.0 + dx, 3.0 + dy), + (10.0 + dx, 7.0 + dy), + (dx, 10.0 + dy), + ); + p.curve_to((-10.0 + dx, 7.0 + dy), (-10.0 + dx, 3.0 + dy), (dx, dy)); + p.close_path(); + p + } + let a = lens(0.0, dy); + let b = lens(0.001, dy); + let top = Topology::::from_paths_with_correctness( + [(&a, ()), (&b, ())], + 0.01, + Correctness::ReallyCorrect, + ) + .unwrap(); + let positions = top.compute_positions(); + let mut counts = [0; 4]; + for idx in positions.indices() { + for el in positions[idx].path.elements() { + match el { + PathEl::MoveTo(_) => counts[0] += 1, + PathEl::LineTo(_) => counts[1] += 1, + PathEl::QuadTo(..) => counts[2] += 1, + PathEl::CurveTo(..) => counts[3] += 1, + PathEl::ClosePath => {} + } + } + } + counts + } + + // Craft patch (start height): moving the input up or down must not change + // how the close segments are positioned, including when the segments start + // at y < 0. + #[test] + fn correct_positions_at_negative_y() { + let below = close_lens_elements(100.0); + let above = close_lens_elements(-100.0); + assert!(below[2] > 0, "{below:?}"); + assert_eq!(below, above); + } } From 70c2b6b5bdb2585987e7443e291cf0513a2d8078 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 7 Nov 2026 07:33:46 -0800 Subject: [PATCH 2/2] linesweeper: record the committed bytes' digest for position.rs --- vendor/linesweeper/SOURCE.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/linesweeper/SOURCE.json b/vendor/linesweeper/SOURCE.json index 338c9857b3..69110c63fe 100644 --- a/vendor/linesweeper/SOURCE.json +++ b/vendor/linesweeper/SOURCE.json @@ -43,7 +43,7 @@ { "path": "src/num.rs", "source_sha256": "39ff85da50c500ce91cf6dea81aedc0dcca1db5e7d0506696dde2da118e93a2a", "source_git_blob": null, "sha256": "39ff85da50c500ce91cf6dea81aedc0dcca1db5e7d0506696dde2da118e93a2a" }, { "path": "src/order.rs", "source_sha256": "7e5b04eae8af134abb032e995f1d3c2ac473822923dfee8d463d9ade6ffeb596", "source_git_blob": null, "sha256": "7e5b04eae8af134abb032e995f1d3c2ac473822923dfee8d463d9ade6ffeb596" }, { "path": "src/perturbation.rs", "source_sha256": "fa274a822bbdf65f8e53e403eef78034dd87964b3f1d3134a064df4ec8cef9c5", "source_git_blob": null, "sha256": "fa274a822bbdf65f8e53e403eef78034dd87964b3f1d3134a064df4ec8cef9c5" }, - { "path": "src/position.rs", "source_sha256": "dfa70840805ecccf5b7eb6122921e46ca60c24cb7b3c17f3b55ffc2549368ab0", "source_git_blob": null, "sha256": "fa3f09aaa49638b5fec122e27092424669c57d2eb5757fe773b9cad5e8b204b2" }, + { "path": "src/position.rs", "source_sha256": "dfa70840805ecccf5b7eb6122921e46ca60c24cb7b3c17f3b55ffc2549368ab0", "source_git_blob": null, "sha256": "37686f512c4f4ded9fcbd19e8a736f1462ad2e883a65d88d32a7c441d512dc30" }, { "path": "src/segments.rs", "source_sha256": "379f9455120492d237cb5a62b3fc06da018a72e2eb75bbfcd61b4cce501d9bbc", "source_git_blob": null, "sha256": "379f9455120492d237cb5a62b3fc06da018a72e2eb75bbfcd61b4cce501d9bbc" }, { "path": "src/snapshots/linesweeper__tests__empty_horizontals.snap", "source_sha256": "e319881853e889badf6524f19af4cd6f112e8dd71bdc516826f4463134a82244", "source_git_blob": null, "sha256": "e319881853e889badf6524f19af4cd6f112e8dd71bdc516826f4463134a82244" }, { "path": "src/snapshots/linesweeper__tests__two_squares.snap", "source_sha256": "01961e0311a5af3b8f13eb52a2a7112560c47cf86771c04e40475dc6f15a0846", "source_git_blob": null, "sha256": "01961e0311a5af3b8f13eb52a2a7112560c47cf86771c04e40475dc6f15a0846" },