mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-06 15:45:44 -05:00
refactor(engine): precompute hull angles during pair evaluation
Store hull edge angles in BestFitResult at evaluation time so they don't need to be recomputed during the fill phase. Extract GetHullEdgeAngles(Polygon) overload from FindHullEdgeAngles. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
1a9bd795a8
commit
de70999975
3 files changed
+10
No files matched your search
@@ -14,6 +14,7 @@ namespace OpenNest.Engine.BestFit
|
||||
public bool Keep { get; set; }
|
||||
public string Reason { get; set; }
|
||||
public double TrueArea { get; set; }
|
||||
public List<double> HullAngles { get; set; }
|
||||
|
||||
public double Utilization
|
||||
{
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace OpenNest.Engine.BestFit
|
||||
|
||||
// Find optimal bounding rectangle via rotating calipers
|
||||
double bestArea, bestWidth, bestHeight, bestRotation;
|
||||
List<double> hullAngles = null;
|
||||
|
||||
if (allPoints.Count >= 3)
|
||||
{
|
||||
@@ -51,6 +52,7 @@ namespace OpenNest.Engine.BestFit
|
||||
bestWidth = result.Width;
|
||||
bestHeight = result.Height;
|
||||
bestRotation = result.Angle;
|
||||
hullAngles = RotationAnalysis.GetHullEdgeAngles(hull);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -59,6 +61,7 @@ namespace OpenNest.Engine.BestFit
|
||||
bestWidth = combinedBox.Width;
|
||||
bestHeight = combinedBox.Length;
|
||||
bestRotation = 0;
|
||||
hullAngles = new List<double> { 0 };
|
||||
}
|
||||
|
||||
var trueArea = drawing.Area * 2;
|
||||
@@ -71,6 +74,7 @@ namespace OpenNest.Engine.BestFit
|
||||
BoundingHeight = bestHeight,
|
||||
OptimalRotation = bestRotation,
|
||||
TrueArea = trueArea,
|
||||
HullAngles = hullAngles,
|
||||
Keep = !overlaps,
|
||||
Reason = overlaps ? "Overlap detected" : "Valid"
|
||||
};
|
||||
|
||||
@@ -80,6 +80,11 @@ namespace OpenNest
|
||||
return new List<double> { 0 };
|
||||
|
||||
var hull = ConvexHull.Compute(points);
|
||||
return GetHullEdgeAngles(hull);
|
||||
}
|
||||
|
||||
public static List<double> GetHullEdgeAngles(Polygon hull)
|
||||
{
|
||||
var vertices = hull.Vertices;
|
||||
var n = hull.IsClosed() ? vertices.Count - 1 : vertices.Count;
|
||||
|
||||
|
||||
Reference in new issue
Block a user