Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Run .NET 8 tests and align curved/revolved regression verdicts

Yuechen Li1bc5005e4c4c
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs
index 65e4416f..c5730680 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs
@@ -31,10 +31,14 @@ public sealed class Step242ConicalSurfaceRegressionTests
}
[Theory]
- [InlineData("testdata/step242/nist/CTC/nist_ctc_01_asme1_ap242-e1.stp", "tessellator", "Viewer.Tessellation.CurvedTopologyUnsupported", "Face 57 curved tessellation expected mirrored line uses for this cone/revolved topology. Observed")]
- [InlineData("testdata/step242/nist/CTC/nist_ctc_04_asme1_ap242-e1.stp", "tessellator", "", "Face 1 curved tessellation supports four-coedge torus/revolved loop layouts and the three-coedge cone loop emitted by the handcrafted fixture. Observed")]
+ [InlineData("testdata/step242/nist/CTC/nist_ctc_01_asme1_ap242-e1.stp", "exporter", "Face:1", "Unsupported surface kind 'Cylinder'. M22 supports planar faces only.")]
+ [InlineData("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp", "tessellator", "Viewer.Tessellation.PlanarCurveFlatteningUnsupported", "Face 3 planar curve flattening does not support curve kind 'BSpline3'.")]
+ [InlineData("testdata/step242/nist/CTC/nist_ctc_04_asme1_ap242-e1.stp", "tessellator", "", "Face 1 curved tessellation supports repeated cone/revolved families with mixed line/circle loops; this topology family is still unsupported. Observed")]
[InlineData("testdata/step242/nist/FTC/nist_ftc_06_asme1_ap242-e2.stp", "tessellator", "", "Face 2 curved tessellation does not support this torus/revolved boundary topology yet. Observed")]
- public void Step242_NistConicalTargets_AdvancePastConicalRadius_AndReportDeterministicNextBlocker(
+ [InlineData("testdata/step242/nist/FTC/nist_ftc_09_asme1_ap242-e1.stp", "tessellator", "", "Face 73 curved tessellation does not support this torus/revolved boundary topology yet. Observed")]
+ [InlineData("testdata/step242/nist/FTC/nist_ftc_10_asme1_ap242-e2.stp", "tessellator", "", "Face 14 curved tessellation supports repeated torus/revolved families with mixed line/circle loops; this topology family is still unsupported. Observed")]
+ [InlineData("testdata/step242/nist/STC/nist_stc_09_asme1_ap242-e3.stp", "exporter", "Edge:1", "Unsupported curve kind 'Circle3'. M22 supports line edges only.")]
+ public void Step242_NistCurvedRevolvedTargets_AdvancePastOldTopologyFamily_AndReportDeterministicNextBlocker(
string relativePath,
string expectedLayer,
string expectedSource,
@@ -54,6 +58,8 @@ public sealed class Step242ConicalSurfaceRegressionTests
var second = Step242CorpusManifestRunner.RunOne(entry);
Assert.DoesNotContain("CONICAL_SURFACE radius", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
+ Assert.DoesNotContain("expected mirrored line uses for this cone/revolved topology", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
+ Assert.DoesNotContain("supports four-coedge torus/revolved loop layouts", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
Assert.Equal(expectedLayer, first.FirstFailureLayer);
if (!string.IsNullOrEmpty(expectedSource))
{
@@ -68,14 +74,15 @@ public sealed class Step242ConicalSurfaceRegressionTests
Assert.Equal(first.FirstFailureLayer, second.FirstFailureLayer);
Assert.Equal(first.FirstDiagnostic.Source, second.FirstDiagnostic.Source);
Assert.Equal(first.FirstDiagnostic.MessagePrefix, second.FirstDiagnostic.MessagePrefix);
+ Assert.False(string.IsNullOrWhiteSpace(first.FirstDiagnostic.MessagePrefix));
}
[Theory]
[InlineData(
"testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp",
"tessellator",
- "Viewer.Tessellation.CurvedTopologyUnsupported",
- "Face 1 curved tessellation expected mirrored")]
+ "Viewer.Tessellation.PlanarCurveFlatteningUnsupported",
+ "Face 3 planar curve flattening does not support curve kind 'BSpline3'.")]
[InlineData(
"testdata/step242/nist/STC/nist_stc_10_asme1_ap242-e2.stp",
"importer-topology",
diff --git a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs
index 5122e3eb..01d21df2 100644
--- a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs
+++ b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs
@@ -394,129 +394,165 @@ public static class BrepDisplayTessellator
var lineCoedges = coedges.Where(c => body.GetEdgeCurve(c.EdgeId).Kind == CurveGeometryKind.Line3).ToArray();
var circleCoedges = coedges.Where(c => body.GetEdgeCurve(c.EdgeId).Kind == CurveGeometryKind.Circle3).ToArray();
- if (coedges.Length == 4 && lineCoedges.Length == 2 && circleCoedges.Length == 2)
+ if (TryResolveFourUseMixedRevolvedLoop(body, coedges, lineCoedges, circleCoedges, axialParameterFromPoint, faceId, out var mixedRevolvedParameters, out var mixedRevolvedDiagnostics))
{
- if (!body.Bindings.TryGetEdgeBinding(lineCoedges[0].EdgeId, out var seamBinding))
- {
- return KernelResult<(double, double, int, int)>.Failure([CreateNotImplemented($"Face {faceId.Value} seam edge is missing curve trim binding.")]);
- }
-
- var seamInterval = seamBinding.TrimInterval ?? new ParameterInterval(0d, 1d);
- var seamStart = seamInterval.Start;
- var seamEnd = seamInterval.End;
-
- if (axialParameterFromPoint is not null)
- {
- var vertexPointsResult = BuildLoopVertexPointLookup(body, coedges, faceId);
- if (!vertexPointsResult.IsSuccess)
- {
- return KernelResult<(double, double, int, int)>.Failure(vertexPointsResult.Diagnostics);
- }
+ return KernelResult<(double, double, int, int)>.Success((
+ mixedRevolvedParameters.VStart,
+ mixedRevolvedParameters.VEnd,
+ CalculateSegmentCount(2d * double.Pi, System.Math.Max(1e-6d, radiusHint), options),
+ CalculateAxialSegments(mixedRevolvedParameters.VStart, mixedRevolvedParameters.VEnd, options)), mixedRevolvedDiagnostics);
+ }
- var projected = vertexPointsResult.Value.Values
- .Select(axialParameterFromPoint)
- .Where(double.IsFinite)
- .ToArray();
+ if (allowThreeCoedgeConeTopology && TryResolveConeRevolvedLoop(body, coedges, lineCoedges, circleCoedges, axialParameterFromPoint, faceId, out var coneRevolvedParameters, out var coneRevolvedDiagnostics))
+ {
+ var angularSegments = CalculateSegmentCount(2d * double.Pi, System.Math.Max(1e-6d, radiusHint), options);
+ var axialSegments = CalculateAxialSegments(coneRevolvedParameters.VStart, coneRevolvedParameters.VEnd, options);
+ return KernelResult<(double, double, int, int)>.Success((coneRevolvedParameters.VStart, coneRevolvedParameters.VEnd, angularSegments, axialSegments), coneRevolvedDiagnostics);
+ }
- if (projected.Length != 0)
- {
- var projectedMin = projected.Min();
- var projectedMax = projected.Max();
- if (seamEnd >= seamStart)
- {
- seamStart = projectedMin;
- seamEnd = projectedMax;
- }
- else
- {
- seamStart = projectedMax;
- seamEnd = projectedMin;
- }
- }
- }
+ var uniqueEdgeIds = coedges
+ .Select(c => c.EdgeId)
+ .Distinct()
+ .ToArray();
+ var allEdgeCurvesAreCircles = uniqueEdgeIds
+ .Select(id => body.GetEdgeCurve(id).Kind)
+ .All(kind => kind == CurveGeometryKind.Circle3);
+ if (lineCoedges.Length == 0 && circleCoedges.Length >= 4 && uniqueEdgeIds.Length == 2 && allEdgeCurvesAreCircles)
+ {
var angularSegments = CalculateSegmentCount(2d * double.Pi, System.Math.Max(1e-6d, radiusHint), options);
- var axialSegments = System.Math.Max(1, System.Math.Clamp((int)double.Ceiling(double.Abs(seamEnd - seamStart) / options.ChordTolerance), 1, options.MaximumSegments));
+ var axialSegments = CalculateSegmentCount(2d * double.Pi, System.Math.Max(1e-6d, radiusHint), options);
+ return KernelResult<(double, double, int, int)>.Success((0d, 2d * double.Pi, angularSegments, axialSegments));
+ }
- return KernelResult<(double, double, int, int)>.Success((seamStart, seamEnd, angularSegments, axialSegments));
+ if (coedges.Length != 4)
+ {
+ var topologyFamily = allowThreeCoedgeConeTopology ? "cone/revolved" : "torus/revolved";
+ return KernelResult<(double, double, int, int)>.Failure([CreateNotImplemented(allowThreeCoedgeConeTopology
+ ? $"Face {faceId.Value} curved tessellation supports repeated {topologyFamily} families with mixed line/circle loops; this topology family is still unsupported. Observed: {DescribeRevolvedLoopTopology(body, coedges)}"
+ : $"Face {faceId.Value} curved tessellation supports repeated {topologyFamily} families with mixed line/circle loops; this topology family is still unsupported. Observed: {DescribeRevolvedLoopTopology(body, coedges)}")]);
}
- if (allowThreeCoedgeConeTopology && coedges.Length == 3 && lineCoedges.Length == 2 && circleCoedges.Length == 1)
+ return KernelResult<(double, double, int, int)>.Failure([CreateNotImplemented($"Face {faceId.Value} curved tessellation does not support this torus/revolved boundary topology yet. Observed: {DescribeRevolvedLoopTopology(body, coedges)}")]);
+ }
+
+ private static bool TryResolveFourUseMixedRevolvedLoop(
+ BrepBody body,
+ IReadOnlyList<Coedge> coedges,
+ IReadOnlyList<Coedge> lineCoedges,
+ IReadOnlyList<Coedge> circleCoedges,
+ Func<Point3D, double>? axialParameterFromPoint,
+ FaceId faceId,
+ out (double VStart, double VEnd) parameters,
+ out IReadOnlyList<KernelDiagnostic> diagnostics)
+ {
+ parameters = default;
+ diagnostics = [];
+ if (coedges.Count != 4 || lineCoedges.Count != 2 || circleCoedges.Count != 2)
{
- var lineEdgeIds = lineCoedges.Select(c => c.EdgeId).Distinct().ToArray();
- if (lineEdgeIds.Length != 1)
- {
- return KernelResult<(double, double, int, int)>.Failure([CreateNotImplemented($"Face {faceId.Value} curved tessellation expected mirrored line uses for this cone/revolved topology. Observed: {DescribeRevolvedLoopTopology(body, coedges)}", CurvedTopologyUnsupportedSource)]);
- }
+ return false;
+ }
- if (!body.Bindings.TryGetEdgeBinding(lineEdgeIds[0], out var lineTrimBinding))
- {
- return KernelResult<(double, double, int, int)>.Failure([CreateNotImplemented($"Face {faceId.Value} line trim edge is missing curve trim binding.")]);
- }
+ var result = TryResolveAxialBoundsFromLines(body, coedges, lineCoedges.Select(c => c.EdgeId).Distinct().ToArray(), axialParameterFromPoint, faceId);
+ if (!result.IsSuccess)
+ {
+ diagnostics = result.Diagnostics;
+ return false;
+ }
- var lineTrimInterval = lineTrimBinding.TrimInterval ?? new ParameterInterval(0d, 1d);
- var lineTrimStart = lineTrimInterval.Start;
- var lineTrimEnd = lineTrimInterval.End;
+ parameters = result.Value;
+ diagnostics = result.Diagnostics;
+ return true;
+ }
- if (axialParameterFromPoint is not null)
- {
- var vertexPointsResult = BuildLoopVertexPointLookup(body, coedges, faceId);
- if (!vertexPointsResult.IsSuccess)
- {
- return KernelResult<(double, double, int, int)>.Failure(vertexPointsResult.Diagnostics);
- }
+ private static bool TryResolveConeRevolvedLoop(
+ BrepBody body,
+ IReadOnlyList<Coedge> coedges,
+ IReadOnlyList<Coedge> lineCoedges,
+ IReadOnlyList<Coedge> circleCoedges,
+ Func<Point3D, double>? axialParameterFromPoint,
+ FaceId faceId,
+ out (double VStart, double VEnd) parameters,
+ out IReadOnlyList<KernelDiagnostic> diagnostics)
+ {
+ parameters = default;
+ diagnostics = [];
+ if (coedges.Count < 3 || lineCoedges.Count < 2 || circleCoedges.Count < 1)
+ {
+ return false;
+ }
- var projected = vertexPointsResult.Value.Values
- .Select(axialParameterFromPoint)
- .Where(double.IsFinite)
- .ToArray();
+ var lineEdgeIds = lineCoedges.Select(c => c.EdgeId).Distinct().ToArray();
+ var result = TryResolveAxialBoundsFromLines(body, coedges, lineEdgeIds, axialParameterFromPoint, faceId);
+ if (!result.IsSuccess)
+ {
+ diagnostics = result.Diagnostics;
+ return false;
+ }
- if (projected.Length != 0)
- {
- var projectedMin = projected.Min();
- var projectedMax = projected.Max();
- if (lineTrimEnd >= lineTrimStart)
- {
- lineTrimStart = projectedMin;
- lineTrimEnd = projectedMax;
- }
- else
- {
- lineTrimStart = projectedMax;
- lineTrimEnd = projectedMin;
- }
- }
- }
+ parameters = result.Value;
+ diagnostics = result.Diagnostics;
+ return true;
+ }
- var angularSegments = CalculateSegmentCount(2d * double.Pi, System.Math.Max(1e-6d, radiusHint), options);
- var axialSpan = double.Abs(lineTrimEnd - lineTrimStart);
- var axialSegments = System.Math.Max(1, System.Math.Clamp((int)double.Ceiling(axialSpan / options.ChordTolerance), 1, options.MaximumSegments));
- return KernelResult<(double, double, int, int)>.Success((lineTrimStart, lineTrimEnd, angularSegments, axialSegments));
+ private static KernelResult<(double VStart, double VEnd)> TryResolveAxialBoundsFromLines(
+ BrepBody body,
+ IReadOnlyList<Coedge> coedges,
+ IReadOnlyList<EdgeId> lineEdgeIds,
+ Func<Point3D, double>? axialParameterFromPoint,
+ FaceId faceId)
+ {
+ if (lineEdgeIds.Count == 0)
+ {
+ return KernelResult<(double VStart, double VEnd)>.Failure([CreateNotImplemented($"Face {faceId.Value} curved tessellation expected line trim edges for revolved topology. Observed: {DescribeRevolvedLoopTopology(body, coedges)}", CurvedTopologyUnsupportedSource)]);
}
- if (coedges.Length != 4)
+ var intervals = new List<ParameterInterval>(lineEdgeIds.Count);
+ foreach (var lineEdgeId in lineEdgeIds)
{
- return KernelResult<(double, double, int, int)>.Failure([CreateNotImplemented(allowThreeCoedgeConeTopology
- ? $"Face {faceId.Value} curved tessellation supports four-coedge torus/revolved loop layouts and the three-coedge cone loop emitted by the handcrafted fixture. Observed: {DescribeRevolvedLoopTopology(body, coedges)}"
- : $"Face {faceId.Value} curved tessellation supports four-coedge torus/revolved loop layouts. Observed: {DescribeRevolvedLoopTopology(body, coedges)}")]);
+ if (!body.Bindings.TryGetEdgeBinding(lineEdgeId, out var lineTrimBinding))
+ {
+ return KernelResult<(double VStart, double VEnd)>.Failure([CreateNotImplemented($"Face {faceId.Value} line trim edge is missing curve trim binding.")]);
+ }
+
+ intervals.Add(lineTrimBinding.TrimInterval ?? new ParameterInterval(0d, 1d));
}
- var uniqueEdgeIds = coedges
- .Select(c => c.EdgeId)
- .Distinct()
- .ToArray();
- var allEdgeCurvesAreCircles = uniqueEdgeIds
- .Select(id => body.GetEdgeCurve(id).Kind)
- .All(kind => kind == CurveGeometryKind.Circle3);
+ var vMin = intervals.Min(i => System.Math.Min(i.Start, i.End));
+ var vMax = intervals.Max(i => System.Math.Max(i.Start, i.End));
+ var increasing = intervals[0].End >= intervals[0].Start;
+ var vStart = increasing ? vMin : vMax;
+ var vEnd = increasing ? vMax : vMin;
- if (lineCoedges.Length == 0 && circleCoedges.Length == 4 && uniqueEdgeIds.Length == 2 && allEdgeCurvesAreCircles)
+ if (axialParameterFromPoint is not null)
{
- var angularSegments = CalculateSegmentCount(2d * double.Pi, System.Math.Max(1e-6d, radiusHint), options);
- var axialSegments = CalculateSegmentCount(2d * double.Pi, System.Math.Max(1e-6d, radiusHint), options);
- return KernelResult<(double, double, int, int)>.Success((0d, 2d * double.Pi, angularSegments, axialSegments));
+ var vertexPointsResult = BuildLoopVertexPointLookup(body, coedges, faceId);
+ if (!vertexPointsResult.IsSuccess)
+ {
+ return KernelResult<(double VStart, double VEnd)>.Failure(vertexPointsResult.Diagnostics);
+ }
+
+ var projected = vertexPointsResult.Value.Values
+ .Select(axialParameterFromPoint)
+ .Where(double.IsFinite)
+ .ToArray();
+
+ if (projected.Length != 0)
+ {
+ var projectedMin = projected.Min();
+ var projectedMax = projected.Max();
+ vStart = increasing ? projectedMin : projectedMax;
+ vEnd = increasing ? projectedMax : projectedMin;
+ }
}
- return KernelResult<(double, double, int, int)>.Failure([CreateNotImplemented($"Face {faceId.Value} curved tessellation does not support this torus/revolved boundary topology yet. Observed: {DescribeRevolvedLoopTopology(body, coedges)}")]);
+ return KernelResult<(double VStart, double VEnd)>.Success((vStart, vEnd));
+ }
+
+ private static int CalculateAxialSegments(double vStart, double vEnd, DisplayTessellationOptions options)
+ {
+ var axialSpan = double.Abs(vEnd - vStart);
+ return System.Math.Max(1, System.Math.Clamp((int)double.Ceiling(axialSpan / options.ChordTolerance), 1, options.MaximumSegments));
}
private static string DescribeRevolvedLoopTopology(BrepBody body, IReadOnlyList<Coedge> coedges)
diff --git a/testdata/step242/manifests/nist.v0.report.json b/testdata/step242/manifests/nist.v0.report.json
index 1aba4834..b35d0e41 100644
--- a/testdata/step242/manifests/nist.v0.report.json
+++ b/testdata/step242/manifests/nist.v0.report.json
@@ -4,11 +4,11 @@
"path": "testdata/step242/nist/CTC/nist_ctc_01_asme1_ap242-e1.stp",
"sizeBytes": 391739,
"status": "importFail",
- "firstFailureLayer": "tessellator",
+ "firstFailureLayer": "exporter",
"firstDiagnostic": {
"code": "NotImplemented",
- "source": "Viewer.Tessellation.CurvedTopologyUnsupported",
- "messagePrefix": "Face 57 curved tessellation expected mirrored line uses for this cone/revolved topology. Observed"
+ "source": "Face:1",
+ "messagePrefix": "Unsupported surface kind \u0027Cylinder\u0027. M22 supports planar faces only."
},
"diagnosticCount": 1,
"exceptionEscaped": false,
@@ -18,8 +18,8 @@
"faces": 117
},
"tessellationCounts": {
- "facePatches": 0,
- "edgePolylines": 0
+ "facePatches": 117,
+ "edgePolylines": 318
},
"canonicalSha256": null
},
@@ -31,8 +31,8 @@
"firstFailureLayer": "tessellator",
"firstDiagnostic": {
"code": "NotImplemented",
- "source": "Viewer.Tessellation.CurvedTopologyUnsupported",
- "messagePrefix": "Face 1 curved tessellation expected mirrored line uses for this cone/revolved topology. Observed"
+ "source": "Viewer.Tessellation.PlanarCurveFlatteningUnsupported",
+ "messagePrefix": "Face 3 planar curve flattening does not support curve kind \u0027BSpline3\u0027."
},
"diagnosticCount": 1,
"exceptionEscaped": false,
@@ -80,7 +80,7 @@
"firstDiagnostic": {
"code": "NotImplemented",
"source": "",
- "messagePrefix": "Face 1 curved tessellation supports four-coedge torus/revolved loop layouts and the three-coedge cone loop emitted by the handcrafted fixture. Observed"
+ "messagePrefix": "Face 1 curved tessellation supports repeated cone/revolved families with mixed line/circle loops; this topology family is still unsupported. Observed"
},
"diagnosticCount": 1,
"exceptionEscaped": false,
@@ -248,7 +248,7 @@
"firstDiagnostic": {
"code": "NotImplemented",
"source": "",
- "messagePrefix": "Face 14 curved tessellation supports four-coedge torus/revolved loop layouts. Observed"
+ "messagePrefix": "Face 14 curved tessellation supports repeated torus/revolved families with mixed line/circle loops; this topology family is still unsupported. Observed"
},
"diagnosticCount": 1,
"exceptionEscaped": false,
@@ -364,11 +364,11 @@
"path": "testdata/step242/nist/STC/nist_stc_09_asme1_ap242-e3.stp",
"sizeBytes": 5237528,
"status": "importFail",
- "firstFailureLayer": "tessellator",
+ "firstFailureLayer": "exporter",
"firstDiagnostic": {
"code": "NotImplemented",
- "source": "",
- "messagePrefix": "Face 31 curved tessellation supports four-coedge torus/revolved loop layouts and the three-coedge cone loop emitted by the handcrafted fixture. Observed"
+ "source": "Edge:1",
+ "messagePrefix": "Unsupported curve kind \u0027Circle3\u0027. M22 supports line edges only."
},
"diagnosticCount": 1,
"exceptionEscaped": false,
@@ -378,8 +378,8 @@
"faces": 125
},
"tessellationCounts": {
- "facePatches": 0,
- "edgePolylines": 0
+ "facePatches": 125,
+ "edgePolylines": 392
},
"canonicalSha256": null
},