Files
PepApi.Core/PepLib.Core/Models/Part.cs
AJ Isaacs 9088af52de 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>
2026-01-23 09:29:13 -05:00

128 lines
3.1 KiB
C#

using PepLib.Enums;
using PepLib.Geometry;
using PepLib.Interfaces;
namespace PepLib.Models
{
public class Part : IMovable
{
private Loop baseLoop;
private Vector location;
private Part()
{
BoundingBox = new Box();
}
public Box BoundingBox { get; protected set; }
public Vector Location
{
get { return location; }
set
{
BoundingBox.Offset(value - location);
location = value;
}
}
public string Name
{
get { return baseLoop.Name; }
set { baseLoop.Name = value; }
}
/// <summary>
/// Reference point relative to the part location.
/// </summary>
public Vector ReferencePoint
{
get { return baseLoop.ReferencePoint; }
set { baseLoop.ReferencePoint = value; }
}
/// <summary>
/// Reference point relative to the zero point.
/// </summary>
public Vector AbsoluteReferencePoint
{
get { return baseLoop.ReferencePoint + location; }
set { baseLoop.ReferencePoint = value - location; }
}
public DateTime LastReferenceDate
{
get { return baseLoop.LastReferenceDate; }
set { baseLoop.LastReferenceDate = value; }
}
public string DrawingName
{
get { return baseLoop.DrawingName; }
set { baseLoop.DrawingName = value; }
}
public string DxfPath
{
get { return baseLoop.DxfPath; }
set { baseLoop.DxfPath = value; }
}
public double Rotation
{
get { return baseLoop.Rotation; }
}
public bool IsDisplayOnly { get; set; } = false;
public void Rotate(double angle)
{
baseLoop.Rotate(angle);
location = Location.Rotate(angle);
UpdateBounds();
}
public void Rotate(double angle, Vector origin)
{
baseLoop.Rotate(angle);
location = Location.Rotate(angle, origin);
UpdateBounds();
}
public void Offset(double x, double y)
{
location = new Vector(location.X + x, location.Y + y);
BoundingBox.Offset(x, y);
}
public void Offset(Vector voffset)
{
location += voffset;
BoundingBox.Offset(voffset);
}
public Program Program
{
get { return baseLoop; }
}
public void UpdateBounds()
{
BoundingBox = baseLoop.GetBoundingBox();
BoundingBox.Offset(Location);
}
public static Part Create(Loop loop, Vector location, double rotation = 0.0)
{
var part = new Part();
part.baseLoop = (Loop)loop.Clone();
part.baseLoop.Mode = ProgrammingMode.Incremental;
part.baseLoop.Rotate(rotation);
part.Location = location;
part.UpdateBounds();
return part;
}
}
}