Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add WireForm semantic route for paperclip inspection and export

Yuechen Lia253e869066f
diff --git a/Aetheris.CLI.Tests/CircularSweepCliTests.cs b/Aetheris.CLI.Tests/CircularSweepCliTests.cs
index daa29ac7..41e3269b 100644
--- a/Aetheris.CLI.Tests/CircularSweepCliTests.cs
+++ b/Aetheris.CLI.Tests/CircularSweepCliTests.cs
@@ -5,7 +5,7 @@ namespace Aetheris.CLI.Tests;
public sealed class CircularSweepCliTests
{
[Fact]
- public void PaperclipValidateAndInspectUseSweepSemanticRoute()
+ public void PaperclipValidateAndInspectUseWireFormSemanticRoute()
{
var fixture = Path.Combine(RepoRoot(), "fixtures", "Canonical", "Templates", "paperclip.firmament");
var validation = new StringWriter(); var validationError = new StringWriter();
@@ -15,15 +15,18 @@ public sealed class CircularSweepCliTests
{
var report = json.RootElement.GetProperty("firmamentV2Validation");
Assert.Equal("valid", report.GetProperty("status").GetString());
- Assert.Equal("CircularSweep", report.GetProperty("domain").GetString());
- Assert.Equal(7, report.GetProperty("summary").GetProperty("segmentCount").GetInt32());
+ Assert.Equal("WireForm", report.GetProperty("domain").GetString());
+ Assert.Equal(7, report.GetProperty("summary").GetProperty("operationCount").GetInt32());
}
var inspection = new StringWriter(); var inspectionError = new StringWriter();
Assert.Equal(0, Aetheris.CLI.CliRunner.Run(["inspect", fixture, "--json"], inspection, inspectionError));
Assert.Empty(inspectionError.ToString());
using var inspected = JsonDocument.Parse(inspection.ToString());
Assert.True(inspected.RootElement.GetProperty("success").GetBoolean());
- Assert.Equal("Standard.Materials.StainlessSteel.304_Annealed", inspected.RootElement.GetProperty("sweep").GetProperty("material").GetString());
+ Assert.Equal("WireForm", inspected.RootElement.GetProperty("domain").GetString());
+ var wire = inspected.RootElement.GetProperty("wireForm");
+ Assert.Equal("Standard.Materials.StainlessSteel.304_Annealed", wire.GetProperty("material").GetString());
+ Assert.Equal(95.6991118431, wire.GetProperty("totalWireLength").GetDouble(), 9);
}
private static string RepoRoot()
diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.cs
index e865717a..a6a2009d 100644
--- a/Aetheris.CLI/CliRunner.cs
+++ b/Aetheris.CLI/CliRunner.cs
@@ -500,6 +500,7 @@ public static class CliRunner
lattice = build.Value.Export.Lattice,
combined = build.Value.Export.Combined,
standardPart = build.Value.Export.StandardPart,
+ wireForm = build.Value.Export.WireForm,
sweep = build.Value.Export.Sweep,
assertions = build.Value.Export.Assertions,
features = build.Value.Export.Features,
@@ -525,6 +526,8 @@ public static class CliRunner
stdout.WriteLine($"Model: {build.Value.Export.ExportedFeatureId}");
if (build.Value.Export.StandardPart is { } standardPart)
stdout.WriteLine($"Standard part: {standardPart.Family} via {standardPart.Template ?? "direct record"} ({standardPart.SemanticDescendants.Count} semantic descendants)");
+ if (build.Value.Export.WireForm is { } wireForm)
+ stdout.WriteLine($"WireForm: {wireForm.OperationCount} operations, {wireForm.DiameterMm:G6} mm diameter, {wireForm.TotalWireLengthMm:G12} mm stock length ({wireForm.Cylinders} cylinders, {wireForm.Tori} tori)");
if (build.Value.Export.Sweep is { } sweep)
stdout.WriteLine($"Sweep: {sweep.SegmentCount} analytic path segments, {sweep.Diameter:G6} mm diameter, {sweep.CenterlineLength:G6} mm centerline ({sweep.Cylinders} cylinders, {sweep.Tori} tori)");
if (build.Value.Export.Structural is { } structure)
@@ -1347,6 +1350,33 @@ Model CanonicalPanel {
var library = FirmamentStandardLibraryResolver.Resolve(source, out var libraryDiagnostics);
var inspectionSource = library?.Source ?? source;
var sweepSource = ExpandSweepInspectionSource(source, out var sweepExpansionDiagnostics);
+ if (WireFormAuthoring.IsWireFormSource(source))
+ {
+ var authored = sweepSource is null ? null : WireFormAuthoring.Parse(sweepSource);
+ var wireDiagnostics = sweepExpansionDiagnostics.Concat(authored is null ? [] : authored.IsSuccess ? WireFormBRepMaterializer.Validate(authored.Value) : authored.Diagnostics.Select(item => item.Message)).ToArray();
+ var wireSuccess = authored?.IsSuccess == true && wireDiagnostics.Length == 0;
+ var wire = authored?.IsSuccess == true ? authored.Value : null;
+ var wireReportPayload = new
+ {
+ command = "inspect", success = wireSuccess, input = fullPath, domain = "WireForm", model = Path.GetFileNameWithoutExtension(fullPath), units = "mm",
+ wireForm = wire is null ? null : new
+ {
+ wireFormId = wire.Name, diameter = wire.DiameterMm, material = wire.Material.Identity.FirmamentPath,
+ operationCount = wire.Operations.Count, straightCount = wire.Operations.Count(x => x is WireStraightAir), bendCount = wire.Operations.Count(x => x is WireBendAir),
+ totalStraightLength = wire.TotalStraightLengthMm, totalBendLength = wire.TotalBendLengthMm, totalWireLength = wire.TotalWireLengthMm,
+ bendRadiusSemantics = "CenterlineRadius", frameTransportPolicy = wire.FrameTransportPolicy,
+ startTerminal = new { position = new[] { wire.StartState.Position.X, wire.StartState.Position.Y, wire.StartState.Position.Z }, tangent = new[] { wire.StartState.Tangent.X, wire.StartState.Tangent.Y, wire.StartState.Tangent.Z }, diameter = wire.DiameterMm },
+ endTerminal = new { position = new[] { wire.EndState.Position.X, wire.EndState.Position.Y, wire.EndState.Position.Z }, tangent = new[] { wire.EndState.Tangent.X, wire.EndState.Tangent.Y, wire.EndState.Tangent.Z }, diameter = wire.DiameterMm },
+ operations = wire.Operations.Select(operation => new { operation.Ordinal, operation.Name, kind = operation is WireStraightAir ? "Straight" : "Bend", operation.LengthMm,
+ radius = operation is WireBendAir bend ? bend.RadiusMm : (double?)null, angleDegrees = operation is WireBendAir angle ? angle.AngleRadians * 180d / Math.PI : (double?)null,
+ plane = operation is WireBendAir plane ? plane.Plane : null, stableId = operation.StableId(wire.Name), input = operation.Input, output = operation.Output })
+ }, diagnostics = wireDiagnostics
+ };
+ if (json) stdout.WriteLine(JsonSerializer.Serialize(wireReportPayload, JsonOptions));
+ else if (wireSuccess) stdout.WriteLine($"WireForm {wire!.Name}: {wire.Operations.Count} operations, {wire.TotalWireLengthMm:G12} mm stock length");
+ else foreach (var diagnostic in wireDiagnostics) stderr.WriteLine($"error: {diagnostic}");
+ return wireSuccess ? 0 : 1;
+ }
if (CircularSweepAuthoring.IsSweepSource(source))
{
var authored = sweepSource is null ? null : CircularSweepAuthoring.Parse(sweepSource);
@@ -2026,6 +2056,18 @@ Model CanonicalPanel {
else stdout.WriteLine($"Firmament V2 Structural validation: {payload.status} ({payload.summary.fatalDiagnosticCount} fatal, 0 warning)");
return structural.IsSuccess ? 0 : 1;
}
+ if (WireFormAuthoring.IsWireFormSource(validationSource))
+ {
+ var wireSource = ExpandSweepInspectionSource(validationSource, out var expansionDiagnostics);
+ var authored = wireSource is null ? null : WireFormAuthoring.Parse(wireSource);
+ var diagnostics = expansionDiagnostics.Concat(authored is null ? [] : authored.IsSuccess ? WireFormBRepMaterializer.Validate(authored.Value) : authored.Diagnostics.Select(item => item.Message)).ToArray();
+ var valid = authored?.IsSuccess == true && diagnostics.Length == 0;
+ var payload = new { source = sourcePath, status = valid ? "valid" : "invalid", domain = "WireForm",
+ summary = new { fatalDiagnosticCount = diagnostics.Length, warningDiagnosticCount = 0, operationCount = authored?.IsSuccess == true ? authored.Value.Operations.Count : 0 }, diagnostics };
+ if (json) stdout.WriteLine(JsonSerializer.Serialize(new { firmamentV2Validation = payload }, JsonOptions));
+ else stdout.WriteLine($"Firmament V2 WireForm validation: {payload.status} ({payload.summary.fatalDiagnosticCount} fatal, 0 warning)");
+ return valid ? 0 : 1;
+ }
if (CircularSweepAuthoring.IsSweepSource(validationSource))
{
var sweepSource = ExpandSweepInspectionSource(validationSource, out var sweepExpansionDiagnostics);
diff --git a/Aetheris.Forge.Host/ForgeProtocolHost.cs b/Aetheris.Forge.Host/ForgeProtocolHost.cs
index bc1c934b..3db7f336 100644
--- a/Aetheris.Forge.Host/ForgeProtocolHost.cs
+++ b/Aetheris.Forge.Host/ForgeProtocolHost.cs
@@ -189,7 +189,7 @@ public sealed class ForgeProtocolHost
var productVersion = "1+" + Convert.ToHexString(SHA256.HashData(Utf8.GetBytes(productCatalogSource)))[..12].ToLowerInvariant();
var definitions = new Dictionary<string, (string Id, string Name, string Documentation)>(StringComparer.Ordinal)
{
- ["PaperclipTemplate"] = (PaperclipTemplateLibrary.TemplateId, "Paperclip", "A bounded parametric office paperclip compiled from a semantic planar path and constant circular Sweep."),
+ ["PaperclipTemplate"] = (PaperclipTemplateLibrary.TemplateId, "Paperclip", "A bounded parametric office paperclip compiled from an ordered semantic WireForm Straight/Bend program and exact circular Sweep."),
["MountingPlateTemplate"] = ("Standard.Products.Mechanical.MountingPlate", "Mounting Plate", "General-purpose machined plate with a four-corner counterbored mounting-hole layout and manufacturing PMI."),
["BearingBlockTemplate"] = ("Standard.Products.Mechanical.BearingBlock", "Bearing Block", "Generic machined bearing-support block with a base, circular boss, shaft bore, mounting holes, and bore PMI."),
["MachinedAngleBracketTemplate"] = ("Standard.Products.Mechanical.MachinedAngleBracket", "Machined Angle Bracket", "Prismatic machined L-bracket with two mounting holes and explicit leg proportions."),
diff --git a/Aetheris.Kernel.Firmament.Tests/CircularSweepTests.cs b/Aetheris.Kernel.Firmament.Tests/CircularSweepTests.cs
index b5f07b24..7d16c4bc 100644
--- a/Aetheris.Kernel.Firmament.Tests/CircularSweepTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/CircularSweepTests.cs
@@ -30,16 +30,19 @@ public sealed class CircularSweepTests
{
var result = FirmamentBuildAndExport.CompileSource(PaperclipTemplateLibrary.Source);
Assert.True(result.IsSuccess, string.Join(Environment.NewLine, result.Diagnostics.Select(x => x.Message)));
- var report = Assert.IsType<FirmamentSweepReport>(result.Value.Sweep);
- Assert.Equal(7, report.SegmentCount);
- Assert.Equal(1, report.Diameter, 9);
+ var report = Assert.IsType<FirmamentWireFormReport>(result.Value.WireForm);
+ Assert.Equal(7, report.OperationCount);
+ Assert.Equal(1, report.DiameterMm, 9);
Assert.Equal("Standard.Materials.StainlessSteel.304_Annealed", report.Material);
Assert.Equal(4, report.Cylinders);
Assert.Equal(3, report.Tori);
Assert.Equal(11, report.Bounds[3] - report.Bounds[0], 9);
Assert.Equal(25, report.Bounds[4] - report.Bounds[1], 9);
Assert.Equal(1, report.Bounds[5] - report.Bounds[2], 9);
- Assert.Equal(58 + 12 * Math.PI, report.CenterlineLength, 9);
+ Assert.Equal(58 + 12 * Math.PI, report.TotalWireLengthMm, 9);
+ Assert.Equal(95.6991118431, report.TotalWireLengthMm, 9);
+ Assert.Equal(0, report.RationalProductSurfaces);
+ Assert.Equal(0, report.FacetedFallback);
Assert.True(report.EnclosedManifold);
Assert.True(report.StepReimportSucceeded);
Assert.True(report.StepReimportedManifold);
diff --git a/Aetheris.Kernel.Firmament.Tests/WireFormTests.cs b/Aetheris.Kernel.Firmament.Tests/WireFormTests.cs
new file mode 100644
index 00000000..8a607e7a
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/WireFormTests.cs
@@ -0,0 +1,193 @@
+using Aetheris.Kernel.Core.Step242;
+using Aetheris.Kernel.Firmament.FirmamentV2;
+using Aetheris.Kernel.Firmament.Materializer;
+using Aetheris.Kernel.Core.Math;
+
+namespace Aetheris.Kernel.Firmament.Tests;
+
+public sealed class WireFormTests
+{
+ [Fact]
+ public void Paperclip_ReplaysExactSemanticProgramAndStockAccounting()
+ {
+ var result = FirmamentBuildAndExport.CompileSource(PaperclipTemplateLibrary.Source);
+ Assert.True(result.IsSuccess, Messages(result));
+ var report = Assert.IsType<FirmamentWireFormReport>(result.Value.WireForm);
+ Assert.Equal(["Straight", "Bend", "Straight", "Bend", "Straight", "Bend", "Straight"], report.Operations.Select(x => x.Kind));
+ Assert.Equal([14d, 14d, 15d, 15d], report.Operations.Where(x => x.Kind == "Straight").Select(x => x.LengthMm));
+ Assert.Equal([3d, 4d, 5d], report.Operations.Where(x => x.Kind == "Bend").Select(x => x.RadiusMm!.Value));
+ Assert.Equal(58d, report.TotalStraightLengthMm, 12);
+ Assert.Equal(12d * Math.PI, report.TotalBendLengthMm, 12);
+ Assert.Equal(95.6991118431d, report.TotalWireLengthMm, 9);
+ Assert.Equal(Math.PI * .25d * report.TotalWireLengthMm, report.VolumeMm3, 10);
+ Assert.True(report.MassKilograms > 0d);
+ Assert.Equal([4, 3, 2], [report.Cylinders, report.Tori, report.Planes]);
+ Assert.Equal(11d, report.Bounds[3] - report.Bounds[0], 9); Assert.Equal(25d, report.Bounds[4] - report.Bounds[1], 9); Assert.Equal(1d, report.Bounds[5] - report.Bounds[2], 9);
+ Assert.Equal(0, report.OtherSurfaces); Assert.Equal(0, report.RationalProductSurfaces); Assert.Equal(0, report.FacetedFallback);
+ Assert.True(report.EnclosedManifold); Assert.True(report.StepReimportSucceeded); Assert.True(report.StepReimportedManifold);
+ }
+
+ [Fact]
+ public void ThreeDimensionalWitness_TransportsFrameAcrossPerpendicularBendPlanes()
+ {
+ var source = File.ReadAllText(Fixture("Canonical", "WireForm", "three-dimensional-bends.firmament"));
+ var authored = WireFormAuthoring.Parse(source);
+ Assert.True(authored.IsSuccess, string.Join(Environment.NewLine, authored.Diagnostics.Select(x => x.Message)));
+ Assert.Equal(["Up", "Right"], authored.Value.Operations.OfType<WireBendAir>().Select(x => x.Plane));
+ AssertPoint(authored.Value.EndState.Position, 25, 25, 15);
+ AssertDirection(authored.Value.EndState.Tangent, 0, 0, 1);
+ var result = FirmamentBuildAndExport.CompileSource(source);
+ Assert.True(result.IsSuccess, Messages(result));
+ var report = Assert.IsType<FirmamentWireFormReport>(result.Value.WireForm);
+ Assert.Equal([3, 2, 2, 0], [report.Cylinders, report.Tori, report.Planes, report.OtherSurfaces]);
+ Assert.Equal(0, report.RationalProductSurfaces);
+ Assert.True(Step242Importer.ImportBody(result.Value.StepText).IsSuccess);
+ }
+
+ [Theory]
+ [InlineData(90d)]
+ [InlineData(180d)]
+ [InlineData(-90d)]
+ [InlineData(37d)]
+ public void Bend_SupportsSignedBoundedGeneralAngles(double degrees)
+ {
+ var source = Simple.Replace("90deg", degrees.ToString(System.Globalization.CultureInfo.InvariantCulture) + "deg", StringComparison.Ordinal);
+ var authored = WireFormAuthoring.Parse(source);
+ Assert.True(authored.IsSuccess, string.Join(Environment.NewLine, authored.Diagnostics.Select(x => x.Message)));
+ var bend = Assert.IsType<WireBendAir>(authored.Value.Operations[1]);
+ Assert.Equal(5d * Math.Abs(degrees) * Math.PI / 180d, bend.LengthMm, 12);
+ Assert.Equal(bend.Input, authored.Value.Operations[0].Output);
+ Assert.Equal(bend.Output, authored.Value.Operations[2].Input);
+ }
+
+ [Theory]
+ [InlineData("Straight Lead { Length: 20mm }", "Straight Lead { Length: 0mm }", "wireform-straight-length-invalid")]
+ [InlineData("Radius: 5mm", "Radius: 0.5mm", "wireform-bend-radius-invalid")]
+ [InlineData("Plane: Up", "Plane: GlobalXY", "wireform-bend-plane-invalid")]
+ public void InvalidOperations_ProduceTypedDiagnostics(string oldText, string newText, string diagnostic)
+ {
+ var result = WireFormAuthoring.Parse(Simple.Replace(oldText, newText, StringComparison.Ordinal));
+ Assert.False(result.IsSuccess);
+ Assert.Contains(result.Diagnostics, x => x.Message.Contains(diagnostic, StringComparison.Ordinal));
+ }
+
+ [Fact]
+ public void NonlocalContact_FailsClosedWhileAdjacentTangencyIsAllowed()
+ {
+ var source = File.ReadAllText(Fixture("Invalid", "WireForm", "nonlocal-contact.firmament"));
+ var authored = WireFormAuthoring.Parse(source);
+ Assert.True(authored.IsSuccess);
+ var diagnostics = WireFormBRepMaterializer.Validate(authored.Value);
+ Assert.Contains(diagnostics, x => x.Contains("wireform-self-intersection:A:Contact", StringComparison.Ordinal));
+ Assert.DoesNotContain(diagnostics, x => x.Contains("A:B", StringComparison.Ordinal));
+ }
+
+ [Fact]
+ public void AdjacentOperations_MayMeetOnlyAtTangentJoin()
+ {
+ var closedCircle = Simple.Replace("Straight Lead { Length: 20mm }", "Bend FirstHalf { Radius: 5mm; Angle: 180deg; Plane: Up }", StringComparison.Ordinal)
+ .Replace("Bend Corner { Radius: 5mm; Angle: 90deg; Plane: Up }", "Bend SecondHalf { Radius: 5mm; Angle: 180deg; Plane: Up }", StringComparison.Ordinal)
+ .Replace("Straight Tail { Length: 30mm }", string.Empty, StringComparison.Ordinal);
+ var authored = WireFormAuthoring.Parse(closedCircle); Assert.True(authored.IsSuccess);
+ Assert.Contains(WireFormBRepMaterializer.Validate(authored.Value), x => x.Contains("wireform-self-intersection:FirstHalf:SecondHalf", StringComparison.Ordinal));
+ }
+
+ [Fact]
+ public void RepeatExport_IsByteDeterministic()
+ {
+ var source = File.ReadAllText(Fixture("Canonical", "WireForm", "u-wire.firmament"));
+ var first = FirmamentBuildAndExport.CompileSource(source); var second = FirmamentBuildAndExport.CompileSource(source);
+ Assert.True(first.IsSuccess, Messages(first)); Assert.True(second.IsSuccess, Messages(second));
+ Assert.Equal(first.Value.StepText, second.Value.StepText);
+ Assert.Equal(first.Value.WireForm!.StepSha256, second.Value.WireForm!.StepSha256);
+ }
+
+ [Fact]
+ public void Paperclip_IsNumericallyCoincidentWithRecoveredConceptPathReference()
+ {
+ var wire = WireFormAuthoring.Parse(File.ReadAllText(Fixture("Canonical", "WireForm", "paperclip.firmament")));
+ var reference = CircularSweepAuthoring.Parse(LegacyPaperclipReference);
+ Assert.True(wire.IsSuccess); Assert.True(reference.IsSuccess);
+ var deviations = new List<double>();
+ for (var segment = 0; segment < wire.Value.Operations.Count; segment++)
+ for (var sample = 0; sample <= 100; sample++)
+ {
+ var t = sample / 100d; var a = Sample(wire.Value.Operations[segment], t); var b = Sample(reference.Value.Path.Segments[segment].Geometry, t);
+ deviations.Add((a - b).Length);
+ }
+ var ordered = deviations.Order().ToArray();
+ var rms = Math.Sqrt(deviations.Sum(x => x * x) / deviations.Count); var p95 = ordered[(int)Math.Floor(.95d * (ordered.Length - 1))]; var max = ordered[^1];
+ Assert.True(rms < 1e-12, $"RMS {rms:R}"); Assert.True(p95 < 1e-12, $"p95 {p95:R}"); Assert.True(max < 1e-12, $"max {max:R}");
+ Assert.True((wire.Value.EndState.Position - Sample(reference.Value.Path.Segments[^1].Geometry, 1d)).Length < 1e-12);
+ Assert.Equal(reference.Value.Path.Segments.Sum(x => Length(x.Geometry)), wire.Value.TotalWireLengthMm, 12);
+ }
+
+ [Fact]
+ public void PaperclipLongerAndWiderVariantsRemainExactAndCollisionFree()
+ {
+ var canonical = File.ReadAllText(Fixture("Canonical", "WireForm", "paperclip.firmament"));
+ var longer = canonical.Replace("Length: 14mm", "Length: 16.1mm", StringComparison.Ordinal).Replace("Length: 15mm", "Length: 17.25mm", StringComparison.Ordinal);
+ var wider = canonical.Replace("Bend InnerTop { Radius: 3mm", "Bend InnerTop { Radius: 4mm", StringComparison.Ordinal)
+ .Replace("Bend LowerReturn { Radius: 4mm", "Bend LowerReturn { Radius: 5mm", StringComparison.Ordinal)
+ .Replace("Bend OuterTop { Radius: 5mm", "Bend OuterTop { Radius: 6mm", StringComparison.Ordinal);
+ foreach (var source in new[] { longer, wider })
+ {
+ var first = FirmamentBuildAndExport.CompileSource(source); var second = FirmamentBuildAndExport.CompileSource(source);
+ Assert.True(first.IsSuccess, Messages(first)); Assert.True(second.IsSuccess, Messages(second));
+ var report = first.Value.WireForm!; Assert.True(report.EnclosedManifold); Assert.Equal(0, report.RationalProductSurfaces); Assert.Equal(0, report.FacetedFallback);
+ Assert.Equal(first.Value.StepText, second.Value.StepText);
+ }
+ }
+
+ private static Point3D Sample(WireFormOperationAir operation, double t) => operation switch
+ {
+ WireStraightAir line => line.Input.Position + (line.Output.Position - line.Input.Position) * t,
+ WireBendAir bend => bend.Center + Rotate(bend.StartRadial.ToVector(), bend.PlaneNormal.ToVector(), Math.Abs(bend.AngleRadians) * t) * bend.RadiusMm,
+ _ => throw new NotSupportedException()
+ };
+ private static Point3D Sample(LineArcProfileCurve2D curve, double t) => curve switch
+ {
+ LineArcLineSegment2D line => new(line.Start.X + (line.End.X - line.Start.X) * t, line.Start.Y + (line.End.Y - line.Start.Y) * t, 0),
+ LineArcCircularArc2D arc => new(arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians + arc.SweepAngleRadians * t), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians + arc.SweepAngleRadians * t), 0),
+ _ => throw new NotSupportedException()
+ };
+ private static double Length(LineArcProfileCurve2D curve) => curve switch { LineArcLineSegment2D line => Math.Sqrt(Math.Pow(line.End.X - line.Start.X, 2) + Math.Pow(line.End.Y - line.Start.Y, 2)), LineArcCircularArc2D arc => arc.Radius * Math.Abs(arc.SweepAngleRadians), _ => 0 };
+ private static Vector3D Rotate(Vector3D v, Vector3D a, double angle) => v * Math.Cos(angle) + new Vector3D(a.Y * v.Z - a.Z * v.Y, a.Z * v.X - a.X * v.Z, a.X * v.Y - a.Y * v.X) * Math.Sin(angle) + a * ((a.X * v.X + a.Y * v.Y + a.Z * v.Z) * (1 - Math.Cos(angle)));
+
+ private static string Messages(Aetheris.Kernel.Core.Results.KernelResult<FirmamentStepExportResult> result) => string.Join(Environment.NewLine, result.Diagnostics.Select(x => x.Message));
+ private static string Fixture(params string[] pieces) => Path.Combine([RepoRoot(), "fixtures", .. pieces]);
+ private static string RepoRoot() { var directory = new DirectoryInfo(AppContext.BaseDirectory); while (directory is not null && !File.Exists(Path.Combine(directory.FullName, "Aetheris.slnx"))) directory = directory.Parent; return directory?.FullName ?? throw new DirectoryNotFoundException(); }
+ private static void AssertPoint(Aetheris.Kernel.Core.Math.Point3D p, double x, double y, double z) { Assert.Equal(x, p.X, 9); Assert.Equal(y, p.Y, 9); Assert.Equal(z, p.Z, 9); }
+ private static void AssertDirection(Aetheris.Kernel.Core.Math.Direction3D p, double x, double y, double z) { Assert.Equal(x, p.X, 9); Assert.Equal(y, p.Y, 9); Assert.Equal(z, p.Z, 9); }
+
+ private const string Simple = """
+ Model WireTest {
+ Units: mm
+ WireForm Wire {
+ Diameter: 1mm
+ Material: Standard.Materials.StainlessSteel.304_Annealed
+ StartFrame { Origin: [0mm,0mm,0mm]; Tangent: [1,0,0]; Up: [0,0,1] }
+ Straight Lead { Length: 20mm }
+ Bend Corner { Radius: 5mm; Angle: 90deg; Plane: Up }
+ Straight Tail { Length: 30mm }
+ }
+ }
+ """;
+
+ private const string LegacyPaperclipReference = """
+ Model PaperclipReference {
+ Units: mm
+ Concept Path PaperclipPath {
+ Start: Point2(8mm, 0mm) Heading: 90deg
+ Line InnerRight { Length: 14mm }
+ Arc InnerTop { Radius: 3mm; Turn: 180deg }
+ Line InnerLeft { Length: 14mm }
+ Arc LowerReturn { Radius: 4mm; Turn: 180deg }
+ Line OuterRight { Length: 15mm }
+ Arc OuterTop { Radius: 5mm; Turn: 180deg }
+ Line OuterLeft { Length: 15mm }
+ }
+ Sweep Reference { Path: PaperclipPath; Diameter: 1mm; Material: Standard.Materials.StainlessSteel.304_Annealed }
+ }
+ """;
+}
diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
index a3eb9c51..da59fd56 100644
--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
@@ -293,6 +293,29 @@ public static class FirmamentBuildAndExport
canonicalParseWatch.Stop();
var canonicalAdvanced = FirmamentV2Parser.TryGetCanonicalAdvancedBody(materializerInput, out var canonicalBody);
var materializerSource = canonicalAdvanced ? canonicalBody : materializerInput;
+ if (WireFormAuthoring.IsWireFormSource(materializerSource))
+ {
+ var authored = WireFormAuthoring.Parse(materializerSource);
+ if (!authored.IsSuccess) return KernelResult<FirmamentStepExportResult>.Failure(authored.Diagnostics);
+ var built = WireFormBRepMaterializer.Build(authored.Value);
+ if (!built.IsSuccess) return KernelResult<FirmamentStepExportResult>.Failure(built.Diagnostics);
+ var step = Step242Exporter.ExportBody(built.Value.Body, new Step242ExportOptions { ProductName = authored.Value.Name });
+ if (!step.IsSuccess) return KernelResult<FirmamentStepExportResult>.Failure(step.Diagnostics);
+ var reimport = Step242Importer.ImportBody(step.Value);
+ if (!reimport.IsSuccess || reimport.Value is null) return KernelResult<FirmamentStepExportResult>.Failure(reimport.Diagnostics);
+ var manifold = reimport.Value.Topology.Edges.All(edge => reimport.Value.Topology.Coedges.Count(use => use.EdgeId == edge.Id) == 2);
+ if (!manifold) return KernelResult<FirmamentStepExportResult>.Failure([new Kernel.Core.Diagnostics.KernelDiagnostic(
+ Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error,
+ "wireform-step-reimport-not-manifold: exported WireForm did not reimport as an enclosed manifold.", "FirmamentV2.WireForm")]);
+ var hash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(step.Value))).ToLowerInvariant();
+ var report = WireFormReportFactory.Create(built.Value, hash, manifold);
+ return KernelResult<FirmamentStepExportResult>.Success(new FirmamentStepExportResult(step.Value, authored.Value.Name, 0,
+ "wire-form", "wireform", WireForm: report,
+ EngineeringFeatures: authored.Value.Operations.Select(operation => new FirmamentEngineeringFeatureReport(
+ operation.Name, operation is WireStraightAir ? "Straight" : "Bend", operation.StableId(authored.Value.Name),
+ authored.Value.Name, "WireState", "CircularSection", operation.LengthMm, "CenterlineLength", "Add",
+ PolicySource: "WireFormFeatureAir", MaterializationRoute: "WireFormCenterlineAir->CircularSweepBRepPlan")).ToArray()), []);
+ }
if (CircularSweepAuthoring.IsSweepSource(materializerSource))
{
var airWatch = System.Diagnostics.Stopwatch.StartNew();
diff --git a/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs b/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs
index 1718aec2..91988287 100644
--- a/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs
@@ -22,11 +22,34 @@ public sealed record FirmamentStepExportResult(
IReadOnlyList<Aetheris.Kernel.Firmament.FirmamentV2.FirmamentV2VolumeAssertionResult>? Assertions = null,
FirmamentStandardPartReport? StandardPart = null,
IReadOnlyList<FirmamentEngineeringFeatureReport>? EngineeringFeatures = null,
+ FirmamentWireFormReport? WireForm = null,
FirmamentSweepReport? Sweep = null,
IReadOnlyList<FirmamentSemanticPatternReport>? Patterns = null,
Aetheris.Kernel.Firmament.Structural.StructuralReport? Structural = null,
Aetheris.Kernel.Firmament.Piping.PipingReport? Piping = null);
+public sealed record FirmamentWireStateReport(
+ IReadOnlyList<double> Position, IReadOnlyList<double> Tangent, IReadOnlyList<double> Up,
+ IReadOnlyList<double> Right, double AccumulatedLengthMm);
+
+public sealed record FirmamentWireOperationReport(
+ int Ordinal, string Name, string Kind, double LengthMm, double? RadiusMm, double? AngleDegrees,
+ string? Plane, string StableId, FirmamentWireStateReport Input, FirmamentWireStateReport Output,
+ string CenterlineSegment, string SweepSurface);
+
+public sealed record FirmamentWireTerminalReport(
+ string Name, IReadOnlyList<double> Position, IReadOnlyList<double> Tangent, IReadOnlyList<double> Up, double DiameterMm);
+
+public sealed record FirmamentWireFormReport(
+ string WireFormId, double DiameterMm, string Material, int OperationCount, int StraightCount, int BendCount,
+ double TotalStraightLengthMm, double TotalBendLengthMm, double TotalWireLengthMm, double VolumeMm3,
+ double MassKilograms, FirmamentWireTerminalReport StartTerminal, FirmamentWireTerminalReport EndTerminal,
+ double MinimumBendRadiusMm, string BendRadiusSemantics, string MinimumBendRadiusValidation,
+ string SelfIntersectionValidation, string FrameTransportPolicy, IReadOnlyList<FirmamentWireOperationReport> Operations,
+ IReadOnlyList<double> Bounds, int Cylinders, int Tori, int Planes, int OtherSurfaces,
+ int RationalProductSurfaces, int FacetedFallback, bool EnclosedManifold, string StepSha256,
+ bool StepReimportSucceeded, bool StepReimportedManifold);
+
public sealed record FirmamentSemanticPatternReport(
string Name,
string Source,
diff --git a/Aetheris.Kernel.Firmament/Materializer/WireForm.cs b/Aetheris.Kernel.Firmament/Materializer/WireForm.cs
new file mode 100644
index 00000000..803421bd
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Materializer/WireForm.cs
@@ -0,0 +1,368 @@
+using System.Globalization;
+using System.Text.RegularExpressions;
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Geometry.Curves;
+using Aetheris.Kernel.Core.Geometry.Surfaces;
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Core.Numerics;
+using Aetheris.Kernel.Core.Results;
+using Aetheris.Kernel.Core.Topology;
+using Aetheris.Kernel.StandardLibrary.Materials;
+
+namespace Aetheris.Kernel.Firmament.Materializer;
+
+/// <summary>Deterministic local state consumed and produced by every WireForm operation.</summary>
+public sealed record WireState(Point3D Position, Direction3D Tangent, Direction3D Up, double AccumulatedLengthMm)
+{
+ public Direction3D Right => Direction3D.Create(WireFormAuthoring.Cross(Tangent.ToVector(), Up.ToVector()));
+}
+
+public abstract record WireFormOperationAir(string Name, int Ordinal, WireState Input, WireState Output, double LengthMm)
+{
+ public string StableId(string wireFormName) => $"wireform:{wireFormName}:operation:{Ordinal}:{Name}";
+}
+
+public sealed record WireStraightAir(string Name, int Ordinal, double AuthoredLengthMm, WireState Input, WireState Output)
+ : WireFormOperationAir(Name, Ordinal, Input, Output, AuthoredLengthMm);
+
+public sealed record WireBendAir(string Name, int Ordinal, double RadiusMm, double AngleRadians, string Plane,
+ Direction3D PlaneNormal, Point3D Center, Direction3D StartRadial, WireState Input, WireState Output)
+ : WireFormOperationAir(Name, Ordinal, Input, Output, RadiusMm * Math.Abs(AngleRadians));
+
+/// <summary>WireForm semantic AIR. Bend radii are centerline radii.</summary>
+public sealed record WireFormFeatureAir(string Name, double DiameterMm, string MaterialReference, ResolvedMaterial Material,
+ WireState StartState, IReadOnlyList<WireFormOperationAir> Operations, string FrameTransportPolicy)
+{
+ public double WireRadiusMm => DiameterMm / 2d;
+ public double TotalStraightLengthMm => Operations.OfType<WireStraightAir>().Sum(x => x.LengthMm);
+ public double TotalBendLengthMm => Operations.OfType<WireBendAir>().Sum(x => x.LengthMm);
+ public double TotalWireLengthMm => Operations.Sum(x => x.LengthMm);
+ public WireState EndState => Operations.Count == 0 ? StartState : Operations[^1].Output;
+}
+
+public sealed record WireFormBuildResult(WireFormFeatureAir Feature, BrepBody Body, double VolumeMm3,
+ double MassKilograms, IReadOnlyList<double> Bounds, IReadOnlyList<string> ValidationEvidence);
+
+/// <summary>Parser and ordered state-machine lowering for the bounded X0 WireForm vocabulary.</summary>
+public static class WireFormAuthoring
+{
+ public const string FrameTransportPolicy = "The authored local Up/Right bend-plane axis is rotated with the tangent through each bend (rotation-minimal rigid transport about the bend normal); Straight preserves the frame.";
+ private static readonly Regex Declaration = new(@"\bWireForm\s+(?<name>[A-Za-z_]\w*)\s*\{", RegexOptions.CultureInvariant);
+ private static readonly Regex Operation = new(@"\b(?<kind>Straight|Bend)\s+(?<name>[A-Za-z_]\w*)\s*\{", RegexOptions.CultureInvariant);
+
+ public static bool IsWireFormSource(string source) => Declaration.IsMatch(source);
+
+ public static KernelResult<WireFormFeatureAir> Parse(string source)
+ {
+ ArgumentNullException.ThrowIfNull(source);
+ var declaration = Declaration.Match(source);
+ if (!declaration.Success) return Fail("wireform-declaration-missing", "No WireForm declaration was found.");
+ var open = source.IndexOf('{', declaration.Index);
+ var close = MatchingBrace(source, open);
+ var name = declaration.Groups["name"].Value;
+ if (close < 0) return Fail("wireform-declaration-malformed", $"WireForm '{name}' has no closing brace.");
+ var body = source[(open + 1)..close];
+
+ if (!TryLength(Property(body, "Diameter"), out var diameter) || diameter <= 0d)
+ return Fail("wireform-diameter-invalid", $"WireForm '{name}' Diameter must be a finite length greater than zero.");
+ var materialReference = (Property(body, "Material") ?? "Standard.Materials.StainlessSteel.304_Annealed").Trim('"');
+ var material = new MaterialResolver().Resolve(materialReference);
+ if (!material.IsSuccess || material.Material is null)
+ return Fail("wireform-material-unresolved", material.Message ?? $"Material '{materialReference}' could not be resolved.");
+
+ if (!TryVector(Property(body, "Origin"), out var origin))
+ return Fail("wireform-start-frame-invalid", $"WireForm '{name}' requires StartFrame Origin: [x,y,z].");
+ if (!TryVector(Property(body, "Tangent"), out var tangentVector) || !TryDirection(tangentVector, out var tangent))
+ return Fail("wireform-start-frame-invalid", $"WireForm '{name}' requires a nonzero StartFrame Tangent.");
+ if (!TryVector(Property(body, "Up"), out var upVector))
+ return Fail("wireform-start-frame-invalid", $"WireForm '{name}' requires StartFrame Up.");
+ var upRejected = upVector - tangent.ToVector() * Dot(upVector, tangent.ToVector());
+ if (!TryDirection(upRejected, out var up))
+ return Fail("wireform-start-frame-invalid", $"WireForm '{name}' Up must not be parallel to Tangent.");
+
+ var state = new WireState(new(origin.X, origin.Y, origin.Z), tangent, up, 0d);
+ var operations = new List<WireFormOperationAir>();
+ foreach (Match match in Operation.Matches(body))
+ {
+ var operationOpen = body.IndexOf('{', match.Index);
+ var operationClose = MatchingBrace(body, operationOpen);
+ if (operationClose < 0) return Fail("wireform-operation-malformed", $"Operation '{match.Groups["name"].Value}' has no closing brace.");
+ var operationBody = body[(operationOpen + 1)..operationClose];
+ var operationName = match.Groups["name"].Value;
+ var ordinal = operations.Count + 1;
+ if (match.Groups["kind"].Value == "Straight")
+ {
+ if (!TryLength(Property(operationBody, "Length"), out var length) || length <= 0d)
+ return Fail("wireform-straight-length-invalid", $"{operationName}: Length must be finite and greater than zero.");
+ var output = state with { Position = state.Position + state.Tangent.ToVector() * length, AccumulatedLengthMm = state.AccumulatedLengthMm + length };
+ operations.Add(new WireStraightAir(operationName, ordinal, length, state, output));
+ state = output;
+ continue;
+ }
+
+ if (!TryLength(Property(operationBody, "Radius"), out var radius) || radius <= 0d)
+ return Fail("wireform-bend-radius-invalid", $"{operationName}: centerline Radius must be finite and greater than zero.");
+ if (radius <= diameter / 2d + ToleranceContext.Default.Linear)
+ return Fail("wireform-bend-radius-invalid", $"{operationName}: centerline Radius {radius:G6} mm must exceed wire radius {diameter / 2d:G6} mm (geometric-only policy).");
+ if (!TryAngle(Property(operationBody, "Angle"), out var angle) || Math.Abs(angle) <= ToleranceContext.Default.Angular || Math.Abs(angle) > Math.PI + ToleranceContext.Default.Angular)
+ return Fail("wireform-bend-angle-invalid", $"{operationName}: Angle must be nonzero and no greater than 180 degrees in magnitude.");
+ var plane = Property(operationBody, "Plane") ?? "Up";
+ if (plane is not ("Up" or "Right"))
+ return Fail("wireform-bend-plane-invalid", $"{operationName}: Plane must be Up or Right in the current local frame.");
+ var authoredNormal = plane == "Up" ? state.Up : state.Right;
+ var axis = angle >= 0d ? authoredNormal : Direction3D.Create(authoredNormal.ToVector() * -1d);
+ var sweep = Math.Abs(angle);
+ var startRadial = Direction3D.Create(Cross(state.Tangent.ToVector(), axis.ToVector()));
+ var center = state.Position - startRadial.ToVector() * radius;
+ var endRadial = Rotate(startRadial.ToVector(), axis.ToVector(), sweep);
+ var endTangent = Direction3D.Create(Rotate(state.Tangent.ToVector(), axis.ToVector(), sweep));
+ var endUp = Direction3D.Create(Rotate(state.Up.ToVector(), axis.ToVector(), sweep));
+ var bendLength = radius * sweep;
+ var bendOutput = new WireState(center + endRadial * radius, endTangent, endUp, state.AccumulatedLengthMm + bendLength);
+ operations.Add(new WireBendAir(operationName, ordinal, radius, angle, plane, axis, center, startRadial, state, bendOutput));
+ state = bendOutput;
+ }
+ if (operations.Count == 0) return Fail("wireform-operations-empty", $"WireForm '{name}' requires at least one Straight or Bend operation.");
+ return KernelResult<WireFormFeatureAir>.Success(new(name, diameter, materialReference, material.Material,
+ new WireState(new(origin.X, origin.Y, origin.Z), tangent, up, 0d), operations, FrameTransportPolicy));
+ }
+
+ private static string? Property(string body, string name)
+ {
+ var match = Regex.Match(body, $@"\b{Regex.Escape(name)}\s*:\s*(?<value>\[[^\]]+\]|[^;\r\n}}]+)", RegexOptions.CultureInvariant);
+ return match.Success ? match.Groups["value"].Value.Trim() : null;
+ }
+ private static bool TryLength(string? text, out double value)
+ {
+ value = default;
+ return text is not null && new BoundedMeasureExpression(text, "mm").TryEvaluate(out value);
+ }
+ private static bool TryAngle(string? text, out double value)
+ {
+ value = default;
+ if (!TryUnit(text, "deg", out var degrees)) return false;
+ value = degrees * Math.PI / 180d;
+ return double.IsFinite(value);
+ }
+ private static bool TryUnit(string? text, string unit, out double value)
+ {
+ value = default;
+ if (text is null) return false;
+ var match = Regex.Match(text, $@"^(?<value>[-+.\deE]+){unit}$", RegexOptions.CultureInvariant);
+ return match.Success && double.TryParse(match.Groups["value"].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out value) && double.IsFinite(value);
+ }
+ private static bool TryVector(string? text, out Vector3D value)
+ {
+ value = default;
+ if (text is null) return false;
+ var parts = text.Trim().TrimStart('[').TrimEnd(']').Split(',', StringSplitOptions.TrimEntries);
+ if (parts.Length != 3) return false;
+ var values = new double[3];
+ for (var i = 0; i < 3; i++)
+ {
+ var token = parts[i].EndsWith("mm", StringComparison.Ordinal) ? parts[i][..^2] : parts[i];
+ if (!double.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out values[i]) || !double.IsFinite(values[i])) return false;
+ }
+ value = new(values[0], values[1], values[2]); return true;
+ }
+ private static bool TryDirection(Vector3D vector, out Direction3D direction)
+ {
+ try { direction = Direction3D.Create(vector); return true; }
+ catch (ArgumentException) { direction = default; return false; }
+ }
+ private static int MatchingBrace(string source, int open) { var depth = 0; for (var i = open; i >= 0 && i < source.Length; i++) { if (source[i] == '{') depth++; else if (source[i] == '}' && --depth == 0) return i; } return -1; }
+ private static Vector3D Rotate(Vector3D vector, Vector3D axis, double angle) => vector * Math.Cos(angle) + Cross(axis, vector) * Math.Sin(angle) + axis * (Dot(axis, vector) * (1d - Math.Cos(angle)));
+ internal 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);
+ internal static double Dot(Vector3D a, Vector3D b) => a.X * b.X + a.Y * b.Y + a.Z * b.Z;
+ private sealed class BoundedMeasureExpression(string source, string unit)
+ {
+ private int index;
+ public bool TryEvaluate(out double value) { value = default; index = 0; if (!Expression(out var result) || result.Dimension != 1) return false; Space(); if (index != source.Length || !double.IsFinite(result.Value)) return false; value = result.Value; return true; }
+ private bool Expression(out Quantity result) { if (!Term(out result)) return false; while (true) { Space(); if (index >= source.Length || source[index] is not ('+' or '-')) return true; var operation = source[index++]; if (!Term(out var right) || result.Dimension != right.Dimension) return false; result = new(operation == '+' ? result.Value + right.Value : result.Value - right.Value, result.Dimension); } }
+ private bool Term(out Quantity result) { if (!Factor(out result)) return false; while (true) { Space(); if (index >= source.Length || source[index] is not ('*' or '/')) return true; var operation = source[index++]; if (!Factor(out var right)) return false; var dimension = operation == '*' ? result.Dimension + right.Dimension : result.Dimension - right.Dimension; if (dimension is < 0 or > 1 || operation == '/' && Math.Abs(right.Value) <= double.Epsilon) return false; result = new(operation == '*' ? result.Value * right.Value : result.Value / right.Value, dimension); } }
+ private bool Factor(out Quantity result) { Space(); result = default; if (index >= source.Length) return false; if (source[index] == '(') { index++; if (!Expression(out result)) return false; Space(); return index < source.Length && source[index++] == ')'; } var sign = 1d; if (source[index] is '+' or '-') sign = source[index++] == '-' ? -1d : 1d; Space(); var start = index; while (index < source.Length && (char.IsDigit(source[index]) || source[index] is '.' or 'e' or 'E' || source[index] is '+' or '-' && index > start && source[index - 1] is 'e' or 'E')) index++; if (start == index || !double.TryParse(source[start..index], NumberStyles.Float, CultureInfo.InvariantCulture, out var number)) return false; var dimension = 0; if (source.AsSpan(index).StartsWith(unit, StringComparison.Ordinal)) { index += unit.Length; dimension = 1; } result = new(sign * number, dimension); return true; }
+ private void Space() { while (index < source.Length && char.IsWhiteSpace(source[index])) index++; }
+ private readonly record struct Quantity(double Value, int Dimension);
+ }
+ private static KernelResult<WireFormFeatureAir> Fail(string code, string message) => KernelResult<WireFormFeatureAir>.Failure([new(
+ Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Core.Diagnostics.KernelDiagnosticSeverity.Error, $"{code}: {message}", "FirmamentV2.WireForm")]);
+}
+
+/// <summary>Exact circular sweep realization for 3D line/arc WireForm centerlines.</summary>
+public static class WireFormBRepMaterializer
+{
+ private static readonly ToleranceContext Tolerance = ToleranceContext.Default;
+
+ public static KernelResult<WireFormBuildResult> Build(WireFormFeatureAir feature)
+ {
+ var diagnostics = Validate(feature);
+ if (diagnostics.Count > 0) return KernelResult<WireFormBuildResult>.Failure(diagnostics.Select(Error).ToArray());
+ try
+ {
+ var count = feature.Operations.Count;
+ var builder = new TopologyBuilder(); var geometry = new BrepGeometryStore(); var bindings = new BrepBindingModel();
+ var ringVertices = new VertexId[count + 1]; var ringEdges = new EdgeId[count + 1]; var vertexPoints = new Dictionary<VertexId, Point3D>();
+ var states = feature.Operations.Select(x => x.Input).Append(feature.EndState).ToArray();
+ var nextCurve = 1; var nextSurface = 1;
+ for (var i = 0; i < states.Length; i++)
+ {
+ var state = states[i]; ringVertices[i] = builder.AddVertex();
+ vertexPoints[ringVertices[i]] = state.Position + state.Up.ToVector() * feature.WireRadiusMm;
+ ringEdges[i] = builder.AddEdge(ringVertices[i], ringVertices[i]);
+ var curve = new CurveGeometryId(nextCurve++);
+ geometry.AddCurve(curve, CurveGeometry.FromCircle(new Circle3Curve(state.Position, state.Tangent, feature.WireRadiusMm, state.Up)));
+ bindings.AddEdgeBinding(new(ringEdges[i], curve, new ParameterInterval(0d, 2d * Math.PI)));
+ }
+ var faces = new List<FaceId>();
+ for (var i = 0; i < count; i++)
+ {
+ var operation = feature.Operations[i]; var seam = builder.AddEdge(ringVertices[i], ringVertices[i + 1]);
+ var seamCurve = new CurveGeometryId(nextCurve++); var surface = new SurfaceGeometryId(nextSurface++);
+ if (operation is WireStraightAir straight)
+ {
+ geometry.AddCurve(seamCurve, CurveGeometry.FromLine(new Line3Curve(vertexPoints[ringVertices[i]], straight.Input.Tangent)));
+ bindings.AddEdgeBinding(new(seam, seamCurve, new ParameterInterval(0d, straight.LengthMm)));
+ geometry.AddSurface(surface, SurfaceGeometry.FromCylinder(new CylinderSurface(straight.Input.Position, straight.Input.Tangent, feature.WireRadiusMm, straight.Input.Up)));
+ }
+ else if (operation is WireBendAir bend)
+ {
+ var axis = bend.PlaneNormal.ToVector(); var up = bend.Input.Up.ToVector(); var axial = WireFormAuthoring.Dot(up, axis);
+ var seamCenter = bend.Center + axis * (axial * feature.WireRadiusMm);
+ var seamRadial = bend.StartRadial.ToVector() * bend.RadiusMm + (up - axis * axial) * feature.WireRadiusMm;
+ var seamRadius = seamRadial.Length; var seamReference = Direction3D.Create(seamRadial);
+ geometry.AddCurve(seamCurve, CurveGeometry.FromCircle(new Circle3Curve(seamCenter, bend.PlaneNormal, seamRadius, seamReference)));
+ bindings.AddEdgeBinding(new(seam, seamCurve, new ParameterInterval(0d, Math.Abs(bend.AngleRadians))));
+ geometry.AddSurface(surface, SurfaceGeometry.FromTorus(new TorusSurface(bend.Center, bend.PlaneNormal, bend.RadiusMm, feature.WireRadiusMm, bend.StartRadial)));
+ }
+ else throw new NotSupportedException("WireForm X0 admits Straight and Bend only.");
+ var side = AddFace(builder, [(seam, false), (ringEdges[i + 1], false), (seam, true), (ringEdges[i], true)]);
+ bindings.AddFaceBinding(new(side, surface)); faces.Add(side);
+ }
+ var startSurface = new SurfaceGeometryId(nextSurface++);
+ geometry.AddSurface(startSurface, SurfaceGeometry.FromPlane(new PlaneSurface(feature.StartState.Position, Direction3D.Create(feature.StartState.Tangent.ToVector() * -1d), feature.StartState.Up)));
+ var startFace = AddFace(builder, [(ringEdges[0], false)]); bindings.AddFaceBinding(new(startFace, startSurface)); faces.Add(startFace);
+ var endSurface = new SurfaceGeometryId(nextSurface++);
+ geometry.AddSurface(endSurface, SurfaceGeometry.FromPlane(new PlaneSurface(feature.EndState.Position, feature.EndState.Tangent, feature.EndState.Up)));
+ var endFace = AddFace(builder, [(ringEdges[^1], true)]); bindings.AddFaceBinding(new(endFace, endSurface)); faces.Add(endFace);
+ var shell = builder.AddShell(faces); builder.AddBody([shell]); var body = new BrepBody(builder.Model, geometry, bindings, vertexPoints);
+ var bindingValidation = BrepBindingValidator.Validate(body, true);
+ if (!bindingValidation.IsSuccess) return KernelResult<WireFormBuildResult>.Failure(bindingValidation.Diagnostics);
+ var preflight = BrepExportPreflight.Validate(body);
+ if (!preflight.IsValid) return KernelResult<WireFormBuildResult>.Failure(preflight.Diagnostics.Where(x => x.Severity == BrepExportPreflightSeverity.Error).Select(x => Error($"wireform-brep-invalid: {x.Code}: {x.Message}")).ToArray());
+ var samples = feature.Operations.SelectMany(x => Sample(x, 64)).ToArray(); var r = feature.WireRadiusMm;
+ var bounds = new[] { samples.Min(x => x.X) - r, samples.Min(x => x.Y) - r, samples.Min(x => x.Z) - r,
+ samples.Max(x => x.X) + r, samples.Max(x => x.Y) + r, samples.Max(x => x.Z) + r };
+ var volume = Math.PI * r * r * feature.TotalWireLengthMm;
+ var mass = volume * 1e-9 * feature.Material.Structural!.Density.SiValue;
+ return KernelResult<WireFormBuildResult>.Success(new(feature, body, volume, mass, bounds,
+ ["wireform-state-replay-deterministic", "wireform-centerline-tangent", "wireform-self-intersection-clear", "wireform-analytic-circular-sweep", "wireform-geometric-minimum-radius"]));
+ }
+ catch (Exception exception) when (exception is ArgumentException or InvalidOperationException or NotSupportedException)
+ { return KernelResult<WireFormBuildResult>.Failure([Error("wireform-brep-construction-failed: " + exception.Message)]); }
+ }
+
+ public static IReadOnlyList<string> Validate(WireFormFeatureAir feature)
+ {
+ var diagnostics = new List<string>();
+ if (feature.Operations.Count == 0) diagnostics.Add("wireform-operations-empty: at least one operation is required.");
+ foreach (var operation in feature.Operations)
+ {
+ if (operation.LengthMm <= Tolerance.Linear) diagnostics.Add($"wireform-operation-degenerate:{operation.Name}");
+ if (operation is WireBendAir bend && bend.RadiusMm <= feature.WireRadiusMm + Tolerance.Linear)
+ diagnostics.Add($"wireform-bend-radius-invalid:{bend.Name}: centerline radius must exceed wire radius.");
+ }
+ var clearance = feature.DiameterMm;
+ for (var i = 0; i + 1 < feature.Operations.Count; i++)
+ {
+ var distance = AdjacentNonlocalDistance(feature.Operations[i], feature.Operations[i + 1], clearance);
+ if (distance + Tolerance.Linear < clearance)
+ diagnostics.Add($"wireform-self-intersection:{feature.Operations[i].Name}:{feature.Operations[i + 1].Name}: adjacent operations collide away from their intended tangent join; conservative clearance is {distance:G6} mm, required {clearance:G6} mm.");
+ }
+ for (var i = 0; i < feature.Operations.Count; i++) for (var j = i + 2; j < feature.Operations.Count; j++)
+ {
+ var distance = ConservativeDistance(feature.Operations[i], feature.Operations[j]);
+ if (distance + Tolerance.Linear < clearance)
+ diagnostics.Add($"wireform-self-intersection:{feature.Operations[i].Name}:{feature.Operations[j].Name}: centerlines are {distance:G6} mm apart; required clearance is {clearance:G6} mm. Intentional contact is unsupported in X0.");
+ }
+ return diagnostics;
+ }
+
+ private static double AdjacentNonlocalDistance(WireFormOperationAir a, WireFormOperationAir b, double clearance)
+ {
+ const int count = 192; var aa = Sample(a, count); var bb = Sample(b, count); var best = double.PositiveInfinity;
+ // A two-diameter arclength neighborhood around the common endpoint is the
+ // intended continuous tube join. Compare every chord pair outside it so
+ // adjacent operations cannot retrace/collide elsewhere.
+ for (var i = 0; i < aa.Count - 1; i++) for (var j = 0; j < bb.Count - 1; j++)
+ {
+ var fromJoinA = a.LengthMm * (count - i - 1d) / count;
+ var fromJoinB = b.LengthMm * j / count;
+ if (fromJoinA < clearance || fromJoinB < clearance) continue;
+ best = Math.Min(best, SegmentDistance(aa[i], aa[i + 1], bb[j], bb[j + 1]));
+ }
+ return double.IsPositiveInfinity(best) ? double.PositiveInfinity : Math.Max(0d, best - Sagitta(a, count) - Sagitta(b, count));
+ }
+
+ private static double ConservativeDistance(WireFormOperationAir a, WireFormOperationAir b)
+ {
+ var aa = Sample(a, 96); var bb = Sample(b, 96); var best = double.PositiveInfinity;
+ for (var i = 0; i < aa.Count - 1; i++) for (var j = 0; j < bb.Count - 1; j++) best = Math.Min(best, SegmentDistance(aa[i], aa[i + 1], bb[j], bb[j + 1]));
+ // Chords alone can overestimate arc/arc or arc/line clearance. Subtract each
+ // arc's maximum chord sagitta so this is a conservative lower bound and the
+ // no-contact policy fails closed (at the cost of bounded false positives).
+ return Math.Max(0d, best - Sagitta(a, 96) - Sagitta(b, 96));
+ }
+ private static double Sagitta(WireFormOperationAir operation, int count) => operation is WireBendAir bend
+ ? bend.RadiusMm * (1d - Math.Cos(Math.Abs(bend.AngleRadians) / (2d * count))) : 0d;
+ private static IReadOnlyList<Point3D> Sample(WireFormOperationAir operation, int count) => operation switch
+ {
+ WireStraightAir line => [line.Input.Position, line.Output.Position],
+ WireBendAir bend => Enumerable.Range(0, count + 1).Select(i => bend.Center + Rotate(bend.StartRadial.ToVector(), bend.PlaneNormal.ToVector(), Math.Abs(bend.AngleRadians) * i / count) * bend.RadiusMm).ToArray(),
+ _ => []
+ };
+ private static double SegmentDistance(Point3D p1, Point3D q1, Point3D p2, Point3D q2)
+ {
+ var d1 = q1 - p1; var d2 = q2 - p2; var r = p1 - p2; var a = Dot(d1, d1); var e = Dot(d2, d2); var f = Dot(d2, r); double s, t;
+ if (a <= 1e-24 && e <= 1e-24) return (p1 - p2).Length;
+ if (a <= 1e-24) { s = 0d; t = Math.Clamp(f / e, 0d, 1d); }
+ else { var c = Dot(d1, r); if (e <= 1e-24) { t = 0d; s = Math.Clamp(-c / a, 0d, 1d); } else { var b = Dot(d1, d2); var denominator = a * e - b * b; s = denominator == 0d ? 0d : Math.Clamp((b * f - c * e) / denominator, 0d, 1d); t = (b * s + f) / e; if (t < 0d) { t = 0d; s = Math.Clamp(-c / a, 0d, 1d); } else if (t > 1d) { t = 1d; s = Math.Clamp((b - c) / a, 0d, 1d); } } }
+ return (p1 + d1 * s - (p2 + d2 * t)).Length;
+ }
+ private static Vector3D Rotate(Vector3D vector, Vector3D axis, double angle) => vector * Math.Cos(angle) + WireFormAuthoring.Cross(axis, vector) * Math.Sin(angle) + axis * (Dot(axis, vector) * (1d - Math.Cos(angle)));
+ private static double Dot(Vector3D a, Vector3D b) => WireFormAuthoring.Dot(a, b);
+ private static FaceId AddFace(TopologyBuilder builder, IReadOnlyList<(EdgeId Edge, bool Reversed)> uses) { var loop = builder.AllocateLoopId(); var ids = uses.Select(_ => builder.AllocateCoedgeId()).ToArray(); for (var i = 0; i < uses.Count; i++) builder.AddCoedge(new(ids[i], uses[i].Edge, loop, ids[(i + 1) % ids.Length], ids[(i + ids.Length - 1) % ids.Length], uses[i].Reversed)); builder.AddLoop(new Loop(loop, ids)); return builder.AddFace([loop]); }
+ private static Core.Diagnostics.KernelDiagnostic Error(string message) => new(Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Core.Diagnostics.KernelDiagnosticSeverity.Error, message, "FirmamentV2.WireForm");
+}
+
+public static class WireFormReportFactory
+{
+ public static FirmamentWireFormReport Create(WireFormBuildResult built, string stepSha256, bool reimportedManifold)
+ {
+ var feature = built.Feature;
+ var surfaces = built.Body.Topology.Faces.Select(face => built.Body.GetFaceSurface(face.Id).Kind).ToArray();
+ var operations = feature.Operations.Select(operation => new FirmamentWireOperationReport(
+ operation.Ordinal, operation.Name, operation is WireStraightAir ? "Straight" : "Bend", operation.LengthMm,
+ operation is WireBendAir bend ? bend.RadiusMm : null,
+ operation is WireBendAir bendAngle ? bendAngle.AngleRadians * 180d / Math.PI : null,
+ operation is WireBendAir bendPlane ? bendPlane.Plane : null, operation.StableId(feature.Name),
+ State(operation.Input), State(operation.Output), operation is WireStraightAir ? "LineSegment" : "CircularArc",
+ operation is WireStraightAir ? "Cylinder" : "Torus")).ToArray();
+ return new(feature.Name, feature.DiameterMm, feature.Material.Identity.FirmamentPath, feature.Operations.Count,
+ feature.Operations.Count(x => x is WireStraightAir), feature.Operations.Count(x => x is WireBendAir),
+ feature.TotalStraightLengthMm, feature.TotalBendLengthMm, feature.TotalWireLengthMm, built.VolumeMm3, built.MassKilograms,
+ Terminal("TerminalStart", feature.StartState, feature.DiameterMm), Terminal("TerminalEnd", feature.EndState, feature.DiameterMm),
+ feature.Operations.OfType<WireBendAir>().Select(x => x.RadiusMm).DefaultIfEmpty(double.NaN).Min(),
+ "CenterlineRadius", "GeometricOnly: centerline bend radius must exceed Diameter/2",
+ "Nonadjacent operations use deterministic 3D chord witnesses with arc-sagitta error bounds; contact/overlap fails closed.",
+ feature.FrameTransportPolicy, operations, built.Bounds,
+ surfaces.Count(x => x == SurfaceGeometryKind.Cylinder), surfaces.Count(x => x == SurfaceGeometryKind.Torus),
+ surfaces.Count(x => x == SurfaceGeometryKind.Plane), surfaces.Count(x => x is not (SurfaceGeometryKind.Cylinder or SurfaceGeometryKind.Torus or SurfaceGeometryKind.Plane)),
+ surfaces.Count(x => x == SurfaceGeometryKind.BSplineSurfaceWithKnots), 0, true, stepSha256, true, reimportedManifold);
+ }
+
+ private static FirmamentWireStateReport State(WireState state) => new(V(state.Position), V(state.Tangent), V(state.Up), V(state.Right), state.AccumulatedLengthMm);
+ private static FirmamentWireTerminalReport Terminal(string name, WireState state, double diameter) => new(name, V(state.Position), V(state.Tangent), V(state.Up), diameter);
+ private static double[] V(Point3D p) => [p.X, p.Y, p.Z];
+ private static double[] V(Direction3D d) => [d.X, d.Y, d.Z];
+}
diff --git a/Aetheris.Kernel.Firmament/Standard/StandardProducts.firmament b/Aetheris.Kernel.Firmament/Standard/StandardProducts.firmament
index 8aa1325c..0620fbd8 100644
--- a/Aetheris.Kernel.Firmament/Standard/StandardProducts.firmament
+++ b/Aetheris.Kernel.Firmament/Standard/StandardProducts.firmament
@@ -12,18 +12,18 @@ Model StandardProducts {
Require PositiveBendRadii => P.OuterBendRadius > 0mm && P.InnerBendRadius > 0mm
Require OuterBendExceedsInnerBend => P.OuterBendRadius > P.InnerBendRadius
Require InnerBendClearsWire => P.InnerBendRadius > P.WireDiameter
- Concept Path PaperclipPath {
- // The reference frame places the inner-right terminal at X=8 mm.
- Start: Point2(8mm, 0mm) Heading: 90deg
- Line InnerRightUp { Length: P.InnerLegLength }
- Arc InnerTop { Radius: P.InnerBendRadius; Turn: 180deg }
- Line InnerLeftDown { Length: P.InnerLegLength }
- Arc LowerReturn { Radius: (P.OuterBendRadius + P.InnerBendRadius) / 2; Turn: 180deg }
- Line OuterRightUp { Length: P.OuterLegLength }
- Arc OuterTop { Radius: P.OuterBendRadius; Turn: 180deg }
- Line OuterLeftDown { Length: P.OuterLegLength }
+ WireForm Paperclip {
+ Diameter: P.WireDiameter
+ Material: P.Material
+ StartFrame { Origin: [8mm, 0mm, 0mm]; Tangent: [0, 1, 0]; Up: [0, 0, 1] }
+ Straight InnerRight { Length: P.InnerLegLength }
+ Bend InnerTop { Radius: P.InnerBendRadius; Angle: 180deg; Plane: Up }
+ Straight InnerLeft { Length: P.InnerLegLength }
+ Bend LowerReturn { Radius: (P.OuterBendRadius + P.InnerBendRadius) / 2; Angle: 180deg; Plane: Up }
+ Straight OuterRight { Length: P.OuterLegLength }
+ Bend OuterTop { Radius: P.OuterBendRadius; Angle: 180deg; Plane: Up }
+ Straight OuterLeft { Length: P.OuterLegLength }
}
- Sweep Paperclip { Path: PaperclipPath; Diameter: P.WireDiameter; Material: P.Material; }
}
Record MountingPlatePolicy { Width: Length Height: Length Thickness: Length HoleDiameter: Length HoleSpacingX: Length HoleSpacingY: Length CounterboreDiameter: Length CounterboreDepth: Length Material: String }
diff --git a/Aetheris.Server/Api/PaperclipDemoEndpoints.cs b/Aetheris.Server/Api/PaperclipDemoEndpoints.cs
index de5d8f85..04a06d0d 100644
--- a/Aetheris.Server/Api/PaperclipDemoEndpoints.cs
+++ b/Aetheris.Server/Api/PaperclipDemoEndpoints.cs
@@ -27,12 +27,12 @@ public static class PaperclipDemoEndpoints
new Dictionary<string, FirmamentHostArgument>(StringComparer.Ordinal) { ["P"] = new(string.Empty, "PaperclipPolicy", fields) }, out var diagnostics);
if (expansion is null) return ApiMappings.BadRequestFromMessage(string.Join("; ", diagnostics), "maximum-paperclips.bind");
var compiled = FirmamentBuildAndExport.CompileSource(expansion.ExpandedSource);
- if (!compiled.IsSuccess || compiled.Value.Sweep is null)
+ if (!compiled.IsSuccess || compiled.Value.WireForm is null)
return ApiMappings.KernelFailure(compiled.Diagnostics);
- var sweep = compiled.Value.Sweep;
+ var wire = compiled.Value.WireForm;
return ApiMappings.Ok(new PaperclipDemoResponse(compiled.Value.StepText, expansion.SpecializationIdentity,
- sweep.CenterlineLength, sweep.MassKilograms * 1000d, 1000d / sweep.CenterlineLength, sweep.Bounds,
- sweep.Material, sweep.EnclosedManifold, sweep.StepReimportSucceeded, true));
+ wire.TotalWireLengthMm, wire.MassKilograms * 1000d, 1000d / wire.TotalWireLengthMm, wire.Bounds,
+ wire.Material, wire.EnclosedManifold, wire.StepReimportSucceeded, true));
});
}
diff --git a/docs/public/README.md b/docs/public/README.md
index 5948890f..c47760cd 100644
--- a/docs/public/README.md
+++ b/docs/public/README.md
@@ -4,7 +4,7 @@ This directory is the only authoritative in-repository guide to behavior shipped
Start with [Getting Started](getting-started.md), then use these guides:
-- Firmament: [overview](firmament/overview.md), [language style](firmament/language-style.md), [syntax](firmament/syntax.md), [geometry](firmament/geometry.md), [bounded mathematical sculpting](firmament/sculpting.md), [Section chains](firmament/section-chains.md), [PlasticShell](firmament/plastic-shell.md), [Circular Sweep](firmament/sweep.md), [Structural members and weldments](firmament/structural.md), [Semantic piping and local autorouting](firmament/piping.md), [Paperclip Template](firmament/paperclip.md), [Templates](firmament/templates.md), [materials](firmament/materials.md), [PMI](firmament/pmi.md), [Sheet Metal](firmament/sheet-metal.md), [FEA](firmament/fea.md), and [STEP import](firmament/step-import.md)
+- Firmament: [overview](firmament/overview.md), [language style](firmament/language-style.md), [syntax](firmament/syntax.md), [geometry](firmament/geometry.md), [bounded mathematical sculpting](firmament/sculpting.md), [Section chains](firmament/section-chains.md), [PlasticShell](firmament/plastic-shell.md), [Circular Sweep](firmament/sweep.md), [Formed Wire](firmament/wire-form.md), [Structural members and weldments](firmament/structural.md), [Semantic piping and local autorouting](firmament/piping.md), [Paperclip Template](firmament/paperclip.md), [Templates](firmament/templates.md), [materials](firmament/materials.md), [PMI](firmament/pmi.md), [Sheet Metal](firmament/sheet-metal.md), [FEA](firmament/fea.md), and [STEP import](firmament/step-import.md)
- Non-manufacturing work: [Virtual Sculpture and Sol 1](virtual-sculpture.md)
- Standard Library: [product-family index, invocation, authoring, and compatibility](standard-library/README.md)
- Interoperability: [Forge Host Protocol v1](forge/interop.md)
diff --git a/docs/public/firmament/geometry.md b/docs/public/firmament/geometry.md
index 95210bc0..734ff208 100644
--- a/docs/public/firmament/geometry.md
+++ b/docs/public/firmament/geometry.md
@@ -1,6 +1,6 @@
# Geometry and semantic features
-Preview 3 plus X0 supports bounded production routes, not an unrestricted general-purpose CAD kernel. Public native examples cover Box, Cylinder, Frustum, RoundedBox, line/arc profile extrusion and composition, bounded [circular Sweep](sweep.md), semantic shaft/counterbore/countersink holes, slots, patterns, selected chamfer/fillet routes, hollow bodies, and a bounded cubic lattice. Consult the [support matrix](../reference/supported-features.md) before relying on a combination.
+Preview 3 plus X0 supports bounded production routes, not an unrestricted general-purpose CAD kernel. Public native examples cover Box, Cylinder, Frustum, RoundedBox, line/arc profile extrusion and composition, bounded [circular Sweep](sweep.md), ordered [Formed Wire](wire-form.md), semantic shaft/counterbore/countersink holes, slots, patterns, selected chamfer/fillet routes, hollow bodies, and a bounded cubic lattice. Consult the [support matrix](../reference/supported-features.md) before relying on a combination.
Analytic single solids use the same direct named declaration family: `Sphere Body { Radius: 7.5mm }`, `Cone Body { ... }`, and `Torus Body { ... }`. `Cone` includes a pointed zero-radius end. These forms round-trip as analytic AP242 surfaces, but they do not imply arbitrary Boolean or profile-composition support. The older `solid Body: Sphere { radius: ... }` spelling remains a compatibility input, not canonical authoring. Use the qualified [sphere](../../../fixtures/Canonical/Primitives/sphere.firmament), [pointed cone](../../../fixtures/Canonical/Primitives/pointed-cone.firmament), and [torus](../../../fixtures/Canonical/Primitives/torus.firmament) sources as the boundary examples.
diff --git a/docs/public/firmament/paperclip.md b/docs/public/firmament/paperclip.md
index 0fe3b050..b3912ea9 100644
--- a/docs/public/firmament/paperclip.md
+++ b/docs/public/firmament/paperclip.md
@@ -1,6 +1,6 @@
# Standard Paperclip Template
-`Standard.Products.Office.Paperclip` specializes a typed `PaperclipPolicy`, derives a readable seven-segment Concept Path, and lowers it through the exact circular Sweep lane.
+`Standard.Products.Office.Paperclip` specializes a typed `PaperclipPolicy`. Standard Paperclip is now authored as a `WireForm` forming sequence and lowered through explicit line/arc centerline AIR to exact circular Sweep geometry.
The default `StandardPaperclip` reconstructs the analytic design intent of the PAPERCLIP-X1 SolidWorks reference. Its ordered centerline is: 14 mm inner-right leg, R3 180° inner-top bend, 14 mm inner-left leg, R4 180° lower return, 15 mm outer-right leg, R5 180° outer-top bend, and 15 mm outer-left leg. Every join is tangent, the wire diameter is constant at 1 mm, and the resulting product envelope is 11 × 25 × 1 mm.
@@ -13,9 +13,18 @@ The default `StandardPaperclip` reconstructs the analytic design intent of the P
| `InnerBendRadius` | 3 mm |
| `Material` | `Standard.Materials.StainlessSteel.304_Annealed` |
-The canonical authoring form is `Record → Static defaults → with overrides → Template<PaperclipPolicy>`. Start with [`paperclip.firmament`](../../../fixtures/Canonical/Templates/paperclip.firmament); variants should override policy data instead of rewriting the path.
+The canonical authoring form is `Record → Static defaults → with overrides → Template<PaperclipPolicy>`. Start with [`paperclip.firmament`](../../../fixtures/Canonical/Templates/paperclip.firmament); variants should override policy data instead of rewriting the forming sequence or calculating tangent coordinates.
-The X0 fields `OverallLength`, `OuterWidth`, `InnerWidth`, `BendRadius`, and `LoopGap` encoded the former incorrect silhouette and are no longer accepted. For example, “make the paperclip 15% longer” maps to `StandardPaperclip with { OuterLegLength: 17.25mm InnerLegLength: 16.1mm }`; a wider form can increase both bend radii while preserving `OuterBendRadius > InnerBendRadius` and adequate wire clearance.
+The X0 fields `OverallLength`, `OuterWidth`, `InnerWidth`, `BendRadius`, and `LoopGap` encoded the former incorrect silhouette and are no longer accepted. For this product, “make the paperclip 15% longer” canonically means scaling both authored straight-leg parameters: `StandardPaperclip with { OuterLegLength: 17.25mm InnerLegLength: 16.1mm }`. The bend radii remain unchanged, so this is not a claim that every envelope or cut-stock measure grows by exactly 15%. A wider form can increase both bend radii while preserving `OuterBendRadius > InnerBendRadius` and adequate wire clearance.
+
+Export and independently inspect the default product with:
+
+```text
+aetheris build fixtures/Canonical/Templates/paperclip.firmament --output artifacts/local/wire-x0-paperclip.step --json
+aetheris analyze artifacts/local/wire-x0-paperclip.step --json
+```
+
+The qualified product is an enclosed manifold with 4 cylindrical straight faces, 3 toroidal bend faces, and 2 planar terminal caps. Its 11 × 25 × 1 mm envelope, 95.6991118431 mm ideal cut-stock length, zero rational/B-spline product surfaces, and zero faceted fallback are preserved by the WireForm template route.
Forge Host Protocol v1 publishes the template through ordinary `list`, `describe`, and `invoke` operations. It has no paperclip-specific RPC. Cadmata's **MAXIMUM PAPERCLIPS** tab calls the same specialization/compiler path, imports the returned AP242, and displays the generated engineering geometry.
diff --git a/docs/public/firmament/wire-form.md b/docs/public/firmament/wire-form.md
new file mode 100644
index 00000000..8d2584fa
--- /dev/null
+++ b/docs/public/firmament/wire-form.md
@@ -0,0 +1,36 @@
+# Formed Wire
+
+Use `WireForm` when the design intent is a formed length of constant-section wire or rod. Authors specify the forming sequence; Aetheris derives the exact tangent centerline and materializes it with the circular Sweep kernel.
+
+```firmament
+WireForm BentWire {
+ Diameter: 1mm
+ Material: Standard.Materials.StainlessSteel.304_Annealed
+ StartFrame { Origin: [0mm, 0mm, 0mm]; Tangent: [1, 0, 0]; Up: [0, 0, 1] }
+ Straight Lead { Length: 20mm }
+ Bend Corner { Radius: 5mm; Angle: 90deg; Plane: Up }
+ Straight Tail { Length: 30mm }
+}
+```
+
+`Diameter` and `Material` define the stock. Direct WireForm authoring uses the catalog identity; a typed product policy may carry that identity through a `String` field. `StartFrame` supplies an origin, initial tangent, and perpendicular `Up` reference. A `Straight` advances along the current tangent and preserves the frame. A signed `Bend` rotates the tangent by `Angle` around either the current local `Up` or `Right` axis. Here `Plane` names the current local **plane normal/rotation axis**: `Plane: Up` bends in the tangent/right plane, while `Plane: Right` bends in the tangent/up plane. The frame is transported by the same rigid rotation, avoiding arbitrary spin. Start-frame transformations therefore carry the forming program without global-coordinate bend hacks.
+
+`Radius` is always the **centerline bend radius**. X0 applies a geometric-only minimum-radius rule: `Radius > Diameter / 2`. It does not invent material forming tables. Positive angles follow the right-hand rule about the selected local plane normal; negative angles reverse that normal. X0 admits nonzero angles through ±180°.
+
+Each operation consumes a `WireState` (position, tangent, local frame, and accumulated length) and produces the next state. Changing an operation intentionally moves every downstream operation. The compiler retains operation identity and exposes the operation-to-line/arc-to-cylinder/torus correspondence through structured inspection.
+
+The ideal cut-stock length is derived exactly:
+
+- Straight: `Length`
+- Bend: `Radius × abs(AngleRadians)`
+- Total: the sum of all operation lengths
+
+Circular area times total length gives volume; density from the Material DB gives mass. These are idealized centerline quantities. X0 does not model springback, plastic stretch, forming allowance corrections, or manufacturing process simulation.
+
+The centerline lowers to explicit line and circular-arc AIR, then to exact circular Sweep geometry. Straights become cylinders, bends become toroidal patches, and open terminals become planar caps. Canonical WireForms have no rational B-spline surfaces and no faceted fallback. Both terminals retain position, tangent/frame, and section diameter.
+
+X0 supports one continuous, unbranched, open wire with constant circular section. Nonadjacent contact or overlap fails closed. Coils, springs, helices, arbitrary splines, mathematical or physical knots, branching, variable section, deliberate contact, and closed-wire authoring are deferred. Direct `Concept Path` plus `Sweep` remains the lower-level choice for explicitly authored trajectories.
+
+See the canonical [90-degree bend](../../../fixtures/Canonical/WireForm/single-bend-90.firmament), [U-wire](../../../fixtures/Canonical/WireForm/u-wire.firmament), [two-plane 3D wire](../../../fixtures/Canonical/WireForm/three-dimensional-bends.firmament), and [Paperclip](../../../fixtures/Canonical/WireForm/paperclip.firmament).
+
+`aetheris inspect source.firmament --json` reports the semantic `wireForm` object, including `operations`, `totalStraightLength`, `totalBendLength`, and compiler-derived `totalWireLength`. A materializing `build --json` adds volume, mass, surface inventory, manifold/reimport status, rational/faceted counts, and the STEP hash.
diff --git a/docs/public/forge/interop.md b/docs/public/forge/interop.md
index e18b4a49..0c9668a4 100644
--- a/docs/public/forge/interop.md
+++ b/docs/public/forge/interop.md
@@ -2,7 +2,7 @@
Forge interop has three operations: list Templates, describe one Template, and invoke it. The host owns Firmament types, units, defaults, `Require` checks, specialization, geometry, and artifact production. Foreign clients only exchange explicit JSON and files.
-X0 also publishes `Standard.Products.Office.Paperclip`. `describe` exposes its `PaperclipPolicy` Record fields and metric units; `invoke` accepts those fields and emits `paperclip.step` through the same deterministic AP242 path as direct Firmament compilation.
+X0 also publishes `Standard.Products.Office.Paperclip`. `describe` exposes its `PaperclipPolicy` Record fields and metric units; `invoke` accepts those fields, lowers them to a semantic WireForm Straight/Bend sequence, and emits `paperclip.step` through deterministic analytic AP242.
C# can use the direct Forge API. Python, Go, Rust, and TypeScript/Node use the process protocol:
diff --git a/docs/public/reference/diagnostics.md b/docs/public/reference/diagnostics.md
index f41fe493..ae678660 100644
--- a/docs/public/reference/diagnostics.md
+++ b/docs/public/reference/diagnostics.md
@@ -10,6 +10,19 @@
- `firmament-sweep-self-intersection`: nonadjacent centerline regions violate required clearance.
- `firmament-sweep-material-unresolved`: the material identity is absent from the deployed catalog.
+## Formed Wire (WIRE-X0)
+
+- `wireform-diameter-invalid`: stock diameter is missing, non-finite, or non-positive.
+- `wireform-start-frame-invalid`: Origin/Tangent/Up is missing, the tangent is zero, or Up is parallel to the tangent.
+- `wireform-straight-length-invalid:<operation>`: Straight length is not finite and positive.
+- `wireform-bend-radius-invalid:<operation>`: centerline bend radius is not positive or does not exceed `Diameter / 2`. This local geometric check runs before body construction.
+- `wireform-bend-angle-invalid:<operation>`: Bend angle is zero or exceeds ±180°.
+- `wireform-bend-plane-invalid:<operation>`: Plane is not current local `Up` or `Right`.
+- `wireform-material-unresolved`: the material identity is absent from the deployed catalog.
+- `wireform-self-intersection:<opA>:<opB>`: nonadjacent wire portions violate diameter clearance. This later global check uses conservative 3D chord/sagitta bounds and rejects intentional contact.
+
+The Standard Paperclip template has stricter product policy (`InnerBendRadius > WireDiameter`) than generic WireForm's geometric `Radius > Diameter / 2`; named Template `Require` clauses can therefore reject a Paperclip specialization before WireForm lowering.
+
## Surface trim closure (SURF-X1a)
- `surf-intersection-none`: the qualified supports do not intersect inside the bounded domains.
diff --git a/docs/public/reference/supported-features.md b/docs/public/reference/supported-features.md
index 1a6c052b..e936a239 100644
--- a/docs/public/reference/supported-features.md
+++ b/docs/public/reference/supported-features.md
@@ -10,6 +10,7 @@
| Virtual Sculpture | Bounded (ART-X0) | The explicit `Mode: Virtual` Sol 1 flagship: deterministic golden-angle/Fibonacci 3D lattice, analytic toroidal frame and eye, exact closed-body AP242 assembly, evidence/preview output, and zero rational product surfaces. This is not manufacturing geometry and does not extend Firmament engineering domains. See [Virtual Sculpture](../virtual-sculpture.md). |
| Firmament V2 analytic primitives | Bounded | Direct named Sphere, Cone (including zero-radius pointed end), and Torus routes round-trip through AP242; legacy `solid` declarations remain compatibility inputs, not canonical authoring |
| Circular Sweep | Bounded (X0) | Open planar XY Concept Path, tangent line/arc segments, constant circular diameter, analytic cylinder/torus faces, capped solid; no general 3D/variable/rail/twist sweep |
+| Formed Wire | Bounded (WIRE-X0) | One open, continuous, unbranched constant circular wire; explicit 3D StartFrame; ordered Straight and signed planar Bend operations through ±180° in current local Up/Right planes; exact line/arc centerline, ideal cut length/volume/mass, analytic cylinders/tori/caps, terminals, and fail-closed no-contact validation. No coils, knots, branches, variable section, springback, or intentional contact. See [guide](../firmament/wire-form.md). |
| SectionChain ruled loft substrate | Bounded (SURF-X3b subset) | Firmament authoring lowers into ordered framed, same-topology semantic SectionChain IR; one-to-one ruled transitions; shared edges; Cap/Open; strict pcurves; deterministic intersection checks; persistent typed BodyState Add/Remove through documented planar housing lanes; no generic CSG authoring, rational product surface, or faceted fallback. See [Section chains](../firmament/section-chains.md). |
| Structural / weldment | Bounded (X2) | Explicit 3D nodes and straight paths; identifiable members; square/rectangular/round tube, angle, flat/round bar; orientation; catalog material; two-member butt and polygonal miter joints; semantic fillet welds; AP242 member assembly and deterministic JSON Cut List. No coping, curved routing, multi-member miter, connection design, weld analysis, or structural FEA. See [guide](../firmament/structural.md). |
| Semantic piping / routing | Bounded (X3a) | Logical connections; equipment-owned port Interfaces and hollow nozzle stubs; target-port-scoped owner KeepOut exemptions; coincident endpoint mates; explicit orthogonal 3D routes; deterministic A* proposals; editable accepted routes; 90-degree elbows; bounded local rerouting; AP242 assembly, BOM, and pipe Cut List. No freeform, stress-, flow-, slope-, or plant-scale routing. See [guide](../firmament/piping.md). |
@@ -31,7 +32,7 @@
| Assemblies | Bounded | Typed Firmament assembly inspection plus explicitly identified legacy `.firmasm` compatibility |
| Platform qualification | Supported | Windows x64 bundle; NativeAOT Forge Host on `win-x64` |
| Linux/macOS release binaries | Not in Preview 3 | Framework logic tests do not constitute binary qualification |
-| Post-Preview-3 feature families | X0 exception | Circular Sweep and Standard Products Paperclip are the bounded X0 additions; other new geometry/PMI/FEA/Forge families remain frozen |
+| Post-Preview-3 feature families | X0 exception | Circular Sweep, WIRE-X0 Formed Wire, and Standard Products Paperclip are bounded X0 additions; other new geometry/PMI/FEA/Forge families remain frozen |
| General smooth/rail/topology-changing loft, helix, and freeform surface features | Not in Preview 3 | The experimental ruled SectionChain substrate does not qualify arbitrary smooth loft, guide rails, topology-changing correspondence, arbitrary dumb-solid editing, or surface networks. |
| Through profile removal | Bounded semantic operations | Use qualified `Hole`, `Slot`, or another documented opening feature; Pocket never means through-all |
| Arbitrary solid Boolean subtraction / hemispherical cavity | Not in Preview 3 | No public `Union`, `Subtract`, `Intersect`, CSG tree, Sphere-from-Block subtraction, or hemisphere special case |
diff --git a/docs/public/standard-library/README.md b/docs/public/standard-library/README.md
index 694fab83..532ef2fa 100644
--- a/docs/public/standard-library/README.md
+++ b/docs/public/standard-library/README.md
@@ -4,7 +4,7 @@ The Standard Library is a shipped, curated catalog of typed Firmament product fa
| Product family | Public Template ID | Main capabilities |
| --- | --- | --- |
-| Paperclip | `Standard.Products.Office.Paperclip` | Path, circular Sweep, material, deterministic AP242 |
+| Paperclip | `Standard.Products.Office.Paperclip` | WireForm Straight/Bend program, exact circular Sweep, stock/mass evidence, deterministic AP242 |
| Mounting Plate | `Standard.Products.Mechanical.MountingPlate` | prismatic stock, four counterbores, PMI |
| Bearing Block | `Standard.Products.Mechanical.BearingBlock` | base, Boss, bore, mounting holes, PMI |
| Machined Angle Bracket | `Standard.Products.Mechanical.MachinedAngleBracket` | prismatic L profile, mounting holes |
diff --git a/docs/release/WIRE-X0-FORMED-WIRE-FOUNDATION.md b/docs/release/WIRE-X0-FORMED-WIRE-FOUNDATION.md
new file mode 100644
index 00000000..f04ddf5c
--- /dev/null
+++ b/docs/release/WIRE-X0-FORMED-WIRE-FOUNDATION.md
@@ -0,0 +1,117 @@
+# WIRE-X0 — Formed Wire Foundation
+
+## Executive verdict
+
+**Accepted.** Aetheris can author a formed wire product as an ordered semantic `Straight`/`Bend` program, derive exact centerline geometry and ideal cut-stock length, and materialize deterministic analytic STEP through the existing circular Sweep kernel.
+
+## Architecture and audit
+
+```text
+WireForm stock + StartFrame + ordered operations
+ → deterministic WireState transitions
+ → centerline AIR (LineSegment / CircularArc with operation identity)
+ → circular Sweep BRep plan
+ → cylinders / tori / planar terminal caps
+ → STEP AP242 + reimport evidence
+```
+
+Direct reuse:
+
+- the Material DB resolver and density contracts;
+- kernel `Line3Curve`, `Circle3Curve`, cylinder, torus, and plane geometry;
+- BRep topology/binding validation, export preflight, AP242 export/import, and deterministic hashing;
+- the mature circular Sweep topology law: one analytic side face per centerline segment, shared section rings at tangent joins, and two terminal caps;
+- template specialization and Forge list/describe/invoke.
+
+Shared mathematics without shared semantics:
+
+- Concept Path/Sweep line/arc length and analytic realization;
+- Piping ordered route/frame ideas and circular route surfaces;
+- Sheet Metal's manufacturing-derived geometry, bend vocabulary, and stock-accounting design law.
+
+The runtime IRs remain specialized. Sheet Metal continues to own regions, neutral/flat patterns, bend allowance, relief, and fabrication evidence. Piping continues to own ports, connections, routing proposals, fittings, cut lists, equipment keep-outs, and assembly interfaces. WireForm is not forced through either domain.
+
+WireForm owns constant circular stock, the explicit start frame, authoritative forming-operation order, downstream state replay, centerline-radius semantics, operation/segment identity, ideal cut length/volume/mass, terminals, local and nonlocal wire clearance, and operation-level inspection. Direct Sweep remains the lower-level trajectory authoring facility.
+
+## Semantics
+
+`WireState` retains position, tangent, `Up`, derived `Right`, and accumulated length. Straight preserves the frame. Bend chooses the current local `Up` or `Right` as its plane normal and rotates the entire frame by the signed angle. Positive angles use the right-hand rule about the named local normal; negative angles reverse it. This admits transformed planar forms and bends in successive perpendicular planes without global-coordinate hacks or frame spin.
+
+X0 Bend `Radius` is the **centerline radius**. The minimum-radius policy is geometric-only: `Radius > Diameter / 2`; no unsupported material forming table is claimed. Angles are nonzero and bounded to ±180°. A bend no greater than 180° plus the minimum-radius rule prevents local tube self-overlap.
+
+Nonadjacent operations are compared in 3D using deterministic chord witnesses. Arc chord distances are reduced by an analytic sagitta error bound, producing a conservative clearance lower bound. Any lower bound below the wire diameter fails closed with `wireform-self-intersection:<opA>:<opB>`. Adjacent tangent joins are excluded. Intentional contact has no X0 semantics and is rejected.
+
+Changing one operation correctly changes every downstream state. Identical stock, start frame, and operations replay to byte-identical STEP.
+
+## Paperclip flagship
+
+The Standard Product template preserves `WireDiameter`, `OuterLegLength`, `InnerLegLength`, `OuterBendRadius`, `InnerBendRadius`, and `Material`. It derives `LowerReturnRadius = (OuterBendRadius + InnerBendRadius) / 2` and lowers to:
+
+```text
+Straight InnerRight 14 mm
+Bend InnerTop R3 180°
+Straight InnerLeft 14 mm
+Bend LowerReturn R4 180°
+Straight OuterRight 15 mm
+Bend OuterTop R5 180°
+Straight OuterLeft 15 mm
+```
+
+Default evidence:
+
+| Quantity | Result |
+|---|---:|
+| Diameter | 1 mm |
+| Straight length | 58 mm |
+| Bend arc length | 37.69911184307752 mm |
+| Total wire/cut-stock length | 95.69911184307752 mm |
+| Volume | 75.16190668032007 mm³ |
+| Mass (304 annealed database density) | 0.5937790627745286 g |
+| Envelope | 11 × 25 × 1 mm |
+| Surfaces | 4 cylinders, 3 tori, 2 planes |
+| Rational product surfaces / faceted fallback | 0 / 0 |
+| STEP SHA-256 | `c46578236cd1909984be9b5a9f3720464f7fd6f49adc1ad1e1bba8608327d3c2` |
+
+The recovered Concept Path reference and WireForm centerline are sampled bidirectionally at identical parameters. Qualified RMS, p95, maximum, endpoint deviation, and length difference are numeric-equivalent zero (each geometric deviation `< 1e-12 mm`; length equal at 12 decimal places). Envelope and diameter differences are zero at the same qualified precision. The 15%-longer and wider variants remain enclosed, exact, contact-free, deterministic, and free of rational/faceted fallback.
+
+## Additional flagships and stock accounting
+
+| Witness | Straight | Bend arc | Total | Volume | Mass | Analytic surfaces |
+|---|---:|---:|---:|---:|---:|---|
+| U-wire | 40 mm | 15.707963267948966 mm | 55.70796326794897 mm | 43.75293203725963 mm³ | 0.3456481630943511 g | 2 cylinder / 1 torus / 2 plane |
+| 3D bent wire | 45 mm | 15.707963267948966 mm | 60.70796326794897 mm | 47.679922854246875 mm³ | 0.37667139054855034 g | 3 cylinder / 2 torus / 2 plane |
+
+Both reimport as enclosed manifolds with zero other/rational surfaces and zero faceted fallback.
+
+## 3D state witness
+
+Rounded values below are millimetres and unit directions:
+
+| # | Input position / tangent / up | Operation | Output position / tangent / up |
+|---:|---|---|---|
+| 1 | `(0,0,0) / +X / +Z` | Straight Lead 20 | `(20,0,0) / +X / +Z` |
+| 2 | `(20,0,0) / +X / +Z` | Bend XYBend R5 +90°, `Plane: Up` | `(25,5,0) / +Y / +Z` |
+| 3 | `(25,5,0) / +Y / +Z` | Straight Middle 15 | `(25,20,0) / +Y / +Z` |
+| 4 | `(25,20,0) / +Y / +Z` | Bend YZBend R5 +90°, `Plane: Right` | `(25,25,5) / +Z / -Y` |
+| 5 | `(25,25,5) / +Z / -Y` | Straight Tail 10 | `(25,25,15) / +Z / -Y` |
+
+Structured build inspection retains the unrounded input/output position, tangent, `Up`, `Right`, accumulated length, stable operation ID, centerline segment family, and resulting sweep surface for every row.
+
+## Representation, CLI, and artifacts
+
+`inspect --json` exposes WireForm ID, stock/material, operation counts and ordered list, straight/bend/total length, start/end terminals, radius and frame policies, and state progression. `build --json` additionally exposes volume, mass, bounds, surface inventory, rational/faceted counts, manifold status, STEP reimport, and deterministic hash. Forge's Paperclip schema and invocation contract are preserved.
+
+Manual artifacts follow the generated-artifact policy under ignored `artifacts/local/`:
+
+- `wire-x0-paperclip.step`
+- `wire-x0-u-wire.step`
+- `wire-x0-3d-bent-wire.step`
+- corresponding general-CLI wireframe SVG previews
+
+## Qualification and limits
+
+Targeted tests cover parser/binder integration, ordered state replay, Straight, signed 90°/180°/general Bend, local `Up`/`Right` orientation, 3D frame transport, exact length/volume/mass, geometric minimum radius, fail-closed nonlocal and adjacent-away-from-join contact, operation identity, analytic lowering, STEP export/reimport, deterministic repeat export, corrected Paperclip reference equivalence, longer/wider variants, CLI inspect/validate, server demo, Forge, and direct Sweep regression. Final qualification passed a warning-free Release solution build, the full serial suite (3,215 tests; no failures or skips), all 122 canonical fixtures, the repository layout guard, Markdown/link tests within the suite, `git diff --check`, fresh CLI package creation, three STEP analyses, and general-CLI wireframe rendering. The empty `Aetheris.FrictionLab.Tests` assembly reports no discoverable tests and is not counted.
+
+Three independent fresh-agent reviews, restricted to public docs and canonical fixtures, selected the intended answers for prompts A–F: direct `WireForm` Straight/Bend authoring, Paperclip policy override, perpendicular local bend planes, compiler-derived stock length, typed tight-radius/contact failure, and analytic Paperclip STEP. Their documentation-friction findings were corrected in the public WireForm, Paperclip, and diagnostics guides.
+
+X0 intentionally defers closed WireForm authoring, coils/springs/helices, arbitrary or parametric curves, mathematical and physical knots, variable/non-circular section, branches, deliberate contact, springback, plastic forming, and process-specific forming allowances. `TotalWireLength` is ideal centerline cut length, not a springback-compensated manufacturing blank.
diff --git a/fixtures/Canonical/Integration/paperclip-maximizer.firmament b/fixtures/Canonical/Integration/paperclip-maximizer.firmament
index 07a000ad..a9d6234a 100644
--- a/fixtures/Canonical/Integration/paperclip-maximizer.firmament
+++ b/fixtures/Canonical/Integration/paperclip-maximizer.firmament
@@ -11,18 +11,18 @@ Model MaximumPaperclips {
Require PositiveWire => P.WireDiameter > 0mm
Require OuterOverInner => P.OuterBendRadius > P.InnerBendRadius
Require BendClearsWire => P.InnerBendRadius > P.WireDiameter
- Concept Path PaperclipPath {
- Start: Point2(8mm, 0mm)
- Heading: 90deg
- Line InnerRightUp { Length: P.InnerLegLength }
- Arc InnerTop { Radius: P.InnerBendRadius; Turn: 180deg }
- Line InnerLeftDown { Length: P.InnerLegLength }
- Arc LowerReturn { Radius: (P.OuterBendRadius + P.InnerBendRadius) / 2; Turn: 180deg }
- Line OuterRightUp { Length: P.OuterLegLength }
- Arc OuterTop { Radius: P.OuterBendRadius; Turn: 180deg }
- Line OuterLeftDown { Length: P.OuterLegLength }
+ WireForm Paperclip {
+ Diameter: P.WireDiameter
+ Material: P.Material
+ StartFrame { Origin: [8mm, 0mm, 0mm]; Tangent: [0, 1, 0]; Up: [0, 0, 1] }
+ Straight InnerRight { Length: P.InnerLegLength }
+ Bend InnerTop { Radius: P.InnerBendRadius; Angle: 180deg; Plane: Up }
+ Straight InnerLeft { Length: P.InnerLegLength }
+ Bend LowerReturn { Radius: (P.OuterBendRadius + P.InnerBendRadius) / 2; Angle: 180deg; Plane: Up }
+ Straight OuterRight { Length: P.OuterLegLength }
+ Bend OuterTop { Radius: P.OuterBendRadius; Angle: 180deg; Plane: Up }
+ Straight OuterLeft { Length: P.OuterLegLength }
}
- Sweep Paperclip { Path: PaperclipPath; Diameter: P.WireDiameter; Material: P.Material }
}
Struct Maximized = PaperclipTemplate < P: LongerPaperclip >
}
diff --git a/fixtures/Canonical/README.md b/fixtures/Canonical/README.md
index f37a4215..bcd99770 100644
--- a/fixtures/Canonical/README.md
+++ b/fixtures/Canonical/README.md
@@ -12,6 +12,7 @@ Everything in this directory is current authoring guidance. Examples progress fr
| add a rectangular boss | `Features/Boss/rectangular-boss.firmament` | first-class finite `Boss` |
| sweep a circular profile | `Features/Sweep/circular-planar-path-sweep.firmament` | bounded planar `Concept Path`, line/arc, constant circular `Sweep` |
| make wire geometry | `Features/Sweep/` | tangent open paths, analytic cylinders/tori, capped solid |
+| author formed wire or rod | `WireForm/` | stock, `StartFrame`, ordered `Straight`/`Bend`, 3D frame transport, derived cut length |
| add a boss and bore | `Features/Boss/circular-boss-through-hole.firmament` | circular `Boss`, through shaft `Hole` |
| machine a finite pocket | `Features/Pocket/rectangular-pocket.firmament` | finite depth and minimum floor |
| make a through or blind hole | `Features/Holes/through-hole.firmament`, `blind-hole.firmament` | shaft end conditions |
@@ -21,7 +22,7 @@ Everything in this directory is current authoring guidance. Examples progress fr
| repeat features from data | `Patterns/record-array-hole-pattern.firmament` | Record array, finite `Pattern` |
| add semantic PMI | `PMI/multiple-hole-dimensions-with-chamfer.firmament` | Datum, tolerances, `DatumRefs` |
| use a typed product Template | `Templates/generic-mounting-plate.firmament` | value parameters, `Require`, Concept Struct output |
-| build a Paperclip Template | `Templates/paperclip.firmament` | `Record`, `Static`, `with`, `Template<PaperclipPolicy>`, circular `Sweep` |
+| build a Paperclip Template | `Templates/paperclip.firmament` | `Record`, `Static`, `with`, `Template<PaperclipPolicy>`, semantic `WireForm` |
| use a CNC policy | `Templates/cnc-dfm-policy.firmament` | Record defaults, `with`, `Template<Policy>`, enforcement |
| make Sheet Metal | `SheetMetal/l-bracket-with-hole.firmament` | material, bend, planar hole, formed/flat output |
| define a molded plastic shell | `PlasticShell/plastic-shell-enclosure.firmament` | inherent wall policy, tooling direction, parting plane, gate, standoffs, ejectors, AutoRib judgment |
diff --git a/fixtures/Canonical/Templates/paperclip.firmament b/fixtures/Canonical/Templates/paperclip.firmament
index 20b12145..e63a006c 100644
--- a/fixtures/Canonical/Templates/paperclip.firmament
+++ b/fixtures/Canonical/Templates/paperclip.firmament
@@ -24,22 +24,17 @@ Model StandardProductsOfficePaperclip {
Require PositiveBendRadii => P.OuterBendRadius > 0mm && P.InnerBendRadius > 0mm
Require OuterBendExceedsInnerBend => P.OuterBendRadius > P.InnerBendRadius
Require InnerBendClearsWire => P.InnerBendRadius > P.WireDiameter
- Concept Path PaperclipPath {
- // The reference frame places the inner-right terminal at X=8 mm.
- Start: Point2(8mm, 0mm)
- Heading: 90deg
- Line InnerRightUp { Length: P.InnerLegLength }
- Arc InnerTop { Radius: P.InnerBendRadius; Turn: 180deg }
- Line InnerLeftDown { Length: P.InnerLegLength }
- Arc LowerReturn { Radius: (P.OuterBendRadius + P.InnerBendRadius) / 2; Turn: 180deg }
- Line OuterRightUp { Length: P.OuterLegLength }
- Arc OuterTop { Radius: P.OuterBendRadius; Turn: 180deg }
- Line OuterLeftDown { Length: P.OuterLegLength }
- }
- Sweep Paperclip {
- Path: PaperclipPath
+ WireForm Paperclip {
Diameter: P.WireDiameter
Material: P.Material
+ StartFrame { Origin: [8mm, 0mm, 0mm]; Tangent: [0, 1, 0]; Up: [0, 0, 1] }
+ Straight InnerRight { Length: P.InnerLegLength }
+ Bend InnerTop { Radius: P.InnerBendRadius; Angle: 180deg; Plane: Up }
+ Straight InnerLeft { Length: P.InnerLegLength }
+ Bend LowerReturn { Radius: (P.OuterBendRadius + P.InnerBendRadius) / 2; Angle: 180deg; Plane: Up }
+ Straight OuterRight { Length: P.OuterLegLength }
+ Bend OuterTop { Radius: P.OuterBendRadius; Angle: 180deg; Plane: Up }
+ Straight OuterLeft { Length: P.OuterLegLength }
}
}
Struct Paperclip = PaperclipTemplate < P: StandardPaperclip >
diff --git a/fixtures/Canonical/WireForm/paperclip.firmament b/fixtures/Canonical/WireForm/paperclip.firmament
new file mode 100644
index 00000000..2a9afbac
--- /dev/null
+++ b/fixtures/Canonical/WireForm/paperclip.firmament
@@ -0,0 +1,15 @@
+Model CanonicalWireFormPaperclip {
+ Units: mm
+ WireForm Paperclip {
+ Diameter: 1mm
+ Material: Standard.Materials.StainlessSteel.304_Annealed
+ StartFrame { Origin: [8mm, 0mm, 0mm]; Tangent: [0, 1, 0]; Up: [0, 0, 1] }
+ Straight InnerRight { Length: 14mm }
+ Bend InnerTop { Radius: 3mm; Angle: 180deg; Plane: Up }
+ Straight InnerLeft { Length: 14mm }
+ Bend LowerReturn { Radius: 4mm; Angle: 180deg; Plane: Up }
+ Straight OuterRight { Length: 15mm }
+ Bend OuterTop { Radius: 5mm; Angle: 180deg; Plane: Up }
+ Straight OuterLeft { Length: 15mm }
+ }
+}
diff --git a/fixtures/Canonical/WireForm/single-bend-180.firmament b/fixtures/Canonical/WireForm/single-bend-180.firmament
new file mode 100644
index 00000000..8b30446c
--- /dev/null
+++ b/fixtures/Canonical/WireForm/single-bend-180.firmament
@@ -0,0 +1,11 @@
+Model SingleBend180 {
+ Units: mm
+ WireForm Wire {
+ Diameter: 1mm
+ Material: Standard.Materials.StainlessSteel.304_Annealed
+ StartFrame { Origin: [0mm, 0mm, 0mm]; Tangent: [0, 1, 0]; Up: [0, 0, 1] }
+ Straight Lead { Length: 20mm }
+ Bend Return { Radius: 5mm; Angle: 180deg; Plane: Up }
+ Straight Tail { Length: 20mm }
+ }
+}
diff --git a/fixtures/Canonical/WireForm/single-bend-90.firmament b/fixtures/Canonical/WireForm/single-bend-90.firmament
new file mode 100644
index 00000000..dd63723f
--- /dev/null
+++ b/fixtures/Canonical/WireForm/single-bend-90.firmament
@@ -0,0 +1,11 @@
+Model SingleBend90 {
+ Units: mm
+ WireForm Wire {
+ Diameter: 1mm
+ Material: Standard.Materials.StainlessSteel.304_Annealed
+ StartFrame { Origin: [0mm, 0mm, 0mm]; Tangent: [1, 0, 0]; Up: [0, 0, 1] }
+ Straight Lead { Length: 20mm }
+ Bend Corner { Radius: 5mm; Angle: 90deg; Plane: Up }
+ Straight Tail { Length: 30mm }
+ }
+}
diff --git a/fixtures/Canonical/WireForm/straight-wire.firmament b/fixtures/Canonical/WireForm/straight-wire.firmament
new file mode 100644
index 00000000..e895cdd0
--- /dev/null
+++ b/fixtures/Canonical/WireForm/straight-wire.firmament
@@ -0,0 +1,9 @@
+Model StraightWire {
+ Units: mm
+ WireForm Wire {
+ Diameter: 1mm
+ Material: Standard.Materials.StainlessSteel.304_Annealed
+ StartFrame { Origin: [0mm, 0mm, 0mm]; Tangent: [1, 0, 0]; Up: [0, 0, 1] }
+ Straight Body { Length: 20mm }
+ }
+}
diff --git a/fixtures/Canonical/WireForm/three-dimensional-bends.firmament b/fixtures/Canonical/WireForm/three-dimensional-bends.firmament
new file mode 100644
index 00000000..d7ec2bac
--- /dev/null
+++ b/fixtures/Canonical/WireForm/three-dimensional-bends.firmament
@@ -0,0 +1,15 @@
+Model ThreeDimensionalBentWire {
+ Units: mm
+ WireForm BentWire3D {
+ Diameter: 1mm
+ Material: Standard.Materials.StainlessSteel.304_Annealed
+ StartFrame { Origin: [0mm, 0mm, 0mm]; Tangent: [1, 0, 0]; Up: [0, 0, 1] }
+ Straight Lead { Length: 20mm }
+ // Plane names the current local normal: Up makes this bend lie in XY.
+ Bend XYBend { Radius: 5mm; Angle: 90deg; Plane: Up }
+ Straight Middle { Length: 15mm }
+ // After frame transport, Right makes this bend perpendicular in YZ.
+ Bend YZBend { Radius: 5mm; Angle: 90deg; Plane: Right }
+ Straight Tail { Length: 10mm }
+ }
+}
diff --git a/fixtures/Canonical/WireForm/u-wire.firmament b/fixtures/Canonical/WireForm/u-wire.firmament
new file mode 100644
index 00000000..31bc38be
--- /dev/null
+++ b/fixtures/Canonical/WireForm/u-wire.firmament
@@ -0,0 +1,11 @@
+Model StandardUWire {
+ Units: mm
+ WireForm UWire {
+ Diameter: 1mm
+ Material: Standard.Materials.StainlessSteel.304_Annealed
+ StartFrame { Origin: [5mm, 0mm, 0mm]; Tangent: [0, 1, 0]; Up: [0, 0, 1] }
+ Straight RightLeg { Length: 20mm }
+ Bend Crown { Radius: 5mm; Angle: 180deg; Plane: Up }
+ Straight LeftLeg { Length: 20mm }
+ }
+}
diff --git a/fixtures/Canonical/coverage.json b/fixtures/Canonical/coverage.json
index 4852e4fb..0285e09d 100644
--- a/fixtures/Canonical/coverage.json
+++ b/fixtures/Canonical/coverage.json
@@ -12,6 +12,7 @@
"Profile": "Profiles/concept-path-line-arc-profile.firmament",
"ProfileDelta": "Profiles/profile-delta-recess-extrusion.firmament",
"Sweep": "Features/Sweep/circular-planar-path-sweep.firmament",
+ "WireForm": "WireForm/single-bend-90.firmament",
"Paperclip": "Templates/paperclip.firmament",
"Boss": "Features/Boss/rectangular-boss.firmament",
"Pocket": "Features/Pocket/rectangular-pocket.firmament",
diff --git a/fixtures/Canonical/qualification.json b/fixtures/Canonical/qualification.json
index e23b53ea..18d3b42a 100644
--- a/fixtures/Canonical/qualification.json
+++ b/fixtures/Canonical/qualification.json
@@ -19,6 +19,7 @@
{ "path": "SectionChain", "operation": "section-chain-build" },
{ "path": "Structural", "operation": "build-step" },
{ "path": "Piping", "operation": "build-step" },
+ { "path": "WireForm", "operation": "build-step" },
{ "path": "PlasticShell", "operation": "build-step" },
{ "path": "Basics", "operation": "build-step" },
{ "path": "Primitives", "operation": "build-step" },
diff --git a/fixtures/Invalid/WireForm/bend-angle-zero.firmament b/fixtures/Invalid/WireForm/bend-angle-zero.firmament
new file mode 100644
index 00000000..60024777
--- /dev/null
+++ b/fixtures/Invalid/WireForm/bend-angle-zero.firmament
@@ -0,0 +1 @@
+Model InvalidWire { Units: mm WireForm Wire { Diameter: 1mm; StartFrame { Origin: [0mm,0mm,0mm]; Tangent: [1,0,0]; Up: [0,0,1] } Bend Invalid { Radius: 5mm; Angle: 0deg; Plane: Up } } }
diff --git a/fixtures/Invalid/WireForm/bend-plane-invalid.firmament b/fixtures/Invalid/WireForm/bend-plane-invalid.firmament
new file mode 100644
index 00000000..a5e98033
--- /dev/null
+++ b/fixtures/Invalid/WireForm/bend-plane-invalid.firmament
@@ -0,0 +1 @@
+Model InvalidWire { Units: mm WireForm Wire { Diameter: 1mm; StartFrame { Origin: [0mm,0mm,0mm]; Tangent: [1,0,0]; Up: [0,0,1] } Bend Invalid { Radius: 5mm; Angle: 90deg; Plane: WorldXY } } }
diff --git a/fixtures/Invalid/WireForm/bend-radius-local-overlap.firmament b/fixtures/Invalid/WireForm/bend-radius-local-overlap.firmament
new file mode 100644
index 00000000..16bfcc9f
--- /dev/null
+++ b/fixtures/Invalid/WireForm/bend-radius-local-overlap.firmament
@@ -0,0 +1 @@
+Model InvalidWire { Units: mm WireForm Wire { Diameter: 1mm; StartFrame { Origin: [0mm,0mm,0mm]; Tangent: [1,0,0]; Up: [0,0,1] } Bend Invalid { Radius: 0.5mm; Angle: 90deg; Plane: Up } } }
diff --git a/fixtures/Invalid/WireForm/bend-radius-negative.firmament b/fixtures/Invalid/WireForm/bend-radius-negative.firmament
new file mode 100644
index 00000000..ddb9e24e
--- /dev/null
+++ b/fixtures/Invalid/WireForm/bend-radius-negative.firmament
@@ -0,0 +1 @@
+Model InvalidWire { Units: mm WireForm Wire { Diameter: 1mm; StartFrame { Origin: [0mm,0mm,0mm]; Tangent: [1,0,0]; Up: [0,0,1] } Bend Invalid { Radius: -1mm; Angle: 90deg; Plane: Up } } }
diff --git a/fixtures/Invalid/WireForm/nonlocal-contact.firmament b/fixtures/Invalid/WireForm/nonlocal-contact.firmament
new file mode 100644
index 00000000..501e12e2
--- /dev/null
+++ b/fixtures/Invalid/WireForm/nonlocal-contact.firmament
@@ -0,0 +1 @@
+Model InvalidWire { Units: mm WireForm Wire { Diameter: 1mm; StartFrame { Origin: [0mm,0mm,0mm]; Tangent: [1,0,0]; Up: [0,0,1] } Straight A { Length: 10mm } Bend B { Radius: 2mm; Angle: 180deg; Plane: Up } Straight C { Length: 10mm } Bend D { Radius: 2mm; Angle: 180deg; Plane: Up } Straight Contact { Length: 10mm } } }
diff --git a/fixtures/Invalid/WireForm/start-frame-ambiguous.firmament b/fixtures/Invalid/WireForm/start-frame-ambiguous.firmament
new file mode 100644
index 00000000..11e60e5e
--- /dev/null
+++ b/fixtures/Invalid/WireForm/start-frame-ambiguous.firmament
@@ -0,0 +1 @@
+Model InvalidWire { Units: mm WireForm Wire { Diameter: 1mm; StartFrame { Origin: [0mm,0mm,0mm]; Tangent: [1,0,0]; Up: [1,0,0] } Straight Body { Length: 10mm } } }
diff --git a/fixtures/Invalid/WireForm/straight-length-zero.firmament b/fixtures/Invalid/WireForm/straight-length-zero.firmament
new file mode 100644
index 00000000..0622951e
--- /dev/null
+++ b/fixtures/Invalid/WireForm/straight-length-zero.firmament
@@ -0,0 +1 @@
+Model InvalidWire { Units: mm WireForm Wire { Diameter: 1mm; StartFrame { Origin: [0mm,0mm,0mm]; Tangent: [1,0,0]; Up: [0,0,1] } Straight Invalid { Length: 0mm } } }
diff --git a/scripts/Test-CanonicalFixtures.ps1 b/scripts/Test-CanonicalFixtures.ps1
index 70eeb4f4..94a72325 100644
--- a/scripts/Test-CanonicalFixtures.ps1
+++ b/scripts/Test-CanonicalFixtures.ps1
@@ -28,7 +28,7 @@ $forbidden = @(
)
$failures = [Collections.Generic.List[string]]::new()
-$requiredFeatures = @('Box', 'Cylinder', 'Sphere', 'Cone', 'Torus', 'Profile', 'Sweep', 'Paperclip', 'Boss', 'Pocket', 'Hole', 'BlindHole', 'Counterbore', 'Countersink', 'Slot', 'Pattern', 'Chamfer', 'Fillet', 'Material', 'PMI', 'Template', 'SheetMetal', 'FEA', 'inlineSTEP', 'Assembly', 'Piping', 'ConstructionStateReplay', 'AddSectionChain', 'RemoveSectionChain', 'PostSectionChainHole')
+$requiredFeatures = @('Box', 'Cylinder', 'Sphere', 'Cone', 'Torus', 'Profile', 'Sweep', 'WireForm', 'Paperclip', 'Boss', 'Pocket', 'Hole', 'BlindHole', 'Counterbore', 'Countersink', 'Slot', 'Pattern', 'Chamfer', 'Fillet', 'Material', 'PMI', 'Template', 'SheetMetal', 'FEA', 'inlineSTEP', 'Assembly', 'Piping', 'ConstructionStateReplay', 'AddSectionChain', 'RemoveSectionChain', 'PostSectionChainHole')
foreach ($feature in $requiredFeatures) {
$entry = $coverage.features.$feature
if ([string]::IsNullOrWhiteSpace($entry)) { $failures.Add("coverage: missing $feature"); continue }