@ifc-lite/cache 3.0.6 → 3.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 +51 -23
- package/dist/adapt.d.ts +72 -0
- package/dist/adapt.d.ts.map +1 -0
- package/dist/adapt.js +68 -0
- package/dist/adapt.js.map +1 -0
- package/dist/glb-color.d.ts +15 -0
- package/dist/glb-color.d.ts.map +1 -0
- package/dist/glb-color.js +18 -0
- package/dist/glb-color.js.map +1 -0
- package/dist/glb.d.ts.map +1 -1
- package/dist/glb.js +3 -3
- package/dist/glb.js.map +1 -1
- package/dist/index.d.ts +18 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/dist/reader.js +2 -2
- package/dist/reader.js.map +1 -1
- package/dist/sections/entities.d.ts +11 -2
- package/dist/sections/entities.d.ts.map +1 -1
- package/dist/sections/entities.js +35 -107
- package/dist/sections/entities.js.map +1 -1
- package/dist/sections/geometry.d.ts.map +1 -1
- package/dist/sections/geometry.js +92 -0
- package/dist/sections/geometry.js.map +1 -1
- package/dist/sections/properties.d.ts.map +1 -1
- package/dist/sections/properties.js +23 -26
- package/dist/sections/properties.js.map +1 -1
- package/dist/sections/quantities.d.ts.map +1 -1
- package/dist/sections/quantities.js +26 -25
- package/dist/sections/quantities.js.map +1 -1
- package/dist/sections/relationships.d.ts +25 -2
- package/dist/sections/relationships.d.ts.map +1 -1
- package/dist/sections/relationships.js +150 -16
- package/dist/sections/relationships.js.map +1 -1
- package/dist/types.d.ts +67 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +67 -1
- package/dist/types.js.map +1 -1
- package/package.json +5 -4
|
@@ -1,7 +1,8 @@
|
|
|
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 {
|
|
4
|
+
import { entityTableFromColumns } from '@ifc-lite/data';
|
|
5
|
+
import { FORMAT_VERSION } from '../types.js';
|
|
5
6
|
/**
|
|
6
7
|
* Write EntityTable to buffer
|
|
7
8
|
* Format:
|
|
@@ -18,11 +19,16 @@ import { IfcTypeEnum, IfcTypeEnumToString, IfcTypeEnumFromString, IFC_ENTITY_NAM
|
|
|
18
19
|
* - geometryIndex: Int32Array[count]
|
|
19
20
|
* - typeRangeCount: uint16
|
|
20
21
|
* - typeRanges: [type:uint16, start:uint32, end:uint32][]
|
|
22
|
+
* - rawTypeName: Uint32Array[count] (string indices; v15+ only)
|
|
21
23
|
*
|
|
22
24
|
* The typeRanges triples are vestigial on read: `readEntities` derives the
|
|
23
25
|
* spans from the typeEnum column instead, because pre-#3101 caches stored
|
|
24
26
|
* `start + count` here and the format version does not distinguish them.
|
|
25
27
|
* They are still written so the section layout is unchanged.
|
|
28
|
+
*
|
|
29
|
+
* `rawTypeName` is appended AFTER the typeRanges triples rather than beside
|
|
30
|
+
* the other columns so the v14 prefix stays byte-identical; a v15 reader
|
|
31
|
+
* handed a v14 section simply stops where the old section ended.
|
|
26
32
|
*/
|
|
27
33
|
export function writeEntities(writer, entities) {
|
|
28
34
|
const count = entities.count;
|
|
@@ -47,11 +53,23 @@ export function writeEntities(writer, entities) {
|
|
|
47
53
|
writer.writeUint32(range.start);
|
|
48
54
|
writer.writeUint32(range.end);
|
|
49
55
|
}
|
|
56
|
+
// Raw IFC class names (v15+). Most concrete IFC product classes have no
|
|
57
|
+
// `IfcTypeEnum` member, so without this column `getTypeName` can only
|
|
58
|
+
// answer 'Unknown' for them after a cache load, while the live parser
|
|
59
|
+
// table answers with the real class. A table built without the column
|
|
60
|
+
// (server hydration) writes zeroes, which read back as the empty string
|
|
61
|
+
// and degrade to the same enum-only answer as before.
|
|
62
|
+
const raw = entities.rawTypeName;
|
|
63
|
+
writer.writeTypedArray(raw && raw.length >= count ? raw.subarray(0, count) : new Uint32Array(count));
|
|
50
64
|
}
|
|
51
65
|
/**
|
|
52
|
-
* Read EntityTable from buffer
|
|
66
|
+
* Read EntityTable from buffer.
|
|
67
|
+
*
|
|
68
|
+
* `version` is the cache header's FORMAT_VERSION. v15+ sections carry a
|
|
69
|
+
* trailing `rawTypeName` column; older ones stop after the typeRanges
|
|
70
|
+
* triples and must not be read past.
|
|
53
71
|
*/
|
|
54
|
-
export function readEntities(reader, strings) {
|
|
72
|
+
export function readEntities(reader, strings, version = FORMAT_VERSION) {
|
|
55
73
|
const count = reader.readUint32();
|
|
56
74
|
// Read columnar arrays
|
|
57
75
|
const expressId = reader.readUint32Array(count);
|
|
@@ -69,55 +87,24 @@ export function readEntities(reader, strings) {
|
|
|
69
87
|
// caches written before #3101 hold `start + count`, later ones hold a
|
|
70
88
|
// `[firstRow, lastRow + 1]` span, and FORMAT_VERSION was deliberately not
|
|
71
89
|
// bumped (header.ts accepts any version <= FORMAT_VERSION by design), so
|
|
72
|
-
// both vintages arrive here indistinguishable.
|
|
73
|
-
// the live typeEnum column
|
|
90
|
+
// both vintages arrive here indistinguishable. `entityTableFromColumns`
|
|
91
|
+
// derives the spans from the live typeEnum column instead, which is why
|
|
92
|
+
// `typeRanges` is deliberately left off the columns object below.
|
|
74
93
|
const typeRangeCount = reader.readUint16();
|
|
75
94
|
for (let i = 0; i < typeRangeCount; i++) {
|
|
76
95
|
reader.readUint16(); // type
|
|
77
96
|
reader.readUint32(); // start
|
|
78
97
|
reader.readUint32(); // end (or count, for a pre-#3101 cache)
|
|
79
98
|
}
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (!arr) {
|
|
90
|
-
arr = [];
|
|
91
|
-
typeIndices.set(t, arr);
|
|
92
|
-
}
|
|
93
|
-
arr.push(i);
|
|
94
|
-
}
|
|
95
|
-
// Derive the spans from the same index arrays, so the one structure that
|
|
96
|
-
// survives interleaving feeds both getByType() and the public typeRanges.
|
|
97
|
-
const typeRanges = new Map();
|
|
98
|
-
for (const [type, indices] of typeIndices) {
|
|
99
|
-
typeRanges.set(type, { start: indices[0], end: indices[indices.length - 1] + 1 });
|
|
100
|
-
}
|
|
101
|
-
// PRE-BUILD INDEX MAP: O(n) once, then O(1) lookups
|
|
102
|
-
// This eliminates O(n²) when getName/hasGeometry are called for every entity
|
|
103
|
-
const idToIndex = new Map();
|
|
104
|
-
for (let i = 0; i < count; i++) {
|
|
105
|
-
idToIndex.set(expressId[i], i);
|
|
106
|
-
}
|
|
107
|
-
const indexOfId = (id) => {
|
|
108
|
-
return idToIndex.get(id) ?? -1;
|
|
109
|
-
};
|
|
110
|
-
// Build GlobalId → expressId map for BCF integration
|
|
111
|
-
const globalIdToExpressId = new Map();
|
|
112
|
-
for (let i = 0; i < count; i++) {
|
|
113
|
-
const gidString = strings.get(globalId[i]);
|
|
114
|
-
if (gidString) {
|
|
115
|
-
globalIdToExpressId.set(gidString, expressId[i]);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
// Additive display-class overrides (UI retype). See entity-table.ts.
|
|
119
|
-
const typeOverrides = new Map();
|
|
120
|
-
return {
|
|
99
|
+
// Raw IFC class names, v15+ only (see writeEntities). Left undefined for
|
|
100
|
+
// older sections, where the bytes are simply not there — reading them
|
|
101
|
+
// would consume whatever section follows.
|
|
102
|
+
const rawTypeName = version >= 15 ? reader.readUint32Array(count) : undefined;
|
|
103
|
+
// One shared implementation with the live parser table. Keeping a second
|
|
104
|
+
// copy here is what let the `rawTypeName` fallback go missing from cache
|
|
105
|
+
// loads while the parser had it: every entity of a class absent from
|
|
106
|
+
// `IfcTypeEnum` came back as 'Unknown'.
|
|
107
|
+
return entityTableFromColumns({
|
|
121
108
|
count,
|
|
122
109
|
expressId,
|
|
123
110
|
typeEnum,
|
|
@@ -129,66 +116,7 @@ export function readEntities(reader, strings) {
|
|
|
129
116
|
containedInStorey,
|
|
130
117
|
definedByType,
|
|
131
118
|
geometryIndex,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const idx = indexOfId(id);
|
|
135
|
-
return idx >= 0 ? strings.get(globalId[idx]) : '';
|
|
136
|
-
},
|
|
137
|
-
getName: (id) => {
|
|
138
|
-
const idx = indexOfId(id);
|
|
139
|
-
return idx >= 0 ? strings.get(name[idx]) : '';
|
|
140
|
-
},
|
|
141
|
-
getDescription: (id) => {
|
|
142
|
-
const idx = indexOfId(id);
|
|
143
|
-
return idx >= 0 ? strings.get(description[idx]) : '';
|
|
144
|
-
},
|
|
145
|
-
getObjectType: (id) => {
|
|
146
|
-
const idx = indexOfId(id);
|
|
147
|
-
return idx >= 0 ? strings.get(objectType[idx]) : '';
|
|
148
|
-
},
|
|
149
|
-
getTypeName: (id) => {
|
|
150
|
-
const override = typeOverrides.get(id);
|
|
151
|
-
if (override !== undefined)
|
|
152
|
-
return override;
|
|
153
|
-
const idx = indexOfId(id);
|
|
154
|
-
return idx >= 0 ? IfcTypeEnumToString(typeEnum[idx]) : 'Unknown';
|
|
155
|
-
},
|
|
156
|
-
hasGeometry: (id) => {
|
|
157
|
-
const idx = indexOfId(id);
|
|
158
|
-
return idx >= 0 ? (flags[idx] & HAS_GEOMETRY) !== 0 : false;
|
|
159
|
-
},
|
|
160
|
-
getByType: (type) => {
|
|
161
|
-
const indices = typeIndices.get(type);
|
|
162
|
-
if (!indices)
|
|
163
|
-
return [];
|
|
164
|
-
const ids = new Array(indices.length);
|
|
165
|
-
for (let i = 0; i < indices.length; i++) {
|
|
166
|
-
ids[i] = expressId[indices[i]];
|
|
167
|
-
}
|
|
168
|
-
return ids;
|
|
169
|
-
},
|
|
170
|
-
getTypeEnum: (id) => {
|
|
171
|
-
const override = typeOverrides.get(id);
|
|
172
|
-
if (override !== undefined)
|
|
173
|
-
return IfcTypeEnumFromString(override);
|
|
174
|
-
const idx = indexOfId(id);
|
|
175
|
-
return idx >= 0 ? typeEnum[idx] : IfcTypeEnum.Unknown;
|
|
176
|
-
},
|
|
177
|
-
setTypeOverride: (id, typeName) => {
|
|
178
|
-
if (typeName === null)
|
|
179
|
-
typeOverrides.delete(id);
|
|
180
|
-
// Canonicalise on the way in, matching `entityTableFromColumns`
|
|
181
|
-
// (packages/data/src/entity-table.ts). `getTypeName` echoes the
|
|
182
|
-
// override back verbatim and consumers like
|
|
183
|
-
// `isSpatialStructureTypeName` match the PascalCase form, so storing
|
|
184
|
-
// the caller's raw UPPERCASE token makes a retyped entity invisible to
|
|
185
|
-
// them. All three EntityTable implementations must agree here.
|
|
186
|
-
else
|
|
187
|
-
typeOverrides.set(id, IFC_ENTITY_NAMES[typeName.toUpperCase()] ?? typeName.toUpperCase());
|
|
188
|
-
},
|
|
189
|
-
getExpressIdByGlobalId: (gid) => {
|
|
190
|
-
return globalIdToExpressId.get(gid) ?? -1;
|
|
191
|
-
},
|
|
192
|
-
};
|
|
119
|
+
rawTypeName,
|
|
120
|
+
}, strings);
|
|
193
121
|
}
|
|
194
122
|
//# sourceMappingURL=entities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entities.js","sourceRoot":"","sources":["../../src/sections/entities.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAO/D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"entities.js","sourceRoot":"","sources":["../../src/sections/entities.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAO/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,aAAa,CAAC,MAAoB,EAAE,QAAqB;IACvE,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;IAE7B,cAAc;IACd,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAE1B,wBAAwB;IACxB,MAAM,CAAC,eAAe,CAAC,QAAQ,CAA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;QAC5B,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ;QAC7B,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,wCAAwC;IAC/D,CAAC;IAED,yEAAyE;IACzE,sEAAsE;IACtE,0CAA0C;IAC1C,MAAM,WAAW,GAAG,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE9E,yEAAyE;IACzE,yEAAyE;IACzE,qEAAqE;IACrE,wCAAwC;IACxC,OAAO,sBAAsB,CAC3B;QACE,KAAK;QACL,SAAS;QACT,QAAQ;QACR,QAAQ;QACR,IAAI;QACJ,WAAW;QACX,UAAU;QACV,KAAK;QACL,iBAAiB;QACjB,aAAa;QACb,aAAa;QACb,WAAW;KACZ,EACD,OAAO,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/sections/geometry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAc,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEtE;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG;IAClD,WAAW,EAAE,QAAQ,EAAE,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CA6BA;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/sections/geometry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAc,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEtE;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG;IAClD,WAAW,EAAE,QAAQ,EAAE,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CA6BA;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,CAsD1E;AAED,8EAA8E;AAC9E,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAW3D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,GAAG,IAAI,CA0BpF;AAgED,qEAAqE;AACrE,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAE,MAAU,GAAG,QAAQ,CA2FrG;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,GAAE,MAAU,GAAG,cAAc,CA2B5F"}
|
|
@@ -52,6 +52,23 @@ export function writeMeshRecord(writer, mesh) {
|
|
|
52
52
|
// view-mode filter sees every cache-restored mesh as class 0: instanced
|
|
53
53
|
// type-library geometry reappears in Model mode and the switch disappears.
|
|
54
54
|
writer.writeUint8(mesh.geometryClass ?? 0);
|
|
55
|
+
// Write the two DISJOINT source ids (v14+, #3199): the representation item
|
|
56
|
+
// this piece was tessellated from, or the material layer it slices. Written
|
|
57
|
+
// unconditionally as two u32 so the record stays fixed-shape.
|
|
58
|
+
//
|
|
59
|
+
// The absent sentinel is 0xFFFFFFFF, NOT 0, and the reason is worth keeping
|
|
60
|
+
// straight because it CHANGED during #3199. `layers.rs` decodes a layer with
|
|
61
|
+
// no material — an air gap — as `material_id = 0`, so 0 reached this writer
|
|
62
|
+
// and the first draft encoded "absent" as 0, which silently dropped exactly
|
|
63
|
+
// those layers: the valid-but-falsy trap.
|
|
64
|
+
//
|
|
65
|
+
// The producer now filters it instead (`with_style_metadata` maps a source id
|
|
66
|
+
// of 0 to `None`, because `#0` is not a STEP instance name), so nothing
|
|
67
|
+
// upstream emits 0 today. This layer does NOT rely on that: an encoding whose
|
|
68
|
+
// absence marker is a value the domain can produce is one upstream change
|
|
69
|
+
// away from being wrong again, and 0xFFFFFFFF costs nothing.
|
|
70
|
+
writer.writeUint32(mesh.geometryItemId ?? ABSENT_SOURCE_ID);
|
|
71
|
+
writer.writeUint32(mesh.materialId ?? ABSENT_SOURCE_ID);
|
|
55
72
|
// Write per-element local-frame origin (v6+, 3×f64): world = origin +
|
|
56
73
|
// position. [0,0,0] for absolute meshes. Without it a cache from a
|
|
57
74
|
// local-frame load restores small local positions with no origin → every
|
|
@@ -71,6 +88,7 @@ export function meshRecordByteLength(mesh) {
|
|
|
71
88
|
16 + // color f32x4
|
|
72
89
|
4 + ifcTypeBytes + // ifcType string
|
|
73
90
|
1 + // geometryClass
|
|
91
|
+
8 + // geometryItemId + materialId u32x2 (v14+)
|
|
74
92
|
24 + // origin f64x3
|
|
75
93
|
mesh.positions.byteLength + mesh.normals.byteLength + mesh.indices.byteLength);
|
|
76
94
|
}
|
|
@@ -105,9 +123,46 @@ function writeAABB(writer, aabb) {
|
|
|
105
123
|
writeVec3(writer, aabb.min);
|
|
106
124
|
writeVec3(writer, aabb.max);
|
|
107
125
|
}
|
|
126
|
+
/** Absent marker for the v14 source ids. Not 0 — `layers.rs` uses 0 for a
|
|
127
|
+
* material-free layer, so 0 is a real value (#3199). No STEP express id can
|
|
128
|
+
* reach 0xFFFFFFFF. */
|
|
129
|
+
const ABSENT_SOURCE_ID = 0xffffffff;
|
|
108
130
|
// Maximum reasonable values for sanity checking
|
|
109
131
|
const MAX_VERTEX_COUNT = 100_000_000; // 100M vertices max per mesh
|
|
110
132
|
const MAX_INDEX_COUNT = 300_000_000; // 300M indices max per mesh
|
|
133
|
+
/** IEEE-754 single-precision: a value is NaN or ±Infinity exactly when its
|
|
134
|
+
* 8 exponent bits are all set, regardless of sign or mantissa. */
|
|
135
|
+
const FLOAT32_EXPONENT_MASK = 0x7f800000;
|
|
136
|
+
/**
|
|
137
|
+
* Throw if any value in a decoded vertex-data array is non-finite (NaN or
|
|
138
|
+
* ±Infinity). A legitimately-produced mesh never contains one (the WASM
|
|
139
|
+
* geometry pipeline does not emit NaN/Infinity vertices), so a hit here means
|
|
140
|
+
* corrupted or adversarial cache bytes, not a valid-but-unusual model.
|
|
141
|
+
*
|
|
142
|
+
* Checked via the raw bit pattern (a `Uint32Array` VIEW over the same buffer,
|
|
143
|
+
* no copy) rather than `Number.isFinite(values[i])` or a chain of
|
|
144
|
+
* `v !== v || v === Infinity || v === -Infinity` float comparisons: this
|
|
145
|
+
* runs on every cache read's hot path (once per mesh, over every
|
|
146
|
+
* position/normal float). Measured on a real 5,927-mesh/473K-vertex fixture
|
|
147
|
+
* (dental_clinic.ifc, `pnpm --filter @ifc-lite/cache exec node` a throwaway
|
|
148
|
+
* write+read harness, 20 iterations after 4 warmup reads): the bitwise
|
|
149
|
+
* exponent test was the fastest of the three forms tried, but a full linear
|
|
150
|
+
* scan of every position/normal float still measured ~15-20% over an
|
|
151
|
+
* unguarded read's ~30ms baseline for this fixture (see the changeset for
|
|
152
|
+
* the exact before/after numbers). Kept despite the cost: it is the only
|
|
153
|
+
* guard in this package that closes a mis-parse (not just a bounds/shape)
|
|
154
|
+
* class of corruption, and the viewer's cache-restore path already falls
|
|
155
|
+
* back to a fresh parse on any reader throw (see `readMeshRecord`'s callers).
|
|
156
|
+
*/
|
|
157
|
+
function assertFiniteVertexData(values, field, meshIndex, expressId) {
|
|
158
|
+
const bits = new Uint32Array(values.buffer, values.byteOffset, values.length);
|
|
159
|
+
for (let i = 0; i < bits.length; i++) {
|
|
160
|
+
if ((bits[i] & FLOAT32_EXPONENT_MASK) === FLOAT32_EXPONENT_MASK) {
|
|
161
|
+
throw new Error(`Invalid cache: mesh ${meshIndex} (expressId=${expressId}) has a non-finite value ` +
|
|
162
|
+
`(${values[i]}) in ${field}[${i}]. Cache may be corrupted.`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
111
166
|
/** Read one per-mesh record (see writeMeshRecord for the layout). */
|
|
112
167
|
export function readMeshRecord(reader, version, meshIndex = 0) {
|
|
113
168
|
const expressId = reader.readUint32();
|
|
@@ -135,6 +190,23 @@ export function readMeshRecord(reader, version, meshIndex = 0) {
|
|
|
135
190
|
// Older caches default to 0 (occurrence); v4 entries are bypassed by the
|
|
136
191
|
// viewer's bumped cache key, so they re-mesh fresh rather than load here.
|
|
137
192
|
const geometryClass = version >= 5 ? reader.readUint8() : 0;
|
|
193
|
+
// Read the two disjoint source ids (version 14+, #3199). See
|
|
194
|
+
// ABSENT_SOURCE_ID for what "absent" is encoded as, and why it is not 0.
|
|
195
|
+
// Older caches predate the fields entirely and leave both undefined, which is
|
|
196
|
+
// the same state the runtime uses where the identity is genuinely merged away
|
|
197
|
+
// -- so a v13 cache degrades to "unknown", never to a WRONG id.
|
|
198
|
+
let geometryItemId;
|
|
199
|
+
let materialId;
|
|
200
|
+
if (version >= 14) {
|
|
201
|
+
const gid = reader.readUint32();
|
|
202
|
+
const mid = reader.readUint32();
|
|
203
|
+
// Compared against the sentinel, never for truthiness: 0 is a real
|
|
204
|
+
// material-layer id (an air gap) and must survive the round trip.
|
|
205
|
+
if (gid !== ABSENT_SOURCE_ID)
|
|
206
|
+
geometryItemId = gid;
|
|
207
|
+
if (mid !== ABSENT_SOURCE_ID)
|
|
208
|
+
materialId = mid;
|
|
209
|
+
}
|
|
138
210
|
// Read per-element local-frame origin (version 6+); world = origin + position.
|
|
139
211
|
let origin;
|
|
140
212
|
if (version >= 6) {
|
|
@@ -147,6 +219,22 @@ export function readMeshRecord(reader, version, meshIndex = 0) {
|
|
|
147
219
|
const positions = reader.readFloat32Array(vertexCount * 3);
|
|
148
220
|
const normals = reader.readFloat32Array(vertexCount * 3);
|
|
149
221
|
const indices = reader.readUint32Array(indexCount);
|
|
222
|
+
// Reject a NaN/Infinity-bombed vertex region instead of letting it flow
|
|
223
|
+
// downstream unfiltered. Structural guards elsewhere in this package (the
|
|
224
|
+
// chunk directory's contiguity check, string-offset monotonicity, row-index
|
|
225
|
+
// bounds) all validate that declared SHAPES are self-consistent, but none of
|
|
226
|
+
// them constrain the numeric DOMAIN of a position/normal float once its
|
|
227
|
+
// slot is legitimately in range -- a byte-flip that lands inside the
|
|
228
|
+
// position array itself passes every existing check and decodes as a
|
|
229
|
+
// syntactically valid, semantically poisoned float. Left unchecked, that
|
|
230
|
+
// reaches `packages/spatial`'s BVH (a NaN aggregate bound silently hides
|
|
231
|
+
// valid SIBLING meshes under the same node until #3547's NaN-safe compare)
|
|
232
|
+
// and the renderer/picking path, neither of which re-validates cache input.
|
|
233
|
+
// Failing here, at the boundary where untrusted bytes become a MeshData,
|
|
234
|
+
// keeps that contract in one place instead of relying on every downstream
|
|
235
|
+
// consumer to defend itself.
|
|
236
|
+
assertFiniteVertexData(positions, 'positions', meshIndex, expressId);
|
|
237
|
+
assertFiniteVertexData(normals, 'normals', meshIndex, expressId);
|
|
150
238
|
return {
|
|
151
239
|
expressId,
|
|
152
240
|
positions,
|
|
@@ -155,6 +243,10 @@ export function readMeshRecord(reader, version, meshIndex = 0) {
|
|
|
155
243
|
color,
|
|
156
244
|
ifcType,
|
|
157
245
|
geometryClass,
|
|
246
|
+
// Spread only the one that is set, so the disjointness the format preserves
|
|
247
|
+
// survives into the object a consumer reads (#3199).
|
|
248
|
+
...(geometryItemId !== undefined ? { geometryItemId } : {}),
|
|
249
|
+
...(materialId !== undefined ? { materialId } : {}),
|
|
158
250
|
...(origin ? { origin } : {}),
|
|
159
251
|
};
|
|
160
252
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.js","sour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AC;QACD,IAAI,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;YAC7B,gBAAgB,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,OAAO;QACL,WAAW;QACX,cAAc;QACd,aAAa;QACb,mBAAmB;QACnB,aAAa;QACb,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,MAAoB;IACpC,OAAO;QACL,CAAC,EAAE,MAAM,CAAC,WAAW,EAAE;QACvB,CAAC,EAAE,MAAM,CAAC,WAAW,EAAE;QACvB,CAAC,EAAE,MAAM,CAAC,WAAW,EAAE;KACxB,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,MAAoB;IACpC,OAAO;QACL,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC;QACrB,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC;KACtB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../src/sections/properties.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../src/sections/properties.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAiB,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEhF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAStE,iFAAiF;AACjF,wBAAgB,4BAA4B,IAAI,IAAI,CAEnD;AAYD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,GAAG,IAAI,CAoBrF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,GAAG,aAAa,CAgIxF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
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 { comparePropertyValues, PropertyValueType } from '@ifc-lite/data';
|
|
4
|
+
import { comparePropertyValues, groupPropertySetsByInstance, PropertyValueType } from '@ifc-lite/data';
|
|
5
5
|
/**
|
|
6
6
|
* List-value parse failures are per-property on a cache-rehydration path, so
|
|
7
7
|
* the warning is latched: a corrupt cache would otherwise emit one line per
|
|
@@ -69,9 +69,9 @@ export function readProperties(reader, strings) {
|
|
|
69
69
|
const valueInt = reader.readInt32Array(count);
|
|
70
70
|
const valueBool = reader.readUint8Array(count);
|
|
71
71
|
const unitId = reader.readInt32Array(count);
|
|
72
|
-
const entityIndex = readIndex(reader);
|
|
73
|
-
const psetIndex = readIndex(reader);
|
|
74
|
-
const propIndex = readIndex(reader);
|
|
72
|
+
const entityIndex = readIndex(reader, count, 'entityIndex');
|
|
73
|
+
const psetIndex = readIndex(reader, count, 'psetIndex');
|
|
74
|
+
const propIndex = readIndex(reader, count, 'propIndex');
|
|
75
75
|
const getPropertyValue = (idx) => {
|
|
76
76
|
const type = propType[idx];
|
|
77
77
|
switch (type) {
|
|
@@ -135,26 +135,7 @@ export function readProperties(reader, strings) {
|
|
|
135
135
|
propIndex,
|
|
136
136
|
getForEntity: (id) => {
|
|
137
137
|
const rowIndices = entityIndex.get(id) || [];
|
|
138
|
-
|
|
139
|
-
for (const idx of rowIndices) {
|
|
140
|
-
const psetNameStr = strings.get(psetName[idx]);
|
|
141
|
-
const psetGlobalIdStr = strings.get(psetGlobalId[idx]);
|
|
142
|
-
if (!psets.has(psetNameStr)) {
|
|
143
|
-
psets.set(psetNameStr, {
|
|
144
|
-
name: psetNameStr,
|
|
145
|
-
globalId: psetGlobalIdStr,
|
|
146
|
-
properties: [],
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
const pset = psets.get(psetNameStr);
|
|
150
|
-
const propNameStr = strings.get(propName[idx]);
|
|
151
|
-
pset.properties.push({
|
|
152
|
-
name: propNameStr,
|
|
153
|
-
type: propType[idx],
|
|
154
|
-
value: getPropertyValue(idx),
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
return Array.from(psets.values());
|
|
138
|
+
return groupPropertySetsByInstance(rowIndices, psetName, psetGlobalId, propName, propType, strings, (idx) => getPropertyValue(idx));
|
|
158
139
|
},
|
|
159
140
|
getPropertyValue: (id, pset, prop) => {
|
|
160
141
|
const rowIndices = entityIndex.get(id) || [];
|
|
@@ -200,7 +181,18 @@ function writeIndex(writer, index) {
|
|
|
200
181
|
}
|
|
201
182
|
}
|
|
202
183
|
}
|
|
203
|
-
|
|
184
|
+
/**
|
|
185
|
+
* Read a row-index table (entityIndex/psetIndex/propIndex): key -> row
|
|
186
|
+
* indices into the parallel column arrays. Each row index MUST be < rowCount
|
|
187
|
+
* — the column arrays (entityId, psetName, propType, valueString, ...) are
|
|
188
|
+
* fixed-size `Uint32Array`/`Float64Array`s, so an out-of-range read returns
|
|
189
|
+
* `undefined` instead of throwing (`arr[idx]` on a typed array never throws).
|
|
190
|
+
* A corrupt cache with an inflated row index would otherwise flow `undefined`
|
|
191
|
+
* names and types into `getForEntity` results silently instead of failing the
|
|
192
|
+
* cache load. Same defect shape, and same fix, as `entity-index.ts`'s
|
|
193
|
+
* `typeIndex` bounds check.
|
|
194
|
+
*/
|
|
195
|
+
function readIndex(reader, rowCount, name) {
|
|
204
196
|
const size = reader.readUint32();
|
|
205
197
|
const index = new Map();
|
|
206
198
|
for (let i = 0; i < size; i++) {
|
|
@@ -208,7 +200,12 @@ function readIndex(reader) {
|
|
|
208
200
|
const valueCount = reader.readUint32();
|
|
209
201
|
const values = [];
|
|
210
202
|
for (let j = 0; j < valueCount; j++) {
|
|
211
|
-
|
|
203
|
+
const rowIndex = reader.readUint32();
|
|
204
|
+
if (rowIndex >= rowCount) {
|
|
205
|
+
throw new Error(`Corrupt cache PropertyTable ${name}: row index ${rowIndex} for key ${key} ` +
|
|
206
|
+
`exceeds row count ${rowCount}`);
|
|
207
|
+
}
|
|
208
|
+
values.push(rowIndex);
|
|
212
209
|
}
|
|
213
210
|
index.set(key, values);
|
|
214
211
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"properties.js","sourceRoot":"","sources":["../../src/sections/properties.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAO/D,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"properties.js","sourceRoot":"","sources":["../../src/sections/properties.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAO/D,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGvG;;;;GAIG;AACH,IAAI,qBAAqB,GAAG,KAAK,CAAC;AAElC,iFAAiF;AACjF,MAAM,UAAU,4BAA4B;IAC1C,qBAAqB,GAAG,KAAK,CAAC;AAChC,CAAC;AAED,SAAS,wBAAwB,CAAC,OAAe,EAAE,GAAY;IAC7D,IAAI,qBAAqB;QAAE,OAAO;IAClC,qBAAqB,GAAG,IAAI,CAAC;IAC7B,OAAO,CAAC,IAAI,CACV,2EAA2E;QACzE,gDAAgD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,EACzF,GAAG,CACJ,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,eAAe,CAAC,MAAoB,EAAE,UAAyB;IAC7E,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAE/B,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAE1B,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,QAAQ,CA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AAC,EAAE,EAAE,CAAC;QAC9B,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QAChC,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACvC,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;YACpC,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;YACrC,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CACb,+BAA+B,IAAI,eAAe,QAAQ,YAAY,GAAG,GAAG;oBAC1E,qBAAqB,QAAQ,EAAE,CAClC,CAAC;YACJ,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxB,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quantities.d.ts","sourceRoot":"","sources":["../../src/sections/quantities.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"quantities.d.ts","sourceRoot":"","sources":["../../src/sections/quantities.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEtE;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,GAAG,IAAI,CAkBrF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,GAAG,aAAa,CA4GxF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
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 { comparePropertyValues } from '@ifc-lite/data';
|
|
4
|
+
import { comparePropertyValues, groupQuantitySetsByInstance } from '@ifc-lite/data';
|
|
5
5
|
/**
|
|
6
6
|
* Write QuantityTable to buffer
|
|
7
7
|
*/
|
|
@@ -10,6 +10,7 @@ export function writeQuantities(writer, quantities) {
|
|
|
10
10
|
writer.writeUint32(count);
|
|
11
11
|
writer.writeTypedArray(quantities.entityId);
|
|
12
12
|
writer.writeTypedArray(quantities.qsetName);
|
|
13
|
+
writer.writeTypedArray(quantities.qsetGlobalId);
|
|
13
14
|
writer.writeTypedArray(quantities.quantityName);
|
|
14
15
|
writer.writeTypedArray(quantities.quantityType);
|
|
15
16
|
writer.writeTypedArray(quantities.value);
|
|
@@ -27,18 +28,20 @@ export function readQuantities(reader, strings) {
|
|
|
27
28
|
const count = reader.readUint32();
|
|
28
29
|
const entityId = reader.readUint32Array(count);
|
|
29
30
|
const qsetName = reader.readUint32Array(count);
|
|
31
|
+
const qsetGlobalId = reader.readUint32Array(count);
|
|
30
32
|
const quantityName = reader.readUint32Array(count);
|
|
31
33
|
const quantityType = reader.readUint8Array(count);
|
|
32
34
|
const value = reader.readFloat64Array(count);
|
|
33
35
|
const unitId = reader.readInt32Array(count);
|
|
34
36
|
const formula = reader.readUint32Array(count);
|
|
35
|
-
const entityIndex = readIndex(reader);
|
|
36
|
-
const qsetIndex = readIndex(reader);
|
|
37
|
-
const quantityIndex = readIndex(reader);
|
|
37
|
+
const entityIndex = readIndex(reader, count, 'entityIndex');
|
|
38
|
+
const qsetIndex = readIndex(reader, count, 'qsetIndex');
|
|
39
|
+
const quantityIndex = readIndex(reader, count, 'quantityIndex');
|
|
38
40
|
return {
|
|
39
41
|
count,
|
|
40
42
|
entityId,
|
|
41
43
|
qsetName,
|
|
44
|
+
qsetGlobalId,
|
|
42
45
|
quantityName,
|
|
43
46
|
quantityType,
|
|
44
47
|
value,
|
|
@@ -49,25 +52,7 @@ export function readQuantities(reader, strings) {
|
|
|
49
52
|
quantityIndex,
|
|
50
53
|
getForEntity: (id) => {
|
|
51
54
|
const rowIndices = entityIndex.get(id) || [];
|
|
52
|
-
|
|
53
|
-
for (const idx of rowIndices) {
|
|
54
|
-
const qsetNameStr = strings.get(qsetName[idx]);
|
|
55
|
-
if (!qsets.has(qsetNameStr)) {
|
|
56
|
-
qsets.set(qsetNameStr, {
|
|
57
|
-
name: qsetNameStr,
|
|
58
|
-
quantities: [],
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
const qset = qsets.get(qsetNameStr);
|
|
62
|
-
const quantNameStr = strings.get(quantityName[idx]);
|
|
63
|
-
qset.quantities.push({
|
|
64
|
-
name: quantNameStr,
|
|
65
|
-
type: quantityType[idx],
|
|
66
|
-
value: value[idx],
|
|
67
|
-
formula: formula[idx] > 0 ? strings.get(formula[idx]) : undefined,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return Array.from(qsets.values());
|
|
55
|
+
return groupQuantitySetsByInstance(rowIndices, qsetName, qsetGlobalId, quantityName, quantityType, value, formula, strings);
|
|
71
56
|
},
|
|
72
57
|
getQuantityValue: (id, qset, quant) => {
|
|
73
58
|
const rowIndices = entityIndex.get(id) || [];
|
|
@@ -135,7 +120,18 @@ function writeIndex(writer, index) {
|
|
|
135
120
|
}
|
|
136
121
|
}
|
|
137
122
|
}
|
|
138
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Read a row-index table (entityIndex/qsetIndex/quantityIndex): key -> row
|
|
125
|
+
* indices into the parallel column arrays. Each row index MUST be < rowCount
|
|
126
|
+
* — the column arrays (entityId, qsetName, quantityType, value, ...) are
|
|
127
|
+
* fixed-size typed arrays, so an out-of-range read returns `undefined`
|
|
128
|
+
* instead of throwing. A corrupt cache with an inflated row index would
|
|
129
|
+
* otherwise flow `undefined` names and values into `getForEntity` results and
|
|
130
|
+
* `NaN` into `sumByType` silently instead of failing the cache load. Same
|
|
131
|
+
* defect shape, and same fix, as `entity-index.ts`'s `typeIndex` bounds
|
|
132
|
+
* check and `properties.ts`'s equivalent guard.
|
|
133
|
+
*/
|
|
134
|
+
function readIndex(reader, rowCount, name) {
|
|
139
135
|
const size = reader.readUint32();
|
|
140
136
|
const index = new Map();
|
|
141
137
|
for (let i = 0; i < size; i++) {
|
|
@@ -143,7 +139,12 @@ function readIndex(reader) {
|
|
|
143
139
|
const valueCount = reader.readUint32();
|
|
144
140
|
const values = [];
|
|
145
141
|
for (let j = 0; j < valueCount; j++) {
|
|
146
|
-
|
|
142
|
+
const rowIndex = reader.readUint32();
|
|
143
|
+
if (rowIndex >= rowCount) {
|
|
144
|
+
throw new Error(`Corrupt cache QuantityTable ${name}: row index ${rowIndex} for key ${key} ` +
|
|
145
|
+
`exceeds row count ${rowCount}`);
|
|
146
|
+
}
|
|
147
|
+
values.push(rowIndex);
|
|
147
148
|
}
|
|
148
149
|
index.set(key, values);
|
|
149
150
|
}
|