refactor(Sample): adapt demos to XFactory IProgress<object> signature

Made-with: Cursor
This commit is contained in:
iamboss 2026-04-11 11:19:36 +08:00
parent e5ea1961a5
commit dd4c3ef28f
4 changed files with 78 additions and 76 deletions

View File

@ -1,4 +1,4 @@
using Hi.Common.XmlUtils;
using Hi.Common.XmlUtils;
using Hi.Geom;
using Hi.Mech;
using Hi.Mech.Topo;
@ -25,7 +25,7 @@ namespace Sample.MachineTool
{
static DemoBuildMachineTool()
{
XFactory.Regs.Add(XName, (xml, baseDirectory, relFile, res) => new DemoBuildMachineTool());
XFactory.Regs.Add(XName, (xml, baseDirectory, relFile, progress, res) => new DemoBuildMachineTool());
}
/// <summary>
/// Generates an XYZ-ABC machine tool instance from embedded resources.

View File

@ -1,4 +1,4 @@
using Hi.Common.XmlUtils;
using Hi.Common.XmlUtils;
using Hi.Geom;
using Hi.MachiningProcs;
using Hi.Mech.Topo;
@ -83,9 +83,10 @@ public static class DemoBuildGeomOnlyMachiningProject
WorkpieceGeomToFixtureBuckleTransformer = new StaticTranslation(new Vec3d(0, 0, 0)),
};
IProgress<object> progress = null;
localProjectService.MachiningChain
= XFactory.GenByFile<CodeXyzabcMachineTool>(
"Resource", "MachineTool/PMC-B1/PMC-B1.mt", GenMode.Default);
"Resource", "MachineTool/PMC-B1/PMC-B1.mt", progress);
localProjectService.MachiningChainFile = "PMC-B1/PMC-B1.mt";
localProjectService.SaveProject();

View File

@ -1,4 +1,4 @@
using System;
using System;
using Hi.Milling.Apts;
using Hi.Common.XmlUtils;
using Hi.Geom;
@ -152,6 +152,8 @@ public static class DemoBuildMachiningProject
localProjectService.LoadProject(projectPath);
MachiningProject machiningProject = localProjectService.MachiningProject;
IProgress<object> progress = null;
#region ConfigureMachiningToolHouse
localProjectService.MachiningToolHouse = new MachiningToolHouse()
{
@ -195,16 +197,16 @@ public static class DemoBuildMachiningProject
IdealGeom = null,
WorkpieceGeomToFixtureBuckleTransformer = new StaticTranslation(new Vec3d(0, 0, 0)),
CuttingPara = XFactory.GenByFile<ICuttingPara>(
"Resource/CuttingParameter", "Al6061T6.mp", GenMode.Default),
"Resource/CuttingParameter", "Al6061T6.mp", progress),
WorkpieceMaterial = XFactory.GenByFile<WorkpieceMaterial>(
"Resource/WorkpieceMaterial", "Al6061T6.WorkpieceMaterial", GenMode.Default),
"Resource/WorkpieceMaterial", "Al6061T6.WorkpieceMaterial", progress),
};
#endregion
#region ConfigureMachineChain
localProjectService.MachiningChain
= XFactory.GenByFile<CodeXyzabcMachineTool>(
"Resource", "MachineTool/PMC-B1/PMC-B1.mt", GenMode.Default);
"Resource", "MachineTool/PMC-B1/PMC-B1.mt", progress);
#endregion
machiningProject.MakeXmlSourceToFile(projectPath);

View File

@ -4,24 +4,24 @@ using Hi.Disp;
using Hi.Geom;
using Hi.Mech.Topo;
namespace Sample.Mech
namespace Sample.Mech;
/// <summary>
/// Demonstrates the creation and visualization of mechanical assemblies with kinematic linkages.
/// Shows how to build coordinate systems, establish kinematic relationships, and capture visual output.
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Mech/DemoTopo1.cs)]
/// </remarks>
public static class DemoTopo1
{
/// <summary>
/// Demonstrates the creation and visualization of mechanical assemblies with kinematic linkages.
/// Shows how to build coordinate systems, establish kinematic relationships, and capture visual output.
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Mech/DemoTopo1.cs)]
/// </remarks>
public static class DemoTopo1
{
/// <summary>
/// Creates a demonstration assembly with kinematic linkages.
/// Builds a mechanical assembly with multiple anchors and branches, including both static and dynamic transformations.
/// </summary>
/// <returns>A tuple containing the assembly and root anchor</returns>
static (Asmb asmb,Anchor root) GetDemoAsmb()
static (Asmb asmb, Anchor root) GetDemoAsmb()
{
#region DocSite.DemoTopo1
//build coordinate systems and the assembly.
@ -50,7 +50,7 @@ namespace Sample.Mech
Console.WriteLine($"{keyValue.Key.Name} : {keyValue.Value}");
#endregion
return (asmb,O);
return (asmb, O);
}
/// <summary>
@ -78,5 +78,4 @@ namespace Sample.Mech
{
SnapshotToFile(GetDemoAsmb());
}
}
}