fix(core): stop Part.Clone from double-counting baked drawing rotation

Part.Clone() rebuilt the clone from BaseDrawing and then re-applied the
part's absolute Rotation on top of it. Since BaseDrawing.Program.Rotation
is itself absolute (baked in), this double-counted it whenever the base
drawing already carried a nonzero rotation, silently corrupting the
clone's orientation while its Location stayed unchanged.

This only manifests for drawings needing canonical-frame axis correction
(nonzero Source.Angle), since DefaultPlateFiller wraps every drawing in a
rotated canonical copy before running any fill strategy. FillHelpers.
BuildRotatedPattern clones parts before tiling, so any strategy that
tiles interlocking pairs (Pairs, Strip/Remnant, Column/Row) could produce
overlapping placements for such drawings.

Fix: clone the already-composed Program directly instead of re-deriving
rotation from BaseDrawing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
aj
2026-09-22 10:46:11 -04:00
co-authored by Claude Sonnet 5
parent da1f8120f1
commit 014c071716
+12 -3
View File
@@ -294,9 +294,18 @@ namespace OpenNest
/// <returns></returns>
public object Clone()
{
var part = new Part(BaseDrawing);
part.Rotate(Rotation);
part.Location = Location;
// Clone the current Program directly rather than rebuilding from BaseDrawing and
// re-rotating by the absolute Rotation: when BaseDrawing.Program.Rotation is nonzero
// (e.g. a canonical-frame copy used internally during fill), `new Part(BaseDrawing)`
// already carries that baked rotation, so re-applying the full absolute Rotation on
// top of it double-counts the baseline and corrupts the clone's orientation.
var part = new Part(
BaseDrawing,
(Program)Program.Clone(),
Location,
new Box(BoundingBox.X, BoundingBox.Y, BoundingBox.Length, BoundingBox.Width)
);
part.ownsProgram = true;
return part;
}