fix: use chain tolerance for shape building to handle DXF endpoint gaps

DXF files can have endpoint gaps at entity junctions that fall right at
the floating-point boundary of Tolerance.Epsilon (0.00001). This caused
shapes to not close, resulting in 0 area and 0% utilization in Best-Fit.

Added ChainTolerance (0.0001) for endpoint chaining in GetConnected and
Shape.IsClosed, keeping the tighter Epsilon for geometric precision.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 08:37:39 -04:00
parent 9f84357c34
commit d0d334e734
3 changed files with 16 additions and 7 deletions
+6 -4
View File
@@ -339,6 +339,8 @@ namespace OpenNest
internal static Entity GetConnected(Vector pt, IEnumerable<Entity> geometry)
{
var tol = Math.Tolerance.ChainTolerance;
foreach (var geo in geometry)
{
switch (geo.Type)
@@ -346,10 +348,10 @@ namespace OpenNest
case EntityType.Arc:
var arc = (Arc)geo;
if (arc.StartPoint() == pt)
if (arc.StartPoint().DistanceTo(pt) <= tol)
return arc;
if (arc.EndPoint() == pt)
if (arc.EndPoint().DistanceTo(pt) <= tol)
{
arc.Reverse();
return arc;
@@ -360,10 +362,10 @@ namespace OpenNest
case EntityType.Line:
var line = (Line)geo;
if (line.StartPoint == pt)
if (line.StartPoint.DistanceTo(pt) <= tol)
return line;
if (line.EndPoint == pt)
if (line.EndPoint.DistanceTo(pt) <= tol)
{
line.Reverse();
return line;