Ystripes#1101
Open
sethhillbrand wants to merge 3 commits into
Open
Conversation
StripeIndex buckets a ring's edges into horizontal Y stripes so PolyTree nesting tests child vertices in ~O(sqrt n) instead of O(n) per query. Wired into owner/split containment behind an edge-count threshold, with a brute-force fallback for small or adversarial rings. Includes unit, differential, and real-world QA.
Mirrors the C++ StripeIndex: per-ring Y-stripe bucketing for PolyTree nesting with a brute-force fallback below the edge-count threshold. Adds the StripeIndex test suite.
Mirrors the C++ StripeIndex: per-ring Y-stripe bucketing for PolyTree nesting with a brute-force fallback below the edge-count threshold. Adds a standalone console QA program.
Owner
|
Hi Seth. |
Contributor
Author
|
@AngusJohnson take your time and let me know if I can help at all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi @AngusJohnson !
A while ago, I wrote a point-in-polygon implementation for KiCad that uses ystripes. It works really well to speed things up relative to our various other algorithms that we used. Eventually, one of our clients came to us with a slow zone fill even in the new system. Profiling showed that one of the bottlenecks was in assigning hierarchy in PolyTrees for boolean ops.
To fix this, I adapted the ystripes algorithm to Clipper2 and tested with our realworld data (as well as the existing Clipper2 adversarial data). Because the algorithm doesn't work well for small polygons, it has a fail-safe that falls back to the original algo at 64 edges. For this reason, we see a worst-case speed-up of 1.0x.
What follows is my testing data on a Intel Core i9-13900KF · Debian 13 (kernel 6.12) · single-threaded, best of 5 results for both baseline and y-stripe.
-O2)-O2)fpc -O2)I couldn't find a QA system for Delphi, so I just made a small self-contained app that tested this.
I wrote this originally in C++ and ported to C# and Delphi (which are not my native languages) so please let me know if I made any mistakes. They both compile, run correctly per the QA. The C++ version is tested in KiCad as well.