From 7beb6713528e1357c0ed45cbbf15faff2dde822d Mon Sep 17 00:00:00 2001 From: iamboss Date: Fri, 28 Aug 2026 19:57:54 +0800 Subject: [PATCH] refactor(demos): build sample machine tools as GeneralXyzabcMachineTool Follows the CodeXyzabcMachineTool retirement in HiMech. DemoBuildMachineTool drops IGetCodeXyzabcMachineTool, which no longer exists, and spells out the doc comments the inherited interface used to supply. The two GenByFile call sites are fixed rather than merely renamed: they read Resource machine tools rooted at , so the factory's `as` cast handed back null and the demo project got no machining chain at all. Co-Authored-By: Claude Opus 5 (1M context) --- MachineTool/DemoBuildMachineTool.cs | 20 ++++++++++++------- .../DemoBuildMachineToolWithoutGeometrys.cs | 4 ++-- .../DemoBuildGeomOnlyMachiningProject.cs | 2 +- Machining/DemoBuildMachiningProject.cs | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/MachineTool/DemoBuildMachineTool.cs b/MachineTool/DemoBuildMachineTool.cs index ecc3457..a95e53a 100644 --- a/MachineTool/DemoBuildMachineTool.cs +++ b/MachineTool/DemoBuildMachineTool.cs @@ -21,7 +21,7 @@ namespace Sample.MachineTool /// ### Source Code /// [!code-csharp[SampleCode](~/../Hi.Sample/MachineTool/DemoBuildMachineTool.cs)] /// - public class DemoBuildMachineTool : IGetCodeXyzabcMachineTool + public class DemoBuildMachineTool { /// /// Registers this type's deserializer with the given @@ -37,7 +37,7 @@ namespace Sample.MachineTool /// Generates an XYZ-ABC machine tool instance from embedded resources. /// /// A configured machine tool model. - public static CodeXyzabcMachineTool GenXyzabcMachineTool() + public static GeneralXyzabcMachineTool GenXyzabcMachineTool() { CodeXyzabcChain chain = new CodeXyzabcChain("[O][Y][X][C][w];[O][Z][B][S][t]"); if (chain.ToolBuckleTransformer is StaticTranslation st) @@ -56,7 +56,7 @@ namespace Sample.MachineTool chain.AnchorToSolid.BuildAnchorToSolid( chain.Asmb.GetDescendantAnchors(), solidMap); - CodeXyzabcMachineTool dst = new CodeXyzabcMachineTool(chain); + GeneralXyzabcMachineTool dst = new GeneralXyzabcMachineTool(chain); dst.GenerateCollisionIndexPairs(); return dst; } @@ -64,7 +64,7 @@ namespace Sample.MachineTool /// /// The cached machine tool instance. /// - CodeXyzabcMachineTool MachineTool { get; } + GeneralXyzabcMachineTool MachineTool { get; } /// /// Default constructor that initializes the machine tool model. @@ -81,9 +81,15 @@ namespace Sample.MachineTool /// public XElement ToXElement() => new XElement(XName); #endregion - /// - public CodeXyzabcMachineTool GetXyzabcMachineTool() => MachineTool; - /// + /// + /// Gets the built machine tool. + /// + /// Machine tool. + public GeneralXyzabcMachineTool GetXyzabcMachineTool() => MachineTool; + /// + /// Gets the machine tool as a machining chain. + /// + /// Machining chain. public IMachiningChain GetMachiningChain() => MachineTool; } } diff --git a/MachineTool/DemoBuildMachineToolWithoutGeometrys.cs b/MachineTool/DemoBuildMachineToolWithoutGeometrys.cs index 37adc5a..d813812 100644 --- a/MachineTool/DemoBuildMachineToolWithoutGeometrys.cs +++ b/MachineTool/DemoBuildMachineToolWithoutGeometrys.cs @@ -18,12 +18,12 @@ public static class DemoBuildMachineToolWithoutGeometrys /// Generates an empty machine tool with basic configuration. /// /// A configured but empty machine tool without solids. - public static CodeXyzabcMachineTool GenEmptyMachineTool() + public static GeneralXyzabcMachineTool GenEmptyMachineTool() { CodeXyzabcChain chain = new CodeXyzabcChain("[O][C][w];[O][X][Y][Z][B][S][t]"); if (chain.ToolBuckleTransformer is StaticTranslation st) st.Trans = new Vec3d(-200, 200, 400); - CodeXyzabcMachineTool xyzabcMachineTool = new CodeXyzabcMachineTool(chain); + GeneralXyzabcMachineTool xyzabcMachineTool = new GeneralXyzabcMachineTool(chain); return xyzabcMachineTool; } } diff --git a/Machining/DemoBuildGeomOnlyMachiningProject.cs b/Machining/DemoBuildGeomOnlyMachiningProject.cs index 5c3dd89..4241418 100644 --- a/Machining/DemoBuildGeomOnlyMachiningProject.cs +++ b/Machining/DemoBuildGeomOnlyMachiningProject.cs @@ -86,7 +86,7 @@ public static class DemoBuildGeomOnlyMachiningProject IProgress progress = null; localProjectService.MachiningChain - = XFactory.GenByFile( + = XFactory.GenByFile( "Resource", "MachineTool/Table-B1.default/Table-B1.mt", progress); localProjectService.MachiningChainFile = "Table-B1.default/Table-B1.mt"; diff --git a/Machining/DemoBuildMachiningProject.cs b/Machining/DemoBuildMachiningProject.cs index 1344537..1912e03 100644 --- a/Machining/DemoBuildMachiningProject.cs +++ b/Machining/DemoBuildMachiningProject.cs @@ -206,7 +206,7 @@ public static class DemoBuildMachiningProject #region ConfigureMachineChain localProjectService.MachiningChain - = XFactory.GenByFile( + = XFactory.GenByFile( "Resource", "MachineTool/Table-B1.default/Table-B1.mt", progress); #endregion