Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

BUILD-PERF-M4 (pass 2): SectionChain trims constructed with their patches

Claude73c2be2b40a8
diff --git a/Aetheris.Kernel.Core/Brep/BrepBindings.cs b/Aetheris.Kernel.Core/Brep/BrepBindings.cs
index 5637b77c..2d0ccffa 100644
--- a/Aetheris.Kernel.Core/Brep/BrepBindings.cs
+++ b/Aetheris.Kernel.Core/Brep/BrepBindings.cs
@@ -190,7 +190,10 @@ public readonly record struct CoedgePcurveBinding(
int? SourceStepSurfaceEntityId = null,
PcurveQualification? Qualification = null);
-public enum PcurveBindingOrigin { SourceValidated, RecoveredAnalytic, RecoveredSpline, DerivedAnalytic }
+/// <summary>Where a face-local trim came from. <see cref="ConstructedBoundary"/>: the edge is, by
+/// construction, an isoparametric boundary of the face's own surface, so the trim is the matching
+/// straight line of its parameter rectangle (BUILD-PERF-M4: no inverse projection or dense lift).</summary>
+public enum PcurveBindingOrigin { SourceValidated, RecoveredAnalytic, RecoveredSpline, DerivedAnalytic, ConstructedBoundary }
/// <summary>Measured edge-to-surface-lift evidence for one face-local trim.</summary>
public sealed record PcurveQualification(
diff --git a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
index 28c72876..801c861e 100644
--- a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
@@ -1126,7 +1126,7 @@ public static class Step242Exporter
: edgePcurveBindings
.Select(binding => BuildStepPcurve(writer, binding, surfaceIds, pcurveContextId,
curve.Kind == CurveGeometryKind.Line3 && binding.Qualification is
- { Origin: PcurveBindingOrigin.RecoveredAnalytic or PcurveBindingOrigin.RecoveredSpline or PcurveBindingOrigin.DerivedAnalytic }
+ { Origin: PcurveBindingOrigin.RecoveredAnalytic or PcurveBindingOrigin.RecoveredSpline or PcurveBindingOrigin.DerivedAnalytic or PcurveBindingOrigin.ConstructedBoundary }
? new ParameterInterval(0d, (endPoint - startPoint).Length) : null))
.Where(id => id is not null)
.Select(id => id!)
diff --git a/Aetheris.Modules.Tests/ConstructedSectionChainTrimTests.cs b/Aetheris.Modules.Tests/ConstructedSectionChainTrimTests.cs
new file mode 100644
index 00000000..63db2410
--- /dev/null
+++ b/Aetheris.Modules.Tests/ConstructedSectionChainTrimTests.cs
@@ -0,0 +1,66 @@
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Step242;
+using Aetheris.Surfacing;
+using Xunit;
+
+namespace Aetheris.Modules.Tests;
+
+/// <summary>
+/// BUILD-PERF-M4: SectionChain transition faces carry trims constructed with their patches (each edge
+/// is an isoparametric boundary of its own patch) instead of trims recovered by inverse projection.
+/// The old qualification density (8193 lifted samples per spline trim) is the oracle here.
+/// </summary>
+public sealed class ConstructedSectionChainTrimTests
+{
+ public static TheoryData<string> Chains() => new() { "smooth", "ruled" };
+
+ private static SectionChain Chain(string lane) => lane == "smooth"
+ ? SectionChainTemplates.ErgonomicFairingG1()
+ : SectionChainTemplates.ErgonomicFairing("g0", smooth: false);
+
+ [Theory]
+ [MemberData(nameof(Chains))]
+ public void TransitionTrimsAreConstructedAndExactAtTheOldQualificationDensity(string lane)
+ {
+ var result = SectionChainMaterializer.Materialize(Chain(lane));
+ Assert.True(result.IsSuccess, string.Join(Environment.NewLine, result.Diagnostics));
+ var body = result.Body!;
+ var splineTrims = body.Bindings.PcurveBindings
+ .Where(binding => body.Geometry.GetSurface(binding.SurfaceGeometryId).Kind == SurfaceGeometryKind.BSplineSurfaceWithKnots)
+ .ToArray();
+ Assert.NotEmpty(splineTrims);
+ Assert.All(splineTrims, binding => Assert.Equal(PcurveBindingOrigin.ConstructedBoundary, binding.Qualification!.Origin));
+ foreach (var binding in splineTrims)
+ {
+ var spline = body.Geometry.GetSurface(binding.SurfaceGeometryId).BSplineSurfaceWithKnots!;
+ var coedge = body.Topology.GetCoedge(binding.CoedgeId);
+ var edge = body.Bindings.GetEdgeBinding(coedge.EdgeId);
+ var curve = body.Geometry.GetCurve(edge.CurveGeometryId);
+ var interval = edge.TrimInterval!.Value;
+ var worst = 0d;
+ for (var sample = 0; sample < 8193; sample++)
+ {
+ var t = interval.Start + (interval.End - interval.Start) * sample / 8192d;
+ var onEdge = curve.Kind == CurveGeometryKind.Line3 ? curve.Line3!.Value.Evaluate(t) : curve.BSpline3!.Value.Evaluate(t);
+ var uv = binding.Pcurve.Evaluate(t);
+ worst = double.Max(worst, (spline.Evaluate(uv.U, uv.V) - onEdge).Length);
+ }
+ Assert.True(worst <= 1e-7, $"{lane}: coedge {binding.CoedgeId.Value} lifts {worst:R} mm off its edge.");
+ }
+ }
+
+ [Theory]
+ [MemberData(nameof(Chains))]
+ public void ConstructedTrimsRoundTripThroughStepAsSourceTrims(string lane)
+ {
+ var body = SectionChainMaterializer.Materialize(Chain(lane)).Body!;
+ var step = Step242Exporter.ExportBody(body);
+ Assert.True(step.IsSuccess, string.Join(Environment.NewLine, step.Diagnostics.Select(item => item.Message)));
+ var imported = Step242Importer.ImportBody(step.Value);
+ Assert.True(imported.IsSuccess, string.Join(Environment.NewLine, imported.Diagnostics.Select(item => item.Message)));
+ var splineTrims = imported.Value.Bindings.PcurveBindings
+ .Where(binding => imported.Value.Geometry.GetSurface(binding.SurfaceGeometryId).Kind == SurfaceGeometryKind.BSplineSurfaceWithKnots);
+ Assert.All(splineTrims, binding => Assert.Equal(PcurveBindingOrigin.SourceValidated, binding.Qualification!.Origin));
+ }
+}
diff --git a/Aetheris.Surfacing/SectionChains.cs b/Aetheris.Surfacing/SectionChains.cs
index 1b633884..7ae3b78d 100644
--- a/Aetheris.Surfacing/SectionChains.cs
+++ b/Aetheris.Surfacing/SectionChains.cs
@@ -501,6 +501,11 @@ public static class SectionChainMaterializer
var surfaceId = new SurfaceGeometryId(nextSurface++);
geometry.AddSurface(surfaceId, entry.Patches[span].ExactSurface);
bindings.AddFaceBinding(new(face, surfaceId)); faces.Add(face);
+ // Exact polynomial patches (smooth G1 and ruled lanes) are tensor-product splines whose
+ // u runs along the profile span and v from source to target section.
+ if (entry.Patches[span].MaterializationKind == SurfaceMaterializationKind.ExactPolynomialBSpline
+ && entry.Patches[span].ExactSurface.BSplineSurfaceWithKnots is { } patchSpline)
+ BindConstructedPcurves(face, surfaceId, patchSpline);
surfaces.Add(new(transition.Source.Section.Profile.Spans[span].SpanId,
transition.Source.Boundaries[span].StableId, transition.Target.Boundaries[transition.Map[span]].StableId,
entry.Patches[span].ExactSurface.Kind, entry.Patches[span].MaterializationKind));
@@ -527,12 +532,56 @@ public static class SectionChainMaterializer
bindings.AddFaceBinding(new(face, surfaceId)); faces.Add(face);
}
var shell = builder.AddShell(faces); builder.AddBody([shell]);
+ // Constructed trims are re-checked here (129-sample lift); only the remaining coedges (caps,
+ // ruled transitions, any constructed trim that was declined) are recovered.
var pcurves = BoundedPcurveBuilder.Populate(builder.Model, geometry, bindings, 1e-5d);
if (!pcurves.IsSuccess)
throw new InvalidOperationException("SectionChain face-local pcurve construction failed: "
+ string.Join(" | ", pcurves.Diagnostics.Select(item => $"{item.Code}:{item.Entity}:{item.Message}")));
return (new BrepBody(builder.Model, geometry, bindings, points), transitionEvidence);
+ // BUILD-PERF-M4: an exact transition face is bounded by four isoparametric curves of its own
+ // patch: the source profile (v = start), the target profile (v = end) and the two longitudinal
+ // boundaries (u = start, u = end: spline rows in the smooth lane, straight rulings in the ruled
+ // lane), each bound with a parameter affine to the patch's there (profile knots, or [0, length]
+ // for a line, which the patch carries as a [0, 1] span). The trim
+ // of each coedge is therefore the matching straight side of the parameter rectangle. A short
+ // lift check guards the construction; a trim it declines is left to recovery.
+ void BindConstructedPcurves(FaceId face, SurfaceGeometryId surfaceId, BSplineSurfaceWithKnots spline)
+ {
+ var coedges = builder.Model.GetLoop(builder.Model.GetFace(face).LoopIds[0]).CoedgeIds;
+ double u0 = spline.DomainStartU, u1 = spline.DomainEndU, v0 = spline.DomainStartV, v1 = spline.DomainEndV;
+ // AddFace order: source profile, end-side longitudinal, target profile, start-side longitudinal.
+ (SurfaceParameterPoint Start, SurfaceParameterPoint End)[] sides =
+ [(new(u0, v0), new(u1, v0)), (new(u1, v0), new(u1, v1)), (new(u0, v1), new(u1, v1)), (new(u0, v0), new(u0, v1))];
+ for (var index = 0; index < coedges.Count && index < sides.Length; index++)
+ {
+ var coedge = builder.Model.GetCoedge(coedges[index]);
+ var binding = bindings.GetEdgeBinding(coedge.EdgeId);
+ if (binding.TrimInterval is not { } interval || !geometry.TryGetCurve(binding.CurveGeometryId, out var curve) || curve is null) continue;
+ var pcurve = PcurveGeometry.Line(interval, sides[index].Start, sides[index].End);
+ const int samples = 33;
+ var deviation = 0d;
+ for (var sample = 0; sample < samples; sample++)
+ {
+ var t = interval.Start + (interval.End - interval.Start) * sample / (samples - 1d);
+ Point3D? onEdge = curve.Kind switch
+ {
+ CurveGeometryKind.Line3 => curve.Line3!.Value.Evaluate(t),
+ CurveGeometryKind.BSpline3 => curve.BSpline3!.Value.Evaluate(t),
+ _ => null
+ };
+ if (onEdge is null) { deviation = double.PositiveInfinity; break; }
+ var uv = pcurve.Evaluate(t);
+ deviation = double.Max(deviation, (spline.Evaluate(uv.U, uv.V) - onEdge.Value).Length);
+ }
+ if (!(deviation <= ConstructedTrimTolerance)) continue;
+ bindings.AddPcurveBinding(new(coedge.Id, face, surfaceId, pcurve,
+ Qualification: new(PcurveBindingOrigin.ConstructedBoundary, deviation, ConstructedTrimTolerance, samples,
+ "IsoparametricBoundary", nameof(SurfaceGeometryKind.BSplineSurfaceWithKnots))));
+ }
+ }
+
void BindBoundary(EdgeId edge, RuledBoundary boundary)
{
var curveId = new CurveGeometryId(nextCurve++);
@@ -737,6 +786,9 @@ public static class SectionChainMaterializer
private static SectionPoint2D Lerp(SectionPoint2D a, SectionPoint2D b, double t) =>
new(a.X + (b.X - a.X) * t, a.Y + (b.Y - a.Y) * t);
+ /// <summary>A constructed trim must reproduce its edge far inside the 1e-5 mm qualification tolerance.</summary>
+ private const double ConstructedTrimTolerance = 1e-7d;
+
private static FaceId AddFace(TopologyBuilder builder, IReadOnlyList<(EdgeId Edge, bool Reversed)> uses)
{
var loop = builder.AllocateLoopId(); var ids = uses.Select(_ => builder.AllocateCoedgeId()).ToArray();
diff --git a/Aetheris.Web.Perf/build-perf-budgets.json b/Aetheris.Web.Perf/build-perf-budgets.json
index cb976e91..e61e9f34 100644
--- a/Aetheris.Web.Perf/build-perf-budgets.json
+++ b/Aetheris.Web.Perf/build-perf-budgets.json
@@ -2,31 +2,31 @@
"schema": "aetheris/build-perf-budgets/m0",
"note": "Machine-independent fields always gate; *Milliseconds fields gate only with --check-time on the recorded machine.",
"recordedOn": "vm \u00B7 2 CPU \u00B7 Unix 6.18.44.114",
- "recordedCommit": "ac297514b2e3",
+ "recordedCommit": "c85f61bbec71",
"projects": {
"bracket": {
"stepDataSha256": "c3323aa5717fbd198c6148ab082623f0f5920c42487c6dd5f398da4abd2d4170",
"meshSha256": "b0ec1fb0d1d40af0e6b13fe9fa1ddd38167ebde5f3f3fd946eeaac4ba97509f9",
"rebuildMatchesCold": true,
"cold": {
- "invokeMilliseconds": 663.9,
- "responseBytes": 29418,
- "allocatedBytes": 4959600
+ "invokeMilliseconds": 687.1,
+ "responseBytes": 29422,
+ "allocatedBytes": 4874664
},
"warm": {
- "invokeMilliseconds": 4.4,
- "responseBytes": 29141,
- "allocatedBytes": 580904
+ "invokeMilliseconds": 5,
+ "responseBytes": 29142,
+ "allocatedBytes": 679256
},
"noChangeRebuild": {
- "invokeMilliseconds": 3.5,
- "responseBytes": 29067,
+ "invokeMilliseconds": 4.8,
+ "responseBytes": 29066,
"allocatedBytes": 577656
},
"rootCommentEdit": {
- "invokeMilliseconds": 4.3,
- "responseBytes": 29103,
- "allocatedBytes": 630776
+ "invokeMilliseconds": 5,
+ "responseBytes": 29101,
+ "allocatedBytes": 630768
}
},
"bolt": {
@@ -34,104 +34,104 @@
"meshSha256": "aa9262734e2c79801a33b60f318d646b7a81aebda0b2bea9c0e711b775f835a6",
"rebuildMatchesCold": true,
"cold": {
- "invokeMilliseconds": 5620.5,
- "responseBytes": 6952197,
- "allocatedBytes": 957124552
+ "invokeMilliseconds": 5423.4,
+ "responseBytes": 6952201,
+ "allocatedBytes": 962555120
},
"warm": {
- "invokeMilliseconds": 2186.9,
+ "invokeMilliseconds": 1974.9,
"responseBytes": 6952173,
- "allocatedBytes": 885366696
+ "allocatedBytes": 885422368
},
"noChangeRebuild": {
- "invokeMilliseconds": 1816.5,
- "responseBytes": 6952123,
- "allocatedBytes": 885153208
+ "invokeMilliseconds": 1849.8,
+ "responseBytes": 6952121,
+ "allocatedBytes": 885176208
},
"leafCommentEdit": {
- "invokeMilliseconds": 1537.9,
+ "invokeMilliseconds": 1539.7,
"responseBytes": 6952121,
- "allocatedBytes": 882119736
+ "allocatedBytes": 882143264
},
"rootCommentEdit": {
- "invokeMilliseconds": 1567.8,
- "responseBytes": 6952157,
- "allocatedBytes": 882214976
+ "invokeMilliseconds": 1590.5,
+ "responseBytes": 6952154,
+ "allocatedBytes": 882245952
}
},
"atlas": {
- "stepDataSha256": "9509cba94c0b98b2a3f8ae2b037626f0bde11667c7c1297cbf5670c9f67b28af",
- "meshSha256": "49fe7e6ef3adce069b21582e99cb1f16876aa10d8da9b13b4b4e029a8b6c2c0b",
+ "stepDataSha256": "aa07767d5b34016a2c1d440818dc0e2c68ad69617006b9f0f22506c1679b2ef0",
+ "meshSha256": "027b4e5076983ac736cad3aa72543127150ef1fd5d78d78a841842ff4afd179b",
"rebuildMatchesCold": true,
"cold": {
- "invokeMilliseconds": 4639.7,
- "responseBytes": 1771521,
- "allocatedBytes": 619200920,
+ "invokeMilliseconds": 4496.6,
+ "responseBytes": 1771510,
+ "allocatedBytes": 361823128,
"reusedDefinitions": 0
},
"warm": {
- "invokeMilliseconds": 2013.7,
- "responseBytes": 1771430,
- "allocatedBytes": 609566080,
+ "invokeMilliseconds": 2184.1,
+ "responseBytes": 1771425,
+ "allocatedBytes": 350792672,
"reusedDefinitions": 0
},
"noChangeRebuild": {
- "invokeMilliseconds": 117.6,
- "responseBytes": 1728477,
- "allocatedBytes": 25563536,
+ "invokeMilliseconds": 61.1,
+ "responseBytes": 1728469,
+ "allocatedBytes": 25563688,
"reusedDefinitions": 24
},
"leafCommentEdit": {
- "invokeMilliseconds": 89.3,
- "responseBytes": 1728489,
- "allocatedBytes": 25796136,
+ "invokeMilliseconds": 146.3,
+ "responseBytes": 1728487,
+ "allocatedBytes": 25787352,
"reusedDefinitions": 24
},
"rootCommentEdit": {
- "invokeMilliseconds": 89,
- "responseBytes": 1728508,
- "allocatedBytes": 25557928,
+ "invokeMilliseconds": 62.5,
+ "responseBytes": 1728513,
+ "allocatedBytes": 25583552,
"reusedDefinitions": 24
}
},
"guitar": {
- "stepDataSha256": "51c8f8fed659bfb09a64317e276cca448c30c5bfe387cccbd8687e25cdb5d3aa",
- "meshSha256": "700ae75e20a1c49685e3d6478b4ff7e714cb28bd36491caf786c63c591a6a2c6",
+ "stepDataSha256": "868717d1b7826f59c073069c9557f04600606f037bd0ebdd29f2807908594449",
+ "meshSha256": "6758e0452b56318e0c7e40071cb0579f143edf2215c104e182fa9c055f59e867",
"rebuildMatchesCold": true,
"cold": {
- "invokeMilliseconds": 10850,
- "responseBytes": 9100217,
- "allocatedBytes": 1906481344,
+ "invokeMilliseconds": 9816,
+ "responseBytes": 9100194,
+ "allocatedBytes": 1230367672,
"reusedDefinitions": 0
},
"warm": {
- "invokeMilliseconds": 5270.6,
- "responseBytes": 9099983,
- "allocatedBytes": 1848811200,
+ "invokeMilliseconds": 3882.5,
+ "responseBytes": 9099938,
+ "allocatedBytes": 1170225960,
"reusedDefinitions": 0
},
"noChangeRebuild": {
- "invokeMilliseconds": 344.4,
- "responseBytes": 9014038,
- "allocatedBytes": 92704448,
+ "invokeMilliseconds": 337,
+ "responseBytes": 9014029,
+ "allocatedBytes": 91973440,
"reusedDefinitions": 56
},
"leafValueEdit": {
- "invokeMilliseconds": 339.9,
- "responseBytes": 9016040,
- "allocatedBytes": 123028784,
+ "invokeMilliseconds": 349.5,
+ "responseBytes": 9016050,
+ "allocatedBytes": 123110832,
"reusedDefinitions": 54
},
"leafCommentEdit": {
- "invokeMilliseconds": 1143.5,
- "responseBytes": 9015249,
- "allocatedBytes": 574376840,
+ "invokeMilliseconds": 636.6,
+ "responseBytes": 9015234,
+ "allocatedBytes": 238374320,
"reusedDefinitions": 55
},
"rootCommentEdit": {
- "invokeMilliseconds": 130.8,
- "responseBytes": 9014055,
- "allocatedBytes": 91458568,
+ "invokeMilliseconds": 250.6,
+ "responseBytes": 9014054,
+ "allocatedBytes": 91630288,
"reusedDefinitions": 56
}
},
@@ -140,29 +140,29 @@
"meshSha256": "ce00e129709c10a86151b4bea6f000947cf1c51e0bb4a226b67aea8f3d54a15a",
"rebuildMatchesCold": true,
"cold": {
- "invokeMilliseconds": 2656.4,
- "responseBytes": 2711150,
- "allocatedBytes": 335707048
+ "invokeMilliseconds": 2723.2,
+ "responseBytes": 2711177,
+ "allocatedBytes": 332010280
},
"warm": {
- "invokeMilliseconds": 1394.6,
- "responseBytes": 2711082,
- "allocatedBytes": 324714384
+ "invokeMilliseconds": 1488.3,
+ "responseBytes": 2711090,
+ "allocatedBytes": 324710896
},
"noChangeRebuild": {
- "invokeMilliseconds": 162.3,
- "responseBytes": 2640572,
- "allocatedBytes": 38404312
+ "invokeMilliseconds": 163.8,
+ "responseBytes": 2640585,
+ "allocatedBytes": 38407000
},
"leafCommentEdit": {
- "invokeMilliseconds": 140.6,
- "responseBytes": 2640573,
- "allocatedBytes": 38407392
+ "invokeMilliseconds": 139,
+ "responseBytes": 2640576,
+ "allocatedBytes": 38410992
},
"rootCommentEdit": {
- "invokeMilliseconds": 163.8,
- "responseBytes": 2640601,
- "allocatedBytes": 38371888
+ "invokeMilliseconds": 162,
+ "responseBytes": 2640598,
+ "allocatedBytes": 38391040
}
}
}
diff --git a/docs/development/milestones/general/build-perf-ladder.md b/docs/development/milestones/general/build-perf-ladder.md
index ee1d1310..8b0a2424 100644
--- a/docs/development/milestones/general/build-perf-ladder.md
+++ b/docs/development/milestones/general/build-perf-ladder.md
@@ -159,6 +159,13 @@ profile memo. Guitar `CarvedMaple` edit 5.7 → 1.14 s, warm 7.6 → 5.3 s (targ
bolt edit 3.1 → 1.6 s. Remaining share is the 8193-sample bounded-pcurve qualification (policy
decision) and the bolt's two mass-property enclosure checks.
+**Result** ([BUILD-PERF-M4](../../../release/BUILD-PERF-M4.md)): success. Second pass: SectionChain
+trims constructed with their patches (`ConstructedBoundary`: each edge is an isoparametric boundary
+of its own patch) instead of recovered and qualified at 8193 samples; the old density is now a test
+oracle. Guitar warm 3.9 s (target ≤ 5 s), `CarvedMaple` edit 0.64 s; STEP for guitar/ATLAS changes
+by its trims only (compare-step: 3.2e-12 relative), rebaselined deliberately. Next authoring-time
+candidate: face orientation on reimport of our own STEP.
+
### M5 — First paint
- Showcase projects ship a precomputed binary display mesh keyed by source hash; the editor shows
diff --git a/docs/release/BUILD-PERF-M4.md b/docs/release/BUILD-PERF-M4.md
index 5441f742..4b7046bc 100644
--- a/docs/release/BUILD-PERF-M4.md
+++ b/docs/release/BUILD-PERF-M4.md
@@ -1,13 +1,13 @@
-# BUILD-PERF-M4 — Kernel hotspots (first pass)
+# BUILD-PERF-M4 — Kernel hotspots
Ladder: [build-perf-ladder.md](../development/milestones/general/build-perf-ladder.md) ·
previous: [BUILD-PERF-M2](BUILD-PERF-M2.md).
-**State: meaningful progression.** Every change is bit-exact: STEP and display-mesh hashes are
-identical for every showcase project. The guitar `CarvedMaple` edit, the slow edit left by M2, fell
-5.7 s → 1.14 s natively. The guitar warm build is 5.3 s (median of 3, runs 4.6–5.7 s) against the
-≤ 5 s working target. The rest of the edit time is the bounded-pcurve qualification sampling. Making
-it cheaper is a policy decision, not an optimization (see the end).
+**State: success.** The exit target is met: guitar warm build 3.9 s (≤ 5 s; 13.9 s at M0). The
+first pass (changes 1–4) is bit-exact. The second pass (change 5) changes how SectionChain trims are
+*produced*: they are constructed with their patches instead of recovered and densely re-checked. That
+changes STEP and display-mesh hashes for the two projects with SectionChain bodies (guitar, ATLAS),
+justified below. The guitar `CarvedMaple` edit fell 5.7 s → 0.64 s natively.
## Changes
@@ -29,29 +29,54 @@ it cheaper is a policy decision, not an optimization (see the end).
function of (content, height, alignment, feature id); the last 16 results are reused. Bolt edit
3.0 s → 1.5 s.
+5. **Trims by construction** (second pass). Every SectionChain transition face is bounded by four
+ isoparametric curves of its own patch: source profile (v = start), target profile (v = end), and
+ the two longitudinal boundaries (u = start, u = end). In the smooth lane those are literally the
+ patch's control rows; in the ruled lane they are its boundary curves and straight rulings. Each edge
+ is bound with a parameter affine to the patch's, so its trim is the matching straight side of the
+ parameter rectangle. `SectionChains.BuildBody` now binds these trims at construction, with the new
+ origin `PcurveBindingOrigin.ConstructedBoundary`, a 33-sample guard (≤ 1e-7 mm, else the trim is
+ left to recovery) and the existing 129-sample retained-trim check in `Populate`. Before, every
+ trim was recovered by inverse projection (grid seed + Newton at 129–4097 points) and qualified at
+ 8193 lifted samples, about 10.5 million spline evaluations per guitar cold build. Measured on the
+ guitar and ATLAS bodies: every transition trim is constructed (CarvedMaple 288, Neck 216,
+ MahoganyBack 72, IvoryBinding 72, fore/upper housing 128 each), with lift deviations of 0 to
+ 2.3e-13 mm. Approximated (non-exact) ruled patches and analytic surfaces keep the recovery path. The
+ exporter writes the constructed trims as `PCURVE`s, and reimport keeps them as source trims.
+
+ **Why the hashes changed, and why that is correct.** STEP now carries exact isoparametric lines
+ instead of recovered polylines (fewer `LINE`/`VECTOR`/`DIRECTION` entities, same `PCURVE` count).
+ The display tessellator trims with them. `compare-step` between the previous and new exports:
+ guitar worst relative difference 3.2e-12, ATLAS 4.9e-16 (tolerance 1e-6): equivalent products.
+ The old qualification density is now a test oracle (`ConstructedSectionChainTrimTests`: 8193
+ lifted samples per constructed trim, ≤ 1e-7 mm, smooth and ruled lanes; constructed trims round-trip
+ through STEP as source trims).
+
## Results (native, median of 3, 2-core container)
| Project | Scenario | M2 | M4 |
|---|---|---|---|
-| guitar | `CarvedMaple` comment edit | 5.70 s (M1) | **1.14 s** |
-| guitar | warm build | 7.64 s | **5.27 s** |
-| guitar | cold build | 16.4 s | **10.9 s** |
-| guitar | knob value edit | ~0.40 s | 0.34 s |
-| atlas | cold / warm | 7.3 / 2.7 s | **4.6 / 2.0 s** |
+| guitar | `CarvedMaple` comment edit | 5.70 s (M1) | 1.14 s (pass 1) → **0.64 s** |
+| guitar | warm build | 7.64 s | 5.27 s (pass 1) → **3.88 s** |
+| guitar | cold build | 16.4 s | 10.9 s (pass 1) → **9.8 s** |
+| guitar | knob value edit | ~0.40 s | 0.35 s |
+| atlas | cold / warm | 7.3 / 2.7 s | **4.5 / 2.2 s** |
+| atlas | `fore-housing` edit (verify-incremental) | ~1.3 s | **0.13–0.23 s** |
| bolt | root comment edit | 3.06 s | **1.57 s** |
| bolt | cold | 6.9 s | 5.6 s |
-New ratchet baseline written (`Aetheris.Web.Perf/build-perf-budgets.json`). Full lane 4581/4581.
-AOT browser numbers to be re-measured on the author's machine.
+New ratchet baseline written after each pass (`Aetheris.Web.Perf/build-perf-budgets.json`; the
+second one deliberately takes the new guitar/ATLAS hashes). Full lane 4585/4585. `verify-incremental`
+(guitar, all ATLAS documents) and `verify-bridge` pass. AOT browser numbers to be re-measured on the
+author's machine.
## What remains, with evidence
-- **Bounded pcurve qualification** (`pcurve.bounded-build`, 856 of the 1 144 ms CarvedMaple edit;
- 3.0 s of the guitar cold build). 80% of it is `MaximumResidual`: every recovered spline pcurve is
- lifted and compared at **8193** samples, plus up to 4097 inverse samples while refining. One guitar
- cold build performs about 10.5 million B-spline surface evaluations. The arithmetic is now as lean
- as it can be without changing results. Fewer lift samples, or an adaptive (error-bounded) residual,
- would change the qualification evidence each binding records, so it is a policy decision.
+- **Reimport orientation check.** Reimporting our own canonical STEP still resolves face
+ orientation by tessellating the body (580 of 667 ms for CarvedMaple). Like the trims, the exporter
+ already knows the orientation. The next authoring-time candidate.
+- **Other recovered trims**: analytic surfaces (cylinders, cones, tori via `BuildPeriodicAnalytic`)
+ and approximated ruled patches still go through recovery. They were not hot in the showcase.
- **Bolt**: two `BrepMassProperties.Evaluate` enclosure checks (thread composition and maker-mark
imprint, ~2.3 s together, tessellation-based) are now the bulk of every bolt rebuild.
- **Datum-seat validation** on cold builds (guitar 1.2 s): tessellates every placed body once.