diff --git a/OpenNest.Engine/BestFit/BestFitResult.cs b/OpenNest.Engine/BestFit/BestFitResult.cs index 169f478..97ce07c 100644 --- a/OpenNest.Engine/BestFit/BestFitResult.cs +++ b/OpenNest.Engine/BestFit/BestFitResult.cs @@ -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 HullAngles { get; set; } public double Utilization { diff --git a/OpenNest.Engine/BestFit/PairEvaluator.cs b/OpenNest.Engine/BestFit/PairEvaluator.cs index 5224820..bffc7c6 100644 --- a/OpenNest.Engine/BestFit/PairEvaluator.cs +++ b/OpenNest.Engine/BestFit/PairEvaluator.cs @@ -42,6 +42,7 @@ namespace OpenNest.Engine.BestFit // Find optimal bounding rectangle via rotating calipers double bestArea, bestWidth, bestHeight, bestRotation; + List 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 { 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" }; diff --git a/OpenNest.Engine/RotationAnalysis.cs b/OpenNest.Engine/RotationAnalysis.cs index 65dac9d..8aa7aa5 100644 --- a/OpenNest.Engine/RotationAnalysis.cs +++ b/OpenNest.Engine/RotationAnalysis.cs @@ -80,6 +80,11 @@ namespace OpenNest return new List { 0 }; var hull = ConvexHull.Compute(points); + return GetHullEdgeAngles(hull); + } + + public static List GetHullEdgeAngles(Polygon hull) + { var vertices = hull.Vertices; var n = hull.IsClosed() ? vertices.Count - 1 : vertices.Count;