fix(core): narrow the perimeter-build catch to geometry failures

BuildPartPerimeter swallowed every exception. It now guards a missing
program and an outline that forms no shape, and catches only geometry
failures; a null perimeter still makes a cut-off exclude the part's whole
bounding-box span.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Fable 5.2 committed 2026-11-12 19:10:26 -05:00
1 parent 32edc18ede
commit a451cf5ef3
2 files changed
+77 -2

No files matched your search

+10 -2
View File
@@ -664,6 +664,11 @@ namespace OpenNest
/// </summary>
public static Geometry.Entity BuildPartPerimeter(Part part)
{
// Null is the conservative answer: the cut-off then excludes the part's whole
// bounding-box span. Only malformed geometry earns it; anything else propagates.
if (part?.Program == null)
return null;
try
{
var entities = Converters
@@ -683,7 +688,10 @@ namespace OpenNest
e.Layer != SpecialLayers.Leadout).ToList();
if (outline.Count == 0)
return null;
var profile = new Geometry.ShapeProfile(outline);
var shapes = Geometry.ShapeBuilder.GetShapes(outline);
if (shapes.Count == 0)
return null;
var profile = Geometry.ShapeProfile.FromShapes(shapes);
if (profile.Perimeter.IsClosed())
{
@@ -700,7 +708,7 @@ namespace OpenNest
hull.Offset(part.Location);
return hull;
}
catch
catch (Exception e) when (Diagnostics.PlateOverlapAnalyzer.IsGeometryFailure(e))
{
return null;
}