@bldrs-ai/conway 1.330.1053 → 1.331.1060
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/compiled/examples/browser-bundled.cjs +1 -1
- package/compiled/examples/cli-bundled.cjs +1 -1
- package/compiled/examples/validator-bundled.cjs +1 -1
- package/compiled/src/compat/web-ifc/ap214_properties.d.ts +21 -0
- package/compiled/src/compat/web-ifc/ap214_properties.d.ts.map +1 -0
- package/compiled/src/compat/web-ifc/ap214_properties.js +51 -0
- package/compiled/src/compat/web-ifc/ifc2x4.d.ts +818 -0
- package/compiled/src/compat/web-ifc/ifc2x4.d.ts.map +1 -0
- package/compiled/src/compat/web-ifc/ifc2x4.js +1003 -0
- package/compiled/src/compat/web-ifc/ifc2x4_helper.d.ts +14433 -0
- package/compiled/src/compat/web-ifc/ifc2x4_helper.d.ts.map +1 -0
- package/compiled/src/compat/web-ifc/ifc2x4_helper.js +34985 -0
- package/compiled/src/compat/web-ifc/ifc_api.d.ts +267 -0
- package/compiled/src/compat/web-ifc/ifc_api.d.ts.map +1 -0
- package/compiled/src/compat/web-ifc/ifc_api.js +544 -0
- package/compiled/src/compat/web-ifc/ifc_api.smoke.test.d.ts +2 -0
- package/compiled/src/compat/web-ifc/ifc_api.smoke.test.d.ts.map +1 -0
- package/compiled/src/compat/web-ifc/ifc_api.smoke.test.js +88 -0
- package/compiled/src/compat/web-ifc/ifc_api_model_passthrough.d.ts +17 -0
- package/compiled/src/compat/web-ifc/ifc_api_model_passthrough.d.ts.map +1 -0
- package/compiled/src/compat/web-ifc/ifc_api_model_passthrough.js +1 -0
- package/compiled/src/compat/web-ifc/ifc_api_model_passthrough_factory.d.ts +17 -0
- package/compiled/src/compat/web-ifc/ifc_api_model_passthrough_factory.d.ts.map +1 -0
- package/compiled/src/compat/web-ifc/ifc_api_model_passthrough_factory.js +61 -0
- package/compiled/src/compat/web-ifc/ifc_api_proxy_ap214.d.ts +205 -0
- package/compiled/src/compat/web-ifc/ifc_api_proxy_ap214.d.ts.map +1 -0
- package/compiled/src/compat/web-ifc/ifc_api_proxy_ap214.js +958 -0
- package/compiled/src/compat/web-ifc/ifc_api_proxy_ifc.d.ts +200 -0
- package/compiled/src/compat/web-ifc/ifc_api_proxy_ifc.d.ts.map +1 -0
- package/compiled/src/compat/web-ifc/ifc_api_proxy_ifc.js +1162 -0
- package/compiled/src/compat/web-ifc/ifc_properties.d.ts +29 -0
- package/compiled/src/compat/web-ifc/ifc_properties.d.ts.map +1 -0
- package/compiled/src/compat/web-ifc/ifc_properties.js +205 -0
- package/compiled/src/compat/web-ifc/index.d.ts +2 -0
- package/compiled/src/compat/web-ifc/index.d.ts.map +1 -0
- package/compiled/src/compat/web-ifc/index.js +17 -0
- package/compiled/src/compat/web-ifc/properties.d.ts +14 -0
- package/compiled/src/compat/web-ifc/properties.d.ts.map +1 -0
- package/compiled/src/compat/web-ifc/properties.js +27 -0
- package/compiled/src/compat/web-ifc/properties_passthrough.d.ts +15 -0
- package/compiled/src/compat/web-ifc/properties_passthrough.d.ts.map +1 -0
- package/compiled/src/compat/web-ifc/properties_passthrough.js +1 -0
- package/compiled/src/compat/web-ifc/shim_schema_mapping.d.ts +7 -0
- package/compiled/src/compat/web-ifc/shim_schema_mapping.d.ts.map +1 -0
- package/compiled/src/compat/web-ifc/shim_schema_mapping.js +792 -0
- package/compiled/src/compat/web-ifc/types-map.d.ts +7 -0
- package/compiled/src/compat/web-ifc/types-map.d.ts.map +1 -0
- package/compiled/src/compat/web-ifc/types-map.js +957 -0
- package/compiled/src/version/version.js +1 -1
- package/compiled/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -1
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
import { ConwayGeometry, } from "../../index.js";
|
|
2
|
+
import { versionString } from "../../version/version.js";
|
|
3
|
+
import Logger from "../../logging/logger.js";
|
|
4
|
+
import Environment from "../../utilities/environment.js";
|
|
5
|
+
import * as glmatrix from "gl-matrix";
|
|
6
|
+
import { IfcApiModelPassthroughFactory } from "./ifc_api_model_passthrough_factory.js";
|
|
7
|
+
import { Properties } from "./properties.js";
|
|
8
|
+
export * from "./ifc2x4.js";
|
|
9
|
+
export const UNKNOWN = 0;
|
|
10
|
+
export const STRING = 1;
|
|
11
|
+
export const LABEL = 2;
|
|
12
|
+
export const ENUM = 3;
|
|
13
|
+
export const REAL = 4;
|
|
14
|
+
export const REF = 5;
|
|
15
|
+
export const EMPTY = 6;
|
|
16
|
+
export const SET_BEGIN = 7;
|
|
17
|
+
export const SET_END = 8;
|
|
18
|
+
export const LINE_END = 9;
|
|
19
|
+
/**
|
|
20
|
+
* @return {number} current time in ms
|
|
21
|
+
*/
|
|
22
|
+
export function ms() {
|
|
23
|
+
return new Date().getTime();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* IfcAPI - Web-IFC API Shim Implementation for full read functionality
|
|
27
|
+
*/
|
|
28
|
+
export class IfcAPI {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.wasmModule = undefined;
|
|
31
|
+
this.fs = undefined;
|
|
32
|
+
this.wasmPath = "";
|
|
33
|
+
this.isWasmPathAbsolute = false;
|
|
34
|
+
this.globalModelIDCounter = 0;
|
|
35
|
+
this.models = new Map();
|
|
36
|
+
this.conwaywasm = new ConwayGeometry();
|
|
37
|
+
this._isCoordinated = false;
|
|
38
|
+
this.linearScalingFactor = 1;
|
|
39
|
+
this.identity = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
40
|
+
// Initialize the matrix using an array
|
|
41
|
+
this.NormalizeMat = glmatrix.mat4.fromValues(1, 0, 0, 0, // First column
|
|
42
|
+
0, 0, -1, 0, // Second column
|
|
43
|
+
0, 1, 0, 0, // Third column
|
|
44
|
+
0, 0, 0, 1);
|
|
45
|
+
this.properties = new Properties(this);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get the passthrough for a particular model id.
|
|
49
|
+
*
|
|
50
|
+
* @param modelID
|
|
51
|
+
* @return {IfcApiModelPassthrough | undefined}
|
|
52
|
+
*/
|
|
53
|
+
getPassthrough(modelID) {
|
|
54
|
+
return this.models.get(modelID);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Initializes the WASM module (WebIFCWasm), required before using any other functionality.
|
|
58
|
+
*
|
|
59
|
+
* @param customLocateFileHandler An optional locateFile function that let's
|
|
60
|
+
* you override the path from which the wasm module is loaded.
|
|
61
|
+
*/
|
|
62
|
+
async Init(customLocateFileHandler) {
|
|
63
|
+
Environment.checkEnvironment();
|
|
64
|
+
Logger.initializeWasmCallbacks();
|
|
65
|
+
Logger.info(versionString);
|
|
66
|
+
const locateFileHandler = (path, prefix) => {
|
|
67
|
+
// when the wasm module requests the wasm file, we redirect to include the user specified path
|
|
68
|
+
if (path.endsWith(".wasm")) {
|
|
69
|
+
if (this.isWasmPathAbsolute) {
|
|
70
|
+
return this.wasmPath + path;
|
|
71
|
+
}
|
|
72
|
+
return prefix + this.wasmPath + path;
|
|
73
|
+
}
|
|
74
|
+
// otherwise use the default path
|
|
75
|
+
return prefix + path;
|
|
76
|
+
};
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
const initializationStatus = await this.conwaywasm.initialize((customLocateFileHandler !== void 0) ?
|
|
79
|
+
customLocateFileHandler : locateFileHandler);
|
|
80
|
+
if (!initializationStatus) {
|
|
81
|
+
Logger.error("Could not initialize Conway Wasm");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.wasmModule = this.conwaywasm.wasmModule;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Opens a model and returns a modelID number
|
|
88
|
+
*
|
|
89
|
+
* @param data containing IFC data (bytes)
|
|
90
|
+
* @param settings settings for loading the model
|
|
91
|
+
* @return {number} model ID
|
|
92
|
+
*/
|
|
93
|
+
OpenModel(data, settings) {
|
|
94
|
+
const modelIdResult = this.globalModelIDCounter;
|
|
95
|
+
const result = IfcApiModelPassthroughFactory.from(modelIdResult, data, this.wasmModule, settings);
|
|
96
|
+
if (result === void 0) {
|
|
97
|
+
return -1;
|
|
98
|
+
}
|
|
99
|
+
this.globalModelIDCounter++;
|
|
100
|
+
this.models.set(modelIdResult, result);
|
|
101
|
+
return modelIdResult;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Creates a new model and returns a modelID number (unimplemented)
|
|
105
|
+
*
|
|
106
|
+
* @param settings settings for generating data the model
|
|
107
|
+
* @return {number} model ID
|
|
108
|
+
*/
|
|
109
|
+
CreateModel(settings) {
|
|
110
|
+
Logger.warning("[CreateModel]: Shim - Unimplemented");
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
*
|
|
115
|
+
* @param modelID
|
|
116
|
+
* @return {Uint8Array} unimplemented
|
|
117
|
+
*/
|
|
118
|
+
ExportFileAsIFC(modelID) {
|
|
119
|
+
Logger.warning(`[ExportFileAsIFC]: Model ${modelID}: Shim - Unimplemented`);
|
|
120
|
+
const emptyArray = new Uint8Array(1);
|
|
121
|
+
return emptyArray;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Opens a model and returns a modelID number
|
|
125
|
+
*
|
|
126
|
+
* @param modelID handle retrieved by OpenModel, model must not be closed
|
|
127
|
+
* @param geometryExpressID containing IFC data (bytes)
|
|
128
|
+
* @return {IfcGeometry}
|
|
129
|
+
*/
|
|
130
|
+
GetGeometry(modelID, geometryExpressID) {
|
|
131
|
+
const result = this.models.get(modelID);
|
|
132
|
+
if (result !== void 0) {
|
|
133
|
+
return result.getGeometry(geometryExpressID);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
Logger.error("[GetGeometry]: model === undefined");
|
|
137
|
+
}
|
|
138
|
+
Logger.error("[GetGeometry]: Error - returning dummyGeometry object");
|
|
139
|
+
const dummyGeometry = (new (this.wasmModule.IfcGeometry)());
|
|
140
|
+
return dummyGeometry;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
*
|
|
144
|
+
* @param modelID
|
|
145
|
+
* @param expressID
|
|
146
|
+
* @param flatten
|
|
147
|
+
* @return {any} line data
|
|
148
|
+
*/
|
|
149
|
+
GetLine(modelID, expressID, flatten = false) {
|
|
150
|
+
const result = this.models.get(modelID);
|
|
151
|
+
if (result === void 0) {
|
|
152
|
+
Logger.error("[GetLine]: model === undefined");
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
return result.getLine(expressID, flatten);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
*
|
|
159
|
+
* @param modelID
|
|
160
|
+
* @return {Vector<LoaderError>}
|
|
161
|
+
*/
|
|
162
|
+
GetAndClearErrors(modelID) {
|
|
163
|
+
Logger.warning("[GetAndClearErrors]: Shim - Unimplemented");
|
|
164
|
+
const wasmErrorsDummy = {
|
|
165
|
+
get(index) {
|
|
166
|
+
// Implementation here
|
|
167
|
+
return { type: "", message: "", expressID: 0, ifcType: 0 };
|
|
168
|
+
},
|
|
169
|
+
size() {
|
|
170
|
+
// Implementation here
|
|
171
|
+
return 0;
|
|
172
|
+
},
|
|
173
|
+
push() {
|
|
174
|
+
// eslint-disable-next-line no-useless-return
|
|
175
|
+
return;
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
return wasmErrorsDummy;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
*
|
|
182
|
+
* @param modelID
|
|
183
|
+
* @param lineObject
|
|
184
|
+
*/
|
|
185
|
+
WriteLine(modelID, lineObject) {
|
|
186
|
+
Logger.warning("[WriteLine]: Shim - Unimplemented");
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
*
|
|
190
|
+
* @param modelID
|
|
191
|
+
* @param line
|
|
192
|
+
* @return {string | undefined}
|
|
193
|
+
*/
|
|
194
|
+
FlattenLine(modelID, line) {
|
|
195
|
+
const result = this.models.get(modelID);
|
|
196
|
+
if (result === void 0) {
|
|
197
|
+
Logger.error("[FlattenLine]: model === undefined");
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
return result.flattenLine(line);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
*
|
|
204
|
+
* @param modelID
|
|
205
|
+
* @param expressID
|
|
206
|
+
* @return {RawLineData}
|
|
207
|
+
*/
|
|
208
|
+
GetRawLineData(modelID, expressID) {
|
|
209
|
+
const result = this.models.get(modelID);
|
|
210
|
+
if (result === void 0) {
|
|
211
|
+
Logger.error("[GetRawLineData]: model === undefined");
|
|
212
|
+
return {
|
|
213
|
+
ID: expressID,
|
|
214
|
+
type: -1,
|
|
215
|
+
arguments: ["invalid"],
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
return result.getRawLineData(expressID);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Get all line ids with the matching type
|
|
222
|
+
*
|
|
223
|
+
* @param modelID
|
|
224
|
+
* @param type
|
|
225
|
+
* @return {Vector<number>} The matching express IDs
|
|
226
|
+
*/
|
|
227
|
+
GetLineIDsWithType(modelID, type) {
|
|
228
|
+
const result = this.models.get(modelID);
|
|
229
|
+
if (result === void 0) {
|
|
230
|
+
Logger.error("[GetLineIDsWithType]: model === undefined");
|
|
231
|
+
const vectorArray = [];
|
|
232
|
+
return {
|
|
233
|
+
get(index) {
|
|
234
|
+
// Your implementation here
|
|
235
|
+
if (index >= vectorArray.length) {
|
|
236
|
+
return -1;
|
|
237
|
+
}
|
|
238
|
+
return vectorArray[index];
|
|
239
|
+
},
|
|
240
|
+
size() {
|
|
241
|
+
// Your implementation here
|
|
242
|
+
return vectorArray.length;
|
|
243
|
+
},
|
|
244
|
+
push(parameter) {
|
|
245
|
+
vectorArray.push(parameter);
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
return result.getLineIDsWithType(type);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
*
|
|
253
|
+
* @param modelID
|
|
254
|
+
* @return {Vector<number>}
|
|
255
|
+
*/
|
|
256
|
+
GetAllLines(modelID) {
|
|
257
|
+
const result = this.models.get(modelID);
|
|
258
|
+
if (result === void 0) {
|
|
259
|
+
Logger.error("[GetAllLines]: model === undefined");
|
|
260
|
+
const vectorArray = [];
|
|
261
|
+
return {
|
|
262
|
+
get(index) {
|
|
263
|
+
// Your implementation here
|
|
264
|
+
if (index >= vectorArray.length) {
|
|
265
|
+
return -1;
|
|
266
|
+
}
|
|
267
|
+
return vectorArray[index];
|
|
268
|
+
},
|
|
269
|
+
size() {
|
|
270
|
+
// Your implementation here
|
|
271
|
+
return vectorArray.length;
|
|
272
|
+
},
|
|
273
|
+
push(parameter) {
|
|
274
|
+
vectorArray.push(parameter);
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
return result.getAllLines();
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
*
|
|
282
|
+
* @param modelID
|
|
283
|
+
* @param transformationMatrix
|
|
284
|
+
*/
|
|
285
|
+
setGeometryTransformation(modelID, transformationMatrix) {
|
|
286
|
+
/* if (transformationMatrix.length != 16) {
|
|
287
|
+
Logger.error(`Bad transformation matrix size: ${transformationMatrix.length}`)
|
|
288
|
+
return
|
|
289
|
+
}
|
|
290
|
+
this.wasmModule.setGeometryTransformation(modelID, transformationMatrix)*/
|
|
291
|
+
Logger.warning("[setGeometryTransformation]: Shim - Unimplemented");
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
*
|
|
295
|
+
* @param modelID
|
|
296
|
+
* @return {Array<number>}
|
|
297
|
+
*/
|
|
298
|
+
GetCoordinationMatrix(modelID) {
|
|
299
|
+
const result = this.models.get(modelID);
|
|
300
|
+
if (result !== void 0) {
|
|
301
|
+
return result.getCoordinationMatrix();
|
|
302
|
+
}
|
|
303
|
+
const coordinationMatrix = glmatrix.mat4.create();
|
|
304
|
+
return Array.from(coordinationMatrix);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
*
|
|
308
|
+
* @param ptr
|
|
309
|
+
* @param size
|
|
310
|
+
* @return {Float32Array}
|
|
311
|
+
*/
|
|
312
|
+
GetVertexArray(ptr, size) {
|
|
313
|
+
return this.getSubArray(this.wasmModule.HEAPF32, ptr, size);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
*
|
|
317
|
+
* @param ptr
|
|
318
|
+
* @param size
|
|
319
|
+
* @return {Uint32Array}
|
|
320
|
+
*/
|
|
321
|
+
GetIndexArray(ptr, size) {
|
|
322
|
+
return this.getSubArray(this.wasmModule.HEAPU32, ptr, size);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
*
|
|
326
|
+
* @param heap
|
|
327
|
+
* @param startPtr
|
|
328
|
+
* @param sizeBytes
|
|
329
|
+
* @return {Float32Array | Uint32Array}
|
|
330
|
+
*/
|
|
331
|
+
getSubArray(heap, startPtr, sizeBytes) {
|
|
332
|
+
// eslint-disable-next-line no-magic-numbers, no-mixed-operators
|
|
333
|
+
return heap.subarray(startPtr / 4, startPtr / 4 + sizeBytes).slice(0);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Closes a model and frees all related memory
|
|
337
|
+
*
|
|
338
|
+
* @param modelID Model handle retrieved by OpenModel, model must not be closed
|
|
339
|
+
*/
|
|
340
|
+
CloseModel(modelID) {
|
|
341
|
+
if (this.models.has(modelID) === false) {
|
|
342
|
+
Logger.error(`[CloseModel]: Model ${modelID} not found`);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
Logger.info(`[CloseModel]: Closing model ${modelID}`);
|
|
346
|
+
this.models.delete(modelID);
|
|
347
|
+
this.conwaywasm.destroy();
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
*
|
|
351
|
+
* @param modelID
|
|
352
|
+
* @param meshCallback
|
|
353
|
+
*/
|
|
354
|
+
StreamAllMeshes(modelID, meshCallback) {
|
|
355
|
+
const result = this.models.get(modelID);
|
|
356
|
+
if (result !== void 0) {
|
|
357
|
+
result.streamAllMeshes(meshCallback);
|
|
358
|
+
}
|
|
359
|
+
Logger.displayLogs();
|
|
360
|
+
Logger.clearLogs();
|
|
361
|
+
Logger.printStatistics(modelID);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
*
|
|
365
|
+
* @param modelID
|
|
366
|
+
* @param types
|
|
367
|
+
* @param meshCallback
|
|
368
|
+
*/
|
|
369
|
+
StreamAllMeshesWithTypes(modelID, types, meshCallback) {
|
|
370
|
+
const result = this.models.get(modelID);
|
|
371
|
+
if (result !== void 0) {
|
|
372
|
+
result.streamAllMeshesWithTypes(types, meshCallback);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Checks if a specific model ID is open or closed
|
|
377
|
+
*
|
|
378
|
+
* @param modelID handle retrieved by OpenModel
|
|
379
|
+
* @return {boolean}
|
|
380
|
+
*/
|
|
381
|
+
IsModelOpen(modelID) {
|
|
382
|
+
if (this.models.has(modelID)) {
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Load all geometry in a model
|
|
389
|
+
*
|
|
390
|
+
* @param modelID handle retrieved by OpenModel
|
|
391
|
+
* @return {Vector<FlatMesh>}
|
|
392
|
+
*/
|
|
393
|
+
LoadAllGeometry(modelID) {
|
|
394
|
+
const result = this.models.get(modelID);
|
|
395
|
+
if (result !== void 0) {
|
|
396
|
+
return result.loadAllGeometry();
|
|
397
|
+
}
|
|
398
|
+
// dummy vars
|
|
399
|
+
const dummyColor = {
|
|
400
|
+
x: 0,
|
|
401
|
+
y: 0,
|
|
402
|
+
z: 0,
|
|
403
|
+
w: 0,
|
|
404
|
+
};
|
|
405
|
+
// Single PlacedGeometry variable
|
|
406
|
+
const singlePlacedGeometry = {
|
|
407
|
+
color: dummyColor,
|
|
408
|
+
geometryExpressID: 0,
|
|
409
|
+
flatTransformation: this.identity,
|
|
410
|
+
};
|
|
411
|
+
// eslint-disable-next-line no-array-constructor
|
|
412
|
+
const placedGeometryArray = new Array();
|
|
413
|
+
// Vector of PlacedGeometry
|
|
414
|
+
const vectorOfPlacedGeometry = {
|
|
415
|
+
get(index) {
|
|
416
|
+
if (index >= placedGeometryArray.length) {
|
|
417
|
+
return singlePlacedGeometry;
|
|
418
|
+
}
|
|
419
|
+
return placedGeometryArray[index];
|
|
420
|
+
},
|
|
421
|
+
size() {
|
|
422
|
+
return placedGeometryArray.length;
|
|
423
|
+
},
|
|
424
|
+
push(parameter) {
|
|
425
|
+
placedGeometryArray.push(parameter);
|
|
426
|
+
},
|
|
427
|
+
};
|
|
428
|
+
// eslint-disable-next-line no-array-constructor
|
|
429
|
+
const flatMeshArray = new Array();
|
|
430
|
+
const flatMeshDummy = {
|
|
431
|
+
geometries: vectorOfPlacedGeometry,
|
|
432
|
+
expressID: 0, // replace with actual expressID
|
|
433
|
+
};
|
|
434
|
+
// Vector of FlatMesh
|
|
435
|
+
const vectorOfFlatMesh = {
|
|
436
|
+
get(index) {
|
|
437
|
+
if (index >= placedGeometryArray.length) {
|
|
438
|
+
return flatMeshDummy;
|
|
439
|
+
}
|
|
440
|
+
return flatMeshArray[index];
|
|
441
|
+
},
|
|
442
|
+
size() {
|
|
443
|
+
// Your implementation here
|
|
444
|
+
return flatMeshArray.length;
|
|
445
|
+
},
|
|
446
|
+
push(parameter) {
|
|
447
|
+
flatMeshArray.push(parameter);
|
|
448
|
+
},
|
|
449
|
+
};
|
|
450
|
+
return vectorOfFlatMesh;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Load geometry for a single element
|
|
454
|
+
*
|
|
455
|
+
* @param modelID handle retrieved by OpenModel
|
|
456
|
+
* @param expressID express ID of flat mesh
|
|
457
|
+
* @return {FlatMesh}
|
|
458
|
+
*/
|
|
459
|
+
GetFlatMesh(modelID, expressID) {
|
|
460
|
+
const result = this.models.get(modelID);
|
|
461
|
+
if (result !== void 0) {
|
|
462
|
+
return result.getFlatMesh(expressID);
|
|
463
|
+
}
|
|
464
|
+
// Single PlacedGeometry variable
|
|
465
|
+
const dummyColor = {
|
|
466
|
+
x: 0,
|
|
467
|
+
y: 0,
|
|
468
|
+
z: 0,
|
|
469
|
+
w: 0,
|
|
470
|
+
};
|
|
471
|
+
const singlePlacedGeometry = {
|
|
472
|
+
color: dummyColor,
|
|
473
|
+
geometryExpressID: 0,
|
|
474
|
+
flatTransformation: [ /* your array of numbers here */],
|
|
475
|
+
};
|
|
476
|
+
// Vector of PlacedGeometry
|
|
477
|
+
const vectorOfPlacedGeometry = {
|
|
478
|
+
get(index) {
|
|
479
|
+
// Your implementation here
|
|
480
|
+
return singlePlacedGeometry; // Dummy return, replace with actual implementation
|
|
481
|
+
},
|
|
482
|
+
size() {
|
|
483
|
+
// Your implementation here
|
|
484
|
+
return 1; // Dummy return, replace with actual implementation
|
|
485
|
+
},
|
|
486
|
+
push() {
|
|
487
|
+
// eslint-disable-next-line no-useless-return
|
|
488
|
+
return;
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
const flatMeshDummy = {
|
|
492
|
+
geometries: vectorOfPlacedGeometry,
|
|
493
|
+
expressID: 0, // replace with actual expressID
|
|
494
|
+
};
|
|
495
|
+
return flatMeshDummy;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Creates a map between element ExpressIDs and GlobalIDs.
|
|
499
|
+
* Each element has two entries, (ExpressID -> GlobalID) and (GlobalID -> ExpressID).
|
|
500
|
+
*
|
|
501
|
+
* @param modelID handle retrieved by OpenModel
|
|
502
|
+
*/
|
|
503
|
+
CreateIfcGuidToExpressIdMapping(modelID) {
|
|
504
|
+
/* const map = new Map<string | number, string | number>()
|
|
505
|
+
|
|
506
|
+
for (let x = 0; x < IfcElements.length; x++) {
|
|
507
|
+
|
|
508
|
+
const type = IfcElements[x]
|
|
509
|
+
const lines = this.GetLineIDsWithType(modelID, type)
|
|
510
|
+
const size = lines.size()
|
|
511
|
+
|
|
512
|
+
for (let y = 0; y < size; y++) {
|
|
513
|
+
|
|
514
|
+
const expressID = lines.get(y)
|
|
515
|
+
const info = this.GetLine(modelID, expressID)
|
|
516
|
+
const globalID = info.GlobalId.value
|
|
517
|
+
|
|
518
|
+
map.set(expressID, globalID)
|
|
519
|
+
map.set(globalID, expressID)
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
this.ifcGuidMap.push(modelID, map)*/
|
|
524
|
+
Logger.warning(`[CreateIfcGuidToExpressIdMapping]: Model ${modelID}: Shim - Unimplemented`);
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
*
|
|
528
|
+
* @param path new wasm path
|
|
529
|
+
* @param absolute is the path absolute?
|
|
530
|
+
*/
|
|
531
|
+
SetWasmPath(path, absolute = false) {
|
|
532
|
+
this.wasmPath = path;
|
|
533
|
+
this.isWasmPathAbsolute = absolute;
|
|
534
|
+
}
|
|
535
|
+
// Non web-ifc methods
|
|
536
|
+
/** The conway version string like "0.23.940-WebMT" */
|
|
537
|
+
getConwayVersion() {
|
|
538
|
+
return versionString;
|
|
539
|
+
}
|
|
540
|
+
/** @see https://bldrs-ai.github.io/conway/classes/statistics_statistics.Statistics.html */
|
|
541
|
+
getStatistics(modelID) {
|
|
542
|
+
return Logger.getStatistics(modelID);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ifc_api.smoke.test.d.ts","sourceRoot":"","sources":["../../../../src/compat/web-ifc/ifc_api.smoke.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// Smoke test for the vendored web-ifc compat surface (`IfcAPI`).
|
|
3
|
+
//
|
|
4
|
+
// CI's IFC regression exercises Conway's *native* parse path, never the
|
|
5
|
+
// compat `IfcAPI` shim. This proves the shim actually works end-to-end —
|
|
6
|
+
// open a model, stream geometry, read properties — for the formats Bldrs
|
|
7
|
+
// Share drives through it (IFC + STEP/AP214), and that the AP203→AP214
|
|
8
|
+
// routing added to the passthrough factory is reachable.
|
|
9
|
+
//
|
|
10
|
+
// Boots the wasm the same way src/ifc/ifc_geometry_extraction.test.ts
|
|
11
|
+
// does (no SetWasmPath → default locate handler resolves the conway-geom
|
|
12
|
+
// wasm from the dist). See design/new/web-ifc-compat-surface.md.
|
|
13
|
+
//
|
|
14
|
+
// NOTE: the models are intentionally NOT closed between tests.
|
|
15
|
+
// `IfcAPI.CloseModel` calls `conwaywasm.destroy()` on the single shared
|
|
16
|
+
// ConwayGeometry created in beforeAll, which would tear down the wasm the
|
|
17
|
+
// remaining tests reuse. One wasm lives for the whole file; Jest reaps it
|
|
18
|
+
// when the worker exits.
|
|
19
|
+
import fs from "fs";
|
|
20
|
+
import { describe, expect, test, beforeAll, jest } from "@jest/globals";
|
|
21
|
+
import { IfcAPI } from "./ifc_api.js";
|
|
22
|
+
import Logger from "../../logging/logger.js";
|
|
23
|
+
const SETTINGS = { COORDINATE_TO_ORIGIN: true, USE_FAST_BOOLS: true };
|
|
24
|
+
let api;
|
|
25
|
+
beforeAll(async () => {
|
|
26
|
+
api = new IfcAPI();
|
|
27
|
+
await api.Init();
|
|
28
|
+
}, 120000);
|
|
29
|
+
describe("web-ifc compat IfcAPI", () => {
|
|
30
|
+
test("opens an IFC model, streams geometry, reads properties", async () => {
|
|
31
|
+
const buffer = new Uint8Array(fs.readFileSync("data/index.ifc"));
|
|
32
|
+
const modelID = api.OpenModel(buffer, SETTINGS);
|
|
33
|
+
expect(modelID).toBeGreaterThanOrEqual(0);
|
|
34
|
+
// Geometry: StreamAllMeshes must emit at least one FlatMesh carrying
|
|
35
|
+
// at least one PlacedGeometry.
|
|
36
|
+
let meshCount = 0;
|
|
37
|
+
let placedGeometryCount = 0;
|
|
38
|
+
api.StreamAllMeshes(modelID, (mesh) => {
|
|
39
|
+
meshCount++;
|
|
40
|
+
placedGeometryCount += mesh.geometries.size();
|
|
41
|
+
});
|
|
42
|
+
expect(meshCount).toBeGreaterThan(0);
|
|
43
|
+
expect(placedGeometryCount).toBeGreaterThan(0);
|
|
44
|
+
// Properties: the spatial structure resolves to a real IfcProject-rooted
|
|
45
|
+
// tree (numeric expressID, non-empty children), and item properties for
|
|
46
|
+
// the root round-trip the same expressID back.
|
|
47
|
+
const tree = await api.properties.getSpatialStructure(modelID);
|
|
48
|
+
// getSpatialStructure returns `Node | undefined` (the passthrough is
|
|
49
|
+
// optional-chained). Narrow it — undefined here is itself a failure.
|
|
50
|
+
if (tree === undefined) {
|
|
51
|
+
throw new Error("getSpatialStructure returned undefined for the IFC model");
|
|
52
|
+
}
|
|
53
|
+
expect(typeof tree.expressID).toBe("number");
|
|
54
|
+
expect(Array.isArray(tree.children)).toBe(true);
|
|
55
|
+
expect(tree.children.length).toBeGreaterThan(0);
|
|
56
|
+
const rootProps = await api.properties.getItemProperties(modelID, tree.expressID);
|
|
57
|
+
expect(rootProps.expressID).toBe(tree.expressID);
|
|
58
|
+
}, 120000);
|
|
59
|
+
test("opens a STEP (AP214) model and streams geometry", async () => {
|
|
60
|
+
const buffer = new Uint8Array(fs.readFileSync("data/create-a-tube.step"));
|
|
61
|
+
const modelID = api.OpenModel(buffer, SETTINGS);
|
|
62
|
+
expect(modelID).toBeGreaterThanOrEqual(0);
|
|
63
|
+
let placedGeometryCount = 0;
|
|
64
|
+
api.StreamAllMeshes(modelID, (mesh) => {
|
|
65
|
+
placedGeometryCount += mesh.geometries.size();
|
|
66
|
+
});
|
|
67
|
+
expect(placedGeometryCount).toBeGreaterThan(0);
|
|
68
|
+
}, 120000);
|
|
69
|
+
test("routes an AP203 (CONFIG_CONTROL_DESIGN) model through the AP214 loader", () => {
|
|
70
|
+
// Validates the AP203→AP214 fall-through added to the passthrough
|
|
71
|
+
// factory (the standalone adapter had no AP203 case and errored).
|
|
72
|
+
// OpenModel catches construction errors internally and returns -1, so
|
|
73
|
+
// it never throws — asserting "doesn't throw" proves nothing. Instead
|
|
74
|
+
// assert the AP203 branch was actually entered, by spying on the
|
|
75
|
+
// factory's `Logger.warning('AP203 Step Detected, using AP214 loader')`.
|
|
76
|
+
// AP203-via-AP214 parse correctness is tracked separately
|
|
77
|
+
// (step-support.md Phase 4).
|
|
78
|
+
const buffer = new Uint8Array(fs.readFileSync("data/config-control-design-min.step"));
|
|
79
|
+
const warnSpy = jest.spyOn(Logger, "warning").mockImplementation(() => { });
|
|
80
|
+
try {
|
|
81
|
+
api.OpenModel(buffer, SETTINGS);
|
|
82
|
+
expect(warnSpy).toHaveBeenCalledWith("AP203 Step Detected, using AP214 loader");
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
warnSpy.mockRestore();
|
|
86
|
+
}
|
|
87
|
+
}, 120000);
|
|
88
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FlatMesh, IfcGeometry, RawLineData, Vector } from "./ifc_api.js";
|
|
2
|
+
import { PropertiesPassthrough } from "./properties_passthrough.js";
|
|
3
|
+
export interface IfcApiModelPassthrough {
|
|
4
|
+
properties: PropertiesPassthrough;
|
|
5
|
+
getFlatMesh(expressID: number): FlatMesh;
|
|
6
|
+
loadAllGeometry(): Vector<FlatMesh>;
|
|
7
|
+
streamAllMeshesWithTypes(types: number[], meshCallback: (mesh: FlatMesh) => void): void;
|
|
8
|
+
streamAllMeshes(meshCallback: (mesh: FlatMesh) => void): void;
|
|
9
|
+
getCoordinationMatrix(): number[];
|
|
10
|
+
getAllLines(): Vector<number>;
|
|
11
|
+
getLineIDsWithType(type: number): Vector<number>;
|
|
12
|
+
getRawLineData(expressID: number): RawLineData;
|
|
13
|
+
flattenLine(line: any): void;
|
|
14
|
+
getLine(expressID: number, flatten?: boolean): string | void;
|
|
15
|
+
getGeometry(geometryExpressID: number): IfcGeometry;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ifc_api_model_passthrough.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ifc_api_model_passthrough.d.ts","sourceRoot":"","sources":["../../../../src/compat/web-ifc/ifc_api_model_passthrough.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAGhE,MAAM,WAAW,sBAAsB;IAErC,UAAU,EAAE,qBAAqB,CAAA;IAEjC,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CAAA;IACxC,eAAe,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAA;IACnC,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,GAAG,IAAI,CAAA;IACvF,eAAe,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,GAAG,IAAI,CAAA;IAC7D,qBAAqB,IAAI,MAAM,EAAE,CAAA;IACjC,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,CAAA;IAC7B,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;IAChD,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,CAAA;IAC9C,WAAW,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,CAAA;IAC5B,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAAA;IAC5D,WAAW,CAAC,iBAAiB,EAAE,MAAM,GAAG,WAAW,CAAA;CACpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Loadersettings } from "./ifc_api.js";
|
|
2
|
+
import { IfcApiModelPassthrough } from "./ifc_api_model_passthrough.js";
|
|
3
|
+
/**
|
|
4
|
+
* The factory to construct models.
|
|
5
|
+
*/
|
|
6
|
+
export declare class IfcApiModelPassthroughFactory {
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param modelID
|
|
10
|
+
* @param data
|
|
11
|
+
* @param wasmModule
|
|
12
|
+
* @param settings
|
|
13
|
+
* @return {IfcApiModelPassthrough | undefined}
|
|
14
|
+
*/
|
|
15
|
+
static from(modelID: number, data: Uint8Array, wasmModule: any, settings?: Loadersettings): IfcApiModelPassthrough | undefined;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ifc_api_model_passthrough_factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ifc_api_model_passthrough_factory.d.ts","sourceRoot":"","sources":["../../../../src/compat/web-ifc/ifc_api_model_passthrough_factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAKpE;;GAEG;AACH,qBAAa,6BAA6B;IAExC;;;;;;;OAOG;WACW,IAAI,CACd,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,GAAG,EACf,QAAQ,CAAC,EAAE,cAAc,GAAI,sBAAsB,GAAG,SAAS;CA+DpE"}
|