fix(cutting): keep clamp zones on cutting-plan previews

Plan Cutting previews were built without the plate's clamp zones, so
machine clamps disappeared from the canvas while inspecting a proposal.
Copy the plate's immutable zones onto the detached preview; it does not
follow the rail, so it never re-resolves.

Review finding 8, Project Memory 4e5f566d.
This commit is contained in:
aj committed 2026-10-13 18:15:49 -04:00
1 parent 1e37c661ff
commit fe7083f4c4
2 files changed
+25

No files matched your search

@@ -336,6 +336,9 @@ public sealed class CuttingPlanProposal
PartSpacing = source.PartSpacing,
EdgeSpacing = source.EdgeSpacing,
};
// Machine clamps stay visible while inspecting the proposal; zones are immutable.
foreach (var zone in source.ClampZones)
preview.ClampZones.Add(zone);
foreach (var proposal in planned.Result.ProposedOrder)
{
var part = (Part)proposal.SourcePart.Clone();
@@ -0,0 +1,22 @@
using OpenNest.Engine.CuttingPlanning;
namespace OpenNest.Tests.CuttingPlanning;
/// <summary>Machine clamps stay visible on a cutting-plan preview of a clamped plate.</summary>
public class ClampZonePreviewTests
{
[Fact]
public void PreviewCarriesThePlatesClampZones()
{
var plate = BestEffortCuttingPlanTests.Plate(BestEffortCuttingPlanTests.TouchingContours());
plate.SetClampRail(new ClampRail(1.5, 0.625, new[] { 6.0, 21 }));
var proposal = CuttingPlanBatch.Capture([plate], ExplicitContourTests.Parameters(), false).Plan();
var preview = proposal.BuildPreview(0);
Assert.NotNull(preview);
Assert.Equal(plate.ClampZones, preview.ClampZones); // same immutable zones, same order
Assert.Equal(2, preview.ClampZones.Count);
Assert.Null(preview.ClampRail); // a detached display copy never re-resolves
}
}