mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-03 12:09:25 -05:00
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:
1 parent
8a1d89cea5
commit
409d30d29e
15 files changed
+108
-154
No files matched your search
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user