Files
OpenNest/OpenNest.Engine/Pattern.cs
AJ Isaacs b738d4c72c refactor: clean up NestEngine — collapse overloads, extract helper, remove dead code
- Fill(NestItem) and Fill(List<Part>) now delegate to their Box overloads
- Add Part.CreateAtOrigin() to replace repeated 4-line build-at-origin pattern
  used in NestEngine, RotationSlideStrategy, and PairEvaluator
- Remove dead code: FillArea overloads, Fill(NestItem, int), FillWithPairs(NestItem),
  ConvertTileResultToParts, PackBottomLeft.FindPointHorizontal, Pattern.GetLines/GetOffsetLines,
  unused count variable in FillNoRotation
- Simplify IsBetterValidFill to delegate to IsBetterFill after overlap check

NestEngine reduced from 717 to 484 lines.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 21:31:15 -05:00

38 lines
773 B
C#

using System.Collections.Generic;
using OpenNest.Geometry;
namespace OpenNest
{
public class Pattern
{
public Pattern()
{
Parts = new List<Part>();
}
public List<Part> Parts { get; }
public Box BoundingBox { get; private set; }
public void UpdateBounds()
{
BoundingBox = Parts.GetBoundingBox();
}
public Pattern Clone(Vector offset)
{
var pattern = new Pattern();
foreach (var part in Parts)
{
var clone = (Part)part.Clone();
clone.Offset(offset);
pattern.Parts.Add(clone);
}
pattern.UpdateBounds();
return pattern;
}
}
}