@ifc-lite/export 1.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/LICENSE +373 -0
- package/dist/csv-exporter.d.ts +40 -0
- package/dist/csv-exporter.d.ts.map +1 -0
- package/dist/csv-exporter.js +159 -0
- package/dist/csv-exporter.js.map +1 -0
- package/dist/gltf-exporter.d.ts +27 -0
- package/dist/gltf-exporter.d.ts.map +1 -0
- package/dist/gltf-exporter.js +295 -0
- package/dist/gltf-exporter.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/jsonld-exporter.d.ts +36 -0
- package/dist/jsonld-exporter.d.ts.map +1 -0
- package/dist/jsonld-exporter.js +167 -0
- package/dist/jsonld-exporter.js.map +1 -0
- package/dist/parquet-exporter.d.ts +40 -0
- package/dist/parquet-exporter.d.ts.map +1 -0
- package/dist/parquet-exporter.js +440 -0
- package/dist/parquet-exporter.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,295 @@
|
|
|
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
|
+
export class GLTFExporter {
|
|
5
|
+
geometryResult;
|
|
6
|
+
constructor(geometryResult) {
|
|
7
|
+
this.geometryResult = geometryResult;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Export to GLB (binary glTF)
|
|
11
|
+
*/
|
|
12
|
+
exportGLB(options = {}) {
|
|
13
|
+
const gltf = this.buildGLTF(options);
|
|
14
|
+
return this.packGLB(gltf.json, gltf.buffers);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Export to glTF (JSON + separate .bin)
|
|
18
|
+
*/
|
|
19
|
+
exportGLTF(options = {}) {
|
|
20
|
+
const gltf = this.buildGLTF(options);
|
|
21
|
+
return {
|
|
22
|
+
json: JSON.stringify(gltf.json, null, 2),
|
|
23
|
+
bin: this.combineBuffers(gltf.buffers),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
buildGLTF(options) {
|
|
27
|
+
const meshes = this.geometryResult.meshes;
|
|
28
|
+
const gltf = {
|
|
29
|
+
asset: {
|
|
30
|
+
version: '2.0',
|
|
31
|
+
generator: 'IFC-Lite',
|
|
32
|
+
},
|
|
33
|
+
scene: 0,
|
|
34
|
+
scenes: [{ nodes: [] }],
|
|
35
|
+
nodes: [],
|
|
36
|
+
meshes: [],
|
|
37
|
+
accessors: [],
|
|
38
|
+
bufferViews: [],
|
|
39
|
+
buffers: [{ byteLength: 0 }],
|
|
40
|
+
};
|
|
41
|
+
if (options.includeMetadata) {
|
|
42
|
+
gltf.asset.extras = {
|
|
43
|
+
meshCount: meshes.length,
|
|
44
|
+
vertexCount: this.geometryResult.totalVertices,
|
|
45
|
+
triangleCount: this.geometryResult.totalTriangles,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// Collect geometry data
|
|
49
|
+
const positions = [];
|
|
50
|
+
const normals = [];
|
|
51
|
+
const indices = [];
|
|
52
|
+
const nodeIndices = [];
|
|
53
|
+
// Helper function to calculate min/max bounds for positions
|
|
54
|
+
const calculateBounds = (positions) => {
|
|
55
|
+
if (positions.length === 0) {
|
|
56
|
+
return { min: [0, 0, 0], max: [0, 0, 0] };
|
|
57
|
+
}
|
|
58
|
+
let minX = positions[0];
|
|
59
|
+
let minY = positions[1];
|
|
60
|
+
let minZ = positions[2];
|
|
61
|
+
let maxX = positions[0];
|
|
62
|
+
let maxY = positions[1];
|
|
63
|
+
let maxZ = positions[2];
|
|
64
|
+
for (let i = 0; i < positions.length; i += 3) {
|
|
65
|
+
const x = positions[i];
|
|
66
|
+
const y = positions[i + 1];
|
|
67
|
+
const z = positions[i + 2];
|
|
68
|
+
minX = Math.min(minX, x);
|
|
69
|
+
minY = Math.min(minY, y);
|
|
70
|
+
minZ = Math.min(minZ, z);
|
|
71
|
+
maxX = Math.max(maxX, x);
|
|
72
|
+
maxY = Math.max(maxY, y);
|
|
73
|
+
maxZ = Math.max(maxZ, z);
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
min: [minX, minY, minZ],
|
|
77
|
+
max: [maxX, maxY, maxZ],
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
for (let i = 0; i < meshes.length; i++) {
|
|
81
|
+
const mesh = meshes[i];
|
|
82
|
+
const meshPositions = (mesh.positions || []);
|
|
83
|
+
const meshNormals = (mesh.normals || []);
|
|
84
|
+
const meshIndices = (mesh.indices || []);
|
|
85
|
+
// Skip empty meshes
|
|
86
|
+
if (!meshPositions.length || !meshNormals.length || !meshIndices.length) {
|
|
87
|
+
console.warn(`Skipping empty mesh ${i} (positions: ${meshPositions.length}, normals: ${meshNormals.length}, indices: ${meshIndices.length})`);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
// Validate array lengths are multiples of 3 for positions/normals
|
|
91
|
+
if (meshPositions.length % 3 !== 0) {
|
|
92
|
+
console.warn(`Mesh ${i} has invalid position count: ${meshPositions.length} (not divisible by 3)`);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (meshNormals.length % 3 !== 0) {
|
|
96
|
+
console.warn(`Mesh ${i} has invalid normal count: ${meshNormals.length} (not divisible by 3)`);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
// Calculate byte offsets BEFORE adding data (based on current array lengths)
|
|
100
|
+
const positionByteOffset = positions.length * 4; // Each float is 4 bytes
|
|
101
|
+
const normalByteOffset = normals.length * 4;
|
|
102
|
+
const indexByteOffset = indices.length * 4;
|
|
103
|
+
const meshPositionsArray = Array.from(meshPositions);
|
|
104
|
+
const meshNormalsArray = Array.from(meshNormals);
|
|
105
|
+
const meshIndicesArray = Array.from(meshIndices);
|
|
106
|
+
positions.push(...meshPositionsArray);
|
|
107
|
+
normals.push(...meshNormalsArray);
|
|
108
|
+
// Indices stay local (0-based) for each mesh since each mesh has its own
|
|
109
|
+
// accessor pointing to its own section of the bufferView
|
|
110
|
+
indices.push(...meshIndicesArray);
|
|
111
|
+
// Calculate bounds for this mesh's positions
|
|
112
|
+
const bounds = calculateBounds(meshPositionsArray);
|
|
113
|
+
// Accessors - byteOffset is relative to the bufferView start
|
|
114
|
+
const posAccessorIdx = gltf.accessors.length;
|
|
115
|
+
gltf.accessors.push({
|
|
116
|
+
bufferView: 0,
|
|
117
|
+
byteOffset: positionByteOffset,
|
|
118
|
+
componentType: 5126, // FLOAT
|
|
119
|
+
count: meshPositions.length / 3,
|
|
120
|
+
type: 'VEC3',
|
|
121
|
+
min: bounds.min,
|
|
122
|
+
max: bounds.max,
|
|
123
|
+
});
|
|
124
|
+
const normAccessorIdx = gltf.accessors.length;
|
|
125
|
+
gltf.accessors.push({
|
|
126
|
+
bufferView: 1,
|
|
127
|
+
byteOffset: normalByteOffset,
|
|
128
|
+
componentType: 5126,
|
|
129
|
+
count: meshNormals.length / 3,
|
|
130
|
+
type: 'VEC3',
|
|
131
|
+
});
|
|
132
|
+
const idxAccessorIdx = gltf.accessors.length;
|
|
133
|
+
gltf.accessors.push({
|
|
134
|
+
bufferView: 2,
|
|
135
|
+
byteOffset: indexByteOffset,
|
|
136
|
+
componentType: 5125, // UNSIGNED_INT
|
|
137
|
+
count: meshIndices.length,
|
|
138
|
+
type: 'SCALAR',
|
|
139
|
+
});
|
|
140
|
+
// Mesh
|
|
141
|
+
const meshIdx = gltf.meshes.length;
|
|
142
|
+
gltf.meshes.push({
|
|
143
|
+
primitives: [{
|
|
144
|
+
attributes: {
|
|
145
|
+
POSITION: posAccessorIdx,
|
|
146
|
+
NORMAL: normAccessorIdx,
|
|
147
|
+
},
|
|
148
|
+
indices: idxAccessorIdx,
|
|
149
|
+
}],
|
|
150
|
+
});
|
|
151
|
+
// Node
|
|
152
|
+
const nodeIdx = gltf.nodes.length;
|
|
153
|
+
const node = {
|
|
154
|
+
mesh: meshIdx,
|
|
155
|
+
};
|
|
156
|
+
if (options.includeMetadata && mesh.expressId) {
|
|
157
|
+
node.extras = {
|
|
158
|
+
expressId: mesh.expressId,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
gltf.nodes.push(node);
|
|
162
|
+
nodeIndices.push(nodeIdx);
|
|
163
|
+
}
|
|
164
|
+
gltf.scenes[0].nodes = nodeIndices;
|
|
165
|
+
// Ensure we have data before creating buffers
|
|
166
|
+
if (positions.length === 0 || normals.length === 0 || indices.length === 0) {
|
|
167
|
+
throw new Error('Cannot export GLB: no valid geometry data found');
|
|
168
|
+
}
|
|
169
|
+
// Buffer views - create typed arrays and get their byte buffers
|
|
170
|
+
const positionsArray = new Float32Array(positions);
|
|
171
|
+
const normalsArray = new Float32Array(normals);
|
|
172
|
+
const indicesArray = new Uint32Array(indices);
|
|
173
|
+
const positionsBytes = positionsArray.buffer;
|
|
174
|
+
const normalsBytes = normalsArray.buffer;
|
|
175
|
+
const indicesBytes = indicesArray.buffer;
|
|
176
|
+
const totalBufferSize = positionsBytes.byteLength + normalsBytes.byteLength + indicesBytes.byteLength;
|
|
177
|
+
// Create bufferViews
|
|
178
|
+
// byteStride is set to the element size (12 bytes for VEC3 FLOAT) for non-interleaved data
|
|
179
|
+
// This satisfies validators that require byteStride when multiple accessors share a bufferView
|
|
180
|
+
gltf.bufferViews.push({
|
|
181
|
+
buffer: 0,
|
|
182
|
+
byteOffset: 0,
|
|
183
|
+
byteLength: positionsBytes.byteLength,
|
|
184
|
+
byteStride: 12, // 3 floats * 4 bytes = 12 bytes per VEC3
|
|
185
|
+
target: 34962, // ARRAY_BUFFER
|
|
186
|
+
});
|
|
187
|
+
gltf.bufferViews.push({
|
|
188
|
+
buffer: 0,
|
|
189
|
+
byteOffset: positionsBytes.byteLength,
|
|
190
|
+
byteLength: normalsBytes.byteLength,
|
|
191
|
+
byteStride: 12, // 3 floats * 4 bytes = 12 bytes per VEC3
|
|
192
|
+
target: 34962,
|
|
193
|
+
});
|
|
194
|
+
gltf.bufferViews.push({
|
|
195
|
+
buffer: 0,
|
|
196
|
+
byteOffset: positionsBytes.byteLength + normalsBytes.byteLength,
|
|
197
|
+
byteLength: indicesBytes.byteLength,
|
|
198
|
+
// No byteStride for indices (ELEMENT_ARRAY_BUFFER)
|
|
199
|
+
target: 34963, // ELEMENT_ARRAY_BUFFER
|
|
200
|
+
});
|
|
201
|
+
gltf.buffers[0].byteLength = totalBufferSize;
|
|
202
|
+
// Validate that all accessors fit within their bufferViews
|
|
203
|
+
for (const accessor of gltf.accessors) {
|
|
204
|
+
const bufferView = gltf.bufferViews[accessor.bufferView];
|
|
205
|
+
if (!bufferView) {
|
|
206
|
+
throw new Error(`Accessor references invalid bufferView ${accessor.bufferView}`);
|
|
207
|
+
}
|
|
208
|
+
// Calculate accessor byte length
|
|
209
|
+
let componentSize = 0;
|
|
210
|
+
if (accessor.componentType === 5126)
|
|
211
|
+
componentSize = 4; // FLOAT
|
|
212
|
+
else if (accessor.componentType === 5125)
|
|
213
|
+
componentSize = 4; // UNSIGNED_INT
|
|
214
|
+
else if (accessor.componentType === 5123)
|
|
215
|
+
componentSize = 2; // UNSIGNED_SHORT
|
|
216
|
+
else if (accessor.componentType === 5120)
|
|
217
|
+
componentSize = 1; // BYTE
|
|
218
|
+
else
|
|
219
|
+
throw new Error(`Unsupported component type: ${accessor.componentType}`);
|
|
220
|
+
let componentsPerElement = 1;
|
|
221
|
+
if (accessor.type === 'VEC3')
|
|
222
|
+
componentsPerElement = 3;
|
|
223
|
+
else if (accessor.type === 'VEC2')
|
|
224
|
+
componentsPerElement = 2;
|
|
225
|
+
else if (accessor.type === 'SCALAR')
|
|
226
|
+
componentsPerElement = 1;
|
|
227
|
+
else
|
|
228
|
+
throw new Error(`Unsupported accessor type: ${accessor.type}`);
|
|
229
|
+
const accessorByteLength = accessor.count * componentsPerElement * componentSize;
|
|
230
|
+
const accessorEnd = (accessor.byteOffset || 0) + accessorByteLength;
|
|
231
|
+
if (accessorEnd > bufferView.byteLength) {
|
|
232
|
+
throw new Error(`Accessor exceeds bufferView bounds: ` +
|
|
233
|
+
`accessor byteOffset=${accessor.byteOffset || 0}, length=${accessorByteLength}, ` +
|
|
234
|
+
`bufferView byteLength=${bufferView.byteLength}, end=${accessorEnd}`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
json: gltf,
|
|
239
|
+
buffers: [
|
|
240
|
+
new Uint8Array(positionsBytes),
|
|
241
|
+
new Uint8Array(normalsBytes),
|
|
242
|
+
new Uint8Array(indicesBytes),
|
|
243
|
+
],
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
combineBuffers(buffers) {
|
|
247
|
+
const totalLength = buffers.reduce((sum, buf) => sum + buf.byteLength, 0);
|
|
248
|
+
const combined = new Uint8Array(totalLength);
|
|
249
|
+
let offset = 0;
|
|
250
|
+
for (const buffer of buffers) {
|
|
251
|
+
combined.set(buffer, offset);
|
|
252
|
+
offset += buffer.byteLength;
|
|
253
|
+
}
|
|
254
|
+
return combined;
|
|
255
|
+
}
|
|
256
|
+
packGLB(gltfJson, buffers) {
|
|
257
|
+
const jsonString = JSON.stringify(gltfJson);
|
|
258
|
+
const jsonBuffer = new TextEncoder().encode(jsonString);
|
|
259
|
+
const jsonPadding = (4 - (jsonBuffer.byteLength % 4)) % 4;
|
|
260
|
+
const paddedJsonLength = jsonBuffer.byteLength + jsonPadding;
|
|
261
|
+
const bin = this.combineBuffers(buffers);
|
|
262
|
+
const binPadding = (4 - (bin.byteLength % 4)) % 4;
|
|
263
|
+
const paddedBinLength = bin.byteLength + binPadding;
|
|
264
|
+
const totalLength = 12 + 8 + paddedJsonLength + 8 + paddedBinLength;
|
|
265
|
+
const glb = new ArrayBuffer(totalLength);
|
|
266
|
+
const view = new DataView(glb);
|
|
267
|
+
const bytes = new Uint8Array(glb);
|
|
268
|
+
let offset = 0;
|
|
269
|
+
// GLB header
|
|
270
|
+
view.setUint32(offset, 0x46546C67, true); // 'glTF'
|
|
271
|
+
offset += 4;
|
|
272
|
+
view.setUint32(offset, 2, true);
|
|
273
|
+
offset += 4;
|
|
274
|
+
view.setUint32(offset, totalLength, true);
|
|
275
|
+
offset += 4;
|
|
276
|
+
// JSON chunk
|
|
277
|
+
view.setUint32(offset, paddedJsonLength, true);
|
|
278
|
+
offset += 4;
|
|
279
|
+
view.setUint32(offset, 0x4E4F534A, true); // 'JSON'
|
|
280
|
+
offset += 4;
|
|
281
|
+
bytes.set(jsonBuffer, offset);
|
|
282
|
+
offset += jsonBuffer.byteLength;
|
|
283
|
+
for (let i = 0; i < jsonPadding; i++) {
|
|
284
|
+
bytes[offset++] = 0x20;
|
|
285
|
+
}
|
|
286
|
+
// BIN chunk
|
|
287
|
+
view.setUint32(offset, paddedBinLength, true);
|
|
288
|
+
offset += 4;
|
|
289
|
+
view.setUint32(offset, 0x004E4942, true); // 'BIN\0'
|
|
290
|
+
offset += 4;
|
|
291
|
+
bytes.set(bin, offset);
|
|
292
|
+
return new Uint8Array(glb);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
//# sourceMappingURL=gltf-exporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gltf-exporter.js","sourceRoot":"","sources":["../src/gltf-exporter.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAa/D,MAAM,OAAO,YAAY;IACb,cAAc,CAAiB;IAEvC,YAAY,cAA8B;QACtC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,UAA6B,EAAE;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,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C,CAAC,CAAC,SAAS;QACnD,MAAM,IAAI,CAAC,CAAC;QACZ,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC9B,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC;YACnC,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;QAC3B,CAAC;QAED,YAAY;QACZ,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;QAC9C,MAAM,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU;QACpD,MAAM,IAAI,CAAC,CAAC;QACZ,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAEvB,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;CACJ"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ifc-lite/export - Export formats
|
|
3
|
+
*/
|
|
4
|
+
export { GLTFExporter, type GLTFExportOptions } from './gltf-exporter.js';
|
|
5
|
+
export { ParquetExporter, type ParquetExportOptions } from './parquet-exporter.js';
|
|
6
|
+
export { CSVExporter, type CSVExportOptions } from './csv-exporter.js';
|
|
7
|
+
export { JSONLDExporter, type JSONLDExportOptions } from './jsonld-exporter.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
* @ifc-lite/export - Export formats
|
|
6
|
+
*/
|
|
7
|
+
export { GLTFExporter } from './gltf-exporter.js';
|
|
8
|
+
export { ParquetExporter } from './parquet-exporter.js';
|
|
9
|
+
export { CSVExporter } from './csv-exporter.js';
|
|
10
|
+
export { JSONLDExporter } from './jsonld-exporter.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;GAEG;AAEH,OAAO,EAAE,YAAY,EAA0B,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAA6B,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,WAAW,EAAyB,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,cAAc,EAA4B,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-LD exporter for semantic web compatibility
|
|
3
|
+
*/
|
|
4
|
+
import type { IfcDataStore } from '@ifc-lite/parser';
|
|
5
|
+
export interface JSONLDExportOptions {
|
|
6
|
+
context?: string;
|
|
7
|
+
includeGeometry?: boolean;
|
|
8
|
+
includeProperties?: boolean;
|
|
9
|
+
includeQuantities?: boolean;
|
|
10
|
+
entityIds?: number[];
|
|
11
|
+
}
|
|
12
|
+
export declare class JSONLDExporter {
|
|
13
|
+
private store;
|
|
14
|
+
constructor(store: IfcDataStore);
|
|
15
|
+
/**
|
|
16
|
+
* Export to JSON-LD format
|
|
17
|
+
*/
|
|
18
|
+
export(options?: JSONLDExportOptions): object;
|
|
19
|
+
/**
|
|
20
|
+
* Get all entity IDs from the store
|
|
21
|
+
*/
|
|
22
|
+
private getAllEntityIds;
|
|
23
|
+
/**
|
|
24
|
+
* Format property value for JSON-LD
|
|
25
|
+
*/
|
|
26
|
+
private formatPropertyValue;
|
|
27
|
+
/**
|
|
28
|
+
* Get property type name from enum
|
|
29
|
+
*/
|
|
30
|
+
private getPropertyTypeName;
|
|
31
|
+
/**
|
|
32
|
+
* Get quantity type name from enum
|
|
33
|
+
*/
|
|
34
|
+
private getQuantityTypeName;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=jsonld-exporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonld-exporter.d.ts","sourceRoot":"","sources":["../src/jsonld-exporter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAKrD,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAe;gBAEhB,KAAK,EAAE,YAAY;IAI/B;;OAEG;IACH,MAAM,CAAC,OAAO,GAAE,mBAAwB,GAAG,MAAM;IA6HjD;;OAEG;IACH,OAAO,CAAC,eAAe;IAQvB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAgB3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAW3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAW5B"}
|
|
@@ -0,0 +1,167 @@
|
|
|
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
|
+
const DEFAULT_CONTEXT = 'https://standards.buildingsmart.org/IFC/DEV/IFC4/ADD2/OWL';
|
|
5
|
+
export class JSONLDExporter {
|
|
6
|
+
store;
|
|
7
|
+
constructor(store) {
|
|
8
|
+
this.store = store;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Export to JSON-LD format
|
|
12
|
+
*/
|
|
13
|
+
export(options = {}) {
|
|
14
|
+
const context = options.context ?? DEFAULT_CONTEXT;
|
|
15
|
+
const includeProperties = options.includeProperties ?? true;
|
|
16
|
+
const includeQuantities = options.includeQuantities ?? false;
|
|
17
|
+
const entityIds = options.entityIds ?? this.getAllEntityIds();
|
|
18
|
+
const graph = [];
|
|
19
|
+
for (const id of entityIds) {
|
|
20
|
+
const node = {
|
|
21
|
+
'@id': `ifc:${id}`,
|
|
22
|
+
'@type': `ifc:${this.store.entities.getTypeName(id)}`,
|
|
23
|
+
'ifc:expressId': id,
|
|
24
|
+
};
|
|
25
|
+
const globalId = this.store.entities.getGlobalId(id);
|
|
26
|
+
if (globalId) {
|
|
27
|
+
node['ifc:globalId'] = globalId;
|
|
28
|
+
}
|
|
29
|
+
const name = this.store.entities.getName(id);
|
|
30
|
+
if (name) {
|
|
31
|
+
node['ifc:name'] = name;
|
|
32
|
+
}
|
|
33
|
+
if (includeProperties) {
|
|
34
|
+
const properties = this.store.properties.getForEntity(id);
|
|
35
|
+
if (properties.length > 0) {
|
|
36
|
+
const propertySets = [];
|
|
37
|
+
for (const pset of properties) {
|
|
38
|
+
const psetNode = {
|
|
39
|
+
'@type': 'ifc:IfcPropertySet',
|
|
40
|
+
'ifc:name': pset.name,
|
|
41
|
+
};
|
|
42
|
+
if (pset.globalId) {
|
|
43
|
+
psetNode['ifc:globalId'] = pset.globalId;
|
|
44
|
+
}
|
|
45
|
+
const props = [];
|
|
46
|
+
for (const prop of pset.properties) {
|
|
47
|
+
const propNode = {
|
|
48
|
+
'@type': `ifc:${this.getPropertyTypeName(prop.type)}`,
|
|
49
|
+
'ifc:name': prop.name,
|
|
50
|
+
};
|
|
51
|
+
const value = this.formatPropertyValue(prop.value);
|
|
52
|
+
if (value !== null) {
|
|
53
|
+
propNode['ifc:nominalValue'] = value;
|
|
54
|
+
}
|
|
55
|
+
if (prop.unit) {
|
|
56
|
+
propNode['ifc:unit'] = prop.unit;
|
|
57
|
+
}
|
|
58
|
+
props.push(propNode);
|
|
59
|
+
}
|
|
60
|
+
if (props.length > 0) {
|
|
61
|
+
psetNode['ifc:hasProperties'] = props;
|
|
62
|
+
}
|
|
63
|
+
propertySets.push(psetNode);
|
|
64
|
+
}
|
|
65
|
+
if (propertySets.length > 0) {
|
|
66
|
+
node['ifc:hasPropertySets'] = propertySets;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (includeQuantities && this.store.quantities) {
|
|
71
|
+
const quantities = this.store.quantities.getForEntity(id);
|
|
72
|
+
if (quantities.length > 0) {
|
|
73
|
+
const quantitySets = [];
|
|
74
|
+
for (const qset of quantities) {
|
|
75
|
+
const qsetNode = {
|
|
76
|
+
'@type': 'ifc:IfcElementQuantity',
|
|
77
|
+
'ifc:name': qset.name,
|
|
78
|
+
};
|
|
79
|
+
const quants = [];
|
|
80
|
+
for (const quant of qset.quantities) {
|
|
81
|
+
const quantNode = {
|
|
82
|
+
'@type': `ifc:${this.getQuantityTypeName(quant.type)}`,
|
|
83
|
+
'ifc:name': quant.name,
|
|
84
|
+
'ifc:value': quant.value,
|
|
85
|
+
};
|
|
86
|
+
if (quant.unit) {
|
|
87
|
+
quantNode['ifc:unit'] = quant.unit;
|
|
88
|
+
}
|
|
89
|
+
if (quant.formula) {
|
|
90
|
+
quantNode['ifc:formula'] = quant.formula;
|
|
91
|
+
}
|
|
92
|
+
quants.push(quantNode);
|
|
93
|
+
}
|
|
94
|
+
if (quants.length > 0) {
|
|
95
|
+
qsetNode['ifc:quantities'] = quants;
|
|
96
|
+
}
|
|
97
|
+
quantitySets.push(qsetNode);
|
|
98
|
+
}
|
|
99
|
+
if (quantitySets.length > 0) {
|
|
100
|
+
node['ifc:hasQuantitySets'] = quantitySets;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
graph.push(node);
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
'@context': {
|
|
108
|
+
'@vocab': context + '#',
|
|
109
|
+
'ifc': context + '#',
|
|
110
|
+
},
|
|
111
|
+
'@graph': graph,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get all entity IDs from the store
|
|
116
|
+
*/
|
|
117
|
+
getAllEntityIds() {
|
|
118
|
+
const ids = [];
|
|
119
|
+
for (let i = 0; i < this.store.entities.count; i++) {
|
|
120
|
+
ids.push(this.store.entities.expressId[i]);
|
|
121
|
+
}
|
|
122
|
+
return ids;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Format property value for JSON-LD
|
|
126
|
+
*/
|
|
127
|
+
formatPropertyValue(value) {
|
|
128
|
+
if (value === null || value === undefined) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
if (Array.isArray(value)) {
|
|
132
|
+
return value.map(v => this.formatPropertyValue(v));
|
|
133
|
+
}
|
|
134
|
+
if (typeof value === 'object') {
|
|
135
|
+
return JSON.stringify(value);
|
|
136
|
+
}
|
|
137
|
+
return value;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get property type name from enum
|
|
141
|
+
*/
|
|
142
|
+
getPropertyTypeName(type) {
|
|
143
|
+
const typeNames = {
|
|
144
|
+
0: 'IfcPropertySingleValue',
|
|
145
|
+
1: 'IfcPropertySingleValue',
|
|
146
|
+
2: 'IfcPropertyEnumeratedValue',
|
|
147
|
+
3: 'IfcPropertyBoundedValue',
|
|
148
|
+
4: 'IfcPropertyListValue',
|
|
149
|
+
};
|
|
150
|
+
return typeNames[type] ?? 'IfcPropertySingleValue';
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get quantity type name from enum
|
|
154
|
+
*/
|
|
155
|
+
getQuantityTypeName(type) {
|
|
156
|
+
const typeNames = {
|
|
157
|
+
0: 'IfcQuantityLength',
|
|
158
|
+
1: 'IfcQuantityArea',
|
|
159
|
+
2: 'IfcQuantityVolume',
|
|
160
|
+
3: 'IfcQuantityCount',
|
|
161
|
+
4: 'IfcQuantityWeight',
|
|
162
|
+
5: 'IfcQuantityTime',
|
|
163
|
+
};
|
|
164
|
+
return typeNames[type] ?? 'IfcQuantityLength';
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=jsonld-exporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonld-exporter.js","sourceRoot":"","sources":["../src/jsonld-exporter.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAS/D,MAAM,eAAe,GAAG,2DAA2D,CAAC;AAUpF,MAAM,OAAO,cAAc;IACjB,KAAK,CAAe;IAE5B,YAAY,KAAmB;QAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,UAA+B,EAAE;QACtC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,eAAe,CAAC;QACnD,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,IAAI,IAAI,CAAC;QAC5D,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,IAAI,KAAK,CAAC;QAC7D,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,eAA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B,CAAC,EAAE,mBAAmB;YACtB,CAAC,EAAE,iBAAiB;SACrB,CAAC;QACF,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,mBAAmB,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parquet exporter for ara3d BOS-compatible format
|
|
3
|
+
*/
|
|
4
|
+
import type { IfcDataStore } from '@ifc-lite/parser';
|
|
5
|
+
import type { GeometryResult } from '@ifc-lite/geometry';
|
|
6
|
+
import { QuantityType } from '@ifc-lite/data';
|
|
7
|
+
export interface ParquetExportOptions {
|
|
8
|
+
includeGeometry?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Export to ara3d BIM Open Schema compatible Parquet files.
|
|
12
|
+
* Creates a .bos archive (ZIP of Parquet files).
|
|
13
|
+
*/
|
|
14
|
+
export declare class ParquetExporter {
|
|
15
|
+
private store;
|
|
16
|
+
private geometryResult?;
|
|
17
|
+
constructor(store: IfcDataStore, geometryResult?: GeometryResult);
|
|
18
|
+
/**
|
|
19
|
+
* Export full model to .bos archive.
|
|
20
|
+
*/
|
|
21
|
+
exportBOS(options?: ParquetExportOptions): Promise<Uint8Array>;
|
|
22
|
+
/**
|
|
23
|
+
* Export individual Parquet file.
|
|
24
|
+
*/
|
|
25
|
+
exportTable(tableName: string): Promise<Uint8Array>;
|
|
26
|
+
private writeEntities;
|
|
27
|
+
private writeProperties;
|
|
28
|
+
private writeQuantities;
|
|
29
|
+
private writeRelationships;
|
|
30
|
+
private writeStrings;
|
|
31
|
+
private writeVertexBuffer;
|
|
32
|
+
private writeIndexBuffer;
|
|
33
|
+
private writeMeshes;
|
|
34
|
+
private writeSpatialHierarchy;
|
|
35
|
+
private writeMetadata;
|
|
36
|
+
private toParquet;
|
|
37
|
+
private createZipArchive;
|
|
38
|
+
}
|
|
39
|
+
export declare function QuantityTypeToString(type: QuantityType): string;
|
|
40
|
+
//# sourceMappingURL=parquet-exporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parquet-exporter.d.ts","sourceRoot":"","sources":["../src/parquet-exporter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAoE,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AAElI,MAAM,WAAW,oBAAoB;IACjC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,qBAAa,eAAe;IACxB,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,cAAc,CAAC,CAAiB;gBAE5B,KAAK,EAAE,YAAY,EAAE,cAAc,CAAC,EAAE,cAAc;IAKhE;;OAEG;IACG,SAAS,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,UAAU,CAAC;IA4BxE;;OAEG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;YAkB3C,aAAa;YAkBb,eAAe;YAgBf,eAAe;YAaf,kBAAkB;YA4BlB,YAAY;YAkBZ,iBAAiB;YA2CjB,gBAAgB;YA0BhB,WAAW;YAmCX,qBAAqB;IA0EnC,OAAO,CAAC,aAAa;YA6BP,SAAS;YAwET,gBAAgB;CAUjC;AA+BD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAU/D"}
|