Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Pin repo SDK to .NET 8 via global.json
Yuechen Licade08571ac8
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242ImporterTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242ImporterTests.csindex b9027f92..3a12740c 100644--- a/Aetheris.Kernel.Core.Tests/Step242/Step242ImporterTests.cs+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242ImporterTests.cs@@ -498,6 +498,30 @@ public sealed class Step242ImporterTestsAssert.True((seamStart - seamEnd).Length <= 1e-8d);}+ var cylinderSurface = import.Value.GetFaceSurface(cylinderFace.Id).Cylinder!.Value;+ var axis = cylinderSurface.Axis.ToVector();+ var sideAxials = patch.Positions+ .Select(point => (point - cylinderSurface.Origin).Dot(axis))+ .ToArray();+ var sideVMin = sideAxials.Min();+ var sideVMax = sideAxials.Max();++ var capPlanes = import.Value.Topology.Faces+ .Where(face => face.Id != cylinderFace.Id)+ .Select(face => import.Value.GetFaceSurface(face.Id))+ .Where(surface => surface.Kind == SurfaceGeometryKind.Plane)+ .Select(surface => surface.Plane!.Value)+ .ToArray();+ Assert.Equal(2, capPlanes.Length);++ var capAxials = capPlanes+ .Select(plane => (plane.Origin - cylinderSurface.Origin).Dot(axis))+ .OrderBy(v => v)+ .ToArray();++ Assert.True(double.Abs(capAxials[0] - sideVMin) <= 1e-8d);+ Assert.True(double.Abs(capAxials[1] - sideVMax) <= 1e-8d);+Assert.All(patch.TriangleIndices, index => Assert.InRange(index, 0, patch.Positions.Count - 1));for (var i = 0; i < patch.TriangleIndices.Count; i += 3)diff --git a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.csindex bb99b171..f8bfc23f 100644--- a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs+++ b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs@@ -244,7 +244,8 @@ public static class BrepDisplayTessellatorfaceId,options,radiusHint: cylinder.Radius,- allowThreeCoedgeConeTopology: false);+ allowThreeCoedgeConeTopology: false,+ axialParameterFromPoint: point => (point - cylinder.Origin).Dot(cylinder.Axis.ToVector()));if (periodicParameters.IsSuccess){return KernelResult<DisplayFaceMeshPatch>.Success(CreatePeriodicGridPatch(@@ -400,10 +401,43 @@ public static class BrepDisplayTessellator}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);+ }++ var projected = vertexPointsResult.Value.Values+ .Select(axialParameterFromPoint)+ .Where(double.IsFinite)+ .ToArray();++ 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 angularSegments = CalculateSegmentCount(2d * double.Pi, System.Math.Max(1e-6d, radiusHint), options);- var axialSegments = System.Math.Max(1, System.Math.Clamp((int)double.Ceiling((seamInterval.End - seamInterval.Start) / options.ChordTolerance), 1, options.MaximumSegments));+ var axialSegments = System.Math.Max(1, System.Math.Clamp((int)double.Ceiling(double.Abs(seamEnd - seamStart) / options.ChordTolerance), 1, options.MaximumSegments));- return KernelResult<(double, double, int, int)>.Success((seamInterval.Start, seamInterval.End, angularSegments, axialSegments));+ return KernelResult<(double, double, int, int)>.Success((seamStart, seamEnd, angularSegments, axialSegments));}if (allowThreeCoedgeConeTopology && coedges.Length == 3 && lineCoedges.Length == 2 && circleCoedges.Length == 1)diff --git a/global.json b/global.jsonnew file mode 100644index 00000000..391ba3c2--- /dev/null+++ b/global.json@@ -0,0 +1,6 @@+{+ "sdk": {+ "version": "8.0.100",+ "rollForward": "latestFeature"+ }+}