Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Add Aetheris CLI baseline build and analyze commands
Yuechen Li7e10551764cd
diff --git a/Aetheris.CLI.Tests/Aetheris.CLI.Tests.csproj b/Aetheris.CLI.Tests/Aetheris.CLI.Tests.csprojnew file mode 100644index 00000000..27acd7cf--- /dev/null+++ b/Aetheris.CLI.Tests/Aetheris.CLI.Tests.csproj@@ -0,0 +1,23 @@+<Project Sdk="Microsoft.NET.Sdk">+ <PropertyGroup>+ <TargetFramework>net8.0</TargetFramework>+ <ImplicitUsings>enable</ImplicitUsings>+ <Nullable>enable</Nullable>+ <IsPackable>false</IsPackable>+ </PropertyGroup>++ <ItemGroup>+ <PackageReference Include="coverlet.collector" Version="6.0.0" />+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />+ <PackageReference Include="xunit" Version="2.9.2" />+ <PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />+ </ItemGroup>++ <ItemGroup>+ <Using Include="Xunit" />+ </ItemGroup>++ <ItemGroup>+ <ProjectReference Include="..\Aetheris.CLI\Aetheris.CLI.csproj" />+ </ItemGroup>+</Project>diff --git a/Aetheris.CLI.Tests/CliBaselineTests.cs b/Aetheris.CLI.Tests/CliBaselineTests.csnew file mode 100644index 00000000..c2d2cfbb--- /dev/null+++ b/Aetheris.CLI.Tests/CliBaselineTests.cs@@ -0,0 +1,127 @@+using System.Text.Json;++namespace Aetheris.CLI.Tests;++public sealed class CliBaselineTests+{+ private static readonly string RepoRoot = FindRepoRoot();++ [Fact]+ public void Build_Command_Builds_Firmament_To_Step()+ {+ var outputPath = Path.Combine(RepoRoot, "testdata", "firmament", "exports", "cli-build-probe.step");+ if (File.Exists(outputPath))+ {+ File.Delete(outputPath);+ }++ var stdout = new StringWriter();+ var stderr = new StringWriter();+ var exitCode = Aetheris.CLI.CliRunner.Run(+ ["build", Path.Combine(RepoRoot, "testdata/firmament/examples/box_basic.firmament"), "--out", outputPath],+ stdout,+ stderr);++ Assert.Equal(0, exitCode);+ Assert.True(File.Exists(outputPath), stderr.ToString());+ Assert.Contains("Build succeeded", stdout.ToString());++ File.Delete(outputPath);+ }++ [Fact]+ public void Analyze_Command_Reports_Summary_Facts()+ {+ var stdout = new StringWriter();+ var stderr = new StringWriter();++ var exitCode = Aetheris.CLI.CliRunner.Run(+ ["analyze", Path.Combine(RepoRoot, "testdata/firmament/exports/box_basic.step"), "--json"],+ stdout,+ stderr);++ Assert.Equal(0, exitCode);+ using var doc = JsonDocument.Parse(stdout.ToString());+ var root = doc.RootElement;+ var summary = root.GetProperty("summary");+ Assert.Equal(1, summary.GetProperty("bodyCount").GetInt32());+ Assert.Equal(1, summary.GetProperty("shellCount").GetInt32());+ Assert.Equal(6, summary.GetProperty("faceCount").GetInt32());+ Assert.Equal(12, summary.GetProperty("edgeCount").GetInt32());+ Assert.Equal(8, summary.GetProperty("vertexCount").GetInt32());+ Assert.Equal("enclosed-manifold", summary.GetProperty("structuralAssessment").GetString());+ }++ [Fact]+ public void Analyze_Command_Supports_Face_Detail()+ {+ var stdout = new StringWriter();+ var stderr = new StringWriter();++ var exitCode = Aetheris.CLI.CliRunner.Run(+ ["analyze", Path.Combine(RepoRoot, "testdata/firmament/exports/box_basic.step"), "--face", "1", "--json"],+ stdout,+ stderr);++ Assert.Equal(0, exitCode);+ using var doc = JsonDocument.Parse(stdout.ToString());+ var face = doc.RootElement.GetProperty("face");+ Assert.Equal(1, face.GetProperty("faceId").GetInt32());+ Assert.Equal("Plane", face.GetProperty("surfaceType").GetString());+ Assert.True(face.GetProperty("adjacentEdgeIds").GetArrayLength() >= 4);+ }++ [Fact]+ public void Analyze_Command_Supports_Edge_Detail()+ {+ var stdout = new StringWriter();+ var stderr = new StringWriter();++ var exitCode = Aetheris.CLI.CliRunner.Run(+ ["analyze", Path.Combine(RepoRoot, "testdata/firmament/exports/box_basic.step"), "--edge", "1", "--json"],+ stdout,+ stderr);++ Assert.Equal(0, exitCode);+ using var doc = JsonDocument.Parse(stdout.ToString());+ var edge = doc.RootElement.GetProperty("edge");+ Assert.Equal(1, edge.GetProperty("edgeId").GetInt32());+ Assert.Equal("Line3", edge.GetProperty("curveType").GetString());+ Assert.True(edge.GetProperty("adjacentFaceIds").GetArrayLength() >= 1);+ }++ [Fact]+ public void Analyze_Command_Supports_Vertex_Detail()+ {+ var stdout = new StringWriter();+ var stderr = new StringWriter();++ var exitCode = Aetheris.CLI.CliRunner.Run(+ ["analyze", Path.Combine(RepoRoot, "testdata/firmament/exports/box_basic.step"), "--vertex", "1", "--json"],+ stdout,+ stderr);++ Assert.Equal(0, exitCode);+ using var doc = JsonDocument.Parse(stdout.ToString());+ var vertex = doc.RootElement.GetProperty("vertex");+ Assert.Equal(1, vertex.GetProperty("vertexId").GetInt32());+ Assert.True(vertex.TryGetProperty("position", out _));+ Assert.True(vertex.GetProperty("incidentEdgeIds").GetArrayLength() >= 1);+ }++ private static string FindRepoRoot()+ {+ var directory = new DirectoryInfo(AppContext.BaseDirectory);+ while (directory is not null)+ {+ if (File.Exists(Path.Combine(directory.FullName, "Aetheris.slnx")))+ {+ return directory.FullName;+ }++ directory = directory.Parent;+ }++ throw new InvalidOperationException("Unable to locate repository root for CLI tests.");+ }+}diff --git a/Aetheris.CLI.Tests/UnitTest1.cs b/Aetheris.CLI.Tests/UnitTest1.csnew file mode 100644index 00000000..83a313bd--- /dev/null+++ b/Aetheris.CLI.Tests/UnitTest1.cs@@ -0,0 +1,7 @@+namespace Aetheris.CLI.Tests;++public sealed class UnitTest1+{+ [Fact]+ public void Placeholder() => Assert.True(true);+}diff --git a/Aetheris.CLI/Aetheris.CLI.csproj b/Aetheris.CLI/Aetheris.CLI.csprojnew file mode 100644index 00000000..f9d0db6d--- /dev/null+++ b/Aetheris.CLI/Aetheris.CLI.csproj@@ -0,0 +1,14 @@+<Project Sdk="Microsoft.NET.Sdk">+ <PropertyGroup>+ <OutputType>Exe</OutputType>+ <TargetFramework>net8.0</TargetFramework>+ <ImplicitUsings>enable</ImplicitUsings>+ <Nullable>enable</Nullable>+ <AssemblyName>aetheris</AssemblyName>+ </PropertyGroup>++ <ItemGroup>+ <ProjectReference Include="..\Aetheris.Kernel.Firmament\Aetheris.Kernel.Firmament.csproj" />+ <ProjectReference Include="..\Aetheris.Kernel.Core\Aetheris.Kernel.Core.csproj" />+ </ItemGroup>+</Project>diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.csnew file mode 100644index 00000000..1a732693--- /dev/null+++ b/Aetheris.CLI/CliRunner.cs@@ -0,0 +1,218 @@+using System.Text.Json;+using Aetheris.Kernel.Firmament;++namespace Aetheris.CLI;++public static class CliRunner+{+ private static readonly JsonSerializerOptions JsonOptions = new()+ {+ WriteIndented = true,+ PropertyNamingPolicy = JsonNamingPolicy.CamelCase+ };++ public static int Run(string[] args, TextWriter stdout, TextWriter stderr)+ {+ if (args.Length == 0)+ {+ stderr.WriteLine("Usage: aetheris <build|analyze> <path> [options]");+ return 1;+ }++ try+ {+ return args[0] switch+ {+ "build" => RunBuild(args.Skip(1).ToArray(), stdout, stderr),+ "analyze" => RunAnalyze(args.Skip(1).ToArray(), stdout, stderr),+ _ => UnknownCommand(args[0], stderr)+ };+ }+ catch (Exception ex)+ {+ stderr.WriteLine(ex.Message);+ return 1;+ }+ }++ private static int RunBuild(string[] args, TextWriter stdout, TextWriter stderr)+ {+ if (args.Length == 0)+ {+ stderr.WriteLine("Usage: aetheris build <file.firmament> [--out <path>] [--json]");+ return 1;+ }++ var sourcePath = args[0];+ string? outPath = null;+ var json = false;++ for (var i = 1; i < args.Length; i++)+ {+ switch (args[i])+ {+ case "--out" when i + 1 < args.Length:+ outPath = args[++i];+ break;+ case "--json":+ json = true;+ break;+ default:+ stderr.WriteLine($"Unknown build option '{args[i]}'.");+ return 1;+ }+ }++ var build = FirmamentBuildAndExport.Run(sourcePath, outPath);+ if (!build.IsSuccess)+ {+ if (json)+ {+ stdout.WriteLine(JsonSerializer.Serialize(new+ {+ success = false,+ diagnostics = build.Diagnostics.Select(d => new { d.Source, d.Message, severity = d.Severity.ToString() })+ }, JsonOptions));+ }+ else+ {+ stderr.WriteLine("Build failed:");+ foreach (var diagnostic in build.Diagnostics)+ {+ stderr.WriteLine($"- [{diagnostic.Severity}] {diagnostic.Source}: {diagnostic.Message}");+ }+ }++ return 1;+ }++ if (json)+ {+ stdout.WriteLine(JsonSerializer.Serialize(new+ {+ success = true,+ sourcePath = build.Value.SourcePath,+ outputPath = build.Value.OutputPath+ }, JsonOptions));+ }+ else+ {+ stdout.WriteLine($"Build succeeded: {build.Value.OutputPath}");+ }++ return 0;+ }++ private static int RunAnalyze(string[] args, TextWriter stdout, TextWriter stderr)+ {+ if (args.Length == 0)+ {+ stderr.WriteLine("Usage: aetheris analyze <file.step> [--face <id>] [--edge <id>] [--vertex <id>] [--json]");+ return 1;+ }++ var stepPath = args[0];+ int? faceId = null;+ int? edgeId = null;+ int? vertexId = null;+ var json = false;++ for (var i = 1; i < args.Length; i++)+ {+ switch (args[i])+ {+ case "--face" when i + 1 < args.Length && int.TryParse(args[++i], out var face):+ faceId = face;+ break;+ case "--edge" when i + 1 < args.Length && int.TryParse(args[++i], out var edge):+ edgeId = edge;+ break;+ case "--vertex" when i + 1 < args.Length && int.TryParse(args[++i], out var vertex):+ vertexId = vertex;+ break;+ case "--json":+ json = true;+ break;+ default:+ stderr.WriteLine($"Unknown analyze option '{args[i]}'.");+ return 1;+ }+ }++ var detailCount = (faceId.HasValue ? 1 : 0) + (edgeId.HasValue ? 1 : 0) + (vertexId.HasValue ? 1 : 0);+ if (detailCount > 1)+ {+ stderr.WriteLine("Specify at most one detail selector: --face, --edge, or --vertex.");+ return 1;+ }++ var analysis = StepAnalyzer.Analyze(stepPath, faceId, edgeId, vertexId);+ if (json)+ {+ stdout.WriteLine(JsonSerializer.Serialize(analysis, JsonOptions));+ return 0;+ }++ WriteSummaryText(analysis, stdout);+ return 0;+ }++ private static void WriteSummaryText(AnalyzeResult analysis, TextWriter stdout)+ {+ var summary = analysis.Summary;+ stdout.WriteLine($"STEP: {analysis.StepPath}");+ stdout.WriteLine($"Bodies: {summary.BodyCount}");+ stdout.WriteLine($"Shells: {summary.ShellCount}");+ stdout.WriteLine($"Faces: {summary.FaceCount}");+ stdout.WriteLine($"Edges: {summary.EdgeCount}");+ stdout.WriteLine($"Vertices: {summary.VertexCount}");+ stdout.WriteLine($"BoundingBox: {FormatBox(summary.BoundingBox)}");+ stdout.WriteLine($"Structure: {summary.StructuralAssessment} ({summary.StructuralAssessmentBasis})");+ stdout.WriteLine("Surface Families:");+ foreach (var family in summary.SurfaceFamilies)+ {+ stdout.WriteLine($" {family.Key}: {family.Value}");+ }++ if (analysis.Face is not null)+ {+ stdout.WriteLine($"Face {analysis.Face.FaceId}: type={analysis.Face.SurfaceType}, bbox={FormatBox(analysis.Face.BoundingBox)}, point={FormatPoint(analysis.Face.RepresentativePoint)}, normal={FormatVector(analysis.Face.PlanarNormal)}, axis={FormatVector(analysis.Face.Axis)}, radius={FormatDouble(analysis.Face.Radius)}, semiAngleRadians={FormatDouble(analysis.Face.SemiAngleRadians)}, edges=[{string.Join(",", analysis.Face.AdjacentEdgeIds)}]");+ }++ if (analysis.Edge is not null)+ {+ stdout.WriteLine($"Edge {analysis.Edge.EdgeId}: curve={analysis.Edge.CurveType}, start={analysis.Edge.StartVertexId}:{FormatPoint(analysis.Edge.StartVertex)}, end={analysis.Edge.EndVertexId}:{FormatPoint(analysis.Edge.EndVertex)}, faces=[{string.Join(",", analysis.Edge.AdjacentFaceIds)}], length={FormatDouble(analysis.Edge.Length)}");+ }++ if (analysis.Vertex is not null)+ {+ stdout.WriteLine($"Vertex {analysis.Vertex.VertexId}: xyz={FormatPoint(analysis.Vertex.Position)}, edges=[{string.Join(",", analysis.Vertex.IncidentEdgeIds)}]");+ }++ if (analysis.Notes.Count > 0)+ {+ stdout.WriteLine("Notes:");+ foreach (var note in analysis.Notes)+ {+ stdout.WriteLine($" - {note}");+ }+ }+ }++ private static int UnknownCommand(string command, TextWriter stderr)+ {+ stderr.WriteLine($"Unknown command '{command}'. Expected 'build' or 'analyze'.");+ return 1;+ }++ private static string FormatBox(Aetheris.Kernel.Core.Math.BoundingBox3D? box) =>+ box is null ? "unknown" : $"min{FormatPoint(box.Value.Min)} max{FormatPoint(box.Value.Max)}";++ private static string FormatPoint(Aetheris.Kernel.Core.Math.Point3D? point) =>+ point is null ? "unknown" : $"({point.Value.X:F6},{point.Value.Y:F6},{point.Value.Z:F6})";++ private static string FormatVector(Aetheris.Kernel.Core.Math.Vector3D? vector) =>+ vector is null ? "n/a" : $"({vector.Value.X:F6},{vector.Value.Y:F6},{vector.Value.Z:F6})";++ private static string FormatDouble(double? value) => value?.ToString("G17") ?? "n/a";+}diff --git a/Aetheris.CLI/Program.cs b/Aetheris.CLI/Program.csnew file mode 100644index 00000000..c2030854--- /dev/null+++ b/Aetheris.CLI/Program.cs@@ -0,0 +1,6 @@+namespace Aetheris.CLI;++public static class Program+{+ public static int Main(string[] args) => CliRunner.Run(args, Console.Out, Console.Error);+}diff --git a/Aetheris.CLI/StepAnalysisModels.cs b/Aetheris.CLI/StepAnalysisModels.csnew file mode 100644index 00000000..ef3b42fb--- /dev/null+++ b/Aetheris.CLI/StepAnalysisModels.cs@@ -0,0 +1,48 @@+using Aetheris.Kernel.Core.Math;++namespace Aetheris.CLI;++public sealed record AnalyzeSummary(+ int BodyCount,+ int ShellCount,+ int FaceCount,+ int EdgeCount,+ int VertexCount,+ BoundingBox3D? BoundingBox,+ string StructuralAssessment,+ IReadOnlyDictionary<string, int> SurfaceFamilies,+ string StructuralAssessmentBasis);++public sealed record FaceDetail(+ int FaceId,+ string SurfaceType,+ BoundingBox3D? BoundingBox,+ Point3D? RepresentativePoint,+ Vector3D? PlanarNormal,+ Vector3D? Axis,+ double? Radius,+ double? SemiAngleRadians,+ IReadOnlyList<int> AdjacentEdgeIds);++public sealed record EdgeDetail(+ int EdgeId,+ string CurveType,+ int StartVertexId,+ Point3D? StartVertex,+ int EndVertexId,+ Point3D? EndVertex,+ IReadOnlyList<int> AdjacentFaceIds,+ double? Length);++public sealed record VertexDetail(+ int VertexId,+ Point3D? Position,+ IReadOnlyList<int> IncidentEdgeIds);++public sealed record AnalyzeResult(+ string StepPath,+ AnalyzeSummary Summary,+ FaceDetail? Face,+ EdgeDetail? Edge,+ VertexDetail? Vertex,+ IReadOnlyList<string> Notes);diff --git a/Aetheris.CLI/StepAnalyzer.cs b/Aetheris.CLI/StepAnalyzer.csnew file mode 100644index 00000000..e67f1493--- /dev/null+++ b/Aetheris.CLI/StepAnalyzer.cs@@ -0,0 +1,259 @@+using Aetheris.Kernel.Core.Brep;+using Aetheris.Kernel.Core.Geometry;+using Aetheris.Kernel.Core.Math;+using Aetheris.Kernel.Core.Step242;+using Aetheris.Kernel.Core.Topology;++namespace Aetheris.CLI;++public static class StepAnalyzer+{+ public static AnalyzeResult Analyze(string stepPath, int? faceId = null, int? edgeId = null, int? vertexId = null)+ {+ var fullPath = Path.GetFullPath(stepPath);+ var import = Step242Importer.ImportBody(File.ReadAllText(fullPath));+ if (!import.IsSuccess)+ {+ throw new InvalidOperationException(string.Join(Environment.NewLine, import.Diagnostics.Select(d => d.Message)));+ }++ var body = import.Value;+ var notes = new List<string>();++ var summary = BuildSummary(body, notes);+ var face = faceId.HasValue ? BuildFaceDetail(body, new FaceId(faceId.Value), notes) : null;+ var edge = edgeId.HasValue ? BuildEdgeDetail(body, new EdgeId(edgeId.Value), notes) : null;+ var vertex = vertexId.HasValue ? BuildVertexDetail(body, new VertexId(vertexId.Value), notes) : null;++ return new AnalyzeResult(fullPath, summary, face, edge, vertex, notes);+ }++ private static AnalyzeSummary BuildSummary(BrepBody body, ICollection<string> notes)+ {+ var topology = body.Topology;+ var surfaceFamilies = new Dictionary<string, int>(StringComparer.Ordinal)+ {+ ["plane"] = 0,+ ["cylinder"] = 0,+ ["cone"] = 0,+ ["sphere"] = 0,+ ["torus"] = 0,+ ["other"] = 0+ };++ foreach (var face in topology.Faces)+ {+ if (!body.TryGetFaceSurface(face.Id, out var surface) || surface is null)+ {+ surfaceFamilies["other"]++;+ continue;+ }++ switch (surface.Kind)+ {+ case SurfaceGeometryKind.Plane: surfaceFamilies["plane"]++; break;+ case SurfaceGeometryKind.Cylinder: surfaceFamilies["cylinder"]++; break;+ case SurfaceGeometryKind.Cone: surfaceFamilies["cone"]++; break;+ case SurfaceGeometryKind.Sphere: surfaceFamilies["sphere"]++; break;+ case SurfaceGeometryKind.Torus: surfaceFamilies["torus"]++; break;+ default: surfaceFamilies["other"]++; break;+ }+ }++ var bbox = TryComputeBodyBoundingBox(body);+ if (bbox is null)+ {+ notes.Add("Bounding box unavailable because one or more vertices did not expose XYZ coordinates.");+ }++ var edgeFaces = BuildEdgeFaceAdjacency(body);+ var leakyEdges = edgeFaces.Count(kvp => kvp.Value.Count == 1);+ var nonManifoldEdges = edgeFaces.Count(kvp => kvp.Value.Count != 2);+ var structural = nonManifoldEdges == 0 ? "enclosed-manifold" : (leakyEdges > 0 ? "leaky-or-open" : "non-manifold");+ var basis = "derived from imported topology edge-to-face adjacency counts";++ return new AnalyzeSummary(+ topology.Bodies.Count(),+ topology.Shells.Count(),+ topology.Faces.Count(),+ topology.Edges.Count(),+ topology.Vertices.Count(),+ bbox,+ structural,+ surfaceFamilies,+ basis);+ }++ private static FaceDetail BuildFaceDetail(BrepBody body, FaceId faceId, ICollection<string> notes)+ {+ if (!body.Topology.TryGetFace(faceId, out var face) || face is null)+ {+ throw new InvalidOperationException($"Face '{faceId.Value}' was not found.");+ }++ var edgeIds = body.GetEdges(faceId).Select(id => id.Value).OrderBy(id => id).ToArray();+ var faceVertices = body.GetEdges(faceId)+ .SelectMany(edge => body.GetVertices(edge))+ .Distinct()+ .Select(v => body.TryGetVertexPoint(v, out var p) ? (Point3D?)p : null)+ .Where(p => p.HasValue)+ .Select(p => p!.Value)+ .ToArray();++ BoundingBox3D? bbox = null;+ Point3D? rep = null;+ if (faceVertices.Length > 0)+ {+ bbox = ComputeBoundingBox(faceVertices);+ rep = new Point3D(faceVertices.Average(v => v.X), faceVertices.Average(v => v.Y), faceVertices.Average(v => v.Z));+ }+ else+ {+ notes.Add($"Face {faceId.Value} has no resolved vertex coordinates for bounds/representative point.");+ }++ if (!body.TryGetFaceSurface(faceId, out var surface) || surface is null)+ {+ return new FaceDetail(faceId.Value, "unknown", bbox, rep, null, null, null, null, edgeIds);+ }++ Vector3D? normal = null;+ Vector3D? axis = null;+ double? radius = null;+ double? semiAngle = null;++ if (surface.Plane is { } plane)+ {+ normal = plane.Normal.ToVector();+ }++ if (surface.Cylinder is { } cylinder)+ {+ axis = cylinder.Axis.ToVector();+ radius = cylinder.Radius;+ }++ if (surface.Cone is { } cone)+ {+ axis = cone.Axis.ToVector();+ semiAngle = cone.SemiAngleRadians;+ radius = cone.PlacementRadius;+ }++ return new FaceDetail(faceId.Value, surface.Kind.ToString(), bbox, rep, normal, axis, radius, semiAngle, edgeIds);+ }++ private static EdgeDetail BuildEdgeDetail(BrepBody body, EdgeId edgeId, ICollection<string> notes)+ {+ if (!body.Topology.TryGetEdge(edgeId, out var edge) || edge is null)+ {+ throw new InvalidOperationException($"Edge '{edgeId.Value}' was not found.");+ }++ var curveType = "unknown";+ double? length = null;+ if (body.Bindings.TryGetEdgeBinding(edgeId, out var binding))+ {+ curveType = binding.TrimInterval is null ? "untrimmed" : "trimmed";+ length = binding.TrimInterval is { } interval ? interval.End - interval.Start : null;++ if (body.Geometry.TryGetCurve(binding.CurveGeometryId, out var curve) && curve is not null)+ {+ curveType = curve.Kind == CurveGeometryKind.Unsupported+ ? $"Unsupported({curve.UnsupportedKind ?? "unknown"})"+ : curve.Kind.ToString();+ }+ }+ else+ {+ notes.Add($"Edge {edgeId.Value} has no curve binding, so curve-type and length are limited.");+ }++ Point3D? startPoint = body.TryGetVertexPoint(edge.StartVertexId, out var start) ? start : null;+ Point3D? endPoint = body.TryGetVertexPoint(edge.EndVertexId, out var end) ? end : null;+ var adjacentFaces = BuildEdgeFaceAdjacency(body)+ .TryGetValue(edgeId, out var faces)+ ? faces.Select(id => id.Value).OrderBy(v => v).ToArray()+ : [];++ return new EdgeDetail(edgeId.Value, curveType, edge.StartVertexId.Value, startPoint, edge.EndVertexId.Value, endPoint, adjacentFaces, length);+ }++ private static VertexDetail BuildVertexDetail(BrepBody body, VertexId vertexId, ICollection<string> notes)+ {+ if (!body.Topology.TryGetVertex(vertexId, out _))+ {+ throw new InvalidOperationException($"Vertex '{vertexId.Value}' was not found.");+ }++ Point3D? position = body.TryGetVertexPoint(vertexId, out var point) ? point : null;+ if (position is null)+ {+ notes.Add($"Vertex {vertexId.Value} coordinates are unavailable in imported body.");+ }++ var incidentEdges = body.Topology.Edges+ .Where(edge => edge.StartVertexId == vertexId || edge.EndVertexId == vertexId)+ .Select(edge => edge.Id.Value)+ .OrderBy(id => id)+ .ToArray();++ return new VertexDetail(vertexId.Value, position, incidentEdges);+ }++ private static BoundingBox3D? TryComputeBodyBoundingBox(BrepBody body)+ {+ var points = body.Topology.Vertices+ .Select(v => body.TryGetVertexPoint(v.Id, out var point) ? (Point3D?)point : null)+ .Where(p => p.HasValue)+ .Select(p => p!.Value)+ .ToArray();++ return points.Length == 0 ? null : ComputeBoundingBox(points);+ }++ private static BoundingBox3D ComputeBoundingBox(IReadOnlyList<Point3D> points)+ {+ var minX = points.Min(p => p.X);+ var minY = points.Min(p => p.Y);+ var minZ = points.Min(p => p.Z);+ var maxX = points.Max(p => p.X);+ var maxY = points.Max(p => p.Y);+ var maxZ = points.Max(p => p.Z);+ return new BoundingBox3D(new Point3D(minX, minY, minZ), new Point3D(maxX, maxY, maxZ));+ }++ private static Dictionary<EdgeId, HashSet<FaceId>> BuildEdgeFaceAdjacency(BrepBody body)+ {+ var edgeFaces = new Dictionary<EdgeId, HashSet<FaceId>>();++ foreach (var face in body.Topology.Faces)+ {+ foreach (var loopId in face.LoopIds)+ {+ if (!body.Topology.TryGetLoop(loopId, out var loop) || loop is null)+ {+ continue;+ }++ foreach (var coedgeId in loop.CoedgeIds)+ {+ if (!body.Topology.TryGetCoedge(coedgeId, out var coedge) || coedge is null)+ {+ continue;+ }++ if (!edgeFaces.TryGetValue(coedge.EdgeId, out var faces))+ {+ faces = [];+ edgeFaces.Add(coedge.EdgeId, faces);+ }++ faces.Add(face.Id);+ }+ }+ }++ return edgeFaces;+ }+}diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.csindex 39095ef2..4814e0e2 100644--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs@@ -5,7 +5,7 @@ namespace Aetheris.Kernel.Firmament;public static class FirmamentBuildAndExport{- public static KernelResult<FirmamentBuildAndExportResult> Run(string sourcePath)+ public static KernelResult<FirmamentBuildAndExportResult> Run(string sourcePath, string? outputPath = null){ArgumentException.ThrowIfNullOrWhiteSpace(sourcePath);@@ -17,14 +17,17 @@ public static class FirmamentBuildAndExportreturn KernelResult<FirmamentBuildAndExportResult>.Failure(exportResult.Diagnostics);}- var outputPath = ResolveDefaultOutputPath(fullSourcePath);- Directory.CreateDirectory(Path.GetDirectoryName(outputPath)!);- File.WriteAllText(outputPath, exportResult.Value.StepText, new UTF8Encoding(false));+ var resolvedOutputPath = string.IsNullOrWhiteSpace(outputPath)+ ? ResolveDefaultOutputPath(fullSourcePath)+ : Path.GetFullPath(outputPath);++ Directory.CreateDirectory(Path.GetDirectoryName(resolvedOutputPath)!);+ File.WriteAllText(resolvedOutputPath, exportResult.Value.StepText, new UTF8Encoding(false));return KernelResult<FirmamentBuildAndExportResult>.Success(new FirmamentBuildAndExportResult(fullSourcePath,- outputPath,+ resolvedOutputPath,exportResult.Value));}diff --git a/Aetheris.sln b/Aetheris.slnindex 79e7d457..c5be0d4a 100644--- a/Aetheris.sln+++ b/Aetheris.sln@@ -15,6 +15,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aetheris.Server", "AetherisEndProjectProject("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aetheris.Server.Tests", "Aetheris.Server.Tests\Aetheris.Server.Tests.csproj", "{03B71CD1-35E4-453D-BFBF-A62314338316}"EndProject+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aetheris.CLI", "Aetheris.CLI\Aetheris.CLI.csproj", "{3E506C1D-AFF7-4FB2-9208-EEFCD1AE12DC}"+EndProject+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aetheris.CLI.Tests", "Aetheris.CLI.Tests\Aetheris.CLI.Tests.csproj", "{DEBC8B25-C561-4887-B93F-A5164461AB1E}"+EndProjectGlobalGlobalSection(SolutionConfigurationPlatforms) = preSolutionDebug|Any CPU = Debug|Any CPU@@ -48,5 +52,13 @@ Global{03B71CD1-35E4-453D-BFBF-A62314338316}.Debug|Any CPU.Build.0 = Debug|Any CPU{03B71CD1-35E4-453D-BFBF-A62314338316}.Release|Any CPU.ActiveCfg = Release|Any CPU{03B71CD1-35E4-453D-BFBF-A62314338316}.Release|Any CPU.Build.0 = Release|Any CPU+ {3E506C1D-AFF7-4FB2-9208-EEFCD1AE12DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU+ {3E506C1D-AFF7-4FB2-9208-EEFCD1AE12DC}.Debug|Any CPU.Build.0 = Debug|Any CPU+ {3E506C1D-AFF7-4FB2-9208-EEFCD1AE12DC}.Release|Any CPU.ActiveCfg = Release|Any CPU+ {3E506C1D-AFF7-4FB2-9208-EEFCD1AE12DC}.Release|Any CPU.Build.0 = Release|Any CPU+ {DEBC8B25-C561-4887-B93F-A5164461AB1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU+ {DEBC8B25-C561-4887-B93F-A5164461AB1E}.Debug|Any CPU.Build.0 = Debug|Any CPU+ {DEBC8B25-C561-4887-B93F-A5164461AB1E}.Release|Any CPU.ActiveCfg = Release|Any CPU+ {DEBC8B25-C561-4887-B93F-A5164461AB1E}.Release|Any CPU.Build.0 = Release|Any CPUEndGlobalSectionEndGlobaldiff --git a/Aetheris.slnx b/Aetheris.slnxindex c6f35585..8fa866e6 100644--- a/Aetheris.slnx+++ b/Aetheris.slnx@@ -9,5 +9,7 @@<Build /><Deploy /></Project>+ <Project Path="Aetheris.CLI/Aetheris.CLI.csproj" />+ <Project Path="Aetheris.CLI.Tests/Aetheris.CLI.Tests.csproj" /><Project Path="Aetheris.Kernel.Core.Tests/Aetheris.Kernel.Core.Tests.csproj" /></Solution>diff --git a/docs/cli-baseline.md b/docs/cli-baseline.mdnew file mode 100644index 00000000..e5ad239e--- /dev/null+++ b/docs/cli-baseline.md@@ -0,0 +1,52 @@+# Aetheris.CLI baseline (C1)++## Supported commands++```bash+aetheris build <file.firmament> [--out <path>] [--json]+aetheris analyze <file.step> [--face <id>] [--edge <id>] [--vertex <id>] [--json]+```++### Contract notes++- `build` runs the existing `FirmamentBuildAndExport.Run` pipeline; it does not implement a parallel compiler/export path.+- `build` default output path remains deterministic: `<repo>/testdata/firmament/exports/<source-filename>.step`.+- `analyze` imports STEP using `Step242Importer.ImportBody` and reports facts from imported topology/geometry bindings.+- At most one detail selector is allowed on `analyze`: `--face`, `--edge`, or `--vertex`.+- `analyze --json` is the canonical machine-readable mode.++## `analyze --json` shape++```json+{+ "stepPath": "...",+ "summary": {+ "bodyCount": 1,+ "shellCount": 1,+ "faceCount": 6,+ "edgeCount": 12,+ "vertexCount": 8,+ "boundingBox": { "min": { "x": 0, "y": 0, "z": 0 }, "max": { "x": 10, "y": 5, "z": 2 } },+ "structuralAssessment": "enclosed-manifold",+ "surfaceFamilies": {+ "plane": 6,+ "cylinder": 0,+ "cone": 0,+ "sphere": 0,+ "torus": 0,+ "other": 0+ },+ "structuralAssessmentBasis": "derived from imported topology edge-to-face adjacency counts"+ },+ "face": null,+ "edge": null,+ "vertex": null,+ "notes": []+}+```++## Truthfulness and deferrals++- Structural classification is based on edge-to-face adjacency counts from imported topology.+- If bounding boxes or points cannot be determined from available vertex coordinates, output is `null` (JSON) / `unknown` (text), and a note is emitted.+- No renderer/viewer, no schema redesign, and no generalized command framework are included in C1.