Table of Contents

Class WorkpieceService

Namespace
Hi.NcMech.Workpieces
Assembly
HiMech.dll

Runtime service for Workpiece.

public class WorkpieceService : IDisplayee, IExpandToBox3d, IDisposable, IGetAnchoredDisplayeeList, IAnchoredCollidableLeaf, IAnchoredCollidableNode, IAnchoredCollidableBased, ICollidable
Inheritance
WorkpieceService
Implements
Inherited Members
Extension Methods

Remarks

WorkpieceService handles meshed geometry, caching, diff calculation, defect scanning, display and collision — state that does not require configuration IO. Compare to Workpiece, which holds the persistent/serializable configuration.

Constructors

WorkpieceService(Func<Workpiece>, Func<string>)

Ctor.

public WorkpieceService(Func<Workpiece> workpieceGetter, Func<string> baseDirectoryGetter = null)

Parameters

workpieceGetter Func<Workpiece>
baseDirectoryGetter Func<string>

Properties

BaseDirectoryGetter

Provides the base directory that relative file paths in this service resolve against (injected by the owning project service); when null, paths are used as-is.

public Func<string> BaseDirectoryGetter { get; }

Property Value

Func<string>

BottomResolution

Resolution.

public double BottomResolution { get; }

Property Value

double

CollidableName

Gets the name of the collidable object.

public string CollidableName { get; }

Property Value

string

CollisionFlag

Gets or sets the collision flag.

public CollisionFlag CollisionFlag { get; set; }

Property Value

CollisionFlag

ConstructionDefectDisplayee

Construction defect displayee.

public ConstructionDefectDisplayee ConstructionDefectDisplayee { get; }

Property Value

ConstructionDefectDisplayee

DetectionRadius_mm

Detection radius in millimeters last used by Diff(double, CancellationToken, IProgress<IMessage>). It is set by that runtime call (e.g. from a session / mission command), not by display callers, and saved on the service so consumers (e.g. the web UI) can bound DiffVisualRadius_mm to it — the visual radius is meaningful only up to the detection radius.

public double DetectionRadius_mm { get; set; }

Property Value

double

DiffAttachmentBag

transient object. For Internal Use.

public ConcurrentBag<DiffAttachment> DiffAttachmentBag { get; }

Property Value

ConcurrentBag<DiffAttachment>

DiffRangeColorRule

Internal used.

public RangeColorRule DiffRangeColorRule { get; set; }

Property Value

RangeColorRule

DiffVisualRadius_mm

Visual radius for difference visualization.

public double DiffVisualRadius_mm { get; set; }

Property Value

double

HasDiff

Indicates whether there are differences between ideal and actual geometry.

public bool HasDiff { get; }

Property Value

bool

IdealGeom

Delegate property for IdealGeom with cache cleanup.

public IGetStl IdealGeom { get; set; }

Property Value

IGetStl

IdealSolid

Gets the drawing representing the ideal geometry faces of the workpiece. The derived solid from IdealGeom.

public Solid IdealSolid { get; }

Property Value

Solid

InitGeom

Delegate property for InitGeom with runtime cleanup.

public IMakeXmlSource InitGeom { get; set; }

Property Value

IMakeXmlSource

InitSolid

The derived solid from InitGeom.

public Solid InitSolid { get; }

Property Value

Solid

IsMeshedGeomInit

Indicates whether the meshed geometry is initialized.

public bool IsMeshedGeomInit { get; }

Property Value

bool

Workpiece

The underlying workpiece data model.

public Workpiece Workpiece { get; }

Property Value

Workpiece

WorkpieceGetter

Lazy factory for the active Workpiece; invoked whenever consumers read Workpiece.

public Func<Workpiece> WorkpieceGetter { get; }

Property Value

Func<Workpiece>

Methods

ClearCache()

Drops the raw / ideal solid and defect display caches so the next access rebuilds from the current Workpiece.

public void ClearCache()

ClearDefectDisplayee()

Clears all defect displayees.

public void ClearDefectDisplayee()

ClearIdealGeomCache()

Clears the ideal geometry cache.

public void ClearIdealGeomCache()

ClearRawGeomCache()

Clears the raw geometry cache.

public void ClearRawGeomCache()

Diff(double, CancellationToken, IProgress<IMessage>)

Calculates the difference between ideal and actual geometry.

