@ifc-lite/export 3.1.0 → 4.0.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 +3 -1
- package/dist/anonymize-export.d.ts.map +1 -1
- package/dist/anonymize-export.js +108 -8
- package/dist/anonymize-export.js.map +1 -1
- package/dist/anonymize-placement.js +4 -4
- package/dist/anonymize-scrub.d.ts.map +1 -1
- package/dist/anonymize-scrub.js +5 -2
- package/dist/anonymize-scrub.js.map +1 -1
- package/dist/anonymize-types.d.ts +30 -7
- package/dist/anonymize-types.d.ts.map +1 -1
- package/dist/declared-property-type.d.ts +15 -0
- package/dist/declared-property-type.d.ts.map +1 -1
- package/dist/declared-property-type.js +43 -0
- package/dist/declared-property-type.js.map +1 -1
- package/dist/georef-closure.d.ts +55 -0
- package/dist/georef-closure.d.ts.map +1 -0
- package/dist/georef-closure.js +95 -0
- package/dist/georef-closure.js.map +1 -0
- package/dist/glb.d.ts.map +1 -1
- package/dist/glb.js +26 -2
- package/dist/glb.js.map +1 -1
- package/dist/ifc5-classification.d.ts +36 -0
- package/dist/ifc5-classification.d.ts.map +1 -0
- package/dist/ifc5-classification.js +46 -0
- package/dist/ifc5-classification.js.map +1 -0
- package/dist/ifc5-export-helpers.d.ts +32 -0
- package/dist/ifc5-export-helpers.d.ts.map +1 -0
- package/dist/ifc5-export-helpers.js +84 -0
- package/dist/ifc5-export-helpers.js.map +1 -0
- package/dist/ifc5-exporter.d.ts.map +1 -1
- package/dist/ifc5-exporter.js +14 -86
- package/dist/ifc5-exporter.js.map +1 -1
- package/dist/ifc5-material.d.ts +38 -0
- package/dist/ifc5-material.d.ts.map +1 -0
- package/dist/ifc5-material.js +32 -0
- package/dist/ifc5-material.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/merged-context.d.ts +100 -0
- package/dist/merged-context.d.ts.map +1 -0
- package/dist/merged-context.js +211 -0
- package/dist/merged-context.js.map +1 -0
- package/dist/merged-empty-containers.d.ts +63 -0
- package/dist/merged-empty-containers.d.ts.map +1 -0
- package/dist/merged-empty-containers.js +354 -0
- package/dist/merged-empty-containers.js.map +1 -0
- package/dist/merged-exporter.d.ts +28 -67
- package/dist/merged-exporter.d.ts.map +1 -1
- package/dist/merged-exporter.js +134 -258
- package/dist/merged-exporter.js.map +1 -1
- package/dist/merged-guid.d.ts +48 -0
- package/dist/merged-guid.d.ts.map +1 -0
- package/dist/merged-guid.js +128 -0
- package/dist/merged-guid.js.map +1 -0
- package/dist/merged-rel-aggregates.d.ts +63 -0
- package/dist/merged-rel-aggregates.d.ts.map +1 -0
- package/dist/merged-rel-aggregates.js +122 -0
- package/dist/merged-rel-aggregates.js.map +1 -0
- package/dist/merged-remap.d.ts +18 -0
- package/dist/merged-remap.d.ts.map +1 -0
- package/dist/merged-remap.js +66 -0
- package/dist/merged-remap.js.map +1 -0
- package/dist/merged-subcontext.d.ts +41 -0
- package/dist/merged-subcontext.d.ts.map +1 -0
- package/dist/merged-subcontext.js +99 -0
- package/dist/merged-subcontext.js.map +1 -0
- package/dist/parquet-exporter-ondemand.d.ts +34 -0
- package/dist/parquet-exporter-ondemand.d.ts.map +1 -0
- package/dist/parquet-exporter-ondemand.js +89 -0
- package/dist/parquet-exporter-ondemand.js.map +1 -0
- package/dist/parquet-exporter.d.ts +1 -29
- package/dist/parquet-exporter.d.ts.map +1 -1
- package/dist/parquet-exporter.js +59 -81
- package/dist/parquet-exporter.js.map +1 -1
- package/dist/parquet-type-strings.d.ts +11 -0
- package/dist/parquet-type-strings.d.ts.map +1 -0
- package/dist/parquet-type-strings.js +40 -0
- package/dist/parquet-type-strings.js.map +1 -0
- package/dist/parquet-uint32-columns.d.ts +30 -0
- package/dist/parquet-uint32-columns.d.ts.map +1 -0
- package/dist/parquet-uint32-columns.js +38 -0
- package/dist/parquet-uint32-columns.js.map +1 -0
- package/dist/reference-collector.d.ts +0 -31
- package/dist/reference-collector.d.ts.map +1 -1
- package/dist/reference-collector.js +27 -82
- package/dist/reference-collector.js.map +1 -1
- package/dist/related-entities.d.ts.map +1 -1
- package/dist/related-entities.js +19 -4
- package/dist/related-entities.js.map +1 -1
- package/dist/schema-converter-attr-remap.d.ts +53 -0
- package/dist/schema-converter-attr-remap.d.ts.map +1 -0
- package/dist/schema-converter-attr-remap.js +106 -0
- package/dist/schema-converter-attr-remap.js.map +1 -0
- package/dist/schema-converter.d.ts.map +1 -1
- package/dist/schema-converter.js +24 -1
- package/dist/schema-converter.js.map +1 -1
- package/dist/schema-untranslatable.d.ts +35 -0
- package/dist/schema-untranslatable.d.ts.map +1 -0
- package/dist/schema-untranslatable.js +60 -0
- package/dist/schema-untranslatable.js.map +1 -0
- package/dist/step-argument-parser.d.ts.map +1 -1
- package/dist/step-argument-parser.js +11 -1
- package/dist/step-argument-parser.js.map +1 -1
- package/dist/step-attribute-mutations.js +14 -11
- package/dist/step-attribute-mutations.js.map +1 -1
- package/dist/step-collection.d.ts.map +1 -1
- package/dist/step-collection.js +20 -6
- package/dist/step-collection.js.map +1 -1
- package/dist/step-export-types.d.ts +15 -0
- package/dist/step-export-types.d.ts.map +1 -1
- package/dist/step-export-types.js +10 -0
- package/dist/step-export-types.js.map +1 -1
- package/dist/step-exporter.d.ts.map +1 -1
- package/dist/step-exporter.js +9 -1
- package/dist/step-exporter.js.map +1 -1
- package/dist/step-map-unit.d.ts +2 -1
- package/dist/step-map-unit.d.ts.map +1 -1
- package/dist/step-map-unit.js.map +1 -1
- package/dist/step-serialization.d.ts +10 -30
- package/dist/step-serialization.d.ts.map +1 -1
- package/dist/step-serialization.js +10 -60
- package/dist/step-serialization.js.map +1 -1
- package/dist/step-source-iteration.d.ts.map +1 -1
- package/dist/step-source-iteration.js +21 -0
- package/dist/step-source-iteration.js.map +1 -1
- package/dist/style-closure.d.ts +91 -0
- package/dist/style-closure.d.ts.map +1 -0
- package/dist/style-closure.js +164 -0
- package/dist/style-closure.js.map +1 -0
- package/dist/subset-entity-reader.d.ts +10 -9
- package/dist/subset-entity-reader.d.ts.map +1 -1
- package/dist/subset-entity-reader.js +21 -11
- package/dist/subset-entity-reader.js.map +1 -1
- package/dist/subset-roots.d.ts +17 -1
- package/dist/subset-roots.d.ts.map +1 -1
- package/dist/subset-roots.js +67 -2
- package/dist/subset-roots.js.map +1 -1
- package/dist/type-owned-psets.d.ts +19 -0
- package/dist/type-owned-psets.d.ts.map +1 -1
- package/dist/type-owned-psets.js +31 -0
- package/dist/type-owned-psets.js.map +1 -1
- package/dist/unit-normalize.d.ts.map +1 -1
- package/dist/unit-normalize.js +10 -2
- package/dist/unit-normalize.js.map +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
import { collectRefsInByteRange } from './reference-collector.js';
|
|
5
|
+
/**
|
|
6
|
+
* Every concrete STEP type name an `IfcMapConversion` can be written as.
|
|
7
|
+
* `entityIndex.byType` is keyed by the RAW STEP type name, not resolved to a
|
|
8
|
+
* supertype, so asking for `IFCMAPCONVERSION` alone misses every file
|
|
9
|
+
* written with IFC4X3's concrete subtype `IfcMapConversionScaled` — the same
|
|
10
|
+
* mistake `step-georeferencing.ts`'s `MAP_CONVERSION_STEP_TYPES`,
|
|
11
|
+
* `subset-roots.ts`'s `IDENTIFYING_TYPES`/`COORDINATE_REFERENCE_TYPES`, and
|
|
12
|
+
* `on-demand-georeferencing.ts`'s `GEOREF_TYPES` all guard against (#3243).
|
|
13
|
+
*/
|
|
14
|
+
const MAP_CONVERSION_STEP_TYPES = [
|
|
15
|
+
'IFCMAPCONVERSION',
|
|
16
|
+
'IFCMAPCONVERSIONSCALED',
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* Collect `IFCMAPCONVERSION` (and, transitively, the `IFCPROJECTEDCRS` it
|
|
20
|
+
* names) when the closure already contains the `IFCGEOMETRICREPRESENTATIONCONTEXT`
|
|
21
|
+
* it converts.
|
|
22
|
+
*
|
|
23
|
+
* Must be called AFTER `collectReferencedEntityIds` (and, if used,
|
|
24
|
+
* `collectStyleEntities`) so the context is already in the closure. Same
|
|
25
|
+
* reverse-pass shape as `collectStyleEntities` (nothing references a styled
|
|
26
|
+
* item back either), just against `IFCMAPCONVERSION`.
|
|
27
|
+
*
|
|
28
|
+
* `excludeIds` (e.g. `pass.hiddenProductIds` / a subset export's
|
|
29
|
+
* `excludedIds`) is honoured the same way `collectReferencedEntityIds`
|
|
30
|
+
* honours it: an excluded `IfcMapConversion`/`IfcProjectedCRS` — for instance
|
|
31
|
+
* one the anonymize-export "remove georeferencing" option deliberately routed
|
|
32
|
+
* into `excludedIds` via `subset-roots.ts`'s `IDENTIFYING_TYPES` — must stay
|
|
33
|
+
* excluded. Without this check, this reverse pass would resurrect it: its
|
|
34
|
+
* only hook, the geometric representation context, is unconditional
|
|
35
|
+
* infrastructure and stays in the closure regardless of that exclusion.
|
|
36
|
+
*
|
|
37
|
+
* @param closure - The existing closure set (mutated in place)
|
|
38
|
+
* @param source - The original STEP file source buffer
|
|
39
|
+
* @param entityIndex - Full entity index with type info and byType lookup
|
|
40
|
+
* @param excludeIds - Entity IDs to never add, even if they reference the
|
|
41
|
+
* closure (deliberately-excluded ids, e.g. a privacy-scrub target)
|
|
42
|
+
*/
|
|
43
|
+
export function collectGeoreferencingEntities(closure, source, entityIndex, excludeIds) {
|
|
44
|
+
const mapConversionIds = MAP_CONVERSION_STEP_TYPES.flatMap((typeName) => entityIndex.byType.get(typeName) ?? []);
|
|
45
|
+
if (mapConversionIds.length === 0)
|
|
46
|
+
return;
|
|
47
|
+
const queue = [];
|
|
48
|
+
const refsOf = (expressId, ref) => {
|
|
49
|
+
const authored = entityIndex.byId.refsOf?.(expressId);
|
|
50
|
+
if (authored)
|
|
51
|
+
return authored.slice();
|
|
52
|
+
return collectRefsInByteRange(source, ref.byteOffset, ref.byteLength);
|
|
53
|
+
};
|
|
54
|
+
for (const expressId of mapConversionIds) {
|
|
55
|
+
if (closure.has(expressId))
|
|
56
|
+
continue;
|
|
57
|
+
if (excludeIds?.has(expressId))
|
|
58
|
+
continue;
|
|
59
|
+
const entityRef = entityIndex.byId.get(expressId);
|
|
60
|
+
if (!entityRef)
|
|
61
|
+
continue;
|
|
62
|
+
// Check SourceCRS specifically — the geometric representation context
|
|
63
|
+
// IfcMapConversion converts — not "any referenced id". SourceCRS is
|
|
64
|
+
// IfcMapConversion's first attribute, so among the referenced ids other
|
|
65
|
+
// than the entity's own (the byte scan yields the record's own "#N="
|
|
66
|
+
// label first, since `ref.byteOffset` starts there, not after it), it is
|
|
67
|
+
// the first one. Checking "any ref" instead let a closure that already
|
|
68
|
+
// contained IfcProjectedCRS (TargetCRS) — reachable some other way, with
|
|
69
|
+
// the context never in the closure — wrongly rescue IfcMapConversion,
|
|
70
|
+
// and the forward walk below then pulled the context in too.
|
|
71
|
+
const refs = refsOf(expressId, entityRef).filter((id) => id !== expressId);
|
|
72
|
+
const sourceCrs = refs[0];
|
|
73
|
+
if (sourceCrs !== undefined && closure.has(sourceCrs)) {
|
|
74
|
+
closure.add(expressId);
|
|
75
|
+
queue.push(expressId);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Walk forward from the newly added IFCMAPCONVERSION to pull in
|
|
79
|
+
// IFCPROJECTEDCRS (TargetCRS) and its referenced units.
|
|
80
|
+
while (queue.length > 0) {
|
|
81
|
+
const entityId = queue.pop();
|
|
82
|
+
const ref = entityIndex.byId.get(entityId);
|
|
83
|
+
if (!ref)
|
|
84
|
+
continue;
|
|
85
|
+
for (const referencedId of refsOf(entityId, ref)) {
|
|
86
|
+
if (!closure.has(referencedId)
|
|
87
|
+
&& !excludeIds?.has(referencedId)
|
|
88
|
+
&& entityIndex.byId.has(referencedId)) {
|
|
89
|
+
closure.add(referencedId);
|
|
90
|
+
queue.push(referencedId);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=georef-closure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"georef-closure.js","sourceRoot":"","sources":["../src/georef-closure.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAoB/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE;;;;;;;;GAQG;AACH,MAAM,yBAAyB,GAAsB;IACnD,kBAAkB;IAClB,wBAAwB;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,6BAA6B,CAC3C,OAAoB,EACpB,MAAmC,EACnC,WAOC,EACD,UAAgC;IAEhC,MAAM,gBAAgB,GAAG,yBAAyB,CAAC,OAAO,CACxD,CAAC,QAAQ,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CACrD,CAAC;IACF,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAE1C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAG,CAAC,SAAiB,EAAE,GAA+C,EAAY,EAAE;QAC9F,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtC,OAAO,sBAAsB,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;IACxE,CAAC,CAAC;IAEF,KAAK,MAAM,SAAS,IAAI,gBAAgB,EAAE,CAAC;QACzC,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;YAAE,SAAS;QACrC,IAAI,UAAU,EAAE,GA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C;gBAC1B,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/glb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glb.d.ts","sourceRoot":"","sources":["../src/glb.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"glb.d.ts","sourceRoot":"","sources":["../src/glb.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;GAGG;AAEH,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,GAAG,CAAC;IACV,GAAG,EAAE,UAAU,CAAC;CACjB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS,CA8CnD;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAWtD;AAiBD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAajG;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,UAAU,GAAG,QAAQ,EAAE,CAoG9D"}
|
package/dist/glb.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
2
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
import { linearToSrgb } from '@ifc-lite/data';
|
|
4
5
|
export function parseGLB(glb) {
|
|
6
|
+
if (glb.byteLength < 12)
|
|
7
|
+
throw new Error('GLB file too small for header');
|
|
5
8
|
const dv = new DataView(glb.buffer, glb.byteOffset, glb.byteLength);
|
|
6
9
|
const magic = dv.getUint32(0, true);
|
|
7
10
|
if (magic !== 0x46546c67)
|
|
@@ -15,10 +18,24 @@ export function parseGLB(glb) {
|
|
|
15
18
|
let offset = 12;
|
|
16
19
|
let json = null;
|
|
17
20
|
let bin = null;
|
|
18
|
-
|
|
21
|
+
// Bound the walk by the DECLARED (and above, validated <= glb.byteLength)
|
|
22
|
+
// `totalLen`, not the raw buffer length. Using `glb.byteLength` here let a
|
|
23
|
+
// buffer with bytes appended after a legitimate GLB's end (e.g. a phantom
|
|
24
|
+
// chunk with the BIN magic) get parsed as additional real chunks — the
|
|
25
|
+
// last BIN/JSON chunk found wins, so an attacker-appended trailing chunk
|
|
26
|
+
// silently REPLACED the genuine bin/json. The walk now stops at `totalLen`,
|
|
27
|
+
// so such a trailing chunk is ignored rather than adopted; the file itself
|
|
28
|
+
// is not rejected. Each chunk is also checked against `totalLen` so a chunkLen
|
|
29
|
+
// that overruns the declared length throws instead of `subarray` silently
|
|
30
|
+
// clamping to a truncated view (mirrors the guard in the sibling GLB
|
|
31
|
+
// reader, `@ifc-lite/cache`'s `glb.ts`).
|
|
32
|
+
while (offset + 8 <= totalLen) {
|
|
19
33
|
const chunkLen = dv.getUint32(offset, true);
|
|
20
34
|
const chunkType = dv.getUint32(offset + 4, true);
|
|
21
35
|
offset += 8;
|
|
36
|
+
if (offset + chunkLen > totalLen) {
|
|
37
|
+
throw new Error(`GLB chunk extends beyond declared length: offset=${offset} chunkLen=${chunkLen} totalLen=${totalLen}`);
|
|
38
|
+
}
|
|
22
39
|
const chunk = glb.subarray(offset, offset + chunkLen);
|
|
23
40
|
offset += chunkLen;
|
|
24
41
|
if (chunkType === 0x4e4f534a) {
|
|
@@ -113,7 +130,14 @@ export function parseGLBToMeshData(glb) {
|
|
|
113
130
|
!Number.isFinite(a)) {
|
|
114
131
|
return [...DEFAULT_COLOR];
|
|
115
132
|
}
|
|
116
|
-
|
|
133
|
+
// baseColorFactor is linear-light per the glTF 2.0 spec; IFC colours (and
|
|
134
|
+
// the mesh colours MeshData.color feeds the viewer) are sRGB-encoded, and
|
|
135
|
+
// the exporter decodes sRGB into linear on write. Decode back to sRGB here
|
|
136
|
+
// so an export -> re-import round-trip is lossless. Alpha is not a colour
|
|
137
|
+
// channel and is passed through unchanged. Mirrors `@ifc-lite/cache`'s
|
|
138
|
+
// `resolveMaterialColor`, which applies the identical conversion to the
|
|
139
|
+
// other GLB reader in this repo — both call the same `linearToSrgb`.
|
|
140
|
+
return [linearToSrgb(r), linearToSrgb(g), linearToSrgb(b), a];
|
|
117
141
|
};
|
|
118
142
|
const readAccessor = (accessorIndex) => {
|
|
119
143
|
const acc = accessors[accessorIndex];
|
package/dist/glb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glb.js","sourceRoot":"","sources":["../src/glb.ts"],"names":[],"mappings":"AAAA;;+DAE+D;
|
|
1
|
+
{"version":3,"file":"glb.js","sourceRoot":"","sources":["../src/glb.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAG/D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAY9C,MAAM,UAAU,QAAQ,CAAC,GAAe;IACtC,IAAI,GAAG,CAAC,UAAU,GAAG,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC1E,MAAM,EAAE,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;IACpE,MAAM,KAAK,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACpC,IAAI,KAAK,KAAK,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC/D,MAAM,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACtC,IAAI,OAA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CAAC,CAAC;QAC1F,GAAG,CAAC,IAAI,CAAC;YACP,SAAS;YACT,SAAS,EAAE,IAAI,YAAY,CAAC,GAAG,CAAC;YAChC,OAAO,EAAE,IAAI,YAAY,CAAC,GAAG,CAAC;YAC9B,OAAO,EAAE,IAAI,WAAW,CAAC,GAAG,CAAC;YAC7B,KAAK,EAAE,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC1C,OAAO,EAAE,YAAY;SACtB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classification carrier for the IFC5 (IFCX) exporter (`ifc5-exporter.ts`,
|
|
3
|
+
* split out to stay under the module-size budget).
|
|
4
|
+
*
|
|
5
|
+
* Resolves an entity's `IfcClassificationReference`s (via
|
|
6
|
+
* `IfcRelAssociatesClassification`, including type-level associations) into
|
|
7
|
+
* the `ifclite::classifications` wire shape (`{ system, code, uri?,
|
|
8
|
+
* description? }[]`), the same shape and attribute key
|
|
9
|
+
* `@ifc-lite/collab`'s snapshot layer (`structured-attrs.ts`) already uses
|
|
10
|
+
* for its structured classification branch — so a classified entity reads
|
|
11
|
+
* back the same way whether the IFCX came from this exporter or from a
|
|
12
|
+
* collab snapshot.
|
|
13
|
+
*/
|
|
14
|
+
import type { IfcDataStore } from '@ifc-lite/parser';
|
|
15
|
+
export interface Ifc5ClassificationRef {
|
|
16
|
+
system: string;
|
|
17
|
+
code: string;
|
|
18
|
+
uri?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* `extractClassificationsOnDemand` needs the source STEP buffer plus the
|
|
23
|
+
* `onDemandClassificationMap` built during columnar parsing; an IFCX-sourced
|
|
24
|
+
* `IfcDataStore` (round-tripping an already-IFC5 model) has neither, so this
|
|
25
|
+
* resolves to an empty list there rather than throwing — that input never
|
|
26
|
+
* carried a classification to lose in the first place.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getClassificationsForEntity(dataStore: IfcDataStore, entityId: number): Ifc5ClassificationRef[];
|
|
29
|
+
/**
|
|
30
|
+
* Mutates `attributes` in place with the entity's classifications under
|
|
31
|
+
* `ifclite::classifications` (the exporter's `attributes` record is built
|
|
32
|
+
* incrementally per node, so this mirrors how Name/Description are set
|
|
33
|
+
* directly rather than returned and merged).
|
|
34
|
+
*/
|
|
35
|
+
export declare function addClassificationAttribute(dataStore: IfcDataStore, entityId: number, attributes: Record<string, unknown>): void;
|
|
36
|
+
//# sourceMappingURL=ifc5-classification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ifc5-classification.d.ts","sourceRoot":"","sources":["../src/ifc5-classification.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIrD,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,YAAY,EACvB,QAAQ,EAAE,MAAM,GACf,qBAAqB,EAAE,CAqBzB;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,YAAY,EACvB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,IAAI,CAGN"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
import { extractClassificationsOnDemand } from '@ifc-lite/parser';
|
|
5
|
+
import { IFCLITE_ATTR } from '@ifc-lite/ifcx';
|
|
6
|
+
/**
|
|
7
|
+
* `extractClassificationsOnDemand` needs the source STEP buffer plus the
|
|
8
|
+
* `onDemandClassificationMap` built during columnar parsing; an IFCX-sourced
|
|
9
|
+
* `IfcDataStore` (round-tripping an already-IFC5 model) has neither, so this
|
|
10
|
+
* resolves to an empty list there rather than throwing — that input never
|
|
11
|
+
* carried a classification to lose in the first place.
|
|
12
|
+
*/
|
|
13
|
+
export function getClassificationsForEntity(dataStore, entityId) {
|
|
14
|
+
const infos = extractClassificationsOnDemand(dataStore, entityId);
|
|
15
|
+
const refs = [];
|
|
16
|
+
for (const info of infos) {
|
|
17
|
+
// A classification with neither a code nor a name carries nothing a
|
|
18
|
+
// reader could show or match against — skip it rather than emit a
|
|
19
|
+
// `{ system, code: '' }` placeholder that looks like real data.
|
|
20
|
+
const code = info.identification || info.name;
|
|
21
|
+
if (!code)
|
|
22
|
+
continue;
|
|
23
|
+
const ref = {
|
|
24
|
+
system: info.system || 'Unknown',
|
|
25
|
+
code,
|
|
26
|
+
};
|
|
27
|
+
if (info.location)
|
|
28
|
+
ref.uri = info.location;
|
|
29
|
+
if (info.description)
|
|
30
|
+
ref.description = info.description;
|
|
31
|
+
refs.push(ref);
|
|
32
|
+
}
|
|
33
|
+
return refs;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Mutates `attributes` in place with the entity's classifications under
|
|
37
|
+
* `ifclite::classifications` (the exporter's `attributes` record is built
|
|
38
|
+
* incrementally per node, so this mirrors how Name/Description are set
|
|
39
|
+
* directly rather than returned and merged).
|
|
40
|
+
*/
|
|
41
|
+
export function addClassificationAttribute(dataStore, entityId, attributes) {
|
|
42
|
+
const classifications = getClassificationsForEntity(dataStore, entityId);
|
|
43
|
+
if (classifications.length > 0)
|
|
44
|
+
attributes[IFCLITE_ATTR.CLASSIFICATIONS] = classifications;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=ifc5-classification.js.map
|
|
@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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** IFCX node in output, matching the shape `collectRequiredImports` scans. */
|
|
2
|
+
interface IfcxNodeOutputLike {
|
|
3
|
+
attributes?: Record<string, unknown>;
|
|
4
|
+
}
|
|
5
|
+
/** Standard IFC5 schema package URIs, keyed by the attribute prefix they provide. */
|
|
6
|
+
export declare const IFCX_SCHEMA_IMPORTS: {
|
|
7
|
+
/** Core IFC: bsi::ifc::class, bsi::ifc::presentation::*, bsi::ifc::material, bsi::ifc::spaceBoundary */
|
|
8
|
+
readonly IFC_CORE: "https://ifcx.dev/@standards.buildingsmart.org/ifc/core/ifc@v5a.ifcx";
|
|
9
|
+
/** IFC properties: bsi::ifc::prop::* */
|
|
10
|
+
readonly IFC_PROP: "https://ifcx.dev/@standards.buildingsmart.org/ifc/core/prop@v5a.ifcx";
|
|
11
|
+
/** OpenUSD geometry: usd::usdgeom::mesh, usd::xformop, usd::usdgeom::visibility */
|
|
12
|
+
readonly USD: "https://ifcx.dev/@openusd.org/usd@v1.ifcx";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Scan data nodes and return the list of standard IFCX import URIs needed
|
|
16
|
+
* for the attribute namespaces actually used.
|
|
17
|
+
*/
|
|
18
|
+
export declare function collectRequiredImports(nodes: IfcxNodeOutputLike[]): {
|
|
19
|
+
uri: string;
|
|
20
|
+
}[];
|
|
21
|
+
/**
|
|
22
|
+
* Generate a deterministic UUID-like string from an expressId.
|
|
23
|
+
* Format: 8-4-4-4-12 hex chars (UUID v4-like but deterministic).
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateUuid(id: number): string;
|
|
26
|
+
/**
|
|
27
|
+
* Convert STEP uppercase type name (e.g. "IFCWALL") to PascalCase class name (e.g. "IfcWall").
|
|
28
|
+
* Uses the IFC type enum lookup for canonical casing (e.g. "IfcRelAggregates", not "Ifcrelaggregates").
|
|
29
|
+
*/
|
|
30
|
+
export declare function stepTypeToClassName(stepType: string): string;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=ifc5-export-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ifc5-export-helpers.d.ts","sourceRoot":"","sources":["../src/ifc5-export-helpers.ts"],"names":[],"mappings":"AAWA,8EAA8E;AAC9E,UAAU,kBAAkB;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,qFAAqF;AACrF,eAAO,MAAM,mBAAmB;IAC9B,wGAAwG;;IAExG,wCAAwC;;IAExC,mFAAmF;;CAE3E,CAAC;AAEX;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,CAmCrF;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAG/C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAU5D"}
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
* Small standalone helpers for {@link Ifc5Exporter} — split out purely to
|
|
6
|
+
* keep ifc5-exporter.ts under its module-size budget; no behavior change.
|
|
7
|
+
*/
|
|
8
|
+
import { IfcTypeEnumToString, IfcTypeEnumFromString } from '@ifc-lite/data';
|
|
9
|
+
/** Standard IFC5 schema package URIs, keyed by the attribute prefix they provide. */
|
|
10
|
+
export const IFCX_SCHEMA_IMPORTS = {
|
|
11
|
+
/** Core IFC: bsi::ifc::class, bsi::ifc::presentation::*, bsi::ifc::material, bsi::ifc::spaceBoundary */
|
|
12
|
+
IFC_CORE: 'https://ifcx.dev/@standards.buildingsmart.org/ifc/core/ifc@v5a.ifcx',
|
|
13
|
+
/** IFC properties: bsi::ifc::prop::* */
|
|
14
|
+
IFC_PROP: 'https://ifcx.dev/@standards.buildingsmart.org/ifc/core/prop@v5a.ifcx',
|
|
15
|
+
/** OpenUSD geometry: usd::usdgeom::mesh, usd::xformop, usd::usdgeom::visibility */
|
|
16
|
+
USD: 'https://ifcx.dev/@openusd.org/usd@v1.ifcx',
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Scan data nodes and return the list of standard IFCX import URIs needed
|
|
20
|
+
* for the attribute namespaces actually used.
|
|
21
|
+
*/
|
|
22
|
+
export function collectRequiredImports(nodes) {
|
|
23
|
+
let needsIfcCore = false;
|
|
24
|
+
let needsIfcProp = false;
|
|
25
|
+
let needsUsd = false;
|
|
26
|
+
for (const node of nodes) {
|
|
27
|
+
if (!node.attributes)
|
|
28
|
+
continue;
|
|
29
|
+
for (const key of Object.keys(node.attributes)) {
|
|
30
|
+
// IFC core schemas: class, presentation, material, spaceBoundary
|
|
31
|
+
if (!needsIfcCore && (key === 'bsi::ifc::class' ||
|
|
32
|
+
key.startsWith('bsi::ifc::presentation::') ||
|
|
33
|
+
key === 'bsi::ifc::material' ||
|
|
34
|
+
key === 'bsi::ifc::spaceBoundary')) {
|
|
35
|
+
needsIfcCore = true;
|
|
36
|
+
}
|
|
37
|
+
// IFC property schemas: bsi::ifc::prop::*
|
|
38
|
+
if (!needsIfcProp && key.startsWith('bsi::ifc::prop::')) {
|
|
39
|
+
needsIfcProp = true;
|
|
40
|
+
}
|
|
41
|
+
// USD schemas: usd::*
|
|
42
|
+
if (!needsUsd && key.startsWith('usd::')) {
|
|
43
|
+
needsUsd = true;
|
|
44
|
+
}
|
|
45
|
+
if (needsIfcCore && needsIfcProp && needsUsd)
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
if (needsIfcCore && needsIfcProp && needsUsd)
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
const imports = [];
|
|
52
|
+
if (needsIfcCore)
|
|
53
|
+
imports.push({ uri: IFCX_SCHEMA_IMPORTS.IFC_CORE });
|
|
54
|
+
if (needsIfcProp)
|
|
55
|
+
imports.push({ uri: IFCX_SCHEMA_IMPORTS.IFC_PROP });
|
|
56
|
+
if (needsUsd)
|
|
57
|
+
imports.push({ uri: IFCX_SCHEMA_IMPORTS.USD });
|
|
58
|
+
return imports;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Generate a deterministic UUID-like string from an expressId.
|
|
62
|
+
* Format: 8-4-4-4-12 hex chars (UUID v4-like but deterministic).
|
|
63
|
+
*/
|
|
64
|
+
export function generateUuid(id) {
|
|
65
|
+
const hex = id.toString(16).padStart(12, '0');
|
|
66
|
+
return `00000000-0000-4000-8000-${hex}`;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Convert STEP uppercase type name (e.g. "IFCWALL") to PascalCase class name (e.g. "IfcWall").
|
|
70
|
+
* Uses the IFC type enum lookup for canonical casing (e.g. "IfcRelAggregates", not "Ifcrelaggregates").
|
|
71
|
+
*/
|
|
72
|
+
export function stepTypeToClassName(stepType) {
|
|
73
|
+
const enumVal = IfcTypeEnumFromString(stepType);
|
|
74
|
+
const name = IfcTypeEnumToString(enumVal);
|
|
75
|
+
if (name !== 'Unknown')
|
|
76
|
+
return name;
|
|
77
|
+
// Fallback for types not in the enum: simple prefix normalisation
|
|
78
|
+
const lower = stepType.toLowerCase();
|
|
79
|
+
if (lower.startsWith('ifc')) {
|
|
80
|
+
return 'Ifc' + lower.charAt(3).toUpperCase() + lower.slice(4);
|
|
81
|
+
}
|
|
82
|
+
return stepType;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=ifc5-export-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ifc5-export-helpers.js","sourceRoot":"","sources":["../src/ifc5-export-helpers.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;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":"","sources":["../src/ifc5-exporter.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAY,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ifc5-exporter.d.ts","sourceRoot":"","sources":["../src/ifc5-exporter.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAY,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAoBnE;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,aAkBhC,CAAC;AAMH,8BAA8B;AAC9B,MAAM,WAAW,iBAAiB;IAChC,kBAAkB;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,yCAAyC;IACzC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gEAAgE;IAChE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,wCAAwC;IACxC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mCAAmC;IACnC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2CAA2C;IAC3C,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACvC;;yEAEqE;IACrE,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;uEAEmE;IACnE,gBAAgB,CA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IA2B1B;;OAEG;IACH,OAAO,CAAC,eAAe;CAsBxB"}
|
package/dist/ifc5-exporter.js
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
2
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
-
import { IfcTypeEnumToString,
|
|
4
|
+
import { IfcTypeEnumToString, PropertyValueType, IFCX_VERSION, } from '@ifc-lite/data';
|
|
5
5
|
import { convertEntityType } from './schema-converter.js';
|
|
6
6
|
import { getEffectiveEntityIndex } from './effective-index.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/** Standard IFC5 schema package URIs, keyed by the attribute prefix they provide. */
|
|
11
|
-
const IFCX_SCHEMA_IMPORTS = {
|
|
12
|
-
/** Core IFC: bsi::ifc::class, bsi::ifc::presentation::*, bsi::ifc::material, bsi::ifc::spaceBoundary */
|
|
13
|
-
IFC_CORE: 'https://ifcx.dev/@standards.buildingsmart.org/ifc/core/ifc@v5a.ifcx',
|
|
14
|
-
/** IFC properties: bsi::ifc::prop::* */
|
|
15
|
-
IFC_PROP: 'https://ifcx.dev/@standards.buildingsmart.org/ifc/core/prop@v5a.ifcx',
|
|
16
|
-
/** OpenUSD geometry: usd::usdgeom::mesh, usd::xformop, usd::usdgeom::visibility */
|
|
17
|
-
USD: 'https://ifcx.dev/@openusd.org/usd@v1.ifcx',
|
|
18
|
-
};
|
|
7
|
+
import { buildMaterialAttribute } from './ifc5-material.js';
|
|
8
|
+
import { collectRequiredImports, generateUuid, stepTypeToClassName } from './ifc5-export-helpers.js';
|
|
9
|
+
import { addClassificationAttribute } from './ifc5-classification.js';
|
|
19
10
|
/**
|
|
20
11
|
* Property names that have official IFC5 schema definitions in prop@v5a.ifcx.
|
|
21
12
|
* Source: https://github.com/buildingSMART/ifcx.dev/blob/main/@standards.buildingsmart.org/ifc/core/prop@v5a.ifcx
|
|
@@ -175,13 +166,20 @@ export class Ifc5Exporter {
|
|
|
175
166
|
propertyCount++;
|
|
176
167
|
}
|
|
177
168
|
}
|
|
169
|
+
// Material (bsi::ifc::material) — see ifc5-material.ts.
|
|
170
|
+
if (options.includeProperties !== false) {
|
|
171
|
+
const material = buildMaterialAttribute(this.dataStore, expressId);
|
|
172
|
+
if (material) {
|
|
173
|
+
attributes['bsi::ifc::material'] = material;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
addClassificationAttribute(this.dataStore, expressId, attributes);
|
|
178
177
|
// Build node
|
|
179
178
|
const node = { path };
|
|
180
179
|
// Children from spatial hierarchy
|
|
181
180
|
const children = this.getChildrenForEntity(expressId);
|
|
182
|
-
if (Object.keys(children).length > 0)
|
|
181
|
+
if (Object.keys(children).length > 0)
|
|
183
182
|
node.children = children;
|
|
184
|
-
}
|
|
185
183
|
// Geometry as USD mesh
|
|
186
184
|
if (options.includeGeometry !== false) {
|
|
187
185
|
const meshes = meshByEntity.get(expressId);
|
|
@@ -197,9 +195,8 @@ export class Ifc5Exporter {
|
|
|
197
195
|
meshCount++;
|
|
198
196
|
}
|
|
199
197
|
}
|
|
200
|
-
if (Object.keys(attributes).length > 0)
|
|
198
|
+
if (Object.keys(attributes).length > 0)
|
|
201
199
|
node.attributes = attributes;
|
|
202
|
-
}
|
|
203
200
|
nodes.push(node);
|
|
204
201
|
emittedIds.add(expressId);
|
|
205
202
|
}
|
|
@@ -639,73 +636,4 @@ export class Ifc5Exporter {
|
|
|
639
636
|
return visible;
|
|
640
637
|
}
|
|
641
638
|
}
|
|
642
|
-
// ============================================================================
|
|
643
|
-
// Helpers
|
|
644
|
-
// ============================================================================
|
|
645
|
-
/**
|
|
646
|
-
* Scan data nodes and return the list of standard IFCX import URIs needed
|
|
647
|
-
* for the attribute namespaces actually used.
|
|
648
|
-
*/
|
|
649
|
-
function collectRequiredImports(nodes) {
|
|
650
|
-
let needsIfcCore = false;
|
|
651
|
-
let needsIfcProp = false;
|
|
652
|
-
let needsUsd = false;
|
|
653
|
-
for (const node of nodes) {
|
|
654
|
-
if (!node.attributes)
|
|
655
|
-
continue;
|
|
656
|
-
for (const key of Object.keys(node.attributes)) {
|
|
657
|
-
// IFC core schemas: class, presentation, material, spaceBoundary
|
|
658
|
-
if (!needsIfcCore && (key === 'bsi::ifc::class' ||
|
|
659
|
-
key.startsWith('bsi::ifc::presentation::') ||
|
|
660
|
-
key === 'bsi::ifc::material' ||
|
|
661
|
-
key === 'bsi::ifc::spaceBoundary')) {
|
|
662
|
-
needsIfcCore = true;
|
|
663
|
-
}
|
|
664
|
-
// IFC property schemas: bsi::ifc::prop::*
|
|
665
|
-
if (!needsIfcProp && key.startsWith('bsi::ifc::prop::')) {
|
|
666
|
-
needsIfcProp = true;
|
|
667
|
-
}
|
|
668
|
-
// USD schemas: usd::*
|
|
669
|
-
if (!needsUsd && key.startsWith('usd::')) {
|
|
670
|
-
needsUsd = true;
|
|
671
|
-
}
|
|
672
|
-
if (needsIfcCore && needsIfcProp && needsUsd)
|
|
673
|
-
break;
|
|
674
|
-
}
|
|
675
|
-
if (needsIfcCore && needsIfcProp && needsUsd)
|
|
676
|
-
break;
|
|
677
|
-
}
|
|
678
|
-
const imports = [];
|
|
679
|
-
if (needsIfcCore)
|
|
680
|
-
imports.push({ uri: IFCX_SCHEMA_IMPORTS.IFC_CORE });
|
|
681
|
-
if (needsIfcProp)
|
|
682
|
-
imports.push({ uri: IFCX_SCHEMA_IMPORTS.IFC_PROP });
|
|
683
|
-
if (needsUsd)
|
|
684
|
-
imports.push({ uri: IFCX_SCHEMA_IMPORTS.USD });
|
|
685
|
-
return imports;
|
|
686
|
-
}
|
|
687
|
-
/**
|
|
688
|
-
* Generate a deterministic UUID-like string from an expressId.
|
|
689
|
-
* Format: 8-4-4-4-12 hex chars (UUID v4-like but deterministic).
|
|
690
|
-
*/
|
|
691
|
-
function generateUuid(id) {
|
|
692
|
-
const hex = id.toString(16).padStart(12, '0');
|
|
693
|
-
return `00000000-0000-4000-8000-${hex}`;
|
|
694
|
-
}
|
|
695
|
-
/**
|
|
696
|
-
* Convert STEP uppercase type name (e.g. "IFCWALL") to PascalCase class name (e.g. "IfcWall").
|
|
697
|
-
* Uses the IFC type enum lookup for canonical casing (e.g. "IfcRelAggregates", not "Ifcrelaggregates").
|
|
698
|
-
*/
|
|
699
|
-
function stepTypeToClassName(stepType) {
|
|
700
|
-
const enumVal = IfcTypeEnumFromString(stepType);
|
|
701
|
-
const name = IfcTypeEnumToString(enumVal);
|
|
702
|
-
if (name !== 'Unknown')
|
|
703
|
-
return name;
|
|
704
|
-
// Fallback for types not in the enum: simple prefix normalisation
|
|
705
|
-
const lower = stepType.toLowerCase();
|
|
706
|
-
if (lower.startsWith('ifc')) {
|
|
707
|
-
return 'Ifc' + lower.charAt(3).toUpperCase() + lower.slice(4);
|
|
708
|
-
}
|
|
709
|
-
return stepType;
|
|
710
|
-
}
|
|
711
639
|
//# sourceMappingURL=ifc5-exporter.js.map
|