Class default<EntityTypeIDs, BaseEntity>Abstract

The base for models parsed from STEP.

Type Parameters

Hierarchy (view full)

Implements

Constructors

  • Construct this step model with its matching schema, a buffer to read from and an element index.

    Type Parameters

    Parameters

    • schema: default<EntityTypeIDs, BaseEntity>

      The Step schema this is based on.

    • buffer_: undefined | Uint8Array<ArrayBufferLike>

      The buffer to read this from. Pass undefined together with provider to build a model whose source is windowed from construction (e.g. a streaming open — see buildModelStreaming); the synchronous read paths (geometry extraction) then require the relevant ranges to be resident, exactly as after spillSourceToExternalStore.

    • elementIndex: StepIndexColumns<EntityTypeIDs> | StepIndexEntry<EntityTypeIDs>[]

      The element index for this, parsed or deserialized - note this takes ownership of this array in the sense it will modify values/unfold inline elements etc.

    • Optionalprovider: StepBufferProvider

      Optional pre-built buffer provider. When omitted, a resident provider over buffer_ is used (the classic path).

    Returns default<EntityTypeIDs, BaseEntity>

Properties

elementMemoization: boolean = true

Will this model memoize elements, set to false to disable, true to enable.

Note that during periods where element memoization is disabled, it's not guaranteed element objects returned from this have referential equality even if they have ID equality.

externalMappingType: default<EntityTypeIDs, BaseEntity>
geometry?: ModelGeometry
materials?: ModelMaterials
nullOnErrors: boolean = true

When an atribute is parsed from an entity in the model that causes a recoverable error, and the field is optional, return null instead of throwing an exception.

The Step schema this is based on.

Accessors

  • get bufferBytesize(): number
  • Get the size in bytes of the backing buffer for this.

    Returns number

    The number of elements.

  • get isSourceExternal(): boolean
  • Are the source bytes held externally (spilled), i.e. windowed in on demand rather than fully resident?

    Returns boolean

    True after a successful spillSourceToExternalStore.

  • get residentSourceBytes(): number
  • Bytes of source currently held resident by the buffer provider (the whole buffer before a spill; the windowed working set after).

    Returns number

    The resident byte count.

  • get size(): number
  • Get the number of elements/entities in this model.

    Returns number

    The number of elements.

