Files
OpenNest/OpenNest.Posts.Cincinnati/SpeedClassifier.cs
AJ Isaacs 8efdc8720c fix: review fixes — culture-invariant formatting, sealed config, threshold boundary
- Use CultureInfo.InvariantCulture in CoordinateFormatter, SpeedClassifier,
  and CincinnatiPreambleWriter to prevent locale-dependent G-code output
- Make CincinnatiPostConfig sealed per spec
- Fix SpeedClassifier.Classify threshold to >= (matching spec)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 23:45:22 -04:00

32 lines
1.1 KiB
C#

namespace OpenNest.Posts.Cincinnati
{
public sealed class SpeedClassifier
{
public double FastThreshold { get; set; } = 0.5;
public double SlowThreshold { get; set; } = 0.1;
public string Classify(double contourLength, double sheetDiagonal)
{
var ratio = contourLength / sheetDiagonal;
if (ratio >= FastThreshold) return "FAST";
if (ratio <= SlowThreshold) return "SLOW";
return "MEDIUM";
}
public string FormatCutDist(double contourLength, double sheetDiagonal)
{
return $"CutDist={FormatValue(contourLength)}/{FormatValue(sheetDiagonal)}";
}
private static string FormatValue(double value)
{
// Cincinnati convention: no leading zero for values < 1 (e.g., ".8702" not "0.8702")
var rounded = System.Math.Round(value, 4);
var str = rounded.ToString("0.####", System.Globalization.CultureInfo.InvariantCulture);
if (rounded > 0 && rounded < 1 && str.StartsWith("0."))
return str.Substring(1);
return str;
}
}
}