Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Implement M6d topology-backed expect_manifold validation

Yuechen Lif2f9a1281a84
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentPrimitiveExecutionTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentPrimitiveExecutionTests.cs
index dd959e5d..396e0d00 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentPrimitiveExecutionTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentPrimitiveExecutionTests.cs
@@ -118,7 +118,7 @@ public sealed class FirmamentPrimitiveExecutionTests
Assert.True(result.Compilation.IsSuccess);
var artifact = result.Compilation.Value;
- Assert.Equal("firmament-topology-selectable-validation-executed", artifact.ArtifactKind);
+ Assert.Equal("firmament-topology-manifold-validation-executed", artifact.ArtifactKind);
Assert.Equal(2, artifact.PrimitiveLoweringPlan!.Primitives.Count);
Assert.Equal(2, artifact.PrimitiveLoweringPlan.Booleans.Count);
Assert.Single(artifact.PrimitiveLoweringPlan.SkippedOps);
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentScaffoldTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentScaffoldTests.cs
index 71435551..11ffa9c3 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentScaffoldTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentScaffoldTests.cs
@@ -37,7 +37,7 @@ public sealed class FirmamentScaffoldTests
Assert.True(result.Compilation.IsSuccess);
var artifact = result.Compilation.Value;
- Assert.Equal("firmament-topology-selectable-validation-executed", artifact.ArtifactKind);
+ Assert.Equal("firmament-topology-manifold-validation-executed", artifact.ArtifactKind);
Assert.NotNull(artifact.ParsedDocument);
Assert.Equal("1", artifact.ParsedDocument!.Firmament.Version);
Assert.Equal("demo", artifact.ParsedDocument.Model.Name);
@@ -177,6 +177,7 @@ public sealed class FirmamentScaffoldTests
radius: 1
-
op: expect_manifold
+ target: s1
""";
var result = compiler.Compile(new FirmamentCompileRequest(new FirmamentSourceDocument(source)));
@@ -890,8 +891,16 @@ public sealed class FirmamentScaffoldTests
count: 1
""",
"expect_manifold" => """
+ -
+ op: box
+ id: b1
+ size[3]:
+ 1
+ 1
+ 1
-
op: expect_manifold
+ target: b1
""",
_ => $$"""
-
@@ -907,7 +916,7 @@ public sealed class FirmamentScaffoldTests
name: demo
units: mm
- ops[{{((opName is "add" or "subtract" or "intersect" or "expect_exists" or "expect_selectable") ? 2 : 1)}}]:
+ ops[{{((opName is "add" or "subtract" or "intersect" or "expect_exists" or "expect_selectable" or "expect_manifold") ? 2 : 1)}}]:
{{payload}}
""";
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentValidationExecutionTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentValidationExecutionTests.cs
index 0a66a212..04299aa5 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentValidationExecutionTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentValidationExecutionTests.cs
@@ -1,3 +1,7 @@
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Topology;
+using Aetheris.Kernel.Firmament.Execution;
+using Aetheris.Kernel.Firmament.Lowering;
using Aetheris.Kernel.Firmament.ParsedModel;
namespace Aetheris.Kernel.Firmament.Tests;
@@ -102,16 +106,71 @@ public sealed class FirmamentValidationExecutionTests
}
[Fact]
- public void Compile_Records_Unsupported_For_ExpectManifold_At_M6a()
+ public void Compile_Executes_ExpectManifold_For_Valid_Solids()
{
- var result = CompileFixture("testdata/firmament/fixtures/m6a-unsupported-expect-manifold.firmament");
+ var result = CompileFixture("testdata/firmament/fixtures/m6d-valid-manifold.firmament");
+
+ Assert.True(result.Compilation.IsSuccess);
+ var validations = result.Compilation.Value.ValidationExecutionResult!.Validations;
+ Assert.Equal(4, validations.Count);
+ Assert.All(validations, validation =>
+ {
+ Assert.Equal(FirmamentKnownOpKind.ExpectManifold, validation.Kind);
+ Assert.True(validation.IsExecuted);
+ Assert.True(validation.IsSuccess);
+ Assert.Null(validation.Reason);
+ });
+ }
+
+ [Fact]
+ public void Compile_Rejects_SelectorShaped_Targets_For_ExpectManifold_Deterministically()
+ {
+ var result = CompileFixture("testdata/firmament/fixtures/m6d-invalid-nonmanifold.firmament");
Assert.True(result.Compilation.IsSuccess);
var validation = Assert.Single(result.Compilation.Value.ValidationExecutionResult!.Validations);
Assert.Equal(FirmamentKnownOpKind.ExpectManifold, validation.Kind);
Assert.False(validation.IsExecuted);
Assert.False(validation.IsSuccess);
- Assert.Contains("unsupported", validation.Reason, StringComparison.Ordinal);
+ Assert.Equal("expect_manifold does not support selector-shaped targets at M6d.", validation.Reason);
+ }
+
+ [Fact]
+ public void ValidationExecutor_Reports_NonManifold_Bodies_Deterministically()
+ {
+ var parsedDocument = new FirmamentParsedDocument(
+ new FirmamentParsedHeader("1"),
+ new FirmamentParsedModelHeader("demo", "mm"),
+ new FirmamentParsedOpsSection(
+ [
+ new FirmamentParsedOpEntry(
+ OpName: "expect_manifold",
+ KnownKind: FirmamentKnownOpKind.ExpectManifold,
+ Family: FirmamentOpFamily.Validation,
+ RawFields: new Dictionary<string, string>(StringComparer.Ordinal) { ["target"] = "base" },
+ ClassifiedFields: new Dictionary<string, string>(StringComparer.Ordinal) { ["targetShape"] = "FeatureId" })
+ ]),
+ HasSchema: false,
+ HasPmi: false);
+
+ var executionResult = new FirmamentPrimitiveExecutionResult(
+ ExecutedPrimitives:
+ [
+ new FirmamentExecutedPrimitive(0, "base", FirmamentLoweredPrimitiveKind.Box, BuildNonManifoldBody())
+ ],
+ ExecutedBooleans: []);
+
+ var validationExecution = FirmamentValidationExecutor.Execute(parsedDocument, executionResult);
+
+ Assert.True(validationExecution.IsSuccess);
+ var validation = Assert.Single(validationExecution.Value.Validations);
+ Assert.True(validation.IsExecuted);
+ Assert.False(validation.IsSuccess);
+ Assert.Equal("Feature 'base' produced non-manifold geometry.", validation.Reason);
+
+ var diagnostic = Assert.Single(validationExecution.Diagnostics);
+ Assert.Contains("[FIRM-REF-0009]", diagnostic.Message, StringComparison.Ordinal);
+ Assert.Contains("Feature 'base' produced non-manifold geometry.", diagnostic.Message, StringComparison.Ordinal);
}
[Fact]
@@ -142,6 +201,7 @@ ops[4]:
count: 1
-
op: expect_manifold
+ target: base
""";
var result = Compile(source);
@@ -177,6 +237,29 @@ ops[4]:
Assert.NotEmpty(result.Compilation.Value.ValidationExecutionResult!.Validations);
}
+ private static BrepBody BuildNonManifoldBody()
+ {
+ var topologyBuilder = new TopologyBuilder();
+ var v0 = topologyBuilder.AddVertex();
+ var v1 = topologyBuilder.AddVertex();
+ var edge = topologyBuilder.AddEdge(v0, v1);
+
+ var faces = new List<FaceId>();
+ for (var i = 0; i < 3; i++)
+ {
+ var loopId = topologyBuilder.AllocateLoopId();
+ var coedgeId = topologyBuilder.AllocateCoedgeId();
+ topologyBuilder.AddLoop(new Loop(loopId, [coedgeId]));
+ topologyBuilder.AddCoedge(new Coedge(coedgeId, edge, loopId, coedgeId, coedgeId, false));
+ faces.Add(topologyBuilder.AddFace([loopId]));
+ }
+
+ var shell = topologyBuilder.AddShell(faces);
+ topologyBuilder.AddBody([shell]);
+
+ return new BrepBody(topologyBuilder.Model, new BrepGeometryStore(), new BrepBindingModel());
+ }
+
private static FirmamentCompileResult CompileFixture(string fixturePath) =>
Compile(FirmamentCorpusHarness.ReadFixtureText(fixturePath));
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentValidationRequiredFieldValidationTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentValidationRequiredFieldValidationTests.cs
index 81559449..e4052ab2 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentValidationRequiredFieldValidationTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentValidationRequiredFieldValidationTests.cs
@@ -52,7 +52,7 @@ public sealed class FirmamentValidationRequiredFieldValidationTests
""");
[Fact]
- public void Compiler_Accepts_ValidExpectManifold_WithoutPayload() =>
+ public void Compiler_Accepts_ValidExpectManifold_With_FeatureTarget() =>
AssertValidationSuccess(
"""
firmament:
@@ -62,11 +62,38 @@ public sealed class FirmamentValidationRequiredFieldValidationTests
name: demo
units: mm
- ops[1]:
+ ops[2]:
+ -
+ op: box
+ id: base
+ size[3]:
+ 1
+ 1
+ 1
-
op: expect_manifold
+ target: base
""");
+
+ [Fact]
+ public void Compiler_Rejects_ExpectManifold_MissingTarget() =>
+ AssertValidationFailure(
+ """
+ firmament:
+ version: 1
+
+ model:
+ name: demo
+ units: mm
+
+ ops[1]:
+ -
+ op: expect_manifold
+ """,
+ FirmamentDiagnosticCodes.ValidationMissingRequiredField,
+ "Validation op 'expect_manifold' at index 0 is missing required field 'target'.");
+
[Fact]
public void Compiler_Rejects_ExpectExists_MissingTarget() =>
AssertValidationFailure(
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentValidationTargetFeatureExistenceTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentValidationTargetFeatureExistenceTests.cs
index 0849d77c..cac529aa 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentValidationTargetFeatureExistenceTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentValidationTargetFeatureExistenceTests.cs
@@ -206,16 +206,27 @@ model:
name: demo
units: mm
-ops[1]:
+ops[2]:
+ -
+ op: box
+ id: base
+ size[3]:
+ 1
+ 1
+ 1
-
op: expect_manifold
+ target: base
""";
var result = new FirmamentCompiler().Compile(new FirmamentCompileRequest(new FirmamentSourceDocument(source)));
Assert.True(result.Compilation.IsSuccess);
- var validationOp = result.Compilation.Value.ParsedDocument!.Ops.Entries[0];
- Assert.Null(validationOp.ClassifiedFields);
+ var validationOp = result.Compilation.Value.ParsedDocument!.Ops.Entries[1];
+ Assert.NotNull(validationOp.ClassifiedFields);
+ Assert.Equal("FeatureId", validationOp.ClassifiedFields!["targetShape"]);
+ Assert.False(validationOp.ClassifiedFields.ContainsKey("selectorResultKind"));
+ Assert.False(validationOp.ClassifiedFields.ContainsKey("selectorCardinality"));
}
[Theory]
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentValidationTargetShapeClassificationTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentValidationTargetShapeClassificationTests.cs
index 93763c6b..c043b002 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentValidationTargetShapeClassificationTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentValidationTargetShapeClassificationTests.cs
@@ -9,6 +9,8 @@ public sealed class FirmamentValidationTargetShapeClassificationTests
[InlineData("expect_exists", "base.top_face", "SelectorShaped")]
[InlineData("expect_selectable", "base", "FeatureId")]
[InlineData("expect_selectable", "mount_hole.edges", "SelectorShaped")]
+ [InlineData("expect_manifold", "base", "FeatureId")]
+ [InlineData("expect_manifold", "base.top_face", "SelectorShaped")]
public void Compiler_Classifies_ValidationTargets_BySurfaceShape(string opName, string target, string expectedShape)
{
var selectorRoot = target.Split('.', 2, StringSplitOptions.None)[0];
@@ -70,6 +72,7 @@ public sealed class FirmamentValidationTargetShapeClassificationTests
[InlineData("expect_exists", "base.top.face")]
[InlineData("expect_selectable", "base top_face")]
[InlineData("expect_selectable", "1base")]
+ [InlineData("expect_manifold", "base..top_face")]
public void Compiler_Rejects_MalformedValidationTargetShape_Deterministically(string opName, string target)
{
var source = $$"""
diff --git a/Aetheris.Kernel.Firmament/Diagnostics/FirmamentDiagnosticCodes.cs b/Aetheris.Kernel.Firmament/Diagnostics/FirmamentDiagnosticCodes.cs
index e1517ac3..b2ce9732 100644
--- a/Aetheris.Kernel.Firmament/Diagnostics/FirmamentDiagnosticCodes.cs
+++ b/Aetheris.Kernel.Firmament/Diagnostics/FirmamentDiagnosticCodes.cs
@@ -32,6 +32,7 @@ public static class FirmamentDiagnosticCodes
public static readonly FirmamentDiagnosticCode ValidationTargetSelectorPortNotAllowedForFeatureKind = new($"{FirmamentDiagnosticConventions.ReferencePrefix}-0006");
public static readonly FirmamentDiagnosticCode ValidationTargetSelectorResolvedEmpty = new($"{FirmamentDiagnosticConventions.ReferencePrefix}-0007");
public static readonly FirmamentDiagnosticCode ValidationTargetSelectableCountMismatch = new($"{FirmamentDiagnosticConventions.ReferencePrefix}-0008");
+ public static readonly FirmamentDiagnosticCode ValidationTargetNonManifoldBody = new($"{FirmamentDiagnosticConventions.ReferencePrefix}-0009");
public static readonly FirmamentDiagnosticCode SelectorPlaceholder = new($"{FirmamentDiagnosticConventions.SelectorPrefix}-0001");
public static readonly FirmamentDiagnosticCode SchemaPlaceholder = new($"{FirmamentDiagnosticConventions.SchemaPrefix}-0001");
public static readonly FirmamentDiagnosticCode LoweringPlaceholder = new($"{FirmamentDiagnosticConventions.LoweringPrefix}-0001");
diff --git a/Aetheris.Kernel.Firmament/Execution/FirmamentManifoldChecker.cs b/Aetheris.Kernel.Firmament/Execution/FirmamentManifoldChecker.cs
new file mode 100644
index 00000000..960c4947
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Execution/FirmamentManifoldChecker.cs
@@ -0,0 +1,51 @@
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Topology;
+
+namespace Aetheris.Kernel.Firmament.Execution;
+
+internal static class FirmamentManifoldChecker
+{
+ public static bool IsManifold(BrepBody body)
+ {
+ ArgumentNullException.ThrowIfNull(body);
+
+ var topology = body.Topology;
+ var edgeIncidenceCounts = new Dictionary<EdgeId, int>();
+
+ foreach (var face in topology.Faces)
+ {
+ foreach (var loopId in face.LoopIds)
+ {
+ if (!topology.TryGetLoop(loopId, out var loop) || loop is null)
+ {
+ continue;
+ }
+
+ foreach (var coedgeId in loop.CoedgeIds)
+ {
+ if (!topology.TryGetCoedge(coedgeId, out var coedge) || coedge is null)
+ {
+ continue;
+ }
+
+ edgeIncidenceCounts.TryGetValue(coedge.EdgeId, out var incidenceCount);
+ edgeIncidenceCounts[coedge.EdgeId] = incidenceCount + 1;
+ }
+ }
+ }
+
+ foreach (var edge in topology.Edges)
+ {
+ var incidenceCount = edgeIncidenceCounts.TryGetValue(edge.Id, out var count)
+ ? count
+ : 0;
+
+ if (incidenceCount != 2)
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+}
diff --git a/Aetheris.Kernel.Firmament/Execution/FirmamentValidationExecutor.cs b/Aetheris.Kernel.Firmament/Execution/FirmamentValidationExecutor.cs
index 5c7400a6..38380b33 100644
--- a/Aetheris.Kernel.Firmament/Execution/FirmamentValidationExecutor.cs
+++ b/Aetheris.Kernel.Firmament/Execution/FirmamentValidationExecutor.cs
@@ -33,13 +33,7 @@ internal static class FirmamentValidationExecutor
{
FirmamentKnownOpKind.ExpectExists => ExecuteExpectExists(index, entry, target, featureBodies, diagnostics),
FirmamentKnownOpKind.ExpectSelectable => ExecuteExpectSelectable(index, entry, target, featureBodies, diagnostics),
- FirmamentKnownOpKind.ExpectManifold => new FirmamentExecutedValidation(
- OpIndex: index,
- Kind: entry.KnownKind,
- Target: target,
- IsExecuted: false,
- IsSuccess: false,
- Reason: "expect_manifold is unsupported at M6a contract-level validation execution."),
+ FirmamentKnownOpKind.ExpectManifold => ExecuteExpectManifold(index, entry, target, featureBodies, diagnostics),
_ => new FirmamentExecutedValidation(
OpIndex: index,
Kind: entry.KnownKind,
@@ -178,6 +172,64 @@ internal static class FirmamentValidationExecutor
: $"Selector '{target}' resolved to {resolution.Count.ToString(CultureInfo.InvariantCulture)} elements but {requestedCount.ToString(CultureInfo.InvariantCulture)} were expected.");
}
+
+ private static FirmamentExecutedValidation ExecuteExpectManifold(
+ int opIndex,
+ FirmamentParsedOpEntry entry,
+ string? target,
+ IReadOnlyDictionary<string, Aetheris.Kernel.Core.Brep.BrepBody> featureBodies,
+ ICollection<KernelDiagnostic> diagnostics)
+ {
+ if (string.IsNullOrWhiteSpace(target))
+ {
+ return new FirmamentExecutedValidation(
+ OpIndex: opIndex,
+ Kind: entry.KnownKind,
+ Target: target,
+ IsExecuted: true,
+ IsSuccess: false,
+ Reason: "expect_manifold target is not executable.");
+ }
+
+ if (!IsFeatureIdTarget(entry))
+ {
+ return new FirmamentExecutedValidation(
+ OpIndex: opIndex,
+ Kind: entry.KnownKind,
+ Target: target,
+ IsExecuted: false,
+ IsSuccess: false,
+ Reason: "expect_manifold does not support selector-shaped targets at M6d.");
+ }
+
+ if (!featureBodies.TryGetValue(target, out var body))
+ {
+ return new FirmamentExecutedValidation(
+ OpIndex: opIndex,
+ Kind: entry.KnownKind,
+ Target: target,
+ IsExecuted: true,
+ IsSuccess: false,
+ Reason: $"Feature '{target}' does not have executable geometry for expect_manifold.");
+ }
+
+ var isSuccess = FirmamentManifoldChecker.IsManifold(body);
+ if (!isSuccess)
+ {
+ diagnostics.Add(CreateDiagnostic(
+ FirmamentDiagnosticCodes.ValidationTargetNonManifoldBody,
+ $"Feature '{target}' produced non-manifold geometry."));
+ }
+
+ return new FirmamentExecutedValidation(
+ OpIndex: opIndex,
+ Kind: entry.KnownKind,
+ Target: target,
+ IsExecuted: true,
+ IsSuccess: isSuccess,
+ Reason: isSuccess ? null : $"Feature '{target}' produced non-manifold geometry.");
+ }
+
private static IReadOnlyDictionary<string, Aetheris.Kernel.Core.Brep.BrepBody> BuildFeatureBodyMap(FirmamentPrimitiveExecutionResult primitiveExecutionResult)
{
var map = new Dictionary<string, Aetheris.Kernel.Core.Brep.BrepBody>(StringComparer.Ordinal);
diff --git a/Aetheris.Kernel.Firmament/FirmamentCompilationArtifact.cs b/Aetheris.Kernel.Firmament/FirmamentCompilationArtifact.cs
index 4100c038..d04e58b3 100644
--- a/Aetheris.Kernel.Firmament/FirmamentCompilationArtifact.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentCompilationArtifact.cs
@@ -5,7 +5,7 @@ using Aetheris.Kernel.Firmament.ParsedModel;
namespace Aetheris.Kernel.Firmament;
public sealed record FirmamentCompilationArtifact(
- string ArtifactKind = "firmament-topology-selectable-validation-executed",
+ string ArtifactKind = "firmament-topology-manifold-validation-executed",
FirmamentParsedDocument? ParsedDocument = null,
FirmamentPrimitiveLoweringPlan? PrimitiveLoweringPlan = null,
FirmamentPrimitiveExecutionResult? PrimitiveExecutionResult = null,
diff --git a/Aetheris.Kernel.Firmament/FirmamentCompiler.cs b/Aetheris.Kernel.Firmament/FirmamentCompiler.cs
index 18e7e3c2..592e08e2 100644
--- a/Aetheris.Kernel.Firmament/FirmamentCompiler.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentCompiler.cs
@@ -80,7 +80,7 @@ public sealed class FirmamentCompiler
return new FirmamentCompileResult(
KernelResult<FirmamentCompilationArtifact>.Success(
new FirmamentCompilationArtifact(
- ArtifactKind: "firmament-topology-selectable-validation-executed",
+ ArtifactKind: "firmament-topology-manifold-validation-executed",
ParsedDocument: validatedDocument,
PrimitiveLoweringPlan: primitiveLoweringResult.Value,
PrimitiveExecutionResult: primitiveExecutionResult.Value,
diff --git a/Aetheris.Kernel.Firmament/Properties/InternalsVisibleTo.cs b/Aetheris.Kernel.Firmament/Properties/InternalsVisibleTo.cs
new file mode 100644
index 00000000..a9cd135d
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Properties/InternalsVisibleTo.cs
@@ -0,0 +1,3 @@
+using System.Runtime.CompilerServices;
+
+[assembly: InternalsVisibleTo("Aetheris.Kernel.Firmament.Tests")]
diff --git a/Aetheris.Kernel.Firmament/Validation/FirmamentDocumentCoherenceValidator.cs b/Aetheris.Kernel.Firmament/Validation/FirmamentDocumentCoherenceValidator.cs
index 07706263..648f49aa 100644
--- a/Aetheris.Kernel.Firmament/Validation/FirmamentDocumentCoherenceValidator.cs
+++ b/Aetheris.Kernel.Firmament/Validation/FirmamentDocumentCoherenceValidator.cs
@@ -79,7 +79,7 @@ internal static class FirmamentDocumentCoherenceValidator
diagnostic = null;
enrichedEntry = null;
- if (entry.KnownKind is not (FirmamentKnownOpKind.ExpectExists or FirmamentKnownOpKind.ExpectSelectable)
+ if (entry.KnownKind is not (FirmamentKnownOpKind.ExpectExists or FirmamentKnownOpKind.ExpectSelectable or FirmamentKnownOpKind.ExpectManifold)
|| !entry.RawFields.TryGetValue("target", out var targetRaw))
{
return;
diff --git a/Aetheris.Kernel.Firmament/Validation/FirmamentValidationRequiredFieldValidator.cs b/Aetheris.Kernel.Firmament/Validation/FirmamentValidationRequiredFieldValidator.cs
index 57aa5246..68bdaf96 100644
--- a/Aetheris.Kernel.Firmament/Validation/FirmamentValidationRequiredFieldValidator.cs
+++ b/Aetheris.Kernel.Firmament/Validation/FirmamentValidationRequiredFieldValidator.cs
@@ -24,7 +24,7 @@ internal static class FirmamentValidationRequiredFieldValidator
{
FirmamentKnownOpKind.ExpectExists => ValidateExpectExists(entry, index),
FirmamentKnownOpKind.ExpectSelectable => ValidateExpectSelectable(entry, index),
- FirmamentKnownOpKind.ExpectManifold => KernelResult<bool>.Success(true),
+ FirmamentKnownOpKind.ExpectManifold => ValidateExpectManifold(entry, index),
_ => KernelResult<bool>.Success(true)
};
@@ -47,6 +47,16 @@ internal static class FirmamentValidationRequiredFieldValidator
return KernelResult<bool>.Success(true);
}
+ private static KernelResult<bool> ValidateExpectManifold(FirmamentParsedOpEntry entry, int opIndex)
+ {
+ if (!TryGetRequiredNonEmptyScalar(entry, "target", opIndex, out var missingOrTypeDiagnostic))
+ {
+ return KernelResult<bool>.Failure([missingOrTypeDiagnostic!]);
+ }
+
+ return KernelResult<bool>.Success(true);
+ }
+
private static KernelResult<bool> ValidateExpectSelectable(FirmamentParsedOpEntry entry, int opIndex)
{
if (!TryGetRequiredNonEmptyScalar(entry, "target", opIndex, out var missingOrTypeDiagnostic))
diff --git a/Aetheris.Kernel.Firmament/Validation/FirmamentValidationTargetShapeValidator.cs b/Aetheris.Kernel.Firmament/Validation/FirmamentValidationTargetShapeValidator.cs
index eb14f500..0d4cc800 100644
--- a/Aetheris.Kernel.Firmament/Validation/FirmamentValidationTargetShapeValidator.cs
+++ b/Aetheris.Kernel.Firmament/Validation/FirmamentValidationTargetShapeValidator.cs
@@ -16,7 +16,7 @@ internal static class FirmamentValidationTargetShapeValidator
for (var index = 0; index < parsedDocument.Ops.Entries.Count; index++)
{
var entry = parsedDocument.Ops.Entries[index];
- if (entry.KnownKind is not (FirmamentKnownOpKind.ExpectExists or FirmamentKnownOpKind.ExpectSelectable))
+ if (entry.KnownKind is not (FirmamentKnownOpKind.ExpectExists or FirmamentKnownOpKind.ExpectSelectable or FirmamentKnownOpKind.ExpectManifold))
{
updatedEntries.Add(entry);
continue;
diff --git a/testdata/firmament/fixtures/m0c-valid-known-validation-op.firmament b/testdata/firmament/fixtures/m0c-valid-known-validation-op.firmament
index acf55abf..d9367e8c 100644
--- a/testdata/firmament/fixtures/m0c-valid-known-validation-op.firmament
+++ b/testdata/firmament/fixtures/m0c-valid-known-validation-op.firmament
@@ -5,6 +5,14 @@ model:
name: demo
units: mm
-ops[1]:
+ops[2]:
+ -
+ op: box
+ id: base
+ size[3]:
+ 1
+ 1
+ 1
-
op: expect_manifold
+ target: base
diff --git a/testdata/firmament/fixtures/m1c-valid-expect-manifold.firmament b/testdata/firmament/fixtures/m1c-valid-expect-manifold.firmament
index acf55abf..d9367e8c 100644
--- a/testdata/firmament/fixtures/m1c-valid-expect-manifold.firmament
+++ b/testdata/firmament/fixtures/m1c-valid-expect-manifold.firmament
@@ -5,6 +5,14 @@ model:
name: demo
units: mm
-ops[1]:
+ops[2]:
+ -
+ op: box
+ id: base
+ size[3]:
+ 1
+ 1
+ 1
-
op: expect_manifold
+ target: base
diff --git a/testdata/firmament/fixtures/m6a-unsupported-expect-manifold.firmament b/testdata/firmament/fixtures/m6a-unsupported-expect-manifold.firmament
index acf55abf..0407941d 100644
--- a/testdata/firmament/fixtures/m6a-unsupported-expect-manifold.firmament
+++ b/testdata/firmament/fixtures/m6a-unsupported-expect-manifold.firmament
@@ -5,6 +5,14 @@ model:
name: demo
units: mm
-ops[1]:
+ops[2]:
+ -
+ op: box
+ id: base
+ size[3]:
+ 2
+ 2
+ 2
-
op: expect_manifold
+ target: base.top_face
diff --git a/testdata/firmament/fixtures/m6d-invalid-nonmanifold.firmament b/testdata/firmament/fixtures/m6d-invalid-nonmanifold.firmament
new file mode 100644
index 00000000..a1d91da6
--- /dev/null
+++ b/testdata/firmament/fixtures/m6d-invalid-nonmanifold.firmament
@@ -0,0 +1,18 @@
+firmament:
+ version: 1
+
+model:
+ name: demo
+ units: mm
+
+ops[2]:
+ -
+ op: box
+ id: base
+ size[3]:
+ 10
+ 10
+ 10
+ -
+ op: expect_manifold
+ target: base.top_face
diff --git a/testdata/firmament/fixtures/m6d-valid-manifold.firmament b/testdata/firmament/fixtures/m6d-valid-manifold.firmament
new file mode 100644
index 00000000..cd3bfdcc
--- /dev/null
+++ b/testdata/firmament/fixtures/m6d-valid-manifold.firmament
@@ -0,0 +1,46 @@
+firmament:
+ version: 1
+
+model:
+ name: demo
+ units: mm
+
+ops[8]:
+ -
+ op: box
+ id: base
+ size[3]:
+ 10
+ 20
+ 30
+ -
+ op: sphere
+ id: ball
+ radius: 8
+ -
+ op: cylinder
+ id: post
+ radius: 4
+ height: 12
+ -
+ op: add
+ id: join1
+ to: base
+ with:
+ op: box
+ size[3]:
+ 2
+ 2
+ 2
+ -
+ op: expect_manifold
+ target: base
+ -
+ op: expect_manifold
+ target: ball
+ -
+ op: expect_manifold
+ target: post
+ -
+ op: expect_manifold
+ target: join1