fix(engine): prevent FillExtents overlap and add strategy filter API
FillExtents vertical copy distance was not clamped, allowing rows to be placed overlapping each other when slide calculations returned large values. Clamp to pairHeight + partSpacing minimum, matching FillLinear. Also add FillStrategyRegistry.SetEnabled() to restrict which strategies run — useful for isolating individual strategies during troubleshooting. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -172,18 +172,12 @@ namespace OpenNest.Engine.Fill
|
||||
if (minSlide >= double.MaxValue || minSlide < 0)
|
||||
return pairHeight + partSpacing;
|
||||
|
||||
// Boundaries are inflated by halfSpacing, so when inflated edges touch
|
||||
// the actual parts have partSpacing gap. Match FillLinear's pattern:
|
||||
// startOffset = pairHeight (no extra spacing), copyDist = height - slide.
|
||||
// Match FillLinear.ComputeCopyDistance: copyDist = startOffset - slide,
|
||||
// clamped so it never goes below pairHeight + partSpacing to prevent
|
||||
// bounding-box overlap from spurious slide values.
|
||||
var copyDist = pairHeight - minSlide;
|
||||
|
||||
// Boundaries are inflated by halfSpacing, so the geometry-aware
|
||||
// distance already guarantees partSpacing gap. Only fall back to
|
||||
// bounding-box distance if the calculation produced a non-positive value.
|
||||
if (copyDist <= Tolerance.Epsilon)
|
||||
return pairHeight + partSpacing;
|
||||
|
||||
return copyDist;
|
||||
return System.Math.Max(copyDist, pairHeight + partSpacing);
|
||||
}
|
||||
|
||||
private static double SlideDistance(
|
||||
|
||||
Reference in New Issue
Block a user