Skip to content
Shapemetry

@huukhanhnguyen/model / document/objectData

document/objectData

concatObjectData()

concatObjectData(input, created): ObjectData | undefined

Empty + created = created. Same kind merges. Mixed wraps as BlockData.

Parameters

input

ObjectData | undefined

created

ObjectData | undefined

Returns

ObjectData | undefined


createdToData()

createdToData(result): ObjectData | undefined

Coerce a producer answer (one *Data, one PolyCurve, one Point, or a list) into the stream.

Parameters

result

unknown

Returns

ObjectData | undefined


dataPieces()

dataPieces(data): ObjectData[]

One document → its PIECES, each its own document.

The stream merges same-kind producers into one document, so anything that has to address a piece (a lock selector, a connectivity clustering) has to split it back out first. The inverse is mergeObjectData, so dataPieces(d).reduce(mergeObjectData) reproduces d.

Parameters

data

ObjectData

Returns

ObjectData[]


isEmptyData()

isEmptyData(data): boolean

Does this document hold NOTHING? The empty stream has exactly one spelling — undefined — so a document with zero pieces ({ edges: [] } from a subtract whose tool covered the subject) has to normalize to it. Left as a document it counted as one data document, and a fully-cut body reported as intact.

Parameters

data

ObjectData

Returns

boolean


mergeObjectData()

mergeObjectData(left, right): ObjectData

Same-kind merge, or BlockData wrap when kinds differ.

Parameters

left

ObjectData

ObjectData

Returns

ObjectData


rowClaimsOf()

rowClaimsOf(data): Record<string, unknown> | undefined

The inverse read of stampRowClaims: the claim bag a DOCUMENT carries on its entries.

A document has no claim slot of its own — the object door already ran and a folded Group's claims were pushed onto the entries. One document is one object's content, so every entry carries the same claim set and the FIRST entry answers for the document.

Parameters

data

ObjectData

Returns

Record<string, unknown> | undefined


rowLayerOf()

rowLayerOf(data): string | undefined

The LAYER a document's entries resolve to: the entry's own declared layer first, then the layer the placement stamped onto its claims.

Two tiers, and the order is what makes the Entity override mean anything — stampRowClaims writes the instance's layer onto every entry's attributes, so reading only that would let the placement's default silently outrank a entry that stated its own. An IMPORTED document is the case this exists for: DXF assigns layer per ENTITY and never per block, so one drawing arrives already carrying N layers across its entries.

Only the kinds whose entry type DECLARES layer participate — CurveEdge, BrepFace, MeshFace. Everything else answers from claims alone, exactly as before.

Parameters

data

ObjectData

Returns

string | undefined


rowMaterialOf()

rowMaterialOf(data): string | undefined

The MATERIAL a document's entries resolve to — rowLayerOf for the other lane reference an entry may override, and the same two tiers in the same order: the entry's own declared material first, then whatever a placement left on its claims.

Same kinds participate, for the same reason — CurveEdge, BrepFace, MeshFace are the entries that declare material. An imported document is again the motivating case: one OBJ arrives with a usemtl run per face group, and one glTF mesh splits into a primitive per material, so the document is already carrying N materials before anything wraps it into an Object.

Parameters

data

ObjectData

Returns

string | undefined


stampRowClaims()

stampRowClaims<T>(data, claims): T

Push object-level claims DOWN onto the document's per-entry claim slots (edges[].attributes / texts[].attributes / faces[].attributes).

Merging is how this stream works — a chain collapses many keyed steps into ONE document, and flattening an object tier destroys the object. Either way the object that carried the claim stops existing, so the claim has to land on the entries it described or it is silently lost. Entries that already declare a key keep it: entry wins over object, the order every reader uses.

Type Parameters

T

T extends ObjectData

Parameters

data

T

claims

Record<string, unknown> | undefined

Returns

T


kindOfData

Re-exports kindOfData

Last updated: 📖 4 min readEdit on GitHub