Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Fix CIR tool local-frame placement and slot fixture span

Yuechen Li93df1abd8606
diff --git a/Aetheris.Kernel.Firmament/Lowering/FirmamentCirLowerer.cs b/Aetheris.Kernel.Firmament/Lowering/FirmamentCirLowerer.cs
index d39027a1..38d0f34f 100644
--- a/Aetheris.Kernel.Firmament/Lowering/FirmamentCirLowerer.cs
+++ b/Aetheris.Kernel.Firmament/Lowering/FirmamentCirLowerer.cs
@@ -49,6 +49,7 @@ internal static class FirmamentCirLowerer
continue;
}
+ rhs = ApplyDefaultToolLocalFrame(boolean.Tool, rhs);
rhs = ApplyPlacement(rhs, boolean.Placement, boolean.OpIndex, boolean.FeatureId, nodesByFeature, diagnostics);
var composed = boolean.Kind switch
{
@@ -130,6 +131,44 @@ internal static class FirmamentCirLowerer
return new CirBoxNode(parts[0], parts[1], parts[2]);
}
+ private static CirNode ApplyDefaultToolLocalFrame(FirmamentLoweredToolOp tool, CirNode node)
+ {
+ var zShift = ResolveDefaultToolFrameZShift(tool);
+ if (!zShift.HasValue || Math.Abs(zShift.Value) <= 1e-12d)
+ {
+ return node;
+ }
+
+ return new CirTransformNode(node, Transform3D.CreateTranslation(new Vector3D(0d, 0d, zShift.Value)));
+ }
+
+ private static double? ResolveDefaultToolFrameZShift(FirmamentLoweredToolOp tool)
+ {
+ if (string.Equals(tool.OpName, "box", StringComparison.Ordinal)
+ && tool.RawFields.TryGetValue("size", out var boxSizeRaw)
+ && !string.IsNullOrWhiteSpace(boxSizeRaw))
+ {
+ var box = FirmamentPrimitiveToolParsing.ParseBox(boxSizeRaw);
+ return box.SizeZ * 0.5d;
+ }
+
+ if (string.Equals(tool.OpName, "cylinder", StringComparison.Ordinal)
+ && tool.RawFields.TryGetValue("height", out var cylinderHeightRaw)
+ && !string.IsNullOrWhiteSpace(cylinderHeightRaw))
+ {
+ return FirmamentPrimitiveToolParsing.ParseScalar(cylinderHeightRaw) * 0.5d;
+ }
+
+ if (string.Equals(tool.OpName, "cone", StringComparison.Ordinal)
+ && tool.RawFields.TryGetValue("height", out var coneHeightRaw)
+ && !string.IsNullOrWhiteSpace(coneHeightRaw))
+ {
+ return FirmamentPrimitiveToolParsing.ParseScalar(coneHeightRaw) * 0.5d;
+ }
+
+ return null;
+ }
+
private static CirNode ApplyPlacement(CirNode node, FirmamentLoweredPlacement? placement, int opIndex, string featureId, IReadOnlyDictionary<string, CirNode> loweredFeatures, List<CirLoweringDiagnostic> diagnostics)
{
if (placement is null)
diff --git a/testdata/firmament/examples/composed_part_with_slot.firmament b/testdata/firmament/examples/composed_part_with_slot.firmament
index d3bd7b92..0b4c88f2 100644
--- a/testdata/firmament/examples/composed_part_with_slot.firmament
+++ b/testdata/firmament/examples/composed_part_with_slot.firmament
@@ -19,11 +19,11 @@ ops[2]:
op: slot_cut
length: 16
width: 8
- height: 10
+ height: 20
corner_radius: 4
place:
on: origin
offset[3]:
0
0
- -5
+ -10