Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
IntelliDraft: Arc2 guide, Profile editing from Sketch, readable output
Claude9bd5847cf1d1
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentIntelliDraftTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentIntelliDraftTests.csindex 11fcc6a4..73d840c4 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentIntelliDraftTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentIntelliDraftTests.cs@@ -114,7 +114,7 @@ public class FirmamentIntelliDraftTestsAssert.Equal(left ? 2 * Math.Atan2(4, 3) : 2 * Math.PI - 2 * Math.Atan2(4, 3), arc.Curve.Sweep, 10);draft.Add(new("trace", draft.Id("layout"), "section", Trace: [new("chord", chord.From, chord.To, Connect: true), new("rim", arc.From, arc.To, Connect: true)]));// Picked clockwise on the left, so it is written counter-clockwise; the arc stays the same one.- Assert.Contains(left ? "rim from upper to lower as rim |> chord from lower to upper" : "chord from upper to lower as chord |> rim from lower to upper", draft.Source);+ Assert.Contains(left ? "rim from upper to lower as rim |> chord from lower to upper" : "chord from upper to lower as chord |> rim from lower to upper", Flat(draft.Source));draft.Add(new("extrude", draft.Id("section"), "body", Length: 6));var built = FirmamentBuildAndExport.CompileSource(draft.Source);Assert.True(built.IsSuccess, string.Join(";", built.Diagnostics.Select(d => d.Message)));@@ -140,6 +140,32 @@ public class FirmamentIntelliDraftTestsAssert.Equal(200, new FirmamentMeasurements(built.Value).Volume().ValueMm3!.Value, 6);}+ [Fact]+ public void Arc2IsTheCounterClockwiseArcBetweenNamedPointsAndTracesLikeAnyEdge()+ {+ var draft = new Draft(); draft.Add(new("layout", Name: "layout"));+ foreach (var (name, x, y) in new[] { ("c", 0d, 0d), ("east", 5d, 0d), ("west", -5d, 0d), ("north", 0d, 5d), ("off", 0d, 7d) })+ draft.Add(new("point", draft.Id("layout"), name, X: x, Y: y));+ draft.Add(new("arc", draft.Id("layout"), "dome", Reference: "c", From: "east", To: "west"));+ Assert.Contains("Arc2 dome { center: c; from: east; to: west }", draft.Source);+ var guide = Assert.Single(draft.View.Guides, g => g.Name == "dome");+ Assert.Equal("Arc", guide.Kind); Assert.Equal(Math.PI, guide.Sweep, 12);+ // A named point on the arc splits it into two clickable spans; the south half is not part of it.+ var spans = draft.View.Spans.Where(s => s.Reference == "dome").Select(s => (s.From, s.To)).ToArray();+ Assert.Equal([("east", "north"), ("north", "west")], spans);+ Assert.Throws<FirmamentLanguageEditException>(() => draft.Add(new("arc", draft.Id("layout"), "bad", Reference: "c", From: "east", To: "off")));+ draft.Add(new("line", draft.Id("layout"), "chord", From: "west", To: "east"));+ var picks = new[] { ("chord", "west", "east"), ("dome", "north", "west"), ("dome", "east", "north") }+ .Select(p => new FirmamentDraftTrace(p.Item1, p.Item2, p.Item3, Alias: p.Item1 + p.Item2, Connect: true)).ToArray();+ draft.Add(new("trace", draft.Id("layout"), "section", Trace: picks));+ draft.Add(new("extrude", draft.Id("section"), "body", Length: 2));+ var built = FirmamentBuildAndExport.CompileSource(draft.Source);+ Assert.True(built.IsSuccess, string.Join(";", built.Diagnostics.Select(d => d.Message)));+ var arcs = FirmamentSketchService.Project(draft.Source, "draft.firmament", "1").Loops[0].Curves.Where(c => c.Kind == "Arc").ToArray();+ Assert.Equal(Math.PI, arcs.Sum(a => Math.Abs(a.Sweep)), 10);+ }++ private static string Flat(string source) => System.Text.RegularExpressions.Regex.Replace(source, @"\s+", " ");private sealed class Draft{public string Source = "Model Part { units: mm }";@@ -253,7 +279,7 @@ public class FirmamentIntelliDraftTestsAssert.True(built.IsSuccess, string.Join(";", built.Diagnostics.Select(d => d.Message)));Assert.Equal(4416, new FirmamentMeasurements(built.Value).Volume().ValueMm3!.Value, 6);Assert.Contains("from: a", draft.Source);- Assert.Contains("bottom |> right |> ledge", draft.Source);+ Assert.Contains("bottom |> right |> ledge", Flat(draft.Source));Assert.All(FirmamentSketchService.Project(draft.Source, "draft.firmament", "1").Loops[0].Curves, c => Assert.NotNull(c.Provenance));GeometryMatches(draft.Source, "named-lines-l.firmament");var side = FirmamentBuildAndExport.CompileSource(draft.Source.Replace("on XY", "on XZ"));diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentIntelliDraft.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentIntelliDraft.csindex d02a3b6f..fc79c63c 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentIntelliDraft.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentIntelliDraft.cs@@ -45,7 +45,7 @@ public static class FirmamentIntelliDraftreturn new(f.Name.Text, source.Substring(f.Value.Span.Start, f.Value.Span.Length), unit is null ? null : value,unit, unit is not null && FirmamentSketchService.Literal(f.Value));}- var elements = declarations.Where(d => FirmamentSketchService.EditableShapes.Contains(d.Syntax.Type.Name.Text) || d.Syntax.Type.Name.Text is "Model" or "Struct" or "Static" or "Point2" or "Line2" or "Axis2" or "Path" or "Line" or "Arc" or "Close" or "Profile" or "Extrude")+ var elements = declarations.Where(d => FirmamentSketchService.EditableShapes.Contains(d.Syntax.Type.Name.Text) || d.Syntax.Type.Name.Text is "Model" or "Struct" or "Static" or "Point2" or "Line2" or "Arc2" or "Axis2" or "Path" or "Line" or "Arc" or "Close" or "Profile" or "Extrude").Select(d => new FirmamentDraftElement(d.Id, d.Syntax.Name?.Text ?? d.Id, d.Syntax.Type.Name.Text, d.ParentId,new(d.Syntax.Span.Start, d.Syntax.Span.Length), (d.Syntax.Body?.Statements.OfType<FieldSyntax>() ?? []).Select(Field).Concat(d.Syntax.Initializer is { } initial ? [new FirmamentDraftField("value", source.Substring(initial.Span.Start, initial.Span.Length),@@ -57,7 +57,7 @@ public static class FirmamentIntelliDraft.Select(d => new FirmamentOutlineDiagnostic("error", d.Code, d.Message,d.SourceSpan is { } s ? new(s.Start, s.Length) : null)));if (diagnostics.Count > 0) return new(elements, [], [], diagnostics, "Unresolved");- var duplicate = elements.Where(e => FirmamentSketchService.EditableShapes.Contains(e.Kind) || e.Kind is "Point2" or "Line2" or "Axis2" or "Path")+ var duplicate = elements.Where(e => FirmamentSketchService.EditableShapes.Contains(e.Kind) || e.Kind is "Point2" or "Line2" or "Arc2" or "Axis2" or "Path").GroupBy(e => e.Name).FirstOrDefault(g => g.Count() > 1);if (duplicate is not null)return new(elements, [], [], [new("error", "draft-guide-ambiguous", $"Construction preview requires an unambiguous guide name: '{duplicate.Key}'.", duplicate.First().Span)], "Unresolved");@@ -84,7 +84,7 @@ public static class FirmamentIntelliDraft{// Rect2 sides, and named Line2 and Circle2 guides, are clickable spans between named points.var owner = elements.FirstOrDefault(e => s.Guide.StartsWith(e.Name + ".", StringComparison.Ordinal) && e.Kind == "Rect2"- || s.Guide == e.Name && e.Kind is "Line2" or "Circle2");+ || s.Guide == e.Name && e.Kind is "Line2" or "Arc2" or "Circle2");var id = s.Guide + ":" + s.From + ":" + s.To;var parentCurve = curves.Single(c => c.Name == s.Guide);return new FirmamentDraftSpan(id, owner?.Id ?? "", s.Guide, s.From, s.To,@@ -212,7 +212,8 @@ public static class FirmamentIntelliDraftbreak;case "layout":if (request.Plane is not ("XY" or "XZ" or "YZ")) throw Refuse("draft-plane-required", "Choose XY, XZ or YZ.");- Insert(model.Id, $"Concept Struct {Name()} on {request.Plane} {{ }}");+ // An open, multi-line body: construction added later goes one declaration per line.+ Insert(model.Id, $"Concept Struct {Name()} on {request.Plane} {{\n}}");break;case "point":Insert(Owner("Struct").Id, $"Point2 {Name()} {{ position: [{Mm(request.X)}, {Mm(request.Y)}] }}");@@ -222,6 +223,9 @@ public static class FirmamentIntelliDraftthrow Refuse("draft-axis-direction", "Draw the axis with two different points.");Insert(Owner("Struct").Id, $"Axis2 {Name()} {{ origin: [{Mm(request.X)}, {Mm(request.Y)}]; direction: [{Number(request.DirectionX)}, {Number(request.DirectionY)}] }}");break;+ case "arc":+ Insert(Owner("Struct").Id, $"Arc2 {Name()} {{ center: {Point(request.Reference)}; from: {Point(request.From)}; to: {Point(request.To)} }}");+ break;case "line":Insert(Owner("Struct").Id, $"Line2 {Name()} {{ from: {Point(request.From)}; to: {Point(request.To)} }}");break;@@ -299,7 +303,10 @@ public static class FirmamentIntelliDraftif (entry.Alias is not null) text += " as " + FirmamentLanguageEditService.RequireIdentifier(entry.Alias, "edge alias");return (entry.Reverse ? "Reverse " : "") + text; // prefix form, as in Loop Inner { Reverse a.Bottom |> … }}- Profile($"Profile {name} using {owner.Name} {{ Loop Outer {{ {string.Join(" |> ", entries.Select(Entry))}{(entries.Count == 1 && entries[0].WholeLoop ? "" : " |> Close")} }} }}");+ var stages = entries.Select(Entry).ToList();+ if (entries is [{ WholeLoop: true }]) Profile($"Profile {name} using {owner.Name} {{ Loop Outer {{ {stages[0]} }} }}");+ // One traced span per line, so a reader can follow the outline.+ else Profile($"Profile {name} using {owner.Name} {{\n Loop Outer {{\n {string.Join("\n |> ", stages.Append("Close"))}\n }}\n}}");}break;case "extrude":diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentSourceSpelling.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentSourceSpelling.csindex 7822165d..8b5ce105 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentSourceSpelling.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentSourceSpelling.cs@@ -269,6 +269,7 @@ public static class FirmamentSourceSpellingAdd("Curve3", "From On Parameter Domain Representation MaxDeviation Closed Periodic");Add("CubicBezier2", "From Control1 Control2 To");Add("Line2", "From To");+ Add("Arc2", "Center From To");Add("Profile", "From");Add("Segment", "Trace From To Sweep");Add("Replace", "On Range Through Derivatives Join StartTangent EndTangent Interpolation SpanNames");diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2MechanicalBinding.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2MechanicalBinding.csindex 83d77ed8..9a831c0a 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2MechanicalBinding.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2MechanicalBinding.cs@@ -604,7 +604,7 @@ public static partial class FirmamentV2Parserdiagnostics.AddRange(publications.Select(d => d.Code + ": " + d.Message));break;case "Box" or "Cylinder" or "Cone" or "Sphere" or "Ellipsoid" or "Polyhedron" or "Torus" or "RoundedBox" or "Frustum" or "StandardPart" or "ExactCoaxialPart":- case "Plane" or "Axis" or "Axis2" or "Point2" or "Line2" or "CubicBezier2" or "Rect2" or "Square2" or "Triangle2" or "Polygon2" or "RegularPolygon2" or "Circle2" or "Ellipse2" or "Ellipse2Guide" or "Slot2" or "RoundedRect2" or "SmoothRoundedRect2" or "Path":+ case "Plane" or "Axis" or "Axis2" or "Point2" or "Line2" or "Arc2" or "CubicBezier2" or "Rect2" or "Square2" or "Triangle2" or "Polygon2" or "RegularPolygon2" or "Circle2" or "Ellipse2" or "Ellipse2Guide" or "Slot2" or "RoundedRect2" or "SmoothRoundedRect2" or "Path":case "Plateau" or "Concept" or "Struct" or "Profile" or "Span" or "Compose" or "Boss" or "Pocket" or "AddOffset" or "RemoveOffset" or "EdgeFinish":case "Enum" or "Record" or "Template" or "template" or "Feature" or "Pattern" or "ProfileDelta" or "Selection" or "InlineStep" or "Recognize" or "Replace" or "Remove" or "Pmi" or "Match" or "Require" or "Assert" or "Thread":break;diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.csindex eef4f745..2e601ebd 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs@@ -297,7 +297,7 @@ public static class ProfileAuthoringParserinternal static ConstructionPlane? ResolveNamedConstructionPlane(string source, string frame, List<string> diagnostics)=> ResolveConstructionPlane(source, frame, diagnostics);- internal static bool OwnsConstructionGuide(string type) => type is "Point2" or "Rect2" or "Line2" or "CubicBezier2" or "Circle2" or "Ellipse2Guide";+ internal static bool OwnsConstructionGuide(string type) => type is "Point2" or "Rect2" or "Line2" or "Arc2" or "CubicBezier2" or "Circle2" or "Ellipse2Guide";internal static bool OwnsDeclaration(DeclarationSyntax declaration) => OwnsConstructionGuide(declaration.Type.Name.Text)|| ClosedBoundary2Authoring.IsBoundaryType(declaration.Type.Name.Text)|| declaration.Type.Name.Text is "Profile" or "Path" or "Span" or "Curve2"@@ -364,6 +364,23 @@ public static class ProfileAuthoringParser}fields.Complete();}+ // Arc2: the counter-clockwise arc around a named centre from one named point to another on the same circle.+ foreach (var d in declarations.Where(d => d.Type.Name.Text == "Arc2"))+ {+ var fields = new FirmamentSyntaxFields(d, diagnostics,bind:bind); var name = d.Name!.Text;+ var c = fields.Word("Center"); var a = fields.Word("From"); var b = fields.Word("To");+ fields.Complete();+ if (c is null || a is null || b is null || !points.TryGetValue(c, out var center) || !points.TryGetValue(a, out var from) || !points.TryGetValue(b, out var to))+ { diagnostics.Add($"profile-layout-unresolved-arc:{name}"); continue; }+ var radius = Distance(center, from);+ if (radius <= Tolerance || Distance(from, to) <= Tolerance) { diagnostics.Add($"profile-layout-arc-degenerate:{name}"); continue; }+ if (!OnCircle(to, center, radius)) { diagnostics.Add($"profile-layout-arc-radius-mismatch:{name}:{a}:{b}"); continue; }+ var start = Math.Atan2(from.Y - center.Y, from.X - center.X);+ var sweep = Math.Atan2(to.Y - center.Y, to.X - center.X) - start;+ while (sweep <= 0) sweep += 2 * Math.PI;+ while (sweep > 2 * Math.PI) sweep -= 2 * Math.PI;+ guides[name] = new LineArcCircularArc2D(center, radius, start, sweep);+ }foreach (var guide in ClosedBoundary2Authoring.SmoothGuides(source, diagnostics)) guides[guide.Key] = guide.Value;if (applySpans) ApplyGeometricSpans(source, points, guides, diagnostics, addGuides: true);}@@ -1125,6 +1142,31 @@ public static class ProfileAuthoringParservar result = new List<(string, string, string, LineArcProfileCurve2D)>();foreach (var (name, geometry) in guides){+ if (geometry is LineArcCircularArc2D arc)+ {+ // Sub-arcs between the named points along an arc, in its own direction.+ var direction = Math.Sign(arc.SweepAngleRadians); var extent = Math.Abs(arc.SweepAngleRadians);+ double Progress((double X, double Y) p)+ {+ var delta = direction * (Math.Atan2(p.Y - arc.Center.Y, p.X - arc.Center.X) - arc.StartAngleRadians);+ while (delta < -1e-9) delta += 2 * Math.PI;+ while (delta >= 2 * Math.PI - 1e-9) delta -= 2 * Math.PI;+ return Math.Abs(delta) < 1e-9 ? 0 : delta;+ }+ var stops = new List<(string Name, double At, (double X, double Y) P)>();+ foreach (var point in points.Where(p => OnCircle(p.Value, arc.Center, arc.Radius)).OrderBy(p => p.Key, StringComparer.Ordinal))+ {+ var at = Progress(point.Value);+ if (Distance(point.Value, End(arc)) <= 1e-7) at = extent;+ if (at <= extent + 1e-7 && !stops.Any(s => Distance(s.P, point.Value) <= Tolerance)) stops.Add((point.Key, at, point.Value));+ }+ var along = stops.OrderBy(s => s.At).ToArray();+ for (var i = 0; i + 1 < along.Length; i++)+ if (along[i + 1].At - along[i].At > 1e-9)+ result.Add((name, along[i].Name, along[i + 1].Name, new LineArcCircularArc2D(arc.Center, arc.Radius,+ Math.Atan2(along[i].P.Y - arc.Center.Y, along[i].P.X - arc.Center.X), direction * (along[i + 1].At - along[i].At))));+ continue;+ }if (geometry is LineArcFullCircle2D circle){// Counter-clockwise arcs between consecutive named points on the circle.@@ -1164,7 +1206,7 @@ public static class ProfileAuthoringParserprivate static string MaskRecognizedProfileDeclarations(string body){- var declarationPattern = @"\b(?:(?:Concept\s+)?(?:Point2|Line2|Rect2|Square2|Circle2|Ellipse2|Ellipse2Guide|Slot2|RoundedRect2|SmoothRoundedRect2|Path)|(?:Triangle2|Polygon2|RegularPolygon2)\s*<[^>]+>)\s+[A-Za-z_]\w*\s*\{";+ var declarationPattern = @"\b(?:(?:Concept\s+)?(?:Point2|Line2|Arc2|Rect2|Square2|Circle2|Ellipse2|Ellipse2Guide|Slot2|RoundedRect2|SmoothRoundedRect2|Path)|(?:Triangle2|Polygon2|RegularPolygon2)\s*<[^>]+>)\s+[A-Za-z_]\w*\s*\{";var blocks = FindBlocks(body, declarationPattern).OrderByDescending(block => block.Match.Index).ToArray();var characters = body.ToCharArray();foreach (var block in blocks)diff --git a/Aetheris.Web.Runtime/Program.cs b/Aetheris.Web.Runtime/Program.csindex 0840420f..21642896 100644--- a/Aetheris.Web.Runtime/Program.cs+++ b/Aetheris.Web.Runtime/Program.cs@@ -623,9 +623,15 @@ public static partial class Program.Concat((build.Value.Features ?? []).Select(feature => new WebTreeNode(feature.FeatureId, feature.Kind, feature.Name, entityId, [], true, featureSources[feature.FeatureId], feature.Diameter))).ToArray();var projectedBodySource = projections.FirstOrDefault(item => item.SemanticId == entityId)?.ConstructSpan is { } bodySpan? SourceRefAt(_sourceName, effective, bodySpan.Start, bodySpan.Length) : null;- var body = new WebTreeNode(entityId, build.Value.ExportedBodyCategory, Name, Id, featureNodes.Select(item => item.Id).ToArray(), true,+ // The tree shows the names the source declares (`Model Bracket`, `Extrude body`); the file+ // stem is only a fallback, so a part has one name in the editor, the tree and the viewport.+ var modelName = Regex.Match(effective, @"\bModel\s+([A-Za-z_]\w*)\s*\{") is { Success: true } model ? model.Groups[1].Value : Name;+ var bodyName = projections.FirstOrDefault(item => item.SemanticId == entityId)?.ConstructSpan is { } named+ && Regex.Match(effective.Substring(named.Start, Math.Min(named.Length, effective.Length - named.Start)), @"^\s*(?:[A-Z]\w*\s+)*?[A-Z]\w*(?:<[^>]*>)?\s+([A-Za-z_]\w*)\s*[{;]") is { Success: true } declared+ ? declared.Groups[1].Value : modelName;+ var body = new WebTreeNode(entityId, build.Value.ExportedBodyCategory, bodyName, Id, featureNodes.Select(item => item.Id).ToArray(), true,boxSource ?? projectedBodySource ?? SourceRef(_sourceName, 0, effective.Length), SemanticConstruct: semanticConstruct);- var root = new WebTreeNode(Id, "Model", Name, null, [body.Id], true, SourceRef(_sourceName, 0, effective.Length));+ var root = new WebTreeNode(Id, "Model", modelName, null, [body.Id], true, SourceRef(_sourceName, 0, effective.Length));var tree = new { rootId = root.Id, nodes = new[] { root, body }.Concat(featureNodes).ToArray() };var expectedPmi = Aetheris.Kernel.Firmament.Drawing.FirmamentDrawingCompiler.AuthoredPmiNames(build.Value);return WebBuildResult.Passed(step, tree, mesh, [Id, entityId, .. featureNodes.Select(item => item.Id)], compileMs, meshMs)diff --git a/Aetheris.Web.Runtime/sdk/src/index.d.ts b/Aetheris.Web.Runtime/sdk/src/index.d.tsindex 1d058010..75ee5bb2 100644--- a/Aetheris.Web.Runtime/sdk/src/index.d.ts+++ b/Aetheris.Web.Runtime/sdk/src/index.d.ts@@ -178,7 +178,7 @@ export interface MeasurementResult {export interface DraftElement { id: string; name: string; kind: string; parent: string | null; span: { start: number; length: number }; fields: readonly { name: string; value: string; number: number | null; unit: string | null; editable: boolean }[] }export interface DraftTrace { reference: string; from?: string; to?: string; alias?: string; reverse?: boolean; connect?: boolean; wholeLoop?: boolean }-export interface DraftOperation { action: 'layout' | 'point' | 'line' | 'circle' | 'path' | 'step' | 'trace' | 'extrude' | 'movePoint' | 'dimension' | 'rectangle' | 'shape' | 'parameter' | 'axis'; width?: number; height?: number; reference?: string; insetX?: number; insetY?: number; sharedInset?: boolean; targetProfile?: string; field?: string; value?: number; parent?: string; name?: string; kind?: string; plane?: string; x?: number; y?: number; length?: number; radius?: number; turn?: number; from?: string; to?: string; trace?: readonly DraftTrace[]; /** Axis2 direction; any non-zero vector, written unitless as drawn. */ directionX?: number; directionY?: number }+export interface DraftOperation { action: 'layout' | 'point' | 'line' | 'circle' | 'path' | 'step' | 'trace' | 'extrude' | 'movePoint' | 'dimension' | 'rectangle' | 'shape' | 'parameter' | 'axis' | 'arc'; width?: number; height?: number; reference?: string; insetX?: number; insetY?: number; sharedInset?: boolean; targetProfile?: string; field?: string; value?: number; parent?: string; name?: string; kind?: string; plane?: string; x?: number; y?: number; length?: number; radius?: number; turn?: number; from?: string; to?: string; trace?: readonly DraftTrace[]; /** Axis2 direction; any non-zero vector, written unitless as drawn. */ directionX?: number; directionY?: number }export interface DraftSpan { id: string; owner: string; reference: string; from: string; to: string; curve: SketchCurve }/** An Axis2 reference direction in a layout. Unbounded and never traced. */export interface DraftAxis { id: string; name: string; owner: string; origin: readonly [number, number]; direction: readonly [number, number] }diff --git a/docs/development/reports/2026-10/intellidraft-arc2-sketch-merge.md b/docs/development/reports/2026-10/intellidraft-arc2-sketch-merge.mdnew file mode 100644index 00000000..f045d82b--- /dev/null+++ b/docs/development/reports/2026-10/intellidraft-arc2-sketch-merge.md@@ -0,0 +1,30 @@+# IntelliDraft: Arc2, Sketch merged in, readable output++## What changed++- **Arc2** is a construction guide: `Arc2 a { center: c; from: p; to: q }`, the+ counter-clockwise arc from `p` to `q` around `c`. `q` off the circle through `p`+ is rejected (`profile-layout-arc-radius-mismatch`). Named points on an arc split+ it into construction spans, so arcs trace by clicking like lines. IntelliDraft's+ `arc` operation writes it; Helios offers it under the circle tool's type menu.+- **Profile editing from the retired Sketch workspace** now goes through IntelliDraft:+ the sketch projection's Profile shapes (code-authored parts) are listed and edited+ with `dimensions` requests, a Profile menu picks among several, and the circular+ opening is available as before. Helios no longer ships the Sketch workspace.+- **Readable source**: new layouts are written with an open multi-line body, so later+ construction lands one declaration per line, and click-traced Profiles put one span+ per line. The language edit service is unchanged.+- **Web runtime tree** uses declared names (`Model Bracket`, `Extrude body`) instead of+ the file stem; the file stem remains the fallback.++## Evidence++- `FirmamentIntelliDraftTests`: Arc2 projection, spans, rejection, trace and build;+ existing tests updated to compare traces whitespace-insensitively.+- `aetheris validate` accepts a hand-written Arc2 + Line2 D profile.+- Helios: IntelliDraft, graph-authoring, editor-presentation and author e2e pass.++## Verdict++Success. Arc2 replaces the Circle2-plus-endpoints arc tool tried earlier; that guide+form still works for code that uses it.diff --git a/docs/public/firmament/sketcher.md b/docs/public/firmament/sketcher.mdindex 6c301e44..9a9c5e39 100644--- a/docs/public/firmament/sketcher.md+++ b/docs/public/firmament/sketcher.md@@ -1,6 +1,6 @@# IntelliDraft and Profile dimensions in Helios-The sketch workspace edits ordinary Firmament source. There is no separate saved+IntelliDraft edits ordinary Firmament source. There is no separate savedsketch model, browser constraint solver or mesh-to-profile conversion.## Construction, trace, part@@ -13,7 +13,7 @@ dimensions remain authoritative when Trace selects boundary spans from its namededges and corners.The toolbar draws lines, arcs, rectangles, circles, ellipses, slots and rounded-rectangles. Keys: V select, L line, A arc, R rectangle, C circle, E ellipse,+rectangles; the line, circle and rounded tools have a type menu. Keys: V select, L line, A arc, R rectangle, C circle, E ellipse,S slot, U rounded, T trace, F fit, Delete removes the selection, Ctrl+Z / Ctrl+Yundo and redo, Escape steps back. A tool stays active after drawing and proposesthe next free name (`rect1`, `rect2`, …). Points snap to a grid that follows the@@ -24,10 +24,10 @@ zoom; Alt snaps to 0.1 mm.written as `Point2 <line>Start` / `<line>End`. The line menu also declares an`Axis2 { origin; direction }`: an unbounded reference direction that is shownon the canvas but never traced.-- **Arc** drags from the centre to the start, then clicks the end (15° steps;- Alt is free). It writes a `Circle2` guide centred on a named point plus the- named points on it. The arc itself is chosen when tracing: each pair of- neighbouring points on a circle is a counter-clockwise span.+- **Arc** (in the circle menu, key A) drags from the centre to the start, then+ clicks the end (15° steps; Alt is free). It writes+ `Arc2 { center; from; to }`: the counter-clockwise arc between named points.+ Named points on an arc split it into spans for tracing.- The rounded menu also draws `SmoothRoundedRect2` (continuous-curvaturecorners) with its `cornerExtent`.@@ -86,47 +86,35 @@ are not replaced with coordinates. Canvas point placement rounds to a 0.1 mmgrid; explicit typed values can use finer precision. Paths created by the UI useXY; the layout frame banner identifies local axes and the world-space normal.-## Closed-shape dimension workspace+## Editing an existing part's Profile-Open **Command palette → New sketch part** to start a rectangular profile and a-6 mm extrusion. Circle, slot and rounded-rectangle sketch starters are also in the-command palette. For an existing part, use **Sketch** above the viewport, or-double-click its Profile/shape node in the graph. Choose the Profile when a guide-is shared by more than one Profile.+**IntelliDraft** also opens on parts written in code. It projects the document's+Profiles; when there is more than one, a **Profile** menu chooses which. Double-+clicking a Profile or shape node in the graph opens IntelliDraft on it. Shapes the+Profile consumes outside any layout are listed with the layout's shapes and are+edited the same way, on the canvas or in the sidebar. A Profile on another plane+shows that plane under the workflow steps. **Command palette → New IntelliDraft+part** starts an empty draft.-## Dimensions and navigation--The workspace uses the Profile's local coordinates. Its header identifies the-resolved plane, world origin and normal; the canvas shows local +X and +Y.-Scroll to zoom, middle-drag or Alt-drag to pan, and use **Fit** to see the outline.-Select a named shape in the inspector or click its center marker.--Type a dimension in the inspector and press Enter or leave the field. Drag a-gold dimension label for an approximate adjustment; type a number for the final-size. Keyboard arrows on a dimension label change it by one displayed unit.-Lengths display in millimetres and rotations in degrees. Slot **overall length**-includes both semicircular ends.+Dimensions follow the source:- A literal is a directly editable driving dimension.-- A directly referenced literal `Static` is edited at its declaration. The UI+- A directly referenced literal `Static` is edited at its declaration. The sidebarnames that shared parameter, so other consumers changing is explicit.-- An expression is read-only here. **Edit source** navigates to it; edit its- driving inputs in Parameters or Source. Dragging never replaces a formula or- typed tolerance with a literal.--Drag previews resolve the Profile without constructing the solid. Releasing a-drag or entering a dimension prepares one source transaction and invokes the-normal engineering build. An invalid profile edit is refused without changing-source. A later solid-build failure retains the previous geometry and the-existing revertible draft. Source edits retain Monaco undo history.+- An expression is read-only and dashed on the canvas. **Edit source** closes the+ draft and shows it in the source editor; edit its driving inputs in Parameters+ or Source. Dragging never replaces a formula or typed tolerance with a literal.-`ProfileResolvedNotBuilt` describes the preview's validation level. It does not-mean an extrusion, revolve, loft or downstream feature has passed its build.+Every edit is one source transaction checked by the compiler. An invalid edit is+refused without changing source; **Build and use part** runs the normal+engineering build before the document is replaced. Lengths display in+millimetres and rotations in degrees. Slot **overall length** includes both+semicircular ends.## Mounting openings that follow their dimensionsFor a Profile whose explicit outer loop traces an unrotated Model-level Rect2,-**Circular profile opening** offers its center, corners and edge midpoints.+**Add circular opening** (in the IntelliDraft sidebar) offers its center, corners and edge midpoints.Choose the rectangle, anchor, inward X/Y insets and opening diameter, then**Add opening**. Inapplicable insets are disabled. For a four-hole plate, add oneopening at each corner with the same insets.@@ -183,7 +171,7 @@ explicitly rejected while those support adapters still assume world XY.## Current boundary-The **Sketch** dimension workspace edits authored Rect2, Circle2, Ellipse2, Slot2, RoundedRect2 and SmoothRoundedRect2 fields+IntelliDraft edits authored Rect2, Circle2, Ellipse2, Slot2, RoundedRect2 and SmoothRoundedRect2 fieldsand displays the resolved line/arc/ellipse/cubic curves of other Profiles.Generated Template/Feature bodies do not become writable source through theirexpanded geometry. Profiles must have an unambiguous authored name in the@@ -192,7 +180,7 @@ document; edits do not reach into included files.IntelliDraft currently authors one unambiguous Model, retained closed shapes,named Point2/Line2/Circle2 guides, Axis2 references, line/arc Paths, one outertrace and a positive extrusion. Strokes snap to named points, not to arbitrary-intersections; an arc's circle stays a full construction circle. The optional Advanced related-rectangle preset shares a top-right corner with+intersections. The optional Advanced related-rectangle preset shares a top-right corner withan unrotated rectangle in the same Concept Struct. Its wall/inset values and therectangle dimensions remain compile-time source expressions. Trace selectionuses named landmarks on the compiler's bounded guides; it does not inventdiff --git a/docs/public/reference/language/profiles.md b/docs/public/reference/language/profiles.mdindex ac13eeab..4e06acc5 100644--- a/docs/public/reference/language/profiles.md+++ b/docs/public/reference/language/profiles.md@@ -117,6 +117,7 @@ low-level control.| --- | --- || `Point2` | `position` || `Line2` | named `from` and `to` points |+| `Arc2` | named `center`, `from` and `to` points; the counter-clockwise arc from `from` to `to`. `to` must lie on the circle through `from`; it is rejected otherwise || `CubicBezier2` | named endpoints plus `control1`, `control2` || `Rect2` | `center`, `size` (two full lengths) || `Square2` | `center`, `size` (one length) |@@ -129,7 +130,8 @@ low-level control.| `Polygon2<Rhombus \| Parallelogram \| Trapezoid \| Explicit>` | variant-specific dimensions || `RegularPolygon2<N>` | regular polygon with a bounded vertex count |-`Point2`, `Line2` and `CubicBezier2` are open guides; the rest are closed.+`Point2`, `Line2`, `Arc2` and `CubicBezier2` are open guides; the rest are closed.+Named points on an `Arc2` split it into spans, as on a `Line2`.Parametric shapes accept `rotation` in degrees.`Polygon2<Explicit>` takes its corners inline,