From febeb76836b6b3e9d56be6dc1746ca31f45c1269 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Thu, 12 Nov 2026 19:03:57 -0500 Subject: [PATCH] refactor(core): remove unused Entity.MoveTo and point-based OffsetEntity Nothing called MoveTo on a geometry entity or the OffsetEntity(distance, point) overload. Shape and Arc threw NotImplementedException for them, and the Line and Polygon versions were wrong and untested. Remove the abstract declarations and every override; the OffsetSide overload stays. Co-Authored-By: Claude Fable 5.2 --- OpenNest.Core/Geometry/Arc.cs | 26 +--------------- OpenNest.Core/Geometry/Circle.cs | 35 +--------------------- OpenNest.Core/Geometry/Entity.cs | 21 ------------- OpenNest.Core/Geometry/Line.cs | 42 +------------------------- OpenNest.Core/Geometry/Polygon.cs | 49 ------------------------------- OpenNest.Core/Geometry/Shape.cs | 24 --------------- 6 files changed, 3 insertions(+), 194 deletions(-) diff --git a/OpenNest.Core/Geometry/Arc.cs b/OpenNest.Core/Geometry/Arc.cs index 7849b37b..98fb652c 100644 --- a/OpenNest.Core/Geometry/Arc.cs +++ b/OpenNest.Core/Geometry/Arc.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using OpenNest.Math; @@ -292,25 +292,6 @@ namespace OpenNest.Geometry Generic.Swap(ref startAngle, ref endAngle); } - /// - /// Moves the center point to the given coordinates. - /// - /// The x-coordinate - /// The y-coordinate - public override void MoveTo(double x, double y) - { - Center = new Vector(x, y); - } - - /// - /// Moves the center point to the given point. - /// - /// The new center point location. - public override void MoveTo(Vector pt) - { - Center = pt; - } - /// /// Offsets the center point by the given distances. /// @@ -462,11 +443,6 @@ namespace OpenNest.Geometry return new Arc(center, radius - distance, startAngle, endAngle, reversed); } - public override Entity OffsetEntity(double distance, Vector pt) - { - throw new NotImplementedException(); - } - /// /// Gets the closest point on the arc to the given point. /// diff --git a/OpenNest.Core/Geometry/Circle.cs b/OpenNest.Core/Geometry/Circle.cs index cf1c8e3b..fca8b494 100644 --- a/OpenNest.Core/Geometry/Circle.cs +++ b/OpenNest.Core/Geometry/Circle.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using OpenNest.Math; namespace OpenNest.Geometry @@ -180,25 +180,6 @@ namespace OpenNest.Geometry Rotation = RotationType.CCW; } - /// - /// Moves the center point to the given coordinates. - /// - /// - /// - public override void MoveTo(double x, double y) - { - Center = new Vector(x, y); - } - - /// - /// Moves the center point to the given point. - /// - /// - public override void MoveTo(Vector pt) - { - Center = pt; - } - /// /// Offsets the center point by the given distances. /// @@ -288,20 +269,6 @@ namespace OpenNest.Geometry } } - public override Entity OffsetEntity(double distance, Vector pt) - { - if (ContainsPoint(pt)) - { - return Radius <= distance - ? null - : new Circle(center, Radius - distance) { Layer = Layer, Rotation = Rotation }; - } - else - { - return new Circle(center, Radius + distance) { Layer = Layer }; - } - } - /// /// Gets the closest point on the circle to the specified point. /// diff --git a/OpenNest.Core/Geometry/Entity.cs b/OpenNest.Core/Geometry/Entity.cs index ea0ea531..57da0bc0 100644 --- a/OpenNest.Core/Geometry/Entity.cs +++ b/OpenNest.Core/Geometry/Entity.cs @@ -111,19 +111,6 @@ namespace OpenNest.Geometry /// public abstract void Reverse(); - /// - /// Moves the entity location to the given coordinates. - /// - /// - /// - public abstract void MoveTo(double x, double y); - - /// - /// Moves the entity location to the given point. - /// - /// - public abstract void MoveTo(Vector pt); - /// /// Offsets the entity location by the given distances. /// @@ -176,14 +163,6 @@ namespace OpenNest.Geometry /// public abstract Entity OffsetEntity(double distance, OffsetSide side); - /// - /// Gets a new entity offset the given distance from this entity. Offset side determined by point. - /// - /// - /// - /// - public abstract Entity OffsetEntity(double distance, Vector pt); - /// /// Gets the closest point on the entity to the given point. /// diff --git a/OpenNest.Core/Geometry/Line.cs b/OpenNest.Core/Geometry/Line.cs index 69372099..556ba9f2 100644 --- a/OpenNest.Core/Geometry/Line.cs +++ b/OpenNest.Core/Geometry/Line.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using OpenNest.Math; @@ -266,36 +266,6 @@ namespace OpenNest.Geometry Generic.Swap(ref pt1, ref pt2); } - /// - /// Moves the start point to the given coordinates. - /// - /// - /// - public override void MoveTo(double x, double y) - { - var xoffset = pt1.X - x; - var yoffset = pt1.Y - y; - - pt2.X += xoffset; - pt2.Y += yoffset; - pt1.X = x; - pt1.Y = y; - boundingBox.Offset(xoffset, yoffset); - } - - /// - /// Moves the start point to the given point. - /// - /// - public override void MoveTo(Vector pt) - { - var offset = pt1 - pt; - - pt2 += offset; - pt1 = pt; - boundingBox.Offset(offset); - } - /// /// Offsets the line location by the given distances. /// @@ -403,16 +373,6 @@ namespace OpenNest.Geometry return new Line(StartPoint + pt, EndPoint + pt); } - public override Entity OffsetEntity(double distance, Vector pt) - { - var a = pt - StartPoint; - var b = EndPoint - StartPoint; - var c = a.DotProduct(b); - var side = c < 0 ? OffsetSide.Left : OffsetSide.Right; - - return OffsetEntity(distance, side); - } - /// /// Splits the line at the given point, returning two sub-lines. /// Either half may be null if the split point coincides with an endpoint. diff --git a/OpenNest.Core/Geometry/Polygon.cs b/OpenNest.Core/Geometry/Polygon.cs index 0a2475f3..62fbab38 100644 --- a/OpenNest.Core/Geometry/Polygon.cs +++ b/OpenNest.Core/Geometry/Polygon.cs @@ -185,39 +185,6 @@ namespace OpenNest.Geometry Vertices.Reverse(); } - /// - /// Moves the start point to the given coordinates. - /// - /// - /// - public override void MoveTo(double x, double y) - { - if (Vertices.Count == 0) - return; - - var first = Vertices[0]; - var offset = new Vector(x - first.X, y - first.Y); - - Vertices.ForEach(vertex => vertex += offset); - boundingBox.Offset(offset); - } - - /// - /// Moves the start point to the given point. - /// - /// - public override void MoveTo(Vector pt) - { - if (Vertices.Count == 0) - return; - - var first = Vertices[0]; - var offset = pt - first; - - Vertices.ForEach(vertex => vertex += offset); - boundingBox.Offset(offset); - } - /// /// Offsets the location by the given distances. /// @@ -354,22 +321,6 @@ namespace OpenNest.Geometry return result; } - public override Entity OffsetEntity(double distance, Vector pt) - { - var left = OffsetEntity(distance, OffsetSide.Left); - var right = OffsetEntity(distance, OffsetSide.Right); - - if (left == null) - return right; - if (right == null) - return left; - - var distLeft = left.ClosestPointTo(pt).DistanceTo(pt); - var distRight = right.ClosestPointTo(pt).DistanceTo(pt); - - return distLeft > distRight ? left : right; - } - /// /// Gets the closest point on the polygon to the given point. /// diff --git a/OpenNest.Core/Geometry/Shape.cs b/OpenNest.Core/Geometry/Shape.cs index 2f028f8d..dd2059ee 100644 --- a/OpenNest.Core/Geometry/Shape.cs +++ b/OpenNest.Core/Geometry/Shape.cs @@ -388,25 +388,6 @@ namespace OpenNest.Geometry get { return Entities.Sum(geo => geo.Length); } } - /// - /// Moves the start point to the given coordinates. - /// - /// - /// - public override void MoveTo(double x, double y) - { - throw new NotImplementedException(); - } - - /// - /// Moves the start point to the given point. - /// - /// - public override void MoveTo(Vector pt) - { - throw new NotImplementedException(); - } - /// /// Offsets the shape location by the given distances. /// @@ -721,11 +702,6 @@ namespace OpenNest.Geometry } } - public override Entity OffsetEntity(double distance, Vector pt) - { - throw new NotImplementedException(); - } - /// /// Offsets the shape outward by the given distance. /// Normalizes to CW winding before offsetting Left (which is outward for CW),