feat: wire contour re-indexing into ContourCuttingStrategy.Apply()
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -36,9 +36,9 @@ namespace OpenNest.CNC.CuttingStrategy
|
|||||||
var leadOut = SelectLeadOut(contourType);
|
var leadOut = SelectLeadOut(contourType);
|
||||||
|
|
||||||
result.Codes.AddRange(leadIn.Generate(closestPt, normal, winding));
|
result.Codes.AddRange(leadIn.Generate(closestPt, normal, winding));
|
||||||
// Contour re-indexing: split shape entities at closestPt so cutting
|
var reindexed = cutout.ReindexAt(closestPt, entity);
|
||||||
// starts there, convert to ICode, and add to result.Codes
|
result.Codes.AddRange(ConvertShapeToMoves(reindexed, closestPt));
|
||||||
throw new System.NotImplementedException("Contour re-indexing not yet implemented");
|
// TODO: MicrotabLeadOut — trim last cutting move by GapSize
|
||||||
result.Codes.AddRange(leadOut.Generate(closestPt, normal, winding));
|
result.Codes.AddRange(leadOut.Generate(closestPt, normal, winding));
|
||||||
|
|
||||||
currentPoint = closestPt;
|
currentPoint = closestPt;
|
||||||
@@ -54,7 +54,9 @@ namespace OpenNest.CNC.CuttingStrategy
|
|||||||
var leadOut = SelectLeadOut(ContourType.External);
|
var leadOut = SelectLeadOut(ContourType.External);
|
||||||
|
|
||||||
result.Codes.AddRange(leadIn.Generate(perimeterPt, normal, winding));
|
result.Codes.AddRange(leadIn.Generate(perimeterPt, normal, winding));
|
||||||
throw new System.NotImplementedException("Contour re-indexing not yet implemented");
|
var reindexed = profile.Perimeter.ReindexAt(perimeterPt, perimeterEntity);
|
||||||
|
result.Codes.AddRange(ConvertShapeToMoves(reindexed, perimeterPt));
|
||||||
|
// TODO: MicrotabLeadOut — trim last cutting move by GapSize
|
||||||
result.Codes.AddRange(leadOut.Generate(perimeterPt, normal, winding));
|
result.Codes.AddRange(leadOut.Generate(perimeterPt, normal, winding));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,5 +175,32 @@ namespace OpenNest.CNC.CuttingStrategy
|
|||||||
_ => Parameters.ExternalLeadOut
|
_ => Parameters.ExternalLeadOut
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<ICode> ConvertShapeToMoves(Shape shape, Vector startPoint)
|
||||||
|
{
|
||||||
|
var moves = new List<ICode>();
|
||||||
|
|
||||||
|
foreach (var entity in shape.Entities)
|
||||||
|
{
|
||||||
|
if (entity is Line line)
|
||||||
|
{
|
||||||
|
moves.Add(new LinearMove(line.EndPoint));
|
||||||
|
}
|
||||||
|
else if (entity is Arc arc)
|
||||||
|
{
|
||||||
|
moves.Add(new ArcMove(arc.EndPoint(), arc.Center, arc.IsReversed ? RotationType.CW : RotationType.CCW));
|
||||||
|
}
|
||||||
|
else if (entity is Circle circle)
|
||||||
|
{
|
||||||
|
moves.Add(new ArcMove(startPoint, circle.Center, circle.Rotation));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new System.InvalidOperationException($"Unsupported entity type: {entity.Type}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return moves;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user