refactor(core): share duplicated geometry helpers

Route the four identical even-odd ray casts through RingContainment.Contains and share the arc-intersection, span-pairing, overlap-region, lead-in, plate-offset, leader-edge, entity-copy and path-perimeter duplicates. Expressions and loop order are unchanged, so results are bit-identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Opus 5.5 committed 2026-11-28 18:36:40 -05:00
1 parent 8a1d89cea5
commit 409d30d29e
15 files changed
+108 -154

No files matched your search

+9 -7
View File
@@ -169,17 +169,13 @@ namespace OpenNest.Support
/// </summary>
public IReadOnlyList<(double Start, double End)> SpansAtY(double y)
{
var crossings = new List<double>();
if (!IsComplete || y < bounds.Bottom || y > bounds.Top)
return Array.Empty<(double, double)>();
var crossings = new List<double>();
AddCrossings(outline, y, crossings);
foreach (var hole in holes)
AddCrossings(hole, y, crossings);
crossings.Sort();
var spans = new List<(double, double)>(crossings.Count / 2);
for (var i = 0; i + 1 < crossings.Count; i += 2)
spans.Add((crossings[i], crossings[i + 1]));
return spans;
return PairCrossings(crossings);
}
/// <summary>
@@ -188,12 +184,18 @@ namespace OpenNest.Support
/// </summary>
public IReadOnlyList<(double Start, double End)> SpansAtX(double x)
{
var crossings = new List<double>();
if (!IsComplete || x < bounds.Left || x > bounds.Right)
return Array.Empty<(double, double)>();
var crossings = new List<double>();
AddCrossingsAtX(outline, x, crossings);
foreach (var hole in holes)
AddCrossingsAtX(hole, x, crossings);
return PairCrossings(crossings);
}
/// <summary>Sorts the crossings and pairs them into the spans between them.</summary>
private static List<(double Start, double End)> PairCrossings(List<double> crossings)
{
crossings.Sort();
var spans = new List<(double, double)>(crossings.Count / 2);
for (var i = 0; i + 1 < crossings.Count; i += 2)