All 132 OpenNest.Engine source files now declare namespaces matching their nested directories: Jobs/, Jobs/Placement/, Jobs/Adapters/, Fill/, RectanglePacking/, CirclePacking/, and engine-root types moved from 'OpenNest' to 'OpenNest.Engine'. RootNamespace updated accordingly. Consumers (Api, Console, Mcp, Benchmark, Training, desktop app, tests) gained the explicit usings the move requires; CLAUDE.md updated.
43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using OpenNest.Math;
|
|
|
|
namespace OpenNest.Engine.Fill
|
|
{
|
|
internal record CombinationResult(bool Found, int Count1, int Count2);
|
|
|
|
internal static class BestCombination
|
|
{
|
|
public static CombinationResult FindFrom2(
|
|
double length1,
|
|
double length2,
|
|
double overallLength
|
|
)
|
|
{
|
|
overallLength += Tolerance.Epsilon;
|
|
var count1 = 0;
|
|
var count2 = 0;
|
|
|
|
var maxCount1 = (int)System.Math.Floor(overallLength / length1);
|
|
var bestRemnant = overallLength + 1;
|
|
|
|
for (var c1 = 0; c1 <= maxCount1; c1++)
|
|
{
|
|
var remaining = overallLength - c1 * length1;
|
|
var c2 = (int)System.Math.Floor(remaining / length2);
|
|
var remnant = remaining - c2 * length2;
|
|
|
|
if (!(remnant < bestRemnant))
|
|
continue;
|
|
|
|
count1 = c1;
|
|
count2 = c2;
|
|
bestRemnant = remnant;
|
|
|
|
if (remnant.IsEqualTo(0))
|
|
break;
|
|
}
|
|
|
|
return new CombinationResult(count1 > 0 || count2 > 0, count1, count2);
|
|
}
|
|
}
|
|
}
|