Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Preserve multi-region prismatic material through composition and imprint

Yuechen Lif7d13d4c5027
diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.cs
index c1586918..8ab1dffd 100644
--- a/Aetheris.CLI/CliRunner.cs
+++ b/Aetheris.CLI/CliRunner.cs
@@ -2135,15 +2135,16 @@ Model CanonicalPanel {
x.From,
x.To,
x.ActiveOperations,
- area = PrismaticSectionStackCompiler.Area(x.Region), signature = ProfileSignature(x.Region.Outer),
- outerLoops = 1,
- innerLoops = x.Region.Holes.Count,
- loops = new[]
+ area = x.MaterialRegions.Sum(PrismaticSectionStackCompiler.Area), signature = ProfileSignature(x.Region.Outer),
+ outerLoops = x.MaterialRegions.Count,
+ innerLoops = x.MaterialRegions.Sum(r => r.Holes.Count),
+ regions = x.MaterialRegions.Select((region, index) => new { index, area = PrismaticSectionStackCompiler.Area(region), signature = ProfileSignature(region.Outer), innerLoops = region.Holes.Count, region.Provenance }),
+ loops = x.MaterialRegions.SelectMany(region => new[]
{
- new { role = "Outer", signedAreaInProfileFrame = PrismaticSectionStackCompiler.ProfileArea(x.Region.Outer), sourceWinding = PrismaticSectionStackCompiler.ProfileArea(x.Region.Outer) >= 0d ? "CounterClockwise" : "Clockwise", materialFacingWinding = "CounterClockwise" }
- }.Concat(x.Region.Holes.Select(h => new { role = "Inner", signedAreaInProfileFrame = PrismaticSectionStackCompiler.ProfileArea(h), sourceWinding = PrismaticSectionStackCompiler.ProfileArea(h) >= 0d ? "CounterClockwise" : "Clockwise", materialFacingWinding = "Clockwise" })),
- lineSegments = x.Region.Outer.Loops[0].Segments.Count(s => s.Geometry is LineArcLineSegment2D),
- arcSegments = x.Region.Outer.Loops[0].Segments.Count(s => s.Geometry is LineArcCircularArc2D)
+ new { role = "Outer", signedAreaInProfileFrame = PrismaticSectionStackCompiler.ProfileArea(region.Outer), sourceWinding = PrismaticSectionStackCompiler.ProfileArea(region.Outer) >= 0d ? "CounterClockwise" : "Clockwise", materialFacingWinding = "CounterClockwise" }
+ }.Concat(region.Holes.Select(h => new { role = "Inner", signedAreaInProfileFrame = PrismaticSectionStackCompiler.ProfileArea(h), sourceWinding = PrismaticSectionStackCompiler.ProfileArea(h) >= 0d ? "CounterClockwise" : "Clockwise", materialFacingWinding = "Clockwise" }))),
+ lineSegments = x.MaterialRegions.Sum(r => r.Outer.Loops[0].Segments.Count(s => s.Geometry is LineArcLineSegment2D)),
+ arcSegments = x.MaterialRegions.Sum(r => r.Outer.Loops[0].Segments.Count(s => s.Geometry is LineArcCircularArc2D))
, arrangement = x.Arrangement is null ? null : new
{
sourceSegmentCount = x.Arrangement.SourceCurves.Count,
@@ -2154,7 +2155,7 @@ Model CanonicalPanel {
resultLoopCount = x.Arrangement.ResultLoops.Count,
perimeter = x.Arrangement.ResultLoops.Sum(loop => loop.Perimeter),
timingsMilliseconds = new { intersections = x.Arrangement.IntersectionTime.TotalMilliseconds, splitting = x.Arrangement.SplitTime.TotalMilliseconds, classification = x.Arrangement.ClassificationTime.TotalMilliseconds, reconstruction = x.Arrangement.ReconstructionTime.TotalMilliseconds },
- provenance = x.Region.Provenance,
+ provenance = x.MaterialRegions.SelectMany(r => r.Provenance).Distinct().Order(StringComparer.Ordinal),
diagnostics = x.Arrangement.Diagnostics
}
}),
@@ -5377,7 +5378,8 @@ Model CanonicalPanel {
_ => s.Geometry.GetType().Name
}).OrderBy(x => x, StringComparer.Ordinal)));
- private static string CompositionSignature(PrismaticSectionStackConstruction stack) => Hash(string.Join("|", stack.Slabs.Select(s => $"{Q(s.From)}:{Q(s.To)}:{ProfileSignature(s.Region.Outer)}:{Q(PrismaticSectionStackCompiler.Area(s.Region))}")));
+ private static string CompositionSignature(PrismaticSectionStackConstruction stack) => Hash(string.Join("|", stack.Slabs.Select(s =>
+ $"{Q(s.From)}:{Q(s.To)}:{string.Join(";", s.MaterialRegions.Select(r => $"{ProfileSignature(r.Outer)}:{Q(PrismaticSectionStackCompiler.Area(r))}"))}")));
private static string Hash(string value) => Convert.ToHexString(SHA256.HashData(System.Text.Encoding.UTF8.GetBytes(value))).ToLowerInvariant();
private static long Q(double value) => (long)Math.Round(value * 1_000_000d, MidpointRounding.AwayFromZero);
}
diff --git a/Aetheris.Kernel.Firmament.Tests/BezierSectionStackTests.cs b/Aetheris.Kernel.Firmament.Tests/BezierSectionStackTests.cs
new file mode 100644
index 00000000..8e9a7404
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/BezierSectionStackTests.cs
@@ -0,0 +1,183 @@
+using Aetheris.Kernel.Core.Brep.Verification;
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Step242;
+using Aetheris.Kernel.Firmament.Materializer;
+
+namespace Aetheris.Kernel.Firmament.Tests;
+
+public sealed class BezierSectionStackTests
+{
+ [Fact]
+ public void CodexEngravesOnThreadedHexBoltAndRoundTripsStep()
+ {
+ var source=File.ReadAllText(Path.GetFullPath(Path.Combine(AppContext.BaseDirectory,"..","..","..","..","fixtures","Thread","hexbolt-threaded.firmament")));
+ var mark=ThreadedHexBoltMakerMark.Build(source,"CODEX",2.5,.2);
+ Assert.Equal(2,mark.Text.CounterCount);
+ Assert.Equal(3,mark.Section.Slabs.Last().MaterialRegions.Count);
+ var mass=BrepMassProperties.Evaluate(mark.Body);
+ Assert.True(mass.IsEnclosed,string.Join("; ",mass.Diagnostics));
+ Assert.True(mass.IsOrientationConsistent,string.Join("; ",mass.Diagnostics));
+ var imported=Step242Importer.ImportBody(mark.StepText);
+ Assert.True(imported.IsSuccess,string.Join("; ",imported.Diagnostics.Select(x=>x.Message)));
+ var importedMass=BrepMassProperties.Evaluate(imported.Value!);
+ Assert.True(importedMass.IsEnclosed,string.Join("; ",importedMass.Diagnostics));
+ Assert.True(importedMass.IsOrientationConsistent,string.Join("; ",importedMass.Diagnostics));
+ if (Environment.GetEnvironmentVariable("AETHERIS_MAKER_MARK_ARTIFACT_DIR") is { Length: > 0 } artifactDirectory)
+ {
+ Directory.CreateDirectory(artifactDirectory);
+ File.WriteAllText(Path.Combine(artifactDirectory,"codex-threaded-hexbolt.step"),mark.StepText);
+ }
+ }
+ [Theory]
+ [InlineData(false)]
+ [InlineData(true)]
+ public void GenericCubicSectionBossAndPocketRemainExact(bool pocket)
+ {
+ var mark = CubicRegion();
+ Assert.True(ResolvedProfile2DValidator.Validate(mark).IsValid);
+ Qualify(mark,pocket);
+ }
+
+ [Fact]
+ public void CounterPocketReconnectsThroughUnderlyingPlate()
+ {
+ var mark=Assert.Single(PlanarTextProfiles.Build("O",3).Regions);
+ var plate=Rectangle();
+ var feature=new PrismaticProfileCompositionFeature("CounterPocket","XY","+Z",
+ new PrismaticProfilePlacement("P",0d,0d,0d,"XY","+Z","+X",false),
+ [new("Plate",PrismaticProfileIntent.Base,plate.Name,0d,1d,"Stock","test"),
+ new("Mark",PrismaticProfileIntent.Remove,mark.Name,.8d,1d,"Pocket","test")],
+ [0d,.8d,1d],"test");
+ var parsed=new PrismaticProfileCompositionParseResult(feature,
+ new Dictionary<string,ResolvedProfile2D> { [plate.Name]=plate,[mark.Name]=mark },[]);
+ var stack=PrismaticSectionStackCompiler.Normalize(parsed,out var diagnostics);
+ Assert.NotNull(stack);
+ Assert.Empty(diagnostics);
+ Assert.Equal(2,stack.Slabs.Single(x=>x.From==.8d).MaterialRegions.Count);
+ var emitted=PrismaticSectionStackEmitter.Emit(stack);
+ Assert.NotNull(emitted.Body);
+ Assert.DoesNotContain(emitted.Diagnostics,x=>x.Contains("non-manifold",StringComparison.Ordinal));
+ var mass=BrepMassProperties.Evaluate(emitted.Body!);
+ Assert.True(mass.IsEnclosed,string.Join("; ",mass.Diagnostics));
+ Assert.True(mass.IsOrientationConsistent,string.Join("; ",mass.Diagnostics));
+ }
+
+ [Theory]
+ [InlineData(false)]
+ [InlineData(true)]
+ public void CurvedProfileFlowsThroughOrdinarySectionStackAndStep(bool pocket)
+ {
+ var mark = Assert.Single(PlanarTextProfiles.Build(pocket ? "C" : "O", 3).Regions);
+ Qualify(mark,pocket);
+ }
+
+ [Theory]
+ [InlineData("D", true)]
+ [InlineData("OO", true)]
+ [InlineData("CODEX", true)]
+ [InlineData("AETHERIS", false)]
+ public void MultipleTextRegionsShareOneConnectedPlate(string word, bool pocket)
+ {
+ var text=PlanarTextProfiles.Build(word,2.5,PlanarTextAlignment.Center);
+ Assert.True(text.Succeeded,string.Join("; ",text.Diagnostics));
+ var plate=Rectangle(30d,12d);
+ var operations=new List<PrismaticProfileOperation> { new("Plate",PrismaticProfileIntent.Base,plate.Name,0d,1d,"Stock","test") };
+ operations.AddRange(text.Regions.Select((region,index)=>new PrismaticProfileOperation($"Mark{index}",
+ pocket ? PrismaticProfileIntent.Remove : PrismaticProfileIntent.Add,region.Name,
+ pocket ? .8d : 1d,pocket ? 1d : 1.2d,pocket ? "Pocket" : "Boss","test")));
+ var feature=new PrismaticProfileCompositionFeature(word,"XY","+Z",
+ new PrismaticProfilePlacement("P",0d,0d,0d,"XY","+Z","+X",false),operations,
+ pocket ? [0d,.8d,1d] : [0d,1d,1.2d],"test");
+ var profiles=text.Regions.Append(plate).ToDictionary(x=>x.Name);
+ var stack=PrismaticSectionStackCompiler.Normalize(new(feature,profiles,[]),out var diagnostics);
+ Assert.True(stack is not null,string.Join("; ",diagnostics));
+ Assert.Empty(diagnostics);
+ Assert.Equal(pocket ? text.CounterCount+1 : text.Regions.Count,stack.Slabs.Last().MaterialRegions.Count);
+ if (word == "CODEX")
+ Assert.Contains(stack.Slabs.Last().Arrangement!.AtomicFragments, fragment =>
+ fragment.StableId.Contains("Glyph[4].Region[0].Outer.Outer.Segment[5]",StringComparison.Ordinal)
+ && fragment.FromParameter == 0d && fragment.ToParameter > .999d);
+ var emitted=PrismaticSectionStackEmitter.Emit(stack);
+ Assert.NotNull(emitted.Body);
+ var mass=BrepMassProperties.Evaluate(emitted.Body!);
+ Assert.True(mass.IsEnclosed,string.Join("; ",mass.Diagnostics));
+ Assert.True(mass.IsOrientationConsistent,string.Join("; ",mass.Diagnostics));
+ var step=Step242Exporter.ExportBody(emitted.Body!);
+ Assert.True(step.IsSuccess,string.Join("; ",step.Diagnostics.Select(x=>x.Message)));
+ var imported=Step242Importer.ImportBody(step.Value!);
+ Assert.True(imported.IsSuccess,string.Join("; ",imported.Diagnostics.Select(x=>x.Message)));
+ var importedMass=BrepMassProperties.Evaluate(imported.Value!);
+ Assert.True(importedMass.IsEnclosed,string.Join("; ",importedMass.Diagnostics));
+ Assert.True(importedMass.IsOrientationConsistent,string.Join("; ",importedMass.Diagnostics));
+ }
+
+ private static void Qualify(ResolvedProfile2D mark,bool pocket)
+ {
+ var plate = Rectangle();
+ var operations = new[]
+ {
+ new PrismaticProfileOperation("Plate",PrismaticProfileIntent.Base,plate.Name,0d,1d,"Stock","test"),
+ new PrismaticProfileOperation("Mark",pocket ? PrismaticProfileIntent.Remove : PrismaticProfileIntent.Add,
+ mark.Name,pocket ? .8d : 1d,pocket ? 1d : 1.2d,pocket ? "Pocket" : "Boss","test")
+ };
+ var feature = new PrismaticProfileCompositionFeature("BezierPlate","XY","+Z",
+ new PrismaticProfilePlacement("P",0d,0d,0d,"XY","+Z","+X",false),operations,
+ pocket ? [0d,.8d,1d] : [0d,1d,1.2d],"test");
+ var parsed = new PrismaticProfileCompositionParseResult(feature,
+ new Dictionary<string,ResolvedProfile2D> { [plate.Name]=plate,[mark.Name]=mark },[]);
+ var stack = PrismaticSectionStackCompiler.Normalize(parsed,out var diagnostics);
+ Assert.True(stack is not null,string.Join("; ",diagnostics));
+ Assert.Empty(diagnostics);
+ var emitted = PrismaticSectionStackEmitter.Emit(stack);
+ Assert.NotNull(emitted.Body);
+ var body = emitted.Body!;
+ Assert.Contains(body.Geometry.Surfaces, x => x.Value.Kind==SurfaceGeometryKind.LinearExtrusion);
+ var mass = BrepMassProperties.Evaluate(body);
+ Assert.True(mass.IsEnclosed,string.Join("; ",mass.Diagnostics));
+ Assert.True(mass.IsOrientationConsistent,string.Join("; ",mass.Diagnostics));
+ var step=Step242Exporter.ExportBody(body);
+ Assert.True(step.IsSuccess,string.Join("; ",step.Diagnostics.Select(x=>x.Message)));
+ var imported=Step242Importer.ImportBody(step.Value!);
+ Assert.True(imported.IsSuccess,string.Join("; ",imported.Diagnostics.Select(x=>x.Message)));
+ Assert.Contains(imported.Value!.Geometry.Surfaces,x=>x.Value.Kind==SurfaceGeometryKind.LinearExtrusion);
+ var originalCurves=body.Geometry.Surfaces.Select(entry=>entry.Value)
+ .Where(x=>x.Kind==SurfaceGeometryKind.LinearExtrusion)
+ .Select(x=>x.LinearExtrusion!.Value.Directrix.BSpline3!.Value)
+ .OrderBy(x=>x.ControlPoints[0].X).ThenBy(x=>x.ControlPoints[0].Y).ToArray();
+ var importedCurves=imported.Value.Geometry.Surfaces.Select(entry=>entry.Value)
+ .Where(x=>x.Kind==SurfaceGeometryKind.LinearExtrusion)
+ .Select(x=>x.LinearExtrusion!.Value.Directrix.BSpline3!.Value)
+ .OrderBy(x=>x.ControlPoints[0].X).ThenBy(x=>x.ControlPoints[0].Y).ToArray();
+ Assert.Equal(originalCurves.Length,importedCurves.Length);
+ for (var i=0;i<originalCurves.Length;i++)
+ for (var j=0;j<4;j++)
+ {
+ Assert.Equal(originalCurves[i].ControlPoints[j].X,importedCurves[i].ControlPoints[j].X,7);
+ Assert.Equal(originalCurves[i].ControlPoints[j].Y,importedCurves[i].ControlPoints[j].Y,7);
+ Assert.Equal(originalCurves[i].ControlPoints[j].Z,importedCurves[i].ControlPoints[j].Z,7);
+ }
+ }
+
+ private static ResolvedProfile2D CubicRegion()
+ {
+ LineArcProfileCurve2D[] geometry =
+ [
+ new LineArcLineSegment2D((-1d,-1d),(1d,-1d)),
+ new LineArcCubicBezier2D((1d,-1d),(2d,-.5d),(2d,.5d),(1d,1d)),
+ new LineArcLineSegment2D((1d,1d),(-1d,1d)),
+ new LineArcLineSegment2D((-1d,1d),(-1d,-1d))
+ ];
+ return new("CubicRegion","XY",[new ResolvedProfileLoop2D("Outer",true,
+ geometry.Select((curve,i)=>new ResolvedProfileSegment2D($"Edge{i}",curve,
+ new ProfileSegmentProvenance($"cubic:{i}","cubic","test","test","XY"))).ToArray())]);
+ }
+
+ private static ResolvedProfile2D Rectangle(double width=10d,double height=10d)
+ {
+ var points=new[] {(-width/2,-height/2),(width/2,-height/2),(width/2,height/2),(-width/2,height/2)};
+ return new("Plate","XY",[new ResolvedProfileLoop2D("Outer",true,
+ Enumerable.Range(0,4).Select(i=>new ResolvedProfileSegment2D($"Edge{i}",
+ new LineArcLineSegment2D(points[i],points[(i+1)%4]),
+ new ProfileSegmentProvenance($"plate:{i}","plate","test","test","XY"))).ToArray())]);
+ }
+}
diff --git a/Aetheris.Kernel.Firmament.Tests/PlanarTextProfilesTests.cs b/Aetheris.Kernel.Firmament.Tests/PlanarTextProfilesTests.cs
index 8eb1de93..b89cc54a 100644
--- a/Aetheris.Kernel.Firmament.Tests/PlanarTextProfilesTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/PlanarTextProfilesTests.cs
@@ -113,16 +113,16 @@ public sealed class PlanarTextProfilesTests
}
[Fact]
- public void SectionArrangementReportsItsExactCubicBoundary()
+ public void SectionArrangementAcceptsItsExactCubicBoundary()
{
var profile = Assert.Single(PlanarTextProfiles.Build("O", 3).Regions);
var operation = new PrismaticProfileOperation("Text", PrismaticProfileIntent.Add,
profile.Name, 0, 0.2, "Text", "test");
var result = ProfileArrangementBuilder.Compose("XY", [operation],
new Dictionary<string, ResolvedProfile2D> { [profile.Name] = profile }, "text-profile-probe");
- Assert.Null(result.Region);
- Assert.Contains(result.Arrangement.Diagnostics,
- d => d.Contains("bounded-cubic-section-unsupported", StringComparison.Ordinal));
+ Assert.NotNull(result.Region);
+ Assert.DoesNotContain(result.Arrangement.Diagnostics,
+ d => d.StartsWith("arrangement-rejected", StringComparison.Ordinal));
}
[Fact]
diff --git a/Aetheris.Kernel.Firmament.Tests/PrismaticProfileCompositionRoundTripTests.cs b/Aetheris.Kernel.Firmament.Tests/PrismaticProfileCompositionRoundTripTests.cs
index 1eaea3da..385857c1 100644
--- a/Aetheris.Kernel.Firmament.Tests/PrismaticProfileCompositionRoundTripTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/PrismaticProfileCompositionRoundTripTests.cs
@@ -226,7 +226,6 @@ public sealed class PrismaticProfileCompositionRoundTripTests
[InlineData("contradictory-coincident-add-remove.firmament", "contradictory-coincident-add-remove-boundary")]
[InlineData("ambiguous-tangent-crossing.firmament", "ambiguous-tangent-crossing")]
[InlineData("dangling-arrangement-fragment.firmament", "endpoint mismatch")]
- [InlineData("disconnected-final-material.firmament", "disconnected-or-invalid-material")]
[InlineData("unresolved-angular-ordering.firmament", "unresolved-angular-order")]
public void InvalidMaterialPolicies_RejectBeforeBrepEmission(string fixture, string expectedDiagnostic)
{
@@ -236,6 +235,18 @@ public sealed class PrismaticProfileCompositionRoundTripTests
Assert.Contains(diagnostics, diagnostic => diagnostic.Contains(expectedDiagnostic, StringComparison.Ordinal));
}
+ [Fact]
+ public void DisconnectedFinalMaterialIsRejectedByThreeDimensionalConnectivity()
+ {
+ var parsed = PrismaticProfileCompositionParser.Parse(File.ReadAllText(CompositionFixture(Path.Combine("invalid", "disconnected-final-material.firmament"))));
+ var stack = PrismaticSectionStackCompiler.Normalize(parsed, out var diagnostics);
+ Assert.NotNull(stack);
+ Assert.Empty(diagnostics);
+ var emitted = PrismaticSectionStackEmitter.Emit(stack);
+ Assert.Null(emitted.Body);
+ Assert.Contains(emitted.Diagnostics, diagnostic => diagnostic.StartsWith("compose-rejected:disconnected-3d-solid", StringComparison.Ordinal));
+ }
+
[Fact]
public void Ctc01Blockout_AllAuthoritativeFacesTessellateForM8()
{
diff --git a/Aetheris.Kernel.Firmament/Materializer/BezierSectionCurve2D.cs b/Aetheris.Kernel.Firmament/Materializer/BezierSectionCurve2D.cs
new file mode 100644
index 00000000..53a0ed31
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Materializer/BezierSectionCurve2D.cs
@@ -0,0 +1,170 @@
+namespace Aetheris.Kernel.Firmament.Materializer;
+
+/// <summary>Exact polynomial operations needed when a validated cubic profile becomes a section boundary.</summary>
+internal static class BezierSectionCurve2D
+{
+ internal readonly record struct Hit((double X,double Y) Point,double First,double Second,bool Tangent);
+ private static (double X, double Y) Mix((double X, double Y) a, (double X, double Y) b, double t) =>
+ (a.X + (b.X - a.X) * t, a.Y + (b.Y - a.Y) * t);
+
+ internal static (double X, double Y) At(LineArcCubicBezier2D c, double t)
+ {
+ var u = 1d - t;
+ return (u*u*u*c.Start.X + 3d*u*u*t*c.Control1.X + 3d*u*t*t*c.Control2.X + t*t*t*c.End.X,
+ u*u*u*c.Start.Y + 3d*u*u*t*c.Control1.Y + 3d*u*t*t*c.Control2.Y + t*t*t*c.End.Y);
+ }
+
+ internal static (double X, double Y) Tangent(LineArcCubicBezier2D c, double t)
+ {
+ var u = 1d - t;
+ return (3d*(u*u*(c.Control1.X-c.Start.X)+2d*u*t*(c.Control2.X-c.Control1.X)+t*t*(c.End.X-c.Control2.X)),
+ 3d*(u*u*(c.Control1.Y-c.Start.Y)+2d*u*t*(c.Control2.Y-c.Control1.Y)+t*t*(c.End.Y-c.Control2.Y)));
+ }
+
+ private static (LineArcCubicBezier2D Left, LineArcCubicBezier2D Right) Divide(LineArcCubicBezier2D c, double t)
+ {
+ var a = Mix(c.Start,c.Control1,t); var b = Mix(c.Control1,c.Control2,t); var d = Mix(c.Control2,c.End,t);
+ var e = Mix(a,b,t); var f = Mix(b,d,t); var p = Mix(e,f,t);
+ return (new(c.Start,a,e,p),new(p,f,d,c.End));
+ }
+
+ internal static LineArcCubicBezier2D Trim(LineArcCubicBezier2D c, double from, double to)
+ {
+ if (from > 0d) c = Divide(c,from).Right;
+ if (to < 1d) c = Divide(c,(to-from)/(1d-from)).Left;
+ return c;
+ }
+
+ /// <summary>Green's theorem integral of x dy - y dx, evaluated on polynomial coefficients.</summary>
+ internal static double SignedDoubleArea(LineArcCubicBezier2D c)
+ {
+ var x = new[] { c.Start.X, 3d*(c.Control1.X-c.Start.X), 3d*(c.Start.X-2d*c.Control1.X+c.Control2.X), -c.Start.X+3d*c.Control1.X-3d*c.Control2.X+c.End.X };
+ var y = new[] { c.Start.Y, 3d*(c.Control1.Y-c.Start.Y), 3d*(c.Start.Y-2d*c.Control1.Y+c.Control2.Y), -c.Start.Y+3d*c.Control1.Y-3d*c.Control2.Y+c.End.Y };
+ var area = 0d;
+ for (var i=0;i<4;i++) for (var j=1;j<4;j++) area += j*(x[i]*y[j]-y[i]*x[j])/(i+j);
+ return area;
+ }
+
+ private static double[] YStationary(LineArcCubicBezier2D c)
+ {
+ var a = -c.Start.Y+3d*c.Control1.Y-3d*c.Control2.Y+c.End.Y;
+ var b = 3d*c.Start.Y-6d*c.Control1.Y+3d*c.Control2.Y;
+ var d = -3d*c.Start.Y+3d*c.Control1.Y;
+ var roots = new List<double> { 0d, 1d };
+ if (Math.Abs(a)<1e-15) { if (Math.Abs(b)>1e-15) roots.Add(-d/(2d*b)); }
+ else { var discriminant=b*b-3d*a*d; if (discriminant>=0d) { var root=Math.Sqrt(discriminant); roots.Add((-b-root)/(3d*a)); roots.Add((-b+root)/(3d*a)); } }
+ return roots.Where(t=>t>=0d && t<=1d).Distinct().Order().ToArray();
+ }
+
+ internal static int RayCrossings(LineArcCubicBezier2D c, (double X,double Y) point, double tol)
+ {
+ var roots=YStationary(c); var count=0;
+ for (var i=0;i<roots.Length-1;i++)
+ {
+ var lo=roots[i]; var hi=roots[i+1]; var y0=At(c,lo).Y; var y1=At(c,hi).Y;
+ if (Math.Abs(y1-y0)<1e-14 || point.Y<Math.Min(y0,y1) || point.Y>=Math.Max(y0,y1)) continue;
+ for (var n=0;n<52;n++) { var mid=(lo+hi)/2d; if ((At(c,mid).Y<point.Y)==(y1>y0)) lo=mid; else hi=mid; }
+ if (At(c,(lo+hi)/2d).X>point.X+tol) count++;
+ }
+ return count;
+ }
+
+ internal static bool OnCurve(LineArcCubicBezier2D c, (double X,double Y) point, double tol, out double parameter)
+ {
+ parameter=0d; var best=double.PositiveInfinity;
+ // A closest-point seed is refined on the exact polynomial. Sampling is used only to locate a parameter,
+ // never to replace curve authority or to declare a distant point on the boundary.
+ for (var i=0;i<=32;i++)
+ {
+ var t=i/32d; var p=At(c,t); var d=(p.X-point.X)*(p.X-point.X)+(p.Y-point.Y)*(p.Y-point.Y);
+ if (d<best) { best=d; parameter=t; }
+ }
+ for (var i=0;i<16;i++)
+ {
+ var p=At(c,parameter); var tangent=Tangent(c,parameter); var denominator=tangent.X*tangent.X+tangent.Y*tangent.Y;
+ if (denominator<1e-25) break;
+ var next=Math.Clamp(parameter+((point.X-p.X)*tangent.X+(point.Y-p.Y)*tangent.Y)/denominator,0d,1d);
+ if (Math.Abs(next-parameter)<1e-15) break;
+ parameter=next;
+ }
+ var final=At(c,parameter);
+ return Math.Sqrt((final.X-point.X)*(final.X-point.X)+(final.Y-point.Y)*(final.Y-point.Y))<=tol;
+ }
+
+ private static (double X,double Y) At(LineArcProfileCurve2D c,double t) => c switch
+ {
+ LineArcLineSegment2D l => Mix(l.Start,l.End,t),
+ LineArcCircularArc2D a => (a.Center.X+a.Radius*Math.Cos(a.StartAngleRadians+a.SweepAngleRadians*t),a.Center.Y+a.Radius*Math.Sin(a.StartAngleRadians+a.SweepAngleRadians*t)),
+ LineArcCubicBezier2D b => At(b,t),
+ _ => throw new NotSupportedException($"Unsupported section boundary: {c.GetType().Name}")
+ };
+
+ private static (double X,double Y) Tangent(LineArcProfileCurve2D c,double t) => c switch
+ {
+ LineArcLineSegment2D l => (l.End.X-l.Start.X,l.End.Y-l.Start.Y),
+ LineArcCircularArc2D a => (-a.Radius*a.SweepAngleRadians*Math.Sin(a.StartAngleRadians+a.SweepAngleRadians*t),a.Radius*a.SweepAngleRadians*Math.Cos(a.StartAngleRadians+a.SweepAngleRadians*t)),
+ LineArcCubicBezier2D b => Tangent(b,t),
+ _ => throw new NotSupportedException($"Unsupported section boundary: {c.GetType().Name}")
+ };
+
+ private static (double MinX,double MaxX,double MinY,double MaxY) Bounds(LineArcProfileCurve2D c,double from,double to)
+ {
+ (double X,double Y)[] points;
+ if (c is LineArcCubicBezier2D b)
+ {
+ var part=Trim(b,from,to); points=[part.Start,part.Control1,part.Control2,part.End];
+ }
+ else if (c is LineArcCircularArc2D a)
+ {
+ var start=a.StartAngleRadians+a.SweepAngleRadians*from;
+ var end=a.StartAngleRadians+a.SweepAngleRadians*to;
+ var low=Math.Min(start,end); var high=Math.Max(start,end);
+ var candidates=new List<double> { start,end };
+ for (var k=(int)Math.Ceiling(low/(Math.PI/2d));k<=Math.Floor(high/(Math.PI/2d));k++) candidates.Add(k*Math.PI/2d);
+ points=candidates.Select(angle=>(a.Center.X+a.Radius*Math.Cos(angle),a.Center.Y+a.Radius*Math.Sin(angle))).ToArray();
+ }
+ else points=[At(c,from),At(c,to)];
+ return (points.Min(p=>p.X),points.Max(p=>p.X),points.Min(p=>p.Y),points.Max(p=>p.Y));
+ }
+
+ /// <summary>Bounded candidate search by exact convex-hull/arc boxes, then polynomial/analytic parameter refinement.</summary>
+ internal static IReadOnlyList<Hit> Intersections(LineArcProfileCurve2D first,LineArcProfileCurve2D second,double tol)
+ {
+ var hits=new List<Hit>();
+ void Add(double t,double u)
+ {
+ for (var i=0;i<18;i++)
+ {
+ var a=At(first,t); var b=At(second,u); var da=Tangent(first,t); var db=Tangent(second,u);
+ var determinant=da.X*db.Y-da.Y*db.X;
+ if (Math.Abs(determinant)<1e-17) break;
+ var dx=b.X-a.X; var dy=b.Y-a.Y;
+ var dt=(dx*db.Y-dy*db.X)/determinant;
+ var du=(dx*da.Y-dy*da.X)/determinant;
+ t=Math.Clamp(t+dt,0d,1d);u=Math.Clamp(u+du,0d,1d);
+ if (Math.Abs(dt)+Math.Abs(du)<1e-14) break;
+ }
+ var pa=At(first,t);var pb=At(second,u);
+ if (Math.Sqrt((pa.X-pb.X)*(pa.X-pb.X)+(pa.Y-pb.Y)*(pa.Y-pb.Y))>tol) return;
+ if (hits.Any(h=>Math.Abs(h.First-t)<1e-6 && Math.Abs(h.Second-u)<1e-6)) return;
+ var ta=Tangent(first,t);var tb=Tangent(second,u);
+ hits.Add(new(((pa.X+pb.X)/2d,(pa.Y+pb.Y)/2d),t,u,Math.Abs(ta.X*tb.Y-ta.Y*tb.X)<1e-10));
+ }
+ foreach (var t in new[] {0d,1d}) foreach(var u in new[] {0d,1d})
+ {
+ var a=At(first,t);var b=At(second,u);
+ if (Math.Sqrt((a.X-b.X)*(a.X-b.X)+(a.Y-b.Y)*(a.Y-b.Y))<=tol) Add(t,u);
+ }
+ void Search(double a0,double a1,double b0,double b1,int depth)
+ {
+ var a=Bounds(first,a0,a1);var b=Bounds(second,b0,b1);
+ if (a.MinX>b.MaxX+tol || b.MinX>a.MaxX+tol || a.MinY>b.MaxY+tol || b.MinY>a.MaxY+tol) return;
+ var aw=Math.Max(a.MaxX-a.MinX,a.MaxY-a.MinY);var bw=Math.Max(b.MaxX-b.MinX,b.MaxY-b.MinY);
+ if (Math.Max(aw,bw)<=tol/2d || depth>=48) { Add((a0+a1)/2d,(b0+b1)/2d);return; }
+ if (aw>=bw) { var mid=(a0+a1)/2d;Search(a0,mid,b0,b1,depth+1);Search(mid,a1,b0,b1,depth+1); }
+ else { var mid=(b0+b1)/2d;Search(a0,a1,b0,mid,depth+1);Search(a0,a1,mid,b1,depth+1); }
+ }
+ Search(0d,1d,0d,1d,0);
+ return hits.OrderBy(h=>h.First).ThenBy(h=>h.Second).ToArray();
+ }
+}
diff --git a/Aetheris.Kernel.Firmament/Materializer/HexBoltThreadStitch.cs b/Aetheris.Kernel.Firmament/Materializer/HexBoltThreadStitch.cs
index 8d81ed78..70d7bc72 100644
--- a/Aetheris.Kernel.Firmament/Materializer/HexBoltThreadStitch.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/HexBoltThreadStitch.cs
@@ -20,6 +20,43 @@ internal static class HexBoltThreadStitch
IReadOnlyDictionary<FaceId, FaceId> ThreadFaces,
IReadOnlyDictionary<EdgeId, EdgeId> ThreadEdges);
+ /// <summary>Replaces only the planar head cap with section-stack pocket faces.</summary>
+ internal static BrepBody ImprintTop(BrepBody threaded, FaceId topCap,
+ BrepBody patch, IReadOnlyCollection<FaceId> patchFaces)
+ {
+ var retained = threaded.Topology.Faces.Where(face => face.Id != topCap).Select(face => face.Id).ToArray();
+ var shell = new ShellCopy();
+ var copied = shell.CopyFaces(threaded, retained);
+ var hostRim = EdgesOfFaces(threaded, [topCap]).Distinct().ToArray();
+ var patchRim = EdgesOfFaces(patch, patchFaces).Distinct()
+ .Where(edge => hostRim.Any(host => SameEdge(threaded, host, patch, edge))).ToArray();
+ if (patchRim.Length != hostRim.Length)
+ throw new InvalidOperationException($"Maker mark rim mismatch: patch={patchRim.Length}, head={hostRim.Length}.");
+ var shared = patchRim.ToDictionary(edge => edge,
+ edge => copied.Edges[hostRim.Single(host => SameEdge(threaded, host, patch, edge))]);
+ shell.CopyFaces(patch, patchFaces, shared);
+ var body = shell.Complete();
+ var nonManifold = body.Topology.Coedges.GroupBy(x => x.EdgeId).Where(x => x.Count() != 2).ToArray();
+ if (nonManifold.Length != 0)
+ throw new InvalidOperationException($"Maker mark shell has {nonManifold.Length} non-manifold edges.");
+ var mass = BrepMassProperties.Evaluate(body);
+ if (!mass.IsEnclosed || !mass.IsOrientationConsistent)
+ throw new InvalidOperationException("Maker mark shell is not enclosed and oriented: " + string.Join(" | ", mass.Diagnostics));
+ return body;
+ }
+
+ private static bool SameEdge(BrepBody firstBody, EdgeId firstId, BrepBody secondBody, EdgeId secondId)
+ {
+ var first = firstBody.Topology.GetEdge(firstId);
+ var second = secondBody.Topology.GetEdge(secondId);
+ firstBody.TryGetVertexPoint(first.StartVertexId, out var a);
+ firstBody.TryGetVertexPoint(first.EndVertexId, out var b);
+ secondBody.TryGetVertexPoint(second.StartVertexId, out var c);
+ secondBody.TryGetVertexPoint(second.EndVertexId, out var d);
+ static bool Near(Point3D x, Point3D y) => (x - y).Length < 1e-5d;
+ return (Near(a, c) && Near(b, d)) || (Near(a, d) && Near(b, c));
+ }
+
internal static Result Create(HexBoltDefinition bolt, BrepHelicalRibResult rib)
{
var shank = bolt.Semantics.Descendants
@@ -96,10 +133,12 @@ internal static class HexBoltThreadStitch
internal sealed record CopyMap(IReadOnlyDictionary<FaceId, FaceId> Faces, IReadOnlyDictionary<EdgeId, EdgeId> Edges);
- internal CopyMap CopyFaces(BrepBody source, IReadOnlyCollection<FaceId> retained)
+ internal CopyMap CopyFaces(BrepBody source, IReadOnlyCollection<FaceId> retained,
+ IReadOnlyDictionary<EdgeId, EdgeId>? sharedEdges = null)
{
var vertexMap = new Dictionary<VertexId, VertexId>();
var edgeMap = new Dictionary<EdgeId, EdgeId>();
+ var reversedShared = new HashSet<EdgeId>();
var curveMap = new Dictionary<CurveGeometryId, CurveGeometryId>();
var surfaceMap = new Dictionary<SurfaceGeometryId, SurfaceGeometryId>();
var faceMap = new Dictionary<FaceId, FaceId>();
@@ -118,6 +157,15 @@ internal static class HexBoltThreadStitch
{
if (edgeMap.TryGetValue(old, out var mapped)) return mapped;
var edge = source.Topology.GetEdge(old);
+ if (sharedEdges is not null && sharedEdges.TryGetValue(old, out mapped))
+ {
+ edgeMap.Add(old, mapped);
+ source.TryGetVertexPoint(edge.StartVertexId, out var oldStart);
+ var mappedEdge = topology.Model.GetEdge(mapped);
+ if ((oldStart - points[mappedEdge.StartVertexId]).Length > 1e-5d)
+ reversedShared.Add(old);
+ return mapped;
+ }
mapped = topology.AddEdge(Vertex(edge.StartVertexId), Vertex(edge.EndVertexId));
edgeMap.Add(old, mapped);
var binding = source.Bindings.GetEdgeBinding(old);
@@ -157,7 +205,7 @@ internal static class HexBoltThreadStitch
var oldCoedge = source.Topology.GetCoedge(loop.CoedgeIds[i]);
topology.AddCoedge(new Coedge(coedgeIds[i], Edge(oldCoedge.EdgeId), loopId,
coedgeIds[(i + 1) % coedgeIds.Length], coedgeIds[(i + coedgeIds.Length - 1) % coedgeIds.Length],
- oldCoedge.IsReversed));
+ oldCoedge.IsReversed ^ reversedShared.Contains(oldCoedge.EdgeId)));
oldToNewCoedges.Add(oldCoedge.Id, coedgeIds[i]);
}
topology.AddLoop(new Loop(loopId, coedgeIds));
diff --git a/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs b/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs
index d352039c..e0c829b3 100644
--- a/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs
@@ -149,7 +149,11 @@ public sealed record PrismaticSectionRegion(
ResolvedProfile2D Outer, IReadOnlyList<ResolvedProfile2D> Holes, IReadOnlyList<string> Provenance);
public sealed record PrismaticSectionSlab(
double From, double To, PrismaticSectionRegion Region, IReadOnlyList<string> ActiveOperations,
- ProfileArrangement2D? Arrangement = null);
+ ProfileArrangement2D? Arrangement = null,
+ IReadOnlyList<PrismaticSectionRegion>? RegionSet = null)
+{
+ public IReadOnlyList<PrismaticSectionRegion> MaterialRegions => RegionSet ?? [Region];
+}
public sealed record PrismaticSectionTransition(
double Level, IReadOnlyList<PrismaticSectionRegion> UpwardRegions, IReadOnlyList<PrismaticSectionRegion> DownwardRegions);
public sealed record PrismaticSectionStackConstruction(
@@ -849,20 +853,20 @@ public static class PrismaticProfileCompositionParser
private static bool HasConnectedBossSupport(PrismaticProfileOperation stock, ResolvedProfile2D boss, IReadOnlyDictionary<string, ResolvedProfile2D> profiles)
{
var probe = ProfileArrangementBuilder.Compose("XY", [stock with { From = 0d, To = 1d }, new("BossSupportProbe", PrismaticProfileIntent.Add, boss.Name, 0d, 1d, "Boss", "generated")], profiles, "boss-connectivity-probe");
- if (probe.Region is null || probe.Arrangement.Diagnostics.Count > 0) return false;
+ if (probe.MaterialRegions.Count == 0 || probe.Arrangement.Diagnostics.Count > 0) return false;
var stockArea = Math.Abs(PrismaticSectionStackCompiler.ProfileArea(profiles[stock.ProfileReference]));
var bossArea = Math.Abs(PrismaticSectionStackCompiler.ProfileArea(boss));
- var overlapArea = stockArea + bossArea - PrismaticSectionStackCompiler.Area(probe.Region);
+ var overlapArea = stockArea + bossArea - probe.MaterialRegions.Sum(PrismaticSectionStackCompiler.Area);
return overlapArea > Math.Max(1e-7d, Math.Min(stockArea, bossArea) * 1e-8d);
}
private static bool IsPocketFootprintInsideStock(PrismaticProfileOperation stock, ResolvedProfile2D pocket, IReadOnlyDictionary<string, ResolvedProfile2D> profiles)
{
var probe = ProfileArrangementBuilder.Compose("XY", [stock with { From = 0d, To = 1d }, new("PocketContainmentProbe", PrismaticProfileIntent.Remove, pocket.Name, 0d, 1d, "Pocket", "generated")], profiles, "pocket-containment-probe");
- if (probe.Region is null || probe.Arrangement.Diagnostics.Count > 0 || probe.Region.Holes.Count == 0) return false;
+ if (probe.MaterialRegions.Count == 0 || probe.Arrangement.Diagnostics.Count > 0) return false;
var stockArea = Math.Abs(PrismaticSectionStackCompiler.ProfileArea(profiles[stock.ProfileReference]));
var pocketArea = Math.Abs(PrismaticSectionStackCompiler.ProfileArea(pocket));
- var retainedArea = PrismaticSectionStackCompiler.Area(probe.Region);
+ var retainedArea = probe.MaterialRegions.Sum(PrismaticSectionStackCompiler.Area);
return Math.Abs((stockArea - retainedArea) - pocketArea) <= Math.Max(1e-7d, pocketArea * 1e-8d);
}
diff --git a/Aetheris.Kernel.Firmament/Materializer/PrismaticSectionStackCompiler.cs b/Aetheris.Kernel.Firmament/Materializer/PrismaticSectionStackCompiler.cs
index 14468cb6..023c19de 100644
--- a/Aetheris.Kernel.Firmament/Materializer/PrismaticSectionStackCompiler.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/PrismaticSectionStackCompiler.cs
@@ -94,7 +94,7 @@ public static class PrismaticSectionStackCompiler
if (active.Length == 0) continue;
var arrangement = ProfileArrangementBuilder.Compose(parsed.Feature.Frame, active, parsed.Profiles, $"slab=({pair.First:R},{pair.Second:R})");
d.AddRange(arrangement.Arrangement.Diagnostics);
- if (arrangement.Region is not null) slabs.Add(new(pair.First, pair.Second, arrangement.Region, active.Select(x => x.Name).Order().ToArray(), arrangement.Arrangement));
+ if (arrangement.MaterialRegions.Count > 0) slabs.Add(new(pair.First, pair.Second, arrangement.MaterialRegions[0], active.Select(x => x.Name).Order().ToArray(), arrangement.Arrangement, arrangement.MaterialRegions));
}
// An empty stack is usually the consequence of a rejected arrangement, which has already said why; reporting
// the consequence as well used to make it the last and most visible line.
@@ -102,8 +102,8 @@ public static class PrismaticSectionStackCompiler
var transitions = new List<PrismaticSectionTransition>();
foreach (var level in parsed.Feature.CriticalLevels)
{
- var below = slabs.SingleOrDefault(s => Math.Abs(s.To - level) < Tol)?.Region;
- var above = slabs.SingleOrDefault(s => Math.Abs(s.From - level) < Tol)?.Region;
+ var below = slabs.SingleOrDefault(s => Math.Abs(s.To - level) < Tol)?.MaterialRegions ?? [];
+ var above = slabs.SingleOrDefault(s => Math.Abs(s.From - level) < Tol)?.MaterialRegions ?? [];
var upwardResult = ProfileArrangementBuilder.Difference(parsed.Feature.Frame, below, above, $"transition={level:R}:below-minus-above");
var downwardResult = ProfileArrangementBuilder.Difference(parsed.Feature.Frame, above, below, $"transition={level:R}:above-minus-below");
d.AddRange(upwardResult.Arrangement.Diagnostics);
@@ -112,7 +112,7 @@ public static class PrismaticSectionStackCompiler
var downward = downwardResult.MaterialRegions;
if (upward.Count > 0 || downward.Count > 0) transitions.Add(new(level, upward, downward));
}
- var volume = slabs.Sum(s => Area(s.Region) * (s.To - s.From));
+ var volume = slabs.Sum(s => s.MaterialRegions.Sum(Area) * (s.To - s.From));
diagnostics = d.Distinct().ToArray();
return d.Any(x => x.Contains("rejected", StringComparison.Ordinal))
? null
@@ -131,7 +131,8 @@ public static class PrismaticSectionStackCompiler
LineArcCircularArc2D arc => ArcArea(arc),
LineArcFullCircle2D circle => 2d * Math.PI * circle.Radius * circle.Radius,
LineArcFullEllipse2D ellipse => 2d * Math.PI * ellipse.MajorRadius * ellipse.MinorRadius,
- _ => 0d
+ LineArcCubicBezier2D cubic => BezierSectionCurve2D.SignedDoubleArea(cubic),
+ _ => throw new NotSupportedException($"Unsupported section boundary: {curve.GetType().Name}")
};
return sum / 2d;
}
@@ -173,7 +174,7 @@ public static class PrismaticSectionStackEmitter
d.AddRange(VariableOuterSectionIntervalValidator.Validate(interval).Diagnostics);
if (d.Any(x => x.StartsWith("VariableOuterSectionInterval", StringComparison.Ordinal)))
return new(null, d.Distinct().ToArray());
- var splitPoints = stack.Slabs.SelectMany(s => Loops(s.Region)).Concat(stack.Transitions.SelectMany(t =>
+ var splitPoints = stack.Slabs.SelectMany(s => s.MaterialRegions.SelectMany(Loops)).Concat(stack.Transitions.SelectMany(t =>
t.UpwardRegions.Concat(t.DownwardRegions).SelectMany(Loops)))
.SelectMany(x => x.Profile.Loops[0].Segments).Concat(variableIntervals.SelectMany(v => v.LowerOuter.Loops.Concat(v.UpperOuter.Loops).Concat(v.InnerLoops.SelectMany(i => i.LowerLoop.Loops))).SelectMany(x => x.Segments))
.SelectMany(x => Ends(x.Geometry)).DistinctBy(p => $"{Math.Round(p.X / Tol):F0},{Math.Round(p.Y / Tol):F0}").ToArray();
@@ -200,7 +201,7 @@ public static class PrismaticSectionStackEmitter
curves[created] = CurveGeometry.FromLine(new Line3Curve(points[Vertex(from, lower)], Direction3D.Create(points[Vertex(to, upper)] - points[Vertex(from, lower)]))); return (created, false);
}
foreach (var slab in stack.Slabs)
- foreach (var item in Loops(slab.Region))
+ foreach (var item in slab.MaterialRegions.SelectMany(Loops))
foreach (var segment in item.Profile.Loops[0].Segments)
foreach (var curve in Split(segment.Geometry, splitPoints))
{
@@ -256,6 +257,32 @@ public static class PrismaticSectionStackEmitter
var a = points[edge.StartVertexId]; var b = points[edge.EndVertexId];
d.Add($"compose-rejected:non-manifold-edge-use:edge={incidence.Key.Value}:uses={incidence.Count()}:curve={curves[incidence.Key].Kind}:from=({a.X:R},{a.Y:R},{a.Z:R}):to=({b.X:R},{b.Y:R},{b.Z:R})");
}
+ // Sections may have many material islands; only the completed shell must
+ // be connected. Shared topological edges link faces through slab floors.
+ var edgeFaces = builder.Model.Faces.SelectMany(face => face.LoopIds.SelectMany(loopId =>
+ builder.Model.Loops.Single(loop => loop.Id == loopId).CoedgeIds.Select(coedgeId =>
+ (Edge: builder.Model.Coedges.Single(coedge => coedge.Id == coedgeId).EdgeId, Face: face.Id))))
+ .GroupBy(x => x.Edge).ToDictionary(x => x.Key, x => x.Select(y => y.Face).Distinct().ToArray());
+ var neighbours = faces.ToDictionary(face => face, _ => new HashSet<FaceId>());
+ foreach (var incident in edgeFaces.Values)
+ foreach (var first in incident)
+ foreach (var second in incident)
+ if (first != second) neighbours[first].Add(second);
+ var unseen = faces.ToHashSet();
+ var components = 0;
+ while (unseen.Count > 0)
+ {
+ components++;
+ var queue = new Queue<FaceId>(); var seed = unseen.First(); unseen.Remove(seed); queue.Enqueue(seed);
+ while (queue.TryDequeue(out var face))
+ foreach (var next in neighbours[face])
+ if (unseen.Remove(next)) queue.Enqueue(next);
+ }
+ if (components != 1)
+ {
+ d.Add($"compose-rejected:disconnected-3d-solid:components={components}");
+ return new(null, d.Distinct().ToArray());
+ }
var descendants = new List<SemanticTopologyDescendant>();
var topLevels = stack.Feature.Operations.GroupBy(x => x.ProfileReference, StringComparer.Ordinal).ToDictionary(x => x.Key, x => x.Max(y => y.To), StringComparer.Ordinal);
var bottomLevels = stack.Feature.Operations.GroupBy(x => x.ProfileReference, StringComparer.Ordinal).ToDictionary(x => x.Key, x => x.Min(y => y.From), StringComparer.Ordinal);
@@ -412,7 +439,7 @@ public static class PrismaticSectionStackEmitter
return builder.AddFace(loops);
}
private static IEnumerable<(ResolvedProfile2D Profile, bool IsHole)> Loops(PrismaticSectionRegion region) { yield return (region.Outer, false); foreach (var h in region.Holes) yield return (h, true); }
- private static (double X, double Y)[] Ends(LineArcProfileCurve2D curve) => curve switch { LineArcLineSegment2D l => [l.Start, l.End], LineArcCircularArc2D a => [(a.Center.X + a.Radius * Math.Cos(a.StartAngleRadians), a.Center.Y + a.Radius * Math.Sin(a.StartAngleRadians)), (a.Center.X + a.Radius * Math.Cos(a.StartAngleRadians + a.SweepAngleRadians), a.Center.Y + a.Radius * Math.Sin(a.StartAngleRadians + a.SweepAngleRadians))], _ => throw new NotSupportedException("X1 composition requires bounded line/arc segments.") };
+ private static (double X, double Y)[] Ends(LineArcProfileCurve2D curve) => curve switch { LineArcLineSegment2D l => [l.Start, l.End], LineArcCircularArc2D a => [(a.Center.X + a.Radius * Math.Cos(a.StartAngleRadians), a.Center.Y + a.Radius * Math.Sin(a.StartAngleRadians)), (a.Center.X + a.Radius * Math.Cos(a.StartAngleRadians + a.SweepAngleRadians), a.Center.Y + a.Radius * Math.Sin(a.StartAngleRadians + a.SweepAngleRadians))], LineArcCubicBezier2D c => [c.Start, c.End], _ => throw new NotSupportedException($"Unsupported section boundary: {curve.GetType().Name}") };
private static IEnumerable<LineArcProfileCurve2D> Split(LineArcProfileCurve2D curve, IReadOnlyList<(double X, double Y)> points)
{
var parameters = points.Select(p => Parameter(curve, p)).Where(x => x is not null).Select(x => x!.Value).Append(0d).Append(1d).Order().Aggregate(new List<double>(), (list, value) => { if (list.Count == 0 || Math.Abs(list[^1] - value) > Tol) list.Add(value); return list; });
@@ -422,10 +449,11 @@ public static class PrismaticSectionStackEmitter
{
if (curve is LineArcLineSegment2D line) { var dx = line.End.X - line.Start.X; var dy = line.End.Y - line.Start.Y; var length2 = dx * dx + dy * dy; var t = ((p.X - line.Start.X) * dx + (p.Y - line.Start.Y) * dy) / length2; return t >= -Tol && t <= 1d + Tol && Math.Abs((line.Start.X + t * dx - p.X)) <= Tol && Math.Abs((line.Start.Y + t * dy - p.Y)) <= Tol ? Math.Clamp(t, 0d, 1d) : null; }
if (curve is LineArcCircularArc2D arc) { if (Math.Abs(Math.Sqrt((p.X - arc.Center.X) * (p.X - arc.Center.X) + (p.Y - arc.Center.Y) * (p.Y - arc.Center.Y)) - arc.Radius) > Tol) return null; var delta = Math.Atan2(p.Y - arc.Center.Y, p.X - arc.Center.X) - arc.StartAngleRadians; if (arc.SweepAngleRadians >= 0d) while (delta < 0d) delta += 2d * Math.PI; else while (delta > 0d) delta -= 2d * Math.PI; var t = delta / arc.SweepAngleRadians; return t >= -Tol && t <= 1d + Tol ? Math.Clamp(t, 0d, 1d) : null; }
+ if (curve is LineArcCubicBezier2D cubic && BezierSectionCurve2D.OnCurve(cubic, p, Tol, out var parameter)) return parameter;
return null;
}
- private static LineArcProfileCurve2D Trim(LineArcProfileCurve2D curve, double from, double to) => curve switch { LineArcLineSegment2D line => new LineArcLineSegment2D((line.Start.X + (line.End.X - line.Start.X) * from, line.Start.Y + (line.End.Y - line.Start.Y) * from), (line.Start.X + (line.End.X - line.Start.X) * to, line.Start.Y + (line.End.Y - line.Start.Y) * to)), LineArcCircularArc2D arc => new LineArcCircularArc2D(arc.Center, arc.Radius, arc.StartAngleRadians + arc.SweepAngleRadians * from, arc.SweepAngleRadians * (to - from)), _ => throw new NotSupportedException() };
- private static LineArcProfileCurve2D Reverse(LineArcProfileCurve2D curve) => curve switch { LineArcLineSegment2D line => new LineArcLineSegment2D(line.End, line.Start), LineArcCircularArc2D arc => new LineArcCircularArc2D(arc.Center, arc.Radius, arc.StartAngleRadians + arc.SweepAngleRadians, -arc.SweepAngleRadians), _ => throw new NotSupportedException() };
+ private static LineArcProfileCurve2D Trim(LineArcProfileCurve2D curve, double from, double to) => curve switch { LineArcLineSegment2D line => new LineArcLineSegment2D((line.Start.X + (line.End.X - line.Start.X) * from, line.Start.Y + (line.End.Y - line.Start.Y) * from), (line.Start.X + (line.End.X - line.Start.X) * to, line.Start.Y + (line.End.Y - line.Start.Y) * to)), LineArcCircularArc2D arc => new LineArcCircularArc2D(arc.Center, arc.Radius, arc.StartAngleRadians + arc.SweepAngleRadians * from, arc.SweepAngleRadians * (to - from)), LineArcCubicBezier2D c => BezierSectionCurve2D.Trim(c, from, to), _ => throw new NotSupportedException() };
+ private static LineArcProfileCurve2D Reverse(LineArcProfileCurve2D curve) => curve switch { LineArcLineSegment2D line => new LineArcLineSegment2D(line.End, line.Start), LineArcCircularArc2D arc => new LineArcCircularArc2D(arc.Center, arc.Radius, arc.StartAngleRadians + arc.SweepAngleRadians, -arc.SweepAngleRadians), LineArcCubicBezier2D c => new LineArcCubicBezier2D(c.End, c.Control2, c.Control1, c.Start), _ => throw new NotSupportedException() };
private static string CurveKey(LineArcProfileCurve2D curve, double z, (double X, double Y) a, (double X, double Y) b) => curve switch
{
LineArcLineSegment2D => $"L:{P(a)}:{P(b)}:{Q(z)}",
@@ -433,6 +461,7 @@ public static class PrismaticSectionStackEmitter
// semicircles share the same unordered endpoint pair. Include the exact
// domain midpoint so distinct cut-loop arcs never collapse to one edge.
LineArcCircularArc2D arc => $"A:{P(arc.Center)}:{Q(arc.Radius)}:{P(a)}:{P(b)}:{P((arc.Center.X+arc.Radius*Math.Cos(arc.StartAngleRadians+arc.SweepAngleRadians*.5d),arc.Center.Y+arc.Radius*Math.Sin(arc.StartAngleRadians+arc.SweepAngleRadians*.5d)))}:{Q(z)}",
+ LineArcCubicBezier2D c => $"B:{P(a)}:{P(c.Control1)}:{P(c.Control2)}:{P(b)}:{Q(z)}",
_ => throw new NotSupportedException()
};
private static string P((double X, double Y) point) => $"{Q(point.X)},{Q(point.Y)}";
@@ -448,20 +477,23 @@ public static class PrismaticSectionStackEmitter
LineArcLineSegment2D line => (new ParameterInterval(0d, Math.Sqrt((line.End.X - line.Start.X) * (line.End.X - line.Start.X) + (line.End.Y - line.Start.Y) * (line.End.Y - line.Start.Y))), true),
LineArcCircularArc2D arc when arc.SweepAngleRadians >= 0d => (new ParameterInterval(arc.StartAngleRadians, arc.StartAngleRadians + arc.SweepAngleRadians), true),
LineArcCircularArc2D arc => (new ParameterInterval(arc.StartAngleRadians + arc.SweepAngleRadians, arc.StartAngleRadians), false),
+ LineArcCubicBezier2D => (new ParameterInterval(0d, 1d), true),
_ => throw new NotSupportedException()
};
- private static CurveGeometry Curve(LineArcProfileCurve2D curve, double z) => curve switch { LineArcLineSegment2D l => CurveGeometry.FromLine(new Line3Curve(new Point3D(l.Start.X, l.Start.Y, z), Direction3D.Create(new Vector3D(l.End.X - l.Start.X, l.End.Y - l.Start.Y, 0)))), LineArcCircularArc2D a => CurveGeometry.FromCircle(new Circle3Curve(new Point3D(a.Center.X, a.Center.Y, z), Direction3D.Create(new Vector3D(0, 0, 1)), a.Radius, Direction3D.Create(new Vector3D(1, 0, 0)))), _ => throw new NotSupportedException() };
- private static SurfaceGeometry SideSurface(LineArcProfileCurve2D curve, double z, bool hole) => curve switch { LineArcLineSegment2D l => SurfaceGeometry.FromPlane(new PlaneSurface(new Point3D(l.Start.X, l.Start.Y, z), Direction3D.Create(new Vector3D(hole ? l.Start.Y - l.End.Y : l.End.Y - l.Start.Y, hole ? l.End.X - l.Start.X : l.Start.X - l.End.X, 0)), Direction3D.Create(new Vector3D(0, 0, 1)))), LineArcCircularArc2D a => SurfaceGeometry.FromCylinder(new CylinderSurface(new Point3D(a.Center.X, a.Center.Y, z), Direction3D.Create(new Vector3D(0, 0, 1)), a.Radius, Direction3D.Create(new Vector3D(1, 0, 0)))), _ => throw new NotSupportedException() };
+ private static CurveGeometry Curve(LineArcProfileCurve2D curve, double z) => curve switch { LineArcLineSegment2D l => CurveGeometry.FromLine(new Line3Curve(new Point3D(l.Start.X, l.Start.Y, z), Direction3D.Create(new Vector3D(l.End.X - l.Start.X, l.End.Y - l.Start.Y, 0)))), LineArcCircularArc2D a => CurveGeometry.FromCircle(new Circle3Curve(new Point3D(a.Center.X, a.Center.Y, z), Direction3D.Create(new Vector3D(0, 0, 1)), a.Radius, Direction3D.Create(new Vector3D(1, 0, 0)))), LineArcCubicBezier2D c => CurveGeometry.FromBSpline(new BSpline3Curve(3, [new(c.Start.X,c.Start.Y,z),new(c.Control1.X,c.Control1.Y,z),new(c.Control2.X,c.Control2.Y,z),new(c.End.X,c.End.Y,z)], [4,4], [0d,1d], "UNSPECIFIED", false, false, "PIECEWISE_BEZIER_KNOTS")), _ => throw new NotSupportedException() };
+ private static SurfaceGeometry SideSurface(LineArcProfileCurve2D curve, double z, bool hole) => curve switch { LineArcLineSegment2D l => SurfaceGeometry.FromPlane(new PlaneSurface(new Point3D(l.Start.X, l.Start.Y, z), Direction3D.Create(new Vector3D(hole ? l.Start.Y - l.End.Y : l.End.Y - l.Start.Y, hole ? l.End.X - l.Start.X : l.Start.X - l.End.X, 0)), Direction3D.Create(new Vector3D(0, 0, 1)))), LineArcCircularArc2D a => SurfaceGeometry.FromCylinder(new CylinderSurface(new Point3D(a.Center.X, a.Center.Y, z), Direction3D.Create(new Vector3D(0, 0, 1)), a.Radius, Direction3D.Create(new Vector3D(1, 0, 0)))), LineArcCubicBezier2D => SurfaceGeometry.FromLinearExtrusion(new LinearExtrusionSurface(Curve(curve,z),new Vector3D(0,0,1))), _ => throw new NotSupportedException() };
private static CurveGeometry Transform(CurveGeometry curve, ConstructionPlane frame) => curve.Kind switch
{
CurveGeometryKind.Line3 => CurveGeometry.FromLine(new Line3Curve(frame.ToWorld((curve.Line3!.Value.Origin.X, curve.Line3.Value.Origin.Y), curve.Line3.Value.Origin.Z), Direction3D.Create(frame.ToWorldDirection(curve.Line3.Value.Direction.ToVector())))),
CurveGeometryKind.Circle3 => CurveGeometry.FromCircle(new Circle3Curve(frame.ToWorld((curve.Circle3!.Value.Center.X, curve.Circle3.Value.Center.Y), curve.Circle3.Value.Center.Z), Direction3D.Create(frame.ToWorldDirection(curve.Circle3.Value.Normal.ToVector())), curve.Circle3.Value.Radius, Direction3D.Create(frame.ToWorldDirection(curve.Circle3.Value.XAxis.ToVector())))),
+ CurveGeometryKind.BSpline3 => CurveGeometry.FromBSpline(new BSpline3Curve(curve.BSpline3!.Value.Degree, curve.BSpline3.Value.ControlPoints.Select(p => frame.ToWorld((p.X,p.Y),p.Z)).ToArray(), curve.BSpline3.Value.KnotMultiplicities, curve.BSpline3.Value.KnotValues, curve.BSpline3.Value.CurveForm, curve.BSpline3.Value.ClosedCurve, curve.BSpline3.Value.SelfIntersect, curve.BSpline3.Value.KnotSpec)),
_ => throw new NotSupportedException($"Section-stack frame transform does not support curve {curve.Kind}.")
};
private static SurfaceGeometry Transform(SurfaceGeometry surface, ConstructionPlane frame) => surface.Kind switch
{
SurfaceGeometryKind.Plane => SurfaceGeometry.FromPlane(new PlaneSurface(frame.ToWorld((surface.Plane!.Value.Origin.X, surface.Plane.Value.Origin.Y), surface.Plane.Value.Origin.Z), Direction3D.Create(frame.ToWorldDirection(surface.Plane.Value.Normal.ToVector())), Direction3D.Create(frame.ToWorldDirection(surface.Plane.Value.UAxis.ToVector())))),
SurfaceGeometryKind.Cylinder => SurfaceGeometry.FromCylinder(new CylinderSurface(frame.ToWorld((surface.Cylinder!.Value.Origin.X, surface.Cylinder.Value.Origin.Y), surface.Cylinder.Value.Origin.Z), Direction3D.Create(frame.ToWorldDirection(surface.Cylinder.Value.Axis.ToVector())), surface.Cylinder.Value.Radius, Direction3D.Create(frame.ToWorldDirection(surface.Cylinder.Value.XAxis.ToVector())))),
+ SurfaceGeometryKind.LinearExtrusion => SurfaceGeometry.FromLinearExtrusion(new LinearExtrusionSurface(Transform(surface.LinearExtrusion!.Value.Directrix, frame),frame.ToWorldDirection(surface.LinearExtrusion.Value.ExtrusionVector))),
_ => throw new NotSupportedException($"Section-stack frame transform does not support surface {surface.Kind}.")
};
private static LoopId AddLoop(TopologyBuilder builder, IReadOnlyList<Use> uses) { var id = builder.AllocateLoopId(); var coedges = uses.Select(_ => builder.AllocateCoedgeId()).ToArray(); for (var i = 0; i < uses.Count; i++) builder.AddCoedge(new Coedge(coedges[i], uses[i].Edge, id, coedges[(i + 1) % coedges.Length], coedges[(i + coedges.Length - 1) % coedges.Length], uses[i].Reverse)); builder.AddLoop(new Loop(id, coedges)); return id; }
diff --git a/Aetheris.Kernel.Firmament/Materializer/ProfileArrangement2D.cs b/Aetheris.Kernel.Firmament/Materializer/ProfileArrangement2D.cs
index 9a009503..83498a73 100644
--- a/Aetheris.Kernel.Firmament/Materializer/ProfileArrangement2D.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/ProfileArrangement2D.cs
@@ -56,7 +56,7 @@ public static class ProfileArrangementBuilder
private const double SideSample = 1e-5;
/// <summary>
- /// Shared bounded line/arc intersection entry point for Profile, Drawing, and
+ /// Shared bounded intersection entry point for Profile, Drawing, and
/// Sheet Metal construction. It never extends a source curve implicitly.
/// </summary>
public static PlanarCurveIntersectionResult IntersectBounded(LineArcProfileCurve2D first, LineArcProfileCurve2D second)
@@ -72,14 +72,14 @@ public static class ProfileArrangementBuilder
return new(hits.OrderBy(x => x.FirstParameter).ThenBy(x => x.SecondParameter).ToArray(), coincident, coincident&&HasPositiveCoincidentOverlap(first,second), diagnostics);
}
- /// <summary>Splits a bounded line or circular arc at a known normalized parameter.</summary>
+ /// <summary>Splits a bounded line, circular arc, or cubic Bézier at a known normalized parameter.</summary>
public static IReadOnlyList<LineArcProfileCurve2D> SplitBounded(LineArcProfileCurve2D curve, double parameter)
{
ArgumentNullException.ThrowIfNull(curve);
if (!double.IsFinite(parameter) || parameter <= Tol || parameter >= 1d - Tol)
throw new ArgumentOutOfRangeException(nameof(parameter), "Split parameter must lie strictly inside (0, 1).");
- if (curve is not LineArcLineSegment2D and not LineArcCircularArc2D)
- throw new NotSupportedException("Bounded split supports line segments and circular arcs.");
+ if (curve is not LineArcLineSegment2D and not LineArcCircularArc2D and not LineArcCubicBezier2D)
+ throw new NotSupportedException($"Unsupported bounded section curve: {curve.GetType().Name}");
return [Trim(curve, 0d, parameter), Trim(curve, parameter, 1d)];
}
@@ -89,8 +89,8 @@ public static class ProfileArrangementBuilder
ArgumentNullException.ThrowIfNull(curve);
if (!double.IsFinite(fromParameter) || !double.IsFinite(toParameter) || fromParameter < -Tol || toParameter > 1d + Tol || toParameter - fromParameter <= Tol)
throw new ArgumentOutOfRangeException(nameof(fromParameter), "Trim interval must be a positive subset of [0, 1].");
- if (curve is not LineArcLineSegment2D and not LineArcCircularArc2D)
- throw new NotSupportedException("Bounded trim supports line segments and circular arcs.");
+ if (curve is not LineArcLineSegment2D and not LineArcCircularArc2D and not LineArcCubicBezier2D)
+ throw new NotSupportedException($"Unsupported bounded section curve: {curve.GetType().Name}");
return Trim(curve, Math.Clamp(fromParameter, 0d, 1d), Math.Clamp(toParameter, 0d, 1d));
}
@@ -109,17 +109,19 @@ public static class ProfileArrangementBuilder
var negative = active.Where(x => x.Intent == PrismaticProfileIntent.Remove)
.Select(x => profiles[x.ProfileReference]).ToArray();
return Build(frame, sources, p => positive.Any(profile => PointInProfile(profile, p) == ArrangementPointLocation.Inside)
- && !negative.Any(profile => PointInProfile(profile, p) == ArrangementPointLocation.Inside), context, rejectAmbiguousTangencies: true, allowMultipleRegions: false);
+ && !negative.Any(profile => PointInProfile(profile, p) == ArrangementPointLocation.Inside), context, rejectAmbiguousTangencies: true, allowMultipleRegions: true);
}
/// <summary>Exact region subtraction used only to derive horizontal section transitions.</summary>
public static ProfileArrangementResult Difference(string frame, PrismaticSectionRegion? left, PrismaticSectionRegion? right, string context)
+ => Difference(frame, left is null ? [] : [left], right is null ? [] : [right], context);
+
+ public static ProfileArrangementResult Difference(string frame, IReadOnlyList<PrismaticSectionRegion> left, IReadOnlyList<PrismaticSectionRegion> right, string context)
{
- if (left is null) return Empty(frame, context);
- var sourceRegions = new[] { (Name: "left", Region: left), (Name: "right", Region: right) }
- .Where(x => x.Region is not null).ToArray();
- var sources = sourceRegions.SelectMany(item => RegionSources(item.Name, item.Region!)).ToArray();
- return Build(frame, sources, p => InRegion(left, p) && !InRegion(right, p), context, rejectAmbiguousTangencies: false, allowMultipleRegions: true);
+ if (left.Count == 0) return Empty(frame, context);
+ var sources = left.SelectMany((region, index) => RegionSources($"left{index}", region))
+ .Concat(right.SelectMany((region, index) => RegionSources($"right{index}", region))).ToArray();
+ return Build(frame, sources, p => left.Any(region => InRegion(region, p)) && !right.Any(region => InRegion(region, p)), context, rejectAmbiguousTangencies: false, allowMultipleRegions: true);
}
public static ArrangementPointLocation PointInProfile(ResolvedProfile2D profile, (double X, double Y) point)
@@ -233,16 +235,6 @@ public static class ProfileArrangementBuilder
StableId = source.StableId + $".quarter{i}",
Geometry = new LineArcCircularArc2D(circle.Center, circle.Radius, i * Math.PI / 2d, Math.PI / 2d)
}) : new[] { source }).ToArray();
- // Cubic profiles are valid exact BRep extrusion input, but the section
- // arrangement below still owns only line/arc intersection and splitting.
- // Reject before its line/arc-only Trim switch can throw or silently omit
- // cubic intersections. The glyph normalizer does not weaken this boundary.
- if (sources.FirstOrDefault(source => source.Geometry is LineArcCubicBezier2D) is { } cubic)
- {
- var diagnostic = $"arrangement-rejected:bounded-cubic-section-unsupported:{cubic.StableId}:context={context}";
- return new(new(frame, sources, [], [], [], 0, [diagnostic],
- TimeSpan.Zero, TimeSpan.Zero, TimeSpan.Zero, TimeSpan.Zero), null);
- }
var diagnostics = new List<string>();
var intersectionClock = Stopwatch.StartNew();
var parameters = sources.ToDictionary(x => x.StableId, _ => new List<double> { 0d, 1d }, StringComparer.Ordinal);
@@ -280,7 +272,18 @@ public static class ProfileArrangementBuilder
foreach (var source in sources.OrderBy(x => x.StableId, StringComparer.Ordinal))
{
var ordered = parameters[source.StableId].OrderBy(x => x).Aggregate(new List<double>(), (list, value) =>
- { if (list.Count == 0 || Math.Abs(list[^1] - value) > Tol) list.Add(Math.Clamp(value, 0d, 1d)); return list; });
+ {
+ // Nearby parameters whose points fall within the existing
+ // geometric tolerance are the same arrangement vertex. Keep
+ // distant parameters even on a closed curve with coincident ends.
+ if (list.Count == 0 || (Math.Abs(list[^1] - value) > Tol &&
+ (Math.Abs(list[^1] - value) > 100d * Tol ||
+ Distance(At(source.Geometry, list[^1]), At(source.Geometry, value)) > Tol)))
+ list.Add(Math.Clamp(value, 0d, 1d));
+ else if (value >= 1d)
+ list[^1] = 1d;
+ return list;
+ });
for (var i = 0; i < ordered.Count - 1; i++)
{
if (ordered[i + 1] - ordered[i] <= Tol) continue;
@@ -296,7 +299,15 @@ public static class ProfileArrangementBuilder
{
var midpoint = At(fragment.Geometry, .5d); var tangent = Tangent(fragment.Geometry, .5d);
var length = Math.Sqrt(tangent.X * tangent.X + tangent.Y * tangent.Y);
- if (length <= Tol) { diagnostics.Add($"arrangement-rejected:degenerate-fragment:{fragment.StableId}"); continue; }
+ // A trimmed cubic can have a stationary midpoint while its bounded
+ // endpoints still span a real edge. Use its chord for the side test.
+ if (length <= Tol)
+ {
+ var ends = Ends(fragment.Geometry);
+ tangent = (ends.End.X - ends.Start.X, ends.End.Y - ends.Start.Y);
+ length = Math.Sqrt(tangent.X * tangent.X + tangent.Y * tangent.Y);
+ }
+ if (length <= Tol) { diagnostics.Add($"arrangement-rejected:degenerate-fragment:{fragment.StableId}:length={length:R}"); continue; }
var offset = SideSample;
var left = (midpoint.X - tangent.Y / length * offset, midpoint.Y + tangent.X / length * offset);
var right = (midpoint.X + tangent.Y / length * offset, midpoint.Y - tangent.X / length * offset);
@@ -394,7 +405,7 @@ public static class ProfileArrangementBuilder
if (loops.Count == 0) return [];
var result = new List<PrismaticSectionRegion>();
var inner = loops.Where(x => !x.IsOuter).ToArray();
- foreach (var outerLoop in loops.Where(x => x.IsOuter).OrderByDescending(x => x.SignedArea))
+ foreach (var outerLoop in loops.Where(x => x.IsOuter).OrderByDescending(x => x.SignedArea).ThenBy(x => x.Fragments.Min(f => f.Source.StableId), StringComparer.Ordinal))
{
var outer = ToProfile(outerLoop, "Outer");
var nested = inner.Where(loop => PointInProfile(outer, Ends(loop.Fragments[0].Geometry).Start) == ArrangementPointLocation.Inside).ToArray();
@@ -431,6 +442,15 @@ public static class ProfileArrangementBuilder
{
coincident = false;
tangent = false;
+ if (a is LineArcCubicBezier2D || b is LineArcCubicBezier2D)
+ {
+ if (a is LineArcCubicBezier2D ca && b is LineArcCubicBezier2D cb &&
+ (ca == cb || ca == new LineArcCubicBezier2D(cb.End, cb.Control2, cb.Control1, cb.Start)))
+ { coincident = true; return []; }
+ var hits = BezierSectionCurve2D.Intersections(a, b, Tol);
+ tangent = hits.Any(h => h.Tangent);
+ return hits.Select(h => h.Point).ToArray();
+ }
return (a, b) switch
{
(LineArcLineSegment2D x, LineArcLineSegment2D y) => LineLine(x, y, ref coincident),
@@ -525,6 +545,8 @@ public static class ProfileArrangementBuilder
if (Math.Abs(Distance(arc.Center, p) - arc.Radius) > Tol) { parameter = 0; return false; }
var angle = Math.Atan2(p.Y - arc.Center.Y, p.X - arc.Center.X); parameter = ArcParameter(arc, angle);
return parameter >= -Tol && parameter <= 1d + Tol;
+ case LineArcCubicBezier2D cubic:
+ return BezierSectionCurve2D.OnCurve(cubic, p, Tol, out parameter);
default: parameter = 0; return false;
}
}
@@ -563,24 +585,28 @@ public static class ProfileArrangementBuilder
{
LineArcLineSegment2D line => new LineArcLineSegment2D(At(line, from), At(line, to)),
LineArcCircularArc2D arc => new LineArcCircularArc2D(arc.Center, arc.Radius, arc.StartAngleRadians + arc.SweepAngleRadians * from, arc.SweepAngleRadians * (to - from)),
+ LineArcCubicBezier2D cubic => BezierSectionCurve2D.Trim(cubic, from, to),
_ => throw new NotSupportedException("Profile arrangements require bounded line or circular-arc source curves.")
};
private static LineArcProfileCurve2D Reverse(LineArcProfileCurve2D curve) => curve switch
{
LineArcLineSegment2D line => new LineArcLineSegment2D(line.End, line.Start),
LineArcCircularArc2D arc => new LineArcCircularArc2D(arc.Center, arc.Radius, arc.StartAngleRadians + arc.SweepAngleRadians, -arc.SweepAngleRadians),
+ LineArcCubicBezier2D cubic => new LineArcCubicBezier2D(cubic.End, cubic.Control2, cubic.Control1, cubic.Start),
_ => throw new NotSupportedException()
};
private static (double X, double Y) At(LineArcProfileCurve2D curve, double parameter) => curve switch
{
LineArcLineSegment2D line => (line.Start.X + (line.End.X - line.Start.X) * parameter, line.Start.Y + (line.End.Y - line.Start.Y) * parameter),
LineArcCircularArc2D arc => (arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians + arc.SweepAngleRadians * parameter), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians + arc.SweepAngleRadians * parameter)),
+ LineArcCubicBezier2D cubic => BezierSectionCurve2D.At(cubic, parameter),
_ => throw new NotSupportedException()
};
private static (double X, double Y) Tangent(LineArcProfileCurve2D curve, double parameter) => curve switch
{
LineArcLineSegment2D line => (line.End.X - line.Start.X, line.End.Y - line.Start.Y),
LineArcCircularArc2D arc => (-arc.Radius * Math.Sin(arc.StartAngleRadians + arc.SweepAngleRadians * parameter) * Math.Sign(arc.SweepAngleRadians), arc.Radius * Math.Cos(arc.StartAngleRadians + arc.SweepAngleRadians * parameter) * Math.Sign(arc.SweepAngleRadians)),
+ LineArcCubicBezier2D cubic => BezierSectionCurve2D.Tangent(cubic, parameter),
_ => throw new NotSupportedException()
};
private static ((double X, double Y) Start, (double X, double Y) End) Ends(LineArcProfileCurve2D curve) => (At(curve, 0d), At(curve, 1d));
@@ -588,10 +614,11 @@ public static class ProfileArrangementBuilder
{
LineArcLineSegment2D line => line.Start.X * line.End.Y - line.End.X * line.Start.Y,
LineArcCircularArc2D arc => ArcArea(arc),
+ LineArcCubicBezier2D cubic => BezierSectionCurve2D.SignedDoubleArea(cubic),
_ => 0d
};
private static double ArcArea(LineArcCircularArc2D arc) { var a = arc.StartAngleRadians; var b = a + arc.SweepAngleRadians; return arc.Center.X * arc.Radius * (Math.Sin(b) - Math.Sin(a)) - arc.Center.Y * arc.Radius * (Math.Cos(b) - Math.Cos(a)) + arc.Radius * arc.Radius * (b - a); }
- private static double Length(LineArcProfileCurve2D curve) => curve switch { LineArcLineSegment2D line => Distance(line.Start, line.End), LineArcCircularArc2D arc => Math.Abs(arc.Radius * arc.SweepAngleRadians), _ => 0d };
+ private static double Length(LineArcProfileCurve2D curve) => curve switch { LineArcLineSegment2D line => Distance(line.Start, line.End), LineArcCircularArc2D arc => Math.Abs(arc.Radius * arc.SweepAngleRadians), LineArcCubicBezier2D cubic => Enumerable.Range(0, 32).Sum(i => { var t=(i+.5d)/32d;var d=BezierSectionCurve2D.Tangent(cubic,t);return Math.Sqrt(d.X*d.X+d.Y*d.Y)/32d; }), _ => 0d };
private static ArrangementPointLocation PointInLoop(IReadOnlyList<LineArcProfileCurve2D> curves, (double X, double Y) point)
{
if (curves.Count == 1 && curves[0] is LineArcFullCircle2D circle)
@@ -607,6 +634,7 @@ public static class ProfileArrangementBuilder
{
if (curve is LineArcLineSegment2D line) crossings += RayLine(point, line);
else if (curve is LineArcCircularArc2D arc) crossings += RayArc(point, arc);
+ else if (curve is LineArcCubicBezier2D cubic) crossings += BezierSectionCurve2D.RayCrossings(cubic, point, Tol);
}
return crossings % 2 == 1 ? ArrangementPointLocation.Inside : ArrangementPointLocation.Outside;
}
@@ -624,6 +652,7 @@ public static class ProfileArrangementBuilder
{
LineArcLineSegment2D => $"L:{VertexKey(a)}:{VertexKey(b)}",
LineArcCircularArc2D arc => $"A:{VertexKey(arc.Center)}:{arc.Radius:R}:{a.X:R}:{a.Y:R}:{b.X:R}:{b.Y:R}:{Math.Sign(arc.SweepAngleRadians)}",
+ LineArcCubicBezier2D cubic => $"B:{VertexKey(cubic.Start)}:{VertexKey(cubic.Control1)}:{VertexKey(cubic.Control2)}:{VertexKey(cubic.End)}",
_ => throw new NotSupportedException()
};
}
@@ -635,6 +664,7 @@ public static class ProfileArrangementBuilder
{
LineArcLineSegment2D => $"L:{ka}:{kb}",
LineArcCircularArc2D arc => $"A:{VertexKey(arc.Center)}:{Math.Round(arc.Radius / Tol):F0}:{ka}:{kb}",
+ LineArcCubicBezier2D cubic => $"B:{ka}:{kb}:{(string.CompareOrdinal(VertexKey(cubic.Start),VertexKey(cubic.End))<=0 ? VertexKey(cubic.Control1)+":"+VertexKey(cubic.Control2) : VertexKey(cubic.Control2)+":"+VertexKey(cubic.Control1))}",
_ => throw new NotSupportedException()
};
}
@@ -646,6 +676,7 @@ public static class ProfileArrangementBuilder
{
(LineArcLineSegment2D, LineArcLineSegment2D) => true,
(LineArcCircularArc2D aa, LineArcCircularArc2D bb) => Math.Sign(aa.SweepAngleRadians) == Math.Sign(bb.SweepAngleRadians),
+ (LineArcCubicBezier2D aa, LineArcCubicBezier2D bb) => VertexKey(aa.Control1)==VertexKey(bb.Control1) && VertexKey(aa.Control2)==VertexKey(bb.Control2),
_ => false
};
}
diff --git a/Aetheris.Kernel.Firmament/Materializer/ThreadedHexBoltMakerMark.cs b/Aetheris.Kernel.Firmament/Materializer/ThreadedHexBoltMakerMark.cs
new file mode 100644
index 00000000..6d83c0f1
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Materializer/ThreadedHexBoltMakerMark.cs
@@ -0,0 +1,92 @@
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Step242;
+using Aetheris.Kernel.Core.Topology;
+
+namespace Aetheris.Kernel.Firmament.Materializer;
+
+/// <summary>A planar maker mark on the existing threaded HexBolt head cap.</summary>
+public static class ThreadedHexBoltMakerMark
+{
+ public sealed record Result(BrepBody Body, string StepText, PrismaticSectionStackConstruction Section,
+ PlanarTextProfileResult Text, double Depth, FaceId OriginalTopFace);
+
+ public static Result Build(string threadedHexBoltSource, string content, double heightMm, double depthMm)
+ {
+ if (!double.IsFinite(depthMm) || depthMm <= 0d || depthMm > .3d)
+ throw new ArgumentOutOfRangeException(nameof(depthMm));
+ var compiled = FirmamentBuildAndExport.CompileSource(threadedHexBoltSource);
+ if (!compiled.IsSuccess || compiled.Value.RuntimeBody is null || compiled.Value.Thread is null ||
+ compiled.Value.StandardPart?.Family != "HexBolt")
+ throw new InvalidOperationException("Maker mark requires a compiled threaded HexBolt: " +
+ string.Join(" | ", compiled.Diagnostics.Select(x => x.Message)));
+ var host = compiled.Value.RuntimeBody;
+ var topId = compiled.Value.StandardPart.SemanticDescendants.Single(x =>
+ x.StableId.EndsWith(".Head.TopFlat", StringComparison.Ordinal)).FaceId;
+ if (topId is null) throw new InvalidOperationException("Threaded HexBolt top face is missing.");
+ var topFace = new FaceId(topId.Value);
+ var (disk, topX) = DiskFromTopRim(host, topFace);
+ var text = PlanarTextProfiles.Build(content, heightMm, PlanarTextAlignment.Center);
+ if (!text.Succeeded) throw new InvalidOperationException(string.Join(" | ", text.Diagnostics));
+ var profiles = text.Regions.Select(region => region with { PlaneFrame = "YZ" }).Append(disk)
+ .ToDictionary(x => x.Name, StringComparer.Ordinal);
+ var operations = new List<PrismaticProfileOperation>
+ {
+ new("HeadCap", PrismaticProfileIntent.Base, disk.Name, -2d * depthMm, 0d, "Stock", "maker-mark")
+ };
+ operations.AddRange(text.Regions.Select((region, index) => new PrismaticProfileOperation(
+ $"Mark{index}", PrismaticProfileIntent.Remove, region.Name, -depthMm, 0d,
+ "Pocket", "maker-mark")));
+ var feature = new PrismaticProfileCompositionFeature("MakerMark", "YZ", "-X",
+ new PrismaticProfilePlacement("HeadTop", topX, 0d, 0d, "YZ", "-X", "+Y", true),
+ operations, [-2d * depthMm, -depthMm, 0d], "maker-mark");
+ var section = PrismaticSectionStackCompiler.Normalize(new(feature, profiles, []), out var diagnostics);
+ if (section is null) throw new InvalidOperationException("Maker mark section: " + string.Join(" | ", diagnostics));
+ var planned = PrismaticSectionStackEmitter.Emit(section);
+ if (planned.Body is null || planned.Plan?.TopologyPlan is null)
+ throw new InvalidOperationException("Maker mark BRep: " + string.Join(" | ", planned.Diagnostics));
+ var patchFaces = planned.Plan.TopologyPlan.FaceMappings.Where(mapping =>
+ (mapping.Kind == "TransitionCap" && mapping.ConstructionStableId != $"transition:{-2d * depthMm:R}") ||
+ (mapping.Kind == "PrismaticSide" && mapping.SourceStableId.Contains("Text.Glyph[", StringComparison.Ordinal)))
+ .Select(mapping => mapping.FaceId).ToArray();
+ var body = HexBoltThreadStitch.ImprintTop(host, topFace, planned.Body, patchFaces);
+ var step = Step242Exporter.ExportBody(body, new Step242ExportOptions
+ {
+ ProductName = "ThreadedHexBoltMakerMark",
+ ApplicationName = "Aetheris.Firmament.MakerMark.X2",
+ BrepExportPreflightMode = BrepExportPreflightMode.Enforce
+ });
+ if (!step.IsSuccess) throw new InvalidOperationException("Maker mark STEP: " +
+ string.Join(" | ", step.Diagnostics.Select(x => x.Message)));
+ return new(body, step.Value, section, text, depthMm, topFace);
+ }
+
+ private static (ResolvedProfile2D Profile, double TopX) DiskFromTopRim(BrepBody body, FaceId topFace)
+ {
+ var face = body.Topology.GetFace(topFace);
+ if (face.LoopIds.Count != 1) throw new InvalidOperationException("Maker mark head cap requires one circular outer loop.");
+ var coedges = body.Topology.GetLoop(face.LoopIds[0]).CoedgeIds;
+ var segments = new List<ResolvedProfileSegment2D>();
+ double? topX = null;
+ foreach (var (coedgeId, index) in coedges.Reverse().Select((id, i) => (id, i)))
+ {
+ var coedge = body.Topology.GetCoedge(coedgeId);
+ var edge = body.Topology.GetEdge(coedge.EdgeId);
+ var startVertex = coedge.IsReversed ? edge.StartVertexId : edge.EndVertexId;
+ var endVertex = coedge.IsReversed ? edge.EndVertexId : edge.StartVertexId;
+ body.TryGetVertexPoint(startVertex, out var start);
+ body.TryGetVertexPoint(endVertex, out var end);
+ topX ??= start.X;
+ if (Math.Abs(start.X - topX.Value) > 1e-7d || Math.Abs(end.X - topX.Value) > 1e-7d)
+ throw new InvalidOperationException("Maker mark head cap is not planar on X.");
+ var radius = Math.Sqrt(start.Y * start.Y + start.Z * start.Z);
+ var angle = Math.Atan2(-start.Z, start.Y);
+ var finish = Math.Atan2(-end.Z, end.Y);
+ var sweep = finish - angle;
+ while (sweep <= 0d) sweep += 2d * Math.PI;
+ if (sweep >= Math.PI) throw new InvalidOperationException("Maker mark rim arc is not bounded below 180 degrees.");
+ segments.Add(new($"Rim{index}", new LineArcCircularArc2D((0d, 0d), radius, angle, sweep),
+ new ProfileSegmentProvenance($"profile:HeadTop.Rim{index}", "HeadTop", "head-cap", "bolt-top-rim", "YZ")));
+ }
+ return (new ResolvedProfile2D("HeadTop", "YZ", [new ResolvedProfileLoop2D("Outer", true, segments)]), topX!.Value);
+ }
+}
diff --git a/docs/release/BREP-BEZIER-SECTION-X0.md b/docs/release/BREP-BEZIER-SECTION-X0.md
new file mode 100644
index 00000000..7c0d2df3
--- /dev/null
+++ b/docs/release/BREP-BEZIER-SECTION-X0.md
@@ -0,0 +1,78 @@
+# BREP-BEZIER-SECTION-X0
+
+## Verdict: Meaningful progression
+
+The shared section stack now accepts bounded cubic Bézier profile edges. A generic
+cubic profile can be added as a Boss or removed as a Pocket from a plate. Both
+results are enclosed, consistently oriented BReps and export/reimport through
+STEP AP242. An `O` region with an inner counter also Bosses successfully with
+an exact curved wall. This removes the prior cubic arrangement and side-face
+blocker for connected sections.
+
+The complete milestone is not accepted. An `O`-shaped Pocket creates a second
+material island at the counter in its upper slab. `ProfileArrangementBuilder.Compose`
+currently requires exactly one outer material loop and reports
+`arrangement-rejected:disconnected-or-invalid-material:outer-loops=2`. The
+`PrismaticSectionSlab` contract also stores one `PrismaticSectionRegion`, so
+CODEX and other multi-glyph sections need a bounded multi-region slab change
+before they can lower as one ordinary Pocket/Boss operation. Quadratic profile
+edges are still represented by exact degree-elevated cubics upstream; a native
+quadratic section-edge carrier is not yet exposed. No bolt or AETHERIS plate
+claim is made.
+
+## Geometry path
+
+- The section arrangement now evaluates, trims, reverses, classifies, and
+ reconstructs cubic edges. Cubic area uses Green's theorem on polynomial
+ coefficients. Ray containment splits the parameter at Y extrema and solves
+ each monotone interval. Bounded intersection candidates use curve convex
+ hulls and analytic arc boxes, followed by parameter refinement; all retained
+ fragments remain exact curves.
+- The section emitter stores each cubic edge as a clamped degree-three
+ `BSpline3Curve` with the original four control points. It builds the wall as
+ the existing `LinearExtrusionSurface` with that directrix and constant +Z
+ vector, then transforms both through the profile construction frame.
+ Thus its support is `S(u,v) = C(u) + vN`. Caps stay planar; cap and wall
+ coedges share topology edge IDs.
+- Existing line and circular-arc behavior remains on its established plane
+ and cylinder branches. STEP already serializes/imports the B-spline directrix
+ and linear-extrusion surface, so no exporter-only representation was added.
+- The bounded arrangement intersection search is tolerance-qualified. It is
+ not a general arbitrary planar Boolean engine. The input profile validator
+ remains the authority for admissible source loops.
+
+## Evidence
+
+`BezierSectionStackTests` contains four positive cases: generic cubic Boss,
+generic cubic Pocket, Inter `O` counter Boss, and Inter `C` Pocket. Each
+checks section normalization, BRep enclosure and orientation, presence of a
+linear-extrusion surface, STEP export and reimport, and preservation of that
+surface kind and its four B-spline directrix control points to seven decimal
+places. A fifth test fixes the exact current O-counter Pocket diagnostic.
+`PlanarTextProfilesTests.SectionArrangementAcceptsItsExactCubicBoundary`
+checks the former cubic rejection boundary now accepts a valid `O` profile.
+
+The threaded HexBolt source was inspected with Aetheris.CLI successfully.
+It was not modified. No production CODEX bolt, AETHERIS plate, visual catalogue
+render, multi-region STEP count, or performance breakdown was produced. Text
+syntax/schema/LX remains deferred while this backend limit exists.
+
+Release build passed with seven existing WebAssembly warnings and no errors.
+The fast Core lane passed 1,000 tests. The full solution lane passed all 1,682
+Firmament tests and all new section tests. It retained the two CLI and five
+SheetMetal failures documented in the prior release reports. One Core display
+tessellation test exceeded its 10-second budget under full-suite load; it
+passed alone in 881 ms immediately afterwards. The full solution command
+therefore exited with failures; it is not reported as green.
+
+## Next geometry boundary
+
+Permit a slab to own several disjoint `PrismaticSectionRegion` values, and
+derive transitions and cap/side topology across the complete set. Then verify
+the O/D counter Pocket and multiple glyph regions before integrating the
+threaded bolt. This is a section-stack topology change, not a typography or
+font-normalization change.
+
+## Downstream status (BREP-MULTIREGION-SLAB-X0)
+
+The later slab work permits multiple material regions in one section. O and D counter Pockets, two O counters, and a multi-island AETHERIS Boss pass enclosure, orientation, and STEP roundtrip checks. The historical Bézier verdict above remains unchanged. CODEX still stops at a short X-glyph arrangement fragment before solid lowering; see `BREP-MULTIREGION-SLAB-X0.md`.
diff --git a/docs/release/BREP-MULTIREGION-SLAB-X0.md b/docs/release/BREP-MULTIREGION-SLAB-X0.md
new file mode 100644
index 00000000..f3dfbbac
--- /dev/null
+++ b/docs/release/BREP-MULTIREGION-SLAB-X0.md
@@ -0,0 +1,30 @@
+# BREP-MULTIREGION-SLAB-X0
+
+## Verdict: Meaningful progression
+
+The planar Boss/Pocket stack now admits multiple material regions in a slab. A finite-depth O Pocket retains its center counter as a separate section region; both regions meet the plate below the pocket floor. D and two O counters also pass on a plate. A multi-island AETHERIS Boss produces one enclosed, consistently oriented body. These cases export and reimport through STEP AP242.
+
+The complete normalized CODEX profile set still fails arrangement classification before solid lowering. The diagnostic is `arrangement-rejected:degenerate-fragment:compose:Mark4.Text.Glyph[4].Region[0].Outer.Outer.Segment[5].part0` on the X glyph. The threaded HexBolt was inspected with the CLI, but CODEX was not engraved into it. No bolt topology, bolt STEP, maker-mark render, or source-language Text claim is made.
+
+## Section and connectivity model
+
+The former slab held one `PrismaticSectionRegion` and `Compose` rejected two outer loops. Each slab now carries an ordered `MaterialRegions` set; each region still has one outer loop and zero or more inner loops. Region order is by descending signed area, then source stable ID. The first-region property remains for legacy single-region consumers; CLI inspection now reports the complete region set and aggregate area.
+
+Transition subtraction works across both neighboring region sets. It creates separate planar caps at a counter floor and the surrounding pocket floor, and the emitter creates vertical walls for every region boundary. After topology construction, face adjacency through shared edges checks whether the actual shell is connected. A through-cut plate that yields two 3D solids is rejected as `compose-rejected:disconnected-3d-solid:components=2`; the former half-depth fixture was connected through its lower slab and was corrected to a through cut. No bridges, 3D Boolean path, or mesh representation were introduced.
+
+## Evidence and remaining boundary
+
+`BezierSectionStackTests` covers O, D, two O counters, and multi-island Boss, with enclosure, orientation, exact cubic surface, and STEP roundtrip checks. The existing one-region Boss/Pocket cases remain in that suite. The normalized CODEX X region is valid upstream; its arrangement creates a fragment whose midpoint tangent and endpoint chord are both below the section classifier's degeneracy tolerance. The classifier now tries the chord for a stationary cubic midpoint, then rejects the genuinely short fragment rather than silently dropping it. Resolving that tolerance and topology boundary is the next prerequisite to CODEX bolt integration.
+
+The source Text syntax, generated schema, LX completion, performance breakdown, and O/CODEX/AETHERIS display renders remain pending because CODEX has not lowered through the production solid path.
+
+## Verification
+
+- Release solution build passed with 0 errors; the existing WebAssembly warnings remain.
+- Fast Core lane: 1,000 passed. Full solution lane: 1,133 Core and 1,686 Firmament tests passed; overall exit code 1 reflects the same two CLI and five SheetMetal baseline failures recorded in the preceding milestones. The full log is in ignored `artifacts/local/multiregion-full-test.log`.
+- After the final semantic probe and report changes, the focused Bézier section, disconnected-solid, and semantic Boss/Pocket tests passed (30 tests); Aetheris.CLI rebuilt with 0 warnings and 0 errors.
+- CLI inspection of `fixtures/Thread/hexbolt-threaded.firmament` succeeded. It is inspection evidence only, not an engraving or STEP result.
+
+## Downstream status (TEXT-CODEX-FINISH-X2)
+
+The later bounded X2 work collapses the tolerance-equivalent X split during section arrangement, then engraves the normalized CODEX regions into the accepted threaded HexBolt head. The resulting body is enclosed and STEP-roundtrips; see `TEXT-CODEX-FINISH-X2.md`. The X0 verdict above remains its historical result.
diff --git a/docs/release/TEXT-CODEX-FINISH-X2.md b/docs/release/TEXT-CODEX-FINISH-X2.md
new file mode 100644
index 00000000..869ef286
--- /dev/null
+++ b/docs/release/TEXT-CODEX-FINISH-X2.md
@@ -0,0 +1,19 @@
+# TEXT-CODEX-FINISH-X2
+
+## Verdict: Accepted for the bounded CODEX maker mark
+
+The normalized X outline is valid. The former rejection came from an intersection split only 0.00000004535 mm from the cubic endpoint. The split parameter differed by 5.60898e-7, but its geometric separation was below the arrangement's existing 1e-7 mm tolerance. The section arrangement now deduplicates adjacent split parameters by both parameter and geometric distance. It retains the source cubic and removes only the tolerance-equivalent split; no glyph contour or font normalizer changed.
+
+The ordinary section stack now lowers the full five-region CODEX profile set into a 0.2 mm Pocket. Its pocket-depth slab contains three material regions: the surrounding head material and the O and D counter islands. The threaded HexBolt comes from the existing `fixtures/Thread/hexbolt-threaded.firmament` build route. A bounded head-cap graft replaces its single planar top face with the section-stack top faces, pocket walls, and floor. The six exact circular rim edges are shared with the retained bolt shell. Thread geometry is unmodified. No general 3D Boolean or mesh fallback is involved.
+
+The final body is enclosed and consistently oriented. STEP AP242 export and reimport pass the same mass-property checks. CLI STEP analysis reports one body, one shell, 295 faces, 691 edges, 408 vertices, and `enclosed-manifold`; all 76 linear-extrusion surfaces and 114 B-spline surfaces are supported. The imported STEP wireframe has no unsupported surface or curve families and pcurve recovery succeeds (maximum residual 7.81e-7 mm).
+
+Reviewable artifacts are generated under ignored `artifacts/local/text-codex-finish-x2/`: `codex-threaded-hexbolt.step`, `codex-threaded-hexbolt-iso.png`, `codex-threaded-hexbolt-head.png`, and the corresponding SVGs. The head-on wireframe shows CODEX and both counters. Wireframe draws occluded bolt edges as well, so projected shank rings cross the lettering; the body and STEP checks, rather than that diagnostic image, establish manifold topology.
+
+To regenerate the STEP, set `AETHERIS_MAKER_MARK_ARTIFACT_DIR` to that ignored directory and run `dotnet test Aetheris.Kernel.Firmament.Tests -c Release --filter FullyQualifiedName~CodexEngravesOnThreadedHexBoltAndRoundTripsStep -m:1`. Run `aetheris wireframe` on the resulting STEP with `--view iso` and `--view right` for the two SVGs.
+
+No Firmament `Text` source syntax, schema, or LX change is introduced in this bounded finish. The maker mark is an explicit code-first construction over the existing compiled threaded HexBolt and normalized text regions.
+
+## Verification
+
+The Release solution build passed with zero errors. The fast Core lane passed 1,000 tests. The final full solution lane passed all 1,133 Core, 1,687 Firmament, and 99 SheetMetal tests. One CLI OBJ vertex-count baseline remained red (905 expected versus 908 actual); the full command therefore exited 1. The focused section suite passed 10 tests, including CODEX Pocket and threaded-bolt STEP roundtrip. The saved STEP SHA-256 is `E65B63D78C13F9B92B88810BA45B8D53126D1299DA4D1E1207474777EE6C4BC2`.
diff --git a/docs/release/TEXT-REGION-NORMALIZE-X1.md b/docs/release/TEXT-REGION-NORMALIZE-X1.md
index 58ede857..acc57fc1 100644
--- a/docs/release/TEXT-REGION-NORMALIZE-X1.md
+++ b/docs/release/TEXT-REGION-NORMALIZE-X1.md
@@ -105,3 +105,16 @@ source in `TEXT-PLANAR-X0.md` remains non-executable.
altered by this milestone.
- No topology counts, manifold result, text STEP size, reimport result, or
catalogue render can be reported for a bolt or plate that has not been built.
+
+## Downstream status (BREP-BEZIER-SECTION-X0)
+
+The later section-stack work now accepts valid cubic regions and constructs
+exact B-spline-directrix translation walls. Generic cubic Boss/Pocket and an
+`O` counter Boss are manifold and STEP-roundtrip. An `O` Pocket still exposes
+the section stack's single-material-region-per-slab limit; CODEX engraving
+and the plate witness remain unbuilt. See `BREP-BEZIER-SECTION-X0.md`. The
+X1 normalization verdict above remains its historical result.
+
+## Downstream status (BREP-MULTIREGION-SLAB-X0)
+
+The later multi-region slab path now accepts O and D counter Pockets, two O counters, and a multi-island AETHERIS Boss with STEP roundtrips. This does not change X1's normalization verdict. CODEX still fails during section arrangement on a short X-glyph fragment, before the threaded-bolt engraving or Text source syntax; see `BREP-MULTIREGION-SLAB-X0.md`.
diff --git a/fixtures/Invalid/ProfileComposition/disconnected-final-material.firmament b/fixtures/Invalid/ProfileComposition/disconnected-final-material.firmament
index 44cd2351..d05d87d3 100644
--- a/fixtures/Invalid/ProfileComposition/disconnected-final-material.firmament
+++ b/fixtures/Invalid/ProfileComposition/disconnected-final-material.firmament
@@ -16,5 +16,5 @@ Profile SplitProfile Using Layout { Loop Outer {
} }
Struct Composition { Compose DisconnectedFinalMaterial {
Base Stock { Profile: BaseProfile; From: 0mm; To: 10mm; Role: Stock }
- Remove Split { Profile: SplitProfile; From: 5mm; To: 10mm; Role: Relief }
+ Remove Split { Profile: SplitProfile; From: 0mm; To: 10mm; Role: Relief }
} }