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
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
BottomResolution
Resolution.
public double BottomResolution { get; }
Property Value
CollidableName
Gets the name of the collidable object.
public string CollidableName { get; }
Property Value
CollisionFlag
Gets or sets the collision flag.
public CollisionFlag CollisionFlag { get; set; }
Property Value
ConstructionDefectDisplayee
Construction defect displayee.
public ConstructionDefectDisplayee ConstructionDefectDisplayee { get; }
Property Value
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
DiffAttachmentBag
transient object. For Internal Use.
public ConcurrentBag<DiffAttachment> DiffAttachmentBag { get; }
Property Value
DiffRangeColorRule
Internal used.
public RangeColorRule DiffRangeColorRule { get; set; }
Property Value
DiffVisualRadius_mm
Visual radius for difference visualization.
public double DiffVisualRadius_mm { get; set; }
Property Value
HasDiff
Indicates whether there are differences between ideal and actual geometry.
public bool HasDiff { get; }
Property Value
IdealGeom
Delegate property for IdealGeom with cache cleanup.
public IGetStl IdealGeom { get; set; }
Property Value
IdealSolid
Gets the drawing representing the ideal geometry faces of the workpiece. The derived solid from IdealGeom.
public Solid IdealSolid { get; }
Property Value
InitGeom
Delegate property for InitGeom with runtime cleanup.
public IMakeXmlSource InitGeom { get; set; }
Property Value
InitSolid
The derived solid from InitGeom.
public Solid InitSolid { get; }
Property Value
IsMeshedGeomInit
Indicates whether the meshed geometry is initialized.
public bool IsMeshedGeomInit { get; }
Property Value
Workpiece
The underlying workpiece data model.
public Workpiece Workpiece { get; }
Property Value
WorkpieceGetter
public Func<Workpiece> WorkpieceGetter { get; }
Property Value
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
detectionRadiusdoubleDetection radius; also saved to DetectionRadius_mm.
tokenCancellationTokenCancellation token.
messageProgressIProgress<IMessage>Progress reporting interface.
Display(Bind)
Display function called in DispEngine rendering loop.
public void Display(Bind bind)
Parameters
bindBindBind 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
disposingbool
ExpandToBox3d(Box3d)
Expands the destination box. This function is usually used to compute the bounding box of elements.
public void ExpandToBox3d(Box3d dst)
Parameters
dstBox3dDestination 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
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
tokenCancellationTokenCancels an in-progress build (leaves the geometry unbuilt / null).
messageProgressIProgress<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
relFilestringSource file path, relative to the injected base directory.
messageProgressIProgress<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
attachmentsIReadOnlyCollection<CbtrPickable>
ScanMeshedGeomInfDefect(IProgress<IMessage>, CancellationToken)
Scans the meshed geometry for inf defects.
public bool? ScanMeshedGeomInfDefect(IProgress<IMessage> messageProgress, CancellationToken cancellationToken)
Parameters
messageProgressIProgress<IMessage>cancellationTokenCancellationToken
Returns
- bool?
SetMeshedGeom(CubeTree)
Sets the meshed geometry instance and rebuilds its attachments.
public void SetMeshedGeom(CubeTree meshedGeom_)
Parameters
meshedGeom_CubeTreeThe 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
relFilestringTarget file path, relative to the injected base directory.
tokenCancellationTokenCancellation token.
messageProgressIProgress<IMessage>IMessage-channel progress sink (null = silent).