Files
OpenNest/OpenNest.Core/Math/Tolerance.cs
AJ Isaacs d0d334e734 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>
2026-03-12 08:37:39 -04:00

21 lines
579 B
C#

using System;
namespace OpenNest.Math
{
public static class Tolerance
{
public const double Epsilon = 0.00001;
/// <summary>
/// Tolerance for chaining entity endpoints when building shapes from DXF imports.
/// Larger than Epsilon to handle floating-point gaps at entity junctions.
/// </summary>
public const double ChainTolerance = 0.0001;
public static bool IsEqualTo(this double a, double b, double tolerance = Epsilon)
{
return System.Math.Abs(b - a) <= tolerance;
}
}
}