Files
OpenNest/OpenNest.Core/CNC/Posting/PostContour.cs
T
ajandClaude Opus 5.5 cd623ff1aa refactor(posts): share contour geometry between posts through Core
Move the CI Fiber post's contour extraction and winding into Core as
OpenNest.CNC.Posting.PostContours and ContourWinding, so every post can
take sheet- or part-frame contours with the perimeter and kerf side
already chosen instead of re-deriving them. CI Fiber now writes from
the shared model; its golden output is unchanged.

Scribe marks are never picked as the perimeter and get no kerf. A cut
that resumes after suppressed moves starts a new contour where they
end, so it is no longer cut as a chord across the gap.

Add tests for a square with a hole in sheet coordinates, identical
contours from absolute and incremental part/hole programs, rotation,
and the kerf side for both windings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:36:44 -05:00

60 lines
2.1 KiB
C#

using System.Collections.Generic;
using OpenNest.Geometry;
namespace OpenNest.CNC.Posting;
/// <summary>
/// One contour of a posted part: pierce, lead-in and cut path in a single absolute frame
/// (sheet coordinates from <see cref="PostContours.Extract(Part)"/>). Arc moves keep their
/// absolute centres; each post formats I/J its own way.
/// </summary>
public sealed class PostContour
{
/// <summary>Pierce point: the rapid target.</summary>
public Vector Pierce { get; set; }
/// <summary>
/// First lead-in move, ending on the contour, or null when the contour starts cutting at
/// the pierce.
/// </summary>
public Motion LeadIn { get; set; }
/// <summary>Lead-in moves after the first (e.g. the arc after a clean-hole line).</summary>
public List<Motion> LeadInExtra { get; } = new();
/// <summary>Moves made with the cut layer on: cut, lead-out, display and scribe.</summary>
public List<Motion> Cuts { get; } = new();
/// <summary>
/// Head-height lock changes in a cut-off's overcut: each comes before the cut at
/// <c>Before</c> (<see cref="Cuts"/>.Count: after the last cut), locking when <c>Lock</c>.
/// </summary>
public List<(int Before, bool Lock)> HeadLocks { get; } = new();
/// <summary>True for the part's outside edge; false for holes, marks and cut-offs.</summary>
public bool IsPerimeter { get; set; }
/// <summary>
/// The compensation that keeps the kerf in the scrap: <see cref="KerfType.Left"/> (G41)
/// leaves the part right of travel, <see cref="KerfType.Right"/> (G42) left of it.
/// <see cref="KerfType.None"/> for marks and cut-offs, which have no inside.
/// </summary>
public KerfType Kerf { get; set; }
/// <summary>True when every cut is on the scribe layer: a mark, not material.</summary>
public bool IsMark
{
get
{
if (Cuts.Count == 0)
return false;
foreach (var cut in Cuts)
{
if (PostContours.LayerOf(cut) != LayerType.Scribe)
return false;
}
return true;
}
}
}