mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-02 06:31:33 -05:00
refactor(engine): share the strip edge loops in IterativeShrinkFiller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
157b4a1017
commit
47497f4153
1 file changed
+22
-26
@@ -270,39 +270,35 @@ namespace OpenNest.Engine.Fill
|
||||
parts.AddRange(s);
|
||||
}
|
||||
|
||||
private static double MaxTop(List<Part> col)
|
||||
private static double MaxTop(List<Part> col) => MaxEdge(col, static b => b.Top);
|
||||
|
||||
private static double MaxRight(List<Part> col) => MaxEdge(col, static b => b.Right);
|
||||
|
||||
private static double MinLeft(List<Part> col) => MinEdge(col, static b => b.Left);
|
||||
|
||||
private static double MinBottom(List<Part> row) => MinEdge(row, static b => b.Bottom);
|
||||
|
||||
private static double MaxEdge(List<Part> parts, Func<Box, double> edge)
|
||||
{
|
||||
var max = double.MinValue;
|
||||
foreach (var p in col)
|
||||
if (p.BoundingBox.Top > max)
|
||||
max = p.BoundingBox.Top;
|
||||
foreach (var p in parts)
|
||||
{
|
||||
var value = edge(p.BoundingBox);
|
||||
if (value > max)
|
||||
max = value;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
private static double MaxRight(List<Part> col)
|
||||
{
|
||||
var max = double.MinValue;
|
||||
foreach (var p in col)
|
||||
if (p.BoundingBox.Right > max)
|
||||
max = p.BoundingBox.Right;
|
||||
return max;
|
||||
}
|
||||
|
||||
private static double MinLeft(List<Part> col)
|
||||
private static double MinEdge(List<Part> parts, Func<Box, double> edge)
|
||||
{
|
||||
var min = double.MaxValue;
|
||||
foreach (var p in col)
|
||||
if (p.BoundingBox.Left < min)
|
||||
min = p.BoundingBox.Left;
|
||||
return min;
|
||||
}
|
||||
|
||||
private static double MinBottom(List<Part> row)
|
||||
{
|
||||
var min = double.MaxValue;
|
||||
foreach (var p in row)
|
||||
if (p.BoundingBox.Bottom < min)
|
||||
min = p.BoundingBox.Bottom;
|
||||
foreach (var p in parts)
|
||||
{
|
||||
var value = edge(p.BoundingBox);
|
||||
if (value < min)
|
||||
min = value;
|
||||
}
|
||||
return min;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user