mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-15 08:55:37 -05:00
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
c8e1b97786
commit
febeb76836
6 files changed
+3
-194
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the center point to the given coordinates.
|
||||
/// </summary>
|
||||
/// <param name="x">The x-coordinate</param>
|
||||
/// <param name="y">The y-coordinate</param>
|
||||
public override void MoveTo(double x, double y)
|
||||
{
|
||||
Center = new Vector(x, y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the center point to the given point.
|
||||
/// </summary>
|
||||
/// <param name="pt">The new center point location.</param>
|
||||
public override void MoveTo(Vector pt)
|
||||
{
|
||||
Center = pt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Offsets the center point by the given distances.
|
||||
/// </summary>
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the closest point on the arc to the given point.
|
||||
/// </summary>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the center point to the given coordinates.
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
public override void MoveTo(double x, double y)
|
||||
{
|
||||
Center = new Vector(x, y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the center point to the given point.
|
||||
/// </summary>
|
||||
/// <param name="pt"></param>
|
||||
public override void MoveTo(Vector pt)
|
||||
{
|
||||
Center = pt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Offsets the center point by the given distances.
|
||||
/// </summary>
|
||||
@@ -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 };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the closest point on the circle to the specified point.
|
||||
/// </summary>
|
||||
|
||||
@@ -111,19 +111,6 @@ namespace OpenNest.Geometry
|
||||
/// </summary>
|
||||
public abstract void Reverse();
|
||||
|
||||
/// <summary>
|
||||
/// Moves the entity location to the given coordinates.
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
public abstract void MoveTo(double x, double y);
|
||||
|
||||
/// <summary>
|
||||
/// Moves the entity location to the given point.
|
||||
/// </summary>
|
||||
/// <param name="pt"></param>
|
||||
public abstract void MoveTo(Vector pt);
|
||||
|
||||
/// <summary>
|
||||
/// Offsets the entity location by the given distances.
|
||||
/// </summary>
|
||||
@@ -176,14 +163,6 @@ namespace OpenNest.Geometry
|
||||
/// <returns></returns>
|
||||
public abstract Entity OffsetEntity(double distance, OffsetSide side);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a new entity offset the given distance from this entity. Offset side determined by point.
|
||||
/// </summary>
|
||||
/// <param name="distance"></param>
|
||||
/// <param name="pt"></param>
|
||||
/// <returns></returns>
|
||||
public abstract Entity OffsetEntity(double distance, Vector pt);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the closest point on the entity to the given point.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenNest.Math;
|
||||
|
||||
@@ -266,36 +266,6 @@ namespace OpenNest.Geometry
|
||||
Generic.Swap<Vector>(ref pt1, ref pt2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the start point to the given coordinates.
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the start point to the given point.
|
||||
/// </summary>
|
||||
/// <param name="pt"></param>
|
||||
public override void MoveTo(Vector pt)
|
||||
{
|
||||
var offset = pt1 - pt;
|
||||
|
||||
pt2 += offset;
|
||||
pt1 = pt;
|
||||
boundingBox.Offset(offset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Offsets the line location by the given distances.
|
||||
/// </summary>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Splits the line at the given point, returning two sub-lines.
|
||||
/// Either half may be null if the split point coincides with an endpoint.
|
||||
|
||||
@@ -185,39 +185,6 @@ namespace OpenNest.Geometry
|
||||
Vertices.Reverse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the start point to the given coordinates.
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the start point to the given point.
|
||||
/// </summary>
|
||||
/// <param name="pt"></param>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Offsets the location by the given distances.
|
||||
/// </summary>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the closest point on the polygon to the given point.
|
||||
/// </summary>
|
||||
|
||||
@@ -388,25 +388,6 @@ namespace OpenNest.Geometry
|
||||
get { return Entities.Sum(geo => geo.Length); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the start point to the given coordinates.
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
public override void MoveTo(double x, double y)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the start point to the given point.
|
||||
/// </summary>
|
||||
/// <param name="pt"></param>
|
||||
public override void MoveTo(Vector pt)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Offsets the shape location by the given distances.
|
||||
/// </summary>
|
||||
@@ -721,11 +702,6 @@ namespace OpenNest.Geometry
|
||||
}
|
||||
}
|
||||
|
||||
public override Entity OffsetEntity(double distance, Vector pt)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Offsets the shape outward by the given distance.
|
||||
/// Normalizes to CW winding before offsetting Left (which is outward for CW),
|
||||
|
||||
Reference in new issue
Block a user