// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using System.Collections.Generic; namespace SixLabors.PolygonClipper { /// /// Captures a clipped contour, its topology, and its ownership hierarchy. /// internal sealed class OutputRecord { /// /// Gets or sets the stable index assigned when the record is pooled. /// public int Index { get; set; } /// /// Gets or sets the number of output points in the contour. /// public int OutputPointCount { get; set; } /// /// Gets or sets the containing output record, if any. /// public OutputRecord? Owner { get; set; } /// /// Gets or sets the front edge that defines the output orientation. /// public ActiveEdge? FrontEdge { get; set; } /// /// Gets or sets the back edge that defines the output orientation. /// public ActiveEdge? BackEdge { get; set; } /// /// Gets or sets the circular linked list of output points. /// public OutputPoint? Points { get; set; } /// /// Gets or sets the cached bounds for ownership tests. /// public Box2 Bounds { get; set; } /// /// Gets or sets the temporary contour used during bounds checks. /// public List Path { get; set; } = []; /// /// Gets or sets split indices used to resolve complex self-intersections. /// public List? Splits { get; set; } /// /// Gets or sets the cached split ownership used to avoid recursion. /// public OutputRecord? RecursiveSplit { get; set; } } /// /// Represents a vertex in the output contour linked list. /// internal sealed class OutputPoint { #pragma warning disable SA1401 // Hot output ring traversal uses fields to avoid accessor overhead. /// /// The vertex coordinate. /// public Vertex Point; /// /// The next point in the linked list. /// public OutputPoint? Next; /// /// The previous point in the linked list. /// public OutputPoint Prev; /// /// The owning output record. /// public OutputRecord OutputRecord; /// /// The horizontal segment reference used for joins. /// public HorizontalSegment? HorizontalSegment; #pragma warning restore SA1401 /// /// Initializes a new instance of the class. /// public OutputPoint(Vertex point, OutputRecord outputRecord) { this.Point = point; this.OutputRecord = outputRecord; this.Next = this; this.Prev = this; this.HorizontalSegment = null; } } /// /// Captures a pending horizontal segment to be joined. /// internal sealed class HorizontalSegment { /// /// Initializes a new instance of the class. /// public HorizontalSegment(OutputPoint op) { this.LeftPoint = op; this.RightPoint = null; this.LeftToRight = true; } /// /// Gets or sets the left-most point of the segment. /// public OutputPoint? LeftPoint { get; set; } /// /// Gets or sets the right-most point of the segment. /// public OutputPoint? RightPoint { get; set; } /// /// Gets or sets a value indicating whether the segment runs left-to-right. /// public bool LeftToRight { get; set; } } /// /// Stores a pair of horizontal edges to be joined. /// internal sealed class HorizontalJoin { /// /// Initializes a new instance of the class. /// public HorizontalJoin(OutputPoint leftToRight, OutputPoint rightToLeft) { this.LeftToRight = leftToRight; this.RightToLeft = rightToLeft; } /// /// Gets or sets the left-to-right point of the join. /// public OutputPoint? LeftToRight { get; set; } /// /// Gets or sets the right-to-left point of the join. /// public OutputPoint? RightToLeft { get; set; } } }