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<CodeXyzabcMachineTool> call sites are fixed rather than
merely renamed: they read Resource machine tools rooted at
<GeneralXyzabcMachineTool>, 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) <noreply@anthropic.com>
This commit is contained in:
2026-08-28 19:57:54 +08:00
co-authored by Claude Opus 5
parent 7ed5372805
commit 7beb671352
4 changed files with 17 additions and 11 deletions
+13 -7
View File
@@ -21,7 +21,7 @@ namespace Sample.MachineTool
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/MachineTool/DemoBuildMachineTool.cs)]
/// </remarks>
public class DemoBuildMachineTool : IGetCodeXyzabcMachineTool
public class DemoBuildMachineTool
{
/// <summary>
/// Registers this type's deserializer with the given <see cref="XFactory"/>
@@ -37,7 +37,7 @@ namespace Sample.MachineTool
/// Generates an XYZ-ABC machine tool instance from embedded resources.
/// </summary>
/// <returns>A configured machine tool model.</returns>
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
/// <summary>
/// The cached machine tool instance.
/// </summary>
CodeXyzabcMachineTool MachineTool { get; }
GeneralXyzabcMachineTool MachineTool { get; }
/// <summary>
/// Default constructor that initializes the machine tool model.
@@ -81,9 +81,15 @@ namespace Sample.MachineTool
/// <inheritdoc/>
public XElement ToXElement() => new XElement(XName);
#endregion
/// <inheritdoc/>
public CodeXyzabcMachineTool GetXyzabcMachineTool() => MachineTool;
/// <inheritdoc/>
/// <summary>
/// Gets the built machine tool.
/// </summary>
/// <returns>Machine tool.</returns>
public GeneralXyzabcMachineTool GetXyzabcMachineTool() => MachineTool;
/// <summary>
/// Gets the machine tool as a machining chain.
/// </summary>
/// <returns>Machining chain.</returns>
public IMachiningChain GetMachiningChain() => MachineTool;
}
}
@@ -18,12 +18,12 @@ public static class DemoBuildMachineToolWithoutGeometrys
/// Generates an empty machine tool with basic configuration.
/// </summary>
/// <returns>A configured but empty machine tool without solids.</returns>
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;
}
}
@@ -86,7 +86,7 @@ public static class DemoBuildGeomOnlyMachiningProject
IProgress<object> progress = null;
localProjectService.MachiningChain
= XFactory.GenByFile<CodeXyzabcMachineTool>(
= XFactory.GenByFile<GeneralXyzabcMachineTool>(
"Resource", "MachineTool/Table-B1.default/Table-B1.mt", progress);
localProjectService.MachiningChainFile = "Table-B1.default/Table-B1.mt";
+1 -1
View File
@@ -206,7 +206,7 @@ public static class DemoBuildMachiningProject
#region ConfigureMachineChain
localProjectService.MachiningChain
= XFactory.GenByFile<CodeXyzabcMachineTool>(
= XFactory.GenByFile<GeneralXyzabcMachineTool>(
"Resource", "MachineTool/Table-B1.default/Table-B1.mt", progress);
#endregion