public void Diff(double detectionRadius, CancellationToken token, IProgress<IMessage> messageProgress = null)

Parameters

detectionRadius double

Detection radius; also saved to DetectionRadius_mm.

token CancellationToken

Cancellation token.

messageProgress IProgress<IMessage>

Progress reporting interface.

Display(Bind)

Display function called in DispEngine rendering loop.

public void Display(Bind bind)

Parameters

bind Bind

Bind with DispEngine. See Bind.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

ExpandToBox3d(Box3d)

Expands the destination box. This function is usually used to compute the bounding box of elements.

public void ExpandToBox3d(Box3d dst)

Parameters

dst Box3d

Destination box

GetAnchoredCollidableNode()

Gets the anchored collidable node associated with this object.

public IAnchoredCollidableNode GetAnchoredCollidableNode()

Returns

IAnchoredCollidableNode

The anchored collidable node.

GetAnchoredDisplayeeList()

Gets a list of anchored displayable objects.

public List<IAnchoredDisplayee> GetAnchoredDisplayeeList()

Returns

List<IAnchoredDisplayee>

A list of IAnchoredDisplayee objects

GetCollidableAnchor()

Gets the anchor associated with this collidable leaf.

public Anchor GetCollidableAnchor()

Returns

Anchor

The anchor for this collidable leaf.

GetCollidee()

Get ICollidee.

public ICollidee GetCollidee()

Returns

ICollidee

ICollidee

GetOrBuildMeshedGeom(CancellationToken, IProgress<IMessage>)

Returns the current meshed geometry, lazily building it from the workpiece's InitGeom (voxelize via NewWithDefectInfos(Stl, double, CancellationToken, IProgress<IMessage>), or load a CubeTreeFile) when not yet present. The first build can be slow — hence the cancellation token + progress sinks; once built, the tree is returned cheaply.

public CubeTree GetOrBuildMeshedGeom(CancellationToken token, IProgress<IMessage> messageProgress = null)

Parameters

token CancellationToken

Cancels an in-progress build (leaves the geometry unbuilt / null).

messageProgress IProgress<IMessage>

IMessage-channel sink (null = silent).

Returns

CubeTree

The meshed cube tree; null when there is no workpiece / InitGeom, or the build was cancelled.

ReadMeshedGeom(string, IProgress<IMessage>)

Reads the meshed geometry from a file, relative to BaseDirectoryGetter.

public bool ReadMeshedGeom(string relFile, IProgress<IMessage> messageProgress = null)

Parameters

relFile string

Source file path, relative to the injected base directory.

messageProgress IProgress<IMessage>

IMessage-channel sink injected by the caller (null = silent).

Returns

bool

True if the file existed and was read; false if it was not found.

ResetMeshedGeom()

Resets the meshed geometry.

public void ResetMeshedGeom()

RetireAttachments(IReadOnlyCollection<CbtrPickable>)

Retires attachments OWNED BY A CALLER (e.g. ClStrip's ClStripPos) that are attached to the current meshed tree. If a tree is current it detaches them under its write-gate render barrier first; otherwise (tree already retired) it just frees them on the background chain. Targeted — never touches the base attachment or diff attachments.

public void RetireAttachments(IReadOnlyCollection<CbtrPickable> attachments)

Parameters

attachments IReadOnlyCollection<CbtrPickable>

ScanMeshedGeomInfDefect(IProgress<IMessage>, CancellationToken)

Scans the meshed geometry for inf defects.

public bool? ScanMeshedGeomInfDefect(IProgress<IMessage> messageProgress, CancellationToken cancellationToken)

Parameters

messageProgress IProgress<IMessage>
cancellationToken CancellationToken

Returns

bool?

SetMeshedGeom(CubeTree)

Sets the meshed geometry instance and rebuilds its attachments.

public void SetMeshedGeom(CubeTree meshedGeom_)

Parameters

meshedGeom_ CubeTree

The meshed cube tree geometry.

WriteMeshedGeom(string, CancellationToken, IProgress<IMessage>)

Writes the meshed geometry to a file, relative to BaseDirectoryGetter.

public void WriteMeshedGeom(string relFile, CancellationToken token, IProgress<IMessage> messageProgress = null)

Parameters

relFile string

Target file path, relative to the injected base directory.

token CancellationToken

Cancellation token.

messageProgress IProgress<IMessage>

IMessage-channel progress sink (null = silent).