Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Fix inner-shell export test compilation and shell count assertion

Yuechen Li882869210fcf
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242InnerShellExportTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242InnerShellExportTests.cs
new file mode 100644
index 00000000..c8264ac0
--- /dev/null
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242InnerShellExportTests.cs
@@ -0,0 +1,222 @@
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Step242;
+using Aetheris.Kernel.Core.Topology;
+
+namespace Aetheris.Kernel.Core.Tests.Step242;
+
+public sealed class Step242InnerShellExportTests
+{
+ [Fact]
+ public void ExportBody_SingleShellRegression_StillUsesManifoldSolidBrep()
+ {
+ var box = BrepPrimitives.CreateBox(6d, 5d, 4d);
+ Assert.True(box.IsSuccess);
+
+ var export = Step242Exporter.ExportBody(box.Value);
+
+ Assert.True(export.IsSuccess);
+ Assert.Contains("MANIFOLD_SOLID_BREP", export.Value, StringComparison.Ordinal);
+ Assert.DoesNotContain("BREP_WITH_VOIDS", export.Value, StringComparison.Ordinal);
+ }
+
+ [Fact]
+ public void ExportBody_InnerShellRepresentation_ValidatesAndExportsDeterministically()
+ {
+ var body = CreateSyntheticBodyWithInnerShell();
+
+ var validation = BrepBindingValidator.Validate(body);
+ Assert.True(validation.IsSuccess);
+
+ var first = Step242Exporter.ExportBody(body);
+ var second = Step242Exporter.ExportBody(body);
+
+ Assert.True(first.IsSuccess);
+ Assert.True(second.IsSuccess);
+ Assert.Equal(first.Value, second.Value);
+ Assert.Contains("BREP_WITH_VOIDS", first.Value, StringComparison.Ordinal);
+ Assert.Contains("ORIENTED_CLOSED_SHELL", first.Value, StringComparison.Ordinal);
+ Assert.Equal(2, CountOccurrences(first.Value, "=CLOSED_SHELL("));
+ }
+
+ [Fact]
+ public void Validate_InnerShellRepresentationRejectsDuplicatedShellRole()
+ {
+ var box = BrepPrimitives.CreateBox(3d, 3d, 3d);
+ Assert.True(box.IsSuccess);
+
+ var shellId = Assert.Single(Assert.Single(box.Value.Topology.Bodies).ShellIds);
+ var invalid = new BrepBody(
+ box.Value.Topology,
+ box.Value.Geometry,
+ box.Value.Bindings,
+ vertexPoints: null,
+ safeBooleanComposition: null,
+ shellRepresentation: new BrepBodyShellRepresentation(shellId, [shellId]));
+
+ var validation = BrepBindingValidator.Validate(invalid);
+
+ Assert.False(validation.IsSuccess);
+ Assert.Contains(validation.Diagnostics, d => d.Message.Contains("more than once", StringComparison.Ordinal));
+ }
+
+ private static BrepBody CreateSyntheticBodyWithInnerShell()
+ {
+ var outer = BrepPrimitives.CreateBox(10d, 10d, 10d);
+ var inner = BrepPrimitives.CreateBox(4d, 4d, 4d);
+ Assert.True(outer.IsSuccess);
+ Assert.True(inner.IsSuccess);
+
+ const int idOffset = 1000;
+ var topology = new TopologyModel();
+
+ foreach (var vertex in outer.Value.Topology.Vertices.OrderBy(v => v.Id.Value))
+ {
+ topology.AddVertex(vertex);
+ }
+
+ foreach (var edge in outer.Value.Topology.Edges.OrderBy(e => e.Id.Value))
+ {
+ topology.AddEdge(edge);
+ }
+
+ foreach (var coedge in outer.Value.Topology.Coedges.OrderBy(c => c.Id.Value))
+ {
+ topology.AddCoedge(coedge);
+ }
+
+ foreach (var loop in outer.Value.Topology.Loops.OrderBy(l => l.Id.Value))
+ {
+ topology.AddLoop(loop);
+ }
+
+ foreach (var face in outer.Value.Topology.Faces.OrderBy(f => f.Id.Value))
+ {
+ topology.AddFace(face);
+ }
+
+ foreach (var shell in outer.Value.Topology.Shells.OrderBy(s => s.Id.Value))
+ {
+ topology.AddShell(shell);
+ }
+
+ var innerVertexMap = inner.Value.Topology.Vertices.ToDictionary(v => v.Id, v => new VertexId(v.Id.Value + idOffset));
+ var innerEdgeMap = inner.Value.Topology.Edges.ToDictionary(e => e.Id, e => new EdgeId(e.Id.Value + idOffset));
+ var innerLoopMap = inner.Value.Topology.Loops.ToDictionary(l => l.Id, l => new LoopId(l.Id.Value + idOffset));
+ var innerCoedgeMap = inner.Value.Topology.Coedges.ToDictionary(c => c.Id, c => new CoedgeId(c.Id.Value + idOffset));
+ var innerFaceMap = inner.Value.Topology.Faces.ToDictionary(f => f.Id, f => new FaceId(f.Id.Value + idOffset));
+ var innerShellMap = inner.Value.Topology.Shells.ToDictionary(s => s.Id, s => new ShellId(s.Id.Value + idOffset));
+
+ foreach (var vertex in inner.Value.Topology.Vertices.OrderBy(v => v.Id.Value))
+ {
+ topology.AddVertex(new Vertex(innerVertexMap[vertex.Id]));
+ }
+
+ foreach (var edge in inner.Value.Topology.Edges.OrderBy(e => e.Id.Value))
+ {
+ topology.AddEdge(new Edge(innerEdgeMap[edge.Id], innerVertexMap[edge.StartVertexId], innerVertexMap[edge.EndVertexId]));
+ }
+
+ foreach (var coedge in inner.Value.Topology.Coedges.OrderBy(c => c.Id.Value))
+ {
+ topology.AddCoedge(new Coedge(
+ innerCoedgeMap[coedge.Id],
+ innerEdgeMap[coedge.EdgeId],
+ innerLoopMap[coedge.LoopId],
+ innerCoedgeMap[coedge.NextCoedgeId],
+ innerCoedgeMap[coedge.PrevCoedgeId],
+ coedge.IsReversed));
+ }
+
+ foreach (var loop in inner.Value.Topology.Loops.OrderBy(l => l.Id.Value))
+ {
+ topology.AddLoop(new Loop(innerLoopMap[loop.Id], loop.CoedgeIds.Select(id => innerCoedgeMap[id]).ToArray()));
+ }
+
+ foreach (var face in inner.Value.Topology.Faces.OrderBy(f => f.Id.Value))
+ {
+ topology.AddFace(new Face(innerFaceMap[face.Id], face.LoopIds.Select(id => innerLoopMap[id]).ToArray()));
+ }
+
+ foreach (var shell in inner.Value.Topology.Shells.OrderBy(s => s.Id.Value))
+ {
+ topology.AddShell(new Shell(innerShellMap[shell.Id], shell.FaceIds.Select(id => innerFaceMap[id]).ToArray()));
+ }
+
+ var outerShellId = Assert.Single(Assert.Single(outer.Value.Topology.Bodies).ShellIds);
+ var innerShellId = innerShellMap[Assert.Single(Assert.Single(inner.Value.Topology.Bodies).ShellIds)];
+ topology.AddBody(new Body(new BodyId(1), [outerShellId, innerShellId]));
+
+ var geometry = new BrepGeometryStore();
+ foreach (var curve in outer.Value.Geometry.Curves)
+ {
+ geometry.AddCurve(curve.Key, curve.Value);
+ }
+
+ foreach (var surface in outer.Value.Geometry.Surfaces)
+ {
+ geometry.AddSurface(surface.Key, surface.Value);
+ }
+
+ foreach (var curve in inner.Value.Geometry.Curves)
+ {
+ geometry.AddCurve(new CurveGeometryId(curve.Key.Value + idOffset), curve.Value);
+ }
+
+ foreach (var surface in inner.Value.Geometry.Surfaces)
+ {
+ geometry.AddSurface(new SurfaceGeometryId(surface.Key.Value + idOffset), surface.Value);
+ }
+
+ var bindings = new BrepBindingModel();
+ foreach (var edgeBinding in outer.Value.Bindings.EdgeBindings.OrderBy(binding => binding.EdgeId.Value))
+ {
+ bindings.AddEdgeBinding(edgeBinding);
+ }
+
+ foreach (var faceBinding in outer.Value.Bindings.FaceBindings.OrderBy(binding => binding.FaceId.Value))
+ {
+ bindings.AddFaceBinding(faceBinding);
+ }
+
+ foreach (var edgeBinding in inner.Value.Bindings.EdgeBindings.OrderBy(binding => binding.EdgeId.Value))
+ {
+ bindings.AddEdgeBinding(edgeBinding with
+ {
+ EdgeId = innerEdgeMap[edgeBinding.EdgeId],
+ CurveGeometryId = new CurveGeometryId(edgeBinding.CurveGeometryId.Value + idOffset)
+ });
+ }
+
+ foreach (var faceBinding in inner.Value.Bindings.FaceBindings.OrderBy(binding => binding.FaceId.Value))
+ {
+ bindings.AddFaceBinding(faceBinding with
+ {
+ FaceId = innerFaceMap[faceBinding.FaceId],
+ SurfaceGeometryId = new SurfaceGeometryId(faceBinding.SurfaceGeometryId.Value + idOffset)
+ });
+ }
+
+ return new BrepBody(
+ topology,
+ geometry,
+ bindings,
+ vertexPoints: null,
+ safeBooleanComposition: null,
+ shellRepresentation: new BrepBodyShellRepresentation(outerShellId, [innerShellId]));
+ }
+
+ private static int CountOccurrences(string text, string token)
+ {
+ var count = 0;
+ var index = 0;
+
+ while ((index = text.IndexOf(token, index, StringComparison.Ordinal)) >= 0)
+ {
+ count++;
+ index += token.Length;
+ }
+
+ return count;
+ }
+}
diff --git a/Aetheris.Kernel.Core/Brep/BrepBindingValidator.cs b/Aetheris.Kernel.Core/Brep/BrepBindingValidator.cs
index 5e621fae..586a5e2d 100644
--- a/Aetheris.Kernel.Core/Brep/BrepBindingValidator.cs
+++ b/Aetheris.Kernel.Core/Brep/BrepBindingValidator.cs
@@ -17,6 +17,8 @@ public static class BrepBindingValidator
var topologyResult = TopologyGraphValidator.Validate(body.Topology);
diagnostics.AddRange(topologyResult.Diagnostics);
+ ValidateShellRepresentation(body, diagnostics);
+
foreach (var edgeBinding in body.Bindings.EdgeBindings)
{
if (!body.Topology.TryGetEdge(edgeBinding.EdgeId, out _))
@@ -75,6 +77,76 @@ public static class BrepBindingValidator
: KernelResult<bool>.Success(true, diagnostics);
}
+
+ private static void ValidateShellRepresentation(BrepBody body, ICollection<KernelDiagnostic> diagnostics)
+ {
+ if (body.ShellRepresentation is null)
+ {
+ return;
+ }
+
+ var topologyBodies = body.Topology.Bodies.OrderBy(node => node.Id.Value).ToArray();
+ if (topologyBodies.Length != 1)
+ {
+ diagnostics.Add(Error($"Shell representation requires exactly one topology body; found {topologyBodies.Length}."));
+ return;
+ }
+
+ var topologyBody = topologyBodies[0];
+ var topologyShellSet = topologyBody.ShellIds.ToHashSet();
+ var referencedShellIds = new List<ShellId> { body.ShellRepresentation.OuterShellId };
+ referencedShellIds.AddRange(body.ShellRepresentation.InnerShellIds);
+
+ var seen = new HashSet<ShellId>();
+ foreach (var shellId in referencedShellIds)
+ {
+ if (!seen.Add(shellId))
+ {
+ diagnostics.Add(Error($"Shell representation references shell {shellId.Value} more than once."));
+ continue;
+ }
+
+ if (!body.Topology.TryGetShell(shellId, out _))
+ {
+ diagnostics.Add(Error($"Shell representation references missing shell {shellId.Value}."));
+ }
+
+ if (!topologyShellSet.Contains(shellId))
+ {
+ diagnostics.Add(Error($"Shell representation references shell {shellId.Value} that is not owned by body {topologyBody.Id.Value}."));
+ }
+ }
+
+ foreach (var shellId in topologyBody.ShellIds)
+ {
+ if (!seen.Contains(shellId))
+ {
+ diagnostics.Add(Error($"Topology body {topologyBody.Id.Value} shell {shellId.Value} is not represented by BrepBody shell roles."));
+ }
+ }
+
+ var faceOwners = new Dictionary<FaceId, ShellId>();
+ foreach (var shellId in referencedShellIds)
+ {
+ if (!body.Topology.TryGetShell(shellId, out var shell) || shell is null)
+ {
+ continue;
+ }
+
+ foreach (var faceId in shell.FaceIds)
+ {
+ if (faceOwners.TryGetValue(faceId, out var existingShellId))
+ {
+ diagnostics.Add(Error($"Face {faceId.Value} is shared between shells {existingShellId.Value} and {shellId.Value}; shell roles must be disjoint."));
+ }
+ else
+ {
+ faceOwners.Add(faceId, shellId);
+ }
+ }
+ }
+ }
+
private static KernelDiagnostic Error(string message) =>
new(KernelDiagnosticCode.ValidationFailed, KernelDiagnosticSeverity.Error, message);
}
diff --git a/Aetheris.Kernel.Core/Brep/BrepBody.cs b/Aetheris.Kernel.Core/Brep/BrepBody.cs
index 56f58de3..be9669a9 100644
--- a/Aetheris.Kernel.Core/Brep/BrepBody.cs
+++ b/Aetheris.Kernel.Core/Brep/BrepBody.cs
@@ -22,13 +22,15 @@ public sealed class BrepBody
BrepGeometryStore geometry,
BrepBindingModel bindings,
IReadOnlyDictionary<VertexId, Point3D>? vertexPoints,
- SafeBooleanComposition? safeBooleanComposition = null)
+ SafeBooleanComposition? safeBooleanComposition = null,
+ BrepBodyShellRepresentation? shellRepresentation = null)
{
Topology = topology;
Geometry = geometry;
Bindings = bindings;
_vertexPoints = vertexPoints ?? new Dictionary<VertexId, Point3D>();
SafeBooleanComposition = safeBooleanComposition;
+ ShellRepresentation = shellRepresentation ?? TryCreateLegacySingleShellRepresentation(topology);
}
public TopologyModel Topology { get; }
@@ -39,6 +41,8 @@ public sealed class BrepBody
public SafeBooleanComposition? SafeBooleanComposition { get; }
+ public BrepBodyShellRepresentation? ShellRepresentation { get; }
+
public bool TryGetVertexPoint(VertexId vertexId, out Point3D point) => _vertexPoints.TryGetValue(vertexId, out point);
public bool TryGetEdgeCurveGeometry(EdgeId edgeId, out CurveGeometry? curve)
@@ -53,6 +57,24 @@ public sealed class BrepBody
return Geometry.TryGetCurve(binding.CurveGeometryId, out curve);
}
+
+ private static BrepBodyShellRepresentation? TryCreateLegacySingleShellRepresentation(TopologyModel topology)
+ {
+ var bodies = topology.Bodies.OrderBy(body => body.Id.Value).ToArray();
+ if (bodies.Length != 1)
+ {
+ return null;
+ }
+
+ var shellIds = bodies[0].ShellIds.OrderBy(shellId => shellId.Value).ToArray();
+ if (shellIds.Length != 1)
+ {
+ return null;
+ }
+
+ return new BrepBodyShellRepresentation(shellIds[0], []);
+ }
+
public bool TryGetFaceSurfaceGeometry(FaceId faceId, out SurfaceGeometry? surface)
{
surface = null;
diff --git a/Aetheris.Kernel.Core/Brep/BrepBodyShellRepresentation.cs b/Aetheris.Kernel.Core/Brep/BrepBodyShellRepresentation.cs
new file mode 100644
index 00000000..69033a39
--- /dev/null
+++ b/Aetheris.Kernel.Core/Brep/BrepBodyShellRepresentation.cs
@@ -0,0 +1,11 @@
+using Aetheris.Kernel.Core.Topology;
+
+namespace Aetheris.Kernel.Core.Brep;
+
+/// <summary>
+/// Explicit shell role partition for a single solid body: one outer shell and zero or more inner void shells.
+/// </summary>
+public sealed record BrepBodyShellRepresentation(ShellId OuterShellId, IReadOnlyList<ShellId> InnerShellIds)
+{
+ public IReadOnlyList<ShellId> OrderedShellIds => [OuterShellId, .. InnerShellIds];
+}
diff --git a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
index 87143863..7e897649 100644
--- a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
@@ -29,12 +29,17 @@ public static class Step242Exporter
}
var shellIds = bodyNodes[0].ShellIds.OrderBy(s => s.Value).ToArray();
- if (shellIds.Length != 1)
+ var shellRepresentation = body.ShellRepresentation;
+ if (shellRepresentation is null)
{
- return Failure("Only one shell per body is supported.", "Topology.Shells");
+ if (shellIds.Length != 1)
+ {
+ return Failure("Multi-shell export requires an explicit BrepBody shell representation.", "Topology.Shells");
+ }
+
+ shellRepresentation = new BrepBodyShellRepresentation(shellIds[0], []);
}
- var shell = model.GetShell(shellIds[0]);
var writer = new Step242TextWriter();
var vertexPointIds = new Dictionary<VertexId, string>();
@@ -48,29 +53,105 @@ public static class Step242Exporter
var bsplineIds = new Dictionary<EdgeId, string>();
var ellipseIds = new Dictionary<EdgeId, string>();
- var faceIds = new List<string>();
+ var outerClosedShellId = BuildClosedShell(writer, body, model, shellRepresentation.OuterShellId, vertexPoints, cartesianPointIds, vertexPointIds, edgeCurveIds, orientedEdgeIds, lineIds, circleIds, bsplineIds, ellipseIds);
+ if (outerClosedShellId is null)
+ {
+ return Failure($"Shell {shellRepresentation.OuterShellId.Value} could not be exported.", $"Shell:{shellRepresentation.OuterShellId.Value}");
+ }
+
+ string brepId;
+ if (shellRepresentation.InnerShellIds.Count == 0)
+ {
+ brepId = writer.AddEntity("MANIFOLD_SOLID_BREP", Step242TextWriter.String(options.ProductName), Step242TextWriter.Ref(outerClosedShellId));
+ }
+ else
+ {
+ var orientedVoidShellIds = new List<string>();
+ foreach (var innerShellId in shellRepresentation.InnerShellIds.OrderBy(id => id.Value))
+ {
+ var innerClosedShellId = BuildClosedShell(writer, body, model, innerShellId, vertexPoints, cartesianPointIds, vertexPointIds, edgeCurveIds, orientedEdgeIds, lineIds, circleIds, bsplineIds, ellipseIds);
+ if (innerClosedShellId is null)
+ {
+ return Failure($"Shell {innerShellId.Value} could not be exported.", $"Shell:{innerShellId.Value}");
+ }
+
+ var orientedClosedShellId = writer.AddEntity(
+ "ORIENTED_CLOSED_SHELL",
+ "$",
+ Step242TextWriter.Ref(innerClosedShellId),
+ Step242TextWriter.BooleanLogical(false));
+
+ orientedVoidShellIds.Add(orientedClosedShellId);
+ }
+
+ brepId = writer.AddEntity(
+ "BREP_WITH_VOIDS",
+ Step242TextWriter.String(options.ProductName),
+ Step242TextWriter.Ref(outerClosedShellId),
+ Step242TextWriter.List(orientedVoidShellIds.ToArray()));
+ }
+
+ var appContextId = writer.AddEntity("APPLICATION_CONTEXT", Step242TextWriter.String("mechanical design"));
+ var productContextId = writer.AddEntity("PRODUCT_CONTEXT", Step242TextWriter.String(""), Step242TextWriter.Ref(appContextId), Step242TextWriter.String("mechanical"));
+ var productId = writer.AddEntity("PRODUCT", Step242TextWriter.String("AETHERIS"), Step242TextWriter.String(options.ProductName), Step242TextWriter.String(""), Step242TextWriter.List(productContextId));
+ var formationId = writer.AddEntity("PRODUCT_DEFINITION_FORMATION", Step242TextWriter.String(""), Step242TextWriter.String(""), Step242TextWriter.Ref(productId));
+ var definitionContextId = writer.AddEntity("PRODUCT_DEFINITION_CONTEXT", Step242TextWriter.String("design"), Step242TextWriter.Ref(appContextId), Step242TextWriter.String("design"));
+ var definitionId = writer.AddEntity("PRODUCT_DEFINITION", Step242TextWriter.String(""), Step242TextWriter.String(""), Step242TextWriter.Ref(formationId), Step242TextWriter.Ref(definitionContextId));
+ var shapeId = writer.AddEntity("PRODUCT_DEFINITION_SHAPE", Step242TextWriter.String(""), Step242TextWriter.String(""), Step242TextWriter.Ref(definitionId));
+ var lengthUnitId = writer.AddRawEntity("(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.))");
+ var planeAngleUnitId = writer.AddRawEntity("(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.))");
+ var solidAngleUnitId = writer.AddRawEntity("(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT())");
+ var repContextId = writer.AddRawEntity($"(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNIT_ASSIGNED_CONTEXT(({lengthUnitId},{planeAngleUnitId},{solidAngleUnitId}))REPRESENTATION_CONTEXT('3','3D'))");
+ EmitSemanticPmi(writer, shapeId, repContextId, lengthUnitId, semanticPmi);
+ var shapeRepresentationId = writer.AddEntity("SHAPE_REPRESENTATION", Step242TextWriter.String(options.ProductName), Step242TextWriter.List(brepId), Step242TextWriter.Ref(repContextId));
+ writer.AddEntity("SHAPE_DEFINITION_REPRESENTATION", Step242TextWriter.Ref(shapeId), Step242TextWriter.Ref(shapeRepresentationId));
+
+ return KernelResult<string>.Success(writer.Build(options.ApplicationName));
+ }
+
+ private static string? BuildClosedShell(
+ Step242TextWriter writer,
+ BrepBody body,
+ TopologyModel model,
+ ShellId shellId,
+ Dictionary<VertexId, Point3D> vertexPoints,
+ Dictionary<VertexId, string> cartesianPointIds,
+ Dictionary<VertexId, string> vertexPointIds,
+ Dictionary<EdgeId, string> edgeCurveIds,
+ Dictionary<CoedgeId, string> orientedEdgeIds,
+ Dictionary<EdgeId, string> lineIds,
+ Dictionary<EdgeId, string> circleIds,
+ Dictionary<EdgeId, string> bsplineIds,
+ Dictionary<EdgeId, string> ellipseIds)
+ {
+ if (!model.TryGetShell(shellId, out var shell) || shell is null)
+ {
+ return null;
+ }
+
+ var faceIds = new List<string>();
foreach (var face in shell.FaceIds.OrderBy(id => id.Value).Select(model.GetFace))
{
if (!body.Bindings.TryGetFaceBinding(face.Id, out var faceBinding))
{
- return Failure("Face is missing surface binding.", $"Face:{face.Id.Value}");
+ return null;
}
if (!body.Geometry.TryGetSurface(faceBinding.SurfaceGeometryId, out var surface) || surface is null)
{
- return Failure("Face surface geometry was not found.", $"Surface:{faceBinding.SurfaceGeometryId.Value}");
+ return null;
}
if (face.LoopIds.Count == 0 && !CanExportLooplessFace(body, face, surface))
{
- return Failure("Faces without boundary loops are not supported in M22 export subset unless they are the canonical loopless sphere primitive.", $"Face:{face.Id.Value}");
+ return null;
}
var surfaceIdResult = BuildSurface(writer, surface, face.Id);
if (!surfaceIdResult.IsSuccess)
{
- return KernelResult<string>.Failure(surfaceIdResult.Diagnostics);
+ return null;
}
var loopBoundIds = new List<string>();
@@ -88,7 +169,7 @@ public static class Step242Exporter
var edgeResult = BuildEdgeCurve(body, model, writer, coedge.EdgeId, vertexPoints, cartesianPointIds, vertexPointIds, lineIds, circleIds, bsplineIds, ellipseIds);
if (!edgeResult.IsSuccess)
{
- return KernelResult<string>.Failure(edgeResult.Diagnostics);
+ return null;
}
edgeCurveId = edgeResult.Value;
@@ -123,26 +204,7 @@ public static class Step242Exporter
faceIds.Add(advancedFaceId);
}
- var closedShellId = writer.AddEntity("CLOSED_SHELL", "$", Step242TextWriter.List(faceIds.ToArray()));
- var brepId = writer.AddEntity("MANIFOLD_SOLID_BREP", Step242TextWriter.String(options.ProductName), Step242TextWriter.Ref(closedShellId));
-
- var appContextId = writer.AddEntity("APPLICATION_CONTEXT", Step242TextWriter.String("mechanical design"));
- var productContextId = writer.AddEntity("PRODUCT_CONTEXT", Step242TextWriter.String(""), Step242TextWriter.Ref(appContextId), Step242TextWriter.String("mechanical"));
- var productId = writer.AddEntity("PRODUCT", Step242TextWriter.String("AETHERIS"), Step242TextWriter.String(options.ProductName), Step242TextWriter.String(""), Step242TextWriter.List(productContextId));
- var formationId = writer.AddEntity("PRODUCT_DEFINITION_FORMATION", Step242TextWriter.String(""), Step242TextWriter.String(""), Step242TextWriter.Ref(productId));
- var definitionContextId = writer.AddEntity("PRODUCT_DEFINITION_CONTEXT", Step242TextWriter.String("design"), Step242TextWriter.Ref(appContextId), Step242TextWriter.String("design"));
- var definitionId = writer.AddEntity("PRODUCT_DEFINITION", Step242TextWriter.String(""), Step242TextWriter.String(""), Step242TextWriter.Ref(formationId), Step242TextWriter.Ref(definitionContextId));
- var shapeId = writer.AddEntity("PRODUCT_DEFINITION_SHAPE", Step242TextWriter.String(""), Step242TextWriter.String(""), Step242TextWriter.Ref(definitionId));
- var lengthUnitId = writer.AddRawEntity("(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.))");
- var planeAngleUnitId = writer.AddRawEntity("(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.))");
- var solidAngleUnitId = writer.AddRawEntity("(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT())");
- var repContextId = writer.AddRawEntity($"(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNIT_ASSIGNED_CONTEXT(({lengthUnitId},{planeAngleUnitId},{solidAngleUnitId}))REPRESENTATION_CONTEXT('3','3D'))");
- EmitSemanticPmi(writer, shapeId, repContextId, lengthUnitId, semanticPmi);
-
- var shapeRepresentationId = writer.AddEntity("SHAPE_REPRESENTATION", Step242TextWriter.String(options.ProductName), Step242TextWriter.List(brepId), Step242TextWriter.Ref(repContextId));
- writer.AddEntity("SHAPE_DEFINITION_REPRESENTATION", Step242TextWriter.Ref(shapeId), Step242TextWriter.Ref(shapeRepresentationId));
-
- return KernelResult<string>.Success(writer.Build(options.ApplicationName));
+ return writer.AddEntity("CLOSED_SHELL", "$", Step242TextWriter.List(faceIds.ToArray()));
}
private static void EmitSemanticPmi(