From b5763bba0ca364d921d710661628d67d3fc41471 Mon Sep 17 00:00:00 2001 From: Pawel Baran Date: Thu, 4 Jul 2024 13:22:27 +0200 Subject: [PATCH] BooleanDifference secured against single-dimensional regions --- Geometry_Engine/Compute/BooleanDifference.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Geometry_Engine/Compute/BooleanDifference.cs b/Geometry_Engine/Compute/BooleanDifference.cs index 815fd25a0..abaa38643 100644 --- a/Geometry_Engine/Compute/BooleanDifference.cs +++ b/Geometry_Engine/Compute/BooleanDifference.cs @@ -102,9 +102,13 @@ public static List BooleanDifference(this Polyline region, List allRegions = new List { region }; Plane p = region.FitPlane(); + if (p == null) + return new List(); + foreach (Polyline refRegion in refRegions) { - if (p.IsCoplanar(refRegion.FitPlane())) + Plane refPlane = refRegion.FitPlane(); + if (refPlane != null && p.IsCoplanar(refPlane)) allRegions.Add(refRegion); } @@ -268,9 +272,13 @@ public static List BooleanDifference(this ICurve region, IEnumerable< List allRegions = new List { region }; Plane p = region.IFitPlane(); + if (p == null) + return new List(); + foreach (ICurve refRegion in refRegionsList) { - if (p.IsCoplanar(refRegion.IFitPlane())) + Plane refPlane = refRegion.IFitPlane(); + if (refPlane != null && p.IsCoplanar(refPlane)) allRegions.Add(refRegion); }