@kruschdev/pascal-mep-kernel 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +29 -2
- package/dist/anatomy/footprint.d.ts +164 -0
- package/dist/anatomy/index.d.ts +31 -0
- package/dist/anatomy/index.js +121 -0
- package/dist/anatomy/levels.d.ts +121 -0
- package/dist/anatomy/occupancy.d.ts +194 -0
- package/dist/anatomy/openings.d.ts +125 -0
- package/dist/anatomy/roof.d.ts +102 -0
- package/dist/chunk-0w98adg9.js +2486 -0
- package/dist/chunk-2e23cyn0.js +3567 -0
- package/dist/chunk-jfzqztgh.js +260 -0
- package/dist/chunk-sab5aaa6.js +615 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +186 -0
- package/dist/router/cavity-graph.d.ts +37 -0
- package/dist/router/index.d.ts +11 -0
- package/dist/router/index.js +12 -0
- package/dist/router/shortest-path.d.ts +37 -0
- package/dist/router/types.d.ts +108 -0
- package/dist/rules/evaluator.d.ts +60 -0
- package/dist/rules/index.d.ts +10 -0
- package/dist/rules/index.js +15 -0
- package/dist/rules/schema.d.ts +227 -0
- package/dist/types.d.ts +137 -0
- package/dist/types.js +48 -0
- package/package.json +73 -4
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// src/types.ts
|
|
2
|
+
var TRADE_PRIORITY_RANK2 = {
|
|
3
|
+
structural: 1,
|
|
4
|
+
plumbing: 2,
|
|
5
|
+
hvac: 3,
|
|
6
|
+
electrical: 4
|
|
7
|
+
};
|
|
8
|
+
var INCHES_TO_METERS2 = 0.0254;
|
|
9
|
+
var METERS_TO_FEET2 = 3.280839895013123;
|
|
10
|
+
var FEET_TO_METERS2 = 0.3048;
|
|
11
|
+
var SQM_TO_SQFT2 = 10.763910416709722;
|
|
12
|
+
function isVec32(v) {
|
|
13
|
+
return Array.isArray(v) && v.length >= 3 && typeof v[0] === "number" && Number.isFinite(v[0]) && typeof v[1] === "number" && Number.isFinite(v[1]) && typeof v[2] === "number" && Number.isFinite(v[2]);
|
|
14
|
+
}
|
|
15
|
+
function toTupleAabb32(box) {
|
|
16
|
+
return {
|
|
17
|
+
min: [box.minX, box.minY, box.minZ],
|
|
18
|
+
max: [box.maxX, box.maxY, box.maxZ]
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function fromTupleAabb32(box) {
|
|
22
|
+
return {
|
|
23
|
+
minX: box.min[0],
|
|
24
|
+
minY: box.min[1],
|
|
25
|
+
minZ: box.min[2],
|
|
26
|
+
maxX: box.max[0],
|
|
27
|
+
maxY: box.max[1],
|
|
28
|
+
maxZ: box.max[2]
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function expandAabb32(box, margin) {
|
|
32
|
+
const [mx, my, mz] = typeof margin === "number" ? [margin, margin, margin] : margin;
|
|
33
|
+
return {
|
|
34
|
+
minX: box.minX - mx,
|
|
35
|
+
minY: box.minY - my,
|
|
36
|
+
minZ: box.minZ - mz,
|
|
37
|
+
maxX: box.maxX + mx,
|
|
38
|
+
maxY: box.maxY + my,
|
|
39
|
+
maxZ: box.maxZ + mz
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function aabb3Intersects2(a, b) {
|
|
43
|
+
return a.minX <= b.maxX && a.maxX >= b.minX && a.minY <= b.maxY && a.maxY >= b.minY && a.minZ <= b.maxZ && a.maxZ >= b.minZ;
|
|
44
|
+
}
|
|
45
|
+
function segmentIntersectsAabb32(a, b, box, margin = 0, eps = 0.000001) {
|
|
46
|
+
const [mx, my, mz] = typeof margin === "number" ? [margin, margin, margin] : margin;
|
|
47
|
+
const minX = box.minX - mx;
|
|
48
|
+
const maxX = box.maxX + mx;
|
|
49
|
+
const minY = box.minY - my;
|
|
50
|
+
const maxY = box.maxY + my;
|
|
51
|
+
const minZ = box.minZ - mz;
|
|
52
|
+
const maxZ = box.maxZ + mz;
|
|
53
|
+
let tMin = 0;
|
|
54
|
+
let tMax = 1;
|
|
55
|
+
const axes = [
|
|
56
|
+
[a[0], b[0] - a[0], minX, maxX],
|
|
57
|
+
[a[1], b[1] - a[1], minY, maxY],
|
|
58
|
+
[a[2], b[2] - a[2], minZ, maxZ]
|
|
59
|
+
];
|
|
60
|
+
for (const [orig, dir, bMin, bMax] of axes) {
|
|
61
|
+
if (Math.abs(dir) < 0.000000001) {
|
|
62
|
+
if (orig < bMin - eps || orig > bMax + eps)
|
|
63
|
+
return false;
|
|
64
|
+
} else {
|
|
65
|
+
let t1 = (bMin - orig) / dir;
|
|
66
|
+
let t2 = (bMax - orig) / dir;
|
|
67
|
+
if (t1 > t2) {
|
|
68
|
+
const tmp = t1;
|
|
69
|
+
t1 = t2;
|
|
70
|
+
t2 = tmp;
|
|
71
|
+
}
|
|
72
|
+
tMin = Math.max(tMin, t1);
|
|
73
|
+
tMax = Math.min(tMax, t2);
|
|
74
|
+
if (tMin > tMax + eps)
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return tMax >= -eps && tMin <= 1 + eps;
|
|
79
|
+
}
|
|
80
|
+
function createOrientedPrismY2(params) {
|
|
81
|
+
const { centerX, centerZ, cos, sin, lxMin, lxMax, lzMin, lzMax, yMin, yMax } = params;
|
|
82
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
83
|
+
let maxX = Number.NEGATIVE_INFINITY;
|
|
84
|
+
let minZ = Number.POSITIVE_INFINITY;
|
|
85
|
+
let maxZ = Number.NEGATIVE_INFINITY;
|
|
86
|
+
for (const lx of [lxMin, lxMax]) {
|
|
87
|
+
for (const lz of [lzMin, lzMax]) {
|
|
88
|
+
const wx = centerX + lx * cos - lz * sin;
|
|
89
|
+
const wz = centerZ + lx * sin + lz * cos;
|
|
90
|
+
if (wx < minX)
|
|
91
|
+
minX = wx;
|
|
92
|
+
if (wx > maxX)
|
|
93
|
+
maxX = wx;
|
|
94
|
+
if (wz < minZ)
|
|
95
|
+
minZ = wz;
|
|
96
|
+
if (wz > maxZ)
|
|
97
|
+
maxZ = wz;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
centerX,
|
|
102
|
+
centerZ,
|
|
103
|
+
cos,
|
|
104
|
+
sin,
|
|
105
|
+
lxMin,
|
|
106
|
+
lxMax,
|
|
107
|
+
lzMin,
|
|
108
|
+
lzMax,
|
|
109
|
+
yMin,
|
|
110
|
+
yMax,
|
|
111
|
+
aabb: { minX, minY: yMin, minZ, maxX, maxY: yMax, maxZ }
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function segmentIntersectsOrientedPrismY2(a, b, prism, padM = 0, eps = 0.000001) {
|
|
115
|
+
const [px, py, pz] = typeof padM === "number" ? [padM, padM, padM] : padM;
|
|
116
|
+
const posPx = Math.max(0, px);
|
|
117
|
+
const posPz = Math.max(0, pz);
|
|
118
|
+
const absCos = Math.abs(prism.cos);
|
|
119
|
+
const absSin = Math.abs(prism.sin);
|
|
120
|
+
const worldPadX = posPx * absCos + posPz * absSin;
|
|
121
|
+
const worldPadZ = posPx * absSin + posPz * absCos;
|
|
122
|
+
if (!segmentIntersectsAabb32(a, b, prism.aabb, [worldPadX, Math.max(0, py), worldPadZ], eps)) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
const adx = a[0] - prism.centerX;
|
|
126
|
+
const adz = a[2] - prism.centerZ;
|
|
127
|
+
const bdx = b[0] - prism.centerX;
|
|
128
|
+
const bdz = b[2] - prism.centerZ;
|
|
129
|
+
const la = [adx * prism.cos + adz * prism.sin, a[1], -adx * prism.sin + adz * prism.cos];
|
|
130
|
+
const lb = [bdx * prism.cos + bdz * prism.sin, b[1], -bdx * prism.sin + bdz * prism.cos];
|
|
131
|
+
const localBox = {
|
|
132
|
+
minX: prism.lxMin,
|
|
133
|
+
maxX: prism.lxMax,
|
|
134
|
+
minY: prism.yMin,
|
|
135
|
+
maxY: prism.yMax,
|
|
136
|
+
minZ: prism.lzMin,
|
|
137
|
+
maxZ: prism.lzMax
|
|
138
|
+
};
|
|
139
|
+
return segmentIntersectsAabb32(la, lb, localBox, [px, py, pz], eps);
|
|
140
|
+
}
|
|
141
|
+
function orientedPrismIntersectsAabb32(prism, box) {
|
|
142
|
+
if (prism.yMax <= box.minY || prism.yMin >= box.maxY)
|
|
143
|
+
return false;
|
|
144
|
+
if (!aabb3Intersects2(prism.aabb, box))
|
|
145
|
+
return false;
|
|
146
|
+
const bCx = (box.minX + box.maxX) / 2;
|
|
147
|
+
const bCz = (box.minZ + box.maxZ) / 2;
|
|
148
|
+
const bHx = (box.maxX - box.minX) / 2;
|
|
149
|
+
const bHz = (box.maxZ - box.minZ) / 2;
|
|
150
|
+
const pLcX = (prism.lxMin + prism.lxMax) / 2;
|
|
151
|
+
const pLcZ = (prism.lzMin + prism.lzMax) / 2;
|
|
152
|
+
const pHx = (prism.lxMax - prism.lxMin) / 2;
|
|
153
|
+
const pHz = (prism.lzMax - prism.lzMin) / 2;
|
|
154
|
+
const pCx = prism.centerX + pLcX * prism.cos - pLcZ * prism.sin;
|
|
155
|
+
const pCz = prism.centerZ + pLcX * prism.sin + pLcZ * prism.cos;
|
|
156
|
+
const dx = bCx - pCx;
|
|
157
|
+
const dz = bCz - pCz;
|
|
158
|
+
const axes = [
|
|
159
|
+
[1, 0],
|
|
160
|
+
[0, 1],
|
|
161
|
+
[prism.cos, prism.sin],
|
|
162
|
+
[-prism.sin, prism.cos]
|
|
163
|
+
];
|
|
164
|
+
for (const [ax, az] of axes) {
|
|
165
|
+
const dist = Math.abs(dx * ax + dz * az);
|
|
166
|
+
const rBox = bHx * Math.abs(ax) + bHz * Math.abs(az);
|
|
167
|
+
const rPrism = pHx * Math.abs(prism.cos * ax + prism.sin * az) + pHz * Math.abs(-prism.sin * ax + prism.cos * az);
|
|
168
|
+
if (dist >= rBox + rPrism - 0.000001)
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
function extractNodeYawRad2(rotation) {
|
|
174
|
+
if (typeof rotation === "number" && Number.isFinite(rotation))
|
|
175
|
+
return rotation;
|
|
176
|
+
if (Array.isArray(rotation)) {
|
|
177
|
+
const y = rotation[1];
|
|
178
|
+
if (typeof y === "number" && Number.isFinite(y))
|
|
179
|
+
return y;
|
|
180
|
+
}
|
|
181
|
+
return 0;
|
|
182
|
+
}
|
|
183
|
+
function polylineLengthM2(path) {
|
|
184
|
+
let total = 0;
|
|
185
|
+
for (let i = 1;i < path.length; i++) {
|
|
186
|
+
const a = path[i - 1];
|
|
187
|
+
const b = path[i];
|
|
188
|
+
total += Math.hypot(b[0] - a[0], b[1] - a[1], b[2] - a[2]);
|
|
189
|
+
}
|
|
190
|
+
return total;
|
|
191
|
+
}
|
|
192
|
+
function polylineHorizontalLengthM2(path) {
|
|
193
|
+
let total = 0;
|
|
194
|
+
for (let i = 1;i < path.length; i++) {
|
|
195
|
+
const a = path[i - 1];
|
|
196
|
+
const b = path[i];
|
|
197
|
+
total += Math.hypot(b[0] - a[0], b[2] - a[2]);
|
|
198
|
+
}
|
|
199
|
+
return total;
|
|
200
|
+
}
|
|
201
|
+
function countPathBendDegrees2(path) {
|
|
202
|
+
let total = 0;
|
|
203
|
+
let prevDir = null;
|
|
204
|
+
for (let i = 1;i < path.length; i++) {
|
|
205
|
+
const a = path[i - 1];
|
|
206
|
+
const b = path[i];
|
|
207
|
+
const dx = b[0] - a[0];
|
|
208
|
+
const dy = b[1] - a[1];
|
|
209
|
+
const dz = b[2] - a[2];
|
|
210
|
+
const len = Math.hypot(dx, dy, dz);
|
|
211
|
+
if (len < 0.00001)
|
|
212
|
+
continue;
|
|
213
|
+
const dir = [dx / len, dy / len, dz / len];
|
|
214
|
+
if (prevDir) {
|
|
215
|
+
const dot = Math.max(-1, Math.min(1, prevDir[0] * dir[0] + prevDir[1] * dir[1] + prevDir[2] * dir[2]));
|
|
216
|
+
const deg = Math.acos(dot) * 180 / Math.PI;
|
|
217
|
+
if (deg > 2)
|
|
218
|
+
total += deg;
|
|
219
|
+
}
|
|
220
|
+
prevDir = dir;
|
|
221
|
+
}
|
|
222
|
+
return total;
|
|
223
|
+
}
|
|
224
|
+
function countPathElbows2(path) {
|
|
225
|
+
let elbows90 = 0;
|
|
226
|
+
let elbows45 = 0;
|
|
227
|
+
let prevDir = null;
|
|
228
|
+
for (let i = 1;i < path.length; i++) {
|
|
229
|
+
const a = path[i - 1];
|
|
230
|
+
const b = path[i];
|
|
231
|
+
const dx = b[0] - a[0];
|
|
232
|
+
const dy = b[1] - a[1];
|
|
233
|
+
const dz = b[2] - a[2];
|
|
234
|
+
const len = Math.hypot(dx, dy, dz);
|
|
235
|
+
if (len < 0.0001)
|
|
236
|
+
continue;
|
|
237
|
+
const dir = [dx / len, dy / len, dz / len];
|
|
238
|
+
if (prevDir) {
|
|
239
|
+
const dot = Math.max(-1, Math.min(1, prevDir[0] * dir[0] + prevDir[1] * dir[1] + prevDir[2] * dir[2]));
|
|
240
|
+
const deg = Math.acos(dot) * 180 / Math.PI;
|
|
241
|
+
if (deg >= 67.5)
|
|
242
|
+
elbows90++;
|
|
243
|
+
else if (deg >= 22.5)
|
|
244
|
+
elbows45++;
|
|
245
|
+
}
|
|
246
|
+
prevDir = dir;
|
|
247
|
+
}
|
|
248
|
+
return { elbows90, elbows45 };
|
|
249
|
+
}
|
|
250
|
+
function round22(n) {
|
|
251
|
+
return Math.round(n * 100) / 100;
|
|
252
|
+
}
|
|
253
|
+
function round32(n) {
|
|
254
|
+
return Math.round(n * 1000) / 1000;
|
|
255
|
+
}
|
|
256
|
+
function round42(n) {
|
|
257
|
+
return Math.round(n * 1e4) / 1e4;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export { TRADE_PRIORITY_RANK2, INCHES_TO_METERS2, METERS_TO_FEET2, FEET_TO_METERS2, SQM_TO_SQFT2, isVec32, toTupleAabb32, fromTupleAabb32, expandAabb32, aabb3Intersects2, segmentIntersectsAabb32, createOrientedPrismY2, segmentIntersectsOrientedPrismY2, orientedPrismIntersectsAabb32, extractNodeYawRad2, polylineLengthM2, polylineHorizontalLengthM2, countPathBendDegrees2, countPathElbows2, round22, round32, round42 };
|