fix(core): charge removal time only for removed clamps on the sheet

Plate.ClampRemovalMinutes multiplied every listed removed id by the
removal time, including ids the rail places beyond the sheet after a resize
or does not know at all. Only removed clamps the rail resolves on this sheet
are pulled, so only those add time; the ids themselves stay listed (C13).

PM 6ded8ac4-84fd-4e8b-9a3b-6f41e494542c item (a)
This commit is contained in:
aj committed 2026-10-13 18:15:50 -04:00
1 parent 04d538b0a4
commit 7ed40d4bb8
2 files changed
+20 -3

No files matched your search

+8 -3
View File
@@ -155,11 +155,16 @@ namespace OpenNest
/// <summary>
/// Minutes this sheet's cut-time estimate gains from <see cref="RemovedClamps"/> (D9):
/// each listed clamp adds <see cref="OpenNest.ClampRail.RemovalMinutes"/> once. Zero
/// when there is no rail (removal is meaningless without one to remove clamps from).
/// each listed clamp the rail places on this sheet adds
/// <see cref="OpenNest.ClampRail.RemovalMinutes"/> once; a listed clamp that is beyond
/// the sheet (or unknown to the rail) is not pulled and costs nothing. Zero when there
/// is no rail (removal is meaningless without one to remove clamps from).
/// </summary>
public double ClampRemovalMinutes =>
ClampRail == null ? 0 : RemovedClamps.Count * ClampRail.RemovalMinutes;
ClampRail == null || RemovedClamps.Count == 0
? 0
: ClampRail.ResolveFor(Size, Quadrant).Count(zone => RemovedClamps.Contains(zone.Id))
* ClampRail.RemovalMinutes;
/// <summary>
/// Follows <paramref name="rail"/> and replaces the zones with its resolution for
+12
View File
@@ -370,4 +370,16 @@ public class ClampRailTests
Assert.False(Machine().Matches(plate, Array.Empty<string>()));
Assert.False(Machine().Matches(plate, new[] { "clamp-4" }));
}
// PM 6ded8ac4 (a): only removed clamps that are actually on this sheet cost time.
[Fact]
public void RemovalTimeCountsOnlyRemovedClampsOnTheSheet()
{
var plate = Sheet(48, 120);
plate.SetClampRail(Machine(), new[] { "clamp-3", "clamp-8", "clamp-99" });
Assert.Equal(2 * ClampRail.DefaultRemovalMinutes, plate.ClampRemovalMinutes); // 3 and 8
plate.Size = new Size(48, 60); // clamp-8 is now beyond the sheet
Assert.Equal(ClampRail.DefaultRemovalMinutes, plate.ClampRemovalMinutes);
Assert.Contains("clamp-8", plate.RemovedClamps); // still listed (C13)
}
}