refactor(demos): build the sample machine tools with GeneralXyzabcMachineTool.CreateFromChainCode and set the buckle and axis transformers through the machine

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-18 20:23:25 +08:00
co-authored by Claude Opus 5
parent 04bffeccaf
commit 65a8cce19e
2 changed files with 9 additions and 10 deletions
+6 -7
View File
@@ -39,10 +39,11 @@ namespace Sample.MachineTool
/// <returns>A configured machine tool model.</returns> /// <returns>A configured machine tool model.</returns>
public static GeneralXyzabcMachineTool GenXyzabcMachineTool() public static GeneralXyzabcMachineTool GenXyzabcMachineTool()
{ {
CodeXyzabcChain chain = new CodeXyzabcChain("[O][Y][X][C][w];[O][Z][B][S][t]"); GeneralXyzabcMachineTool dst = GeneralXyzabcMachineTool.CreateFromChainCode(
if (chain.ToolBuckleTransformer is StaticTranslation st) "[O][Y][X][C][w];[O][Z][B][S][t]");
if (dst.ToolBuckleTransformer is StaticTranslation st)
st.Trans = new Vec3d(-72.40, 72.40, 176.44); st.Trans = new Vec3d(-72.40, 72.40, 176.44);
chain.TransformerB.Pivot = new Vec3d(-72.4, -177.4, 225.94); dst.TransformerB.Pivot = new Vec3d(-72.4, -177.4, 225.94);
Dictionary<string, Solid> solidMap = new Dictionary<string, Solid>() Dictionary<string, Solid> solidMap = new Dictionary<string, Solid>()
{ {
["O"] = new Solid(new Stl("MachineTool/base.stl")), ["O"] = new Solid(new Stl("MachineTool/base.stl")),
@@ -53,10 +54,8 @@ namespace Sample.MachineTool
["C"] = new Solid(new Stl("MachineTool/C.stl")), ["C"] = new Solid(new Stl("MachineTool/C.stl")),
["S"] = new Solid(new Stl("MachineTool/spindle.stl")), ["S"] = new Solid(new Stl("MachineTool/spindle.stl")),
}; };
chain.AnchorToSolid.BuildAnchorToSolid( dst.AnchorToSolid.BuildAnchorToSolid(
chain.Asmb.DescendantAnchors(), solidMap); dst.Asmb.DescendantAnchors(), solidMap);
GeneralXyzabcMachineTool dst = new GeneralXyzabcMachineTool(chain);
dst.GenerateCollisionIndexPairs(); dst.GenerateCollisionIndexPairs();
return dst; return dst;
} }
@@ -20,10 +20,10 @@ public static class DemoBuildMachineToolWithoutGeometrys
/// <returns>A configured but empty machine tool without solids.</returns> /// <returns>A configured but empty machine tool without solids.</returns>
public static GeneralXyzabcMachineTool GenEmptyMachineTool() public static GeneralXyzabcMachineTool GenEmptyMachineTool()
{ {
CodeXyzabcChain chain = new CodeXyzabcChain("[O][C][w];[O][X][Y][Z][B][S][t]"); GeneralXyzabcMachineTool xyzabcMachineTool = GeneralXyzabcMachineTool.CreateFromChainCode(
if (chain.ToolBuckleTransformer is StaticTranslation st) "[O][C][w];[O][X][Y][Z][B][S][t]");
if (xyzabcMachineTool.ToolBuckleTransformer is StaticTranslation st)
st.Trans = new Vec3d(-200, 200, 400); st.Trans = new Vec3d(-200, 200, 400);
GeneralXyzabcMachineTool xyzabcMachineTool = new GeneralXyzabcMachineTool(chain);
return xyzabcMachineTool; return xyzabcMachineTool;
} }
} }