mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-14 19:31:55 -04:00
fix(io): write an empty sheet whose rail differs only in removal time
The writer's sentinel rule compared zones only, so an empty sheet following a rail that differs from the default only in clamp removal minutes was dropped on save although ChangePlateDefaults treats it as configured stock. The rule now also requires the sheet to follow the default rail itself. PM 1469b4e0-dc59-416b-8118-560b726aa1e1
This commit is contained in:
1 parent
9df9a802cd
commit
07cba5719f
2 files changed
+19
-1
No files matched your search
@@ -470,6 +470,22 @@ public class ClampRailPersistenceTests
|
||||
Assert.Equal(edge, kept.EdgeSpacing.Left);
|
||||
}
|
||||
|
||||
// Delta review: a sheet whose rail differs from the defaults only in removal time is
|
||||
// configured stock too (ChangePlateDefaults leaves it alone) and must be written.
|
||||
[Fact]
|
||||
public void EmptySheetOnARailWithOtherRemovalTimeIsKept()
|
||||
{
|
||||
var nest = new Nest("railed");
|
||||
nest.PlateDefaults.Size = new Size(48, 96);
|
||||
nest.SetClampRail(Machine());
|
||||
var plate = nest.CreatePlate();
|
||||
plate.SetClampRail(new ClampRail(1.5, 0.625, MachineCenters, removalMinutes: 7));
|
||||
|
||||
var kept = Assert.Single(RoundTrip(nest).Plates);
|
||||
|
||||
Assert.Equal(7, kept.ClampRail.RemovalMinutes);
|
||||
}
|
||||
|
||||
/// <summary>Removes a named property wherever it appears in the document, simulating a
|
||||
/// key an older writer never emitted. Rebuilds via <see cref="JsonNode"/> so the result
|
||||
/// is always valid JSON regardless of whether the property was first, last or only one
|
||||
|
||||
@@ -201,7 +201,8 @@ namespace OpenNest.IO
|
||||
/// <summary>
|
||||
/// True when a plate created from the saved defaults would be this sheet's clamp
|
||||
/// configuration: same size, quadrant, edge and part spacing, no last-resort
|
||||
/// removal, and zones the saved rail recreates (C17: anything else is configured
|
||||
/// removal, not following another rail (removal time included), and zones the
|
||||
/// saved rail recreates (C17: anything else is configured
|
||||
/// stock and is written).
|
||||
/// </summary>
|
||||
private bool DefaultsRecreateClamps(Plate plate)
|
||||
@@ -217,6 +218,7 @@ namespace OpenNest.IO
|
||||
&& plate.EdgeSpacing.Bottom == defaults.EdgeSpacing.Bottom
|
||||
&& plate.EdgeSpacing.Right == defaults.EdgeSpacing.Right
|
||||
&& plate.EdgeSpacing.Top == defaults.EdgeSpacing.Top
|
||||
&& (plate.ClampRail == null || Equals(plate.ClampRail, rail))
|
||||
&& rail.Matches(plate);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user