Restructure project layout to flatten directory structure
Move all projects from Source/ to repository root for simpler navigation. - Remove External/ dependency DLLs (will use NuGet packages) - Remove Installer/ NSIS script - Replace PartCollection/PlateCollection with ObservableList - Add packages.config for NuGet dependencies 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
52
OpenNest.Engine/RectanglePacking/Item.cs
Normal file
52
OpenNest.Engine/RectanglePacking/Item.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenNest.RectanglePacking
|
||||
{
|
||||
internal class Item : Box
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public bool IsRotated { get; private set; }
|
||||
|
||||
public void Rotate()
|
||||
{
|
||||
Generic.Swap(ref Size.Width, ref Size.Height);
|
||||
IsRotated = !IsRotated;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new Item
|
||||
{
|
||||
IsRotated = this.IsRotated,
|
||||
Location = this.Location,
|
||||
Size = this.Size,
|
||||
Id = this.Id
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
internal static class ItemListExtensions
|
||||
{
|
||||
public static Box GetBoundingBox(this IList<Item> items)
|
||||
{
|
||||
if (items.Count == 0)
|
||||
return Box.Empty;
|
||||
|
||||
double minX = items[0].X;
|
||||
double minY = items[0].Y;
|
||||
double maxX = items[0].X + items[0].Width;
|
||||
double maxY = items[0].Y + items[0].Height;
|
||||
|
||||
foreach (var box in items)
|
||||
{
|
||||
if (box.Left < minX) minX = box.Left;
|
||||
if (box.Right > maxX) maxX = box.Right;
|
||||
if (box.Bottom < minY) minY = box.Bottom;
|
||||
if (box.Top > maxY) maxY = box.Top;
|
||||
}
|
||||
|
||||
return new Box(minX, minY, maxX - minX, maxY - minY);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user