re-init
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using Hi.Geom;
|
||||
using Hi.Mech.Topo;
|
||||
using Hi.NcMech.Xyzabc;
|
||||
using Hi.Numerical.Xyzabc;
|
||||
|
||||
namespace Sample.MachineTool
|
||||
{
|
||||
/// <summary>
|
||||
/// Demo generating empty machine tool instances for testing or development.
|
||||
/// </summary>
|
||||
public static class DemoBuildEmptyMachineTool
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates an empty machine tool with basic configuration.
|
||||
/// </summary>
|
||||
/// <returns>A configured but empty machine tool without solids.</returns>
|
||||
public static CodeXyzabcMachineTool 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);
|
||||
return xyzabcMachineTool;
|
||||
}
|
||||
/// <summary>
|
||||
/// Generates and saves an empty machine tool URI to a file.
|
||||
/// </summary>
|
||||
/// <param name="baseDirectory">The base directory to save the machine tool file.</param>
|
||||
/// <returns>The machine tool URI object that was created and saved.</returns>
|
||||
public static CodeXyzabcMachineToolUri GenEmptyMachineToolUri(string baseDirectory)
|
||||
{
|
||||
CodeXyzabcMachineToolUri machineToolUri = new CodeXyzabcMachineToolUri(@"Samples/EmpytMachineTool.mt",
|
||||
GenEmptyMachineTool());
|
||||
machineToolUri.SaveToUri(baseDirectory);
|
||||
return machineToolUri;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
using Hi.Common.XmlUtils;
|
||||
using Hi.Geom;
|
||||
using Hi.Mech;
|
||||
using Hi.Mech.Topo;
|
||||
using Hi.NcMech;
|
||||
using Hi.NcMech.Solids;
|
||||
using Hi.NcMech.Xyzabc;
|
||||
using Hi.Numerical.Xyzabc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Sample.MachineTool
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to the PMC-B1 machine tool model.
|
||||
/// </summary>
|
||||
public class DemoBuildMachineTool : IGetCodeXyzabcMachineTool
|
||||
{
|
||||
static DemoBuildMachineTool()
|
||||
{
|
||||
XFactory.Default.Regs.Add(XName, (xml, baseDirectory, relFile, res) => new DemoBuildMachineTool());
|
||||
}
|
||||
/// <summary>
|
||||
/// Generates an XYZ-ABC machine tool instance from embedded resources.
|
||||
/// </summary>
|
||||
/// <returns>A configured machine tool model.</returns>
|
||||
public static CodeXyzabcMachineTool GenXyzabcMachineTool()
|
||||
{
|
||||
CodeXyzabcChain chain = new CodeXyzabcChain("[O][Y][X][C][w];[O][Z][B][S][t]");
|
||||
if (chain.ToolBuckleTransformer is StaticTranslation st)
|
||||
st.Trans = new Vec3d(-72.40, 72.40, 176.44);
|
||||
chain.TransformerB.Pivot = new Vec3d(-72.4, -177.4, 225.94);
|
||||
Dictionary<string, Solid> solidMap = new Dictionary<string, Solid>()
|
||||
{
|
||||
["O"] = new Solid(new Stl("MachineTool/base.stl")),
|
||||
["X"] = new Solid(new Stl("MachineTool/X.stl")),
|
||||
["Y"] = new Solid(new Stl("MachineTool/Y.stl")),
|
||||
["Z"] = new Solid(new Stl("MachineTool/Z.stl")),
|
||||
["B"] = new Solid(new Stl("MachineTool/B.stl")),
|
||||
["C"] = new Solid(new Stl("MachineTool/C.stl")),
|
||||
["S"] = new Solid(new Stl("MachineTool/spindle.stl")),
|
||||
};
|
||||
chain.AnchorToSolid.BuildAnchorToSolid(
|
||||
chain.Asmb.GetDescendantAnchors(), solidMap);
|
||||
|
||||
CodeXyzabcMachineTool dst = new CodeXyzabcMachineTool(chain);
|
||||
dst.GenerateCollisionIndexPairs();
|
||||
return dst;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The cached machine tool instance.
|
||||
/// </summary>
|
||||
CodeXyzabcMachineTool MachineTool { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor that initializes the machine tool model.
|
||||
/// </summary>
|
||||
public DemoBuildMachineTool()
|
||||
{
|
||||
MachineTool = GenXyzabcMachineTool();
|
||||
}
|
||||
#region XML IO
|
||||
//public PmcB1MachineToolSource(XElement src, object res) : this() { }
|
||||
/// <summary>
|
||||
/// XML element name for serialization.
|
||||
/// </summary>
|
||||
public static string XName = nameof(DemoBuildMachineTool);
|
||||
/// <inheritdoc/>
|
||||
public XElement ToXElement() => new XElement(XName);
|
||||
#endregion
|
||||
/// <inheritdoc/>
|
||||
public CodeXyzabcMachineTool GetXyzabcMachineTool() => MachineTool;
|
||||
/// <inheritdoc/>
|
||||
public IMachiningChain GetMachiningChain() => MachineTool;
|
||||
/// <inheritdoc/>
|
||||
public ISolidMachiningChain GetSolidMachiningChain() => MachineTool;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user