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:
@@ -739,6 +739,8 @@ namespace OpenNest
|
||||
return pts.Count > 0;
|
||||
}
|
||||
|
||||
private const int PushArcSegments = 36;
|
||||
|
||||
public static List<Line> GetPartLines(Part part)
|
||||
{
|
||||
var entities = ConvertProgram.ToGeometry(part.Program);
|
||||
@@ -747,7 +749,7 @@ namespace OpenNest
|
||||
|
||||
foreach (var shape in shapes)
|
||||
{
|
||||
var polygon = shape.ToPolygon();
|
||||
var polygon = shape.ToPolygon(PushArcSegments);
|
||||
polygon.Offset(part.Location);
|
||||
lines.AddRange(polygon.ToLines());
|
||||
}
|
||||
@@ -768,7 +770,7 @@ namespace OpenNest
|
||||
if (offsetEntity == null)
|
||||
continue;
|
||||
|
||||
var polygon = offsetEntity.ToPolygon();
|
||||
var polygon = offsetEntity.ToPolygon(PushArcSegments);
|
||||
polygon.Offset(part.Location);
|
||||
lines.AddRange(polygon.ToLines());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user