feat: add Bend domain model and BendDirection enum to OpenNest.Core

Introduces OpenNest.Core/Bending/ with Bend and BendDirection types as
the foundation for bend line detection. Includes 6 passing unit tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-24 20:18:52 -04:00
parent 39f8a79cfd
commit c2a470f79c
3 changed files with 136 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
using OpenNest.Geometry;
using OpenNest.Math;
namespace OpenNest.Bending
{
public class Bend
{
public Vector StartPoint { get; set; }
public Vector EndPoint { get; set; }
public BendDirection Direction { get; set; }
public double? Angle { get; set; }
public double? Radius { get; set; }
public string NoteText { get; set; }
public double Length => StartPoint.DistanceTo(EndPoint);
public double AngleRadians => Angle.HasValue
? OpenNest.Math.Angle.ToRadians(Angle.Value)
: 0;
public Line ToLine() => new Line(StartPoint, EndPoint);
/// <summary>
/// Returns the angle of the bend line itself (not the bend angle).
/// Used for grain direction comparison.
/// </summary>
public double LineAngle => StartPoint.AngleTo(EndPoint);
public override string ToString()
{
var dir = Direction.ToString();
var angle = Angle?.ToString("0.##") ?? "?";
var radius = Radius?.ToString("0.###") ?? "?";
return $"{dir} {angle}° R{radius}";
}
}
}

View File

@@ -0,0 +1,9 @@
namespace OpenNest.Bending
{
public enum BendDirection
{
Unknown,
Up,
Down
}
}