perf: reduce arc segments for push distance calculation

ToPolygon() defaults to 1000 segments per arc, causing ~33k line
segments and O(n*m) slowdown. Use 36 segments (10° resolution) which
is more than sufficient for push distance accuracy.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 18:56:27 -05:00
parent 3931012079
commit ec5eff4884
+4 -2
View File
@@ -739,6 +739,8 @@ namespace OpenNest
return pts.Count > 0; return pts.Count > 0;
} }
private const int PushArcSegments = 36;
public static List<Line> GetPartLines(Part part) public static List<Line> GetPartLines(Part part)
{ {
var entities = ConvertProgram.ToGeometry(part.Program); var entities = ConvertProgram.ToGeometry(part.Program);
@@ -747,7 +749,7 @@ namespace OpenNest
foreach (var shape in shapes) foreach (var shape in shapes)
{ {
var polygon = shape.ToPolygon(); var polygon = shape.ToPolygon(PushArcSegments);
polygon.Offset(part.Location); polygon.Offset(part.Location);
lines.AddRange(polygon.ToLines()); lines.AddRange(polygon.ToLines());
} }
@@ -768,7 +770,7 @@ namespace OpenNest
if (offsetEntity == null) if (offsetEntity == null)
continue; continue;
var polygon = offsetEntity.ToPolygon(); var polygon = offsetEntity.ToPolygon(PushArcSegments);
polygon.Offset(part.Location); polygon.Offset(part.Location);
lines.AddRange(polygon.ToLines()); lines.AddRange(polygon.ToLines());
} }