Methods

  • Iterate over all the elements in this.

    Returns IterableIterator<BaseEntity, any, any>

    The iterable iterator to allow lazy iteration over all the elements in this.

    An element per iteration for all the elements in this.

  • Page in the byte range(s) backing a record by express ID — see ensureResidentByLocalID. Unknown express IDs resolve silently (the following read will surface the miss the same way it does for a fully-resident model).

    Parameters

    • expressID: number

      The express ID of the record.

    Returns Promise<void>

    Resolves when resident.

  • Page in the byte range(s) backing a record so following synchronous extraction of it succeeds. Covers the record's own range (which contains any inline elements) and, for complex / external-mapped records, each mapped class record's range.

    No-op (fast resolved promise) while the source is fully resident.

    Parameters

    • localID: number

      The local ID of the record.

    Returns Promise<void>

    Resolves when resident.

  • Iterate the express IDs of entities of a set of types (including sub-types) without materializing entity descriptors or touching the source buffer — only the type index and the express ID column are read, so this stays cheap and safe even when the model source has been spilled to an external store.

    Multi-mapped elements (e.g. complex/multi-entity mappings) may be yielded once per matching mapping, so callers that need distinct IDs should dedupe.

    Type Parameters

    Parameters

    • Rest...types: T

      The list of types to iterate.

    Returns IterableIterator<number, any, any>

    A lazy iterator of express IDs for matching entities.

    The express ID of each matching entity.

  • Extract a set of elements given a local ID iterator.

    Parameters

    • from: Iterable<number, any, any>

      An iterable of local IDs

    Returns IterableIterator<BaseEntity, any, any>

    The iterable iterator to allow lazy iteration over the elements matching the local ids.

    An element per iteration matching the ids in from.

  • Given a cursor, get the matching entities for it as a lazy iterable iterator.

    Parameters

    • cursor: IIndexSetCursor

      The cursor to iterate over.

    • freeCursor: boolean = false

      Should the cursor be freed after

    Returns IterableIterator<BaseEntity, any, any>

    The iterable iterator to allow lazy iteration over a cursor.

    An element per iteration matching the ids in the cursor.

  • Given an express ID, return the matching element if one exists.

    Parameters

    • expressID: number

      The express ID to fetch the element for.

    Returns undefined | BaseEntity

    The element if one exists for that ID, otherwise undefined.

  • Given a local ID (i.e. dense index/reference), return the matching element if one exists.

    Parameters

    • localID: number

      The local ID to fetch for.

    Returns undefined | BaseEntity

    The matching element or undefined if none exists.

  • Given an express ID, return the matching element if one exists.

    Parameters

    • localID: number

      The local ID to fetch the element for.

    Returns undefined | number

    The express ID if one exists for that local ID, otherwise undefined.

  • Get an inline element by address.

    Parameters

    • address: undefined | number

    Returns undefined | BaseEntity

    The number of elements.

  • Given an express ID, return the matching element if one exists.

    Type Parameters

    Parameters

    • expressID: number

      The express ID to fetch the element for.

    • type: T

      The constructor matching the type of the element to fetch.

    Returns undefined | O

    The element if one exists for that ID, otherwise undefined.

  • Invalidate the cache store for this, so new items will be created.

    Parameters

    • dropVtable: boolean = false

      If true, remove the vtable entries for old entries as well, freeing up the v-table space on garbage collection.

    Returns void

  • Map an array of local IDs to their matching express IDs.

    Parameters

    Returns Uint32Array<ArrayBufferLike>

    express ID array

  • Get the non empty type IDs for this without including sub-types, only direct instances.

    Returns IterableIterator<EntityTypeIDs, any, any>

    The unique set of non empty type IDs for this model.

  • Get the non empty type IDs for this.

    Returns Set<EntityTypeIDs>

    The unique set of non empty type IDs for this model.

  • Force the population of the the buffer entry for a particular element.

    Parameters

    • localID: number

      The local id to fetch the buffer entry for.

    Returns void

    Throws an error if the ID is invalid.

  • Force the population of the the vtable entry for a particular ID (i.e. extracting the field locations)

    Parameters

    • localID: number

      The id to fetch the vtable entry for.

    Returns boolean

    Did the vtable entry populate correctly?

    Throws an error if the ID is invalid.

  • Populate a raw vtable entry for a particular element, extra

    Parameters

    Returns boolean

    Did the vtable entry populate correctly?

  • Release the resident source buffer and serve subsequent record reads from fixed-size windows paged in from an external store.

    The store must contain EXACTLY the model's source bytes (same length; byte-identical content is the caller's responsibility — typically the original file already sitting in OPFS). All cached descriptors/entities are invalidated, since they hold views over the released buffer; they rematerialise on demand through the windowed provider.

    After this, synchronous extraction of a record whose range isn't resident throws StepBufferNotResidentError — async API surfaces must call ensureResidentByExpressID / ensureResidentByLocalID first. Parse and geometry extraction always run before any spill, so those paths are unaffected.

    Parameters

    • store: StepExternalByteStore

      The external store holding the source bytes.

    • OptionalchunkBytes: number

      Optional window size in bytes.

    • OptionalmaxResidentChunks: number

      Optional residency cap in windows.

    Returns void

  • Count entities of a set of types (including sub-types) without iterating or materializing them — reads the type index's prefix sums, so it's cheap enough to call up front for progress totals (see core/progress.ts). Multi-mapped elements can be counted once per matching mapping, so treat this as an upper bound; see MultiIndexSet.count.

    Type Parameters

    Parameters

    • Rest...types: T

      The list of types to count.

    Returns number

    The number of matching entities.

  • Use the type index to get set of entities of a set of types not including sub-types from the list of type ids, acts as a union given the input type list, with lazy iteration over the set.

    Parameters

    Returns IterableIterator<BaseEntity, any, any>

    An iterable corresponding to the lazy set of items.

  • Use the type index to get set of entities of a set of types including sub-types, acts as a union given the input type list, with lazy iteration over the set.

    Type Parameters

    Parameters

    • Rest...types: T

      The list of types to return

    Returns IterableIterator<InstanceType<T[number]>, any, any>

    An iterable corresponding to the lazy set of items.

  • Use the type index to get set of entities of a set of types including sub-types from the list of type ids, acts as a union given the input type list, with lazy iteration over the set.

    Parameters

    Returns IterableIterator<BaseEntity, any, any>

    An iterable corresponding to the lazy set of items.