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>
21 lines
579 B
C#
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;
|
|
}
|
|
}
|
|
}
|