mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-03 10:59:27 -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
@@ -143,19 +143,6 @@ public static class KeepOutOverlap
|
||||
|
||||
/// <summary>Even-odd ray cast; exact for a point that is not on the ring (callers only
|
||||
/// ask after ruling out any edge through the rectangle containing the point).</summary>
|
||||
private static bool Contains(Polygon ring, Vector point)
|
||||
{
|
||||
var inside = false;
|
||||
var vertices = ring.Vertices;
|
||||
var count = vertices.Count;
|
||||
for (int i = 0, j = count - 1; i < count; j = i++)
|
||||
{
|
||||
var a = vertices[i];
|
||||
var b = vertices[j];
|
||||
if ((a.Y > point.Y) != (b.Y > point.Y)
|
||||
&& point.X < (b.X - a.X) * (point.Y - a.Y) / (b.Y - a.Y) + a.X)
|
||||
inside = !inside;
|
||||
}
|
||||
return inside;
|
||||
}
|
||||
private static bool Contains(Polygon ring, Vector point) =>
|
||||
RingContainment.Contains(ring.Vertices, point);
|
||||
}
|
||||
Reference in new issue
Block a user