feat: add IBendDetector interface, SolidWorks implementation, and registry

Introduces a pluggable bend detection system in OpenNest.IO.Bending:
- IBendDetector takes CadDocument directly to preserve MText/layer/linetype info
- SolidWorksBendDetector finds lines on BEND layer with CENTER linetype and matches nearby MText notes
- BendDetectorRegistry auto-registers SolidWorks detector and supports AutoDetect

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-24 20:26:27 -04:00
parent 574a8f2c38
commit 5f74afeda1
4 changed files with 221 additions and 0 deletions
@@ -0,0 +1,40 @@
using ACadSharp;
using OpenNest.Bending;
using System.Collections.Generic;
using System.Linq;
namespace OpenNest.IO.Bending
{
public static class BendDetectorRegistry
{
private static readonly List<IBendDetector> detectors = new();
static BendDetectorRegistry()
{
Register(new SolidWorksBendDetector());
}
public static void Register(IBendDetector detector)
{
detectors.Add(detector);
}
public static IReadOnlyList<IBendDetector> Detectors => detectors;
public static IBendDetector GetByName(string name)
{
return detectors.FirstOrDefault(d => d.Name == name);
}
public static List<Bend> AutoDetect(CadDocument document)
{
foreach (var detector in detectors)
{
var bends = detector.DetectBends(document);
if (bends.Count > 0)
return bends;
}
return new List<Bend>();
}
}
}