perf: optimize fill hot path — bbox pre-check and geometry inner loop
- Add bounding box rejection in HasOverlaps to skip expensive Part.Intersects (CNC→geometry conversion) for non-adjacent parts. Eliminates ~35% CPU in IsBetterValidFill for grid layouts. - Optimize RayEdgeDistance: access Line fields directly instead of property getters (avoids Vector struct copies), inline IsEqualTo with direct range comparison (avoids Math.Abs), and precompute deltas for reuse in interpolation. - Cache line endpoints in DirectionalDistance outer loop to avoid repeated struct copies in the inner loop. - Add fill timer to ActionClone.Fill, displayed in PlateView status bar as "Fill: N parts in M ms". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -273,8 +273,19 @@ namespace OpenNest
|
||||
|
||||
for (var i = 0; i < parts.Count; i++)
|
||||
{
|
||||
var box1 = parts[i].BoundingBox;
|
||||
|
||||
for (var j = i + 1; j < parts.Count; j++)
|
||||
{
|
||||
var box2 = parts[j].BoundingBox;
|
||||
|
||||
// Fast bounding box rejection — if boxes don't overlap,
|
||||
// the parts can't intersect. Eliminates nearly all pairs
|
||||
// in grid layouts.
|
||||
if (box1.Right < box2.Left || box2.Right < box1.Left ||
|
||||
box1.Top < box2.Bottom || box2.Top < box1.Bottom)
|
||||
continue;
|
||||
|
||||
List<Vector> pts;
|
||||
|
||||
if (parts[i].Intersects(parts[j], out pts))
|
||||
|
||||
Reference in New Issue
Block a user