@vulcan-energy/mcp-helper 0.2.4 → 0.2.5
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 +9 -0
- package/README.md +19 -14
- package/THIRD_PARTY_NOTICES.md +10 -1
- package/dist/bin/vulcan-mcp-helper.js +25 -37
- package/dist/hem-target-runtime/browser-adapter.mjs +36 -6
- package/dist/hem-target-runtime/csv-target.mjs +126 -0
- package/dist/hem-target-runtime/host.mjs +1215 -493
- package/dist/hem-target-runtime/python-worker.mjs +5 -3
- package/dist/hem-target-runtime/rust-worker.mjs +5 -3
- package/dist/server.js +23 -35
- package/package.json +1 -1
- package/wasm/THIRD_PARTY_RUST_CRATES.md +5693 -0
- package/wasm/wasm_version.json +9 -9
- package/wasm/wasm_wrapper.js +6 -6
- package/wasm/wasm_wrapper_bg.wasm +0 -0
|
@@ -9970,13 +9970,16 @@ var HEM_TARGETS = [
|
|
|
9970
9970
|
}
|
|
9971
9971
|
];
|
|
9972
9972
|
var RECOMMENDED_HEM_TARGET = HEM_TARGETS[0].id;
|
|
9973
|
+
var UNPINNED_CSV_TARGET = "rust-fhs-a7-62d3df70-c5ba2673-v1";
|
|
9973
9974
|
function resolveHemTarget(id) {
|
|
9974
9975
|
const target = HEM_TARGETS.find((target2) => target2.id === id);
|
|
9975
9976
|
if (!target) throw new Error(`HEM target '${id}' is unavailable. Select a supported target explicitly; saved runs are never upgraded automatically.`);
|
|
9976
9977
|
return target;
|
|
9977
9978
|
}
|
|
9978
9979
|
function modelArtifacts(manifest) {
|
|
9979
|
-
|
|
9980
|
+
const runtime = [manifest.runtime.javascript, manifest.runtime.wasm];
|
|
9981
|
+
const converter = [manifest.preparation.javascript, manifest.preparation.wasm].filter((path) => !runtime.includes(path));
|
|
9982
|
+
return manifest.artifacts.filter((artifact) => !artifact.path.startsWith("source/") && !artifact.path.startsWith("notices/") && !converter.includes(artifact.path));
|
|
9980
9983
|
}
|
|
9981
9984
|
function validateTargetManifest(manifest, target) {
|
|
9982
9985
|
if (manifest.bundleId !== target.id || manifest.protocol !== 1 || manifest.engineCommit !== target.engineCommit || manifest.wrapperCommit !== target.wrapperCommit || manifest.conversionProfile !== target.conversionProfile) {
|
|
@@ -9994,7 +9997,7 @@ function validateTargetManifest(manifest, target) {
|
|
|
9994
9997
|
sizesByHash.set(artifact.sha256, artifact.bytes);
|
|
9995
9998
|
paths.add(artifact.path);
|
|
9996
9999
|
}
|
|
9997
|
-
for (const path of [
|
|
10000
|
+
for (const path of [manifest.preparation.schema, manifest.preparation.defaults, manifest.runtime.javascript, ...manifest.runtime.wasm ? [manifest.runtime.wasm] : [], ...manifest.runtime.wheels ?? []]) {
|
|
9998
10001
|
if (path.startsWith("source/") || path.startsWith("notices/")) throw new Error(`Runtime/preparation cannot reference reserved source/notice material: ${path}`);
|
|
9999
10002
|
if (!paths.has(path)) throw new Error(`Target manifest is missing required artifact ${path}`);
|
|
10000
10003
|
}
|
|
@@ -10016,7 +10019,7 @@ function validateTargetManifest(manifest, target) {
|
|
|
10016
10019
|
}
|
|
10017
10020
|
}
|
|
10018
10021
|
function resolveBatchTarget(ids, savedTarget) {
|
|
10019
|
-
if (!ids.length
|
|
10022
|
+
if (!ids.length) throw new Error("A batch needs at least one base model.");
|
|
10020
10023
|
const unique = new Set(ids);
|
|
10021
10024
|
if (unique.size !== 1) throw new Error("A batch cannot mix HEM targets. Create a separate batch for each target.");
|
|
10022
10025
|
const id = ids[0];
|
|
@@ -10161,6 +10164,104 @@ var TargetAssets = class _TargetAssets {
|
|
|
10161
10164
|
}
|
|
10162
10165
|
};
|
|
10163
10166
|
|
|
10167
|
+
// ../community/packages/geometry-editor/src/geometry/io/csvSectionRows.ts
|
|
10168
|
+
var parseCsvLine = parseGeometryCsvLine;
|
|
10169
|
+
var isSectionHeaderLine = isGeometryCsvSectionHeaderLine;
|
|
10170
|
+
var isTabularSectionHeaderLine = isTabularGeometryCsvSectionHeaderLine;
|
|
10171
|
+
function csvMetadataValue(csv, key) {
|
|
10172
|
+
const rows = csv.replace(/^\uFEFF/, "").split(/\r?\n/).map(parseCsvLine);
|
|
10173
|
+
const end = rows.findIndex((fields) => fields.every((field) => !field.trim()));
|
|
10174
|
+
const values = new Set(rows.slice(0, end === -1 ? void 0 : end).filter((fields) => fields[0]?.replace(/^#\s*/, "").trim() === key).map((fields) => fields[1]?.trim() ?? ""));
|
|
10175
|
+
if (values.size > 1) throw new Error(`CSV contains conflicting ${key} metadata`);
|
|
10176
|
+
return values.values().next().value;
|
|
10177
|
+
}
|
|
10178
|
+
function isLegacyBuildingServicesSectionTitle(fields) {
|
|
10179
|
+
if (fields.length === 0) return false;
|
|
10180
|
+
return fields[0].trim() === "Building Services" && fields.slice(1).every((f) => f.trim() === "");
|
|
10181
|
+
}
|
|
10182
|
+
function stripLegacyBuildingServicesBlocks(csv) {
|
|
10183
|
+
const lines = csv.split(/\r?\n/);
|
|
10184
|
+
const out = [];
|
|
10185
|
+
let skipping = false;
|
|
10186
|
+
for (let i = 0; i < lines.length; i++) {
|
|
10187
|
+
const line = lines[i];
|
|
10188
|
+
const f = parseCsvLine(line);
|
|
10189
|
+
if (!skipping && isLegacyBuildingServicesSectionTitle(f)) {
|
|
10190
|
+
skipping = true;
|
|
10191
|
+
continue;
|
|
10192
|
+
}
|
|
10193
|
+
if (skipping) {
|
|
10194
|
+
if (isTabularSectionHeaderLine(f)) {
|
|
10195
|
+
skipping = false;
|
|
10196
|
+
out.push(line);
|
|
10197
|
+
}
|
|
10198
|
+
continue;
|
|
10199
|
+
}
|
|
10200
|
+
out.push(line);
|
|
10201
|
+
}
|
|
10202
|
+
return out.join("\n");
|
|
10203
|
+
}
|
|
10204
|
+
function parseCsvSections(csvText) {
|
|
10205
|
+
const lines = csvText.split(/\r?\n/);
|
|
10206
|
+
const sections = [];
|
|
10207
|
+
let currentSection = null;
|
|
10208
|
+
let columnHeaders = null;
|
|
10209
|
+
let columnHeaderLineIndex = -1;
|
|
10210
|
+
let rows = [];
|
|
10211
|
+
for (let i = 0; i < lines.length; i++) {
|
|
10212
|
+
const line = lines[i];
|
|
10213
|
+
const trimmed = line.trim();
|
|
10214
|
+
if (trimmed === "") continue;
|
|
10215
|
+
const fields = parseCsvLine(line);
|
|
10216
|
+
if (isSectionHeaderLine(fields)) {
|
|
10217
|
+
if (currentSection && columnHeaders) {
|
|
10218
|
+
sections.push({
|
|
10219
|
+
...currentSection,
|
|
10220
|
+
columnHeaders,
|
|
10221
|
+
columnHeaderLineIndex,
|
|
10222
|
+
rows
|
|
10223
|
+
});
|
|
10224
|
+
}
|
|
10225
|
+
currentSection = {
|
|
10226
|
+
name: fields[0].trim(),
|
|
10227
|
+
headerLineIndex: i
|
|
10228
|
+
};
|
|
10229
|
+
columnHeaders = null;
|
|
10230
|
+
columnHeaderLineIndex = -1;
|
|
10231
|
+
rows = [];
|
|
10232
|
+
continue;
|
|
10233
|
+
}
|
|
10234
|
+
if (currentSection && !columnHeaders) {
|
|
10235
|
+
columnHeaders = fields.map((f) => f.trim());
|
|
10236
|
+
columnHeaderLineIndex = i;
|
|
10237
|
+
continue;
|
|
10238
|
+
}
|
|
10239
|
+
if (currentSection && columnHeaders) {
|
|
10240
|
+
const data = {};
|
|
10241
|
+
for (let j = 0; j < columnHeaders.length; j++) {
|
|
10242
|
+
if (columnHeaders[j]) {
|
|
10243
|
+
data[columnHeaders[j]] = (fields[j] ?? "").trim();
|
|
10244
|
+
}
|
|
10245
|
+
}
|
|
10246
|
+
rows.push({ lineIndex: i, fields, data });
|
|
10247
|
+
}
|
|
10248
|
+
}
|
|
10249
|
+
if (currentSection && columnHeaders) {
|
|
10250
|
+
sections.push({
|
|
10251
|
+
...currentSection,
|
|
10252
|
+
columnHeaders,
|
|
10253
|
+
columnHeaderLineIndex,
|
|
10254
|
+
rows
|
|
10255
|
+
});
|
|
10256
|
+
}
|
|
10257
|
+
return sections;
|
|
10258
|
+
}
|
|
10259
|
+
|
|
10260
|
+
// ../hem-target-runtime/src/hem/csvTarget.ts
|
|
10261
|
+
function csvTarget(csv) {
|
|
10262
|
+
return csvMetadataValue(csv, "TargetBundleId") || UNPINNED_CSV_TARGET;
|
|
10263
|
+
}
|
|
10264
|
+
|
|
10164
10265
|
// ../hem-target-runtime/src/hem/targetSchemaCorrections.ts
|
|
10165
10266
|
var PYTHON_TARGETS = /* @__PURE__ */ new Set(["python-fhs-a8-f2ab6cf7-8ca182b0-v1", "python-fhs-a9-918addad-b9b90138-v1"]);
|
|
10166
10267
|
var RUST_A7 = "rust-fhs-a7-62d3df70-c5ba2673-v1";
|
|
@@ -10308,99 +10409,6 @@ function selectionErrors(scenario, remedy) {
|
|
|
10308
10409
|
return errors;
|
|
10309
10410
|
}
|
|
10310
10411
|
|
|
10311
|
-
// ../community/packages/geometry-editor/src/geometry/io/csvSectionRows.ts
|
|
10312
|
-
var parseCsvLine = parseGeometryCsvLine;
|
|
10313
|
-
var isSectionHeaderLine = isGeometryCsvSectionHeaderLine;
|
|
10314
|
-
var isTabularSectionHeaderLine = isTabularGeometryCsvSectionHeaderLine;
|
|
10315
|
-
function csvMetadataValue(csv, key) {
|
|
10316
|
-
const rows = csv.replace(/^\uFEFF/, "").split(/\r?\n/).map(parseCsvLine);
|
|
10317
|
-
const end = rows.findIndex((fields) => fields.every((field) => !field.trim()));
|
|
10318
|
-
const values = new Set(rows.slice(0, end === -1 ? void 0 : end).filter((fields) => fields[0]?.replace(/^#\s*/, "").trim() === key).map((fields) => fields[1]?.trim() ?? ""));
|
|
10319
|
-
if (values.size > 1) throw new Error(`CSV contains conflicting ${key} metadata`);
|
|
10320
|
-
return values.values().next().value;
|
|
10321
|
-
}
|
|
10322
|
-
function isLegacyBuildingServicesSectionTitle(fields) {
|
|
10323
|
-
if (fields.length === 0) return false;
|
|
10324
|
-
return fields[0].trim() === "Building Services" && fields.slice(1).every((f) => f.trim() === "");
|
|
10325
|
-
}
|
|
10326
|
-
function stripLegacyBuildingServicesBlocks(csv) {
|
|
10327
|
-
const lines = csv.split(/\r?\n/);
|
|
10328
|
-
const out = [];
|
|
10329
|
-
let skipping = false;
|
|
10330
|
-
for (let i = 0; i < lines.length; i++) {
|
|
10331
|
-
const line = lines[i];
|
|
10332
|
-
const f = parseCsvLine(line);
|
|
10333
|
-
if (!skipping && isLegacyBuildingServicesSectionTitle(f)) {
|
|
10334
|
-
skipping = true;
|
|
10335
|
-
continue;
|
|
10336
|
-
}
|
|
10337
|
-
if (skipping) {
|
|
10338
|
-
if (isTabularSectionHeaderLine(f)) {
|
|
10339
|
-
skipping = false;
|
|
10340
|
-
out.push(line);
|
|
10341
|
-
}
|
|
10342
|
-
continue;
|
|
10343
|
-
}
|
|
10344
|
-
out.push(line);
|
|
10345
|
-
}
|
|
10346
|
-
return out.join("\n");
|
|
10347
|
-
}
|
|
10348
|
-
function parseCsvSections(csvText) {
|
|
10349
|
-
const lines = csvText.split(/\r?\n/);
|
|
10350
|
-
const sections = [];
|
|
10351
|
-
let currentSection = null;
|
|
10352
|
-
let columnHeaders = null;
|
|
10353
|
-
let columnHeaderLineIndex = -1;
|
|
10354
|
-
let rows = [];
|
|
10355
|
-
for (let i = 0; i < lines.length; i++) {
|
|
10356
|
-
const line = lines[i];
|
|
10357
|
-
const trimmed = line.trim();
|
|
10358
|
-
if (trimmed === "") continue;
|
|
10359
|
-
const fields = parseCsvLine(line);
|
|
10360
|
-
if (isSectionHeaderLine(fields)) {
|
|
10361
|
-
if (currentSection && columnHeaders) {
|
|
10362
|
-
sections.push({
|
|
10363
|
-
...currentSection,
|
|
10364
|
-
columnHeaders,
|
|
10365
|
-
columnHeaderLineIndex,
|
|
10366
|
-
rows
|
|
10367
|
-
});
|
|
10368
|
-
}
|
|
10369
|
-
currentSection = {
|
|
10370
|
-
name: fields[0].trim(),
|
|
10371
|
-
headerLineIndex: i
|
|
10372
|
-
};
|
|
10373
|
-
columnHeaders = null;
|
|
10374
|
-
columnHeaderLineIndex = -1;
|
|
10375
|
-
rows = [];
|
|
10376
|
-
continue;
|
|
10377
|
-
}
|
|
10378
|
-
if (currentSection && !columnHeaders) {
|
|
10379
|
-
columnHeaders = fields.map((f) => f.trim());
|
|
10380
|
-
columnHeaderLineIndex = i;
|
|
10381
|
-
continue;
|
|
10382
|
-
}
|
|
10383
|
-
if (currentSection && columnHeaders) {
|
|
10384
|
-
const data = {};
|
|
10385
|
-
for (let j = 0; j < columnHeaders.length; j++) {
|
|
10386
|
-
if (columnHeaders[j]) {
|
|
10387
|
-
data[columnHeaders[j]] = (fields[j] ?? "").trim();
|
|
10388
|
-
}
|
|
10389
|
-
}
|
|
10390
|
-
rows.push({ lineIndex: i, fields, data });
|
|
10391
|
-
}
|
|
10392
|
-
}
|
|
10393
|
-
if (currentSection && columnHeaders) {
|
|
10394
|
-
sections.push({
|
|
10395
|
-
...currentSection,
|
|
10396
|
-
columnHeaders,
|
|
10397
|
-
columnHeaderLineIndex,
|
|
10398
|
-
rows
|
|
10399
|
-
});
|
|
10400
|
-
}
|
|
10401
|
-
return sections;
|
|
10402
|
-
}
|
|
10403
|
-
|
|
10404
10412
|
// ../community/packages/geometry-editor/src/geometry/validation/ecaasOnlyProducts.ts
|
|
10405
10413
|
var ecaasOnlyProductMessage = (labels) => `ECaaS-only product (${labels.join(", ")}): this model can be submitted to ECaaS but can't run locally in Vulcan.`;
|
|
10406
10414
|
var collectProductReferences = (value, out) => {
|
|
@@ -10975,6 +10983,151 @@ function resolveBuildingElementPitch(element) {
|
|
|
10975
10983
|
return derivePitchFromGeometry(element.coordinates, element.type);
|
|
10976
10984
|
}
|
|
10977
10985
|
|
|
10986
|
+
// ../community/packages/geometry-editor/src/lib/profileLineFace.ts
|
|
10987
|
+
function normalizeProfilePoints(raw) {
|
|
10988
|
+
if (!Array.isArray(raw)) return null;
|
|
10989
|
+
const sorted = raw.filter(
|
|
10990
|
+
(point) => !!point && typeof point === "object" && typeof point.t === "number" && Number.isFinite(point.t) && typeof point.h === "number" && Number.isFinite(point.h)
|
|
10991
|
+
).map((point) => ({
|
|
10992
|
+
t: Math.min(Math.max(point.t, 0), 1),
|
|
10993
|
+
h: point.h
|
|
10994
|
+
})).sort((left, right) => left.t - right.t);
|
|
10995
|
+
if (sorted.length < 2) return null;
|
|
10996
|
+
const deduped = [];
|
|
10997
|
+
for (const point of sorted) {
|
|
10998
|
+
if (deduped.length > 0 && Math.abs(deduped[deduped.length - 1].t - point.t) < 1e-9) {
|
|
10999
|
+
deduped[deduped.length - 1] = point;
|
|
11000
|
+
continue;
|
|
11001
|
+
}
|
|
11002
|
+
deduped.push(point);
|
|
11003
|
+
}
|
|
11004
|
+
if (deduped.length < 2) return null;
|
|
11005
|
+
if (deduped[0].t > 0) deduped.unshift({ t: 0, h: deduped[0].h });
|
|
11006
|
+
if (deduped[deduped.length - 1].t < 1) deduped.push({ t: 1, h: deduped[deduped.length - 1].h });
|
|
11007
|
+
deduped[0] = { ...deduped[0], t: 0 };
|
|
11008
|
+
deduped[deduped.length - 1] = { ...deduped[deduped.length - 1], t: 1 };
|
|
11009
|
+
return deduped;
|
|
11010
|
+
}
|
|
11011
|
+
function interpolateProfileHeight(profile, t) {
|
|
11012
|
+
if (profile.length === 0) return 0;
|
|
11013
|
+
if (t <= profile[0].t) return profile[0].h;
|
|
11014
|
+
if (t >= profile[profile.length - 1].t) return profile[profile.length - 1].h;
|
|
11015
|
+
for (let index = 0; index < profile.length - 1; index += 1) {
|
|
11016
|
+
const start = profile[index];
|
|
11017
|
+
const end = profile[index + 1];
|
|
11018
|
+
if (t < start.t || t > end.t) continue;
|
|
11019
|
+
const span = end.t - start.t;
|
|
11020
|
+
if (Math.abs(span) < 1e-9) return end.h;
|
|
11021
|
+
const ratio = (t - start.t) / span;
|
|
11022
|
+
return start.h + (end.h - start.h) * ratio;
|
|
11023
|
+
}
|
|
11024
|
+
return profile[profile.length - 1].h;
|
|
11025
|
+
}
|
|
11026
|
+
var MIN_WALL_FACE_GAP_M = 0.01;
|
|
11027
|
+
function readProfiledLineFace(extra) {
|
|
11028
|
+
if (!extra || typeof extra !== "object" || Array.isArray(extra)) return null;
|
|
11029
|
+
const gf = extra.geometry_face;
|
|
11030
|
+
if (!gf || typeof gf !== "object" || gf.kind !== "profiled-line-face") return null;
|
|
11031
|
+
const points = (raw) => (Array.isArray(raw) ? raw : []).map((p) => ({ t: Number(p?.t), h: Number(p?.h) }));
|
|
11032
|
+
return {
|
|
11033
|
+
kind: "profiled-line-face",
|
|
11034
|
+
top_profile: points(gf.top_profile),
|
|
11035
|
+
bottom_profile: points(gf.bottom_profile),
|
|
11036
|
+
...gf.top_mode === "roof" ? { top_mode: "roof" } : {},
|
|
11037
|
+
...gf.bottom_mode === "roof" ? { bottom_mode: "roof" } : {}
|
|
11038
|
+
};
|
|
11039
|
+
}
|
|
11040
|
+
function wallFaceBreakpoints(top, bottom) {
|
|
11041
|
+
return Array.from(new Set([...top, ...bottom].map((p) => p.t))).sort((a, b) => a - b);
|
|
11042
|
+
}
|
|
11043
|
+
function wallFaceOverlap(top, bottom) {
|
|
11044
|
+
const low = wallFaceBreakpoints(top, bottom).filter((t) => {
|
|
11045
|
+
const gap = interpolateProfileHeight(top, t) - interpolateProfileHeight(bottom, t);
|
|
11046
|
+
return gap < (t === 0 || t === 1 ? 0 : MIN_WALL_FACE_GAP_M) - 1e-9;
|
|
11047
|
+
});
|
|
11048
|
+
return low.length === 0 ? null : [low[0], low[low.length - 1]];
|
|
11049
|
+
}
|
|
11050
|
+
function wallFaceProblem(top, bottom, widthM) {
|
|
11051
|
+
for (const [label, profile] of [["Top", top], ["Bottom", bottom]]) {
|
|
11052
|
+
const ordered = profile.length >= 2 && profile.every((p, i) => Number.isFinite(p.t) && Number.isFinite(p.h) && p.t >= 0 && p.t <= 1 && (i === 0 || p.t > profile[i - 1].t));
|
|
11053
|
+
if (!ordered) return `${label} points must run in order along the wall. Make each distance larger than the one before it.`;
|
|
11054
|
+
if (profile.some((p) => p.h < 0)) return `${label} heights cannot be below the base. Set them to 0 or more.`;
|
|
11055
|
+
}
|
|
11056
|
+
const overlap = wallFaceOverlap(top, bottom);
|
|
11057
|
+
if (!overlap) return null;
|
|
11058
|
+
const at = (t) => `${(t * widthM).toFixed(2)} m`;
|
|
11059
|
+
return overlap[0] === overlap[1] ? `Top must be above bottom (at ${at(overlap[0])}). Raise the top or lower the bottom there.` : `Top must be above bottom (from ${at(overlap[0])} to ${at(overlap[1])}). Raise the top or lower the bottom there.`;
|
|
11060
|
+
}
|
|
11061
|
+
var roundMicro = (v) => Math.round(v * 1e6) / 1e6;
|
|
11062
|
+
var lowestBottom = (face) => Math.min(...face.bottom_profile.map((p) => p.h));
|
|
11063
|
+
function wallFootFromExportedBaseHeight(baseHeight, extra) {
|
|
11064
|
+
const face = readProfiledLineFace(extra);
|
|
11065
|
+
if (baseHeight === void 0 || !face || wallFaceProblem(face.top_profile, face.bottom_profile, 1)) {
|
|
11066
|
+
return baseHeight;
|
|
11067
|
+
}
|
|
11068
|
+
const lowest = lowestBottom(face);
|
|
11069
|
+
return lowest === 0 ? baseHeight : roundMicro(baseHeight - lowest);
|
|
11070
|
+
}
|
|
11071
|
+
function readFaceEdges(el) {
|
|
11072
|
+
const face = readProfiledLineFace(el.extra_json);
|
|
11073
|
+
const top = face && normalizeProfilePoints(face.top_profile);
|
|
11074
|
+
const bottom = face && normalizeProfilePoints(face.bottom_profile);
|
|
11075
|
+
return top && bottom ? { top, bottom } : null;
|
|
11076
|
+
}
|
|
11077
|
+
function lineFaceEdgesAt(el, t) {
|
|
11078
|
+
const face = readFaceEdges(el);
|
|
11079
|
+
if (!face) return { bottom: 0, top: typeof el.height === "number" && el.height > 0 ? el.height : 0 };
|
|
11080
|
+
return { bottom: interpolateProfileHeight(face.bottom, t), top: interpolateProfileHeight(face.top, t) };
|
|
11081
|
+
}
|
|
11082
|
+
function lineFaceEnvelope(el) {
|
|
11083
|
+
const face = readFaceEdges(el);
|
|
11084
|
+
if (!face) return lineFaceEdgesAt(el, 0);
|
|
11085
|
+
return { bottom: Math.min(...face.bottom.map((p) => p.h)), top: Math.max(...face.top.map((p) => p.h)) };
|
|
11086
|
+
}
|
|
11087
|
+
function lineFaceRunsAtHeight(el, lengthM, loM, hiM, h, tol) {
|
|
11088
|
+
const face = readFaceEdges(el);
|
|
11089
|
+
if (!face || lengthM <= 0) return [[loM, hiM]];
|
|
11090
|
+
const lo = loM / lengthM;
|
|
11091
|
+
const hi = hiM / lengthM;
|
|
11092
|
+
const ts = [lo, ...wallFaceBreakpoints(face.top, face.bottom).filter((t) => t > lo && t < hi), hi];
|
|
11093
|
+
const limits = [
|
|
11094
|
+
(t) => interpolateProfileHeight(face.bottom, t) - tol - h,
|
|
11095
|
+
(t) => h - interpolateProfileHeight(face.top, t) - tol
|
|
11096
|
+
];
|
|
11097
|
+
const toM = (t) => t === lo ? loM : t === hi ? hiM : t * lengthM;
|
|
11098
|
+
const runs = [];
|
|
11099
|
+
for (let i = 0; i < ts.length - 1; i += 1) {
|
|
11100
|
+
const a = ts[i];
|
|
11101
|
+
const b = ts[i + 1];
|
|
11102
|
+
let s = a;
|
|
11103
|
+
let e = b;
|
|
11104
|
+
for (const f of limits) {
|
|
11105
|
+
const fa = f(a);
|
|
11106
|
+
const fb = f(b);
|
|
11107
|
+
if (fa <= 0 && fb <= 0) continue;
|
|
11108
|
+
if (fa > 0 && fb > 0) {
|
|
11109
|
+
e = s - 1;
|
|
11110
|
+
break;
|
|
11111
|
+
}
|
|
11112
|
+
const cross3 = a + (b - a) * fa / (fa - fb);
|
|
11113
|
+
if (fa > 0) s = Math.max(s, cross3);
|
|
11114
|
+
else e = Math.min(e, cross3);
|
|
11115
|
+
}
|
|
11116
|
+
if (e <= s) continue;
|
|
11117
|
+
const last3 = runs[runs.length - 1];
|
|
11118
|
+
if (last3 && Math.abs(last3[1] - toM(s)) < 1e-9) last3[1] = toM(e);
|
|
11119
|
+
else runs.push([toM(s), toM(e)]);
|
|
11120
|
+
}
|
|
11121
|
+
return runs;
|
|
11122
|
+
}
|
|
11123
|
+
function lineFaceEdgesAtPoint(el, p) {
|
|
11124
|
+
const a = el.coordinates[0];
|
|
11125
|
+
const b = el.coordinates[1];
|
|
11126
|
+
const len2 = (b.x - a.x) ** 2 + (b.y - a.y) ** 2;
|
|
11127
|
+
const t = len2 < 1e-18 ? 0 : ((p.x - a.x) * (b.x - a.x) + (p.y - a.y) * (b.y - a.y)) / len2;
|
|
11128
|
+
return lineFaceEdgesAt(el, Math.min(1, Math.max(0, t)));
|
|
11129
|
+
}
|
|
11130
|
+
|
|
10978
11131
|
// ../community/packages/geometry-editor/src/geometry/io/geometryCsvLayouts.ts
|
|
10979
11132
|
var PROMOTED_EXTRA_JSON_FIELDS = {
|
|
10980
11133
|
ElectricBattery: [
|
|
@@ -11411,6 +11564,11 @@ function num(d, column, cell = V(d, column)) {
|
|
|
11411
11564
|
}
|
|
11412
11565
|
return roundToTwoDecimals(Number(cell));
|
|
11413
11566
|
}
|
|
11567
|
+
function wallFootCell(d, extraJson) {
|
|
11568
|
+
const cell = V(d, "base_height");
|
|
11569
|
+
if (cell === "" || !NUMBER_CELL.test(cell)) return num(d, "base_height");
|
|
11570
|
+
return roundToTwoDecimals(wallFootFromExportedBaseHeight(Number(cell), extraJson));
|
|
11571
|
+
}
|
|
11414
11572
|
function reqNum(d, column, cell) {
|
|
11415
11573
|
return csvRequiredValue(num(d, column, cell));
|
|
11416
11574
|
}
|
|
@@ -11635,6 +11793,7 @@ function ingestGeometryTabularSections(sections, parseExtraJson) {
|
|
|
11635
11793
|
pitch: pitchOpt ?? null,
|
|
11636
11794
|
coordinates: opaqueCoords
|
|
11637
11795
|
});
|
|
11796
|
+
const opaqueExtraJson = parseExtraJson(V(d, "extra_json"), V(d, "Name"));
|
|
11638
11797
|
const opaqueElement = {
|
|
11639
11798
|
...baseElement,
|
|
11640
11799
|
type: "BuildingElementOpaque",
|
|
@@ -11643,13 +11802,13 @@ function ingestGeometryTabularSections(sections, parseExtraJson) {
|
|
|
11643
11802
|
area: reqNum(d, "area"),
|
|
11644
11803
|
...opaquePitch !== void 0 ? { pitch: opaquePitch } : {},
|
|
11645
11804
|
orientation360: num(d, "orientation360"),
|
|
11646
|
-
base_height:
|
|
11805
|
+
base_height: wallFootCell(d, opaqueExtraJson),
|
|
11647
11806
|
// A blank cell stays unset: the target schema requires a choice for a roof, with no default.
|
|
11648
11807
|
is_unheated_pitched_roof: V(d, "is_unheated_pitched_roof") ? V(d, "is_unheated_pitched_roof") === "TRUE" : void 0,
|
|
11649
11808
|
is_external_door: V(d, "is_external_door") === "TRUE",
|
|
11650
11809
|
parent_element: V(d, "parent_element") ? V(d, "parent_element") : null,
|
|
11651
11810
|
coordinates: opaqueCoords,
|
|
11652
|
-
extra_json:
|
|
11811
|
+
extra_json: opaqueExtraJson
|
|
11653
11812
|
};
|
|
11654
11813
|
newElements.push(opaqueElement);
|
|
11655
11814
|
break;
|
|
@@ -11662,6 +11821,7 @@ function ingestGeometryTabularSections(sections, parseExtraJson) {
|
|
|
11662
11821
|
pitch: pitchOptT ?? null,
|
|
11663
11822
|
coordinates: transparentCoords
|
|
11664
11823
|
});
|
|
11824
|
+
const transparentExtraJson = parseExtraJson(V(d, "extra_json"), V(d, "Name"));
|
|
11665
11825
|
const transparentElement = {
|
|
11666
11826
|
...baseElement,
|
|
11667
11827
|
type: "BuildingElementTransparent",
|
|
@@ -11670,14 +11830,14 @@ function ingestGeometryTabularSections(sections, parseExtraJson) {
|
|
|
11670
11830
|
area: reqNum(d, "area"),
|
|
11671
11831
|
...transparentPitch !== void 0 ? { pitch: transparentPitch } : {},
|
|
11672
11832
|
orientation360: num(d, "orientation360"),
|
|
11673
|
-
base_height:
|
|
11833
|
+
base_height: wallFootCell(d, transparentExtraJson),
|
|
11674
11834
|
parent_element: V(d, "linked_wall") ? V(d, "linked_wall") : null,
|
|
11675
11835
|
frame_area_fraction: num(d, "frame_area_fraction"),
|
|
11676
11836
|
free_area_height: num(d, "free_area_height"),
|
|
11677
11837
|
mid_height: num(d, "mid_height"),
|
|
11678
11838
|
max_window_open_area: num(d, "max_window_open_area"),
|
|
11679
11839
|
coordinates: transparentCoords,
|
|
11680
|
-
extra_json:
|
|
11840
|
+
extra_json: transparentExtraJson
|
|
11681
11841
|
};
|
|
11682
11842
|
newElements.push(transparentElement);
|
|
11683
11843
|
break;
|
|
@@ -12240,6 +12400,539 @@ function isSlopedPitchedRoofElementForEavesGable(o) {
|
|
|
12240
12400
|
return false;
|
|
12241
12401
|
}
|
|
12242
12402
|
|
|
12403
|
+
// ../community/packages/geometry-editor/src/lib/roofCutouts.ts
|
|
12404
|
+
var import_polygon_clipping3 = __toESM(require_polygon_clipping_umd(), 1);
|
|
12405
|
+
|
|
12406
|
+
// ../community/packages/geometry-editor/src/lib/roofTopElevationAtPlanM.ts
|
|
12407
|
+
function roofBaseElevationM(roof, floors) {
|
|
12408
|
+
if (floors && floors.length > 0) {
|
|
12409
|
+
return elementBaseElevationMForTb(roof, floors);
|
|
12410
|
+
}
|
|
12411
|
+
const c = roof.coordinates;
|
|
12412
|
+
if (!c?.length) return 0;
|
|
12413
|
+
const bh = roof.base_height;
|
|
12414
|
+
if (typeof bh === "number" && Number.isFinite(bh) && bh >= 0) return bh;
|
|
12415
|
+
return Math.min(...c.map((p) => typeof p.z === "number" && Number.isFinite(p.z) ? p.z : 0));
|
|
12416
|
+
}
|
|
12417
|
+
function inwardNormal2DStripLeftOfDirectedEdge(roof) {
|
|
12418
|
+
const c = roof.coordinates;
|
|
12419
|
+
if (!c || c.length < 2) return null;
|
|
12420
|
+
const ax = c[0].x;
|
|
12421
|
+
const ay = c[0].y;
|
|
12422
|
+
const bx = c[1].x;
|
|
12423
|
+
const by = c[1].y;
|
|
12424
|
+
const ex = bx - ax;
|
|
12425
|
+
const ey = by - ay;
|
|
12426
|
+
const len2 = Math.hypot(ex, ey);
|
|
12427
|
+
if (len2 < 1e-9) return null;
|
|
12428
|
+
const nx = -ey / len2;
|
|
12429
|
+
const ny = ex / len2;
|
|
12430
|
+
return [nx, ny];
|
|
12431
|
+
}
|
|
12432
|
+
function inwardNormal2DForSlopedRoof(roof, globalOrientationOffset) {
|
|
12433
|
+
const c = roof.coordinates;
|
|
12434
|
+
if (!c || c.length < 2) return null;
|
|
12435
|
+
if (c.length >= 3) {
|
|
12436
|
+
const planPts = c.map((p) => [p.x, p.y]);
|
|
12437
|
+
const orientationAxis = isOrientationPitchAxis(roof);
|
|
12438
|
+
if (orientationAxis && !Number.isFinite(globalOrientationOffset)) return null;
|
|
12439
|
+
return slopedPolygonPlaneBasis(
|
|
12440
|
+
planPts,
|
|
12441
|
+
orientationAxis ? "orientation" : "bottom-edge",
|
|
12442
|
+
roof.orientation360 ?? 0,
|
|
12443
|
+
globalOrientationOffset ?? 0
|
|
12444
|
+
)?.upslope2D ?? null;
|
|
12445
|
+
}
|
|
12446
|
+
return inwardNormal2DStripLeftOfDirectedEdge(roof);
|
|
12447
|
+
}
|
|
12448
|
+
function roofTopElevationAtPlanM(roof, x, y, floors, globalOrientationOffset) {
|
|
12449
|
+
const c = roof.coordinates;
|
|
12450
|
+
if (!c || c.length < 2) return null;
|
|
12451
|
+
const pitch = roof.pitch;
|
|
12452
|
+
if (typeof pitch !== "number" || !Number.isFinite(pitch) || pitch <= 0 || pitch >= 90) return null;
|
|
12453
|
+
const orientationAxis = isOrientationPitchAxis(roof);
|
|
12454
|
+
if (orientationAxis && !Number.isFinite(globalOrientationOffset)) return null;
|
|
12455
|
+
const points = c.map((point) => [point.x, point.y]);
|
|
12456
|
+
const basis = c.length >= 3 ? slopedPolygonPlaneBasis(
|
|
12457
|
+
points,
|
|
12458
|
+
orientationAxis ? "orientation" : "bottom-edge",
|
|
12459
|
+
roof.orientation360 ?? 0,
|
|
12460
|
+
globalOrientationOffset ?? 0
|
|
12461
|
+
) : null;
|
|
12462
|
+
const inward = basis?.upslope2D ?? inwardNormal2DForSlopedRoof(roof, globalOrientationOffset);
|
|
12463
|
+
if (!inward) return null;
|
|
12464
|
+
const baseEl = roofBaseElevationM(roof, floors);
|
|
12465
|
+
const anchor = basis?.anchorXY ?? [c[0].x, c[0].y];
|
|
12466
|
+
return elevationAtSlopedVertexM([x, y], anchor, inward, baseEl, pitch);
|
|
12467
|
+
}
|
|
12468
|
+
|
|
12469
|
+
// ../community/packages/geometry-editor/src/lib/wallEdgeFromRoofs.ts
|
|
12470
|
+
var OUTLINE_TOL_M = 0.1;
|
|
12471
|
+
var ALONGSIDE_SIN = 0.1;
|
|
12472
|
+
function distanceToEdgesAlongside(p, ring, dir) {
|
|
12473
|
+
let best = Infinity;
|
|
12474
|
+
for (let i = 0; i < ring.length; i += 1) {
|
|
12475
|
+
const a = ring[i];
|
|
12476
|
+
const b = ring[(i + 1) % ring.length];
|
|
12477
|
+
const ex = b.x - a.x;
|
|
12478
|
+
const ey = b.y - a.y;
|
|
12479
|
+
const len2 = ex * ex + ey * ey;
|
|
12480
|
+
if (Math.abs(dir.x * ey - dir.y * ex) > ALONGSIDE_SIN * Math.sqrt(len2)) continue;
|
|
12481
|
+
const u = len2 < 1e-18 ? 0 : Math.max(0, Math.min(1, ((p.x - a.x) * ex + (p.y - a.y) * ey) / len2));
|
|
12482
|
+
best = Math.min(best, Math.hypot(p.x - a.x - ex * u, p.y - a.y - ey * u));
|
|
12483
|
+
}
|
|
12484
|
+
return best;
|
|
12485
|
+
}
|
|
12486
|
+
function roofCoversPlanPoint(roof, p, dir) {
|
|
12487
|
+
return isPointInPolygon2D(p, roof.coordinates) || distanceToEdgesAlongside(p, roof.coordinates, dir) < OUTLINE_TOL_M;
|
|
12488
|
+
}
|
|
12489
|
+
|
|
12490
|
+
// ../community/packages/geometry-editor/src/lib/roofCutouts.ts
|
|
12491
|
+
var ON_ROOF_TOL_M = 0.05;
|
|
12492
|
+
var JOIN_TOL_M = 0.1;
|
|
12493
|
+
var END_GAP_TOL_M = 0.05;
|
|
12494
|
+
var INSIDE_PROBE_M = 0.15;
|
|
12495
|
+
var zonesCompatible = (a, b) => a === void 0 || b === void 0 || a === b;
|
|
12496
|
+
function pitchedRoofsForWalls(elements, globalOrientationOffset) {
|
|
12497
|
+
return elements.filter((e) => {
|
|
12498
|
+
if (e.type !== "BuildingElementOpaque" || e.isPlaceholder) return false;
|
|
12499
|
+
if (isOrientationPitchAxis(e) && !inwardNormal2DForSlopedRoof(e, globalOrientationOffset)) return false;
|
|
12500
|
+
return isSlopedPitchedRoofElementForEavesGable(e);
|
|
12501
|
+
});
|
|
12502
|
+
}
|
|
12503
|
+
function isFlatRoofDeckLineForTb(o) {
|
|
12504
|
+
if (o.isPlaceholder) return false;
|
|
12505
|
+
if (!isRoofLikeOpaqueElement(o)) return false;
|
|
12506
|
+
if (o.pitch !== 0) return false;
|
|
12507
|
+
if (o.is_unheated_pitched_roof) return true;
|
|
12508
|
+
const n = (o.name ?? "").trim().toLowerCase();
|
|
12509
|
+
return n === "roof" || n.includes("roof");
|
|
12510
|
+
}
|
|
12511
|
+
function flatRoofDeckElevationMForTb(o, floors) {
|
|
12512
|
+
return opaquePolygonBaseElevationMForTb(o, floors ?? []);
|
|
12513
|
+
}
|
|
12514
|
+
var memos = /* @__PURE__ */ new WeakMap();
|
|
12515
|
+
function memo(owner, key, compute) {
|
|
12516
|
+
let byKey = memos.get(owner);
|
|
12517
|
+
if (!byKey) memos.set(owner, byKey = /* @__PURE__ */ new Map());
|
|
12518
|
+
if (!byKey.has(key)) byKey.set(key, compute());
|
|
12519
|
+
return byKey.get(key);
|
|
12520
|
+
}
|
|
12521
|
+
function roofsWallsStandOn(elements, globalOrientationOffset) {
|
|
12522
|
+
return memo(elements, `roofs|${globalOrientationOffset}`, () => [
|
|
12523
|
+
...pitchedRoofsForWalls(elements, globalOrientationOffset),
|
|
12524
|
+
...elements.filter((e) => e.type === "BuildingElementOpaque" && (e.coordinates?.length ?? 0) >= 3 && isFlatRoofDeckLineForTb(e))
|
|
12525
|
+
]);
|
|
12526
|
+
}
|
|
12527
|
+
function modelMayHaveRoofCutouts(elements) {
|
|
12528
|
+
return memo(elements, "mayHave", () => elements.some((e) => e.type === "BuildingElementOpaque" && isFlatRoofDeckLineForTb(e) || (readProfiledLineFace(e.extra_json)?.bottom_profile.some((p) => p.h > ON_ROOF_TOL_M) ?? false)));
|
|
12529
|
+
}
|
|
12530
|
+
function bottomEdgeRoofRuns(w, roofs, floors, globalOrientationOffset) {
|
|
12531
|
+
if (w.coordinates?.length !== 2) return [];
|
|
12532
|
+
const face = readProfiledLineFace(w.extra_json);
|
|
12533
|
+
const bottom = face ? normalizeProfilePoints(face.bottom_profile) : [{ t: 0, h: 0 }, { t: 1, h: 0 }];
|
|
12534
|
+
if (!bottom) return [];
|
|
12535
|
+
const [A, B] = [w.coordinates[0], w.coordinates[1]];
|
|
12536
|
+
const len2 = Math.hypot(B.x - A.x, B.y - A.y);
|
|
12537
|
+
if (len2 < 1e-9) return [];
|
|
12538
|
+
const foot = elementBaseElevationMForTb(w, floors ?? []);
|
|
12539
|
+
const dir = { x: (B.x - A.x) / len2, y: (B.y - A.y) / len2 };
|
|
12540
|
+
const roofAt = (p, z, raised) => roofs.find((r) => {
|
|
12541
|
+
if (r.id === w.id || !raised && r.pitch !== 0) return false;
|
|
12542
|
+
if (!zonesCompatible(w.zoneId, r.zoneId) || !roofCoversPlanPoint(r, p, dir)) return false;
|
|
12543
|
+
const roofZ = r.pitch === 0 ? flatRoofDeckElevationMForTb(r, floors) : roofTopElevationAtPlanM(r, p.x, p.y, floors, globalOrientationOffset);
|
|
12544
|
+
return roofZ !== null && Math.abs(roofZ - z) <= ON_ROOF_TOL_M;
|
|
12545
|
+
});
|
|
12546
|
+
const runs = [];
|
|
12547
|
+
for (let i = 0; i < bottom.length - 1; i += 1) {
|
|
12548
|
+
const t0 = bottom[i].t;
|
|
12549
|
+
const t1 = bottom[i + 1].t;
|
|
12550
|
+
const tm = (t0 + t1) / 2;
|
|
12551
|
+
const h = interpolateProfileHeight(bottom, tm);
|
|
12552
|
+
const roof = roofAt({ x: A.x + (B.x - A.x) * tm, y: A.y + (B.y - A.y) * tm }, foot + h, h > ON_ROOF_TOL_M);
|
|
12553
|
+
if (!roof) continue;
|
|
12554
|
+
const last3 = runs[runs.length - 1];
|
|
12555
|
+
if (last3 && last3.roof === roof && last3.t1 === t0) last3.t1 = t1;
|
|
12556
|
+
else runs.push({ roof, t0, t1 });
|
|
12557
|
+
}
|
|
12558
|
+
return runs;
|
|
12559
|
+
}
|
|
12560
|
+
var near2 = (p, q) => Math.hypot(p.x - q.x, p.y - q.y) <= JOIN_TOL_M;
|
|
12561
|
+
var last = (list) => list[list.length - 1];
|
|
12562
|
+
var isClosed = (c) => c.pts.length >= 3 && near2(c.pts[0], last(c.pts));
|
|
12563
|
+
function branchPoints(segs) {
|
|
12564
|
+
const nodes = [];
|
|
12565
|
+
for (const s of segs) {
|
|
12566
|
+
for (const p of [s.a, s.b]) {
|
|
12567
|
+
let node;
|
|
12568
|
+
for (const n of nodes) {
|
|
12569
|
+
if (near2(n.at, p)) {
|
|
12570
|
+
node = n;
|
|
12571
|
+
break;
|
|
12572
|
+
}
|
|
12573
|
+
}
|
|
12574
|
+
if (node) node.segs.push(s);
|
|
12575
|
+
else nodes.push({ at: p, segs: [s] });
|
|
12576
|
+
}
|
|
12577
|
+
}
|
|
12578
|
+
return nodes.filter((n) => n.segs.length >= 3);
|
|
12579
|
+
}
|
|
12580
|
+
function buildChains(segs) {
|
|
12581
|
+
const pool = new Set(segs);
|
|
12582
|
+
const chains = [];
|
|
12583
|
+
for (const s of segs) {
|
|
12584
|
+
if (!pool.delete(s)) continue;
|
|
12585
|
+
const chain = { pts: [s.a, s.b], segs: [s], head: { seg: s, t: 0 }, tail: { seg: s, t: 1 } };
|
|
12586
|
+
for (const side of ["tail", "head"]) {
|
|
12587
|
+
while (!isClosed(chain)) {
|
|
12588
|
+
const end = side === "tail" ? last(chain.pts) : chain.pts[0];
|
|
12589
|
+
let next;
|
|
12590
|
+
for (const n of pool) {
|
|
12591
|
+
if (near2(n.a, end) || near2(n.b, end)) {
|
|
12592
|
+
next = n;
|
|
12593
|
+
break;
|
|
12594
|
+
}
|
|
12595
|
+
}
|
|
12596
|
+
if (!next) break;
|
|
12597
|
+
pool.delete(next);
|
|
12598
|
+
const fromA = near2(next.a, end);
|
|
12599
|
+
const far = fromA ? next.b : next.a;
|
|
12600
|
+
const farEnd = { seg: next, t: fromA ? 1 : 0 };
|
|
12601
|
+
chain.segs.push(next);
|
|
12602
|
+
if (side === "tail") {
|
|
12603
|
+
chain.pts.push(far);
|
|
12604
|
+
chain.tail = farEnd;
|
|
12605
|
+
} else {
|
|
12606
|
+
chain.pts.unshift(far);
|
|
12607
|
+
chain.head = farEnd;
|
|
12608
|
+
}
|
|
12609
|
+
}
|
|
12610
|
+
}
|
|
12611
|
+
chains.push(chain);
|
|
12612
|
+
}
|
|
12613
|
+
return chains;
|
|
12614
|
+
}
|
|
12615
|
+
var isFootprintWall = (e) => !e.isPlaceholder && isVerticalLineWall(e) && e.type !== "BuildingElementAdjacentConditionedSpace" && e.location !== "internal" && !(e.type === "BuildingElementOpaque" && isRoofLikeOpaqueElement(e));
|
|
12616
|
+
function distToSegment(p, a, b) {
|
|
12617
|
+
const ex = b.x - a.x;
|
|
12618
|
+
const ey = b.y - a.y;
|
|
12619
|
+
const len2 = ex * ex + ey * ey;
|
|
12620
|
+
const u = len2 < 1e-18 ? 0 : Math.max(0, Math.min(1, ((p.x - a.x) * ex + (p.y - a.y) * ey) / len2));
|
|
12621
|
+
return Math.hypot(p.x - a.x - ex * u, p.y - a.y - ey * u);
|
|
12622
|
+
}
|
|
12623
|
+
function linkSegments(roof, elements, segs, openEnds, floors, globalOrientationOffset) {
|
|
12624
|
+
const ring = roof.coordinates;
|
|
12625
|
+
const onRoofPlan = (p) => isPointInPolygon2D(p, ring) || ringPosition(p, ring).d <= JOIN_TOL_M;
|
|
12626
|
+
const joinsAt = (el, foot, t, p) => {
|
|
12627
|
+
if (!onRoofPlan(p)) return true;
|
|
12628
|
+
const z = roofSurfaceZ(roof, p, floors, globalOrientationOffset);
|
|
12629
|
+
if (z === null) return false;
|
|
12630
|
+
const { bottom, top } = lineFaceEdgesAt(el, t);
|
|
12631
|
+
return foot + bottom <= z + ON_ROOF_TOL_M && z < foot + top - ON_ROOF_TOL_M;
|
|
12632
|
+
};
|
|
12633
|
+
const standingEls = new Set(segs.map((s) => s.el));
|
|
12634
|
+
const walls = elements.flatMap((el) => {
|
|
12635
|
+
if (standingEls.has(el) || !isFootprintWall(el) || !segs.some((s) => zonesCompatible(s.el.zoneId, el.zoneId))) return [];
|
|
12636
|
+
const a = el.coordinates[0];
|
|
12637
|
+
const b = el.coordinates[1];
|
|
12638
|
+
const len2 = Math.hypot(b.x - a.x, b.y - a.y);
|
|
12639
|
+
if (len2 < JOIN_TOL_M) return [];
|
|
12640
|
+
const foot = elementBaseElevationMForTb(el, floors);
|
|
12641
|
+
const tOf = (p) => ((p.x - a.x) * (b.x - a.x) + (p.y - a.y) * (b.y - a.y)) / (len2 * len2);
|
|
12642
|
+
const ends = openEnds.filter((p) => distToSegment(p, a, b) <= JOIN_TOL_M);
|
|
12643
|
+
if (!joinsAt(el, foot, 0, a) && !joinsAt(el, foot, 1, b) && !ends.some((p) => joinsAt(el, foot, tOf(p), p))) return [];
|
|
12644
|
+
return [{ el, a, b, len: len2, foot, tOf }];
|
|
12645
|
+
});
|
|
12646
|
+
const cuts = [...openEnds, ...walls.flatMap((w) => [w.a, w.b])];
|
|
12647
|
+
const links = [];
|
|
12648
|
+
for (const w of walls) {
|
|
12649
|
+
const ts = [0, 1, ...cuts.filter((p) => distToSegment(p, w.a, w.b) <= JOIN_TOL_M).map(w.tOf)].map((t) => Math.max(0, Math.min(1, t))).sort((x, y) => x - y).filter((t, k, list) => k === 0 || (t - list[k - 1]) * w.len > JOIN_TOL_M);
|
|
12650
|
+
ts[ts.length - 1] = 1;
|
|
12651
|
+
for (let k = 0; k < ts.length - 1; k += 1) {
|
|
12652
|
+
const at = (t) => ({ x: w.a.x + (w.b.x - w.a.x) * t, y: w.a.y + (w.b.y - w.a.y) * t });
|
|
12653
|
+
const [t0, t1] = [ts[k], ts[k + 1]];
|
|
12654
|
+
const s = { el: w.el, a: at(t0), b: at(t1), onRoof: false, probes: [] };
|
|
12655
|
+
const mid = at((t0 + t1) / 2);
|
|
12656
|
+
if (!joinsAt(w.el, w.foot, t0, s.a) || !joinsAt(w.el, w.foot, t1, s.b)) continue;
|
|
12657
|
+
if (segs.some((st) => distToSegment(mid, st.a, st.b) <= JOIN_TOL_M)) continue;
|
|
12658
|
+
if (links.some((l) => near2(l.a, s.a) && near2(l.b, s.b) || near2(l.a, s.b) && near2(l.b, s.a))) continue;
|
|
12659
|
+
links.push(s);
|
|
12660
|
+
}
|
|
12661
|
+
}
|
|
12662
|
+
return links;
|
|
12663
|
+
}
|
|
12664
|
+
function shortestJoins(openEnds, links) {
|
|
12665
|
+
const nodes = [];
|
|
12666
|
+
const grid = /* @__PURE__ */ new Map();
|
|
12667
|
+
const cell = (v) => Math.floor(v / JOIN_TOL_M);
|
|
12668
|
+
const nodeOf = (p) => {
|
|
12669
|
+
const [cx, cy] = [cell(p.x), cell(p.y)];
|
|
12670
|
+
const around = [-1, 0, 1].flatMap((dx) => [-1, 0, 1].flatMap((dy) => grid.get(`${cx + dx},${cy + dy}`) ?? []));
|
|
12671
|
+
const hit = around.find((n) => near2(nodes[n], p));
|
|
12672
|
+
if (hit !== void 0) return hit;
|
|
12673
|
+
nodes.push(p);
|
|
12674
|
+
const key = `${cx},${cy}`;
|
|
12675
|
+
grid.set(key, [...grid.get(key) ?? [], nodes.length - 1]);
|
|
12676
|
+
return nodes.length - 1;
|
|
12677
|
+
};
|
|
12678
|
+
const endNodes = openEnds.map(nodeOf);
|
|
12679
|
+
const adjacent = [];
|
|
12680
|
+
for (const link of links) {
|
|
12681
|
+
const [u, v] = [nodeOf(link.a), nodeOf(link.b)];
|
|
12682
|
+
if (u === v) continue;
|
|
12683
|
+
const length = Math.hypot(link.b.x - link.a.x, link.b.y - link.a.y);
|
|
12684
|
+
(adjacent[u] ?? (adjacent[u] = [])).push({ to: v, link, length });
|
|
12685
|
+
(adjacent[v] ?? (adjacent[v] = [])).push({ to: u, link, length });
|
|
12686
|
+
}
|
|
12687
|
+
const joins = [];
|
|
12688
|
+
endNodes.forEach((start, i) => {
|
|
12689
|
+
const dist = /* @__PURE__ */ new Map([[start, 0]]);
|
|
12690
|
+
const via = /* @__PURE__ */ new Map();
|
|
12691
|
+
const done = /* @__PURE__ */ new Set();
|
|
12692
|
+
for (; ; ) {
|
|
12693
|
+
let cur = -1;
|
|
12694
|
+
for (const [n, d] of dist) if (!done.has(n) && (cur < 0 || d < dist.get(cur))) cur = n;
|
|
12695
|
+
if (cur < 0) break;
|
|
12696
|
+
done.add(cur);
|
|
12697
|
+
if (cur !== start) {
|
|
12698
|
+
endNodes.forEach((end, j) => {
|
|
12699
|
+
if (j <= i || end !== cur) return;
|
|
12700
|
+
const path = [];
|
|
12701
|
+
for (let n = cur; n !== start; n = via.get(n).from) path.unshift(via.get(n).link);
|
|
12702
|
+
joins.push({ i, j, length: dist.get(cur), path });
|
|
12703
|
+
});
|
|
12704
|
+
}
|
|
12705
|
+
for (const { to, link, length } of adjacent[cur] ?? []) {
|
|
12706
|
+
const d = dist.get(cur) + length;
|
|
12707
|
+
if (!done.has(to) && d < (dist.get(to) ?? Infinity)) {
|
|
12708
|
+
dist.set(to, d);
|
|
12709
|
+
via.set(to, { from: cur, link });
|
|
12710
|
+
}
|
|
12711
|
+
}
|
|
12712
|
+
}
|
|
12713
|
+
});
|
|
12714
|
+
return joins;
|
|
12715
|
+
}
|
|
12716
|
+
function ringPosition(p, ring) {
|
|
12717
|
+
let best = { s: 0, d: Infinity };
|
|
12718
|
+
for (let i = 0; i < ring.length; i += 1) {
|
|
12719
|
+
const a = ring[i];
|
|
12720
|
+
const b = ring[(i + 1) % ring.length];
|
|
12721
|
+
const ex = b.x - a.x;
|
|
12722
|
+
const ey = b.y - a.y;
|
|
12723
|
+
const len2 = ex * ex + ey * ey;
|
|
12724
|
+
const u = len2 < 1e-18 ? 0 : Math.max(0, Math.min(1, ((p.x - a.x) * ex + (p.y - a.y) * ey) / len2));
|
|
12725
|
+
const d = Math.hypot(p.x - a.x - ex * u, p.y - a.y - ey * u);
|
|
12726
|
+
if (d < best.d) best = { s: i + u, d };
|
|
12727
|
+
}
|
|
12728
|
+
return best;
|
|
12729
|
+
}
|
|
12730
|
+
function ringVerticesBetween(ring, from, to, dir) {
|
|
12731
|
+
const n = ring.length;
|
|
12732
|
+
const offset = (k) => (dir * (k - from) % n + n) % n;
|
|
12733
|
+
const span = offset(to);
|
|
12734
|
+
return ring.flatMap((p, k) => {
|
|
12735
|
+
const o = offset(k);
|
|
12736
|
+
return o > 1e-9 && o < span - 1e-9 ? [{ p, o }] : [];
|
|
12737
|
+
}).sort((x, y) => x.o - y.o).map(({ p }) => p);
|
|
12738
|
+
}
|
|
12739
|
+
function cutHeadAtRing(pts, ring) {
|
|
12740
|
+
if (isPointInPolygon2D(pts[0], ring) || ringPosition(pts[0], ring).d <= JOIN_TOL_M) return pts;
|
|
12741
|
+
for (let k = 0; k < pts.length - 1; k += 1) {
|
|
12742
|
+
const p = pts[k];
|
|
12743
|
+
const q = pts[k + 1];
|
|
12744
|
+
let best = null;
|
|
12745
|
+
for (let i = 0; i < ring.length; i += 1) {
|
|
12746
|
+
const a = ring[i];
|
|
12747
|
+
const b = ring[(i + 1) % ring.length];
|
|
12748
|
+
const den = (q.x - p.x) * (b.y - a.y) - (q.y - p.y) * (b.x - a.x);
|
|
12749
|
+
if (Math.abs(den) < 1e-12) continue;
|
|
12750
|
+
const u = ((a.x - p.x) * (b.y - a.y) - (a.y - p.y) * (b.x - a.x)) / den;
|
|
12751
|
+
const v = ((a.x - p.x) * (q.y - p.y) - (a.y - p.y) * (q.x - p.x)) / den;
|
|
12752
|
+
if (u < 0 || u > 1 || v < 0 || v > 1 || best && best.u <= u) continue;
|
|
12753
|
+
best = { u, x: { x: p.x + (q.x - p.x) * u, y: p.y + (q.y - p.y) * u } };
|
|
12754
|
+
}
|
|
12755
|
+
if (best) return [best.x, ...pts.slice(k + 1)];
|
|
12756
|
+
}
|
|
12757
|
+
return pts;
|
|
12758
|
+
}
|
|
12759
|
+
function roofSurfaceZ(roof, p, floors, globalOrientationOffset) {
|
|
12760
|
+
return roof.pitch === 0 ? flatRoofDeckElevationMForTb(roof, floors) : roofTopElevationAtPlanM(roof, p.x, p.y, floors, globalOrientationOffset);
|
|
12761
|
+
}
|
|
12762
|
+
function closeUnderRoofsAbove(chain, roofs, floors, globalOrientationOffset) {
|
|
12763
|
+
const above = (end, p) => {
|
|
12764
|
+
const { a, b, el } = end.seg;
|
|
12765
|
+
const len2 = Math.hypot(b.x - a.x, b.y - a.y);
|
|
12766
|
+
const dir = { x: (b.x - a.x) / len2, y: (b.y - a.y) / len2 };
|
|
12767
|
+
const topZ = elementBaseElevationMForTb(el, floors) + lineFaceEdgesAt(el, end.t).top;
|
|
12768
|
+
return roofs.filter((r) => {
|
|
12769
|
+
if (!roofCoversPlanPoint(r, p, dir) && ringPosition(p, r.coordinates).d > JOIN_TOL_M) return false;
|
|
12770
|
+
const z = roofSurfaceZ(r, p, floors, globalOrientationOffset);
|
|
12771
|
+
return z !== null && Math.abs(z - topZ) <= JOIN_TOL_M;
|
|
12772
|
+
});
|
|
12773
|
+
};
|
|
12774
|
+
const head = chain.pts[0];
|
|
12775
|
+
const tail = last(chain.pts);
|
|
12776
|
+
const overHead = above(chain.head, head);
|
|
12777
|
+
const overTail = above(chain.tail, tail);
|
|
12778
|
+
if (overHead.length === 0 || overTail.length === 0) return null;
|
|
12779
|
+
const planes = [.../* @__PURE__ */ new Set([...overHead, ...overTail])].map((r) => [r.coordinates.map((p) => [p.x, p.y])]);
|
|
12780
|
+
const outline = import_polygon_clipping3.default.union(...planes).map((polygon) => polygon[0].slice(0, -1).map(([x, y]) => ({ x, y }))).find((r) => [head, tail].every((p) => isPointInPolygon2D(p, r) || ringPosition(p, r).d <= JOIN_TOL_M));
|
|
12781
|
+
if (!outline) return null;
|
|
12782
|
+
const from = ringPosition(tail, outline).s;
|
|
12783
|
+
const to = ringPosition(head, outline).s;
|
|
12784
|
+
const ways = [1, -1].map((dir) => [...chain.pts, ...ringVerticesBetween(outline, from, to, dir)]);
|
|
12785
|
+
const area = (pts) => calculatePolygonArea(pts.map((p) => ({ ...p, z: 0 })));
|
|
12786
|
+
return area(ways[0]) >= area(ways[1]) ? ways[0] : ways[1];
|
|
12787
|
+
}
|
|
12788
|
+
function deriveRoofCutout(roof, elements, floors, globalOrientationOffset) {
|
|
12789
|
+
if (roof.type !== "BuildingElementOpaque" || !modelMayHaveRoofCutouts(elements)) return null;
|
|
12790
|
+
const byRoof = memo(elements, `cutouts|${globalOrientationOffset}|${JSON.stringify(floors)}`, () => /* @__PURE__ */ new WeakMap());
|
|
12791
|
+
if (!byRoof.has(roof)) byRoof.set(roof, computeRoofCutout(roof, elements, floors, globalOrientationOffset));
|
|
12792
|
+
return byRoof.get(roof);
|
|
12793
|
+
}
|
|
12794
|
+
function computeRoofCutout(roof, elements, floors, globalOrientationOffset) {
|
|
12795
|
+
const roofs = roofsWallsStandOn(elements, globalOrientationOffset);
|
|
12796
|
+
if (!roofs.some((r) => r.id === roof.id)) return null;
|
|
12797
|
+
const ring = roof.coordinates;
|
|
12798
|
+
const inRoof = (p) => isPointInPolygon2D(p, ring);
|
|
12799
|
+
const standing = [];
|
|
12800
|
+
const segs = [];
|
|
12801
|
+
const deckZ = roof.pitch === 0 ? flatRoofDeckElevationMForTb(roof, floors) : null;
|
|
12802
|
+
const mayStand = (el) => {
|
|
12803
|
+
const bottom = readProfiledLineFace(el.extra_json)?.bottom_profile.map((p) => p.h) ?? [0];
|
|
12804
|
+
if (deckZ === null) return bottom.some((h) => h > ON_ROOF_TOL_M);
|
|
12805
|
+
const foot = elementBaseElevationMForTb(el, floors);
|
|
12806
|
+
return foot + Math.min(...bottom) <= deckZ + ON_ROOF_TOL_M && deckZ <= foot + Math.max(...bottom) + ON_ROOF_TOL_M;
|
|
12807
|
+
};
|
|
12808
|
+
for (const el of elements) {
|
|
12809
|
+
if (!isFootprintWall(el) || !mayStand(el)) continue;
|
|
12810
|
+
const runs = bottomEdgeRoofRuns(el, roofs, floors, globalOrientationOffset).filter((run2) => run2.roof.id === roof.id);
|
|
12811
|
+
if (runs.length === 0) continue;
|
|
12812
|
+
const a = el.coordinates[0];
|
|
12813
|
+
const b = el.coordinates[1];
|
|
12814
|
+
const len2 = Math.hypot(b.x - a.x, b.y - a.y);
|
|
12815
|
+
const left = { x: -(b.y - a.y) / len2, y: (b.x - a.x) / len2 };
|
|
12816
|
+
const probes = runs.flatMap(({ t0, t1 }) => {
|
|
12817
|
+
const tm = (t0 + t1) / 2;
|
|
12818
|
+
const probe = { x: a.x + (b.x - a.x) * tm + left.x * INSIDE_PROBE_M, y: a.y + (b.y - a.y) * tm + left.y * INSIDE_PROBE_M };
|
|
12819
|
+
return inRoof(probe) ? [probe] : [];
|
|
12820
|
+
});
|
|
12821
|
+
if (probes.length === 0) continue;
|
|
12822
|
+
runs.forEach(({ t0, t1 }) => standing.push({ wall: el, t0, t1 }));
|
|
12823
|
+
segs.push({ el, a, b, onRoof: true, probes });
|
|
12824
|
+
}
|
|
12825
|
+
if (segs.length === 0) return null;
|
|
12826
|
+
const issues = [];
|
|
12827
|
+
const names = (list) => [...new Set(list.map((s) => s.el.name))].sort();
|
|
12828
|
+
const branches = branchPoints(segs);
|
|
12829
|
+
if (branches.length > 0) {
|
|
12830
|
+
for (const { at, segs: meeting } of branches) issues.push({ kind: "branch", at, wallNames: names(meeting) });
|
|
12831
|
+
return { polygons: [], planArea: 0, wallNames: [], standing: [], issues };
|
|
12832
|
+
}
|
|
12833
|
+
const firstChains = buildChains(segs);
|
|
12834
|
+
const openEnds = firstChains.flatMap((c) => isClosed(c) ? [] : [c.pts[0], last(c.pts)]);
|
|
12835
|
+
const joins = openEnds.length === 0 ? [] : shortestJoins(openEnds, linkSegments(roof, elements, segs, openEnds, floors, globalOrientationOffset));
|
|
12836
|
+
const usedEnds = /* @__PURE__ */ new Set();
|
|
12837
|
+
const usedLinks = /* @__PURE__ */ new Set();
|
|
12838
|
+
for (const join of joins.sort((x, y) => x.length - y.length || x.i - y.i || x.j - y.j)) {
|
|
12839
|
+
if (usedEnds.has(join.i) || usedEnds.has(join.j) || join.path.some((l) => usedLinks.has(l))) continue;
|
|
12840
|
+
usedEnds.add(join.i);
|
|
12841
|
+
usedEnds.add(join.j);
|
|
12842
|
+
join.path.forEach((l) => usedLinks.add(l));
|
|
12843
|
+
}
|
|
12844
|
+
const allSegs = [...segs, ...usedLinks];
|
|
12845
|
+
const linkBranches = branchPoints(allSegs);
|
|
12846
|
+
if (linkBranches.length > 0) {
|
|
12847
|
+
for (const { at, segs: meeting } of linkBranches) issues.push({ kind: "branch", at, wallNames: names(meeting) });
|
|
12848
|
+
return { polygons: [], planArea: 0, wallNames: [], standing: [], issues };
|
|
12849
|
+
}
|
|
12850
|
+
const stopKind = (end, p) => {
|
|
12851
|
+
if (!inRoof(p) || ringPosition(p, ring).d <= JOIN_TOL_M) return "outline";
|
|
12852
|
+
if (end.seg.onRoof) {
|
|
12853
|
+
const { bottom, top } = lineFaceEdgesAt(end.seg.el, end.t);
|
|
12854
|
+
if (top - bottom <= END_GAP_TOL_M) return "zero";
|
|
12855
|
+
}
|
|
12856
|
+
return null;
|
|
12857
|
+
};
|
|
12858
|
+
const footprints = [];
|
|
12859
|
+
const closingWalls = /* @__PURE__ */ new Set();
|
|
12860
|
+
const loose = [];
|
|
12861
|
+
const accept = (onRoof, pts) => {
|
|
12862
|
+
onRoof.forEach((s) => {
|
|
12863
|
+
closingWalls.add(s);
|
|
12864
|
+
if (s.probes.some((probe) => !isPointInPolygon2D(probe, pts))) issues.push({ kind: "facing", wallNames: [s.el.name] });
|
|
12865
|
+
});
|
|
12866
|
+
footprints.push([pts.map((p) => [p.x, p.y])]);
|
|
12867
|
+
};
|
|
12868
|
+
for (const chain of buildChains(allSegs)) {
|
|
12869
|
+
const onRoof = chain.segs.filter((s) => s.onRoof);
|
|
12870
|
+
if (isClosed(chain)) {
|
|
12871
|
+
accept(onRoof, chain.pts);
|
|
12872
|
+
continue;
|
|
12873
|
+
}
|
|
12874
|
+
const head = chain.pts[0];
|
|
12875
|
+
const tail = last(chain.pts);
|
|
12876
|
+
const ends = [{ wallName: chain.head.seg.el.name, p: head }, { wallName: chain.tail.seg.el.name, p: tail }];
|
|
12877
|
+
const kinds = [stopKind(chain.head, head), stopKind(chain.tail, tail)];
|
|
12878
|
+
if (kinds[0] === null || kinds[1] === null) {
|
|
12879
|
+
kinds.forEach((k, n) => {
|
|
12880
|
+
if (k === null) loose.push({ ...ends[n], chainWalls: names(onRoof) });
|
|
12881
|
+
});
|
|
12882
|
+
continue;
|
|
12883
|
+
}
|
|
12884
|
+
if (kinds[0] !== kinds[1]) {
|
|
12885
|
+
issues.push({ kind: "mixed", ends, wallNames: names(onRoof) });
|
|
12886
|
+
continue;
|
|
12887
|
+
}
|
|
12888
|
+
if (kinds[0] === "zero") {
|
|
12889
|
+
const closed = closeUnderRoofsAbove(chain, roofs.filter((r) => r.id !== roof.id), floors, globalOrientationOffset);
|
|
12890
|
+
if (closed) accept(onRoof, closed);
|
|
12891
|
+
else issues.push({ kind: "noRoofAbove", ends, wallNames: names(onRoof) });
|
|
12892
|
+
continue;
|
|
12893
|
+
}
|
|
12894
|
+
const pts = cutHeadAtRing([...cutHeadAtRing(chain.pts, ring)].reverse(), ring).reverse();
|
|
12895
|
+
const from = ringPosition(last(pts), ring).s;
|
|
12896
|
+
const to = ringPosition(pts[0], ring).s;
|
|
12897
|
+
const probes = onRoof.flatMap((s) => s.probes);
|
|
12898
|
+
const ways = [1, -1].map((dir) => {
|
|
12899
|
+
const polygon = [...pts, ...ringVerticesBetween(ring, from, to, dir)];
|
|
12900
|
+
return { polygon, inside: probes.filter((probe) => isPointInPolygon2D(probe, polygon)).length };
|
|
12901
|
+
});
|
|
12902
|
+
if (ways[0].inside === ways[1].inside) {
|
|
12903
|
+
issues.push({ kind: "side", ends, wallNames: names(onRoof) });
|
|
12904
|
+
continue;
|
|
12905
|
+
}
|
|
12906
|
+
accept(onRoof, ways[0].inside > ways[1].inside ? ways[0].polygon : ways[1].polygon);
|
|
12907
|
+
}
|
|
12908
|
+
while (loose.length > 0) {
|
|
12909
|
+
const a = loose.shift();
|
|
12910
|
+
let k = -1;
|
|
12911
|
+
loose.forEach((b2, i) => {
|
|
12912
|
+
if (k < 0 || Math.hypot(b2.p.x - a.p.x, b2.p.y - a.p.y) < Math.hypot(loose[k].p.x - a.p.x, loose[k].p.y - a.p.y)) k = i;
|
|
12913
|
+
});
|
|
12914
|
+
const b = k >= 0 ? loose.splice(k, 1)[0] : null;
|
|
12915
|
+
issues.push({
|
|
12916
|
+
kind: "gap",
|
|
12917
|
+
wallNames: [.../* @__PURE__ */ new Set([...a.chainWalls, ...b?.chainWalls ?? []])].sort(),
|
|
12918
|
+
ends: b ? [{ wallName: a.wallName, p: a.p }, { wallName: b.wallName, p: b.p }] : [{ wallName: a.wallName, p: a.p }]
|
|
12919
|
+
});
|
|
12920
|
+
}
|
|
12921
|
+
const polygons = footprints.length === 0 ? [] : import_polygon_clipping3.default.intersection(import_polygon_clipping3.default.union(...footprints), [ring.map((p) => [p.x, p.y])]);
|
|
12922
|
+
const planArea = polygons.reduce((sum, polygon) => sum + polygon.reduce((s, r, k) => {
|
|
12923
|
+
const a = calculatePolygonArea(r.map(([x, y]) => ({ x, y, z: 0 })));
|
|
12924
|
+
return k === 0 ? s + a : s - a;
|
|
12925
|
+
}, 0), 0);
|
|
12926
|
+
const closing = planArea > 1e-6 ? [...closingWalls] : [];
|
|
12927
|
+
return {
|
|
12928
|
+
polygons,
|
|
12929
|
+
planArea,
|
|
12930
|
+
wallNames: names(closing),
|
|
12931
|
+
standing: standing.filter((s) => closing.some((c) => c.el === s.wall)),
|
|
12932
|
+
issues
|
|
12933
|
+
};
|
|
12934
|
+
}
|
|
12935
|
+
|
|
12243
12936
|
// ../community/packages/geometry-editor/src/lib/unheatedPitchedRoofCeiling.ts
|
|
12244
12937
|
var UNHEATED_PITCHED_ROOF_CEILING_ELEVATION_KEY = "unheated_pitched_roof_ceiling_elevation";
|
|
12245
12938
|
var ROOF_WALL_PLAN_INTERSECTION_TOL_M = 0.35;
|
|
@@ -12428,11 +13121,48 @@ function getElementBaseElevation(element, floorElevations, floorZLookup) {
|
|
|
12428
13121
|
if (viewer !== void 0) return viewer;
|
|
12429
13122
|
return floorElevations.get(floorZ) ?? 0;
|
|
12430
13123
|
}
|
|
13124
|
+
function getTopOfStoreyElevationM(floorZ, floors, floorElevations) {
|
|
13125
|
+
const bottom = floorElevations.get(floorZ) ?? 0;
|
|
13126
|
+
const floorDef = floors.find((f) => f.zIndex === floorZ);
|
|
13127
|
+
return bottom + (floorDef?.height ?? 0);
|
|
13128
|
+
}
|
|
13129
|
+
function isRoofLikePlanarOpaque(element, planarByZ) {
|
|
13130
|
+
return planarByZ && isRoofLikeOpaqueElement(element);
|
|
13131
|
+
}
|
|
13132
|
+
function isPitchSlopedSurface(element) {
|
|
13133
|
+
const pitch = element.pitch;
|
|
13134
|
+
return isFiniteNumber2(pitch) && pitch > 0 && pitch < 90;
|
|
13135
|
+
}
|
|
13136
|
+
function getOpaquePolygonBaseElevationM(element, floorElevations, floors, planarByZ, floorZLookup) {
|
|
13137
|
+
const floorZ = getElementFloorZ(element, floorZLookup);
|
|
13138
|
+
const rawBaseHeight = element.base_height;
|
|
13139
|
+
const unset = !isFiniteNumber2(rawBaseHeight) || rawBaseHeight === 0;
|
|
13140
|
+
if (planarByZ && isPitchSlopedSurface(element) && unset) {
|
|
13141
|
+
return floorElevations.get(floorZ) ?? 0;
|
|
13142
|
+
}
|
|
13143
|
+
if (isRoofLikePlanarOpaque(element, planarByZ)) {
|
|
13144
|
+
if (unset) {
|
|
13145
|
+
return getTopOfStoreyElevationM(floorZ, floors, floorElevations);
|
|
13146
|
+
}
|
|
13147
|
+
return rawBaseHeight;
|
|
13148
|
+
}
|
|
13149
|
+
return getElementBaseElevation(element, floorElevations, floorZLookup);
|
|
13150
|
+
}
|
|
13151
|
+
function isPlanarAtSingleZ(element) {
|
|
13152
|
+
if (!Array.isArray(element.coordinates) || element.coordinates.length < 3) return false;
|
|
13153
|
+
const zValues = element.coordinates.map((coord) => coord?.z).filter((z) => isFiniteNumber2(z));
|
|
13154
|
+
if (zValues.length < 3) return false;
|
|
13155
|
+
const first = zValues[0];
|
|
13156
|
+
return zValues.every((z) => Math.abs(z - first) < 1e-6);
|
|
13157
|
+
}
|
|
12431
13158
|
function elementBaseElevationMForTb(element, floors) {
|
|
12432
13159
|
const floorElevations = getFloorElevations(floors);
|
|
12433
13160
|
const floorZLookup = getFloorZLookup(floors);
|
|
12434
13161
|
return getElementBaseElevation(element, floorElevations, floorZLookup);
|
|
12435
13162
|
}
|
|
13163
|
+
function opaquePolygonBaseElevationMForTb(element, floors) {
|
|
13164
|
+
return getOpaquePolygonBaseElevationM(element, getFloorElevations(floors), floors, isPlanarAtSingleZ(element), getFloorZLookup(floors));
|
|
13165
|
+
}
|
|
12436
13166
|
function elementFloorZIndexForTb(element, floors) {
|
|
12437
13167
|
if (!physicalZUsesFloorId(element)) {
|
|
12438
13168
|
const floorId = element.floorId?.trim();
|
|
@@ -12550,14 +13280,19 @@ function collectWallSegments(elements) {
|
|
|
12550
13280
|
if (h <= 0) continue;
|
|
12551
13281
|
const ori = el.orientation360;
|
|
12552
13282
|
const pi = el.pitch;
|
|
13283
|
+
const foot = wallBaseElevationM(el);
|
|
13284
|
+
const spanAt = (t) => {
|
|
13285
|
+
const { bottom, top } = lineFaceEdgesAt(el, t);
|
|
13286
|
+
return { zBase: foot + bottom, height: top - bottom };
|
|
13287
|
+
};
|
|
12553
13288
|
out.push({
|
|
12554
13289
|
id: el.id,
|
|
12555
13290
|
name: el.name,
|
|
12556
13291
|
zoneId: el.zoneId,
|
|
12557
13292
|
k0,
|
|
12558
13293
|
k1,
|
|
12559
|
-
|
|
12560
|
-
|
|
13294
|
+
span0: spanAt(0),
|
|
13295
|
+
span1: spanAt(1),
|
|
12561
13296
|
orientation360: typeof ori === "number" && Number.isFinite(ori) ? ori : void 0,
|
|
12562
13297
|
pitch: typeof pi === "number" && Number.isFinite(pi) ? pi : void 0
|
|
12563
13298
|
});
|
|
@@ -12616,14 +13351,15 @@ function dedupeParallelWallSegmentsInPlan(segments) {
|
|
|
12616
13351
|
map.set(key, { ...s });
|
|
12617
13352
|
continue;
|
|
12618
13353
|
}
|
|
12619
|
-
const
|
|
12620
|
-
|
|
12621
|
-
|
|
12622
|
-
|
|
13354
|
+
const union = (a, b) => {
|
|
13355
|
+
const zBase = Math.min(a.zBase, b.zBase);
|
|
13356
|
+
const zTop = Math.max(a.zBase + a.height, b.zBase + b.height);
|
|
13357
|
+
return { zBase, height: zTop - zBase };
|
|
13358
|
+
};
|
|
12623
13359
|
map.set(key, {
|
|
12624
13360
|
...prev,
|
|
12625
|
-
|
|
12626
|
-
|
|
13361
|
+
span0: union(prev.span0, spanAtKey(s, prev.k0)),
|
|
13362
|
+
span1: union(prev.span1, spanAtKey(s, prev.k1)),
|
|
12627
13363
|
orientation360: typeof prev.orientation360 === "number" && Number.isFinite(prev.orientation360) ? prev.orientation360 : typeof s.orientation360 === "number" && Number.isFinite(s.orientation360) ? s.orientation360 : prev.orientation360,
|
|
12628
13364
|
pitch: typeof prev.pitch === "number" && Number.isFinite(prev.pitch) ? prev.pitch : typeof s.pitch === "number" && Number.isFinite(s.pitch) ? s.pitch : prev.pitch
|
|
12629
13365
|
});
|
|
@@ -12690,6 +13426,9 @@ function geometricOutwardRightOfDirectedEdge(from, to) {
|
|
|
12690
13426
|
if (len2 < 1e-12) return { x: 0, y: 0 };
|
|
12691
13427
|
return { x: ty / len2, y: -tx / len2 };
|
|
12692
13428
|
}
|
|
13429
|
+
function spanAtKey(s, k) {
|
|
13430
|
+
return k === s.k0 ? s.span0 : s.span1;
|
|
13431
|
+
}
|
|
12693
13432
|
function segmentForKeys(comp, ka, kb) {
|
|
12694
13433
|
return comp.find((s) => s.k0 === ka && s.k1 === kb || s.k0 === kb && s.k1 === ka);
|
|
12695
13434
|
}
|
|
@@ -12812,25 +13551,27 @@ function polygonSignedAreaFromKeys(keys) {
|
|
|
12812
13551
|
}
|
|
12813
13552
|
return a / 2;
|
|
12814
13553
|
}
|
|
12815
|
-
function verticalOverlapForCornerWallSegs(a, b) {
|
|
12816
|
-
const
|
|
12817
|
-
const
|
|
12818
|
-
const
|
|
13554
|
+
function verticalOverlapForCornerWallSegs(a, b, k) {
|
|
13555
|
+
const sa = spanAtKey(a, k);
|
|
13556
|
+
const sb = spanAtKey(b, k);
|
|
13557
|
+
const zTopA = sa.zBase + sa.height;
|
|
13558
|
+
const zTopB = sb.zBase + sb.height;
|
|
13559
|
+
const z0 = Math.max(sa.zBase, sb.zBase);
|
|
12819
13560
|
const z1 = Math.min(zTopA, zTopB);
|
|
12820
13561
|
if (!Number.isFinite(z0) || !Number.isFinite(z1) || z1 - z0 < MIN_CORNER_VERTICAL_OVERLAP_M) {
|
|
12821
13562
|
return null;
|
|
12822
13563
|
}
|
|
12823
13564
|
return { z0, z1 };
|
|
12824
13565
|
}
|
|
12825
|
-
function cornersFromOrderedPolyline(keys,
|
|
13566
|
+
function cornersFromOrderedPolyline(keys, isClosed2, sub2, zoneId) {
|
|
12826
13567
|
const proposals = [];
|
|
12827
13568
|
const n = keys.length;
|
|
12828
|
-
const lastIdx =
|
|
12829
|
-
const startIdx =
|
|
13569
|
+
const lastIdx = isClosed2 ? n : n - 1;
|
|
13570
|
+
const startIdx = isClosed2 ? 0 : 1;
|
|
12830
13571
|
for (let i = startIdx; i < lastIdx; i++) {
|
|
12831
13572
|
const k = keys[i];
|
|
12832
|
-
const pk =
|
|
12833
|
-
const qk =
|
|
13573
|
+
const pk = isClosed2 ? keys[(i - 1 + n) % n] : keys[i - 1];
|
|
13574
|
+
const qk = isClosed2 ? keys[(i + 1) % n] : keys[i + 1];
|
|
12834
13575
|
const p = parseKey(pk);
|
|
12835
13576
|
const c = parseKey(k);
|
|
12836
13577
|
const q = parseKey(qk);
|
|
@@ -12842,7 +13583,7 @@ function cornersFromOrderedPolyline(keys, isClosed, sub2, zoneId) {
|
|
|
12842
13583
|
const segPk = segmentForKeys(sub2, pk, k);
|
|
12843
13584
|
const segKq = segmentForKeys(sub2, k, qk);
|
|
12844
13585
|
if (!segPk || !segKq) continue;
|
|
12845
|
-
const overlap = verticalOverlapForCornerWallSegs(segPk, segKq);
|
|
13586
|
+
const overlap = verticalOverlapForCornerWallSegs(segPk, segKq, k);
|
|
12846
13587
|
if (!overlap) continue;
|
|
12847
13588
|
const { z0, z1 } = overlap;
|
|
12848
13589
|
const wallName = segPk.name ?? "Wall";
|
|
@@ -12935,7 +13676,7 @@ function proposeExternalCornerThermalBridges(elements) {
|
|
|
12935
13676
|
seenCorners.add(sig);
|
|
12936
13677
|
const code = convex ? "E16" : "E17";
|
|
12937
13678
|
const role = convex ? "external_corner_convex" : "external_corner_reentrant";
|
|
12938
|
-
const overlap = verticalOverlapForCornerWallSegs(s1, s2);
|
|
13679
|
+
const overlap = verticalOverlapForCornerWallSegs(s1, s2, Vkey);
|
|
12939
13680
|
if (!overlap) continue;
|
|
12940
13681
|
const { z0, z1 } = overlap;
|
|
12941
13682
|
proposals.push({
|
|
@@ -12979,7 +13720,7 @@ var Z_BAND_EPS_M = 0.04;
|
|
|
12979
13720
|
function dist2XY(a, b) {
|
|
12980
13721
|
return Math.hypot(a.x - b.x, a.y - b.y);
|
|
12981
13722
|
}
|
|
12982
|
-
function
|
|
13723
|
+
function zonesCompatible2(a, b) {
|
|
12983
13724
|
if (a !== void 0 && b !== void 0 && a !== b) return false;
|
|
12984
13725
|
return true;
|
|
12985
13726
|
}
|
|
@@ -13038,26 +13779,21 @@ function adjacentBaseElevationLegacy(a) {
|
|
|
13038
13779
|
const z1 = typeof coords[1]?.z === "number" && Number.isFinite(coords[1].z) ? coords[1].z : 0;
|
|
13039
13780
|
return Math.min(z0, z1);
|
|
13040
13781
|
}
|
|
13041
|
-
function
|
|
13042
|
-
const
|
|
13043
|
-
|
|
13044
|
-
const zLo2 = elementBaseElevationMForTb(wall, floors);
|
|
13045
|
-
return { zLo: zLo2, zHi: zLo2 + h };
|
|
13046
|
-
}
|
|
13047
|
-
const zLo = opaqueWallBaseElevationLegacy(wall);
|
|
13048
|
-
return { zLo, zHi: zLo + h };
|
|
13782
|
+
function lineVerticalExtentM(el, foot) {
|
|
13783
|
+
const { bottom, top } = lineFaceEnvelope(el);
|
|
13784
|
+
return { zLo: foot + bottom, zHi: foot + top, foot };
|
|
13049
13785
|
}
|
|
13050
13786
|
function adjacentVerticalExtentM(adj, floors) {
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
}
|
|
13056
|
-
const zLo = adjacentBaseElevationLegacy(adj);
|
|
13057
|
-
return { zLo, zHi: zLo + h };
|
|
13787
|
+
return lineVerticalExtentM(
|
|
13788
|
+
adj,
|
|
13789
|
+
floors && floors.length > 0 ? elementBaseElevationMForTb(adj, floors) : adjacentBaseElevationLegacy(adj)
|
|
13790
|
+
);
|
|
13058
13791
|
}
|
|
13059
13792
|
function opaqueEnvelopeVerticalExtentM(wall, floors) {
|
|
13060
|
-
return
|
|
13793
|
+
return lineVerticalExtentM(
|
|
13794
|
+
wall,
|
|
13795
|
+
floors && floors.length > 0 ? elementBaseElevationMForTb(wall, floors) : opaqueWallBaseElevationLegacy(wall)
|
|
13796
|
+
);
|
|
13061
13797
|
}
|
|
13062
13798
|
function adjacentEnvelopeVerticalExtentM(adj, floors) {
|
|
13063
13799
|
return adjacentVerticalExtentM(adj, floors);
|
|
@@ -13137,12 +13873,12 @@ function proposeAdjacentWallJunctionThermalBridges(elements, floors) {
|
|
|
13137
13873
|
const W = wall.coordinates;
|
|
13138
13874
|
const Wa = W[0];
|
|
13139
13875
|
const Wb = W[1];
|
|
13140
|
-
const wExt =
|
|
13876
|
+
const wExt = opaqueEnvelopeVerticalExtentM(wall, floors);
|
|
13141
13877
|
for (const adj of unconditionedFloors) {
|
|
13142
|
-
if (!
|
|
13878
|
+
if (!zonesCompatible2(wall.zoneId, adj.zoneId)) continue;
|
|
13143
13879
|
if (elementFloorZIndexForTb(adj, floors) < 0) continue;
|
|
13144
13880
|
const slabZ = elementBaseElevationMForTb(adj, floors);
|
|
13145
|
-
if (Math.abs(slabZ - wExt.
|
|
13881
|
+
if (Math.abs(slabZ - wExt.foot) > Z_BAND_EPS_M) continue;
|
|
13146
13882
|
const A = adj.coordinates;
|
|
13147
13883
|
const overlap = planOverlapAdjacentOnWall(Wa, Wb, A[0], A[1]);
|
|
13148
13884
|
if (!overlap) continue;
|
|
@@ -13150,31 +13886,33 @@ function proposeAdjacentWallJunctionThermalBridges(elements, floors) {
|
|
|
13150
13886
|
const zLo = Math.max(wExt.zLo, aExt.zLo);
|
|
13151
13887
|
const zHi = Math.min(wExt.zHi, aExt.zHi);
|
|
13152
13888
|
if (zHi - zLo < MIN_VERTICAL_OVERLAP_M) continue;
|
|
13153
|
-
const
|
|
13154
|
-
|
|
13155
|
-
|
|
13156
|
-
|
|
13157
|
-
|
|
13158
|
-
|
|
13159
|
-
|
|
13160
|
-
|
|
13161
|
-
|
|
13162
|
-
|
|
13163
|
-
|
|
13164
|
-
|
|
13165
|
-
|
|
13166
|
-
|
|
13167
|
-
|
|
13168
|
-
|
|
13169
|
-
|
|
13170
|
-
|
|
13171
|
-
|
|
13172
|
-
|
|
13173
|
-
|
|
13174
|
-
|
|
13175
|
-
|
|
13176
|
-
|
|
13177
|
-
|
|
13889
|
+
for (const [tLo, tHi] of lineFaceRunsAtHeight(wall, overlap.wallLen, overlap.tLo, overlap.tHi, slabZ - wExt.foot, Z_BAND_EPS_M)) {
|
|
13890
|
+
const a = pointOnWallAtT(Wa, Wb, tLo, overlap.wallLen);
|
|
13891
|
+
const b = pointOnWallAtT(Wa, Wb, tHi, overlap.wallLen);
|
|
13892
|
+
const L = dist2XY(a, b);
|
|
13893
|
+
if (L < MIN_PLAN_OVERLAP_M) continue;
|
|
13894
|
+
const z = roundToTwoDecimals(slabZ);
|
|
13895
|
+
const junctionCode = "E20";
|
|
13896
|
+
out.push({
|
|
13897
|
+
proposalId: `e20:${wall.id}:${adj.id}:${roundToTwoDecimals(tLo)}`,
|
|
13898
|
+
openingId: adj.id,
|
|
13899
|
+
openingName: `${adj.name} \u2194 ${wall.name}`,
|
|
13900
|
+
zoneId: wall.zoneId ?? adj.zoneId,
|
|
13901
|
+
edgeRole: "unheated_adjacent_wall_junction",
|
|
13902
|
+
junctionCode,
|
|
13903
|
+
suggestedLengthM: roundToTwoDecimals(L),
|
|
13904
|
+
linearThermalTransmittance: psiTable37ForCode(junctionCode),
|
|
13905
|
+
reason: `E20 exposed floor (normal) with external wall: unheated horizontal run "${adj.name}" \xD7 "${wall.name}" (plan ${roundToTwoDecimals(
|
|
13906
|
+
tHi - tLo
|
|
13907
|
+
)} m at ${z} m); use E21 if inverted`,
|
|
13908
|
+
coordinates: [
|
|
13909
|
+
{ x: roundToTwoDecimals(a.x), y: roundToTwoDecimals(a.y), z },
|
|
13910
|
+
{ x: roundToTwoDecimals(b.x), y: roundToTwoDecimals(b.y), z }
|
|
13911
|
+
],
|
|
13912
|
+
parentElementForTb: wall.name,
|
|
13913
|
+
hostElementIds: [wall.id, adj.id]
|
|
13914
|
+
});
|
|
13915
|
+
}
|
|
13178
13916
|
}
|
|
13179
13917
|
}
|
|
13180
13918
|
return out;
|
|
@@ -13243,69 +13981,6 @@ function proposeBasementGroundE22ThermalBridges(elements, floors) {
|
|
|
13243
13981
|
return out;
|
|
13244
13982
|
}
|
|
13245
13983
|
|
|
13246
|
-
// ../community/packages/geometry-editor/src/lib/roofTopElevationAtPlanM.ts
|
|
13247
|
-
function roofBaseElevationM(roof, floors) {
|
|
13248
|
-
if (floors && floors.length > 0) {
|
|
13249
|
-
return elementBaseElevationMForTb(roof, floors);
|
|
13250
|
-
}
|
|
13251
|
-
const c = roof.coordinates;
|
|
13252
|
-
if (!c?.length) return 0;
|
|
13253
|
-
const bh = roof.base_height;
|
|
13254
|
-
if (typeof bh === "number" && Number.isFinite(bh) && bh >= 0) return bh;
|
|
13255
|
-
return Math.min(...c.map((p) => typeof p.z === "number" && Number.isFinite(p.z) ? p.z : 0));
|
|
13256
|
-
}
|
|
13257
|
-
function inwardNormal2DStripLeftOfDirectedEdge(roof) {
|
|
13258
|
-
const c = roof.coordinates;
|
|
13259
|
-
if (!c || c.length < 2) return null;
|
|
13260
|
-
const ax = c[0].x;
|
|
13261
|
-
const ay = c[0].y;
|
|
13262
|
-
const bx = c[1].x;
|
|
13263
|
-
const by = c[1].y;
|
|
13264
|
-
const ex = bx - ax;
|
|
13265
|
-
const ey = by - ay;
|
|
13266
|
-
const len2 = Math.hypot(ex, ey);
|
|
13267
|
-
if (len2 < 1e-9) return null;
|
|
13268
|
-
const nx = -ey / len2;
|
|
13269
|
-
const ny = ex / len2;
|
|
13270
|
-
return [nx, ny];
|
|
13271
|
-
}
|
|
13272
|
-
function inwardNormal2DForSlopedRoof(roof, globalOrientationOffset) {
|
|
13273
|
-
const c = roof.coordinates;
|
|
13274
|
-
if (!c || c.length < 2) return null;
|
|
13275
|
-
if (c.length >= 3) {
|
|
13276
|
-
const planPts = c.map((p) => [p.x, p.y]);
|
|
13277
|
-
const orientationAxis = isOrientationPitchAxis(roof);
|
|
13278
|
-
if (orientationAxis && !Number.isFinite(globalOrientationOffset)) return null;
|
|
13279
|
-
return slopedPolygonPlaneBasis(
|
|
13280
|
-
planPts,
|
|
13281
|
-
orientationAxis ? "orientation" : "bottom-edge",
|
|
13282
|
-
roof.orientation360 ?? 0,
|
|
13283
|
-
globalOrientationOffset ?? 0
|
|
13284
|
-
)?.upslope2D ?? null;
|
|
13285
|
-
}
|
|
13286
|
-
return inwardNormal2DStripLeftOfDirectedEdge(roof);
|
|
13287
|
-
}
|
|
13288
|
-
function roofTopElevationAtPlanM(roof, x, y, floors, globalOrientationOffset) {
|
|
13289
|
-
const c = roof.coordinates;
|
|
13290
|
-
if (!c || c.length < 2) return null;
|
|
13291
|
-
const pitch = roof.pitch;
|
|
13292
|
-
if (typeof pitch !== "number" || !Number.isFinite(pitch) || pitch <= 0 || pitch >= 90) return null;
|
|
13293
|
-
const orientationAxis = isOrientationPitchAxis(roof);
|
|
13294
|
-
if (orientationAxis && !Number.isFinite(globalOrientationOffset)) return null;
|
|
13295
|
-
const points = c.map((point) => [point.x, point.y]);
|
|
13296
|
-
const basis = c.length >= 3 ? slopedPolygonPlaneBasis(
|
|
13297
|
-
points,
|
|
13298
|
-
orientationAxis ? "orientation" : "bottom-edge",
|
|
13299
|
-
roof.orientation360 ?? 0,
|
|
13300
|
-
globalOrientationOffset ?? 0
|
|
13301
|
-
) : null;
|
|
13302
|
-
const inward = basis?.upslope2D ?? inwardNormal2DForSlopedRoof(roof, globalOrientationOffset);
|
|
13303
|
-
if (!inward) return null;
|
|
13304
|
-
const baseEl = roofBaseElevationM(roof, floors);
|
|
13305
|
-
const anchor = basis?.anchorXY ?? [c[0].x, c[0].y];
|
|
13306
|
-
return elevationAtSlopedVertexM([x, y], anchor, inward, baseEl, pitch);
|
|
13307
|
-
}
|
|
13308
|
-
|
|
13309
13984
|
// ../community/packages/geometry-editor/src/geometry/thermalBridge/tbLinkage.ts
|
|
13310
13985
|
function distPointToSegmentXY(px, py, ax, ay, bx, by) {
|
|
13311
13986
|
const abx = bx - ax;
|
|
@@ -13323,6 +13998,7 @@ function distPointToSegmentXY(px, py, ax, ay, bx, by) {
|
|
|
13323
13998
|
}
|
|
13324
13999
|
|
|
13325
14000
|
// ../community/packages/geometry-editor/src/geometry/thermalBridge/proposeFacadeOpenings.ts
|
|
14001
|
+
var last2 = (list) => list[list.length - 1];
|
|
13326
14002
|
var SKIP_SILL_THERMAL_BRIDGE_BELOW_Z_M = 0.08;
|
|
13327
14003
|
var Z_MATCH_EPS = 1e-4;
|
|
13328
14004
|
function isFiniteNonNegative(n) {
|
|
@@ -13494,23 +14170,47 @@ function appendFacadeOpeningThermalBridgeProposalsForHost(t, elements, floors, u
|
|
|
13494
14170
|
const width = typeof t.width === "number" && t.width > 0 ? t.width : geomWidthM;
|
|
13495
14171
|
const height = typeof t.height === "number" && t.height > 0 ? t.height : 0;
|
|
13496
14172
|
const zTop = zSill + height;
|
|
13497
|
-
const
|
|
13498
|
-
const
|
|
13499
|
-
const
|
|
13500
|
-
const
|
|
14173
|
+
const horizontalLengthM = geomWidthM > 0 ? geomWidthM : width;
|
|
14174
|
+
const face = readProfiledLineFace(t.extra_json);
|
|
14175
|
+
const topEdge = face && normalizeProfilePoints(face.top_profile);
|
|
14176
|
+
const bottomEdge = face && normalizeProfilePoints(face.bottom_profile);
|
|
14177
|
+
const shaped = topEdge && bottomEdge ? { top: topEdge, bottom: bottomEdge } : null;
|
|
14178
|
+
const edgeRuns = (edge) => {
|
|
14179
|
+
const at = (p) => ({ x: p0.x + (p1.x - p0.x) * p.t, y: p0.y + (p1.y - p0.y) * p.t, z: zSill + p.h });
|
|
14180
|
+
const runs = [];
|
|
14181
|
+
const bends = edge.filter((p, k) => {
|
|
14182
|
+
if (k === 0 || k === edge.length - 1) return true;
|
|
14183
|
+
const [a, b] = [edge[k - 1], edge[k + 1]];
|
|
14184
|
+
return Math.abs(a.h + (b.h - a.h) * (p.t - a.t) / (b.t - a.t) - p.h) > 1e-6;
|
|
14185
|
+
});
|
|
14186
|
+
for (let k = 1; k < bends.length; k += 1) {
|
|
14187
|
+
const [a, b] = [at(bends[k - 1]), at(bends[k])];
|
|
14188
|
+
const length = Math.hypot(b.x - a.x, b.y - a.y, b.z - a.z);
|
|
14189
|
+
if (length > 1e-6) runs.push({ coords: [a, b], length });
|
|
14190
|
+
}
|
|
14191
|
+
return runs;
|
|
14192
|
+
};
|
|
14193
|
+
const sillA = { x: p0.x, y: p0.y, z: shaped ? zSill + shaped.bottom[0].h : zSill };
|
|
14194
|
+
const sillB = { x: p1.x, y: p1.y, z: shaped ? zSill + last2(shaped.bottom).h : zSill };
|
|
14195
|
+
const headA = { x: p0.x, y: p0.y, z: shaped ? zSill + shaped.top[0].h : zTop };
|
|
14196
|
+
const headB = { x: p1.x, y: p1.y, z: shaped ? zSill + last2(shaped.top).h : zTop };
|
|
13501
14197
|
const jambFirstBottom = sillA;
|
|
13502
14198
|
const jambFirstTop = headA;
|
|
13503
14199
|
const jambSecondBottom = sillB;
|
|
13504
14200
|
const jambSecondTop = headB;
|
|
13505
14201
|
const usesUnheatedBasementWallFloor = useIntermediateWallFloor && unheatedBasementWallFloorTargetM !== null && Math.abs(zSill - unheatedBasementWallFloorTargetM) <= SKIP_SILL_THERMAL_BRIDGE_BELOW_Z_M;
|
|
13506
|
-
const horizontalLengthM = geomWidthM > 0 ? geomWidthM : width;
|
|
13507
14202
|
const roles = [
|
|
13508
|
-
{
|
|
14203
|
+
...shaped ? edgeRuns(shaped.top).map((run2, k) => ({
|
|
14204
|
+
role: "lintel",
|
|
14205
|
+
id: `lintel:${k}`,
|
|
14206
|
+
...run2,
|
|
14207
|
+
reason: `Lintel run along part ${k + 1} of the shaped top of opening "${t.name}"`
|
|
14208
|
+
})) : [{
|
|
13509
14209
|
role: "lintel",
|
|
13510
14210
|
coords: [headA, headB],
|
|
13511
14211
|
length: horizontalLengthM,
|
|
13512
14212
|
reason: `Lintel run along top of opening "${t.name}" (segment length in plan)`
|
|
13513
|
-
},
|
|
14213
|
+
}],
|
|
13514
14214
|
...useIntermediateWallFloor ? [
|
|
13515
14215
|
{
|
|
13516
14216
|
role: "wall_intermediate_floor_foot",
|
|
@@ -13527,7 +14227,12 @@ function appendFacadeOpeningThermalBridgeProposalsForHost(t, elements, floors, u
|
|
|
13527
14227
|
reason: `Wall\u2013floor junction under "${t.name}" (E5 replaces E3 sill where opening meets ground)`,
|
|
13528
14228
|
parentElementForTb: hostWall
|
|
13529
14229
|
}
|
|
13530
|
-
] :
|
|
14230
|
+
] : shaped ? edgeRuns(shaped.bottom).map((run2, k) => ({
|
|
14231
|
+
role: "sill",
|
|
14232
|
+
id: `sill:${k}`,
|
|
14233
|
+
...run2,
|
|
14234
|
+
reason: `Sill along part ${k + 1} of the shaped bottom of opening "${t.name}"`
|
|
14235
|
+
})) : [
|
|
13531
14236
|
{
|
|
13532
14237
|
role: "sill",
|
|
13533
14238
|
coords: [sillA, sillB],
|
|
@@ -13538,20 +14243,21 @@ function appendFacadeOpeningThermalBridgeProposalsForHost(t, elements, floors, u
|
|
|
13538
14243
|
{
|
|
13539
14244
|
role: "jamb_first",
|
|
13540
14245
|
coords: [jambFirstBottom, jambFirstTop],
|
|
13541
|
-
length: height,
|
|
14246
|
+
length: shaped ? headA.z - sillA.z : height,
|
|
13542
14247
|
reason: jambReason(t.name, "first", usedBaseHeight, z0, z1)
|
|
13543
14248
|
},
|
|
13544
14249
|
{
|
|
13545
14250
|
role: "jamb_second",
|
|
13546
14251
|
coords: [jambSecondBottom, jambSecondTop],
|
|
13547
|
-
length: height,
|
|
14252
|
+
length: shaped ? headB.z - sillB.z : height,
|
|
13548
14253
|
reason: jambReason(t.name, "second", usedBaseHeight, z0, z1)
|
|
13549
14254
|
}
|
|
13550
14255
|
];
|
|
13551
14256
|
for (const row of roles) {
|
|
14257
|
+
if (shaped && row.length <= 1e-6) continue;
|
|
13552
14258
|
const code = defaultJunctionCodeForEdge(row.role);
|
|
13553
14259
|
const proposal = {
|
|
13554
|
-
proposalId: `${t.id}:${row.role}`,
|
|
14260
|
+
proposalId: `${t.id}:${row.id ?? row.role}`,
|
|
13555
14261
|
openingId: t.id,
|
|
13556
14262
|
openingName: t.name,
|
|
13557
14263
|
zoneId: t.zoneId,
|
|
@@ -13619,22 +14325,12 @@ var MIN_WALL = 0.05;
|
|
|
13619
14325
|
function dist2XY4(a, b) {
|
|
13620
14326
|
return Math.hypot(a.x - b.x, a.y - b.y);
|
|
13621
14327
|
}
|
|
13622
|
-
function partyBaseLegacy(p) {
|
|
13623
|
-
const c = p.coordinates;
|
|
13624
|
-
const z0 = typeof c[0]?.z === "number" && Number.isFinite(c[0].z) ? c[0].z : 0;
|
|
13625
|
-
const z1 = typeof c[1]?.z === "number" && Number.isFinite(c[1].z) ? c[1].z : 0;
|
|
13626
|
-
const bh = p.base_height;
|
|
13627
|
-
if (typeof bh === "number" && Number.isFinite(bh) && bh >= 0) return bh;
|
|
13628
|
-
return Math.min(z0, z1);
|
|
13629
|
-
}
|
|
13630
14328
|
function partyWallVerticalExtentM(p, floors) {
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
}
|
|
13636
|
-
const zLo = partyBaseLegacy(p);
|
|
13637
|
-
return { zLo, zHi: zLo + h };
|
|
14329
|
+
return opaqueEnvelopeVerticalExtentM(p, floors);
|
|
14330
|
+
}
|
|
14331
|
+
function verticalExtentAtPointM(el, ext, p) {
|
|
14332
|
+
const { bottom, top } = lineFaceEdgesAtPoint(el, p);
|
|
14333
|
+
return { zLo: ext.foot + bottom, zHi: ext.foot + top };
|
|
13638
14334
|
}
|
|
13639
14335
|
function isPartyWallVerticalEnvelopeLine(el) {
|
|
13640
14336
|
if (el.type !== "BuildingElementPartyWall") return false;
|
|
@@ -13647,19 +14343,6 @@ function isPartyWallVerticalEnvelopeLine(el) {
|
|
|
13647
14343
|
if (typeof el.height !== "number" || el.height < MIN_PLAN) return false;
|
|
13648
14344
|
return true;
|
|
13649
14345
|
}
|
|
13650
|
-
function wallVerticalExtentM2(wall, floors) {
|
|
13651
|
-
const h = typeof wall.height === "number" && wall.height > 0 ? wall.height : 0;
|
|
13652
|
-
if (floors && floors.length > 0) {
|
|
13653
|
-
const zLo2 = elementBaseElevationMForTb(wall, floors);
|
|
13654
|
-
return { zLo: zLo2, zHi: zLo2 + h };
|
|
13655
|
-
}
|
|
13656
|
-
const c = wall.coordinates;
|
|
13657
|
-
const z0 = typeof c[0]?.z === "number" && Number.isFinite(c[0].z) ? c[0].z : 0;
|
|
13658
|
-
const z1 = typeof c[1]?.z === "number" && Number.isFinite(c[1].z) ? c[1].z : 0;
|
|
13659
|
-
const bh = wall.base_height;
|
|
13660
|
-
const zLo = typeof bh === "number" && Number.isFinite(bh) && bh >= 0 ? bh : Math.min(z0, z1);
|
|
13661
|
-
return { zLo, zHi: zLo + h };
|
|
13662
|
-
}
|
|
13663
14346
|
function pointOnWallAtT3(Wa, Wb, t, wallLen) {
|
|
13664
14347
|
const vx = Wb.x - Wa.x;
|
|
13665
14348
|
const vy = Wb.y - Wa.y;
|
|
@@ -13672,13 +14355,15 @@ function appendPartyExternalCornerE18WhenNoColinearOverlap(wall, party, Wa, Wb,
|
|
|
13672
14355
|
const Pa = party.coordinates[0];
|
|
13673
14356
|
const Pb = party.coordinates[1];
|
|
13674
14357
|
const pExt = partyWallVerticalExtentM(party, floors);
|
|
13675
|
-
const zLo = Math.max(wExt.zLo, pExt.zLo);
|
|
13676
|
-
const zHi = Math.min(wExt.zHi, pExt.zHi);
|
|
13677
|
-
if (zHi - zLo < MIN_VERT) return;
|
|
13678
14358
|
const tol = ADJACENT_WALL_COINCIDENT_PERP_TOL_M;
|
|
13679
14359
|
const junctionCode = "E18";
|
|
13680
|
-
const len2 = zHi - zLo;
|
|
13681
14360
|
const tryEmit = (planX, planY, source) => {
|
|
14361
|
+
const w = verticalExtentAtPointM(wall, wExt, { x: planX, y: planY });
|
|
14362
|
+
const p = verticalExtentAtPointM(party, pExt, { x: planX, y: planY });
|
|
14363
|
+
const zLo = Math.max(w.zLo, p.zLo);
|
|
14364
|
+
const zHi = Math.min(w.zHi, p.zHi);
|
|
14365
|
+
if (zHi - zLo < MIN_VERT) return;
|
|
14366
|
+
const len2 = zHi - zLo;
|
|
13682
14367
|
const sig = `${wall.id}:${party.id}:${roundToTwoDecimals(planX)}:${roundToTwoDecimals(planY)}`;
|
|
13683
14368
|
if (cornerSeen.has(sig)) return;
|
|
13684
14369
|
cornerSeen.add(sig);
|
|
@@ -13736,17 +14421,18 @@ function proposePartyWallToExternalE18(elements, floors) {
|
|
|
13736
14421
|
const Wa = W[0];
|
|
13737
14422
|
const Wb = W[1];
|
|
13738
14423
|
const wallLen = dist2XY4(Wa, Wb);
|
|
13739
|
-
const wExt =
|
|
14424
|
+
const wExt = opaqueEnvelopeVerticalExtentM(wall, floors);
|
|
13740
14425
|
for (const p of partyWalls) {
|
|
13741
|
-
if (!
|
|
14426
|
+
if (!zonesCompatible2(wall.zoneId, p.zoneId)) continue;
|
|
13742
14427
|
const P = p.coordinates;
|
|
13743
14428
|
const overlap = planOverlapAdjacentOnWall(Wa, Wb, P[0], P[1]);
|
|
13744
14429
|
if (overlap) {
|
|
13745
|
-
const pExt = partyWallVerticalExtentM(p, floors);
|
|
13746
|
-
const zLo = Math.max(wExt.zLo, pExt.zLo);
|
|
13747
|
-
const zHi = Math.min(wExt.zHi, pExt.zHi);
|
|
13748
|
-
if (zHi - zLo < MIN_VERT) continue;
|
|
13749
14430
|
const { x, y } = pointOnWallAtT3(Wa, Wb, overlap.tMid, overlap.wallLen);
|
|
14431
|
+
const wAt = verticalExtentAtPointM(wall, wExt, { x, y });
|
|
14432
|
+
const pAt = verticalExtentAtPointM(p, partyWallVerticalExtentM(p, floors), { x, y });
|
|
14433
|
+
const zLo = Math.max(wAt.zLo, pAt.zLo);
|
|
14434
|
+
const zHi = Math.min(wAt.zHi, pAt.zHi);
|
|
14435
|
+
if (zHi - zLo < MIN_VERT) continue;
|
|
13750
14436
|
const len2 = zHi - zLo;
|
|
13751
14437
|
const junctionCode = "E18";
|
|
13752
14438
|
out.push({
|
|
@@ -14066,6 +14752,82 @@ function pushEavesGableProposals(o, floors, elements, out, globalOrientationOffs
|
|
|
14066
14752
|
});
|
|
14067
14753
|
}
|
|
14068
14754
|
}
|
|
14755
|
+
function trimRoofEdgesInsideCutouts(proposals, elements, floors, globalOrientationOffset) {
|
|
14756
|
+
if (!modelMayHaveRoofCutouts(elements)) return proposals;
|
|
14757
|
+
const cutouts = /* @__PURE__ */ new Map();
|
|
14758
|
+
const cutoutFor = (roofId) => {
|
|
14759
|
+
if (!cutouts.has(roofId)) {
|
|
14760
|
+
const roof = elements.find((e) => e.id === roofId);
|
|
14761
|
+
cutouts.set(roofId, roof && deriveRoofCutout(roof, elements, floors, globalOrientationOffset)?.polygons || []);
|
|
14762
|
+
}
|
|
14763
|
+
return cutouts.get(roofId);
|
|
14764
|
+
};
|
|
14765
|
+
const roofEdgeRoles = /* @__PURE__ */ new Set(["sloped_roof_eaves", "sloped_roof_gable", "sloped_roof_ridge", "flat_roof_edge"]);
|
|
14766
|
+
return proposals.flatMap((p) => {
|
|
14767
|
+
if (!roofEdgeRoles.has(p.edgeRole)) return [p];
|
|
14768
|
+
const polygons = cutoutFor(p.openingId);
|
|
14769
|
+
if (polygons.length === 0) return [p];
|
|
14770
|
+
const [a, b] = p.coordinates;
|
|
14771
|
+
const pieces = segmentPartsOutsidePolygons(a, b, polygons);
|
|
14772
|
+
if (pieces.length === 1 && pieces[0][0] === 0 && pieces[0][1] === 1) return [p];
|
|
14773
|
+
const at = (u) => ({ x: a.x + (b.x - a.x) * u, y: a.y + (b.y - a.y) * u, z: roundToTwoDecimals(a.z + (b.z - a.z) * u) });
|
|
14774
|
+
return pieces.flatMap(([u0, u1], k) => (u1 - u0) * dist2XY5(a, b) < MIN_LEN_M ? [] : [{
|
|
14775
|
+
...p,
|
|
14776
|
+
proposalId: `${p.proposalId}:cut${k}`,
|
|
14777
|
+
suggestedLengthM: roundToTwoDecimals(p.suggestedLengthM * (u1 - u0)),
|
|
14778
|
+
reason: `${p.reason}; part outside the walls standing on the roof`,
|
|
14779
|
+
coordinates: [at(u0), at(u1)]
|
|
14780
|
+
}]);
|
|
14781
|
+
});
|
|
14782
|
+
}
|
|
14783
|
+
function segmentPartsOutsidePolygons(a, b, polygons) {
|
|
14784
|
+
const TOL = 0.1;
|
|
14785
|
+
const dx = b.x - a.x;
|
|
14786
|
+
const dy = b.y - a.y;
|
|
14787
|
+
const len2 = dx * dx + dy * dy;
|
|
14788
|
+
if (len2 < 1e-18) return [];
|
|
14789
|
+
const us = /* @__PURE__ */ new Set([0, 1]);
|
|
14790
|
+
const rings = polygons.flat();
|
|
14791
|
+
for (const ring of rings) {
|
|
14792
|
+
for (let i = 0; i < ring.length - 1; i += 1) {
|
|
14793
|
+
const [px, py] = ring[i];
|
|
14794
|
+
const [qx, qy] = ring[i + 1];
|
|
14795
|
+
const u = ((px - a.x) * dx + (py - a.y) * dy) / len2;
|
|
14796
|
+
if (u > 0 && u < 1) us.add(u);
|
|
14797
|
+
const ex = qx - px;
|
|
14798
|
+
const ey = qy - py;
|
|
14799
|
+
const den = dx * ey - dy * ex;
|
|
14800
|
+
if (Math.abs(den) < 1e-12) continue;
|
|
14801
|
+
const t = ((px - a.x) * ey - (py - a.y) * ex) / den;
|
|
14802
|
+
const v = ((px - a.x) * dy - (py - a.y) * dx) / den;
|
|
14803
|
+
if (t > 0 && t < 1 && v >= 0 && v <= 1) us.add(t);
|
|
14804
|
+
}
|
|
14805
|
+
}
|
|
14806
|
+
const covered = (p) => polygons.some((polygon) => {
|
|
14807
|
+
const ringPts = (r) => r.map(([x, y]) => ({ x, y }));
|
|
14808
|
+
const onBoundary = polygon.some((r) => r.some(([px, py], i) => {
|
|
14809
|
+
if (i === r.length - 1) return false;
|
|
14810
|
+
const [qx, qy] = r[i + 1];
|
|
14811
|
+
const ex = qx - px;
|
|
14812
|
+
const ey = qy - py;
|
|
14813
|
+
const l2 = ex * ex + ey * ey;
|
|
14814
|
+
const w = l2 < 1e-18 ? 0 : Math.max(0, Math.min(1, ((p.x - px) * ex + (p.y - py) * ey) / l2));
|
|
14815
|
+
return Math.hypot(p.x - px - ex * w, p.y - py - ey * w) <= TOL;
|
|
14816
|
+
}));
|
|
14817
|
+
return onBoundary || isPointInPolygon2D(p, ringPts(polygon[0])) && !polygon.slice(1).some((hole) => isPointInPolygon2D(p, ringPts(hole)));
|
|
14818
|
+
});
|
|
14819
|
+
const sorted = [...us].sort((m, n) => m - n);
|
|
14820
|
+
const parts = [];
|
|
14821
|
+
for (let i = 0; i < sorted.length - 1; i += 1) {
|
|
14822
|
+
const u0 = sorted[i];
|
|
14823
|
+
const u1 = sorted[i + 1];
|
|
14824
|
+
if (covered({ x: a.x + dx * ((u0 + u1) / 2), y: a.y + dy * ((u0 + u1) / 2) })) continue;
|
|
14825
|
+
const prev = parts[parts.length - 1];
|
|
14826
|
+
if (prev && prev[1] === u0) prev[1] = u1;
|
|
14827
|
+
else parts.push([u0, u1]);
|
|
14828
|
+
}
|
|
14829
|
+
return parts;
|
|
14830
|
+
}
|
|
14069
14831
|
function proposeSlopedRoofEavesGableThermalBridges(elements, floors, globalOrientationOffset) {
|
|
14070
14832
|
floors = withEffectiveStoreyHeights(floors, elements);
|
|
14071
14833
|
const out = [];
|
|
@@ -14075,10 +14837,10 @@ function proposeSlopedRoofEavesGableThermalBridges(elements, floors, globalOrien
|
|
|
14075
14837
|
pushEavesGableProposals(o, floors, elements, out, globalOrientationOffset);
|
|
14076
14838
|
}
|
|
14077
14839
|
const partyWalls = elements.filter(isPartyWallVerticalEnvelopeLine);
|
|
14078
|
-
return out.filter((p) => {
|
|
14840
|
+
return trimRoofEdgesInsideCutouts(out, elements, floors ?? [], globalOrientationOffset).filter((p) => {
|
|
14079
14841
|
const [a, b] = p.coordinates;
|
|
14080
14842
|
const spans = partyWalls.flatMap((pw) => {
|
|
14081
|
-
if (!
|
|
14843
|
+
if (!zonesCompatible2(p.zoneId, pw.zoneId)) return [];
|
|
14082
14844
|
const hit = overlapEndpointsOnRoofPlanEdgeForPartyWall(a, b, pw);
|
|
14083
14845
|
return hit ? [hit.ovl] : [];
|
|
14084
14846
|
}).sort((m, n) => m.tLo - n.tLo);
|
|
@@ -14151,7 +14913,7 @@ function proposeDormerRoofToHostRoofR10ThermalBridges(elements, floors, globalOr
|
|
|
14151
14913
|
const hostName = dormerBundleHostName(dormerRoof);
|
|
14152
14914
|
if (!hostName) continue;
|
|
14153
14915
|
const hostRoof = roofByName.get(hostName);
|
|
14154
|
-
if (!hostRoof || !
|
|
14916
|
+
if (!hostRoof || !zonesCompatible2(dormerRoof.zoneId, hostRoof.zoneId)) continue;
|
|
14155
14917
|
if (isColdPitchedRoof(hostRoof) || isColdPitchedRoof(dormerRoof)) continue;
|
|
14156
14918
|
const eavesUnit = planUnit2(c[0], c[1]);
|
|
14157
14919
|
if (!eavesUnit) continue;
|
|
@@ -14227,59 +14989,61 @@ function coldPitchedRoofBoundaryZM(roof, elements, floors) {
|
|
|
14227
14989
|
}
|
|
14228
14990
|
function proposeDormerWallToHostRoofR8R9ThermalBridges(elements, floors, globalOrientationOffset) {
|
|
14229
14991
|
floors = withEffectiveStoreyHeights(floors, elements);
|
|
14992
|
+
const roofs = pitchedRoofsForWalls(elements, globalOrientationOffset);
|
|
14230
14993
|
const roofByName = /* @__PURE__ */ new Map();
|
|
14231
|
-
for (const
|
|
14232
|
-
if (e.type !== "BuildingElementOpaque" || e.isPlaceholder) continue;
|
|
14233
|
-
const o = e;
|
|
14234
|
-
if (isOrientationPitchAxis(o) && !inwardNormal2DForSlopedRoof(o, globalOrientationOffset)) continue;
|
|
14235
|
-
if (!isSlopedPitchedRoofElementForEavesGable(o)) continue;
|
|
14994
|
+
for (const o of roofs) {
|
|
14236
14995
|
const n = (o.name ?? "").trim();
|
|
14237
14996
|
if (n) roofByName.set(n, o);
|
|
14238
14997
|
}
|
|
14239
14998
|
const out = [];
|
|
14240
|
-
|
|
14241
|
-
if (el.type !== "BuildingElementOpaque" || el.isPlaceholder) continue;
|
|
14242
|
-
const w = el;
|
|
14243
|
-
if (!isDormerVerticalWallForHostMeet(w)) continue;
|
|
14244
|
-
const hostName = dormerBundleHostName2(w);
|
|
14245
|
-
if (!hostName) continue;
|
|
14246
|
-
const roof = roofByName.get(hostName);
|
|
14247
|
-
if (!roof || !zonesCompatible(w.zoneId, roof.zoneId)) continue;
|
|
14248
|
-
const c = w.coordinates;
|
|
14249
|
-
if (!c || c.length !== 2) continue;
|
|
14250
|
-
const A = c[0];
|
|
14251
|
-
const B = c[1];
|
|
14999
|
+
const pushWallOnRoof = (w, roof, A, B, run2) => {
|
|
14252
15000
|
const cold = !!roof.is_unheated_pitched_roof;
|
|
14253
15001
|
const coldBoundaryZM = cold ? coldPitchedRoofBoundaryZM(roof, elements, floors) : null;
|
|
14254
15002
|
const z0 = coldBoundaryZM ?? roofTopElevationAtPlanM(roof, A.x, A.y, floors, globalOrientationOffset);
|
|
14255
15003
|
const z1 = coldBoundaryZM ?? roofTopElevationAtPlanM(roof, B.x, B.y, floors, globalOrientationOffset);
|
|
14256
|
-
if (z0 === null || z1 === null)
|
|
15004
|
+
if (z0 === null || z1 === null) return;
|
|
14257
15005
|
const wExt = opaqueEnvelopeVerticalExtentM(w, floors);
|
|
14258
15006
|
const rLo = Math.min(z0, z1) - ROOF_WALL_Z_OVERLAP_PAD_M;
|
|
14259
15007
|
const rHi = Math.max(z0, z1) + ROOF_WALL_Z_OVERLAP_PAD_M;
|
|
14260
|
-
if (wExt.zHi < rLo || wExt.zLo > rHi)
|
|
15008
|
+
if (wExt.zHi < rLo || wExt.zLo > rHi) return;
|
|
14261
15009
|
const c0 = { x: A.x, y: A.y, z: z0 };
|
|
14262
15010
|
const c1 = { x: B.x, y: B.y, z: z1 };
|
|
14263
15011
|
const planLen = Math.hypot(B.x - A.x, B.y - A.y);
|
|
14264
15012
|
const len2 = cold ? planLen : computeThermalBridgeLinearRunLengthM([c0, c1]);
|
|
14265
|
-
if (len2 < MIN_WALL_PLAN_LEN_M)
|
|
15013
|
+
if (len2 < MIN_WALL_PLAN_LEN_M) return;
|
|
14266
15014
|
const junctionCode = junctionR8OrR9ForRoof(roof);
|
|
14267
15015
|
const ins = cold ? "cold roof (insulation at ceiling line)" : "warm roof (insulation at rafter line)";
|
|
14268
15016
|
const dz = Math.abs(z1 - z0);
|
|
14269
15017
|
out.push({
|
|
14270
|
-
proposalId: `dormerhostr89:${roof.id}:${w.id}:${roundToTwoDecimals(len2)}`,
|
|
15018
|
+
proposalId: run2 === null ? `dormerhostr89:${roof.id}:${w.id}:${roundToTwoDecimals(len2)}` : `onroofr89:${roof.id}:${w.id}:${run2}`,
|
|
14271
15019
|
openingId: w.id,
|
|
14272
|
-
openingName: `${roof.name} (host) \u2194 ${w.name}`,
|
|
15020
|
+
openingName: `${roof.name}${run2 === null ? " (host)" : ""} \u2194 ${w.name}`,
|
|
14273
15021
|
zoneId: roof.zoneId ?? w.zoneId,
|
|
14274
15022
|
edgeRole: EDGE_ROLE2,
|
|
14275
15023
|
junctionCode,
|
|
14276
15024
|
suggestedLengthM: roundToTwoDecimals(len2),
|
|
14277
15025
|
linearThermalTransmittance: psiTable37ForCode(junctionCode),
|
|
14278
|
-
reason: `Table 3.7 ${junctionCode} (${ins}): dormer wall "${w.name}" on **host** roof "${roof.name}" (${cold ? "projected ceiling boundary" : "footprint on roof plane"}; plan ${roundToTwoDecimals(planLen)} m; |\u0394z| ${roundToTwoDecimals(dz)} m; 3D length ${roundToTwoDecimals(len2)} m)`,
|
|
15026
|
+
reason: `Table 3.7 ${junctionCode} (${ins}): ${run2 === null ? "dormer wall" : "wall"} "${w.name}" on ${run2 === null ? "**host** roof" : "roof"} "${roof.name}" (${cold ? "projected ceiling boundary" : "footprint on roof plane"}; plan ${roundToTwoDecimals(planLen)} m; |\u0394z| ${roundToTwoDecimals(dz)} m; 3D length ${roundToTwoDecimals(len2)} m)`,
|
|
14279
15027
|
coordinates: [c0, c1],
|
|
14280
15028
|
parentElementForTb: roof.name,
|
|
14281
15029
|
roofAdjacentPairIds: [roof.id, w.id]
|
|
14282
15030
|
});
|
|
15031
|
+
};
|
|
15032
|
+
for (const el of elements) {
|
|
15033
|
+
if (el.type !== "BuildingElementOpaque" || el.isPlaceholder) continue;
|
|
15034
|
+
const w = el;
|
|
15035
|
+
if (isDormerVerticalWallForHostMeet(w)) {
|
|
15036
|
+
const hostName = dormerBundleHostName2(w);
|
|
15037
|
+
const roof = hostName ? roofByName.get(hostName) : void 0;
|
|
15038
|
+
if (!roof || !zonesCompatible2(w.zoneId, roof.zoneId)) continue;
|
|
15039
|
+
pushWallOnRoof(w, roof, w.coordinates[0], w.coordinates[1], null);
|
|
15040
|
+
} else if (isExternalLineWall(w)) {
|
|
15041
|
+
const [A, B] = [w.coordinates[0], w.coordinates[1]];
|
|
15042
|
+
const at = (t) => ({ x: A.x + (B.x - A.x) * t, y: A.y + (B.y - A.y) * t });
|
|
15043
|
+
for (const run2 of bottomEdgeRoofRuns(w, roofs, floors, globalOrientationOffset)) {
|
|
15044
|
+
pushWallOnRoof(w, run2.roof, at(run2.t0), at(run2.t1), `${roundToTwoDecimals(run2.t0)}`);
|
|
15045
|
+
}
|
|
15046
|
+
}
|
|
14283
15047
|
}
|
|
14284
15048
|
return out;
|
|
14285
15049
|
}
|
|
@@ -14294,19 +15058,6 @@ function isPartyHorizontalConditionedFloorSlabHost(el) {
|
|
|
14294
15058
|
if (!isVulcanUiPartyFloorElement(el)) return false;
|
|
14295
15059
|
return horizontalConditionedFloorSlabPlanEdgesForPartyWallTb(el).length > 0;
|
|
14296
15060
|
}
|
|
14297
|
-
function wallVerticalExtentM3(wall, floors) {
|
|
14298
|
-
const h = typeof wall.height === "number" && wall.height > 0 ? wall.height : 0;
|
|
14299
|
-
if (floors && floors.length > 0) {
|
|
14300
|
-
const zLo2 = elementBaseElevationMForTb(wall, floors);
|
|
14301
|
-
return { zLo: zLo2, zHi: zLo2 + h };
|
|
14302
|
-
}
|
|
14303
|
-
const c = wall.coordinates;
|
|
14304
|
-
const z0 = typeof c[0]?.z === "number" && Number.isFinite(c[0].z) ? c[0].z : 0;
|
|
14305
|
-
const z1 = typeof c[1]?.z === "number" && Number.isFinite(c[1].z) ? c[1].z : 0;
|
|
14306
|
-
const bh = wall.base_height;
|
|
14307
|
-
const zLo = typeof bh === "number" && Number.isFinite(bh) && bh >= 0 ? bh : Math.min(z0, z1);
|
|
14308
|
-
return { zLo, zHi: zLo + h };
|
|
14309
|
-
}
|
|
14310
15061
|
function pointOnWallAtT4(Wa, Wb, t, wallLen) {
|
|
14311
15062
|
const vx = Wb.x - Wa.x;
|
|
14312
15063
|
const vy = Wb.y - Wa.y;
|
|
@@ -14327,9 +15078,9 @@ function proposeE7PartyFloorToExternalWallThermalBridges(elements, floors) {
|
|
|
14327
15078
|
if (!W || W.length < 2) continue;
|
|
14328
15079
|
const Wa = W[0];
|
|
14329
15080
|
const Wb = W[1];
|
|
14330
|
-
const wExt =
|
|
15081
|
+
const wExt = opaqueEnvelopeVerticalExtentM(wall, floors);
|
|
14331
15082
|
for (const adj of partyFloors) {
|
|
14332
|
-
if (!
|
|
15083
|
+
if (!zonesCompatible2(wall.zoneId, adj.zoneId)) continue;
|
|
14333
15084
|
const slabZ = floors && floors.length > 0 ? elementBaseElevationMForTb(adj, floors) : (() => {
|
|
14334
15085
|
const c = adj.coordinates;
|
|
14335
15086
|
let zMin = Infinity;
|
|
@@ -14348,37 +15099,34 @@ function proposeE7PartyFloorToExternalWallThermalBridges(elements, floors) {
|
|
|
14348
15099
|
edgeIdx++;
|
|
14349
15100
|
continue;
|
|
14350
15101
|
}
|
|
14351
|
-
const tLo = overlap.tLo;
|
|
14352
|
-
const tHi = overlap.tHi;
|
|
14353
15102
|
const wlen = overlap.wallLen;
|
|
14354
|
-
const
|
|
14355
|
-
|
|
14356
|
-
|
|
14357
|
-
|
|
14358
|
-
|
|
14359
|
-
|
|
15103
|
+
for (const [tLo, tHi] of lineFaceRunsAtHeight(wall, wlen, overlap.tLo, overlap.tHi, slabZ - wExt.foot, Z_BAND_EPS)) {
|
|
15104
|
+
const a = pointOnWallAtT4(Wa, Wb, tLo, wlen);
|
|
15105
|
+
const b = pointOnWallAtT4(Wa, Wb, tHi, wlen);
|
|
15106
|
+
const L = dist2XY6(a, b);
|
|
15107
|
+
if (L < 0.05) continue;
|
|
15108
|
+
const junctionCode = "E7";
|
|
15109
|
+
const zOut = roundToTwoDecimals(slabZ);
|
|
15110
|
+
out.push({
|
|
15111
|
+
proposalId: `e7:${wall.id}:${adj.id}:e${edgeIdx}:${roundToTwoDecimals((tLo + tHi) / 2)}`,
|
|
15112
|
+
openingId: adj.id,
|
|
15113
|
+
openingName: `${adj.name} \u2194 ${wall.name}`,
|
|
15114
|
+
zoneId: wall.zoneId ?? adj.zoneId,
|
|
15115
|
+
edgeRole: "e7_party_floor_external",
|
|
15116
|
+
junctionCode,
|
|
15117
|
+
suggestedLengthM: roundToTwoDecimals(L),
|
|
15118
|
+
linearThermalTransmittance: psiTable37ForCode(junctionCode),
|
|
15119
|
+
reason: `E7 (party floor or party ceiling between dwellings) at ${zOut} m along external wall "${wall.name}" and party slab "${adj.name}" (plan overlap ${roundToTwoDecimals(
|
|
15120
|
+
tHi - tLo
|
|
15121
|
+
)} m; edge ${edgeIdx})`,
|
|
15122
|
+
coordinates: [
|
|
15123
|
+
{ x: roundToTwoDecimals(a.x), y: roundToTwoDecimals(a.y), z: zOut },
|
|
15124
|
+
{ x: roundToTwoDecimals(b.x), y: roundToTwoDecimals(b.y), z: zOut }
|
|
15125
|
+
],
|
|
15126
|
+
parentElementForTb: wall.name,
|
|
15127
|
+
hostElementIds: [wall.id, adj.id]
|
|
15128
|
+
});
|
|
14360
15129
|
}
|
|
14361
|
-
const junctionCode = "E7";
|
|
14362
|
-
const zOut = roundToTwoDecimals(slabZ);
|
|
14363
|
-
out.push({
|
|
14364
|
-
proposalId: `e7:${wall.id}:${adj.id}:e${edgeIdx}:${roundToTwoDecimals(overlap.tMid)}`,
|
|
14365
|
-
openingId: adj.id,
|
|
14366
|
-
openingName: `${adj.name} \u2194 ${wall.name}`,
|
|
14367
|
-
zoneId: wall.zoneId ?? adj.zoneId,
|
|
14368
|
-
edgeRole: "e7_party_floor_external",
|
|
14369
|
-
junctionCode,
|
|
14370
|
-
suggestedLengthM: roundToTwoDecimals(L),
|
|
14371
|
-
linearThermalTransmittance: psiTable37ForCode(junctionCode),
|
|
14372
|
-
reason: `E7 (party floor or party ceiling between dwellings) at ${zOut} m along external wall "${wall.name}" and party slab "${adj.name}" (plan overlap ${roundToTwoDecimals(
|
|
14373
|
-
overlap.overlapLen
|
|
14374
|
-
)} m; edge ${edgeIdx})`,
|
|
14375
|
-
coordinates: [
|
|
14376
|
-
{ x: roundToTwoDecimals(a.x), y: roundToTwoDecimals(a.y), z: zOut },
|
|
14377
|
-
{ x: roundToTwoDecimals(b.x), y: roundToTwoDecimals(b.y), z: zOut }
|
|
14378
|
-
],
|
|
14379
|
-
parentElementForTb: wall.name,
|
|
14380
|
-
hostElementIds: [wall.id, adj.id]
|
|
14381
|
-
});
|
|
14382
15130
|
edgeIdx++;
|
|
14383
15131
|
}
|
|
14384
15132
|
}
|
|
@@ -14558,28 +15306,6 @@ var MIN_EDGE_LEN_XY_M = 0.05;
|
|
|
14558
15306
|
function dist2XY7(a, b) {
|
|
14559
15307
|
return Math.hypot(a.x - b.x, a.y - b.y);
|
|
14560
15308
|
}
|
|
14561
|
-
function isFlatRoofDeckLineForTb(o) {
|
|
14562
|
-
if (o.isPlaceholder) return false;
|
|
14563
|
-
if (!isRoofLikeOpaqueElement(o)) return false;
|
|
14564
|
-
if (o.pitch !== 0) return false;
|
|
14565
|
-
if (o.is_unheated_pitched_roof) return true;
|
|
14566
|
-
const n = (o.name ?? "").trim().toLowerCase();
|
|
14567
|
-
return n === "roof" || n.includes("roof");
|
|
14568
|
-
}
|
|
14569
|
-
function flatRoofDeckElevationMForTb(o, floors) {
|
|
14570
|
-
if (floors && floors.length > 0) {
|
|
14571
|
-
return elementBaseElevationMForTb(o, floors);
|
|
14572
|
-
}
|
|
14573
|
-
const c = o.coordinates;
|
|
14574
|
-
const bh = o.base_height;
|
|
14575
|
-
if (typeof bh === "number" && Number.isFinite(bh) && bh >= 0) return bh;
|
|
14576
|
-
let maxZ = -Infinity;
|
|
14577
|
-
for (const p of c ?? []) {
|
|
14578
|
-
if (typeof p?.z === "number" && Number.isFinite(p.z)) maxZ = Math.max(maxZ, p.z);
|
|
14579
|
-
}
|
|
14580
|
-
if (maxZ !== -Infinity) return maxZ;
|
|
14581
|
-
return 0;
|
|
14582
|
-
}
|
|
14583
15309
|
function flatRoofDeckEffectivePolygonVertexCount(c) {
|
|
14584
15310
|
if (c.length < 3) return c.length;
|
|
14585
15311
|
const a = c[0];
|
|
@@ -14587,7 +15313,7 @@ function flatRoofDeckEffectivePolygonVertexCount(c) {
|
|
|
14587
15313
|
if (dist2XY7(a, b) < MIN_EDGE_LEN_XY_M) return c.length - 1;
|
|
14588
15314
|
return c.length;
|
|
14589
15315
|
}
|
|
14590
|
-
function proposeFlatRoofEdgeThermalBridges(elements, floors) {
|
|
15316
|
+
function proposeFlatRoofEdgeThermalBridges(elements, floors, globalOrientationOffset) {
|
|
14591
15317
|
floors = withEffectiveStoreyHeights(floors, elements);
|
|
14592
15318
|
const out = [];
|
|
14593
15319
|
for (const el of elements) {
|
|
@@ -14643,7 +15369,31 @@ function proposeFlatRoofEdgeThermalBridges(elements, floors) {
|
|
|
14643
15369
|
});
|
|
14644
15370
|
}
|
|
14645
15371
|
}
|
|
14646
|
-
|
|
15372
|
+
for (const el of elements) {
|
|
15373
|
+
if (el.type !== "BuildingElementOpaque" || !isFlatRoofDeckLineForTb(el) || (el.coordinates?.length ?? 0) < 3) continue;
|
|
15374
|
+
const cutout = deriveRoofCutout(el, elements, floors ?? [], globalOrientationOffset);
|
|
15375
|
+
const z = flatRoofDeckElevationMForTb(el, floors);
|
|
15376
|
+
for (const { wall, t0, t1 } of cutout?.standing ?? []) {
|
|
15377
|
+
const [A, B] = [wall.coordinates[0], wall.coordinates[1]];
|
|
15378
|
+
const at = (t) => ({ x: A.x + (B.x - A.x) * t, y: A.y + (B.y - A.y) * t, z });
|
|
15379
|
+
const lenM = dist2XY7(A, B) * (t1 - t0);
|
|
15380
|
+
if (lenM < MIN_EDGE_LEN_XY_M) continue;
|
|
15381
|
+
out.push({
|
|
15382
|
+
proposalId: `${el.id}:wall_on_deck:${wall.id}:${roundToTwoDecimals(t0)}`,
|
|
15383
|
+
openingId: wall.id,
|
|
15384
|
+
openingName: `${el.name} \u2194 ${wall.name}`,
|
|
15385
|
+
zoneId: wall.zoneId ?? el.zoneId,
|
|
15386
|
+
edgeRole: "wall_intermediate_continuous",
|
|
15387
|
+
junctionCode: "E6",
|
|
15388
|
+
suggestedLengthM: roundToTwoDecimals(lenM),
|
|
15389
|
+
linearThermalTransmittance: psiTable37ForCode("E6"),
|
|
15390
|
+
reason: `E6: wall "${wall.name}" stands on the flat roof "${el.name}", which is a floor inside the dwelling under the room the walls enclose`,
|
|
15391
|
+
coordinates: [at(t0), at(t1)],
|
|
15392
|
+
parentElementForTb: wall.name
|
|
15393
|
+
});
|
|
15394
|
+
}
|
|
15395
|
+
}
|
|
15396
|
+
return trimRoofEdgesInsideCutouts(out, elements, floors ?? [], globalOrientationOffset);
|
|
14647
15397
|
}
|
|
14648
15398
|
|
|
14649
15399
|
// ../community/packages/geometry-editor/src/geometry/thermalBridge/proposeWallGroundContinuous.ts
|
|
@@ -14688,7 +15438,7 @@ function projectOnWallLine2(Wa, Wb, p) {
|
|
|
14688
15438
|
const perp = Math.abs(-uy * (p.x - Wa.x) + ux * (p.y - Wa.y));
|
|
14689
15439
|
return { t, perp, wallLen };
|
|
14690
15440
|
}
|
|
14691
|
-
function
|
|
15441
|
+
function zonesCompatible3(a, b) {
|
|
14692
15442
|
if (a !== void 0 && b !== void 0 && a !== b) return false;
|
|
14693
15443
|
return true;
|
|
14694
15444
|
}
|
|
@@ -14760,7 +15510,7 @@ function gapIntervalsAlongWall(wallLen, covered) {
|
|
|
14760
15510
|
}
|
|
14761
15511
|
function footIntervalOnWallForRole(wall, foot, footRole) {
|
|
14762
15512
|
if (foot.edgeRole !== footRole) return null;
|
|
14763
|
-
if (!
|
|
15513
|
+
if (!zonesCompatible3(wall.zoneId, foot.zoneId)) return null;
|
|
14764
15514
|
const c = wall.coordinates;
|
|
14765
15515
|
const Wa = { x: c[0].x, y: c[0].y };
|
|
14766
15516
|
const Wb = { x: c[1].x, y: c[1].y };
|
|
@@ -14805,7 +15555,7 @@ function proposeWallGroundContinuous(elements, openingProposals, floors) {
|
|
|
14805
15555
|
const iv = footIntervalOnWallForRole(w, foot, "wall_ground_foot");
|
|
14806
15556
|
if (iv) covered.push(iv);
|
|
14807
15557
|
}
|
|
14808
|
-
const gaps = gapIntervalsAlongWall(wallLen, covered);
|
|
15558
|
+
const gaps = gapIntervalsAlongWall(wallLen, covered).flatMap(([a, b]) => lineFaceRunsAtHeight(w, wallLen, a, b, 0, SKIP_SILL_THERMAL_BRIDGE_BELOW_Z_M));
|
|
14809
15559
|
const targetZ = groundContactElevationTargetMForContinuousTb(w, elements, floors);
|
|
14810
15560
|
const z = roundToTwoDecimals(
|
|
14811
15561
|
targetZ ?? (floors && floors.length > 0 ? elementBaseElevationMForTb(w, floors) : opaqueWallBaseElevationM(w))
|
|
@@ -14890,7 +15640,7 @@ function proposePartyWallGroundP1P6ThermalBridges(elements, floors) {
|
|
|
14890
15640
|
const pExt = partyWallVerticalExtentM(pw, floors);
|
|
14891
15641
|
const wallBaseM = elementBaseElevationMForTb(pw, floors);
|
|
14892
15642
|
for (const g of grounds) {
|
|
14893
|
-
if (!
|
|
15643
|
+
if (!zonesCompatible2(pw.zoneId, g.zoneId)) continue;
|
|
14894
15644
|
const slabZElev = nonBasementGroundSurfaceElevationM(g) ?? elementBaseElevationMForTb(g, floors);
|
|
14895
15645
|
if (slabZElev < pExt.zLo - Z_BAND_EPS_M2 || slabZElev > pExt.zHi + Z_BAND_EPS_M2) continue;
|
|
14896
15646
|
if (Math.abs(slabZElev - wallBaseM) > SKIP_SILL_THERMAL_BRIDGE_BELOW_Z_M) continue;
|
|
@@ -14904,34 +15654,33 @@ function proposePartyWallGroundP1P6ThermalBridges(elements, floors) {
|
|
|
14904
15654
|
edgeIdx++;
|
|
14905
15655
|
continue;
|
|
14906
15656
|
}
|
|
14907
|
-
const
|
|
14908
|
-
|
|
14909
|
-
|
|
14910
|
-
|
|
14911
|
-
|
|
14912
|
-
|
|
15657
|
+
for (const [tLo, tHi] of lineFaceRunsAtHeight(pw, overlap.wallLen, overlap.tLo, overlap.tHi, slabZElev - pExt.foot, SKIP_SILL_THERMAL_BRIDGE_BELOW_Z_M)) {
|
|
15658
|
+
const a = pointOnWallAtT5(Pa, Pb, tLo, overlap.wallLen);
|
|
15659
|
+
const b = pointOnWallAtT5(Pa, Pb, tHi, overlap.wallLen);
|
|
15660
|
+
const L = dist2XY9(a, b);
|
|
15661
|
+
if (L < MIN_PLAN_OVERLAP_M2) continue;
|
|
15662
|
+
const zSlab = roundToTwoDecimals(slabZElev);
|
|
15663
|
+
const junctionCode = "P1";
|
|
15664
|
+
out.push({
|
|
15665
|
+
proposalId: `p1:${pw.id}:${g.id}:e${edgeIdx}:${roundToTwoDecimals(tLo)}`,
|
|
15666
|
+
openingId: g.id,
|
|
15667
|
+
openingName: `${g.name ?? g.id} \u2194 ${pw.name}`,
|
|
15668
|
+
zoneId: pw.zoneId ?? g.zoneId,
|
|
15669
|
+
edgeRole: "party_wall_junction",
|
|
15670
|
+
junctionCode,
|
|
15671
|
+
suggestedLengthM: roundToTwoDecimals(L),
|
|
15672
|
+
linearThermalTransmittance: psiTable37ForCode(junctionCode),
|
|
15673
|
+
reason: `P1 party wall \xD7 ground floor: "${pw.name}" \xD7 BuildingElementGround "${g.name ?? g.id}" slab edge (plan ${roundToTwoDecimals(
|
|
15674
|
+
tHi - tLo
|
|
15675
|
+
)} m at ${zSlab} m); use **P6** if inverted ground-floor junction`,
|
|
15676
|
+
coordinates: [
|
|
15677
|
+
{ x: roundToTwoDecimals(a.x), y: roundToTwoDecimals(a.y), z: zSlab },
|
|
15678
|
+
{ x: roundToTwoDecimals(b.x), y: roundToTwoDecimals(b.y), z: zSlab }
|
|
15679
|
+
],
|
|
15680
|
+
parentElementForTb: pw.name ?? pw.id,
|
|
15681
|
+
hostElementIds: [pw.id, g.id]
|
|
15682
|
+
});
|
|
14913
15683
|
}
|
|
14914
|
-
const zSlab = roundToTwoDecimals(slabZElev);
|
|
14915
|
-
const junctionCode = "P1";
|
|
14916
|
-
out.push({
|
|
14917
|
-
proposalId: `p1:${pw.id}:${g.id}:e${edgeIdx}:${roundToTwoDecimals(overlap.tLo)}`,
|
|
14918
|
-
openingId: g.id,
|
|
14919
|
-
openingName: `${g.name ?? g.id} \u2194 ${pw.name}`,
|
|
14920
|
-
zoneId: pw.zoneId ?? g.zoneId,
|
|
14921
|
-
edgeRole: "party_wall_junction",
|
|
14922
|
-
junctionCode,
|
|
14923
|
-
suggestedLengthM: roundToTwoDecimals(L),
|
|
14924
|
-
linearThermalTransmittance: psiTable37ForCode(junctionCode),
|
|
14925
|
-
reason: `P1 party wall \xD7 ground floor: "${pw.name}" \xD7 BuildingElementGround "${g.name ?? g.id}" slab edge (plan ${roundToTwoDecimals(
|
|
14926
|
-
overlap.overlapLen
|
|
14927
|
-
)} m at ${zSlab} m); use **P6** if inverted ground-floor junction`,
|
|
14928
|
-
coordinates: [
|
|
14929
|
-
{ x: roundToTwoDecimals(a.x), y: roundToTwoDecimals(a.y), z: zSlab },
|
|
14930
|
-
{ x: roundToTwoDecimals(b.x), y: roundToTwoDecimals(b.y), z: zSlab }
|
|
14931
|
-
],
|
|
14932
|
-
parentElementForTb: pw.name ?? pw.id,
|
|
14933
|
-
hostElementIds: [pw.id, g.id]
|
|
14934
|
-
});
|
|
14935
15684
|
edgeIdx++;
|
|
14936
15685
|
}
|
|
14937
15686
|
}
|
|
@@ -14969,7 +15718,7 @@ function proposePartyWallIntermediateFloorP2P3ThermalBridges(elements, floors) {
|
|
|
14969
15718
|
const Pb = P[1];
|
|
14970
15719
|
const pExt = partyWallVerticalExtentM(pw, floors);
|
|
14971
15720
|
for (const adj of conditionedFloors) {
|
|
14972
|
-
if (!
|
|
15721
|
+
if (!zonesCompatible2(pw.zoneId, adj.zoneId)) continue;
|
|
14973
15722
|
const slabZ = elementBaseElevationMForTb(adj, floors);
|
|
14974
15723
|
if (slabZ < pExt.zLo - Z_BAND_EPS_M3 || slabZ > pExt.zHi + Z_BAND_EPS_M3) continue;
|
|
14975
15724
|
if (partyWallGroundFamilyClaimsElevation(pw, elements, floors, slabZ)) continue;
|
|
@@ -14990,35 +15739,34 @@ function proposePartyWallIntermediateFloorP2P3ThermalBridges(elements, floors) {
|
|
|
14990
15739
|
edgeIdx += 1;
|
|
14991
15740
|
continue;
|
|
14992
15741
|
}
|
|
14993
|
-
const
|
|
14994
|
-
|
|
14995
|
-
|
|
14996
|
-
|
|
14997
|
-
|
|
14998
|
-
|
|
15742
|
+
for (const [tLo, tHi] of lineFaceRunsAtHeight(pw, overlap.wallLen, overlap.tLo, overlap.tHi, slabZ - pExt.foot, Z_BAND_EPS_M3)) {
|
|
15743
|
+
const a = pointOnSegmentAtT(Pa, Pb, tLo, overlap.wallLen);
|
|
15744
|
+
const b = pointOnSegmentAtT(Pa, Pb, tHi, overlap.wallLen);
|
|
15745
|
+
const L = dist2XY10(a, b);
|
|
15746
|
+
if (L < MIN_PLAN_OVERLAP_M3) continue;
|
|
15747
|
+
const z = roundToTwoDecimals(slabZ);
|
|
15748
|
+
out.push({
|
|
15749
|
+
proposalId: `${junctionCode.toLowerCase()}:pw:${pw.id}:${adj.id}:e${edgeIdx}:${roundToTwoDecimals(tLo)}`,
|
|
15750
|
+
openingId: adj.id,
|
|
15751
|
+
openingName: `${adj.name} \u2194 ${pw.name}`,
|
|
15752
|
+
zoneId: pw.zoneId ?? adj.zoneId,
|
|
15753
|
+
edgeRole: "party_wall_junction",
|
|
15754
|
+
junctionCode,
|
|
15755
|
+
suggestedLengthM: roundToTwoDecimals(L),
|
|
15756
|
+
linearThermalTransmittance: psiTable37ForCode(junctionCode),
|
|
15757
|
+
reason: junctionCode === "P3" ? `P3 party wall \xD7 intermediate floor (party element): "${pw.name}" \xD7 conditioned floor "${adj.name}" (plan ${roundToTwoDecimals(
|
|
15758
|
+
tHi - tLo
|
|
15759
|
+
)} m at ${z} m)` : `P2 party wall \xD7 intermediate floor: "${pw.name}" \xD7 conditioned floor "${adj.name}" (plan ${roundToTwoDecimals(
|
|
15760
|
+
tHi - tLo
|
|
15761
|
+
)} m at ${z} m)`,
|
|
15762
|
+
coordinates: [
|
|
15763
|
+
{ x: roundToTwoDecimals(a.x), y: roundToTwoDecimals(a.y), z },
|
|
15764
|
+
{ x: roundToTwoDecimals(b.x), y: roundToTwoDecimals(b.y), z }
|
|
15765
|
+
],
|
|
15766
|
+
parentElementForTb: pw.name ?? pw.id,
|
|
15767
|
+
hostElementIds: [pw.id, adj.id]
|
|
15768
|
+
});
|
|
14999
15769
|
}
|
|
15000
|
-
const z = roundToTwoDecimals(slabZ);
|
|
15001
|
-
out.push({
|
|
15002
|
-
proposalId: `${junctionCode.toLowerCase()}:pw:${pw.id}:${adj.id}:e${edgeIdx}:${roundToTwoDecimals(overlap.tLo)}`,
|
|
15003
|
-
openingId: adj.id,
|
|
15004
|
-
openingName: `${adj.name} \u2194 ${pw.name}`,
|
|
15005
|
-
zoneId: pw.zoneId ?? adj.zoneId,
|
|
15006
|
-
edgeRole: "party_wall_junction",
|
|
15007
|
-
junctionCode,
|
|
15008
|
-
suggestedLengthM: roundToTwoDecimals(L),
|
|
15009
|
-
linearThermalTransmittance: psiTable37ForCode(junctionCode),
|
|
15010
|
-
reason: junctionCode === "P3" ? `P3 party wall \xD7 intermediate floor (party element): "${pw.name}" \xD7 conditioned floor "${adj.name}" (plan ${roundToTwoDecimals(
|
|
15011
|
-
overlap.overlapLen
|
|
15012
|
-
)} m at ${z} m)` : `P2 party wall \xD7 intermediate floor: "${pw.name}" \xD7 conditioned floor "${adj.name}" (plan ${roundToTwoDecimals(
|
|
15013
|
-
overlap.overlapLen
|
|
15014
|
-
)} m at ${z} m)`,
|
|
15015
|
-
coordinates: [
|
|
15016
|
-
{ x: roundToTwoDecimals(a.x), y: roundToTwoDecimals(a.y), z },
|
|
15017
|
-
{ x: roundToTwoDecimals(b.x), y: roundToTwoDecimals(b.y), z }
|
|
15018
|
-
],
|
|
15019
|
-
parentElementForTb: pw.name ?? pw.id,
|
|
15020
|
-
hostElementIds: [pw.id, adj.id]
|
|
15021
|
-
});
|
|
15022
15770
|
edgeIdx += 1;
|
|
15023
15771
|
}
|
|
15024
15772
|
}
|
|
@@ -15052,7 +15800,7 @@ function proposePartyWallToFlatRoofP4ThermalBridges(elements, floors) {
|
|
|
15052
15800
|
const emitEdge = (Ra, Rb, edgeIdx) => {
|
|
15053
15801
|
if (dist2XYPlan(Ra, Rb) < 1e-4) return;
|
|
15054
15802
|
for (const p of partyWalls) {
|
|
15055
|
-
if (!
|
|
15803
|
+
if (!zonesCompatible2(o.zoneId, p.zoneId)) continue;
|
|
15056
15804
|
if (!partyWallContainsDeckZM(p, floors, deckZ)) continue;
|
|
15057
15805
|
const hit = overlapEndpointsOnRoofPlanEdgeForPartyWall(Ra, Rb, p);
|
|
15058
15806
|
if (!hit) continue;
|
|
@@ -15137,7 +15885,7 @@ function proposePartyWallToSlopedRoofP4P5ThermalBridges(elements, floors, global
|
|
|
15137
15885
|
const cold = !!o.is_unheated_pitched_roof;
|
|
15138
15886
|
const zB = cold ? getUnheatedPitchedRoofCeilingElevationM(o, elements, floors).value : zEavesM2(o, floors);
|
|
15139
15887
|
for (const p of partyWalls) {
|
|
15140
|
-
if (!
|
|
15888
|
+
if (!zonesCompatible2(o.zoneId, p.zoneId)) continue;
|
|
15141
15889
|
const n = c.length;
|
|
15142
15890
|
for (let i = 0; i < n; i++) {
|
|
15143
15891
|
const Ra = c[i];
|
|
@@ -15489,7 +16237,7 @@ function proposeRoomInRoofRoofToWallR8R9ThermalBridges(elements, floors, globalO
|
|
|
15489
16237
|
for (let ei = 0; ei < edges.length; ei++) {
|
|
15490
16238
|
const [Wa, Wb] = edges[ei];
|
|
15491
16239
|
for (const adj of adjacents) {
|
|
15492
|
-
if (!
|
|
16240
|
+
if (!zonesCompatible2(roof.zoneId, adj.zoneId)) continue;
|
|
15493
16241
|
const A = adj.coordinates;
|
|
15494
16242
|
const overlap = planOverlapAdjacentOnWall(Wa, Wb, A[0], A[1]);
|
|
15495
16243
|
if (!overlap) continue;
|
|
@@ -15527,7 +16275,7 @@ function proposeRoomInRoofRoofToWallR8R9ThermalBridges(elements, floors, globalO
|
|
|
15527
16275
|
});
|
|
15528
16276
|
}
|
|
15529
16277
|
for (const ow of opaqueVerticalWalls) {
|
|
15530
|
-
if (!
|
|
16278
|
+
if (!zonesCompatible2(roof.zoneId, ow.zoneId)) continue;
|
|
15531
16279
|
const A = ow.coordinates;
|
|
15532
16280
|
const overlap = planOverlapAdjacentOnWall(Wa, Wb, A[0], A[1]);
|
|
15533
16281
|
if (!overlap) continue;
|
|
@@ -15626,7 +16374,7 @@ function proposeWallIntermediateContinuous(elements, openingProposals, floors) {
|
|
|
15626
16374
|
const iv = footIntervalOnWallForRole(w, foot, "wall_intermediate_floor_foot");
|
|
15627
16375
|
if (iv) covered.push(iv);
|
|
15628
16376
|
}
|
|
15629
|
-
const gaps = gapIntervalsAlongWall(wallLen, covered);
|
|
16377
|
+
const gaps = gapIntervalsAlongWall(wallLen, covered).flatMap(([a, b]) => lineFaceRunsAtHeight(w, wallLen, a, b, 0, SKIP_SILL_THERMAL_BRIDGE_BELOW_Z_M));
|
|
15630
16378
|
const zTargetM = useUnheatedBasementE6 ? basementTargetM : effectiveFloors ? slabElevationMForFloorZ(elementFloorZIndexForTb(w, effectiveFloors), effectiveFloors) : null;
|
|
15631
16379
|
if (zTargetM === null) continue;
|
|
15632
16380
|
const z = roundToTwoDecimals(zTargetM);
|
|
@@ -15665,7 +16413,7 @@ function proposeWallIntermediateContinuous(elements, openingProposals, floors) {
|
|
|
15665
16413
|
function proposeAutoThermalBridgesWithRaw(elements, floors, globalOrientationOffset) {
|
|
15666
16414
|
const openings = proposeFacadeOpeningThermalBridges(elements, floors);
|
|
15667
16415
|
const roofOpenings = proposeRoofOpeningThermalBridges(elements, floors, globalOrientationOffset);
|
|
15668
|
-
const flatRoofEdges = proposeFlatRoofEdgeThermalBridges(elements, floors);
|
|
16416
|
+
const flatRoofEdges = proposeFlatRoofEdgeThermalBridges(elements, floors, globalOrientationOffset);
|
|
15669
16417
|
const slopedEavesGable = proposeSlopedRoofEavesGableThermalBridges(elements, floors, globalOrientationOffset);
|
|
15670
16418
|
const groundContinuous = proposeWallGroundContinuous(elements, openings, floors);
|
|
15671
16419
|
const intermediateContinuous = proposeWallIntermediateContinuous(elements, openings, floors);
|
|
@@ -16770,9 +17518,6 @@ function editorFloorsAndElementsForParsedCsv(parsed) {
|
|
|
16770
17518
|
var ECAAS_SCHEMAS = {
|
|
16771
17519
|
"1.0.0a7": () => Promise.resolve().then(() => __toESM(require_ecaas_input_fhs_schema(), 1)).then((module) => module.default)
|
|
16772
17520
|
};
|
|
16773
|
-
function csvTarget(csv) {
|
|
16774
|
-
return csvMetadataValue(csv, "TargetBundleId");
|
|
16775
|
-
}
|
|
16776
17521
|
async function snapshotBatchTarget(config, readFile) {
|
|
16777
17522
|
const sources = {};
|
|
16778
17523
|
const ids = [];
|
|
@@ -16855,47 +17600,13 @@ function treatedFloorAreaBatchMessage(config, snapshot) {
|
|
|
16855
17600
|
});
|
|
16856
17601
|
return messages.length ? messages.join("\n") : void 0;
|
|
16857
17602
|
}
|
|
16858
|
-
|
|
16859
|
-
function
|
|
16860
|
-
|
|
16861
|
-
let loaded = preparations.get(id);
|
|
16862
|
-
if (!loaded) {
|
|
16863
|
-
loaded = instantiateTargetPreparation(manifest);
|
|
16864
|
-
preparations.set(id, loaded);
|
|
16865
|
-
loaded.catch(() => preparations.delete(id));
|
|
16866
|
-
}
|
|
16867
|
-
return loaded.then((prepare) => (request, snippets) => {
|
|
16868
|
-
try {
|
|
16869
|
-
return prepare(request, snippets);
|
|
16870
|
-
} catch (error) {
|
|
16871
|
-
preparations.delete(id);
|
|
16872
|
-
throw error;
|
|
16873
|
-
}
|
|
16874
|
-
});
|
|
17603
|
+
function appPreparation(module) {
|
|
17604
|
+
if (typeof module.prepare_target_scenario !== "function") throw new Error("This app build cannot prepare HEM targets: its WASM does not export prepare_target_scenario");
|
|
17605
|
+
return module.prepare_target_scenario;
|
|
16875
17606
|
}
|
|
16876
|
-
|
|
16877
|
-
|
|
16878
|
-
|
|
16879
|
-
const artifact2 = manifest.artifacts.find((asset) => asset.path === path);
|
|
16880
|
-
if (!artifact2) throw new Error(`Missing preparation asset ${path}`);
|
|
16881
|
-
return artifact2;
|
|
16882
|
-
};
|
|
16883
|
-
const [javascript, wasm] = await Promise.all([
|
|
16884
|
-
assets.bytes(artifact(manifest.preparation.javascript)),
|
|
16885
|
-
assets.bytes(artifact(manifest.preparation.wasm))
|
|
16886
|
-
]);
|
|
16887
|
-
const url = URL.createObjectURL(new Blob([javascript], { type: "text/javascript" }));
|
|
16888
|
-
try {
|
|
16889
|
-
const module = await import(
|
|
16890
|
-
/* @vite-ignore */
|
|
16891
|
-
url
|
|
16892
|
-
);
|
|
16893
|
-
await module.default({ module_or_path: wasm });
|
|
16894
|
-
if (typeof module.prepare_target_scenario !== "function") throw new Error("Pinned preparation artifact does not implement target preparation protocol 1");
|
|
16895
|
-
return module.prepare_target_scenario;
|
|
16896
|
-
} finally {
|
|
16897
|
-
URL.revokeObjectURL(url);
|
|
16898
|
-
}
|
|
17607
|
+
function preparedByBuild(versionInfo, remedy) {
|
|
17608
|
+
if (!versionInfo?.build_id || !versionInfo.source_git_commit) throw new Error(`Cannot record which build prepares this run: the WASM version file (wasm_version.json) is missing or has no build_id and source_git_commit. ${remedy}`);
|
|
17609
|
+
return { build_id: versionInfo.build_id, source_git_commit: versionInfo.source_git_commit, variant: versionInfo.variant, sha256: versionInfo.sha256 };
|
|
16899
17610
|
}
|
|
16900
17611
|
async function prepareTargetBatch(config, snapshot, manifest, configName, runId, startedAt, prepare) {
|
|
16901
17612
|
const target = resolveHemTarget(snapshot.targetBundleId);
|
|
@@ -16977,7 +17688,7 @@ async function prepareTargetBatch(config, snapshot, manifest, configName, runId,
|
|
|
16977
17688
|
}
|
|
16978
17689
|
}
|
|
16979
17690
|
if (heatingProfile && (modes.length !== 1 || modes[0] !== "actual")) throw new Error("Heating profiles require actual alone; they are not FHS compliance calculations");
|
|
16980
|
-
await assertTargetDefaults(source.csv, source.defaults, defaults_json);
|
|
17691
|
+
await assertTargetDefaults(source.csv, source.defaults, defaults_json, target.version);
|
|
16981
17692
|
const request = { csv: source.csv, schema_json, defaults_json, ...targetPreparationContract(target) };
|
|
16982
17693
|
const result = JSON.parse(prepare(JSON.stringify(request), JSON.stringify(snippets)));
|
|
16983
17694
|
if (!result.ok) throw new Error(result.error ?? "Target preparation failed");
|
|
@@ -17056,12 +17767,12 @@ function withFhsInputErrors(output, csv, snippetKeys = /* @__PURE__ */ new Set()
|
|
|
17056
17767
|
return errors.length ? { ...output, validation: { ...output.validation, is_valid: false, errors: [...output.validation.errors, ...errors] } } : output;
|
|
17057
17768
|
}
|
|
17058
17769
|
function preparationManifest(manifest) {
|
|
17059
|
-
const paths = new Set(
|
|
17770
|
+
const paths = /* @__PURE__ */ new Set([manifest.preparation.schema, manifest.preparation.defaults]);
|
|
17060
17771
|
return { ...manifest, artifacts: manifest.artifacts.filter((artifact) => paths.has(artifact.path)) };
|
|
17061
17772
|
}
|
|
17062
|
-
async function prepareTargetCsvWithManifest(csv, manifest, readFile) {
|
|
17773
|
+
async function prepareTargetCsvWithManifest(csv, manifest, prepare, readFile) {
|
|
17063
17774
|
const id = csvTarget(csv);
|
|
17064
|
-
if (
|
|
17775
|
+
if (id !== manifest.bundleId) throw new Error("Source CSV and preparation target differ");
|
|
17065
17776
|
const target = resolveHemTarget(id);
|
|
17066
17777
|
const assets = await TargetAssets.open();
|
|
17067
17778
|
await assets.download(preparationManifest(manifest), () => {
|
|
@@ -17070,13 +17781,12 @@ async function prepareTargetCsvWithManifest(csv, manifest, readFile) {
|
|
|
17070
17781
|
const ecaas = findEcaasOnlyProductsInCsv(csv).length > 0;
|
|
17071
17782
|
const ecaasSchema = ecaas ? ECAAS_SCHEMAS[target.wrapperVersion] : void 0;
|
|
17072
17783
|
const unavailable = ecaas && !ecaasSchema;
|
|
17073
|
-
const [defaults_json, schema_json, capturedDefaults
|
|
17784
|
+
const [defaults_json, schema_json, capturedDefaults] = await Promise.all([
|
|
17074
17785
|
text(manifest.preparation.defaults),
|
|
17075
17786
|
ecaasSchema ? ecaasSchema() : text(manifest.preparation.schema).then((schema) => correctTargetSchema(target.id, schema)),
|
|
17076
|
-
captureDeclaredDefaults(csv, readFile)
|
|
17077
|
-
loadTargetPreparation(manifest)
|
|
17787
|
+
captureDeclaredDefaults(csv, readFile)
|
|
17078
17788
|
]);
|
|
17079
|
-
await assertTargetDefaults(csv, capturedDefaults, defaults_json);
|
|
17789
|
+
await assertTargetDefaults(csv, capturedDefaults, defaults_json, target.version);
|
|
17080
17790
|
const result = JSON.parse(prepare(JSON.stringify({
|
|
17081
17791
|
csv,
|
|
17082
17792
|
schema_json,
|
|
@@ -17108,12 +17818,12 @@ async function captureDeclaredDefaults(csv, readFile) {
|
|
|
17108
17818
|
JSON.parse(json);
|
|
17109
17819
|
return { json, sha256: await sha256(new TextEncoder().encode(json)) };
|
|
17110
17820
|
}
|
|
17111
|
-
async function assertTargetDefaults(csv, captured, pinned) {
|
|
17821
|
+
async function assertTargetDefaults(csv, captured, pinned, version) {
|
|
17112
17822
|
const path = csvMetadataValue(csv, "DefaultsPath");
|
|
17113
17823
|
if (!path) return;
|
|
17114
17824
|
if (!captured || await sha256(new TextEncoder().encode(captured.json)) !== captured.sha256) throw new Error(`Missing or changed saved defaults '${path}'. Explicitly refresh and resave the batch.`);
|
|
17115
17825
|
if (captured.sha256 !== await sha256(new TextEncoder().encode(pinned))) {
|
|
17116
|
-
throw new Error(`Defaults '${path}' differ from
|
|
17826
|
+
throw new Error(`Defaults '${path}' differ from HEM ${version}'s pinned defaults. If this file is the standard template, refresh it. In the Vulcan app, open Workspace in the profile menu and click Restore Sample Library. Restore replaces every sample library file with the shipped copy. First copy the ones you have edited: shipped snippets, the example model (example_semi_detached.csv) and the tariff files (tariffs.meta.json, Example Energy.csv). If it is your own file, keep a copy, move the settings you need into the CSV or into snippets, then remove the DefaultsPath row from the CSV. HEM ${version} then uses its pinned defaults.`);
|
|
17117
17827
|
}
|
|
17118
17828
|
}
|
|
17119
17829
|
function selectedWeather(scenario) {
|
|
@@ -17143,13 +17853,24 @@ async function captureWeather(choice, readFile) {
|
|
|
17143
17853
|
}
|
|
17144
17854
|
|
|
17145
17855
|
// ../hem-target-runtime/src/hem/cliTargetHost.ts
|
|
17856
|
+
async function packageConverter(remedy) {
|
|
17857
|
+
const glue = "/app/wasm_wrapper.js";
|
|
17858
|
+
const module = await import(
|
|
17859
|
+
/* @vite-ignore */
|
|
17860
|
+
glue
|
|
17861
|
+
);
|
|
17862
|
+
await module.default({ module_or_path: "/app/wasm_wrapper_bg.wasm" });
|
|
17863
|
+
const response = await fetch("/app/wasm_version.json");
|
|
17864
|
+
if (!response.ok) throw new Error("The package WASM version file is missing");
|
|
17865
|
+
return { prepare: appPreparation(module), preparedBy: preparedByBuild(await response.json(), remedy) };
|
|
17866
|
+
}
|
|
17146
17867
|
async function run(request) {
|
|
17147
17868
|
const { manifest } = request;
|
|
17148
17869
|
const target = resolveHemTarget(manifest.bundleId);
|
|
17149
17870
|
validateTargetManifest(manifest, target);
|
|
17150
17871
|
if (request.operation === "prepare") {
|
|
17151
17872
|
if (typeof request.csv !== "string") throw new Error("CSV source required");
|
|
17152
|
-
return prepareTargetCsvWithManifest(request.csv, manifest, window.targetCliRead);
|
|
17873
|
+
return prepareTargetCsvWithManifest(request.csv, manifest, (await packageConverter(request.wasmRemedy)).prepare, window.targetCliRead);
|
|
17153
17874
|
}
|
|
17154
17875
|
const config = request.config;
|
|
17155
17876
|
if (request.operation === "snapshot") {
|
|
@@ -17167,15 +17888,16 @@ async function run(request) {
|
|
|
17167
17888
|
await assets.download(manifest, (completed, total) => {
|
|
17168
17889
|
void window.targetCliProgress({ status: "running", stage: "download", completed, total });
|
|
17169
17890
|
});
|
|
17170
|
-
const
|
|
17891
|
+
const { prepare, preparedBy } = await packageConverter(request.wasmRemedy);
|
|
17892
|
+
const jobs = (await prepareTargetBatch(
|
|
17171
17893
|
config,
|
|
17172
17894
|
config.__hem,
|
|
17173
17895
|
manifest,
|
|
17174
17896
|
request.configName,
|
|
17175
17897
|
request.jobId,
|
|
17176
17898
|
request.startedAt,
|
|
17177
|
-
|
|
17178
|
-
);
|
|
17899
|
+
prepare
|
|
17900
|
+
)).map((job) => ({ ...job, preparedBy }));
|
|
17179
17901
|
return new Promise((resolve2, reject) => {
|
|
17180
17902
|
const worker = new Worker(target.runtime === "python" ? "/python-worker.mjs" : "/rust-worker.mjs", { type: "module" });
|
|
17181
17903
|
const finish = (error) => {
|