feat: add Pattern class for grouping parts with relative positions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
<Compile Include="NestDirection.cs" />
|
||||
<Compile Include="NestEngine.cs" />
|
||||
<Compile Include="NestItem.cs" />
|
||||
<Compile Include="Pattern.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RectanglePacking\Bin.cs" />
|
||||
<Compile Include="RectanglePacking\FillBestFit.cs" />
|
||||
|
||||
57
OpenNest.Engine/Pattern.cs
Normal file
57
OpenNest.Engine/Pattern.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
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 List<Line> GetLines(PushDirection facingDirection)
|
||||
{
|
||||
var lines = new List<Line>();
|
||||
|
||||
foreach (var part in Parts)
|
||||
lines.AddRange(Helper.GetPartLines(part, facingDirection));
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
public List<Line> GetOffsetLines(double spacing, PushDirection facingDirection)
|
||||
{
|
||||
var lines = new List<Line>();
|
||||
|
||||
foreach (var part in Parts)
|
||||
lines.AddRange(Helper.GetOffsetPartLines(part, spacing, facingDirection));
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user