refactor: clean up NestEngine — collapse overloads, extract helper, remove dead code
- Fill(NestItem) and Fill(List<Part>) now delegate to their Box overloads - Add Part.CreateAtOrigin() to replace repeated 4-line build-at-origin pattern used in NestEngine, RotationSlideStrategy, and PairEvaluator - Remove dead code: FillArea overloads, Fill(NestItem, int), FillWithPairs(NestItem), ConvertTileResultToParts, PackBottomLeft.FindPointHorizontal, Pattern.GetLines/GetOffsetLines, unused count variable in FillNoRotation - Simplify IsBetterValidFill to delegate to IsBetterFill after overlap check NestEngine reduced from 717 to 484 lines. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -103,6 +103,23 @@ namespace OpenNest
|
||||
BoundingBox.Offset(voffset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a part normalized to the origin with optional rotation.
|
||||
/// </summary>
|
||||
public static Part CreateAtOrigin(Drawing drawing, double rotation = 0)
|
||||
{
|
||||
var part = new Part(drawing);
|
||||
|
||||
if (!Math.Tolerance.IsEqualTo(rotation, 0))
|
||||
part.Rotate(rotation);
|
||||
|
||||
var bbox = part.Program.BoundingBox();
|
||||
part.Offset(-bbox.Location.X, -bbox.Location.Y);
|
||||
part.UpdateBounds();
|
||||
|
||||
return part;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the bounding box of the part.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user