fix(engine): fix FillExtents competition and vertical gap bugs
- FillExtents.Fill reported progress internally which overwrote the UI's temporary parts even when a better result (e.g. Pairs with 70 parts) won the competition. Added final ReportProgress call in FindBestFill and Fill(groupParts) to ensure the UI always shows the actual winner. - FillExtents vertical copy distance clamp (Math.Max with pairHeight + spacing) prevented geometry-aware compaction from ever occurring, causing visible gaps between rows. Boundaries are already inflated by halfSpacing so the calculated distance is correct; only fall back to bounding-box distance on non-positive results. - PairFiller now sets RemainderPatterns on FillLinear so remainder strips get pair-based filling instead of only individual parts (+1 part in tight layouts). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -176,6 +176,13 @@ namespace OpenNest
|
||||
}
|
||||
}
|
||||
|
||||
// Always report the final winner so the UI's temporary parts
|
||||
// match the returned result.
|
||||
var winPhase = PhaseResults.Count > 0
|
||||
? PhaseResults.OrderByDescending(r => r.PartCount).First().Phase
|
||||
: NestPhase.Linear;
|
||||
ReportProgress(progress, winPhase, PlateNumber, best, workArea, BuildProgressSummary());
|
||||
|
||||
return best ?? new List<Part>();
|
||||
}
|
||||
|
||||
@@ -320,6 +327,11 @@ namespace OpenNest
|
||||
Debug.WriteLine("[FindBestFill] Cancelled, returning current best");
|
||||
}
|
||||
|
||||
// Always report the final winner so the UI's temporary parts
|
||||
// match the returned result (sub-phases may have reported their
|
||||
// own intermediate results via progress).
|
||||
ReportProgress(progress, WinnerPhase, PlateNumber, best, workArea, BuildProgressSummary());
|
||||
|
||||
return best ?? new List<Part>();
|
||||
}
|
||||
|
||||
|
||||
@@ -177,9 +177,13 @@ namespace OpenNest
|
||||
// startOffset = pairHeight (no extra spacing), copyDist = height - slide.
|
||||
var copyDist = pairHeight - minSlide;
|
||||
|
||||
// Clamp: never let geometry quirks produce a distance smaller than
|
||||
// the bounding box height (which would overlap).
|
||||
return System.Math.Max(copyDist, pairHeight + partSpacing);
|
||||
// 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;
|
||||
}
|
||||
|
||||
private static double SlideDistance(
|
||||
|
||||
@@ -50,6 +50,12 @@ namespace OpenNest
|
||||
var pairParts = result.BuildParts(item.Drawing);
|
||||
var angles = result.HullAngles;
|
||||
var engine = new FillLinear(workArea, partSpacing);
|
||||
|
||||
// Let the remainder strip try pair-based filling too.
|
||||
var p0 = DefaultNestEngine.BuildRotatedPattern(pairParts, 0);
|
||||
var p90 = DefaultNestEngine.BuildRotatedPattern(pairParts, Angle.HalfPI);
|
||||
engine.RemainderPatterns = new List<Pattern> { p0, p90 };
|
||||
|
||||
var filled = DefaultNestEngine.FillPattern(engine, pairParts, angles, workArea);
|
||||
|
||||
if (filled != null && filled.Count > 0)
|
||||
|
||||
Reference in New Issue
Block a user