using System; namespace OpenNest.Dimensions { public enum DimensionKind { /// The part's overall size along X, drawn above or below it. OverallHorizontal, /// The part's overall size along Y, drawn right or left of it. OverallVertical, /// A circle's or arc's radius, on a leader from its center. Radius, /// A circle's or arc's diameter, on a leader across it. Diameter, } /// /// An annotation on a drawing. Only its placement is stored: the value is measured from the /// geometry each time it is resolved, so it cannot go stale. It never affects the program. /// public sealed class DrawingDimension { public DimensionKind Kind { get; set; } /// /// Never zero. Overall dimensions: distance from the part's extents to the dimension line, /// positive above a horizontal dimension's part or right of a vertical one's. Radius and /// diameter: distance from the curve to the label along the leader, positive outside. /// public double Offset { get; set; } /// The circle or arc a radius or diameter measures; empty for overall dimensions. public Guid EntityId { get; set; } /// Radius and diameter: the leader's direction from the center, in radians. public double Angle { get; set; } public bool IsRadial => IsRadialKind(Kind); public static bool IsRadialKind(DimensionKind kind) => kind is DimensionKind.Radius or DimensionKind.Diameter; public DrawingDimension Clone() => new() { Kind = Kind, Offset = Offset, EntityId = EntityId, Angle = Angle }; } }