Table of Contents

Class DemoBuildMachineTool

Namespace
Sample.MachineTool
Assembly
Hi.Sample.dll

Provides access to the PMC-B1 machine tool model.

public class DemoBuildMachineTool : IGetCodeXyzabcMachineTool
Inheritance
DemoBuildMachineTool
Implements
Inherited Members

Remarks

Source Code

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>
    /// <remarks>
    /// ### Source Code
    /// [!code-csharp[SampleCode](~/../Hi.Sample/MachineTool/DemoBuildMachineTool.cs)]
    /// </remarks>
    public class DemoBuildMachineTool : IGetCodeXyzabcMachineTool
    {
        static DemoBuildMachineTool()
        {
            XFactory.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;
    }
}

Constructors

DemoBuildMachineTool()

Default constructor that initializes the machine tool model.

public DemoBuildMachineTool()

Fields

XName

XML element name for serialization.

public static string XName

Field Value

string

Methods

GenXyzabcMachineTool()

Generates an XYZ-ABC machine tool instance from embedded resources.

public static CodeXyzabcMachineTool GenXyzabcMachineTool()

Returns

CodeXyzabcMachineTool

A configured machine tool model.

GetMachiningChain()

public IMachiningChain GetMachiningChain()

Returns

IMachiningChain

GetXyzabcMachineTool()

public CodeXyzabcMachineTool GetXyzabcMachineTool()

Returns

CodeXyzabcMachineTool

Machine tool.

ToXElement()

public XElement ToXElement()

Returns

XElement