feat: add PairCandidate, BestFitResult, and IBestFitStrategy for best-fit pair finding
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
40
OpenNest.Engine/BestFit/BestFitResult.cs
Normal file
40
OpenNest.Engine/BestFit/BestFitResult.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
namespace OpenNest.Engine.BestFit
|
||||
{
|
||||
public class BestFitResult
|
||||
{
|
||||
public PairCandidate Candidate { get; set; }
|
||||
public double RotatedArea { get; set; }
|
||||
public double BoundingWidth { get; set; }
|
||||
public double BoundingHeight { get; set; }
|
||||
public double OptimalRotation { get; set; }
|
||||
public bool Keep { get; set; }
|
||||
public string Reason { get; set; }
|
||||
public double TrueArea { get; set; }
|
||||
|
||||
public double Utilization
|
||||
{
|
||||
get { return RotatedArea > 0 ? TrueArea / RotatedArea : 0; }
|
||||
}
|
||||
|
||||
public double LongestSide
|
||||
{
|
||||
get { return System.Math.Max(BoundingWidth, BoundingHeight); }
|
||||
}
|
||||
|
||||
public double ShortestSide
|
||||
{
|
||||
get { return System.Math.Min(BoundingWidth, BoundingHeight); }
|
||||
}
|
||||
}
|
||||
|
||||
public enum BestFitSortField
|
||||
{
|
||||
Area,
|
||||
LongestSide,
|
||||
ShortestSide,
|
||||
Type,
|
||||
OriginalSequence,
|
||||
Keep,
|
||||
WhyKeepDrop
|
||||
}
|
||||
}
|
||||
11
OpenNest.Engine/BestFit/IBestFitStrategy.cs
Normal file
11
OpenNest.Engine/BestFit/IBestFitStrategy.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenNest.Engine.BestFit
|
||||
{
|
||||
public interface IBestFitStrategy
|
||||
{
|
||||
int Type { get; }
|
||||
string Description { get; }
|
||||
List<PairCandidate> GenerateCandidates(Drawing drawing, double spacing, double stepSize);
|
||||
}
|
||||
}
|
||||
15
OpenNest.Engine/BestFit/PairCandidate.cs
Normal file
15
OpenNest.Engine/BestFit/PairCandidate.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using OpenNest.Geometry;
|
||||
|
||||
namespace OpenNest.Engine.BestFit
|
||||
{
|
||||
public class PairCandidate
|
||||
{
|
||||
public Drawing Drawing { get; set; }
|
||||
public double Part1Rotation { get; set; }
|
||||
public double Part2Rotation { get; set; }
|
||||
public Vector Part2Offset { get; set; }
|
||||
public int StrategyType { get; set; }
|
||||
public int TestNumber { get; set; }
|
||||
public double Spacing { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BestCombination.cs" />
|
||||
<Compile Include="BestFit\PairCandidate.cs" />
|
||||
<Compile Include="BestFit\BestFitResult.cs" />
|
||||
<Compile Include="BestFit\IBestFitStrategy.cs" />
|
||||
<Compile Include="CirclePacking\Bin.cs" />
|
||||
<Compile Include="CirclePacking\FillEndEven.cs" />
|
||||
<Compile Include="CirclePacking\FillEndOdd.cs" />
|
||||
|
||||
Reference in New Issue
Block a user