using System.Collections.Generic;
using OpenNest.Geometry;
namespace OpenNest.CNC.Posting;
///
/// One contour of a posted part: pierce, lead-in and cut path in a single absolute frame
/// (sheet coordinates from ). Arc moves keep their
/// absolute centres; each post formats I/J its own way.
///
public sealed class PostContour
{
/// Pierce point: the rapid target.
public Vector Pierce { get; set; }
///
/// First lead-in move, ending on the contour, or null when the contour starts cutting at
/// the pierce.
///
public Motion LeadIn { get; set; }
/// Lead-in moves after the first (e.g. the arc after a clean-hole line).
public List LeadInExtra { get; } = new();
/// Moves made with the cut layer on: cut, lead-out, display and scribe.
public List Cuts { get; } = new();
///
/// Head-height lock changes in a cut-off's overcut: each comes before the cut at
/// Before (.Count: after the last cut), locking when Lock.
///
public List<(int Before, bool Lock)> HeadLocks { get; } = new();
/// Whether the rapid to the pierce raises the head over parts already cut ().
public bool Raised { get; set; }
///
/// True for a common line's shared cut (): an open
/// centerline cut made without kerf compensation.
///
public bool IsCommonLine { get; set; }
///
/// For a common-line remainder, the winding of the perimeter it belongs to
/// (): it is cut as the perimeter, compensated on that side.
/// Null for every other contour.
///
public RotationType? RemainderWinding { get; set; }
///
/// True for the part's outside edge, or a common-line remainder of it; false for holes,
/// marks, shared cuts and cut-offs.
///
public bool IsPerimeter { get; set; }
///
/// The compensation that keeps the kerf in the scrap: (G41)
/// leaves the part right of travel, (G42) left of it.
/// for marks, common-line shared cuts and cut-offs, which have
/// no inside.
///
public KerfType Kerf { get; set; }
/// True when every cut is on the scribe layer: a mark, not material.
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;
}
}
}