Repo-wide sweep with the pinned CSharpier 1.3.0 tool. Whitespace and line-wrapping only; OpenNest.Engine.Tests (109) and OpenNest.IO.Tests pass after reformat, full solution builds 0 errors. Added .csharpierignore so csproj/config XML keeps its existing layout (CSharpier's XML wrapping churns attributes with zero benefit). Formatting is now enforceable: dotnet csharpier check . passes.
101 lines
2.7 KiB
C#
101 lines
2.7 KiB
C#
using System.Collections.Generic;
|
|
using OpenNest.Geometry;
|
|
|
|
namespace OpenNest.CNC
|
|
{
|
|
public class ArcMove : Motion
|
|
{
|
|
public ArcMove() { }
|
|
|
|
public ArcMove(
|
|
double x,
|
|
double y,
|
|
double i,
|
|
double j,
|
|
RotationType rotation = RotationType.CCW
|
|
)
|
|
: this(new Vector(x, y), new Vector(i, j), rotation) { }
|
|
|
|
public ArcMove(
|
|
Vector endPoint,
|
|
Vector centerPoint,
|
|
RotationType rotation = RotationType.CCW
|
|
)
|
|
{
|
|
EndPoint = endPoint;
|
|
CenterPoint = centerPoint;
|
|
Rotation = rotation;
|
|
Layer = LayerType.Cut;
|
|
}
|
|
|
|
public LayerType Layer { get; set; }
|
|
|
|
public RotationType Rotation { get; set; }
|
|
|
|
public Vector CenterPoint { get; set; }
|
|
|
|
public double Radius
|
|
{
|
|
get { return CenterPoint.DistanceTo(EndPoint); }
|
|
}
|
|
|
|
public override void Rotate(double angle)
|
|
{
|
|
base.Rotate(angle);
|
|
CenterPoint = CenterPoint.Rotate(angle);
|
|
}
|
|
|
|
public override void Rotate(double angle, Vector origin)
|
|
{
|
|
base.Rotate(angle, origin);
|
|
CenterPoint = CenterPoint.Rotate(angle, origin);
|
|
}
|
|
|
|
public override void Offset(double x, double y)
|
|
{
|
|
base.Offset(x, y);
|
|
CenterPoint = new Vector(CenterPoint.X + x, CenterPoint.Y + y);
|
|
}
|
|
|
|
public override void Offset(Vector voffset)
|
|
{
|
|
base.Offset(voffset);
|
|
CenterPoint += voffset;
|
|
}
|
|
|
|
public override CodeType Type
|
|
{
|
|
get { return CodeType.ArcMove; }
|
|
}
|
|
|
|
public override ICode Clone()
|
|
{
|
|
return new ArcMove(EndPoint, CenterPoint, Rotation)
|
|
{
|
|
Layer = Layer,
|
|
Suppressed = Suppressed,
|
|
VariableRefs =
|
|
VariableRefs != null ? new Dictionary<string, string>(VariableRefs) : null,
|
|
};
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return ToString(DefaultDecimalPlaces);
|
|
}
|
|
|
|
public override string ToString(int decimalPlaces)
|
|
{
|
|
var dp = "N" + decimalPlaces;
|
|
var x = EndPoint.X.ToString(dp);
|
|
var y = EndPoint.Y.ToString(dp);
|
|
var i = CenterPoint.X.ToString(dp);
|
|
var j = CenterPoint.Y.ToString(dp);
|
|
|
|
return Rotation == RotationType.CW
|
|
? string.Format("G02 X{0} Y{1} I{2} J{3}", x, y, i, j)
|
|
: string.Format("G03 X{0} Y{1} I{2} J{3}", x, y, i, j);
|
|
}
|
|
}
|
|
}
|