/** * FederationRegistry - Bulletproof multi-model ID management * * Each model gets a unique ID offset, ensuring globally unique IDs across * all federated models. This eliminates ID collisions when multiple IFC * files have overlapping expressIds. * * Inspired by HOOPS Communicator's loadSubtree approach where node IDs * are automatically offset to avoid conflicts. */ export interface ModelRange { modelId: string; offset: number; maxExpressId: number; } export interface GlobalIdLookup { modelId: string; expressId: number; } /** * Central registry for multi-model federation * Manages ID offsets and provides O(1) to-global / O(log N) from-global transformations */ export declare class FederationRegistry { private modelRanges; private sortedRanges; private nextOffset; /** * Register a new model and get its ID offset * Call this BEFORE adding meshes to the scene * * @param modelId Unique identifier for this model * @param maxExpressId Highest expressId in this model (scan meshes first) * @returns The offset to add to all expressIds for this model */ registerModel(modelId: string, maxExpressId: number): number; /** * Unregister a model (when removed from viewer) * Note: The offset space is NOT reclaimed to avoid invalidating any * existing references (selections, undo stack, etc.) */ unregisterModel(modelId: string): void; /** * Transform a local expressId to a globally unique ID * O(1) - direct map lookup + addition */ toGlobalId(modelId: string, expressId: number): number; /** * Transform a global ID back to model + local expressId * O(log N) - binary search on sorted ranges */ fromGlobalId(globalId: number): GlobalIdLookup | null; /** * Get the model ID that owns a global ID (without computing expressId) * O(log N) */ getModelForGlobalId(globalId: number): string | null; /** * Get the offset for a model (useful for batch transformations) */ getOffset(modelId: string): number | null; /** * Check if a model is registered */ hasModel(modelId: string): boolean; /** * Get all registered model IDs */ getModelIds(): string[]; /** * Get the number of registered models */ getModelCount(): number; /** * Get all global IDs for a model (as a range) * Useful for bulk operations like "hide all entities in model X" */ getGlobalIdRange(modelId: string): { start: number; end: number; } | null; /** * Check if a global ID belongs to a specific model * O(1) when we know the model */ isInModel(globalId: number, modelId: string): boolean; /** * Clear all registrations (for full reset) */ clear(): void; /** * Binary search to find the range that could contain a globalId * Returns the range with the largest offset that is <= globalId */ private binarySearchRange; } export declare const federationRegistry: FederationRegistry; //# sourceMappingURL=federation-registry.d.ts.map