refactor(PepLib.Core): reorganize files into logical folder structure
Move 38 files from root directory into organized subfolders: - Enums/ (7 files): StatusType, ApplicationType, DrawingType, etc. - Geometry/ (5 files): Vector, Box, Size, Spacing, Node - Models/ (15 files): Nest, Plate, Part, Program, Report, etc. - Utilities/ (7 files): MathHelper, Tolerance, ZipHelper, etc. - Extensions/ (2 files): PartListExtensions, PlateListExtensions - Interfaces/ (1 file): IMovable Update namespaces to follow folder hierarchy (e.g., PepLib.Models). Add GlobalUsings.cs for internal backward compatibility. Update Codes/ and IO/ files with new using statements. Update PepApi.Core consumers to reference new namespaces. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
40
PepLib.Core/Extensions/PartListExtensions.cs
Normal file
40
PepLib.Core/Extensions/PartListExtensions.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using PepLib.Geometry;
|
||||
using PepLib.Models;
|
||||
|
||||
namespace PepLib.Extensions
|
||||
{
|
||||
public static class PartListExtensions
|
||||
{
|
||||
public static Box GetBoundingBox(this List<Part> parts)
|
||||
{
|
||||
if (parts.Count == 0)
|
||||
return new Box();
|
||||
|
||||
var firstpart = parts[0];
|
||||
|
||||
double minX = firstpart.BoundingBox.X;
|
||||
double minY = firstpart.BoundingBox.Y;
|
||||
double maxX = firstpart.BoundingBox.X + firstpart.BoundingBox.Width;
|
||||
double maxY = firstpart.BoundingBox.Y + firstpart.BoundingBox.Height;
|
||||
|
||||
foreach (var part in parts)
|
||||
{
|
||||
var box = part.BoundingBox;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
41
PepLib.Core/Extensions/PlateListExtensions.cs
Normal file
41
PepLib.Core/Extensions/PlateListExtensions.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using PepLib.Models;
|
||||
|
||||
namespace PepLib.Extensions
|
||||
{
|
||||
public static class PlateListExtensions
|
||||
{
|
||||
public static void JoinLikePlates(this List<Report.Plate> plates)
|
||||
{
|
||||
START:
|
||||
|
||||
for (int i = 0; i < plates.Count; ++i)
|
||||
{
|
||||
var p1 = plates[i];
|
||||
|
||||
for (int j = 0; j < plates.Count; ++j)
|
||||
{
|
||||
var p2 = plates[j];
|
||||
|
||||
if (i == j)
|
||||
continue;
|
||||
|
||||
if (p1.Width != p2.Width)
|
||||
continue;
|
||||
|
||||
if (p1.Length != p2.Length)
|
||||
continue;
|
||||
|
||||
if (p1.MaterialDescription != p2.MaterialDescription)
|
||||
continue;
|
||||
|
||||
if (p1.Thickness != p2.Thickness)
|
||||
continue;
|
||||
|
||||
p1.Quantity += p2.Quantity;
|
||||
plates.Remove(p2);
|
||||
goto START;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user