/** * Reference collector for IFC STEP export filtering. * * Walks #ID references transitively from a set of root entities to build * the complete closure of all entities that must be included for a valid * STEP file. Used for visible-only export and merged export. * * KEY DESIGN: In IFC STEP files, the reference graph is: * - Products reference geometry (Product → Placement → CartesianPoint) * - Relationships reference products (Rel → Product, NOT Product → Rel) * - Properties are reached via relationships (Rel → PropertySet → Property) * * For visible-only export, we need: * 1. Infrastructure + spatial structure (always included) * 2. Visible product entities (checked against hidden/isolated) * 3. Relationship entities (always included as roots — they reference products) * 4. Forward closure from the above roots pulls in geometry, properties, etc. * 5. Hidden product IDs are BLOCKED during the closure walk so their * exclusively-referenced geometry doesn't get pulled in. * 6. IfcStyledItem entities are collected in a reverse pass after the closure * because they reference geometry but nothing references them back. * 7. Openings whose parent element is hidden are also excluded * (via IfcRelVoidsElement propagation). */ import type { IfcDataStore } from '@ifc-lite/parser'; /** * Collect all entity IDs transitively referenced from a set of root entities. * * Starting from `rootIds`, reads each entity's raw bytes from the source buffer * and extracts all `#ID` references via byte-level scanning (no string * allocation). Recursively follows references to build a complete closure * that guarantees referential integrity. * * @param rootIds - Seed entity IDs to start the walk from * @param source - The original STEP file source buffer * @param entityIndex - Map of expressId → byte position in source * @param excludeIds - Entity IDs to NEVER follow during the walk. * * Performance: O(total bytes of included entities). Each entity visited once. * Uses byte-level scanning — no TextDecoder, no regex, no string allocation. */ export declare function collectReferencedEntityIds(rootIds: Set, source: Uint8Array, entityIndex: { get(id: number): { byteOffset: number; byteLength: number; } | undefined; has(id: number): boolean; }, excludeIds?: Set): Set; /** * Compute the root entity set and hidden product IDs for a visible-only export. * * Returns: * - `roots`: Entity IDs that form the seed set for the reference closure. * Includes infrastructure, spatial structure, relationship entities, and * visible product entities. * - `hiddenProductIds`: Product entity IDs that are hidden/not isolated. * These should be passed as `excludeIds` to `collectReferencedEntityIds` * to prevent the closure from walking into hidden products' geometry. * * Also propagates hidden status from building elements to their openings * via IfcRelVoidsElement, so orphaned openings are excluded. */ export declare function getVisibleEntityIds(dataStore: IfcDataStore, hiddenIds: Set, isolatedIds: Set | null): { roots: Set; hiddenProductIds: Set; }; /** * Collect style entities (IFCSTYLEDITEM, etc.) that reference geometry already * in the closure, then transitively follow their style references. * * In IFC STEP, IFCSTYLEDITEM references a geometry RepresentationItem, but * nothing references the StyledItem back. So the forward closure walk misses * them entirely. This function does a reverse pass using the byType index: * for each styled item, check if any referenced ID is in the closure. If yes, * add the styled item and walk its style chain into the closure. * * Uses byType for O(styledItems) instead of O(allEntities), and byte-level * scanning for #ID extraction. * * Must be called AFTER collectReferencedEntityIds so the closure is complete. * * @param closure - The existing closure set (mutated in place) * @param source - The original STEP file source buffer * @param entityIndex - Full entity index with type info and byType lookup */ export declare function collectStyleEntities(closure: Set, source: Uint8Array, entityIndex: { byId: { get(expressId: number): { type: string; byteOffset: number; byteLength: number; } | undefined; has(expressId: number): boolean; }; byType: Map; }): void; //# sourceMappingURL=reference-collector.d.ts.map