Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add prismatic CIR mirror feasibility lab

Yuechen Li572f2207382c
diff --git a/Aetheris.Firmament.FrictionLab/CIRLab/CirPrismaticMirrorLab.cs b/Aetheris.Firmament.FrictionLab/CIRLab/CirPrismaticMirrorLab.cs
new file mode 100644
index 00000000..6644bef4
--- /dev/null
+++ b/Aetheris.Firmament.FrictionLab/CIRLab/CirPrismaticMirrorLab.cs
@@ -0,0 +1,462 @@
+using Aetheris.Kernel.Core.Cir;
+using Aetheris.Kernel.Core.Math;
+
+namespace Aetheris.Firmament.FrictionLab.CIRLab;
+
+public enum CirPrismaticMirrorStrategy
+{
+ HalfSpaceConvexPolyhedron,
+ SectionStackImplicit,
+}
+
+public enum CirPrismaticMirrorRequestKind
+{
+ PointContainmentAndMapOccupancy,
+ FaceIdentity,
+ TopologyParity,
+}
+
+public sealed record CirPrismaticPointExpectation(string Name, Point3D Point, bool ExpectedInside, string Reason);
+
+public sealed record CirPrismaticPointClassification(string Name, Point3D Point, bool ExpectedInside, bool ActualInside, double SignedDistance, bool Matched, string Reason);
+
+public sealed record CirPrismaticMapSummary(
+ int Rows,
+ int Cols,
+ int TotalSamples,
+ int HitSamples,
+ int EmptySamples,
+ double? ThicknessMin,
+ double? ThicknessMax,
+ double? ThicknessAverage,
+ string Bounds)
+{
+ public override string ToString() => FormattableString.Invariant(
+ $"rows={Rows};cols={Cols};total={TotalSamples};hit={HitSamples};empty={EmptySamples};min={Fmt(ThicknessMin)};max={Fmt(ThicknessMax)};avg={Fmt(ThicknessAverage)};bounds={Bounds}");
+
+ private static string Fmt(double? value) => value is { } v ? v.ToString("0.###", System.Globalization.CultureInfo.InvariantCulture) : "null";
+}
+
+public sealed record CirPrismaticMirrorResult(
+ string CaseName,
+ CirPrismaticMirrorStrategy Strategy,
+ string MirrorStatus,
+ string Capabilities,
+ string KnownLosses,
+ bool Succeeded,
+ IReadOnlyList<CirPrismaticPointClassification> PointClassifications,
+ CirPrismaticMapSummary? MapSummary,
+ IReadOnlyList<string> Diagnostics,
+ string Recommendation)
+{
+ public string StableProjection() => string.Join("|", new[]
+ {
+ CaseName,
+ Strategy.ToString(),
+ MirrorStatus,
+ Capabilities,
+ KnownLosses,
+ Succeeded.ToString(),
+ MapSummary?.ToString() ?? "no-map",
+ string.Join(",", PointClassifications.Select(p => FormattableString.Invariant($"{p.Name}:{p.ActualInside}:{p.SignedDistance:0.######}:{p.Matched}"))),
+ string.Join(",", Diagnostics),
+ Recommendation,
+ });
+}
+
+public static class CirPrismaticMirrorLab
+{
+ private const double DefaultTolerance = 1e-7d;
+ private const int MapRows = 16;
+ private const int MapCols = 16;
+ private const int ThicknessSamples = 96;
+
+ public static IReadOnlyList<CirPrismaticMirrorResult> RunRequiredCases() =>
+ [
+ Evaluate("rectangle-inset", PrismaticSectionTransitionEmitterLab.RectangleToInsetRectangle(), CirPrismaticMirrorStrategy.HalfSpaceConvexPolyhedron),
+ Evaluate("rectangle-inset", PrismaticSectionTransitionEmitterLab.RectangleToInsetRectangle(), CirPrismaticMirrorStrategy.SectionStackImplicit),
+ Evaluate("top-edge-chamfer", TopEdgeChamferCase(), CirPrismaticMirrorStrategy.HalfSpaceConvexPolyhedron),
+ Evaluate("top-edge-chamfer", TopEdgeChamferCase(), CirPrismaticMirrorStrategy.SectionStackImplicit),
+ ];
+
+ public static CirPrismaticMirrorResult Evaluate(
+ string caseName,
+ PrismaticSectionTransitionCase sourceCase,
+ CirPrismaticMirrorStrategy strategy,
+ CirPrismaticMirrorRequestKind requestKind = CirPrismaticMirrorRequestKind.PointContainmentAndMapOccupancy,
+ double tolerance = DefaultTolerance)
+ {
+ var diagnostics = new List<string>
+ {
+ "cir-prismatic-x1-lab-started",
+ $"cir-prismatic-x1-case-started:{caseName}",
+ strategy == CirPrismaticMirrorStrategy.HalfSpaceConvexPolyhedron
+ ? "cir-prismatic-x1-strategy-halfspace-attempted"
+ : "cir-prismatic-x1-strategy-section-stack-attempted",
+ "cir-prismatic-x1-loss-face-identity",
+ "cir-prismatic-x1-loss-loop-identity",
+ "cir-prismatic-x1-loss-split-face-lineage",
+ "cir-prismatic-x1-loss-topology-parity",
+ "cir-prismatic-x1-no-production-analyzer-behavior-changed",
+ "cir-prismatic-x1-no-cir-to-brep-extraction",
+ };
+
+ if (requestKind is CirPrismaticMirrorRequestKind.FaceIdentity or CirPrismaticMirrorRequestKind.TopologyParity)
+ {
+ diagnostics.Add("cir-prismatic-x1-mirror-rejected-lossy-for-request");
+ diagnostics.Add(requestKind == CirPrismaticMirrorRequestKind.FaceIdentity
+ ? "cir-prismatic-x1-request-face-identity-rejected"
+ : "cir-prismatic-x1-request-topology-parity-rejected");
+ return new(caseName, strategy, "mirror-rejected-lossy-for-request", "none", LossesText(), false, [], null, StableDiagnostics(diagnostics), "cir-prismatic-mirror-invalid-rejected");
+ }
+
+ var validationBlocker = ValidateCase(sourceCase, tolerance);
+ if (validationBlocker is not null)
+ {
+ diagnostics.Add(strategy == CirPrismaticMirrorStrategy.HalfSpaceConvexPolyhedron
+ ? $"cir-prismatic-x1-strategy-halfspace-blocked:{validationBlocker}"
+ : $"cir-prismatic-x1-strategy-section-stack-blocked:{validationBlocker}");
+ return new(caseName, strategy, "mirror-unavailable", "none", LossesText(), false, [], null, StableDiagnostics(diagnostics), "cir-prismatic-mirror-deferred");
+ }
+
+ IPrismaticMirrorEvaluator evaluator = strategy == CirPrismaticMirrorStrategy.HalfSpaceConvexPolyhedron
+ ? HalfSpacePrismaticMirror.Create(sourceCase.Sections, tolerance)
+ : SectionStackPrismaticMirror.Create(sourceCase.Sections, tolerance);
+
+ diagnostics.Add(strategy == CirPrismaticMirrorStrategy.HalfSpaceConvexPolyhedron
+ ? "cir-prismatic-x1-strategy-halfspace-succeeded"
+ : "cir-prismatic-x1-strategy-section-stack-succeeded");
+ diagnostics.Add($"cir-prismatic-x1-mirror-admitted-exact:{caseName}");
+ diagnostics.Add($"cir-prismatic-x1-point-classification-succeeded:{caseName}");
+ diagnostics.Add($"cir-prismatic-x1-map-summary-created:{caseName}");
+
+ var classifications = TestPoints(caseName).Select(p => Classify(evaluator, p, tolerance)).ToArray();
+ if (classifications.Any(p => !p.Matched))
+ {
+ diagnostics.Add($"cir-prismatic-x1-point-classification-mismatch:{caseName}");
+ }
+
+ var summary = CreateMapSummary(evaluator, tolerance);
+ return new(
+ caseName,
+ strategy,
+ "mirror-admitted-exact",
+ "point-containment,map-occupancy,section-sampling,approximate-volume",
+ LossesText(),
+ classifications.All(p => p.Matched),
+ classifications,
+ summary,
+ StableDiagnostics(diagnostics),
+ strategy == CirPrismaticMirrorStrategy.HalfSpaceConvexPolyhedron
+ ? "cir-prismatic-mirror-use-convex-polyhedron-first"
+ : "cir-prismatic-mirror-needs-section-stack-evaluator");
+ }
+
+ private static PrismaticSectionTransitionCase TopEdgeChamferCase() =>
+ new(
+ "top-edge-chamfer",
+ PrismaticTopEdgeChamferLab.CreateSectionStack(new PrismaticTopEdgeChamferCase("canonical-top-pos-x-edge", 10, 8, 6, 1)),
+ PrismaticCorrespondenceMap.Identity(4));
+
+ private static string? ValidateCase(PrismaticSectionTransitionCase sourceCase, double tolerance)
+ {
+ if (sourceCase.Correspondence is null)
+ {
+ return "missing-correspondence";
+ }
+
+ if (sourceCase.Sections.Count < 2)
+ {
+ return "too-few-sections";
+ }
+
+ var vertexCount = sourceCase.Sections[0].OuterLoop.Count;
+ if (vertexCount < 3 || sourceCase.Correspondence.VertexMap.Count != vertexCount)
+ {
+ return "unsupported-correspondence";
+ }
+
+ for (var i = 0; i < sourceCase.Sections.Count; i++)
+ {
+ var section = sourceCase.Sections[i];
+ if (section.HasArcs || section.HasHoles || section.OuterLoopCount != 1)
+ {
+ return "non-line-only-single-loop-section";
+ }
+
+ if (section.OuterLoop.Count != vertexCount)
+ {
+ return "mismatched-vertex-count";
+ }
+
+ if (SignedArea(section.OuterLoop) <= tolerance)
+ {
+ return "non-convex-or-non-ccw-profile";
+ }
+
+ if (!IsConvex(section.OuterLoop, tolerance))
+ {
+ return "non-convex-profile";
+ }
+
+ if (i > 0 && section.Z <= sourceCase.Sections[i - 1].Z + tolerance)
+ {
+ return "non-increasing-z";
+ }
+ }
+
+ return null;
+ }
+
+ private static CirPrismaticPointClassification Classify(IPrismaticMirrorEvaluator evaluator, CirPrismaticPointExpectation expectation, double tolerance)
+ {
+ var distance = evaluator.SignedDistance(expectation.Point);
+ var inside = distance <= tolerance;
+ return new(expectation.Name, expectation.Point, expectation.ExpectedInside, inside, distance, inside == expectation.ExpectedInside, expectation.Reason);
+ }
+
+ private static IReadOnlyList<CirPrismaticPointExpectation> TestPoints(string caseName) => caseName switch
+ {
+ "rectangle-inset" =>
+ [
+ new("center-mid-height", new Point3D(0, 0, 0.5), true, "inside center at mid-height"),
+ new("outside-far-pos-x", new Point3D(7, 0, 0.5), false, "outside far +X"),
+ new("outside-far-pos-y", new Point3D(0, 6, 0.5), false, "outside far +Y"),
+ new("lower-full-rectangle-only", new Point3D(4.75, 0, 0.05), true, "inside lower wide rectangle below inset transition"),
+ new("upper-inset-excluded", new Point3D(4.75, 0, 0.95), false, "outside upper inset at same X"),
+ new("near-side-plane-inside", new Point3D(4 - (DefaultTolerance * 0.25), 0, 1), true, "inside within tolerance near upper +X side"),
+ new("near-side-plane-outside", new Point3D(4 + (DefaultTolerance * 2), 0, 1), false, "outside beyond tolerance near upper +X side"),
+ ],
+ "top-edge-chamfer" =>
+ [
+ new("lower-body-below-transition", new Point3D(4.75, 0, 4.5), true, "inside lower body below transition"),
+ new("above-inset-excluded-pos-x", new Point3D(4.75, 0, 6), false, "outside upper inset excluded area near +X top transition"),
+ new("below-chamfer-plane", new Point3D(4.25, 0, 5.25), true, "inside below chamfer plane near transition"),
+ new("beyond-chamfer-plane", new Point3D(4.75, 0, 5.75), false, "outside beyond chamfer plane"),
+ new("center-inside", new Point3D(0, 0, 3), true, "center inside"),
+ ],
+ _ => [new("center", new Point3D(0, 0, 0), true, "default center")],
+ };
+
+ private static CirPrismaticMapSummary CreateMapSummary(IPrismaticMirrorEvaluator evaluator, double tolerance)
+ {
+ var bounds = evaluator.Bounds;
+ var thicknesses = new List<double>();
+ var total = MapRows * MapCols;
+ for (var row = 0; row < MapRows; row++)
+ {
+ var y = bounds.Min.Y + ((row + 0.5d) / MapRows * bounds.SizeY);
+ for (var col = 0; col < MapCols; col++)
+ {
+ var x = bounds.Min.X + ((col + 0.5d) / MapCols * bounds.SizeX);
+ var thickness = EstimateZThickness(evaluator, x, y, tolerance);
+ if (thickness > tolerance)
+ {
+ thicknesses.Add(thickness);
+ }
+ }
+ }
+
+ return new(
+ MapRows,
+ MapCols,
+ total,
+ thicknesses.Count,
+ total - thicknesses.Count,
+ thicknesses.Count == 0 ? null : thicknesses.Min(),
+ thicknesses.Count == 0 ? null : thicknesses.Max(),
+ thicknesses.Count == 0 ? null : thicknesses.Average(),
+ FormatBounds(bounds));
+ }
+
+ private static double EstimateZThickness(IPrismaticMirrorEvaluator evaluator, double x, double y, double tolerance)
+ {
+ var bounds = evaluator.Bounds;
+ var step = bounds.SizeZ / ThicknessSamples;
+ var insideCount = 0;
+ for (var i = 0; i < ThicknessSamples; i++)
+ {
+ var z = bounds.Min.Z + ((i + 0.5d) / ThicknessSamples * bounds.SizeZ);
+ if (evaluator.SignedDistance(new Point3D(x, y, z)) <= tolerance)
+ {
+ insideCount++;
+ }
+ }
+
+ return insideCount * step;
+ }
+
+ private static string FormatBounds(CirBounds bounds) => FormattableString.Invariant(
+ $"[{bounds.Min.X:0.###},{bounds.Min.Y:0.###},{bounds.Min.Z:0.###}]..[{bounds.Max.X:0.###},{bounds.Max.Y:0.###},{bounds.Max.Z:0.###}]");
+
+ private static string LossesText() => "face-identity-lost,loop-identity-lost,split-face-lineage-lost,feature-role-labels-lost,topology-parity-unavailable";
+
+ private static IReadOnlyList<string> StableDiagnostics(IEnumerable<string> diagnostics) =>
+ diagnostics.Distinct(StringComparer.Ordinal).OrderBy(x => x, StringComparer.Ordinal).ToArray();
+
+ private static double SignedArea(IReadOnlyList<(double X, double Y)> loop)
+ {
+ var area = 0d;
+ for (var i = 0; i < loop.Count; i++)
+ {
+ var a = loop[i];
+ var b = loop[(i + 1) % loop.Count];
+ area += (a.X * b.Y) - (b.X * a.Y);
+ }
+
+ return area * 0.5d;
+ }
+
+ private static bool IsConvex(IReadOnlyList<(double X, double Y)> loop, double tolerance)
+ {
+ for (var i = 0; i < loop.Count; i++)
+ {
+ var a = loop[i];
+ var b = loop[(i + 1) % loop.Count];
+ var c = loop[(i + 2) % loop.Count];
+ var cross = ((b.X - a.X) * (c.Y - b.Y)) - ((b.Y - a.Y) * (c.X - b.X));
+ if (cross < -tolerance)
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private interface IPrismaticMirrorEvaluator
+ {
+ CirBounds Bounds { get; }
+
+ double SignedDistance(Point3D point);
+ }
+
+ private sealed record Plane(double A, double B, double C, double D)
+ {
+ public double Evaluate(Point3D point) => (A * point.X) + (B * point.Y) + (C * point.Z) + D;
+ }
+
+ private sealed class HalfSpacePrismaticMirror : IPrismaticMirrorEvaluator
+ {
+ private readonly IReadOnlyList<Plane> _planes;
+
+ private HalfSpacePrismaticMirror(IReadOnlyList<Plane> planes, CirBounds bounds)
+ {
+ _planes = planes;
+ Bounds = bounds;
+ }
+
+ public CirBounds Bounds { get; }
+
+ public static HalfSpacePrismaticMirror Create(IReadOnlyList<PrismaticSection> sections, double tolerance)
+ {
+ var planes = new List<Plane>();
+ var minZ = sections.Min(s => s.Z);
+ var maxZ = sections.Max(s => s.Z);
+ planes.Add(new Plane(0, 0, -1, minZ));
+ planes.Add(new Plane(0, 0, 1, -maxZ));
+
+ for (var sectionIndex = 0; sectionIndex < sections.Count - 1; sectionIndex++)
+ {
+ var lower = sections[sectionIndex];
+ var upper = sections[sectionIndex + 1];
+ for (var i = 0; i < lower.OuterLoop.Count; i++)
+ {
+ var a0 = ToPoint(lower.OuterLoop[i], lower.Z);
+ var a1 = ToPoint(lower.OuterLoop[(i + 1) % lower.OuterLoop.Count], lower.Z);
+ var b0 = ToPoint(upper.OuterLoop[i], upper.Z);
+ var edge = a1 - a0;
+ var lift = b0 - a0;
+ var normal = Cross(edge, lift);
+ var length = double.Sqrt((normal.X * normal.X) + (normal.Y * normal.Y) + (normal.Z * normal.Z));
+ if (length <= tolerance)
+ {
+ continue;
+ }
+
+ var nx = normal.X / length;
+ var ny = normal.Y / length;
+ var nz = normal.Z / length;
+ planes.Add(new Plane(nx, ny, nz, -((nx * a0.X) + (ny * a0.Y) + (nz * a0.Z))));
+ }
+ }
+
+ return new(planes, BoundsFor(sections));
+ }
+
+ public double SignedDistance(Point3D point) => _planes.Max(p => p.Evaluate(point));
+ }
+
+ private sealed class SectionStackPrismaticMirror : IPrismaticMirrorEvaluator
+ {
+ private readonly IReadOnlyList<PrismaticSection> _sections;
+
+ private SectionStackPrismaticMirror(IReadOnlyList<PrismaticSection> sections)
+ {
+ _sections = sections;
+ Bounds = BoundsFor(sections);
+ }
+
+ public CirBounds Bounds { get; }
+
+ public static SectionStackPrismaticMirror Create(IReadOnlyList<PrismaticSection> sections, double _) => new(sections);
+
+ public double SignedDistance(Point3D point)
+ {
+ if (point.Z < Bounds.Min.Z)
+ {
+ return Bounds.Min.Z - point.Z;
+ }
+
+ if (point.Z > Bounds.Max.Z)
+ {
+ return point.Z - Bounds.Max.Z;
+ }
+
+ var interval = 0;
+ for (var i = 0; i < _sections.Count - 1; i++)
+ {
+ if (point.Z >= _sections[i].Z && point.Z <= _sections[i + 1].Z)
+ {
+ interval = i;
+ break;
+ }
+ }
+
+ var lower = _sections[interval];
+ var upper = _sections[interval + 1];
+ var t = (point.Z - lower.Z) / (upper.Z - lower.Z);
+ var maxSide = double.NegativeInfinity;
+ for (var i = 0; i < lower.OuterLoop.Count; i++)
+ {
+ var a = Interpolate(lower.OuterLoop[i], upper.OuterLoop[i], t);
+ var b = Interpolate(lower.OuterLoop[(i + 1) % lower.OuterLoop.Count], upper.OuterLoop[(i + 1) % lower.OuterLoop.Count], t);
+ var dx = b.X - a.X;
+ var dy = b.Y - a.Y;
+ var length = double.Sqrt((dx * dx) + (dy * dy));
+ var value = (((point.X - a.X) * dy) - ((point.Y - a.Y) * dx)) / length;
+ maxSide = double.Max(maxSide, value);
+ }
+
+ var zDistance = double.Max(Bounds.Min.Z - point.Z, point.Z - Bounds.Max.Z);
+ return double.Max(maxSide, zDistance);
+ }
+ }
+
+ private static Point3D ToPoint((double X, double Y) point, double z) => new(point.X, point.Y, z);
+
+ private static (double X, double Y) Interpolate((double X, double Y) lower, (double X, double Y) upper, double t) =>
+ (lower.X + ((upper.X - lower.X) * t), lower.Y + ((upper.Y - lower.Y) * t));
+
+ private static Vector3D Cross(Vector3D a, Vector3D b) => new(
+ (a.Y * b.Z) - (a.Z * b.Y),
+ (a.Z * b.X) - (a.X * b.Z),
+ (a.X * b.Y) - (a.Y * b.X));
+
+ private static CirBounds BoundsFor(IReadOnlyList<PrismaticSection> sections)
+ {
+ var xs = sections.SelectMany(s => s.OuterLoop.Select(p => p.X)).ToArray();
+ var ys = sections.SelectMany(s => s.OuterLoop.Select(p => p.Y)).ToArray();
+ return new(new Point3D(xs.Min(), ys.Min(), sections.Min(s => s.Z)), new Point3D(xs.Max(), ys.Max(), sections.Max(s => s.Z)));
+ }
+}
diff --git a/Aetheris.FrictionLab.Tests/CIRLab/CirPrismaticMirrorLabTests.cs b/Aetheris.FrictionLab.Tests/CIRLab/CirPrismaticMirrorLabTests.cs
new file mode 100644
index 00000000..252f7a99
--- /dev/null
+++ b/Aetheris.FrictionLab.Tests/CIRLab/CirPrismaticMirrorLabTests.cs
@@ -0,0 +1,105 @@
+using Aetheris.Firmament.FrictionLab.CIRLab;
+
+namespace Aetheris.FrictionLab.Tests.CIRLab;
+
+public sealed class CirPrismaticMirrorLabTests
+{
+ private static string Stable(CirPrismaticMirrorResult result) => result.StableProjection();
+
+ [Theory]
+ [InlineData("rectangle-inset", CirPrismaticMirrorStrategy.HalfSpaceConvexPolyhedron)]
+ [InlineData("rectangle-inset", CirPrismaticMirrorStrategy.SectionStackImplicit)]
+ public void CirPrismaticX1_RectangleInsetMirrorFeasibility_ClassifiesPointsAndCreatesStableMap(
+ string caseName,
+ CirPrismaticMirrorStrategy strategy)
+ {
+ var result = CirPrismaticMirrorLab.RunRequiredCases().Single(x => x.CaseName == caseName && x.Strategy == strategy);
+
+ Assert.True(result.Succeeded);
+ Assert.Equal("mirror-admitted-exact", result.MirrorStatus);
+ Assert.Contains("point-containment", result.Capabilities);
+ Assert.Contains("map-occupancy", result.Capabilities);
+ Assert.Contains("face-identity-lost", result.KnownLosses);
+ Assert.Contains("topology-parity-unavailable", result.KnownLosses);
+ Assert.All(result.PointClassifications, p => Assert.True(p.Matched, $"{p.Name} expected {p.ExpectedInside} but was {p.ActualInside} ({p.SignedDistance})"));
+ Assert.Contains(result.PointClassifications, p => p.Name == "center-mid-height" && p.ActualInside);
+ Assert.Contains(result.PointClassifications, p => p.Name == "outside-far-pos-x" && !p.ActualInside);
+ Assert.Contains(result.PointClassifications, p => p.Name == "outside-far-pos-y" && !p.ActualInside);
+ Assert.Contains(result.PointClassifications, p => p.Name == "lower-full-rectangle-only" && p.ActualInside);
+ Assert.Contains(result.PointClassifications, p => p.Name == "upper-inset-excluded" && !p.ActualInside);
+ Assert.NotNull(result.MapSummary);
+ Assert.Equal(16, result.MapSummary!.Rows);
+ Assert.Equal(16, result.MapSummary.Cols);
+ Assert.Equal(256, result.MapSummary.TotalSamples);
+ Assert.Equal("[-5,-4,0]..[5,4,1]", result.MapSummary.Bounds);
+ Assert.Equal(256, result.MapSummary.HitSamples);
+ Assert.Equal(0, result.MapSummary.EmptySamples);
+ Assert.Equal(0.250, Math.Round(result.MapSummary.ThicknessMin!.Value, 3));
+ Assert.Equal(1.000, Math.Round(result.MapSummary.ThicknessMax!.Value, 3));
+ Assert.Equal(strategy == CirPrismaticMirrorStrategy.HalfSpaceConvexPolyhedron
+ ? "cir-prismatic-mirror-use-convex-polyhedron-first"
+ : "cir-prismatic-mirror-needs-section-stack-evaluator", result.Recommendation);
+ Assert.Contains("cir-prismatic-x1-mirror-admitted-exact:rectangle-inset", result.Diagnostics);
+ Assert.Contains("cir-prismatic-x1-point-classification-succeeded:rectangle-inset", result.Diagnostics);
+ Assert.Contains("cir-prismatic-x1-map-summary-created:rectangle-inset", result.Diagnostics);
+ Assert.Contains("cir-prismatic-x1-no-production-analyzer-behavior-changed", result.Diagnostics);
+ Assert.Contains("cir-prismatic-x1-no-cir-to-brep-extraction", result.Diagnostics);
+ }
+
+ [Theory]
+ [InlineData(CirPrismaticMirrorStrategy.HalfSpaceConvexPolyhedron)]
+ [InlineData(CirPrismaticMirrorStrategy.SectionStackImplicit)]
+ public void CirPrismaticX1_TopEdgeChamferMirrorFeasibility_ClassifiesPointsAndCreatesStableMap(CirPrismaticMirrorStrategy strategy)
+ {
+ var result = CirPrismaticMirrorLab.RunRequiredCases().Single(x => x.CaseName == "top-edge-chamfer" && x.Strategy == strategy);
+
+ Assert.True(result.Succeeded);
+ Assert.Equal("mirror-admitted-exact", result.MirrorStatus);
+ Assert.All(result.PointClassifications, p => Assert.True(p.Matched, $"{p.Name} expected {p.ExpectedInside} but was {p.ActualInside} ({p.SignedDistance})"));
+ Assert.Contains(result.PointClassifications, p => p.Name == "lower-body-below-transition" && p.ActualInside);
+ Assert.Contains(result.PointClassifications, p => p.Name == "above-inset-excluded-pos-x" && !p.ActualInside);
+ Assert.Contains(result.PointClassifications, p => p.Name == "below-chamfer-plane" && p.ActualInside);
+ Assert.Contains(result.PointClassifications, p => p.Name == "beyond-chamfer-plane" && !p.ActualInside);
+ Assert.Contains(result.PointClassifications, p => p.Name == "center-inside" && p.ActualInside);
+ Assert.NotNull(result.MapSummary);
+ Assert.Equal(256, result.MapSummary!.TotalSamples);
+ Assert.Equal("[-5,-4,0]..[5,4,6]", result.MapSummary.Bounds);
+ Assert.Equal(256, result.MapSummary.HitSamples);
+ Assert.Equal(0, result.MapSummary.EmptySamples);
+ Assert.Equal(5.312, Math.Round(result.MapSummary.ThicknessMin!.Value, 3));
+ Assert.Equal(6.000, Math.Round(result.MapSummary.ThicknessMax!.Value, 3));
+ Assert.Contains("cir-prismatic-x1-mirror-admitted-exact:top-edge-chamfer", result.Diagnostics);
+ Assert.Contains("cir-prismatic-x1-map-summary-created:top-edge-chamfer", result.Diagnostics);
+ }
+
+ [Theory]
+ [InlineData(CirPrismaticMirrorRequestKind.FaceIdentity)]
+ [InlineData(CirPrismaticMirrorRequestKind.TopologyParity)]
+ public void CirPrismaticX1_LossyRequestsRejectWithMetadataVocabulary(CirPrismaticMirrorRequestKind requestKind)
+ {
+ var result = CirPrismaticMirrorLab.Evaluate(
+ "rectangle-inset",
+ PrismaticSectionTransitionEmitterLab.RectangleToInsetRectangle(),
+ CirPrismaticMirrorStrategy.HalfSpaceConvexPolyhedron,
+ requestKind);
+
+ Assert.False(result.Succeeded);
+ Assert.Equal("mirror-rejected-lossy-for-request", result.MirrorStatus);
+ Assert.Equal("none", result.Capabilities);
+ Assert.Contains("face-identity-lost", result.KnownLosses);
+ Assert.Contains("topology-parity-unavailable", result.KnownLosses);
+ Assert.Contains("cir-prismatic-x1-mirror-rejected-lossy-for-request", result.Diagnostics);
+ Assert.Contains("cir-prismatic-x1-loss-face-identity", result.Diagnostics);
+ Assert.Contains("cir-prismatic-x1-loss-topology-parity", result.Diagnostics);
+ Assert.Equal("cir-prismatic-mirror-invalid-rejected", result.Recommendation);
+ }
+
+ [Fact]
+ public void CirPrismaticX1_RepeatedMirrorEvaluationsAreDeterministic()
+ {
+ var first = CirPrismaticMirrorLab.RunRequiredCases().Select(Stable).ToArray();
+ var second = CirPrismaticMirrorLab.RunRequiredCases().Select(Stable).ToArray();
+
+ Assert.Equal(first, second);
+ }
+}
diff --git a/docs/air-cir-x1-mirror-metadata-prototype.md b/docs/air-cir-x1-mirror-metadata-prototype.md
index 9198cbd5..1d0da64c 100644
--- a/docs/air-cir-x1-mirror-metadata-prototype.md
+++ b/docs/air-cir-x1-mirror-metadata-prototype.md
@@ -127,3 +127,9 @@ Recommended next work is one of:
## 13. CIR-MAP-X2 consumption note
CIR-MAP-X2 is the first lab/test-only consumer of `CirMirrorAdmissionService` for map backend selection. The X2 dispatcher asks admission for the requested analyzer use, selects the CIR tape primitive map backend only when a box/cylinder/sphere mirror is `mirror-admitted-exact` for `MapOccupancy`, and rejects face identity/topology parity as lossy. Prismatic section transitions and profile-authored chamfers remain mirror-unavailable or unsupported; no production analyzer, CLI, STEP, Boolean, BRep topology, AIR emitter, CIR node kind, prismatic mirror, or CIR-to-BRep behavior changes are introduced.
+
+## CIR-PRISMATIC-X1 prismatic feasibility note
+
+CIR-PRISMATIC-X1 evaluates a bounded prismatic mirror in the friction-lab layer only. For `rectangle-inset` and `top-edge-chamfer`, the lab can produce `mirror-admitted-exact` metadata for point containment and map occupancy using AIR-authored section data, while still rejecting face identity and topology parity as lossy.
+
+The AIR-CIR-X1 production admission service remains intentionally conservative: prismatic mirrors are unavailable to production dispatch unless a later X2-style milestone promotes a bounded half-space/convex-polyhedron or section-stack evaluator into an explicitly admitted mirror path.
diff --git a/docs/cir-map-x2-mirror-aware-primitive-map-dispatch.md b/docs/cir-map-x2-mirror-aware-primitive-map-dispatch.md
index 1325df3b..a5d3e015 100644
--- a/docs/cir-map-x2-mirror-aware-primitive-map-dispatch.md
+++ b/docs/cir-map-x2-mirror-aware-primitive-map-dispatch.md
@@ -170,3 +170,7 @@ Recommended next work is one of:
3. **AIR-CIR-X2** — mirror provenance/staleness hardening before any wider analyzer routing.
Do not claim prismatic map support until an actual admitted mirror exists and can be compared against a trustworthy baseline.
+
+## CIR-PRISMATIC-X1 follow-up note
+
+CIR-PRISMATIC-X1 proves prismatic mirror feasibility in a lab/test-only path for `rectangle-inset` and `top-edge-chamfer`, and recommends the convex half-space/polyhedron strategy as the next implementation direction. CIR-MAP-X2 dispatch remains primitive-only in production-facing terms: prismatic map dispatch is still unavailable until a later milestone promotes an explicitly admitted prismatic mirror into the dispatch contract.
diff --git a/docs/cir-prismatic-x1-prismatic-mirror-feasibility.md b/docs/cir-prismatic-x1-prismatic-mirror-feasibility.md
new file mode 100644
index 00000000..9671aba6
--- /dev/null
+++ b/docs/cir-prismatic-x1-prismatic-mirror-feasibility.md
@@ -0,0 +1,156 @@
+# CIR-PRISMATIC-X1 — Prismatic CIR mirror feasibility lab
+
+Status: **Lab/test-only prototype**. No production analyzer, CLI, STEP exporter/importer, Boolean core, BRep topology, AIR emitter, production prismatic route, or CIR-to-BRep extraction behavior changed.
+
+## 1. Purpose and scope
+
+CIR-PRISMATIC-X1 evaluates the first bounded CIR/FRep mirror strategy for prismatic section-transition bodies whose AIR-authored source is a stack of line-only convex sections with stable vertex correspondence. The lab answers a narrow feasibility question: can map occupancy and point containment be represented by an admitted mirror for prismatic corpus cases without claiming topology parity or production `analyze map` support?
+
+The implementation is deliberately in `Aetheris.Firmament.FrictionLab.CIRLab` as `CirPrismaticMirrorLab`. It is not wired into `StepAnalyzer`, `aetheris analyze map`, production CIR dispatch, production BRep spatial queries, STEP import/export, Boolean operations, or AIR/prismatic emitters.
+
+## 2. References
+
+This milestone depends on the current Aetheris V2 and AIR/CIR/BRep authority split:
+
+- `docs/aetheris-v2-sweep-first-architecture.md`
+- `docs/air-cir-a0-authority-and-mirror-contract.md`
+- `docs/air-cir-x1-mirror-metadata-prototype.md`
+- `docs/cir-map-x1-primitive-map-prototype.md`
+- `docs/cir-map-x2-mirror-aware-primitive-map-dispatch.md`
+- `docs/edge-prismatic-x7-analyze-map-cir-frep-audit.md`
+
+The key inherited constraint is that CIR/FRep may answer field questions such as containment or occupancy only when the mirror is explicitly admitted. BRep remains authority for explicit topology, face identity, loop identity, split-face lineage, and STEP exchange.
+
+## 3. Strategies compared
+
+### 3.1 Half-space / convex polyhedron mirror
+
+The half-space prototype represents a convex all-planar section-transition body as the intersection of deterministic oriented planes:
+
+- two Z cap half-spaces from the lowest and highest section;
+- one side half-space per corresponding section edge per transition interval;
+- signed containment as the maximum plane violation.
+
+The planes are derived from AIR/prismatic section data, not from reverse-engineered STEP. This preserves the intended mirror provenance path and avoids introducing STEP importer/exporter coupling. For convex line-only stacks such as `rectangle-inset` and `top-edge-chamfer`, the lab admits the mirror as `mirror-admitted-exact` for point containment and map occupancy within the lab tolerance.
+
+Future production shape options remain open: `CirHalfSpaceNode`, `CirConvexPolyhedronNode`, or a tape payload operation. X1 does not add any production CIR node kind.
+
+### 3.2 Section-stack implicit evaluator
+
+The section-stack prototype evaluates membership from the AIR-authored Z section stack:
+
+- find the section interval containing the point Z;
+- linearly interpolate corresponding vertices at that Z;
+- classify the XY point against the interpolated convex polygon;
+- combine that with cap-Z bounds.
+
+This mirrors the construction intent and is easy to audit for prismatic routes with explicit correspondence. It is more specialized than a general convex-polyhedron evaluator, but it can encode the section-stack contract directly. X1 keeps it as a comparison evaluator rather than recommending it as the first general CIR node.
+
+## 4. Case results
+
+| Case | Strategy | Status | Point classification | Map-like summary | Recommendation |
+| --- | --- | --- | --- | --- | --- |
+| `rectangle-inset` | half-space convex polyhedron | `mirror-admitted-exact` | all expected inside/outside points match | 16×16 top-view grid, 256 occupied / 0 empty, thickness min 0.250, max 1.000 | `cir-prismatic-mirror-use-convex-polyhedron-first` |
+| `rectangle-inset` | section-stack implicit | `mirror-admitted-exact` | all expected inside/outside points match | same stable summary as half-space | comparison path; keep as section-stack fallback/evaluator candidate |
+| `top-edge-chamfer` | half-space convex polyhedron | `mirror-admitted-exact` | all expected inside/outside points match | 16×16 top-view grid, 256 occupied / 0 empty, thickness min 5.312, max 6.000 | `cir-prismatic-mirror-use-convex-polyhedron-first` |
+| `top-edge-chamfer` | section-stack implicit | `mirror-admitted-exact` | all expected inside/outside points match | same stable summary as half-space | comparison path; keep as section-stack fallback/evaluator candidate |
+
+Optional hexagon/pentagon cases were not implemented in X1. The strategy should extend to convex line-only stacks, but X1 intentionally stays bounded to the required `rectangle-inset` and `top-edge-chamfer` evidence.
+
+## 5. Point classification findings
+
+`rectangle-inset` includes these checks:
+
+- center inside at mid-height;
+- outside far +X;
+- outside far +Y;
+- inside near the lower full rectangle but outside the upper inset when sampled near the lower Z;
+- outside at upper Z where the inset excludes the point;
+- near-side-plane tolerance checks on the upper +X side.
+
+`top-edge-chamfer` includes these checks:
+
+- inside lower body below transition;
+- outside above/inset excluded area near the +X top transition;
+- inside below the chamfer plane near transition;
+- outside beyond the chamfer plane;
+- center inside.
+
+Both strategies classify the required points deterministically.
+
+## 6. Map-like summary findings
+
+The lab uses a deterministic 16×16 top-view sampling grid over the AIR-authored prismatic bounds. For each XY sample it estimates Z thickness with a fixed 96-sample ray through the mirror field. The summary is intentionally map-like rather than production `analyze map`: it reports occupied/empty sample counts and approximate min/max/average thickness, but it does not produce face IDs, visible topology, or BRep raycast parity.
+
+The top-view grids have no empty XY cells because both required cases retain a nonzero lower-body thickness throughout the full lower footprint. The minimum thickness is therefore near the most eroded top footprint corner/edge, not zero.
+
+## 7. Mirror status and metadata policy
+
+For both required cases, both strategies return:
+
+- status: `mirror-admitted-exact`;
+- capabilities: point containment, map occupancy, section sampling, approximate volume;
+- known losses: face identity, loop identity, split-face lineage, feature role labels, topology parity;
+- lossy topology/face-identity requests: `mirror-rejected-lossy-for-request`.
+
+This is lab metadata only. AIR-CIR-X1 production admission still does not expose a general prismatic mirror to production map dispatch.
+
+## 8. Known losses
+
+The X1 mirrors answer field occupancy, not topology. Known losses are explicit and deterministic:
+
+- face identity lost;
+- loop identity lost;
+- split-face lineage lost;
+- chamfer transition face label lost unless a later milestone preserves it as metadata;
+- exact topology parity unavailable.
+
+Any request for face identity or topology parity is rejected as `mirror-rejected-lossy-for-request`.
+
+## 9. Recommendation
+
+Recommendation: **use the convex polyhedron / half-space strategy first** for the next implementation step.
+
+Rationale:
+
+- it covers both required cases exactly for containment/map occupancy;
+- it naturally generalizes to convex all-planar prismatic bodies beyond section-stack-specific construction;
+- it can be represented later as `CirHalfSpaceNode`, `CirConvexPolyhedronNode`, or a tape payload op without changing production behavior in X1;
+- the section-stack evaluator remains valuable as an AIR-intent comparison oracle and possible specialized evaluator, but it is narrower and depends more directly on section correspondence semantics.
+
+Recommended diagnostic token: `cir-prismatic-mirror-use-convex-polyhedron-first`.
+
+## 10. Non-goals
+
+X1 does not:
+
+- change production analyzer behavior;
+- change default CLI behavior;
+- add public API;
+- change STEP exporter/importer behavior;
+- change Boolean core behavior;
+- change BRep topology;
+- change AIR emitter behavior;
+- change production prismatic routes;
+- perform CIR-to-BRep extraction;
+- claim production prismatic map support;
+- make gated artifact corpus stability tests run by default.
+
+## 11. Tests run
+
+Focused X1 validation:
+
+```bash
+dotnet test Aetheris.FrictionLab.Tests/Aetheris.FrictionLab.Tests.csproj -c Release -f net10.0 --filter "CirPrismatic"
+```
+
+Required broader regression commands for this milestone were run after the implementation and documentation updates; see the PR/test summary for exact command outcomes.
+
+## 12. Next milestone
+
+The next milestone should be one of:
+
+- **CIR-PRISMATIC-X2 first-class mirror node/evaluator**: introduce a first-class half-space/convex-polyhedron CIR mirror or tape payload with explicit admission metadata and tolerance policy; or
+- **EDGE-PRISMATIC-X8 hybrid map dispatch with admitted mirror**: only after X2 provides an admitted prismatic mirror handle, route production map dispatch through the hybrid policy without losing BRep topology responsibilities.
+
+Do not route production `analyze map` through this X1 lab prototype directly.
diff --git a/docs/edge-prismatic-x7-analyze-map-cir-frep-audit.md b/docs/edge-prismatic-x7-analyze-map-cir-frep-audit.md
index 20a7ad93..cb601549 100644
--- a/docs/edge-prismatic-x7-analyze-map-cir-frep-audit.md
+++ b/docs/edge-prismatic-x7-analyze-map-cir-frep-audit.md
@@ -391,3 +391,9 @@ This milestone explicitly does not include:
## 13. CIR-MAP-X2 prismatic status note
CIR-MAP-X2 adds a lab/test-only mirror-aware primitive map dispatcher, but it deliberately does not add prismatic mirror support. Prismatic section-transition and profile-authored chamfer sources still resolve to mirror-unavailable or unsupported admission for map occupancy, emit no-prismatic-mirror-used diagnostics, and do not select the CIR map backend. Prismatic map support remains blocked until a real admitted prismatic mirror exists and can be validated against an appropriate baseline.
+
+## CIR-PRISMATIC-X1 follow-up note
+
+CIR-PRISMATIC-X1 adds a lab-only prismatic mirror feasibility prototype for the required `rectangle-inset` and `top-edge-chamfer` prismatic corpus cases. It compares a convex half-space/polyhedron evaluator against a section-stack implicit evaluator, admits both as exact for bounded point containment and map-like occupancy in the lab, and recommends the half-space/convex-polyhedron path for the next first-class implementation step.
+
+This does **not** change the X7 production audit conclusion: production `analyze map` remains unsupported for prismatic STEP/BRep artifacts until a later milestone introduces an admitted prismatic mirror into production dispatch. X1 also makes no STEP, BRep topology, Boolean, AIR emitter, CLI, or CIR-to-BRep extraction changes.