@ifc-lite/drawing-2d 1.4.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/drawing-generator.d.ts +80 -0
- package/dist/drawing-generator.d.ts.map +1 -0
- package/dist/drawing-generator.js +281 -0
- package/dist/drawing-generator.js.map +1 -0
- package/dist/edge-extractor.d.ts +47 -0
- package/dist/edge-extractor.d.ts.map +1 -0
- package/dist/edge-extractor.js +204 -0
- package/dist/edge-extractor.js.map +1 -0
- package/dist/gpu-section-cutter.d.ts +42 -0
- package/dist/gpu-section-cutter.d.ts.map +1 -0
- package/dist/gpu-section-cutter.js +405 -0
- package/dist/gpu-section-cutter.js.map +1 -0
- package/dist/graphic-overrides/index.d.ts +10 -0
- package/dist/graphic-overrides/index.d.ts.map +1 -0
- package/dist/graphic-overrides/index.js +8 -0
- package/dist/graphic-overrides/index.js.map +1 -0
- package/dist/graphic-overrides/presets.d.ts +22 -0
- package/dist/graphic-overrides/presets.d.ts.map +1 -0
- package/dist/graphic-overrides/presets.js +283 -0
- package/dist/graphic-overrides/presets.js.map +1 -0
- package/dist/graphic-overrides/rule-engine.d.ts +64 -0
- package/dist/graphic-overrides/rule-engine.d.ts.map +1 -0
- package/dist/graphic-overrides/rule-engine.js +438 -0
- package/dist/graphic-overrides/rule-engine.js.map +1 -0
- package/dist/graphic-overrides/types.d.ts +200 -0
- package/dist/graphic-overrides/types.d.ts.map +1 -0
- package/dist/graphic-overrides/types.js +5 -0
- package/dist/graphic-overrides/types.js.map +1 -0
- package/dist/hatch-generator.d.ts +76 -0
- package/dist/hatch-generator.d.ts.map +1 -0
- package/dist/hatch-generator.js +282 -0
- package/dist/hatch-generator.js.map +1 -0
- package/dist/hidden-line.d.ts +64 -0
- package/dist/hidden-line.d.ts.map +1 -0
- package/dist/hidden-line.js +318 -0
- package/dist/hidden-line.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +109 -0
- package/dist/index.js.map +1 -0
- package/dist/line-merger.d.ts +35 -0
- package/dist/line-merger.d.ts.map +1 -0
- package/dist/line-merger.js +265 -0
- package/dist/line-merger.js.map +1 -0
- package/dist/math.d.ts +90 -0
- package/dist/math.d.ts.map +1 -0
- package/dist/math.js +284 -0
- package/dist/math.js.map +1 -0
- package/dist/openings/index.d.ts +7 -0
- package/dist/openings/index.d.ts.map +1 -0
- package/dist/openings/index.js +10 -0
- package/dist/openings/index.js.map +1 -0
- package/dist/openings/opening-filter.d.ts +61 -0
- package/dist/openings/opening-filter.d.ts.map +1 -0
- package/dist/openings/opening-filter.js +244 -0
- package/dist/openings/opening-filter.js.map +1 -0
- package/dist/openings/opening-relationship-builder.d.ts +35 -0
- package/dist/openings/opening-relationship-builder.d.ts.map +1 -0
- package/dist/openings/opening-relationship-builder.js +121 -0
- package/dist/openings/opening-relationship-builder.js.map +1 -0
- package/dist/openings/opening-utils.d.ts +55 -0
- package/dist/openings/opening-utils.d.ts.map +1 -0
- package/dist/openings/opening-utils.js +128 -0
- package/dist/openings/opening-utils.js.map +1 -0
- package/dist/polygon-builder.d.ts +62 -0
- package/dist/polygon-builder.d.ts.map +1 -0
- package/dist/polygon-builder.js +261 -0
- package/dist/polygon-builder.js.map +1 -0
- package/dist/section-cutter.d.ts +49 -0
- package/dist/section-cutter.d.ts.map +1 -0
- package/dist/section-cutter.js +220 -0
- package/dist/section-cutter.js.map +1 -0
- package/dist/sheet/frame-renderer.d.ts +28 -0
- package/dist/sheet/frame-renderer.d.ts.map +1 -0
- package/dist/sheet/frame-renderer.js +199 -0
- package/dist/sheet/frame-renderer.js.map +1 -0
- package/dist/sheet/frame-types.d.ts +57 -0
- package/dist/sheet/frame-types.d.ts.map +1 -0
- package/dist/sheet/frame-types.js +88 -0
- package/dist/sheet/frame-types.js.map +1 -0
- package/dist/sheet/index.d.ts +26 -0
- package/dist/sheet/index.d.ts.map +1 -0
- package/dist/sheet/index.js +12 -0
- package/dist/sheet/index.js.map +1 -0
- package/dist/sheet/paper-sizes.d.ts +36 -0
- package/dist/sheet/paper-sizes.d.ts.map +1 -0
- package/dist/sheet/paper-sizes.js +252 -0
- package/dist/sheet/paper-sizes.js.map +1 -0
- package/dist/sheet/scale-bar-renderer.d.ts +29 -0
- package/dist/sheet/scale-bar-renderer.d.ts.map +1 -0
- package/dist/sheet/scale-bar-renderer.js +287 -0
- package/dist/sheet/scale-bar-renderer.js.map +1 -0
- package/dist/sheet/scale-bar-types.d.ts +82 -0
- package/dist/sheet/scale-bar-types.d.ts.map +1 -0
- package/dist/sheet/scale-bar-types.js +66 -0
- package/dist/sheet/scale-bar-types.js.map +1 -0
- package/dist/sheet/sheet-types.d.ts +84 -0
- package/dist/sheet/sheet-types.d.ts.map +1 -0
- package/dist/sheet/sheet-types.js +77 -0
- package/dist/sheet/sheet-types.js.map +1 -0
- package/dist/sheet/title-block-renderer.d.ts +44 -0
- package/dist/sheet/title-block-renderer.d.ts.map +1 -0
- package/dist/sheet/title-block-renderer.js +335 -0
- package/dist/sheet/title-block-renderer.js.map +1 -0
- package/dist/sheet/title-block-types.d.ts +100 -0
- package/dist/sheet/title-block-types.d.ts.map +1 -0
- package/dist/sheet/title-block-types.js +174 -0
- package/dist/sheet/title-block-types.js.map +1 -0
- package/dist/styles.d.ts +77 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +347 -0
- package/dist/styles.js.map +1 -0
- package/dist/styling/index.d.ts +7 -0
- package/dist/styling/index.d.ts.map +1 -0
- package/dist/styling/index.js +10 -0
- package/dist/styling/index.js.map +1 -0
- package/dist/styling/layer-mapping.d.ts +57 -0
- package/dist/styling/layer-mapping.d.ts.map +1 -0
- package/dist/styling/layer-mapping.js +303 -0
- package/dist/styling/layer-mapping.js.map +1 -0
- package/dist/styling/line-styles.d.ts +49 -0
- package/dist/styling/line-styles.d.ts.map +1 -0
- package/dist/styling/line-styles.js +123 -0
- package/dist/styling/line-styles.js.map +1 -0
- package/dist/styling/line-weights.d.ts +61 -0
- package/dist/styling/line-weights.d.ts.map +1 -0
- package/dist/styling/line-weights.js +183 -0
- package/dist/styling/line-weights.js.map +1 -0
- package/dist/svg-exporter.d.ts +63 -0
- package/dist/svg-exporter.d.ts.map +1 -0
- package/dist/svg-exporter.js +278 -0
- package/dist/svg-exporter.js.map +1 -0
- package/dist/symbols/door-symbol.d.ts +82 -0
- package/dist/symbols/door-symbol.d.ts.map +1 -0
- package/dist/symbols/door-symbol.js +390 -0
- package/dist/symbols/door-symbol.js.map +1 -0
- package/dist/symbols/index.d.ts +8 -0
- package/dist/symbols/index.d.ts.map +1 -0
- package/dist/symbols/index.js +11 -0
- package/dist/symbols/index.js.map +1 -0
- package/dist/symbols/symbol-renderer.d.ts +29 -0
- package/dist/symbols/symbol-renderer.d.ts.map +1 -0
- package/dist/symbols/symbol-renderer.js +173 -0
- package/dist/symbols/symbol-renderer.js.map +1 -0
- package/dist/symbols/symbol-utils.d.ts +48 -0
- package/dist/symbols/symbol-utils.d.ts.map +1 -0
- package/dist/symbols/symbol-utils.js +129 -0
- package/dist/symbols/symbol-utils.js.map +1 -0
- package/dist/symbols/window-symbol.d.ts +57 -0
- package/dist/symbols/window-symbol.d.ts.map +1 -0
- package/dist/symbols/window-symbol.js +209 -0
- package/dist/symbols/window-symbol.js.map +1 -0
- package/dist/types.d.ts +443 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +31 -0
- package/dist/types.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
import { getAxisNormal, getProjectionAxes } from './math';
|
|
5
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
6
|
+
// SHADER CODE
|
|
7
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
8
|
+
const SECTION_CUT_SHADER = /* wgsl */ `
|
|
9
|
+
struct Triangle {
|
|
10
|
+
v0: vec3<f32>,
|
|
11
|
+
v1: vec3<f32>,
|
|
12
|
+
v2: vec3<f32>,
|
|
13
|
+
entityId: u32,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
struct Plane {
|
|
17
|
+
normal: vec3<f32>,
|
|
18
|
+
distance: f32,
|
|
19
|
+
// Projection axes for 2D output
|
|
20
|
+
axisU: u32, // 0=x, 1=y, 2=z
|
|
21
|
+
axisV: u32,
|
|
22
|
+
flipU: f32, // 1.0 or -1.0
|
|
23
|
+
_padding: f32,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
struct Segment {
|
|
27
|
+
p0_3d: vec3<f32>,
|
|
28
|
+
_pad0: f32,
|
|
29
|
+
p1_3d: vec3<f32>,
|
|
30
|
+
_pad1: f32,
|
|
31
|
+
p0_2d: vec2<f32>,
|
|
32
|
+
p1_2d: vec2<f32>,
|
|
33
|
+
entityId: u32,
|
|
34
|
+
valid: u32,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@group(0) @binding(0) var<storage, read> triangles: array<Triangle>;
|
|
38
|
+
@group(0) @binding(1) var<uniform> plane: Plane;
|
|
39
|
+
@group(0) @binding(2) var<storage, read_write> segments: array<Segment>;
|
|
40
|
+
@group(0) @binding(3) var<storage, read_write> segmentCount: atomic<u32>;
|
|
41
|
+
|
|
42
|
+
const EPSILON: f32 = 1e-7;
|
|
43
|
+
|
|
44
|
+
fn signedDistance(point: vec3<f32>) -> f32 {
|
|
45
|
+
return dot(point, plane.normal) - plane.distance;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
fn edgeIntersection(v0: vec3<f32>, v1: vec3<f32>, d0: f32, d1: f32) -> vec3<f32> {
|
|
49
|
+
let t = d0 / (d0 - d1);
|
|
50
|
+
return mix(v0, v1, t);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
fn projectTo2D(p: vec3<f32>) -> vec2<f32> {
|
|
54
|
+
var coords: array<f32, 3>;
|
|
55
|
+
coords[0] = p.x;
|
|
56
|
+
coords[1] = p.y;
|
|
57
|
+
coords[2] = p.z;
|
|
58
|
+
|
|
59
|
+
let u = coords[plane.axisU] * plane.flipU;
|
|
60
|
+
let v = coords[plane.axisV];
|
|
61
|
+
return vec2<f32>(u, v);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@compute @workgroup_size(64)
|
|
65
|
+
fn main(@builtin(global_invocation_id) id: vec3<u32>) {
|
|
66
|
+
let triIdx = id.x;
|
|
67
|
+
if (triIdx >= arrayLength(&triangles)) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let tri = triangles[triIdx];
|
|
72
|
+
|
|
73
|
+
// Signed distances from plane
|
|
74
|
+
let d0 = signedDistance(tri.v0);
|
|
75
|
+
let d1 = signedDistance(tri.v1);
|
|
76
|
+
let d2 = signedDistance(tri.v2);
|
|
77
|
+
|
|
78
|
+
// Check for intersection
|
|
79
|
+
let pos = u32(d0 > EPSILON) + u32(d1 > EPSILON) + u32(d2 > EPSILON);
|
|
80
|
+
let neg = u32(d0 < -EPSILON) + u32(d1 < -EPSILON) + u32(d2 < -EPSILON);
|
|
81
|
+
|
|
82
|
+
// No intersection if all on same side
|
|
83
|
+
if (pos == 3u || neg == 3u || (pos == 0u && neg == 0u)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Find intersection points
|
|
88
|
+
var points: array<vec3<f32>, 2>;
|
|
89
|
+
var count: u32 = 0u;
|
|
90
|
+
|
|
91
|
+
// Edge v0-v1
|
|
92
|
+
if ((d0 > EPSILON) != (d1 > EPSILON)) {
|
|
93
|
+
points[count] = edgeIntersection(tri.v0, tri.v1, d0, d1);
|
|
94
|
+
count = count + 1u;
|
|
95
|
+
} else if (abs(d0) < EPSILON) {
|
|
96
|
+
points[count] = tri.v0;
|
|
97
|
+
count = count + 1u;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Edge v1-v2
|
|
101
|
+
if ((d1 > EPSILON) != (d2 > EPSILON)) {
|
|
102
|
+
points[count] = edgeIntersection(tri.v1, tri.v2, d1, d2);
|
|
103
|
+
count = count + 1u;
|
|
104
|
+
} else if (abs(d1) < EPSILON && count < 2u) {
|
|
105
|
+
points[count] = tri.v1;
|
|
106
|
+
count = count + 1u;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Edge v2-v0
|
|
110
|
+
if (count < 2u) {
|
|
111
|
+
if ((d2 > EPSILON) != (d0 > EPSILON)) {
|
|
112
|
+
points[count] = edgeIntersection(tri.v2, tri.v0, d2, d0);
|
|
113
|
+
count = count + 1u;
|
|
114
|
+
} else if (abs(d2) < EPSILON && count < 2u) {
|
|
115
|
+
points[count] = tri.v2;
|
|
116
|
+
count = count + 1u;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (count >= 2u) {
|
|
121
|
+
// Project to 2D
|
|
122
|
+
let p0_2d = projectTo2D(points[0]);
|
|
123
|
+
let p1_2d = projectTo2D(points[1]);
|
|
124
|
+
|
|
125
|
+
// Skip degenerate segments
|
|
126
|
+
let diff = p1_2d - p0_2d;
|
|
127
|
+
if (dot(diff, diff) < EPSILON * EPSILON) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Atomically allocate output slot
|
|
132
|
+
let outIdx = atomicAdd(&segmentCount, 1u);
|
|
133
|
+
|
|
134
|
+
segments[outIdx].p0_3d = points[0];
|
|
135
|
+
segments[outIdx].p1_3d = points[1];
|
|
136
|
+
segments[outIdx].p0_2d = p0_2d;
|
|
137
|
+
segments[outIdx].p1_2d = p1_2d;
|
|
138
|
+
segments[outIdx].entityId = tri.entityId;
|
|
139
|
+
segments[outIdx].valid = 1u;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
`;
|
|
143
|
+
export class GPUSectionCutter {
|
|
144
|
+
device;
|
|
145
|
+
resources = null;
|
|
146
|
+
constructor(device) {
|
|
147
|
+
this.device = device;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Initialize GPU resources for a given maximum triangle count
|
|
151
|
+
*/
|
|
152
|
+
async initialize(maxTriangles) {
|
|
153
|
+
const maxSegments = maxTriangles; // At most one segment per triangle
|
|
154
|
+
// Create shader module
|
|
155
|
+
const shaderModule = this.device.createShaderModule({
|
|
156
|
+
code: SECTION_CUT_SHADER,
|
|
157
|
+
});
|
|
158
|
+
// Create compute pipeline
|
|
159
|
+
const pipeline = this.device.createComputePipeline({
|
|
160
|
+
layout: 'auto',
|
|
161
|
+
compute: {
|
|
162
|
+
module: shaderModule,
|
|
163
|
+
entryPoint: 'main',
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
// Triangle buffer (input)
|
|
167
|
+
// Each triangle: 3 vec3 (36 bytes) + entityId (4 bytes) = 40 bytes, padded to 48
|
|
168
|
+
const triangleBufferSize = maxTriangles * 48;
|
|
169
|
+
const triangleBuffer = this.device.createBuffer({
|
|
170
|
+
size: triangleBufferSize,
|
|
171
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
|
|
172
|
+
});
|
|
173
|
+
// Plane uniform buffer
|
|
174
|
+
const planeBuffer = this.device.createBuffer({
|
|
175
|
+
size: 32, // 4 floats normal + 1 distance + 2 axes + 1 flip + 1 padding = 8 floats
|
|
176
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
177
|
+
});
|
|
178
|
+
// Segment buffer (output)
|
|
179
|
+
// Each segment: 2 vec3 + 2 vec2 + 2 u32 = 64 bytes
|
|
180
|
+
const segmentBufferSize = maxSegments * 64;
|
|
181
|
+
const segmentBuffer = this.device.createBuffer({
|
|
182
|
+
size: segmentBufferSize,
|
|
183
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC,
|
|
184
|
+
});
|
|
185
|
+
// Atomic counter buffer
|
|
186
|
+
const countBuffer = this.device.createBuffer({
|
|
187
|
+
size: 4,
|
|
188
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC,
|
|
189
|
+
});
|
|
190
|
+
// Readback buffers
|
|
191
|
+
const readbackBuffer = this.device.createBuffer({
|
|
192
|
+
size: segmentBufferSize,
|
|
193
|
+
usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST,
|
|
194
|
+
});
|
|
195
|
+
const countReadbackBuffer = this.device.createBuffer({
|
|
196
|
+
size: 4,
|
|
197
|
+
usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST,
|
|
198
|
+
});
|
|
199
|
+
// Create bind group
|
|
200
|
+
const bindGroup = this.device.createBindGroup({
|
|
201
|
+
layout: pipeline.getBindGroupLayout(0),
|
|
202
|
+
entries: [
|
|
203
|
+
{ binding: 0, resource: { buffer: triangleBuffer } },
|
|
204
|
+
{ binding: 1, resource: { buffer: planeBuffer } },
|
|
205
|
+
{ binding: 2, resource: { buffer: segmentBuffer } },
|
|
206
|
+
{ binding: 3, resource: { buffer: countBuffer } },
|
|
207
|
+
],
|
|
208
|
+
});
|
|
209
|
+
this.resources = {
|
|
210
|
+
pipeline,
|
|
211
|
+
triangleBuffer,
|
|
212
|
+
planeBuffer,
|
|
213
|
+
segmentBuffer,
|
|
214
|
+
countBuffer,
|
|
215
|
+
readbackBuffer,
|
|
216
|
+
countReadbackBuffer,
|
|
217
|
+
bindGroup,
|
|
218
|
+
maxTriangles,
|
|
219
|
+
maxSegments,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Cut meshes using GPU compute shader
|
|
224
|
+
*/
|
|
225
|
+
async cutMeshes(meshes, config) {
|
|
226
|
+
if (!this.resources) {
|
|
227
|
+
throw new Error('GPU resources not initialized. Call initialize() first.');
|
|
228
|
+
}
|
|
229
|
+
// Collect all triangles with entity info
|
|
230
|
+
const triangleData = this.collectTriangles(meshes);
|
|
231
|
+
const triangleCount = triangleData.count;
|
|
232
|
+
if (triangleCount === 0) {
|
|
233
|
+
return [];
|
|
234
|
+
}
|
|
235
|
+
// Ensure we have enough buffer space
|
|
236
|
+
if (triangleCount > this.resources.maxTriangles) {
|
|
237
|
+
await this.initialize(triangleCount * 2);
|
|
238
|
+
}
|
|
239
|
+
// Capture resources reference after potential reinitialization to avoid race conditions
|
|
240
|
+
const resources = this.resources;
|
|
241
|
+
if (!resources) {
|
|
242
|
+
throw new Error('GPU resources became unavailable after initialization');
|
|
243
|
+
}
|
|
244
|
+
// Upload triangle data
|
|
245
|
+
this.device.queue.writeBuffer(resources.triangleBuffer, 0, triangleData.buffer.buffer, triangleData.buffer.byteOffset, triangleData.buffer.byteLength);
|
|
246
|
+
// Upload plane data
|
|
247
|
+
const planeData = this.createPlaneData(config);
|
|
248
|
+
this.device.queue.writeBuffer(resources.planeBuffer, 0, planeData.buffer, planeData.byteOffset, planeData.byteLength);
|
|
249
|
+
// Reset counter
|
|
250
|
+
this.device.queue.writeBuffer(resources.countBuffer, 0, new Uint32Array([0]));
|
|
251
|
+
// Dispatch compute shader
|
|
252
|
+
const encoder = this.device.createCommandEncoder();
|
|
253
|
+
const pass = encoder.beginComputePass();
|
|
254
|
+
pass.setPipeline(resources.pipeline);
|
|
255
|
+
pass.setBindGroup(0, resources.bindGroup);
|
|
256
|
+
const workgroupCount = Math.ceil(triangleCount / 64);
|
|
257
|
+
pass.dispatchWorkgroups(workgroupCount);
|
|
258
|
+
pass.end();
|
|
259
|
+
// Copy results to readback buffers
|
|
260
|
+
encoder.copyBufferToBuffer(resources.countBuffer, 0, resources.countReadbackBuffer, 0, 4);
|
|
261
|
+
this.device.queue.submit([encoder.finish()]);
|
|
262
|
+
// Read back count first
|
|
263
|
+
await resources.countReadbackBuffer.mapAsync(GPUMapMode.READ);
|
|
264
|
+
const countData = new Uint32Array(resources.countReadbackBuffer.getMappedRange());
|
|
265
|
+
const segmentCount = countData[0];
|
|
266
|
+
resources.countReadbackBuffer.unmap();
|
|
267
|
+
if (segmentCount === 0) {
|
|
268
|
+
return [];
|
|
269
|
+
}
|
|
270
|
+
// Copy and read back segments
|
|
271
|
+
const encoder2 = this.device.createCommandEncoder();
|
|
272
|
+
encoder2.copyBufferToBuffer(resources.segmentBuffer, 0, resources.readbackBuffer, 0, segmentCount * 64);
|
|
273
|
+
this.device.queue.submit([encoder2.finish()]);
|
|
274
|
+
await resources.readbackBuffer.mapAsync(GPUMapMode.READ);
|
|
275
|
+
const segmentData = new Float32Array(resources.readbackBuffer.getMappedRange(0, segmentCount * 64));
|
|
276
|
+
// Parse segments
|
|
277
|
+
const segments = this.parseSegments(segmentData, segmentCount, triangleData.entityMap);
|
|
278
|
+
resources.readbackBuffer.unmap();
|
|
279
|
+
return segments;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Collect triangles from meshes into a flat buffer
|
|
283
|
+
*/
|
|
284
|
+
collectTriangles(meshes) {
|
|
285
|
+
// Count total triangles
|
|
286
|
+
let totalTriangles = 0;
|
|
287
|
+
for (const mesh of meshes) {
|
|
288
|
+
totalTriangles += mesh.indices.length / 3;
|
|
289
|
+
}
|
|
290
|
+
// 12 floats per triangle (3 vertices * 3 coords + 3 padding for alignment)
|
|
291
|
+
const buffer = new Float32Array(totalTriangles * 12);
|
|
292
|
+
const entityMap = new Map();
|
|
293
|
+
let triIdx = 0;
|
|
294
|
+
let entityCounter = 0;
|
|
295
|
+
for (const mesh of meshes) {
|
|
296
|
+
const { positions, indices, expressId, ifcType, modelIndex } = mesh;
|
|
297
|
+
const triangleCount = indices.length / 3;
|
|
298
|
+
// Map entity counter to mesh info
|
|
299
|
+
entityMap.set(entityCounter, {
|
|
300
|
+
entityId: expressId,
|
|
301
|
+
ifcType: ifcType || 'Unknown',
|
|
302
|
+
modelIndex: modelIndex || 0,
|
|
303
|
+
});
|
|
304
|
+
for (let t = 0; t < triangleCount; t++) {
|
|
305
|
+
const i0 = indices[t * 3];
|
|
306
|
+
const i1 = indices[t * 3 + 1];
|
|
307
|
+
const i2 = indices[t * 3 + 2];
|
|
308
|
+
const base = triIdx * 12;
|
|
309
|
+
// v0
|
|
310
|
+
buffer[base + 0] = positions[i0 * 3];
|
|
311
|
+
buffer[base + 1] = positions[i0 * 3 + 1];
|
|
312
|
+
buffer[base + 2] = positions[i0 * 3 + 2];
|
|
313
|
+
// v1
|
|
314
|
+
buffer[base + 3] = positions[i1 * 3];
|
|
315
|
+
buffer[base + 4] = positions[i1 * 3 + 1];
|
|
316
|
+
buffer[base + 5] = positions[i1 * 3 + 2];
|
|
317
|
+
// v2
|
|
318
|
+
buffer[base + 6] = positions[i2 * 3];
|
|
319
|
+
buffer[base + 7] = positions[i2 * 3 + 1];
|
|
320
|
+
buffer[base + 8] = positions[i2 * 3 + 2];
|
|
321
|
+
// entityId (as float, will be reinterpreted)
|
|
322
|
+
const entityView = new DataView(buffer.buffer, (base + 9) * 4, 4);
|
|
323
|
+
entityView.setUint32(0, entityCounter, true);
|
|
324
|
+
// Padding
|
|
325
|
+
buffer[base + 10] = 0;
|
|
326
|
+
buffer[base + 11] = 0;
|
|
327
|
+
triIdx++;
|
|
328
|
+
}
|
|
329
|
+
entityCounter++;
|
|
330
|
+
}
|
|
331
|
+
return { buffer, count: totalTriangles, entityMap };
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Create plane uniform data
|
|
335
|
+
*/
|
|
336
|
+
createPlaneData(config) {
|
|
337
|
+
const normal = getAxisNormal(config.axis, config.flipped);
|
|
338
|
+
const axes = getProjectionAxes(config.axis);
|
|
339
|
+
const axisToIndex = { x: 0, y: 1, z: 2 };
|
|
340
|
+
const data = new Float32Array(8);
|
|
341
|
+
data[0] = normal.x;
|
|
342
|
+
data[1] = normal.y;
|
|
343
|
+
data[2] = normal.z;
|
|
344
|
+
data[3] = config.position;
|
|
345
|
+
// Store axis indices as float (will be cast to u32 in shader)
|
|
346
|
+
const view = new DataView(data.buffer);
|
|
347
|
+
view.setUint32(16, axisToIndex[axes.u], true); // axisU
|
|
348
|
+
view.setUint32(20, axisToIndex[axes.v], true); // axisV
|
|
349
|
+
data[6] = config.flipped ? -1.0 : 1.0; // flipU
|
|
350
|
+
data[7] = 0; // padding
|
|
351
|
+
return data;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Parse GPU output into CutSegment array
|
|
355
|
+
*/
|
|
356
|
+
parseSegments(data, count, entityMap) {
|
|
357
|
+
const segments = [];
|
|
358
|
+
for (let i = 0; i < count; i++) {
|
|
359
|
+
const base = i * 16; // 64 bytes = 16 floats
|
|
360
|
+
const valid = new DataView(data.buffer, (base + 14) * 4, 4).getUint32(0, true);
|
|
361
|
+
if (valid !== 1)
|
|
362
|
+
continue;
|
|
363
|
+
const entityIdx = new DataView(data.buffer, (base + 13) * 4, 4).getUint32(0, true);
|
|
364
|
+
const entityInfo = entityMap.get(entityIdx) || {
|
|
365
|
+
entityId: 0,
|
|
366
|
+
ifcType: 'Unknown',
|
|
367
|
+
modelIndex: 0,
|
|
368
|
+
};
|
|
369
|
+
segments.push({
|
|
370
|
+
p0: { x: data[base + 0], y: data[base + 1], z: data[base + 2] },
|
|
371
|
+
p1: { x: data[base + 4], y: data[base + 5], z: data[base + 6] },
|
|
372
|
+
p0_2d: { x: data[base + 8], y: data[base + 9] },
|
|
373
|
+
p1_2d: { x: data[base + 10], y: data[base + 11] },
|
|
374
|
+
entityId: entityInfo.entityId,
|
|
375
|
+
ifcType: entityInfo.ifcType,
|
|
376
|
+
modelIndex: entityInfo.modelIndex,
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
return segments;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Release GPU resources
|
|
383
|
+
*/
|
|
384
|
+
destroy() {
|
|
385
|
+
if (this.resources) {
|
|
386
|
+
this.resources.triangleBuffer.destroy();
|
|
387
|
+
this.resources.planeBuffer.destroy();
|
|
388
|
+
this.resources.segmentBuffer.destroy();
|
|
389
|
+
this.resources.countBuffer.destroy();
|
|
390
|
+
this.resources.readbackBuffer.destroy();
|
|
391
|
+
this.resources.countReadbackBuffer.destroy();
|
|
392
|
+
this.resources = null;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
397
|
+
// GPU AVAILABILITY CHECK
|
|
398
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
399
|
+
/**
|
|
400
|
+
* Check if WebGPU compute shaders are available
|
|
401
|
+
*/
|
|
402
|
+
export function isGPUComputeAvailable() {
|
|
403
|
+
return typeof navigator !== 'undefined' && 'gpu' in navigator;
|
|
404
|
+
}
|
|
405
|
+
//# sourceMappingURL=gpu-section-cutter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpu-section-cutter.js","sourceRoot":"","sources":["../src/gpu-section-cutter.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAW/D,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAE1D,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E,MAAM,kBAAkB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsIrC,CAAC;AAmBF,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAY;IAClB,SAAS,GAAwB,IAAI,CAAC;IAE9C,YAAY,MAAiB;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,YAAoB;QACnC,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,mCAAmC;QAErE,uBAAuB;QACvB,MAAM,YAAY,GAAG,IA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ACrC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;YACxC,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;YAC7C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,CAAC;IACH,CAAC;CACF;AAED,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E;AAE9E;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,OAAO,SAAS,KAAK,WAAW,IAAI,KAAK,IAAI,SAAS,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graphic Overrides Module
|
|
3
|
+
*
|
|
4
|
+
* Provides parametric styling for 2D architectural drawings based on
|
|
5
|
+
* element properties, IFC types, and user-defined criteria.
|
|
6
|
+
*/
|
|
7
|
+
export type { LineWeightPreset, LineStylePreset, DashPattern, CriteriaOperator, CriteriaType, OverrideCriterion, OverrideCriteria, GraphicStyle, GraphicOverrideRule, GraphicOverridePreset, ElementData, ResolvedGraphicStyle, OverrideResult, } from './types';
|
|
8
|
+
export { GraphicOverrideEngine, createOverrideEngine, ifcTypeCriterion, propertyCriterion, andCriteria, orCriteria, } from './rule-engine';
|
|
9
|
+
export { BUILT_IN_PRESETS, VIEW_3D_PRESET, ARCHITECTURAL_PRESET, FIRE_SAFETY_PRESET, STRUCTURAL_PRESET, MEP_PRESET, MONOCHROME_PRESET, getBuiltInPreset, getPresetsByCategory, } from './presets';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/graphic-overrides/index.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AAGH,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,EACX,oBAAoB,EACpB,cAAc,GACf,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,UAAU,GACX,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
// Rule Engine
|
|
5
|
+
export { GraphicOverrideEngine, createOverrideEngine, ifcTypeCriterion, propertyCriterion, andCriteria, orCriteria, } from './rule-engine';
|
|
6
|
+
// Presets
|
|
7
|
+
export { BUILT_IN_PRESETS, VIEW_3D_PRESET, ARCHITECTURAL_PRESET, FIRE_SAFETY_PRESET, STRUCTURAL_PRESET, MEP_PRESET, MONOCHROME_PRESET, getBuiltInPreset, getPresetsByCategory, } from './presets';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/graphic-overrides/index.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AA0B/D,cAAc;AACd,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,UAAU,GACX,MAAM,eAAe,CAAC;AAEvB,UAAU;AACV,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in Graphic Override Presets
|
|
3
|
+
*
|
|
4
|
+
* Pre-configured override rule sets for common use cases.
|
|
5
|
+
*/
|
|
6
|
+
import type { GraphicOverridePreset } from './types';
|
|
7
|
+
export declare const ARCHITECTURAL_PRESET: GraphicOverridePreset;
|
|
8
|
+
export declare const FIRE_SAFETY_PRESET: GraphicOverridePreset;
|
|
9
|
+
export declare const STRUCTURAL_PRESET: GraphicOverridePreset;
|
|
10
|
+
export declare const MEP_PRESET: GraphicOverridePreset;
|
|
11
|
+
export declare const VIEW_3D_PRESET: GraphicOverridePreset;
|
|
12
|
+
export declare const MONOCHROME_PRESET: GraphicOverridePreset;
|
|
13
|
+
export declare const BUILT_IN_PRESETS: GraphicOverridePreset[];
|
|
14
|
+
/**
|
|
15
|
+
* Get a built-in preset by ID
|
|
16
|
+
*/
|
|
17
|
+
export declare function getBuiltInPreset(id: string): GraphicOverridePreset | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Get all built-in presets for a category
|
|
20
|
+
*/
|
|
21
|
+
export declare function getPresetsByCategory(category: string): GraphicOverridePreset[];
|
|
22
|
+
//# sourceMappingURL=presets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/graphic-overrides/presets.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAuB,MAAM,SAAS,CAAC;AA2G1E,eAAO,MAAM,oBAAoB,EAAE,qBAQlC,CAAC;AAmFF,eAAO,MAAM,kBAAkB,EAAE,qBAQhC,CAAC;AA+EF,eAAO,MAAM,iBAAiB,EAAE,qBAQ/B,CAAC;AAkFF,eAAO,MAAM,UAAU,EAAE,qBAQxB,CAAC;AAMF,eAAO,MAAM,cAAc,EAAE,qBAQ5B,CAAC;AA2BF,eAAO,MAAM,iBAAiB,EAAE,qBAQ/B,CAAC;AAMF,eAAO,MAAM,gBAAgB,EAAE,qBAAqB,EAOnD,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS,CAE9E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,EAAE,CAE9E"}
|