feat: add reverse push directions for concave interlocking and cache best-fit results
Add PushDirection.Right and PushDirection.Up to RotationSlideStrategy so parts can approach from all four directions. This discovers concave interlocking arrangements (e.g. L-shaped parts nesting into each other's cavities) that the original Left/Down-only slides could never reach. Introduce BestFitCache so best-fit results are computed once at step size 0.25 and shared between the viewer and nesting engine. The GPU evaluator factory is configured once at startup instead of being wired per call site, and NestEngine.CreateEvaluator is removed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -35,6 +35,16 @@ namespace OpenNest.Engine.BestFit
|
||||
part1, part2Template, drawing, spacing, stepSize,
|
||||
PushDirection.Down, candidates, ref testNumber);
|
||||
|
||||
// Try pushing right (approach from left — finds concave interlocking)
|
||||
GenerateCandidatesForAxis(
|
||||
part1, part2Template, drawing, spacing, stepSize,
|
||||
PushDirection.Right, candidates, ref testNumber);
|
||||
|
||||
// Try pushing up (approach from below — finds concave interlocking)
|
||||
GenerateCandidatesForAxis(
|
||||
part1, part2Template, drawing, spacing, stepSize,
|
||||
PushDirection.Up, candidates, ref testNumber);
|
||||
|
||||
return candidates;
|
||||
}
|
||||
|
||||
@@ -77,11 +87,15 @@ namespace OpenNest.Engine.BestFit
|
||||
{
|
||||
var part2 = (Part)part2Template.Clone();
|
||||
|
||||
// Place part2 far away along push axis, at perpendicular offset
|
||||
// Place part2 far away along push axis, at perpendicular offset.
|
||||
// Left/Down: start on the positive side; Right/Up: start on the negative side.
|
||||
var isPositiveStart = pushDir == PushDirection.Left || pushDir == PushDirection.Down;
|
||||
var startPos = isPositiveStart ? pushStartOffset : -pushStartOffset;
|
||||
|
||||
if (isHorizontalPush)
|
||||
part2.Offset(pushStartOffset, offset);
|
||||
part2.Offset(startPos, offset);
|
||||
else
|
||||
part2.Offset(offset, pushStartOffset);
|
||||
part2.Offset(offset, startPos);
|
||||
|
||||
// Get part2's offset lines (half-spacing outward)
|
||||
var part2Lines = Helper.GetOffsetPartLines(part2, halfSpacing);
|
||||
|
||||
Reference in New Issue
Block a user