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.
37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
using System.Collections.Generic;
|
|
using OpenNest.Geometry;
|
|
|
|
namespace OpenNest.Engine.RapidPlanning
|
|
{
|
|
public class DirectRapidPlanner : IRapidPlanner
|
|
{
|
|
public RapidPath Plan(Vector from, Vector to, IReadOnlyList<Shape> cutAreas)
|
|
{
|
|
var travelLine = new Line(from, to);
|
|
|
|
foreach (var cutArea in cutAreas)
|
|
{
|
|
if (TravelLineIntersectsShape(travelLine, cutArea))
|
|
{
|
|
return new RapidPath { HeadUp = true, Waypoints = new List<Vector>() };
|
|
}
|
|
}
|
|
|
|
return new RapidPath { HeadUp = false, Waypoints = new List<Vector>() };
|
|
}
|
|
|
|
private static bool TravelLineIntersectsShape(Line travelLine, Shape shape)
|
|
{
|
|
foreach (var entity in shape.Entities)
|
|
{
|
|
if (entity is Line edge)
|
|
{
|
|
if (travelLine.Intersects(edge, out _))
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|