@ifc-lite/parser 2.1.8 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -269
- package/dist/classification-extractor.d.ts +1 -1
- package/dist/classification-extractor.d.ts.map +1 -1
- package/dist/classification-resolver.d.ts +18 -0
- package/dist/classification-resolver.d.ts.map +1 -0
- package/dist/classification-resolver.js +126 -0
- package/dist/classification-resolver.js.map +1 -0
- package/dist/columnar-parser-attributes.d.ts +39 -0
- package/dist/columnar-parser-attributes.d.ts.map +1 -0
- package/dist/columnar-parser-attributes.js +225 -0
- package/dist/columnar-parser-attributes.js.map +1 -0
- package/dist/columnar-parser-indexes.d.ts +42 -0
- package/dist/columnar-parser-indexes.d.ts.map +1 -0
- package/dist/columnar-parser-indexes.js +102 -0
- package/dist/columnar-parser-indexes.js.map +1 -0
- package/dist/columnar-parser-relationships.d.ts +17 -0
- package/dist/columnar-parser-relationships.d.ts.map +1 -0
- package/dist/columnar-parser-relationships.js +95 -0
- package/dist/columnar-parser-relationships.js.map +1 -0
- package/dist/columnar-parser.d.ts +2 -21
- package/dist/columnar-parser.d.ts.map +1 -1
- package/dist/columnar-parser.js +13 -411
- package/dist/columnar-parser.js.map +1 -1
- package/dist/deterministic-global-id.d.ts +2 -0
- package/dist/deterministic-global-id.d.ts.map +1 -0
- package/dist/deterministic-global-id.js +71 -0
- package/dist/deterministic-global-id.js.map +1 -0
- package/dist/georef-extractor.d.ts +7 -1
- package/dist/georef-extractor.d.ts.map +1 -1
- package/dist/georef-extractor.js +29 -5
- package/dist/georef-extractor.js.map +1 -1
- package/dist/ifc-schema.d.ts +11 -0
- package/dist/ifc-schema.d.ts.map +1 -1
- package/dist/ifc-schema.js +20 -1
- package/dist/ifc-schema.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/material-extractor.d.ts +1 -1
- package/dist/material-extractor.d.ts.map +1 -1
- package/dist/material-resolver.d.ts +37 -0
- package/dist/material-resolver.d.ts.map +1 -0
- package/dist/material-resolver.js +230 -0
- package/dist/material-resolver.js.map +1 -0
- package/dist/on-demand-extractors.d.ts +4 -51
- package/dist/on-demand-extractors.d.ts.map +1 -1
- package/dist/on-demand-extractors.js +35 -342
- package/dist/on-demand-extractors.js.map +1 -1
- package/dist/schedule-extractor.d.ts +95 -0
- package/dist/schedule-extractor.d.ts.map +1 -0
- package/dist/schedule-extractor.js +511 -0
- package/dist/schedule-extractor.js.map +1 -0
- package/dist/schedule-serializer.d.ts +57 -0
- package/dist/schedule-serializer.d.ts.map +1 -0
- package/dist/schedule-serializer.js +309 -0
- package/dist/schedule-serializer.js.map +1 -0
- package/dist/style-extractor.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,30 +1,6 @@
|
|
|
1
1
|
# @ifc-lite/parser
|
|
2
2
|
|
|
3
|
-
High-performance IFC parser
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
### Core Parser (Existing)
|
|
8
|
-
- ✅ Fast byte-level STEP tokenization (~1,259 MB/s)
|
|
9
|
-
- ✅ Entity extraction with lazy evaluation
|
|
10
|
-
- ✅ Property and quantity extraction
|
|
11
|
-
- ✅ Relationship graph building
|
|
12
|
-
- ✅ Spatial hierarchy with elevation support
|
|
13
|
-
- ✅ Style and material appearance
|
|
14
|
-
- ✅ Columnar storage (TypedArrays)
|
|
15
|
-
|
|
16
|
-
### NEW: 100% Schema Coverage
|
|
17
|
-
- ✅ **776 IFC4 entities** (auto-generated from EXPRESS schemas)
|
|
18
|
-
- ✅ **397 type definitions**
|
|
19
|
-
- ✅ **207 enumerations**
|
|
20
|
-
- ✅ **60 SELECT union types**
|
|
21
|
-
- ✅ Full TypeScript type safety
|
|
22
|
-
- ✅ Runtime schema metadata
|
|
23
|
-
|
|
24
|
-
### NEW: Advanced Extractors
|
|
25
|
-
- ✅ **Materials Extractor** - IfcMaterial, layers, profiles, constituents
|
|
26
|
-
- ✅ **Georeferencing Extractor** - Coordinate transformations, CRS support
|
|
27
|
-
- ✅ **Classification Extractor** - Uniclass, Omniclass, MasterFormat, etc.
|
|
3
|
+
High-performance IFC parser. Tokenizes STEP files at ~1,259 MB/s, builds columnar TypedArray storage, and ships full type-safe coverage of IFC4 (776 entities) and IFC4X3 (876 entities).
|
|
28
4
|
|
|
29
5
|
## Installation
|
|
30
6
|
|
|
@@ -32,7 +8,7 @@ High-performance IFC parser with **100% schema coverage** via code generation.
|
|
|
32
8
|
npm install @ifc-lite/parser
|
|
33
9
|
```
|
|
34
10
|
|
|
35
|
-
##
|
|
11
|
+
## Parse a file
|
|
36
12
|
|
|
37
13
|
```typescript
|
|
38
14
|
import { IfcParser } from '@ifc-lite/parser';
|
|
@@ -40,287 +16,102 @@ import { IfcParser } from '@ifc-lite/parser';
|
|
|
40
16
|
const parser = new IfcParser();
|
|
41
17
|
const buffer = await fetch('model.ifc').then(r => r.arrayBuffer());
|
|
42
18
|
|
|
43
|
-
|
|
19
|
+
const t0 = performance.now();
|
|
44
20
|
const result = await parser.parse(buffer, {
|
|
45
|
-
onProgress: ({ phase, percent }) => {
|
|
46
|
-
console.log(`${phase}: ${percent.toFixed(1)}%`);
|
|
47
|
-
}
|
|
21
|
+
onProgress: ({ phase, percent }) => console.log(`${phase}: ${percent.toFixed(1)}%`),
|
|
48
22
|
});
|
|
49
23
|
|
|
50
|
-
console.log(`Parsed ${result.entityCount} entities`);
|
|
24
|
+
console.log(`Parsed ${result.entityCount} entities in ${(performance.now() - t0).toFixed(0)}ms`);
|
|
51
25
|
```
|
|
52
26
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
### Basic Entity Access
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
import type { IfcWall, IfcDoor, IfcWindow } from '@ifc-lite/parser';
|
|
59
|
-
|
|
60
|
-
// Type-safe entity access with full IntelliSense
|
|
61
|
-
const walls = result.entities.values();
|
|
62
|
-
for (const wall of walls) {
|
|
63
|
-
if (wall.type === 'IfcWall') {
|
|
64
|
-
console.log(wall.name);
|
|
65
|
-
// TypeScript knows all IfcWall attributes!
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### Schema Metadata
|
|
27
|
+
For columnar storage (TypedArray-backed, query-friendly, recommended for models > 10 MB):
|
|
71
28
|
|
|
72
29
|
```typescript
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
// Get metadata for any entity type
|
|
76
|
-
const wallMeta = getEntityMetadata('IfcWall');
|
|
77
|
-
|
|
78
|
-
console.log(wallMeta.parent); // 'IfcBuildingElement'
|
|
79
|
-
console.log(wallMeta.inheritanceChain); // Full chain from IfcRoot
|
|
80
|
-
console.log(wallMeta.allAttributes); // All attributes including inherited
|
|
30
|
+
const store = await parser.parseColumnar(buffer);
|
|
81
31
|
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
32
|
+
// store.entities — typed access by expressId
|
|
33
|
+
// store.properties — flattened pset table
|
|
34
|
+
// store.quantities — flattened qset table
|
|
35
|
+
// store.spatialHierarchy.byStorey — Map<storeyId, Set<elementId>>
|
|
36
|
+
console.log(`${store.entityCount} entities, schema ${store.schemaVersion}`);
|
|
86
37
|
```
|
|
87
38
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
import { extractMaterials, getMaterialNameForElement } from '@ifc-lite/parser';
|
|
92
|
-
|
|
93
|
-
// Extract all material definitions
|
|
94
|
-
const materialsData = extractMaterials(result.entities, entitiesByType);
|
|
95
|
-
|
|
96
|
-
console.log(`Materials: ${materialsData.materials.size}`);
|
|
97
|
-
console.log(`Layer sets: ${materialsData.materialLayerSets.size}`);
|
|
98
|
-
console.log(`Associations: ${materialsData.associations.length}`);
|
|
99
|
-
|
|
100
|
-
// Get material for a specific wall
|
|
101
|
-
const wallId = 12345;
|
|
102
|
-
const materialName = getMaterialNameForElement(wallId, materialsData);
|
|
103
|
-
console.log(`Wall material: ${materialName}`); // e.g., "Concrete C30/37"
|
|
104
|
-
|
|
105
|
-
// Access material details
|
|
106
|
-
for (const [id, material] of materialsData.materials) {
|
|
107
|
-
console.log(`${material.name}: ${material.description}`);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Access layer sets (multi-layer walls, roofs, etc.)
|
|
111
|
-
for (const [id, layerSet] of materialsData.materialLayerSets) {
|
|
112
|
-
console.log(`${layerSet.name}: ${layerSet.totalThickness}m total`);
|
|
113
|
-
for (const layerId of layerSet.layers) {
|
|
114
|
-
const layer = materialsData.materialLayers.get(layerId);
|
|
115
|
-
console.log(` - ${layer?.name}: ${layer?.thickness}m`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
```
|
|
39
|
+
## Type-safe entity access
|
|
119
40
|
|
|
120
|
-
|
|
41
|
+
All 776 IFC4 entities (876 for IFC4X3) ship as TypeScript types via the generated schema.
|
|
121
42
|
|
|
122
43
|
```typescript
|
|
123
|
-
import {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
//
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
// Transform local coordinates to world coordinates
|
|
137
|
-
const localPoint: [number, number, number] = [10, 20, 5];
|
|
138
|
-
const worldPoint = transformToWorld(localPoint, georef);
|
|
139
|
-
console.log(`World coordinates: ${worldPoint}`); // Real-world coordinates
|
|
140
|
-
|
|
141
|
-
// Access CRS details
|
|
142
|
-
console.log(`Projection: ${georef.projectedCRS?.mapProjection}`);
|
|
143
|
-
console.log(`Datum: ${georef.projectedCRS?.geodeticDatum}`);
|
|
144
|
-
console.log(`Zone: ${georef.projectedCRS?.mapZone}`);
|
|
145
|
-
}
|
|
44
|
+
import type { IfcWall, IfcDoor, IfcSlab } from '@ifc-lite/parser';
|
|
45
|
+
import { isKnownEntity, getEntityMetadata } from '@ifc-lite/parser';
|
|
46
|
+
|
|
47
|
+
// Schema metadata
|
|
48
|
+
const meta = getEntityMetadata('IfcWall');
|
|
49
|
+
console.log(meta.parent); // 'IfcBuildingElement'
|
|
50
|
+
console.log(meta.inheritanceChain); // ['IfcRoot', ..., 'IfcWall']
|
|
51
|
+
console.log(meta.allAttributes); // every attribute including inherited
|
|
52
|
+
|
|
53
|
+
// Schema membership check
|
|
54
|
+
console.log(isKnownEntity('IfcWall')); // true
|
|
55
|
+
console.log(isKnownEntity('IfcWidget')); // false
|
|
146
56
|
```
|
|
147
57
|
|
|
148
|
-
|
|
58
|
+
## On-demand property extraction
|
|
59
|
+
|
|
60
|
+
Properties and quantities are extracted lazily — pay only for what you read.
|
|
149
61
|
|
|
150
62
|
```typescript
|
|
151
63
|
import {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
64
|
+
extractPropertiesOnDemand,
|
|
65
|
+
extractQuantitiesOnDemand,
|
|
66
|
+
extractMaterialsOnDemand,
|
|
67
|
+
extractClassificationsOnDemand,
|
|
156
68
|
} from '@ifc-lite/parser';
|
|
157
69
|
|
|
158
|
-
// Extract all classifications
|
|
159
|
-
const classificationsData = extractClassifications(result.entities, entitiesByType);
|
|
160
|
-
|
|
161
|
-
console.log(`Systems: ${classificationsData.classifications.size}`);
|
|
162
|
-
console.log(`References: ${classificationsData.classificationReferences.size}`);
|
|
163
|
-
|
|
164
|
-
// Get classifications for a specific element
|
|
165
70
|
const wallId = 12345;
|
|
166
|
-
const classifications = getClassificationsForElement(wallId, classificationsData);
|
|
167
71
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
console.log(`Name: ${classification.name}`);
|
|
72
|
+
const psets = extractPropertiesOnDemand(store, wallId);
|
|
73
|
+
// [{ name: 'Pset_WallCommon', properties: [{ name: 'FireRating', value: 'REI 60' }, ...] }]
|
|
171
74
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
console.log(`Path: ${path.join(' > ')}`);
|
|
175
|
-
// e.g., "Uniclass 2015 > Pr > Pr_60 > Pr_60_10 > Pr_60_10_32"
|
|
176
|
-
}
|
|
75
|
+
const qsets = extractQuantitiesOnDemand(store, wallId);
|
|
76
|
+
// [{ name: 'Qto_WallBaseQuantities', quantities: [{ name: 'Length', value: 5.0 }, ...] }]
|
|
177
77
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
for (const [code, elementIds] of groups) {
|
|
181
|
-
console.log(`${code}: ${elementIds.length} elements`);
|
|
182
|
-
}
|
|
183
|
-
```
|
|
78
|
+
const material = extractMaterialsOnDemand(store, wallId);
|
|
79
|
+
// { name: 'Concrete C30/37', layers: [{ name: 'Concrete', thickness: 0.15 }, ...] }
|
|
184
80
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
```typescript
|
|
188
|
-
import { extractCompleteIfcData, getEnrichedElementInfo } from '@ifc-lite/parser/examples/comprehensive-extraction';
|
|
189
|
-
|
|
190
|
-
// Extract everything in one call
|
|
191
|
-
const completeData = extractCompleteIfcData(result.entities, entitiesByType);
|
|
192
|
-
|
|
193
|
-
// Get enriched info for any element (with materials, classifications, world coords)
|
|
194
|
-
const wallInfo = getEnrichedElementInfo(wallId, completeData);
|
|
195
|
-
|
|
196
|
-
console.log(wallInfo);
|
|
197
|
-
// {
|
|
198
|
-
// id: 12345,
|
|
199
|
-
// type: 'IfcWall',
|
|
200
|
-
// name: 'Wall-001',
|
|
201
|
-
// inheritanceChain: ['IfcRoot', 'IfcObject', 'IfcProduct', 'IfcElement', 'IfcBuildingElement', 'IfcWall'],
|
|
202
|
-
// material: {
|
|
203
|
-
// name: 'Concrete C30/37',
|
|
204
|
-
// type: 'LayerSet',
|
|
205
|
-
// layers: [
|
|
206
|
-
// { material: 'Concrete', thickness: 0.15 },
|
|
207
|
-
// { material: 'Insulation', thickness: 0.10 },
|
|
208
|
-
// ]
|
|
209
|
-
// },
|
|
210
|
-
// classifications: [
|
|
211
|
-
// { system: 'Uniclass 2015', code: 'Pr_60_10_32', name: 'External walls', path: [...] }
|
|
212
|
-
// ],
|
|
213
|
-
// worldCoordinates: [500010, 4000020, 105],
|
|
214
|
-
// properties: { ... },
|
|
215
|
-
// quantities: { ... }
|
|
216
|
-
// }
|
|
81
|
+
const classifications = extractClassificationsOnDemand(store, wallId);
|
|
82
|
+
// [{ system: 'Uniclass 2015', code: 'Pr_60_10_32', name: 'External walls', ... }]
|
|
217
83
|
```
|
|
218
84
|
|
|
219
|
-
##
|
|
220
|
-
|
|
221
|
-
### Core Classes
|
|
222
|
-
|
|
223
|
-
- **`IfcParser`** - Main parser class
|
|
224
|
-
- **`StepTokenizer`** - Fast STEP file tokenizer
|
|
225
|
-
- **`EntityExtractor`** - Entity extraction with lazy evaluation
|
|
226
|
-
- **`PropertyExtractor`** - Property set extraction
|
|
227
|
-
- **`QuantityExtractor`** - Quantity set extraction
|
|
228
|
-
- **`RelationshipExtractor`** - Relationship graph building
|
|
229
|
-
- **`SpatialHierarchyBuilder`** - Spatial hierarchy building
|
|
230
|
-
- **`StyleExtractor`** - Material and color extraction
|
|
231
|
-
|
|
232
|
-
### NEW: Advanced Extractors
|
|
233
|
-
|
|
234
|
-
- **`extractMaterials()`** - Extract all material definitions
|
|
235
|
-
- **`extractGeoreferencing()`** - Extract coordinate system info
|
|
236
|
-
- **`extractClassifications()`** - Extract classification systems
|
|
237
|
-
|
|
238
|
-
### NEW: Generated Schema
|
|
239
|
-
|
|
240
|
-
- **`SCHEMA_REGISTRY`** - Complete IFC4 schema metadata (776 entities)
|
|
241
|
-
- **`getEntityMetadata()`** - Get metadata for any entity type
|
|
242
|
-
- **`getAllAttributesForEntity()`** - Get all attributes including inherited
|
|
243
|
-
- **`getInheritanceChainForEntity()`** - Get full inheritance chain
|
|
244
|
-
- **`isKnownEntity()`** - Check if entity type exists in schema
|
|
245
|
-
|
|
246
|
-
### Types (100% Coverage)
|
|
247
|
-
|
|
248
|
-
All 776 IFC4 entities are available as TypeScript types:
|
|
85
|
+
## Georeferencing
|
|
249
86
|
|
|
250
87
|
```typescript
|
|
251
|
-
import
|
|
252
|
-
// Spatial
|
|
253
|
-
IfcProject, IfcSite, IfcBuilding, IfcBuildingStorey, IfcSpace,
|
|
254
|
-
|
|
255
|
-
// Building Elements
|
|
256
|
-
IfcWall, IfcDoor, IfcWindow, IfcSlab, IfcColumn, IfcBeam,
|
|
257
|
-
IfcStair, IfcRoof, IfcRailing, IfcCurtainWall,
|
|
258
|
-
|
|
259
|
-
// Materials (NEW!)
|
|
260
|
-
IfcMaterial, IfcMaterialLayer, IfcMaterialLayerSet,
|
|
261
|
-
IfcMaterialProfile, IfcMaterialProfileSet,
|
|
262
|
-
IfcMaterialConstituent, IfcMaterialConstituentSet,
|
|
263
|
-
|
|
264
|
-
// Georeferencing (NEW!)
|
|
265
|
-
IfcMapConversion, IfcProjectedCRS, IfcGeometricRepresentationContext,
|
|
88
|
+
import { extractGeoreferencingOnDemand } from '@ifc-lite/parser';
|
|
266
89
|
|
|
267
|
-
|
|
268
|
-
IfcClassification, IfcClassificationReference,
|
|
90
|
+
const georef = extractGeoreferencingOnDemand(store);
|
|
269
91
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
92
|
+
if (georef?.hasGeoreference) {
|
|
93
|
+
console.log(`CRS: ${georef.projectedCRS?.name}`);
|
|
94
|
+
console.log(`Origin: ${georef.eastings}, ${georef.northings}, ${georef.orthogonalHeight}`);
|
|
95
|
+
console.log(`Rotation: ${georef.rotationRadians} rad`);
|
|
96
|
+
}
|
|
275
97
|
```
|
|
276
98
|
|
|
277
|
-
## Schema Coverage
|
|
278
|
-
|
|
279
|
-
### Before (Manual Implementation)
|
|
280
|
-
- ~70 entities manually implemented
|
|
281
|
-
- ~7% schema coverage
|
|
282
|
-
- Missing: materials, georeferencing, infrastructure
|
|
283
|
-
|
|
284
|
-
### After (Code Generation)
|
|
285
|
-
- **776 entities** (IFC4) or **876 entities** (IFC4X3)
|
|
286
|
-
- **100% schema coverage**
|
|
287
|
-
- Includes: materials, georeferencing, infrastructure, classifications, structural, MEP, cost, scheduling
|
|
288
|
-
|
|
289
99
|
## Performance
|
|
290
100
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
## Examples
|
|
101
|
+
| Model size | Parse time |
|
|
102
|
+
|---:|---:|
|
|
103
|
+
| 10 MB | ~100–200 ms |
|
|
104
|
+
| 50 MB | ~600–700 ms |
|
|
105
|
+
| 200 MB | ~2.5–3 s |
|
|
298
106
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
-
|
|
302
|
-
- **material-report.ts** - Generate material usage reports
|
|
303
|
-
- **georef-transform.ts** - Coordinate system transformations
|
|
304
|
-
- **classification-query.ts** - Query by classification codes
|
|
305
|
-
|
|
306
|
-
## Development
|
|
307
|
-
|
|
308
|
-
```bash
|
|
309
|
-
# Build
|
|
310
|
-
npm run build
|
|
311
|
-
|
|
312
|
-
# Test
|
|
313
|
-
npm test
|
|
314
|
-
|
|
315
|
-
# Regenerate IFC schema (if EXPRESS files updated)
|
|
316
|
-
cd ../codegen
|
|
317
|
-
npm run generate:ifc4
|
|
318
|
-
```
|
|
107
|
+
- Tokenization: ~1,259 MB/s on M1/M2 laptops
|
|
108
|
+
- Bundle: ~200 KB gzipped (schema registry included)
|
|
109
|
+
- Memory: TypedArray columnar storage
|
|
319
110
|
|
|
320
|
-
##
|
|
111
|
+
## API
|
|
321
112
|
|
|
322
|
-
|
|
113
|
+
See the [Parsing Guide](https://louistrue.github.io/ifc-lite/guide/parsing/) and [API Reference](https://louistrue.github.io/ifc-lite/api/typescript/#ifc-liteparser).
|
|
323
114
|
|
|
324
115
|
## License
|
|
325
116
|
|
|
326
|
-
|
|
117
|
+
[MPL-2.0](../../LICENSE)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classification-extractor.d.ts","sourceRoot":"","sources":["../src/classification-extractor.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"classification-extractor.d.ts","sourceRoot":"","sources":["../src/classification-extractor.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,yBAAyB;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC7C,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;IAC/D,YAAY,EAAE,yBAAyB,EAAE,CAAC;CAC3C;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,EAChC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GACpC,mBAAmB,CAsCrB;AAmED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,EACjB,mBAAmB,EAAE,mBAAmB,GACvC,uBAAuB,EAAE,CAc3B;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,EACjB,mBAAmB,EAAE,mBAAmB,GACvC,MAAM,GAAG,SAAS,CAGpB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,mBAAmB,EAAE,MAAM,EAC3B,mBAAmB,EAAE,mBAAmB,GACvC,MAAM,EAAE,CA8BV;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,mBAAmB,EAAE,mBAAmB,GACvC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAavB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,mBAAmB,EAAE,MAAM,EAC3B,mBAAmB,EAAE,mBAAmB,GACvC,MAAM,GAAG,SAAS,CAmBpB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IfcDataStore } from './columnar-parser.js';
|
|
2
|
+
export interface ClassificationInfo {
|
|
3
|
+
system?: string;
|
|
4
|
+
identification?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
location?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
path?: string[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Extract classifications for a single entity ON-DEMAND.
|
|
12
|
+
* Uses the onDemandClassificationMap built during parsing.
|
|
13
|
+
* Falls back to relationship graph when on-demand map is not available (e.g., server-loaded models).
|
|
14
|
+
* Also checks type-level associations via IfcRelDefinesByType.
|
|
15
|
+
* Returns an array of classification references with system info.
|
|
16
|
+
*/
|
|
17
|
+
export declare function extractClassificationsOnDemand(store: IfcDataStore, entityId: number): ClassificationInfo[];
|
|
18
|
+
//# sourceMappingURL=classification-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classification-resolver.d.ts","sourceRoot":"","sources":["../src/classification-resolver.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,WAAW,kBAAkB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC1C,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,MAAM,GACjB,kBAAkB,EAAE,CA0EtB"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* Classification extraction — resolves IfcClassificationReference chains
|
|
6
|
+
* and IfcClassification systems for entity classification lookups.
|
|
7
|
+
*/
|
|
8
|
+
import { EntityExtractor } from './entity-extractor.js';
|
|
9
|
+
import { RelationshipType } from '@ifc-lite/data';
|
|
10
|
+
/**
|
|
11
|
+
* Extract classifications for a single entity ON-DEMAND.
|
|
12
|
+
* Uses the onDemandClassificationMap built during parsing.
|
|
13
|
+
* Falls back to relationship graph when on-demand map is not available (e.g., server-loaded models).
|
|
14
|
+
* Also checks type-level associations via IfcRelDefinesByType.
|
|
15
|
+
* Returns an array of classification references with system info.
|
|
16
|
+
*/
|
|
17
|
+
export function extractClassificationsOnDemand(store, entityId) {
|
|
18
|
+
let classRefIds;
|
|
19
|
+
if (store.onDemandClassificationMap) {
|
|
20
|
+
classRefIds = store.onDemandClassificationMap.get(entityId);
|
|
21
|
+
}
|
|
22
|
+
else if (store.relationships) {
|
|
23
|
+
// Fallback: use relationship graph (server-loaded models)
|
|
24
|
+
const related = store.relationships.getRelated(entityId, RelationshipType.AssociatesClassification, 'inverse');
|
|
25
|
+
if (related.length > 0)
|
|
26
|
+
classRefIds = related;
|
|
27
|
+
}
|
|
28
|
+
// Also check type-level classifications via IfcRelDefinesByType
|
|
29
|
+
if (store.relationships) {
|
|
30
|
+
const typeIds = store.relationships.getRelated(entityId, RelationshipType.DefinesByType, 'inverse');
|
|
31
|
+
for (const typeId of typeIds) {
|
|
32
|
+
let typeClassRefs;
|
|
33
|
+
if (store.onDemandClassificationMap) {
|
|
34
|
+
typeClassRefs = store.onDemandClassificationMap.get(typeId);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const related = store.relationships.getRelated(typeId, RelationshipType.AssociatesClassification, 'inverse');
|
|
38
|
+
if (related.length > 0)
|
|
39
|
+
typeClassRefs = related;
|
|
40
|
+
}
|
|
41
|
+
if (typeClassRefs && typeClassRefs.length > 0) {
|
|
42
|
+
classRefIds = classRefIds ? [...classRefIds, ...typeClassRefs] : [...typeClassRefs];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (!classRefIds || classRefIds.length === 0)
|
|
47
|
+
return [];
|
|
48
|
+
if (!store.source?.length)
|
|
49
|
+
return [];
|
|
50
|
+
const extractor = new EntityExtractor(store.source);
|
|
51
|
+
const results = [];
|
|
52
|
+
for (const classRefId of classRefIds) {
|
|
53
|
+
const ref = store.entityIndex.byId.get(classRefId);
|
|
54
|
+
if (!ref)
|
|
55
|
+
continue;
|
|
56
|
+
const entity = extractor.extractEntity(ref);
|
|
57
|
+
if (!entity)
|
|
58
|
+
continue;
|
|
59
|
+
const typeUpper = entity.type.toUpperCase();
|
|
60
|
+
const attrs = entity.attributes || [];
|
|
61
|
+
if (typeUpper === 'IFCCLASSIFICATIONREFERENCE') {
|
|
62
|
+
// IfcClassificationReference: [Location, Identification, Name, ReferencedSource, Description, Sort]
|
|
63
|
+
const info = {
|
|
64
|
+
location: typeof attrs[0] === 'string' ? attrs[0] : undefined,
|
|
65
|
+
identification: typeof attrs[1] === 'string' ? attrs[1] : undefined,
|
|
66
|
+
name: typeof attrs[2] === 'string' ? attrs[2] : undefined,
|
|
67
|
+
description: typeof attrs[4] === 'string' ? attrs[4] : undefined,
|
|
68
|
+
};
|
|
69
|
+
// Walk up to find the classification system name
|
|
70
|
+
const referencedSourceId = typeof attrs[3] === 'number' ? attrs[3] : undefined;
|
|
71
|
+
if (referencedSourceId) {
|
|
72
|
+
const path = walkClassificationChain(store, extractor, referencedSourceId);
|
|
73
|
+
info.system = path.systemName;
|
|
74
|
+
info.path = path.codes;
|
|
75
|
+
}
|
|
76
|
+
results.push(info);
|
|
77
|
+
}
|
|
78
|
+
else if (typeUpper === 'IFCCLASSIFICATION') {
|
|
79
|
+
// IfcClassification: [Source, Edition, EditionDate, Name, Description, Location, ReferenceTokens]
|
|
80
|
+
results.push({
|
|
81
|
+
system: typeof attrs[3] === 'string' ? attrs[3] : undefined,
|
|
82
|
+
name: typeof attrs[3] === 'string' ? attrs[3] : undefined,
|
|
83
|
+
description: typeof attrs[4] === 'string' ? attrs[4] : undefined,
|
|
84
|
+
location: typeof attrs[5] === 'string' ? attrs[5] : undefined,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return results;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Walk up the IfcClassificationReference chain to find the root IfcClassification system.
|
|
92
|
+
*/
|
|
93
|
+
function walkClassificationChain(store, extractor, startId) {
|
|
94
|
+
const codes = [];
|
|
95
|
+
let currentId = startId;
|
|
96
|
+
const visited = new Set();
|
|
97
|
+
while (currentId !== undefined && !visited.has(currentId)) {
|
|
98
|
+
visited.add(currentId);
|
|
99
|
+
const ref = store.entityIndex.byId.get(currentId);
|
|
100
|
+
if (!ref)
|
|
101
|
+
break;
|
|
102
|
+
const entity = extractor.extractEntity(ref);
|
|
103
|
+
if (!entity)
|
|
104
|
+
break;
|
|
105
|
+
const typeUpper = entity.type.toUpperCase();
|
|
106
|
+
const attrs = entity.attributes || [];
|
|
107
|
+
if (typeUpper === 'IFCCLASSIFICATION') {
|
|
108
|
+
// Root: IfcClassification [Source, Edition, EditionDate, Name, ...]
|
|
109
|
+
const systemName = typeof attrs[3] === 'string' ? attrs[3] : undefined;
|
|
110
|
+
return { systemName, codes };
|
|
111
|
+
}
|
|
112
|
+
if (typeUpper === 'IFCCLASSIFICATIONREFERENCE') {
|
|
113
|
+
// IfcClassificationReference [Location, Identification, Name, ReferencedSource, ...]
|
|
114
|
+
const code = typeof attrs[1] === 'string' ? attrs[1] :
|
|
115
|
+
typeof attrs[2] === 'string' ? attrs[2] : undefined;
|
|
116
|
+
if (code)
|
|
117
|
+
codes.unshift(code);
|
|
118
|
+
currentId = typeof attrs[3] === 'number' ? attrs[3] : undefined;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return { codes };
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=classification-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classification-resolver.js","sourceRoot":"","sources":["../src/classification-resolver.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAYlD;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B,CAC1C,KAAmB,EACnB,QAAgB;IAEhB,IAAI,WAAiC,CAAC;IAEtC,IAAI,KAAK,CAAC,yBAAyB,E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AO,CAAC,IAAI,CAAC,CAAC;YAE9B,SAAS,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACpE,CAAC;aAAM,CAAC;YACJ,MAAM;QACV,CAAC;IACL,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level buffer attribute utilities for columnar parsing.
|
|
3
|
+
*
|
|
4
|
+
* Pure functions that operate on raw Uint8Array buffers to extract
|
|
5
|
+
* STEP entity attributes without TextDecoder overhead.
|
|
6
|
+
*/
|
|
7
|
+
import type { EntityRef } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Find the byte range of a quoted string at a specific attribute position in STEP entity bytes.
|
|
10
|
+
* Returns [start, end) byte offsets (excluding quotes), or null if not found.
|
|
11
|
+
*
|
|
12
|
+
* @param buffer - The IFC file buffer
|
|
13
|
+
* @param entityStart - byte offset of the entity
|
|
14
|
+
* @param entityLen - byte length of the entity
|
|
15
|
+
* @param attrIndex - 0-based attribute index (0=GlobalId, 2=Name)
|
|
16
|
+
*/
|
|
17
|
+
export declare function findQuotedAttrRange(buffer: Uint8Array, entityStart: number, entityLen: number, attrIndex: number): [number, number] | null;
|
|
18
|
+
/**
|
|
19
|
+
* Skip N commas at depth 0 in STEP bytes.
|
|
20
|
+
*/
|
|
21
|
+
export declare function skipCommas(buffer: Uint8Array, start: number, end: number, count: number): number;
|
|
22
|
+
/** Read a #ID entity reference as a number. Returns -1 if not an entity ref. */
|
|
23
|
+
export declare function readRefId(buffer: Uint8Array, pos: number, end: number): [number, number];
|
|
24
|
+
/** Read a list of entity refs (#id1,#id2,...) or a single #id. Returns [ids, newPos]. */
|
|
25
|
+
export declare function readRefList(buffer: Uint8Array, pos: number, end: number): [number[], number];
|
|
26
|
+
/**
|
|
27
|
+
* Batch extract GlobalId (attr[0]) and Name (attr[2]) for many entities using
|
|
28
|
+
* only 2 TextDecoder.decode() calls total (one for all GlobalIds, one for all Names).
|
|
29
|
+
*
|
|
30
|
+
* This is ~100x faster than calling extractEntity() per entity for large batches
|
|
31
|
+
* because it eliminates per-entity TextDecoder overhead which is significant in Firefox.
|
|
32
|
+
*
|
|
33
|
+
* Returns a Map from expressId → { globalId, name }.
|
|
34
|
+
*/
|
|
35
|
+
export declare function batchExtractGlobalIdAndName(buffer: Uint8Array, refs: EntityRef[], yieldIfNeeded?: () => Promise<void>): Promise<Map<number, {
|
|
36
|
+
globalId: string;
|
|
37
|
+
name: string;
|
|
38
|
+
}>>;
|
|
39
|
+
//# sourceMappingURL=columnar-parser-attributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"columnar-parser-attributes.d.ts","sourceRoot":"","sources":["../src/columnar-parser-attributes.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAC/B,MAAM,EAAE,UAAU,EAClB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAClB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAiDzB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAkBhG;AAED,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAYxF;AAED,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAsB5F;AAED;;;;;;;;GAQG;AACH,wBAAsB,2BAA2B,CAC7C,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,SAAS,EAAE,EACjB,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GACpC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAmF1D"}
|