Class Workpiece
- Namespace
- Hi.NcMech.Workpieces
- Assembly
- HiMech.dll
Workpiece configuration data model: a mechanism that owns its key assembly and root anchor and names which of its own anchors play the workpiece's three roles — FixtureMount, where the fixture (or the machine's worktable end) attaches; ProgramZeroAnchor, the frame the NC program is written in; and GeomAnchor, the frame the stock geometry is given in. The topology between them is free; the solid dictionary stays empty, as the meshed geometry belongs to WorkpieceService.
CreateDefault() makes the shape every workpiece had before
the topology became free: the root anchor is the fixture mount, and one
zero StaticTranslation branch leads from the geometry anchor
to it and one to the program-zero anchor. A file without an embedded
topology (no <Asmb>) seeds that shape and applies its legacy
transformer elements — WorkpieceGeomToProgramZeroTransformer (or the
inverse-read ProgramZeroToWorkpieceGeomTransformer) and
WorkpieceGeomToFixtureBuckleTransformer (or the composed
FixtureBuckleToProgramZeroTransformer / FixtureToGeomTransformer /
WorkpieceBuckleToGeomZeroTranslation) — onto its branches; writing
always embeds the topology (MechanismXml) and names the
three roles by anchor Guid.
A role is a reference the workpiece checks for one thing only — the
anchor is inside its assembly — so a workpiece can be built in any order
and live in any incomplete form (a role unbound) without an exception;
whether it is complete is judged where it matters: the equipment
attaches only the bound roles, the run start names a missing one
(RequireWorkpieceOnTheMachine), the web editor lists what is
missing.
public class Workpiece : IMechanism, ITopo, IGetAsmb, IGetAnchor, IGetTopoIndex, IGetAnchoredDisplayeeList, IGetAnchorToSolidDictionary, IGetCuttingPara, IMakeXmlSource
- Inheritance
-
Workpiece
- Implements
- Inherited Members
- Extension Methods
Remarks
Workpiece holds the persistent/serializable configuration. Meshed geometry, caching, diff calculation, defect scanning, display and collision are managed by WorkpieceService.
Constructors
Workpiece()
Initializes an empty workpiece: an assembly named
DefaultAsmbName holding only the root anchor O, no
role bound. Build the topology on it, or start from
CreateDefault().
public Workpiece()
Workpiece(XElement, string, string, IProgress<IMessage>)
Initializes a new instance of the Workpiece class from
XML: the embedded topology and roles when the element carries
<Asmb>, otherwise the default shape with the legacy
transformer elements applied to its branches.
public Workpiece(XElement src, string baseDirectory, string relFile, IProgress<IMessage> progress)
Parameters
srcXElementXML element source.
baseDirectorystringBase directory.
relFilestringRelative file path.
progressIProgress<IMessage>Progress reporter for diagnostic messages emitted during construction.
Fields
DefaultAsmbName
The name of the key assembly of a workpiece made by Workpiece() or CreateDefault().
public const string DefaultAsmbName = "Workpiece"
Field Value
DefaultDiffVisualRadius_mm
DiffVisualRadius_mm of a project file that carries none (files saved before the setting became project-level).
public const double DefaultDiffVisualRadius_mm = 0.1
Field Value
DefaultInitResolution_mm
The initial resolution of a workpiece that has none set, in mm: 0.125 (grid level 20).
public const double DefaultInitResolution_mm = 0.125
Field Value
Properties
AnchorToSolid
The solid dictionary of the mechanism contract — empty: the meshed geometry is WorkpieceService's.
public Dictionary<Anchor, Solid> AnchorToSolid { get; }
Property Value
Asmb
The key assembly holding every anchor and branch of the workpiece.
public Asmb Asmb { get; }
Property Value
CollidableName
Collidable name.
public string CollidableName { get; }
Property Value
CuttingPara
Milling parameters.
public ICuttingPara CuttingPara { get; set; }
Property Value
CuttingParaFile
File path for milling parameters.
public string CuttingParaFile { get; set; }
Property Value
DiffVisualRadius_mm
Colour-scale radius (mm) of the ideal-vs-machined difference overlay: a
deviation of this size or more saturates the diff colouring. A project
setting, not a session one — every snapshot of one part is read against
the same criterion — and independent of the detection radius the last
Diff ran with (above it the scale simply never saturates). Finite
and positive: at zero floor and ceiling coincide and the colour rule
degenerates.
public double DiffVisualRadius_mm { get; set; }
Property Value
FixtureMount
The anchor the fixture's workpiece mount (or, with no fixture, the machine's worktable end) attaches to; null when unbound. Assign any anchor of Asmb, or null, at any point of building the topology (see the completeness remarks on the class).
public Anchor FixtureMount { get; set; }
Property Value
Exceptions
- ArgumentException
The anchor is not inside Asmb.
GeomAnchor
Anchor of the workpiece geometry — the frame InitGeom and IdealGeom are given in; null when unbound. As FixtureMount.
public Anchor GeomAnchor { get; set; }
Property Value
Exceptions
- ArgumentException
The anchor is not inside Asmb.
IdealGeom
Ideal geometry representation.
public IGetStl IdealGeom { get; set; }
Property Value
InitGeom
Raw geometry for initiate.
public IMakeXmlSource InitGeom { get; set; }
Property Value
InitResolution
Resolution for initialization.
public double InitResolution { get; set; }
Property Value
ProgramZeroAnchor
Anchor of program zero — the frame the NC program and the cutter locations are given in; null when unbound. As FixtureMount.
public Anchor ProgramZeroAnchor { get; set; }
Property Value
Exceptions
- ArgumentException
The anchor is not inside Asmb.
Root
The root anchor the workpiece is placed and drawn from.
public Anchor Root { get; }
Property Value
WorkpieceMaterial
Workpiece material.
public WorkpieceMaterial WorkpieceMaterial { get; set; }
Property Value
WorkpieceMaterialFile
File path for workpiece material.
public string WorkpieceMaterialFile { get; set; }
Property Value
XName
Name for XML IO.
public static string XName { get; }
Property Value
Methods
CreateDefault()
Creates a workpiece in the default shape: the root anchor, named and bound as FixtureMount; ProgramZeroAnchor and GeomAnchor; and from the geometry anchor one zero StaticTranslation branch to each of the other two (each branch named after the anchor it reaches).
public static Workpiece CreateDefault()
Returns
- Workpiece
The new workpiece.
GetAnchor()
Get key anchor. (i.e. root anchor)
public Anchor GetAnchor()
Returns
- Anchor
key anchor
GetAnchorToSolidDictionary()
public Dictionary<Anchor, Solid> GetAnchorToSolidDictionary()
Returns
- Dictionary<Anchor, Solid>
A dictionary where keys are anchors and values are their associated solids.
GetAsmb()
Gets the key asmb.
public Asmb GetAsmb()
Returns
- Asmb
The key asmb.
GetCuttingPara()
Get ICuttingPara.
public ICuttingPara GetCuttingPara()
Returns
IsGeomToProgramZeroStatic()
Whether the branch chain from GeomAnchor to ProgramZeroAnchor exists and carries no dynamic transformer, so TryGetGeomToProgramZeroMat4d(out mat4d_t) holds for a whole play. False when a role is unbound or the two are not connected.
public bool IsGeomToProgramZeroStatic()
Returns
- bool
true when the chain exists and is static.
LicensedDefaultResolution_mm(double)
The resolution a new project or a newly added Machining Resolution command is written with: the coarser of
DefaultInitResolution_mm and the width the licence allows a workpiece of
referenceSize_mm (LicenseCaps.LicensedGridWidth_mm: reference / N taken to the
coarser ladder rung; the ladder's finest width with no cap or no reference, so the plain default then). A
value the user never chose must not be clamped with a warning on every new project; a value already in a
project is clamped where it is used, with the warning, and is not rewritten.
public static double LicensedDefaultResolution_mm(double referenceSize_mm)
Parameters
referenceSize_mmdoubleThe longest side of the workpiece geometry's bounding box; 0 when unknown.
Returns
- double
The default initial / machining resolution in mm.
MakeXmlSource(string, string, bool)
Writes the scalar configuration, the topology in one MechanismXml section (every transformer inside its branch), the three roles as anchor references, and the geometry, parameter and material references.
public XElement MakeXmlSource(string baseDirectory, string relFile, bool exhibitionOnly)
Parameters
baseDirectorystringThe base directory for resolving relative paths
relFilestringThe relative file path for the XML source
exhibitionOnlyboolif true, the extended file creation is suppressed.
Returns
- XElement
An XML element representing the object's state
Remarks
For the demand of easy moving source folder (especially project folder) without configuration file path corruption, the relative file path is applied.
The baseDirectory is typically the folder at the nearest configuration file folder.
Since the folder can be moving with the configuration file.
Reg(XFactory)
Registers this type's deserializer with the given XFactory
and chains Reg(factory) on dependents. Idempotent.
public static void Reg(XFactory factory = null)
Parameters
factoryXFactory
TryGetFixtureToProgramZeroMat4d(out mat4d_t)
Matrix transformation from FixtureMount to ProgramZeroAnchor through the workpiece's own branches.
public bool TryGetFixtureToProgramZeroMat4d(out mat4d_t mat)
Parameters
matmat4d_tThe matrix, when the method returns true.
Returns
- bool
False when a role is unbound or the two are not connected.
TryGetGeomToProgramZeroMat4d(out mat4d_t)
Matrix transformation from GeomAnchor to ProgramZeroAnchor through the workpiece's own branches. The play reads it once at its start (see IsGeomToProgramZeroStatic()).
public bool TryGetGeomToProgramZeroMat4d(out mat4d_t mat)
Parameters
matmat4d_tThe matrix, when the method returns true.
Returns
- bool
False when a role is unbound or the two are not connected.