Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Fix M09 query compile and nullability issues

Yuechen Lif5417919cd17
diff --git a/Aetheris.Kernel.Core/Brep/BrepBodyQueries.cs b/Aetheris.Kernel.Core/Brep/BrepBodyQueries.cs
index 4b21764f..dcd9f585 100644
--- a/Aetheris.Kernel.Core/Brep/BrepBodyQueries.cs
+++ b/Aetheris.Kernel.Core/Brep/BrepBodyQueries.cs
@@ -19,7 +19,7 @@ public static class BrepBodyQueries
public static bool TryGetShellIds(this BrepBody body, BodyId bodyId, out IReadOnlyList<ShellId>? shellIds)
{
shellIds = null;
- if (!body.Topology.TryGetBody(bodyId, out var topologyBody))
+ if (!body.Topology.TryGetBody(bodyId, out var topologyBody) || topologyBody is null)
{
return false;
}
@@ -38,7 +38,7 @@ public static class BrepBodyQueries
public static bool TryGetFaceIds(this BrepBody body, ShellId shellId, out IReadOnlyList<FaceId>? faceIds)
{
faceIds = null;
- if (!body.Topology.TryGetShell(shellId, out var shell))
+ if (!body.Topology.TryGetShell(shellId, out var shell) || shell is null)
{
return false;
}
@@ -57,7 +57,7 @@ public static class BrepBodyQueries
public static bool TryGetLoopIds(this BrepBody body, FaceId faceId, out IReadOnlyList<LoopId>? loopIds)
{
loopIds = null;
- if (!body.Topology.TryGetFace(faceId, out var face))
+ if (!body.Topology.TryGetFace(faceId, out var face) || face is null)
{
return false;
}
@@ -76,7 +76,7 @@ public static class BrepBodyQueries
public static bool TryGetCoedgeIds(this BrepBody body, LoopId loopId, out IReadOnlyList<CoedgeId>? coedgeIds)
{
coedgeIds = null;
- if (!body.Topology.TryGetLoop(loopId, out var loop))
+ if (!body.Topology.TryGetLoop(loopId, out var loop) || loop is null)
{
return false;
}
@@ -95,7 +95,7 @@ public static class BrepBodyQueries
public static bool TryGetCoedgeEdgeId(this BrepBody body, CoedgeId coedgeId, out EdgeId edgeId)
{
edgeId = default;
- if (!body.Topology.TryGetCoedge(coedgeId, out var coedge))
+ if (!body.Topology.TryGetCoedge(coedgeId, out var coedge) || coedge is null)
{
return false;
}
@@ -116,7 +116,7 @@ public static class BrepBodyQueries
startVertexId = default;
endVertexId = default;
- if (!body.Topology.TryGetEdge(edgeId, out var edge))
+ if (!body.Topology.TryGetEdge(edgeId, out var edge) || edge is null)
{
return false;
}
diff --git a/Aetheris.Kernel.Core/Brep/Queries/BrepSpatialQueries.cs b/Aetheris.Kernel.Core/Brep/Queries/BrepSpatialQueries.cs
index cce089f2..56e0463c 100644
--- a/Aetheris.Kernel.Core/Brep/Queries/BrepSpatialQueries.cs
+++ b/Aetheris.Kernel.Core/Brep/Queries/BrepSpatialQueries.cs
@@ -1,5 +1,6 @@
using Aetheris.Kernel.Core.Diagnostics;
using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Geometry.Surfaces;
using Aetheris.Kernel.Core.Math;
using Aetheris.Kernel.Core.Numerics;
using Aetheris.Kernel.Core.Results;
@@ -422,6 +423,11 @@ public static class BrepSpatialQueries
private static bool TryResolvePrimitive(BrepBody body, out PrimitiveDescriptor descriptor, out KernelDiagnostic diagnostic)
{
descriptor = default;
+ diagnostic = new KernelDiagnostic(
+ KernelDiagnosticCode.NotImplemented,
+ KernelDiagnosticSeverity.Error,
+ "Spatial query v1 only supports primitive Brep bodies from BrepPrimitives.CreateBox/CreateCylinder/CreateSphere.",
+ Source: nameof(BrepSpatialQueries));
var bindings = body.Bindings.FaceBindings.ToArray();
if (bindings.Length == 1)
@@ -430,7 +436,6 @@ public static class BrepSpatialQueries
if (surface.Kind == SurfaceGeometryKind.Sphere && surface.Sphere is SphereSurface sphere)
{
descriptor = PrimitiveDescriptor.ForSphere(bindings[0].FaceId, sphere.Center, sphere.Radius);
- diagnostic = default;
return true;
}
}
@@ -470,7 +475,6 @@ public static class BrepSpatialQueries
cylinder.Radius,
minV,
maxV);
- diagnostic = default;
return true;
}
}
@@ -555,17 +559,11 @@ public static class BrepSpatialQueries
yMaxFace,
zMinFace,
zMaxFace);
- diagnostic = default;
return true;
}
}
}
- diagnostic = new KernelDiagnostic(
- KernelDiagnosticCode.NotImplemented,
- KernelDiagnosticSeverity.Error,
- "Spatial query v1 only supports primitive Brep bodies from BrepPrimitives.CreateBox/CreateCylinder/CreateSphere.",
- Source: nameof(BrepSpatialQueries));
return false;
}