bimdown-cli 0.3.0 → 0.5.1

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.
Files changed (151) hide show
  1. package/README.md +24 -3
  2. package/dist/chunk-4SKM4RHY.js +142 -0
  3. package/dist/chunk-4SKM4RHY.js.map +1 -0
  4. package/dist/chunk-4YHVOWS4.js +255 -0
  5. package/dist/chunk-4YHVOWS4.js.map +1 -0
  6. package/dist/chunk-AYAXRYGP.js +2129 -0
  7. package/dist/chunk-AYAXRYGP.js.map +1 -0
  8. package/dist/chunk-EC5MR5ZH.js +648 -0
  9. package/dist/chunk-EC5MR5ZH.js.map +1 -0
  10. package/dist/chunk-HS3PO2LB.js +487 -0
  11. package/dist/chunk-HS3PO2LB.js.map +1 -0
  12. package/dist/chunk-IQJA3EFO.js +179 -0
  13. package/dist/chunk-IQJA3EFO.js.map +1 -0
  14. package/dist/chunk-JY6KWRDB.js +80 -0
  15. package/dist/chunk-JY6KWRDB.js.map +1 -0
  16. package/dist/chunk-KWSGJUMZ.js +2501 -0
  17. package/dist/chunk-KWSGJUMZ.js.map +1 -0
  18. package/dist/chunk-LWYIPR64.js +35 -0
  19. package/dist/chunk-LWYIPR64.js.map +1 -0
  20. package/dist/chunk-OBY3UYCO.js +44 -0
  21. package/dist/chunk-OBY3UYCO.js.map +1 -0
  22. package/dist/chunk-XC6WHJRL.js +29 -0
  23. package/dist/chunk-XC6WHJRL.js.map +1 -0
  24. package/dist/chunk-XQU52JKB.js +187 -0
  25. package/dist/chunk-XQU52JKB.js.map +1 -0
  26. package/dist/clash-load-D3LNQR6G.js +941 -0
  27. package/dist/clash-load-D3LNQR6G.js.map +1 -0
  28. package/dist/cli.js +431 -0
  29. package/dist/cli.js.map +1 -0
  30. package/dist/dehydrate-ZHAGOI7Q.js +90 -0
  31. package/dist/dehydrate-ZHAGOI7Q.js.map +1 -0
  32. package/dist/diff-T2KOK2WR.js +89 -0
  33. package/dist/diff-T2KOK2WR.js.map +1 -0
  34. package/dist/engine-2TPWJVEQ.js +12 -0
  35. package/dist/engine-2TPWJVEQ.js.map +1 -0
  36. package/dist/hydrate-V24H7IF3.js +673 -0
  37. package/dist/hydrate-V24H7IF3.js.map +1 -0
  38. package/dist/import-ifc-RCZSXDA6.js +5324 -0
  39. package/dist/import-ifc-RCZSXDA6.js.map +1 -0
  40. package/dist/info-QC7YXWNX.js +92 -0
  41. package/dist/info-QC7YXWNX.js.map +1 -0
  42. package/dist/init-VWDML3UC.js +112 -0
  43. package/dist/init-VWDML3UC.js.map +1 -0
  44. package/dist/lib.d.ts +492 -0
  45. package/dist/lib.js +6528 -0
  46. package/dist/lib.js.map +1 -0
  47. package/dist/mep-W4HJI363.js +25 -0
  48. package/dist/mep-W4HJI363.js.map +1 -0
  49. package/dist/merge-ESOPDSA5.js +413 -0
  50. package/dist/merge-ESOPDSA5.js.map +1 -0
  51. package/dist/publish-3TAXQCUV.js +80 -0
  52. package/dist/publish-3TAXQCUV.js.map +1 -0
  53. package/dist/render-UEWYHPN6.js +1807 -0
  54. package/dist/render-UEWYHPN6.js.map +1 -0
  55. package/dist/resolve-topology-AQ2RO3W3.js +338 -0
  56. package/dist/resolve-topology-AQ2RO3W3.js.map +1 -0
  57. package/dist/spec/csv-schema/annotation/dimension.yaml +77 -0
  58. package/dist/spec/csv-schema/annotation/tag.yaml +44 -0
  59. package/dist/spec/csv-schema/annotation/text_note.yaml +52 -0
  60. package/dist/spec/csv-schema/architecture/ceiling.yaml +8 -1
  61. package/dist/spec/csv-schema/architecture/column.yaml +5 -1
  62. package/dist/spec/csv-schema/architecture/curtain_wall.yaml +45 -5
  63. package/dist/spec/csv-schema/architecture/door.yaml +5 -0
  64. package/dist/spec/csv-schema/architecture/furniture.yaml +28 -0
  65. package/dist/spec/csv-schema/architecture/opening.yaml +27 -6
  66. package/dist/spec/csv-schema/architecture/railing.yaml +35 -0
  67. package/dist/spec/csv-schema/architecture/roof.yaml +34 -1
  68. package/dist/spec/csv-schema/architecture/slab.yaml +19 -0
  69. package/dist/spec/csv-schema/architecture/space.yaml +11 -1
  70. package/dist/spec/csv-schema/architecture/stair.yaml +49 -0
  71. package/dist/spec/csv-schema/architecture/stair_landing.yaml +36 -0
  72. package/dist/spec/csv-schema/architecture/stair_run.yaml +31 -0
  73. package/dist/spec/csv-schema/architecture/wall.yaml +14 -1
  74. package/dist/spec/csv-schema/architecture/window.yaml +19 -0
  75. package/dist/spec/csv-schema/base/element.yaml +20 -11
  76. package/dist/spec/csv-schema/base/furniture_params.yaml +60 -0
  77. package/dist/spec/csv-schema/base/hosted_element.yaml +10 -2
  78. package/dist/spec/csv-schema/base/mep_connectable.yaml +23 -0
  79. package/dist/spec/csv-schema/base/mep_design.yaml +24 -0
  80. package/dist/spec/csv-schema/base/mep_insulated.yaml +9 -0
  81. package/dist/spec/csv-schema/base/mep_system_tag.yaml +12 -0
  82. package/dist/spec/csv-schema/base/point_element.yaml +1 -0
  83. package/dist/spec/csv-schema/base/section_profile.yaml +5 -0
  84. package/dist/spec/csv-schema/base/spatial_line_element.yaml +4 -2
  85. package/dist/spec/csv-schema/base/structural_section_profile.yaml +50 -0
  86. package/dist/spec/csv-schema/base/vertical_span.yaml +9 -3
  87. package/dist/spec/csv-schema/base/wall_bounded.yaml +21 -0
  88. package/dist/spec/csv-schema/grid.yaml +5 -0
  89. package/dist/spec/csv-schema/mep/cable_tray.yaml +10 -3
  90. package/dist/spec/csv-schema/mep/circuit.yaml +70 -0
  91. package/dist/spec/csv-schema/mep/conduit.yaml +2 -2
  92. package/dist/spec/csv-schema/mep/connector.yaml +112 -0
  93. package/dist/spec/csv-schema/mep/duct.yaml +10 -3
  94. package/dist/spec/csv-schema/mep/equipment.yaml +18 -1
  95. package/dist/spec/csv-schema/mep/mep_node.yaml +91 -2
  96. package/dist/spec/csv-schema/mep/mep_system.yaml +21 -0
  97. package/dist/spec/csv-schema/mep/pipe.yaml +27 -3
  98. package/dist/spec/csv-schema/mep/terminal.yaml +22 -1
  99. package/dist/spec/csv-schema/model_group.yaml +40 -0
  100. package/dist/spec/csv-schema/sheet/sheet.yaml +50 -0
  101. package/dist/spec/csv-schema/sheet/sheet_viewport.yaml +86 -0
  102. package/dist/spec/csv-schema/structure/beam.yaml +29 -1
  103. package/dist/spec/csv-schema/structure/beam_system.yaml +29 -0
  104. package/dist/spec/csv-schema/structure/brace.yaml +24 -1
  105. package/dist/spec/csv-schema/structure/foundation.yaml +40 -7
  106. package/dist/spec/csv-schema/structure/structure_column.yaml +19 -1
  107. package/dist/spec/csv-schema/structure/structure_slab.yaml +32 -0
  108. package/dist/spec/csv-schema/structure/structure_wall.yaml +22 -0
  109. package/dist/spec/csv-schema/types/beam_type.yaml +11 -0
  110. package/dist/spec/csv-schema/types/ceiling_type.yaml +6 -0
  111. package/dist/spec/csv-schema/types/column_type.yaml +12 -0
  112. package/dist/spec/csv-schema/types/curtain_wall_type.yaml +32 -0
  113. package/dist/spec/csv-schema/types/door_type.yaml +27 -0
  114. package/dist/spec/csv-schema/types/element_type.yaml +21 -0
  115. package/dist/spec/csv-schema/types/fenestration.yaml +16 -0
  116. package/dist/spec/csv-schema/types/foundation_type.yaml +36 -0
  117. package/dist/spec/csv-schema/types/furniture_type.yaml +11 -0
  118. package/dist/spec/csv-schema/types/layered_type.yaml +13 -0
  119. package/dist/spec/csv-schema/types/railing_type.yaml +40 -0
  120. package/dist/spec/csv-schema/types/roof_type.yaml +7 -0
  121. package/dist/spec/csv-schema/types/slab_type.yaml +9 -0
  122. package/dist/spec/csv-schema/types/type_layer.yaml +47 -0
  123. package/dist/spec/csv-schema/types/wall_type.yaml +6 -0
  124. package/dist/spec/csv-schema/types/window_type.yaml +31 -0
  125. package/dist/spec/csv-schema/underlay.yaml +73 -0
  126. package/dist/spec/csv-schema/view.yaml +36 -0
  127. package/dist/spec/duckdb-strategy.md +4 -3
  128. package/dist/spec/geojson-schema/readme.md +380 -0
  129. package/dist/spec/mep-port-conventions.md +190 -0
  130. package/dist/spec/migration-guide.md +1 -1
  131. package/dist/spec/project_metadata.schema.yaml +52 -4
  132. package/dist/spec/readme.md +356 -97
  133. package/dist/spec/starter-types/global/beam_type.csv +5 -0
  134. package/dist/spec/starter-types/global/ceiling_type.csv +3 -0
  135. package/dist/spec/starter-types/global/column_type.csv +5 -0
  136. package/dist/spec/starter-types/global/curtain_wall_type.csv +2 -0
  137. package/dist/spec/starter-types/global/door_type.csv +6 -0
  138. package/dist/spec/starter-types/global/foundation_type.csv +7 -0
  139. package/dist/spec/starter-types/global/furniture_type.csv +11 -0
  140. package/dist/spec/starter-types/global/railing_type.csv +5 -0
  141. package/dist/spec/starter-types/global/roof_type.csv +3 -0
  142. package/dist/spec/starter-types/global/slab_type.csv +4 -0
  143. package/dist/spec/starter-types/global/type_layer.csv +40 -0
  144. package/dist/spec/starter-types/global/wall_type.csv +8 -0
  145. package/dist/spec/starter-types/global/window_type.csv +6 -0
  146. package/dist/spec/svg-schema/readme.md +47 -1
  147. package/package.json +17 -5
  148. package/dist/index.js +0 -3366
  149. package/dist/index.js.map +0 -1
  150. package/dist/spec/csv-schema/base/mep_connected_segment.yaml +0 -17
  151. package/dist/spec/csv-schema/base/mep_system.yaml +0 -7
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/geo/roof-solver.ts"],"sourcesContent":["/**\n * Copy of bimdown-editor/editor/src/geometry/roofSolver.ts (the editor's\n * footprint roof solver), so `render` draws the same ridges, hips, valleys\n * and slope arrows the editor does. Keep the two in sync.\n */\n/**\n * Footprint roof solver (Revit \"roof by footprint\").\n *\n * Every footprint edge either defines a slope (an eave: a plane rising inward\n * from the edge at its slope angle) or not (a gable / rake edge: the roof is\n * cut vertically there). The roof's underside is the lowest of the planes that\n * can reach a point, where an edge's plane reaches the wedge between the\n * bisectors at its two corners (and its own inner side). For convex footprints\n * that is exactly the lower envelope of all planes; the wedge restriction is\n * what keeps an L / T / U roof correct at its re-entrant corners (valleys)\n * instead of one wing's plane cutting through the other wing. No bounding-box\n * assumption anywhere.\n *\n * Also handled here: a mansard deck (a cap on the rise), extrusion roofs (a\n * profile across the first edge, extruded along it) and convex-decomposed\n * openings, so the roof mesh needs no CSG.\n *\n * Pure geometry, no three.js: the CLI renderer carries a copy of this file.\n */\n\nexport type P2 = { x: number; y: number };\n\n/** rise(p) = a·x + b·y + c, metres above the eave (roof base). */\nexport interface Plane { a: number; b: number; c: number }\n\n/** Half-plane a·x + b·y + c ≥ 0. */\ninterface HalfPlane { a: number; b: number; c: number }\n\n/** Extrusion roof: underside rise `z` at distance `u` across the first edge. */\nexport interface ExtrusionProfile {\n /** Point on the first edge line (u = 0). */\n origin: P2;\n /** Unit vector across the first edge, pointing into the footprint. */\n across: P2;\n pts: { u: number; z: number }[];\n}\n\nexport interface RoofInput {\n outline: P2[];\n /** Slope in degrees per edge outline[i] → outline[i+1]; ≤ 0 = not slope-defining. */\n edgeSlopes: number[];\n /** Maximum rise (mansard upper deck). */\n cap?: number;\n /** Extrusion roof: replaces the edge planes. */\n profile?: ExtrusionProfile;\n}\n\nexport interface RoofPiece {\n /** Convex, counter-clockwise. */\n poly: P2[];\n /** Index into `planes`. */\n plane: number;\n}\n\nexport type RoofLineKind = 'ridge' | 'hip' | 'valley';\nexport interface RoofLine { a: P2; b: P2; kind: RoofLineKind }\n\nexport interface RoofSolution {\n planes: Plane[];\n /** Footprint edge index per plane (−1: cap, flat or profile plane). */\n planeEdge: number[];\n pieces: RoofPiece[];\n /** Underside rise above the eave at a plan point (0 outside every plane). */\n rise(p: P2): number;\n /** Fold lines between roof planes. */\n lines: RoofLine[];\n maxRise: number;\n /** Largest slope (degrees) of any plane; 0 for a flat roof. */\n maxSlopeDeg: number;\n}\n\nconst EPS = 1e-9;\nconst AREA_EPS = 1e-7;\n\n// ─── Polygon helpers ─────────────────────────────────────────────────────────\n\nexport function signedArea(poly: P2[]): number {\n let a = 0;\n for (let i = 0; i < poly.length; i++) {\n const p = poly[i], q = poly[(i + 1) % poly.length];\n a += p.x * q.y - q.x * p.y;\n }\n return a / 2;\n}\n\n/** Drop consecutive duplicates (and a closing repeat of the first vertex). */\nexport function cleanRing(poly: P2[], eps = 1e-6): P2[] {\n const out: P2[] = [];\n for (const p of poly) {\n const last = out[out.length - 1];\n if (!last || Math.hypot(p.x - last.x, p.y - last.y) > eps) out.push({ x: p.x, y: p.y });\n }\n while (out.length > 1 && Math.hypot(out[0].x - out[out.length - 1].x, out[0].y - out[out.length - 1].y) <= eps) out.pop();\n return out;\n}\n\nconst evalHp = (h: HalfPlane, p: P2) => h.a * p.x + h.b * p.y + h.c;\nexport const riseOf = (pl: Plane, p: P2) => pl.a * p.x + pl.b * p.y + pl.c;\n\n/** Keep the part of a convex polygon where f ≥ 0 (Sutherland–Hodgman, one plane). */\nexport function clipHalf(poly: P2[], h: HalfPlane): P2[] {\n const out: P2[] = [];\n const n = poly.length;\n for (let i = 0; i < n; i++) {\n const a = poly[i], b = poly[(i + 1) % n];\n const fa = evalHp(h, a), fb = evalHp(h, b);\n if (fa >= -EPS) out.push(a);\n if ((fa > EPS && fb < -EPS) || (fa < -EPS && fb > EPS)) {\n const t = fa / (fa - fb);\n out.push({ x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t });\n }\n }\n return cleanRing(out, 1e-9);\n}\n\nfunction isPiece(poly: P2[]): boolean {\n return poly.length >= 3 && Math.abs(signedArea(poly)) > AREA_EPS;\n}\n\n/** Ear-clipping triangulation of a simple polygon (any orientation). */\nexport function triangulate(poly: P2[]): P2[][] {\n const pts = cleanRing(poly);\n if (pts.length < 3) return [];\n const ccw = signedArea(pts) >= 0 ? pts : pts.slice().reverse();\n const idx = ccw.map((_, i) => i);\n const tris: P2[][] = [];\n const cross = (o: P2, a: P2, b: P2) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);\n const inTri = (p: P2, a: P2, b: P2, c: P2) =>\n cross(a, b, p) >= -EPS && cross(b, c, p) >= -EPS && cross(c, a, p) >= -EPS;\n let guard = 0;\n while (idx.length > 3 && guard++ < 10000) {\n let clipped = false;\n for (let k = 0; k < idx.length; k++) {\n const i0 = idx[(k + idx.length - 1) % idx.length], i1 = idx[k], i2 = idx[(k + 1) % idx.length];\n const a = ccw[i0], b = ccw[i1], c = ccw[i2];\n const cr = cross(a, b, c);\n if (cr <= EPS) {\n // Collinear: drop the middle vertex.\n if (Math.abs(cr) <= EPS) { idx.splice(k, 1); clipped = true; break; }\n continue;\n }\n let ear = true;\n for (const j of idx) {\n if (j === i0 || j === i1 || j === i2) continue;\n const p = ccw[j];\n if ((p.x === a.x && p.y === a.y) || (p.x === b.x && p.y === b.y) || (p.x === c.x && p.y === c.y)) continue;\n if (inTri(p, a, b, c)) { ear = false; break; }\n }\n if (!ear) continue;\n tris.push([a, b, c]);\n idx.splice(k, 1);\n clipped = true;\n break;\n }\n if (!clipped) break; // degenerate input: give up on the rest\n }\n if (idx.length === 3) {\n const t = idx.map(i => ccw[i]);\n if (Math.abs(signedArea(t)) > AREA_EPS) tris.push(signedArea(t) > 0 ? t : t.reverse());\n }\n return tris;\n}\n\n/** Convex polygon minus convex polygon: up to n convex pieces. */\nfunction subtractConvex(piece: P2[], hole: P2[]): P2[][] {\n const h = signedArea(hole) >= 0 ? hole : hole.slice().reverse();\n const out: P2[][] = [];\n let rest = piece;\n for (let i = 0; i < h.length && rest.length >= 3; i++) {\n const a = h[i], b = h[(i + 1) % h.length];\n // Inside of a CCW edge is its left: (b−a) × (p−a) ≥ 0.\n const inside: HalfPlane = { a: -(b.y - a.y), b: b.x - a.x, c: (b.y - a.y) * a.x - (b.x - a.x) * a.y };\n const outside: HalfPlane = { a: -inside.a, b: -inside.b, c: -inside.c };\n const part = clipHalf(rest, outside);\n if (isPiece(part)) out.push(part);\n rest = clipHalf(rest, inside);\n }\n return out;\n}\n\n/** Pieces minus a set of (any-shape) holes. */\nexport function subtractHoles<T extends { poly: P2[] }>(pieces: T[], holes: P2[][]): T[] {\n let cur = pieces;\n for (const hole of holes) {\n for (const tri of triangulate(hole)) {\n const next: T[] = [];\n for (const pc of cur) {\n if (!bboxOverlap(pc.poly, tri)) { next.push(pc); continue; }\n for (const poly of subtractConvex(pc.poly, tri)) next.push({ ...pc, poly });\n }\n cur = next;\n }\n }\n return cur;\n}\n\nfunction bboxOverlap(a: P2[], b: P2[]): boolean {\n const ba = bounds(a), bb = bounds(b);\n return ba.minX <= bb.maxX + EPS && bb.minX <= ba.maxX + EPS && ba.minY <= bb.maxY + EPS && bb.minY <= ba.maxY + EPS;\n}\n\nfunction bounds(poly: P2[]) {\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n for (const p of poly) {\n if (p.x < minX) minX = p.x; if (p.x > maxX) maxX = p.x;\n if (p.y < minY) minY = p.y; if (p.y > maxY) maxY = p.y;\n }\n return { minX, minY, maxX, maxY };\n}\n\n/** Convex polygon ∩ convex polygon (CCW clip). */\nexport function intersectConvex(subject: P2[], clip: P2[]): P2[] {\n const c = signedArea(clip) >= 0 ? clip : clip.slice().reverse();\n let out = subject;\n for (let i = 0; i < c.length && out.length >= 3; i++) {\n const a = c[i], b = c[(i + 1) % c.length];\n out = clipHalf(out, { a: -(b.y - a.y), b: b.x - a.x, c: (b.y - a.y) * a.x - (b.x - a.x) * a.y });\n }\n return out;\n}\n\nexport function pointInPolygon(p: P2, poly: P2[]): boolean {\n let inside = false;\n for (let i = 0, j = poly.length - 1; i < poly.length; j = i++) {\n const a = poly[i], b = poly[j];\n if ((a.y > p.y) !== (b.y > p.y) && p.x < ((b.x - a.x) * (p.y - a.y)) / (b.y - a.y) + a.x) inside = !inside;\n }\n return inside;\n}\n\nexport function centroid(poly: P2[]): P2 {\n let a = 0, cx = 0, cy = 0;\n for (let i = 0; i < poly.length; i++) {\n const p = poly[i], q = poly[(i + 1) % poly.length];\n const c = p.x * q.y - q.x * p.y;\n a += c; cx += (p.x + q.x) * c; cy += (p.y + q.y) * c;\n }\n if (Math.abs(a) < 1e-12) {\n const n = poly.length || 1;\n return { x: poly.reduce((s, v) => s + v.x, 0) / n, y: poly.reduce((s, v) => s + v.y, 0) / n };\n }\n return { x: cx / (3 * a), y: cy / (3 * a) };\n}\n\n// ─── Solver ─────────────────────────────────────────────────────────────────\n\ninterface EdgeFrame { a: P2; b: P2; n: P2; tan: number; mid: P2 }\n\n/** Signed distance from edge e's line (positive on the footprint side), as a linear function. */\nconst distFn = (e: EdgeFrame): HalfPlane => ({ a: e.n.x, b: e.n.y, c: -(e.a.x * e.n.x + e.a.y * e.n.y) });\nconst scale = (h: HalfPlane, k: number): HalfPlane => ({ a: h.a * k, b: h.b * k, c: h.c * k });\nconst minus = (p: HalfPlane, q: HalfPlane): HalfPlane => ({ a: p.a - q.a, b: p.b - q.b, c: p.c - q.c });\n\nexport function solveRoof(input: RoofInput): RoofSolution {\n const outline = cleanRing(input.outline);\n const n = outline.length;\n const orient = signedArea(outline) >= 0 ? 1 : -1;\n const planes: Plane[] = [];\n const planeEdge: number[] = [];\n const empty: RoofSolution = {\n planes: [{ a: 0, b: 0, c: 0 }], planeEdge: [-1], pieces: [], rise: () => 0, lines: [], maxRise: 0, maxSlopeDeg: 0,\n };\n if (n < 3) return empty;\n\n const edges: EdgeFrame[] = outline.map((a, i) => {\n const b = outline[(i + 1) % n];\n const len = Math.hypot(b.x - a.x, b.y - a.y) || 1;\n const ux = (b.x - a.x) / len, uy = (b.y - a.y) / len;\n const slope = input.edgeSlopes[i] ?? 0;\n return {\n a, b, n: { x: -uy * orient, y: ux * orient },\n tan: slope > 0 ? Math.tan((Math.min(slope, 89) * Math.PI) / 180) : 0,\n mid: { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 },\n };\n });\n\n const tris = triangulate(outline);\n const zeroPlane = (): number => {\n planes.push({ a: 0, b: 0, c: 0 });\n planeEdge.push(-1);\n return planes.length - 1;\n };\n\n // ── Extrusion roof: one plane per profile segment, banded across the first edge.\n if (input.profile && input.profile.pts.length >= 2) {\n const { origin, across } = input.profile;\n const pts = [...input.profile.pts].sort((p, q) => p.u - q.u);\n const uFn: HalfPlane = { a: across.x, b: across.y, c: -(origin.x * across.x + origin.y * across.y) };\n const bands: { lo: number; hi: number; plane: number }[] = [];\n const addPlane = (k: number, z0: number) => {\n // rise = z0 + k·(u) with u = uFn(p)\n planes.push({ a: k * uFn.a, b: k * uFn.b, c: z0 + k * uFn.c });\n planeEdge.push(-1);\n return planes.length - 1;\n };\n bands.push({ lo: -Infinity, hi: pts[0].u, plane: addPlane(0, pts[0].z) });\n for (let i = 0; i + 1 < pts.length; i++) {\n const du = pts[i + 1].u - pts[i].u;\n if (du < 1e-9) continue;\n const k = (pts[i + 1].z - pts[i].z) / du;\n bands.push({ lo: pts[i].u, hi: pts[i + 1].u, plane: addPlane(k, pts[i].z - k * pts[i].u) });\n }\n bands.push({ lo: pts[pts.length - 1].u, hi: Infinity, plane: addPlane(0, pts[pts.length - 1].z) });\n const pieces: RoofPiece[] = [];\n for (const tri of tris) {\n for (const band of bands) {\n let poly = tri;\n if (band.lo > -Infinity) poly = clipHalf(poly, { ...uFn, c: uFn.c - band.lo });\n if (band.hi < Infinity) poly = clipHalf(poly, scale({ ...uFn, c: uFn.c - band.hi }, -1));\n if (isPiece(poly)) pieces.push({ poly, plane: band.plane });\n }\n }\n const rise = (p: P2) => {\n const u = evalHp(uFn, p);\n for (const band of bands) if (u >= band.lo - 1e-9 && u <= band.hi + 1e-9) return riseOf(planes[band.plane], p);\n return 0;\n };\n return finish(planes, planeEdge, pieces, rise, outline);\n }\n\n // ── Footprint roof: one plane per slope-defining edge, limited to its wedge.\n const sloped = edges.map(e => e.tan > 0);\n if (!sloped.some(Boolean)) {\n const z = zeroPlane();\n return finish(planes, planeEdge, tris.map(poly => ({ poly, plane: z })), () => 0, outline);\n }\n\n const wedges: { plane: number; hps: HalfPlane[] }[] = [];\n edges.forEach((e, i) => {\n if (!sloped[i]) return;\n const d = distFn(e);\n const pl = { a: d.a * e.tan, b: d.b * e.tan, c: d.c * e.tan };\n // Collinear eaves with one slope share a plane (T / U footprints).\n let pi = planes.findIndex((q, k) => planeEdge[k] >= 0\n && Math.abs(q.a - pl.a) < 1e-9 && Math.abs(q.b - pl.b) < 1e-9 && Math.abs(q.c - pl.c) < 1e-7);\n if (pi < 0) {\n planes.push(pl);\n planeEdge.push(i);\n pi = planes.length - 1;\n }\n const hps: HalfPlane[] = [d];\n for (const j of [(i + n - 1) % n, (i + 1) % n]) {\n const o = edges[j];\n // Boundary through the shared corner: where this plane meets the\n // neighbour's plane, or the neighbour's own line when it is a gable.\n const g = sloped[j] ? minus(scale(d, e.tan), scale(distFn(o), o.tan)) : distFn(o);\n const s = evalHp(g, e.mid);\n if (Math.abs(s) < 1e-9) continue; // collinear neighbour\n hps.push(scale(g, s > 0 ? 1 : -1));\n }\n wedges.push({ plane: pi, hps });\n });\n let capPlane = -1;\n if (input.cap !== undefined && input.cap > 0) {\n planes.push({ a: 0, b: 0, c: input.cap });\n planeEdge.push(-1);\n capPlane = planes.length - 1;\n }\n let zero = -1;\n\n const inWedge = (w: { hps: HalfPlane[] }, p: P2, tol = 1e-7) => w.hps.every(h => evalHp(h, p) >= -tol);\n const activeAt = (p: P2, tol?: number) => {\n const act: number[] = [];\n for (const w of wedges) if (!act.includes(w.plane) && inWedge(w, p, tol)) act.push(w.plane);\n if (capPlane >= 0) act.push(capPlane);\n return act;\n };\n const rise = (p: P2) => {\n let z = Infinity;\n for (const pl of activeAt(p, 1e-6)) z = Math.min(z, riseOf(planes[pl], p));\n return z === Infinity ? 0 : Math.max(0, z);\n };\n\n // Cells: footprint triangles split along every wedge boundary, so each cell\n // sees one fixed set of reachable planes; the lower envelope inside a cell\n // is then a plain convex clip per plane.\n const lines = uniqueLines(wedges.flatMap(w => w.hps));\n const pieces: RoofPiece[] = [];\n for (const tri of tris) {\n let cells: P2[][] = [tri];\n for (const ln of lines) {\n const next: P2[][] = [];\n for (const cell of cells) {\n let pos = false, neg = false;\n for (const p of cell) {\n const v = evalHp(ln, p);\n if (v > 1e-9) pos = true; else if (v < -1e-9) neg = true;\n }\n if (!(pos && neg)) { next.push(cell); continue; }\n const a = clipHalf(cell, ln), b = clipHalf(cell, scale(ln, -1));\n if (isPiece(a)) next.push(a);\n if (isPiece(b)) next.push(b);\n }\n cells = next;\n }\n for (const cell of cells) {\n const act = activeAt(centroid(cell));\n if (act.length === 0) {\n if (zero < 0) zero = zeroPlane();\n pieces.push({ poly: cell, plane: zero });\n continue;\n }\n for (const i of act) {\n let poly = cell;\n for (const j of act) {\n if (j === i || poly.length < 3) continue;\n // keep plane_i ≤ plane_j\n const pi = planes[i], pj = planes[j];\n poly = clipHalf(poly, { a: pj.a - pi.a, b: pj.b - pi.b, c: pj.c - pi.c });\n }\n if (isPiece(poly)) pieces.push({ poly, plane: i });\n }\n }\n }\n return finish(planes, planeEdge, pieces, rise, outline);\n}\n\nfunction uniqueLines(hps: HalfPlane[]): HalfPlane[] {\n const out: HalfPlane[] = [];\n for (const h of hps) {\n const len = Math.hypot(h.a, h.b);\n if (len < 1e-12) continue;\n const k = { a: h.a / len, b: h.b / len, c: h.c / len };\n if (out.some(o => (Math.abs(o.a - k.a) < 1e-7 && Math.abs(o.b - k.b) < 1e-7 && Math.abs(o.c - k.c) < 1e-6)\n || (Math.abs(o.a + k.a) < 1e-7 && Math.abs(o.b + k.b) < 1e-7 && Math.abs(o.c + k.c) < 1e-6))) continue;\n out.push(k);\n }\n return out;\n}\n\nfunction finish(planes: Plane[], planeEdge: number[], pieces: RoofPiece[], rise: (p: P2) => number, outline: P2[]): RoofSolution {\n const ccwPieces = pieces.map(pc => ({ ...pc, poly: signedArea(pc.poly) >= 0 ? pc.poly : pc.poly.slice().reverse() }));\n let maxRise = 0;\n for (const pc of ccwPieces) for (const p of pc.poly) maxRise = Math.max(maxRise, riseOf(planes[pc.plane], p));\n let maxSlopeDeg = 0;\n const used = new Set(ccwPieces.map(p => p.plane));\n for (const i of used) {\n const g = Math.hypot(planes[i].a, planes[i].b);\n maxSlopeDeg = Math.max(maxSlopeDeg, (Math.atan(g) * 180) / Math.PI);\n }\n return {\n planes, planeEdge, pieces: ccwPieces, rise,\n lines: foldLines(planes, ccwPieces, rise, outline),\n maxRise, maxSlopeDeg,\n };\n}\n\n/** Boundaries between pieces of different planes, merged per plane pair and classified. */\nfunction foldLines(planes: Plane[], pieces: RoofPiece[], rise: (p: P2) => number, outline: P2[]): RoofLine[] {\n const DELTA = 1e-3;\n const planeAt = (p: P2): number => {\n for (const pc of pieces) {\n let inside = true;\n const poly = pc.poly;\n for (let i = 0; i < poly.length; i++) {\n const a = poly[i], b = poly[(i + 1) % poly.length];\n if ((b.x - a.x) * (p.y - a.y) - (b.y - a.y) * (p.x - a.x) < -1e-9) { inside = false; break; }\n }\n if (inside) return pc.plane;\n }\n return -1;\n };\n const samePlane = (i: number, j: number) => {\n const p = planes[i], q = planes[j];\n return Math.abs(p.a - q.a) < 1e-9 && Math.abs(p.b - q.b) < 1e-9 && Math.abs(p.c - q.c) < 1e-7;\n };\n const groups = new Map<string, { dir: P2; origin: P2; spans: [number, number][] }>();\n for (const pc of pieces) {\n const poly = pc.poly;\n for (let i = 0; i < poly.length; i++) {\n const a = poly[i], b = poly[(i + 1) % poly.length];\n const len = Math.hypot(b.x - a.x, b.y - a.y);\n if (len < 1e-6) continue;\n const ux = (b.x - a.x) / len, uy = (b.y - a.y) / len;\n // Outward (right) normal of a CCW edge.\n const m = { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };\n const probe = { x: m.x + uy * DELTA, y: m.y - ux * DELTA };\n if (!pointInPolygon(probe, outline)) continue;\n const other = planeAt(probe);\n if (other < 0 || other === pc.plane || samePlane(other, pc.plane)) continue;\n const key = pc.plane < other ? `${pc.plane}|${other}` : `${other}|${pc.plane}`;\n let g = groups.get(key);\n if (!g) groups.set(key, g = { dir: { x: ux, y: uy }, origin: a, spans: [] });\n const t = (p: P2) => (p.x - g!.origin.x) * g!.dir.x + (p.y - g!.origin.y) * g!.dir.y;\n const ta = t(a), tb = t(b);\n g.spans.push([Math.min(ta, tb), Math.max(ta, tb)]);\n }\n }\n const out: RoofLine[] = [];\n for (const g of groups.values()) {\n g.spans.sort((p, q) => p[0] - q[0]);\n const merged: [number, number][] = [];\n for (const s of g.spans) {\n const last = merged[merged.length - 1];\n if (last && s[0] <= last[1] + 1e-5) last[1] = Math.max(last[1], s[1]);\n else merged.push([s[0], s[1]]);\n }\n for (const [t0, t1] of merged) {\n if (t1 - t0 < 1e-4) continue;\n const a = { x: g.origin.x + g.dir.x * t0, y: g.origin.y + g.dir.y * t0 };\n const b = { x: g.origin.x + g.dir.x * t1, y: g.origin.y + g.dir.y * t1 };\n const m = { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };\n const nx = -g.dir.y, ny = g.dir.x;\n const h = rise(m);\n const h1 = rise({ x: m.x + nx * DELTA * 5, y: m.y + ny * DELTA * 5 });\n const h2 = rise({ x: m.x - nx * DELTA * 5, y: m.y - ny * DELTA * 5 });\n const convex = h - (h1 + h2) / 2 > 0;\n const level = Math.abs(rise(a) - rise(b)) < 1e-6;\n out.push({ a, b, kind: !convex ? 'valley' : level ? 'ridge' : 'hip' });\n }\n }\n return out;\n}\n\n// ─── Mesh ───────────────────────────────────────────────────────────────────\n\nexport type V3 = [number, number, number];\n\n/**\n * Closed roof solid (plan x, y, elevation z): underside at baseZ + rise,\n * top `vThick` above it, plumb-cut edges along the footprint and the holes.\n * Triangles are wound counter-clockwise seen from outside.\n */\nexport function roofSolidTriangles(sol: RoofSolution, outline: P2[], baseZ: number, vThick: number, holes: P2[][] = []): V3[][] {\n const pieces = holes.length > 0 ? subtractHoles(sol.pieces, holes) : sol.pieces;\n const under = (pc: RoofPiece, p: P2) => baseZ + Math.max(0, riseOf(sol.planes[pc.plane], p));\n const tris: V3[][] = [];\n for (const pc of pieces) {\n const poly = pc.poly;\n for (let i = 1; i + 1 < poly.length; i++) {\n const a = poly[0], b = poly[i], c = poly[i + 1];\n tris.push([[a.x, a.y, under(pc, a) + vThick], [b.x, b.y, under(pc, b) + vThick], [c.x, c.y, under(pc, c) + vThick]]);\n tris.push([[a.x, a.y, under(pc, a)], [c.x, c.y, under(pc, c)], [b.x, b.y, under(pc, b)]]);\n }\n }\n const z = (p: P2) => baseZ + sol.rise(p);\n const ring = (r: P2[], outward: boolean) => sideWalls(r, pieces, z, vThick, outward, tris);\n ring(cleanRing(outline), true);\n for (const h of holes) ring(cleanRing(h), false);\n return tris;\n}\n\n/** Vertical faces along a ring, split where the roof surface folds. */\nfunction sideWalls(ring: P2[], pieces: RoofPiece[], z: (p: P2) => number, vThick: number, outward: boolean, tris: V3[][]): void {\n if (ring.length < 3) return;\n // Walk counter-clockwise for the outline (faces out) and clockwise for holes.\n const ccw = signedArea(ring) >= 0;\n const r = ccw === outward ? ring : ring.slice().reverse();\n for (let i = 0; i < r.length; i++) {\n const a = r[i], b = r[(i + 1) % r.length];\n const len = Math.hypot(b.x - a.x, b.y - a.y);\n if (len < 1e-9) continue;\n const ux = (b.x - a.x) / len, uy = (b.y - a.y) / len;\n const ts = [0, 1];\n for (const pc of pieces) {\n for (const p of pc.poly) {\n const t = ((p.x - a.x) * ux + (p.y - a.y) * uy) / len;\n if (t <= 1e-6 || t >= 1 - 1e-6) continue;\n const off = Math.abs((p.x - a.x) * uy - (p.y - a.y) * ux);\n if (off < 1e-5) ts.push(t);\n }\n }\n ts.sort((p, q) => p - q);\n for (let k = 0; k + 1 < ts.length; k++) {\n if (ts[k + 1] - ts[k] < 1e-7) continue;\n const p = { x: a.x + (b.x - a.x) * ts[k], y: a.y + (b.y - a.y) * ts[k] };\n const q = { x: a.x + (b.x - a.x) * ts[k + 1], y: a.y + (b.y - a.y) * ts[k + 1] };\n const zp = z(p), zq = z(q);\n tris.push([[p.x, p.y, zp], [q.x, q.y, zq], [q.x, q.y, zq + vThick]]);\n tris.push([[p.x, p.y, zp], [q.x, q.y, zq + vThick], [p.x, p.y, zp + vThick]]);\n }\n }\n}\n\n// ─── Roof parameters from element attrs ─────────────────────────────────────\n\n/** Parse a semicolon-separated number list (\"30;0;30;0\"). Blank entries → NaN. */\nexport function parseNumberList(s: string | undefined): number[] {\n if (!s || !s.trim()) return [];\n return s.split(';').map(v => (v.trim() === '' ? NaN : Number(v)));\n}\n\nexport function formatNumberList(vs: number[]): string {\n return vs.map(v => (Number.isFinite(v) ? String(Math.round(v * 1000) / 1000) : '0')).join(';');\n}\n\n/**\n * Per-edge slopes a legacy roof (roof_type + one slope, no edge_slopes) implies:\n * hip → every edge, gable → every edge but the wing ends, shed → one eave.\n */\nexport function legacyEdgeSlopes(outline: P2[], roofType: string, slopeDeg: number): number[] {\n const n = outline.length;\n if (roofType === 'flat' || !(slopeDeg > 0) || n < 3) return new Array(n).fill(0);\n if (roofType === 'hip' || roofType === 'mansard') return new Array(n).fill(slopeDeg);\n const len = (i: number) => {\n const a = outline[i], b = outline[(i + 1) % n];\n return Math.hypot(b.x - a.x, b.y - a.y);\n };\n const { minX, minY, maxX, maxY } = bounds(outline);\n const alongX = maxX - minX >= maxY - minY;\n const dirOf = (i: number) => {\n const a = outline[i], b = outline[(i + 1) % n];\n const l = len(i) || 1;\n return { x: (b.x - a.x) / l, y: (b.y - a.y) / l };\n };\n if (roofType === 'shed') {\n // Low eave on the min side across the long axis (the old bbox planes).\n let best = -1, bestKey = Infinity;\n for (let i = 0; i < n; i++) {\n const d = dirOf(i);\n if (Math.abs(alongX ? d.x : d.y) < 0.99) continue;\n const a = outline[i], b = outline[(i + 1) % n];\n const key = alongX ? (a.y + b.y) / 2 : (a.x + b.x) / 2;\n if (key < bestKey - 1e-9) { bestKey = key; best = i; }\n }\n if (best < 0) for (let i = 0; i < n; i++) if (best < 0 || len(i) > len(best)) best = i;\n return outline.map((_, i) => (i === best ? slopeDeg : 0));\n }\n // gable: wing ends are short edges between two convex corners.\n const orient = signedArea(outline) >= 0 ? 1 : -1;\n const convex = (v: number) => {\n const p = outline[(v + n - 1) % n], c = outline[v], q = outline[(v + 1) % n];\n return ((c.x - p.x) * (q.y - c.y) - (c.y - p.y) * (q.x - c.x)) * orient > 1e-9;\n };\n const ends = outline.map((_, i) => convex(i) && convex((i + 1) % n)\n && len(i) < len((i + n - 1) % n) - 1e-6 && len(i) < len((i + 1) % n) - 1e-6);\n if (!ends.some(Boolean)) {\n // No wing ends (e.g. a square): gable ends across the long axis.\n for (let i = 0; i < n; i++) {\n const d = dirOf(i);\n if (Math.abs(alongX ? d.y : d.x) > 0.99) ends[i] = true;\n }\n }\n return outline.map((_, i) => (ends[i] ? 0 : slopeDeg));\n}\n\n/** Rise cap of a legacy mansard: the deck sits 30 % of the half-span in from the eaves. */\nexport function mansardCap(outline: P2[], steepDeg: number): number {\n const { minX, minY, maxX, maxY } = bounds(outline);\n const halfSpan = Math.min(maxX - minX, maxY - minY) / 2;\n return halfSpan * 0.3 * Math.tan((steepDeg * Math.PI) / 180);\n}\n\n/** Mansard lower slope: the roof's slope + 20°, at most 70°. */\nexport const mansardSlope = (slopeDeg: number) => Math.min(slopeDeg + 20, 70);\n\nexport interface RoofAttrs {\n roof_type?: string;\n slope?: string;\n edge_slopes?: string;\n profile?: string;\n}\n\n/** Solver input for a roof element (edge_slopes > legacy roof_type + slope). */\nexport function roofInputFor(outline: P2[], attrs: RoofAttrs): RoofInput {\n const ring = cleanRing(outline);\n const roofType = attrs.roof_type || 'flat';\n const slope = parseFloat(attrs.slope || '0') || 0;\n if (roofType === 'extrusion') {\n const profile = parseProfile(attrs.profile);\n if (ring.length >= 3 && profile.length >= 2) {\n const a = ring[0], b = ring[1];\n const len = Math.hypot(b.x - a.x, b.y - a.y) || 1;\n const orient = signedArea(ring) >= 0 ? 1 : -1;\n return {\n outline: ring, edgeSlopes: [],\n profile: { origin: a, across: { x: (-(b.y - a.y) / len) * orient, y: ((b.x - a.x) / len) * orient }, pts: profile },\n };\n }\n return { outline: ring, edgeSlopes: new Array(ring.length).fill(0) };\n }\n const explicit = parseNumberList(attrs.edge_slopes);\n if (explicit.length === ring.length && explicit.some(v => v > 0)) {\n const edgeSlopes = explicit.map(v => (Number.isFinite(v) && v > 0 ? v : 0));\n // A mansard keeps its upper deck over explicit (steep) edge slopes.\n const cap = roofType === 'mansard' ? mansardCap(ring, Math.max(...edgeSlopes)) : undefined;\n return { outline: ring, edgeSlopes, cap };\n }\n if (roofType === 'mansard' && slope > 0) {\n const steep = mansardSlope(slope);\n return { outline: ring, edgeSlopes: new Array(ring.length).fill(steep), cap: mansardCap(ring, steep) };\n }\n return { outline: ring, edgeSlopes: legacyEdgeSlopes(ring, roofType, slope) };\n}\n\n/** \"u,z;u,z;…\" → profile points (blank / malformed pairs dropped). */\nexport function parseProfile(s: string | undefined): { u: number; z: number }[] {\n if (!s) return [];\n const out: { u: number; z: number }[] = [];\n for (const pair of s.split(';')) {\n const [u, z] = pair.split(',').map(v => Number(v.trim()));\n if (Number.isFinite(u) && Number.isFinite(z)) out.push({ u, z });\n }\n return out;\n}\n\n/** Vertical thickness of a sloped roof slab whose perpendicular thickness is `t`. */\nexport function verticalThickness(t: number, slopeDeg: number): number {\n const c = Math.cos((Math.min(slopeDeg, 80) * Math.PI) / 180);\n return c > 1e-6 ? t / c : t;\n}\n"],"mappings":";;;AA4EA,IAAM,MAAM;AACZ,IAAM,WAAW;AAIV,SAAS,WAAW,MAAoB;AAC7C,MAAI,IAAI;AACR,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,IAAI,KAAK,CAAC,GAAG,IAAI,MAAM,IAAI,KAAK,KAAK,MAAM;AACjD,SAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;AAAA,EAC3B;AACA,SAAO,IAAI;AACb;AAGO,SAAS,UAAU,MAAY,MAAM,MAAY;AACtD,QAAM,MAAY,CAAC;AACnB,aAAW,KAAK,MAAM;AACpB,UAAM,OAAO,IAAI,IAAI,SAAS,CAAC;AAC/B,QAAI,CAAC,QAAQ,KAAK,MAAM,EAAE,IAAI,KAAK,GAAG,EAAE,IAAI,KAAK,CAAC,IAAI,IAAK,KAAI,KAAK,EAAE,GA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+ extractPointGeometry,
5
+ parseGeoJsonFile
6
+ } from "./chunk-4SKM4RHY.js";
7
+ import {
8
+ readCsv
9
+ } from "./chunk-JY6KWRDB.js";
10
+ import {
11
+ discoverLayout,
12
+ listFiles
13
+ } from "./chunk-OBY3UYCO.js";
14
+
15
+ // src/mep/load.ts
16
+ import { existsSync } from "fs";
17
+ import { join } from "path";
18
+ var MEP_CURVE_TABLES = ["duct", "pipe", "cable_tray", "conduit"];
19
+ var HOST_TABLES = ["equipment", "terminal", "mep_node"];
20
+ function num(v, fallback = 0) {
21
+ const n = parseFloat(String(v ?? ""));
22
+ return Number.isFinite(n) ? n : fallback;
23
+ }
24
+ function levelElevations(dir) {
25
+ const out = /* @__PURE__ */ new Map();
26
+ const p = join(dir, "global", "level.csv");
27
+ if (!existsSync(p)) return out;
28
+ for (const r of readCsv(p).rows) out.set(r.id, num(r.elevation));
29
+ return out;
30
+ }
31
+ function featuresById(path) {
32
+ const map = /* @__PURE__ */ new Map();
33
+ if (!existsSync(path)) return map;
34
+ try {
35
+ for (const f of parseGeoJsonFile(path).features) {
36
+ const id = String(f.properties?.id ?? "");
37
+ if (id) map.set(id, f);
38
+ }
39
+ } catch {
40
+ }
41
+ return map;
42
+ }
43
+ function loadMep(dir) {
44
+ const layout = discoverLayout(dir);
45
+ const elev = levelElevations(dir);
46
+ const dirs = [{ name: "global", path: layout.globalDir }, ...layout.levelDirs];
47
+ const curves = [];
48
+ const hosts = [];
49
+ const ports = [];
50
+ const circuits = [];
51
+ const rowOf = /* @__PURE__ */ new Map();
52
+ const hostFrame = /* @__PURE__ */ new Map();
53
+ const connectorRows = [];
54
+ for (const d of dirs) {
55
+ if (!existsSync(d.path)) continue;
56
+ const files = new Set(listFiles(d.path));
57
+ const base = elev.get(d.name) ?? 0;
58
+ for (const t of MEP_CURVE_TABLES) {
59
+ if (!files.has(`${t}.csv`)) continue;
60
+ const geo = featuresById(join(d.path, `${t}.geojson`));
61
+ for (const row of readCsv(join(d.path, `${t}.csv`)).rows) {
62
+ const f = geo.get(row.id);
63
+ if (!f || f.geometry.type !== "LineString") continue;
64
+ let lg;
65
+ try {
66
+ lg = extractLineGeometry(f);
67
+ } catch {
68
+ continue;
69
+ }
70
+ const off = num(f.properties?.base_offset);
71
+ curves.push({
72
+ id: row.id,
73
+ scope: d.name,
74
+ table: t,
75
+ a: [lg.start_x, lg.start_y, lg.start_z ?? base + off],
76
+ b: [lg.end_x, lg.end_y, lg.end_z ?? base + off],
77
+ from: row.from ?? "",
78
+ to: row.to ?? "",
79
+ system: (row.system_type ?? "").trim(),
80
+ shape: (row.shape ?? "").trim() || (t === "duct" || t === "cable_tray" ? "rect" : "round"),
81
+ w: num(row.size_x),
82
+ h: num(row.size_y),
83
+ ...t === "cable_tray" && num(row.max_fill) > 0 ? { maxFill: num(row.max_fill) } : {}
84
+ });
85
+ rowOf.set(`${d.name}/${row.id}`, row);
86
+ }
87
+ }
88
+ for (const t of HOST_TABLES) {
89
+ if (!files.has(`${t}.csv`)) continue;
90
+ const geo = featuresById(join(d.path, `${t}.geojson`));
91
+ for (const row of readCsv(join(d.path, `${t}.csv`)).rows) {
92
+ const f = geo.get(row.id);
93
+ if (!f || f.geometry.type !== "Point") continue;
94
+ const pg = extractPointGeometry(f);
95
+ const pos = [pg.x, pg.y, pg.z ?? base + num(f.properties?.base_offset)];
96
+ hosts.push({
97
+ id: row.id,
98
+ scope: d.name,
99
+ table: t,
100
+ pos,
101
+ kind: (row.kind ?? "").trim(),
102
+ fitting: (row.fitting ?? "").trim(),
103
+ system: (row.system_type ?? "").trim(),
104
+ circuitId: (row.circuit_id ?? "").trim(),
105
+ load: num(row.load),
106
+ flow: num(row.flow)
107
+ });
108
+ hostFrame.set(`${d.name}/${row.id}`, { pos, rot: pg.rotation ?? 0 });
109
+ rowOf.set(`${d.name}/${row.id}`, row);
110
+ }
111
+ }
112
+ if (files.has("connector.csv")) for (const r of readCsv(join(d.path, "connector.csv")).rows) connectorRows.push({ ...r, __dir: d.name });
113
+ if (files.has("circuit.csv")) {
114
+ for (const r of readCsv(join(d.path, "circuit.csv")).rows) {
115
+ circuits.push({
116
+ id: r.id,
117
+ scope: d.name,
118
+ hostId: r.host_id ?? "",
119
+ number: r.number ?? "",
120
+ voltage: num(r.voltage),
121
+ rating: num(r.rating),
122
+ phase: (r.phase ?? "").trim(),
123
+ poles: num(r.poles),
124
+ powerFactor: num(r.power_factor),
125
+ cableSize: num(r.cable_size),
126
+ trays: (r.cable_trays ?? "").split(/[;,\s]+/).map((x) => x.trim()).filter(Boolean)
127
+ });
128
+ }
129
+ }
130
+ }
131
+ for (const r of connectorRows) {
132
+ const host = hostFrame.get(`${r.__dir}/${r.host_id ?? ""}`) ?? hostFrame.get(`global/${r.host_id ?? ""}`);
133
+ if (!host || !r.name) continue;
134
+ const th = host.rot * Math.PI / 180;
135
+ const ox = num(r.offset_x), oy = num(r.offset_y), oz = num(r.offset_z);
136
+ ports.push({
137
+ hostId: r.host_id,
138
+ scope: hostFrame.has(`${r.__dir}/${r.host_id}`) ? r.__dir : "global",
139
+ name: r.name,
140
+ pos: [host.pos[0] + ox * Math.cos(th) - oy * Math.sin(th), host.pos[1] + ox * Math.sin(th) + oy * Math.cos(th), host.pos[2] + oz],
141
+ system: (r.system_type ?? "").trim(),
142
+ domain: (r.domain ?? "").trim(),
143
+ shape: (r.shape ?? "").trim(),
144
+ w: num(r.size_w),
145
+ h: num(r.size_h),
146
+ flowDir: (r.flow_dir ?? "").trim()
147
+ });
148
+ }
149
+ return { curves, hosts, ports, circuits, rowOf };
150
+ }
151
+ function summarizeSystems(m) {
152
+ const by = /* @__PURE__ */ new Map();
153
+ const get = (s) => {
154
+ let e = by.get(s);
155
+ if (!e) by.set(s, e = { system: s, curves: 0, length: 0, devices: 0, tables: [] });
156
+ return e;
157
+ };
158
+ for (const c of m.curves) {
159
+ const e = get(c.system || "(none)");
160
+ e.curves++;
161
+ e.length += Math.hypot(c.b[0] - c.a[0], c.b[1] - c.a[1], c.b[2] - c.a[2]);
162
+ if (!e.tables.includes(c.table)) e.tables.push(c.table);
163
+ }
164
+ for (const h of m.hosts) {
165
+ if (h.table === "mep_node") continue;
166
+ for (const s of (h.system || "").split(",").map((x) => x.trim()).filter(Boolean)) get(s).devices++;
167
+ }
168
+ return [...by.values()].sort((a, b) => a.system.localeCompare(b.system));
169
+ }
170
+
171
+ export {
172
+ MEP_CURVE_TABLES,
173
+ num,
174
+ levelElevations,
175
+ featuresById,
176
+ loadMep,
177
+ summarizeSystems
178
+ };
179
+ //# sourceMappingURL=chunk-IQJA3EFO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/mep/load.ts"],"sourcesContent":["/**\n * Load a project's MEP network (curves, hosts, ports, circuits) in world\n * coordinates for the connectivity check and the system summary.\n */\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { readCsv } from '../utils/csv.js';\nimport { parseGeoJsonFile, extractLineGeometry, extractPointGeometry, type BimDownFeature } from '../utils/geojson.js';\nimport { discoverLayout, listFiles } from '../utils/fs.js';\nimport type { MepModelIn, MepCurveIn, MepHostIn, MepPortIn, MepCircuitIn, Vec3 } from './check.js';\n\nexport const MEP_CURVE_TABLES = ['duct', 'pipe', 'cable_tray', 'conduit'];\nconst HOST_TABLES = ['equipment', 'terminal', 'mep_node'] as const;\n\nexport interface LoadedMep extends MepModelIn {\n /** Raw CSV rows by `${dir}/${id}` (curves and hosts). */\n rowOf: Map<string, Record<string, string>>;\n}\n\nexport function num(v: unknown, fallback = 0): number {\n const n = parseFloat(String(v ?? ''));\n return Number.isFinite(n) ? n : fallback;\n}\n\nexport function levelElevations(dir: string): Map<string, number> {\n const out = new Map<string, number>();\n const p = join(dir, 'global', 'level.csv');\n if (!existsSync(p)) return out;\n for (const r of readCsv(p).rows) out.set(r.id, num(r.elevation));\n return out;\n}\n\nexport function featuresById(path: string): Map<string, BimDownFeature> {\n const map = new Map<string, BimDownFeature>();\n if (!existsSync(path)) return map;\n try {\n for (const f of parseGeoJsonFile(path).features) {\n const id = String(f.properties?.id ?? '');\n if (id) map.set(id, f);\n }\n } catch { /* unreadable geometry: validate reports it */ }\n return map;\n}\n\nexport function loadMep(dir: string): LoadedMep {\n const layout = discoverLayout(dir);\n const elev = levelElevations(dir);\n const dirs = [{ name: 'global', path: layout.globalDir }, ...layout.levelDirs];\n const curves: MepCurveIn[] = [];\n const hosts: MepHostIn[] = [];\n const ports: MepPortIn[] = [];\n const circuits: MepCircuitIn[] = [];\n const rowOf = new Map<string, Record<string, string>>();\n const hostFrame = new Map<string, { pos: Vec3; rot: number }>(); // `${dir}/${id}`\n const connectorRows: (Record<string, string> & { __dir: string })[] = [];\n\n for (const d of dirs) {\n if (!existsSync(d.path)) continue;\n const files = new Set(listFiles(d.path));\n const base = elev.get(d.name) ?? 0;\n for (const t of MEP_CURVE_TABLES) {\n if (!files.has(`${t}.csv`)) continue;\n const geo = featuresById(join(d.path, `${t}.geojson`));\n for (const row of readCsv(join(d.path, `${t}.csv`)).rows) {\n const f = geo.get(row.id);\n if (!f || f.geometry.type !== 'LineString') continue;\n let lg;\n try { lg = extractLineGeometry(f); } catch { continue; }\n const off = num(f.properties?.base_offset);\n curves.push({\n id: row.id, scope: d.name, table: t,\n a: [lg.start_x, lg.start_y, lg.start_z ?? base + off],\n b: [lg.end_x, lg.end_y, lg.end_z ?? base + off],\n from: row.from ?? '', to: row.to ?? '', system: (row.system_type ?? '').trim(),\n shape: (row.shape ?? '').trim() || (t === 'duct' || t === 'cable_tray' ? 'rect' : 'round'),\n w: num(row.size_x), h: num(row.size_y),\n ...(t === 'cable_tray' && num(row.max_fill) > 0 ? { maxFill: num(row.max_fill) } : {}),\n });\n rowOf.set(`${d.name}/${row.id}`, row);\n }\n }\n for (const t of HOST_TABLES) {\n if (!files.has(`${t}.csv`)) continue;\n const geo = featuresById(join(d.path, `${t}.geojson`));\n for (const row of readCsv(join(d.path, `${t}.csv`)).rows) {\n const f = geo.get(row.id);\n if (!f || f.geometry.type !== 'Point') continue;\n const pg = extractPointGeometry(f);\n const pos: Vec3 = [pg.x, pg.y, pg.z ?? base + num(f.properties?.base_offset)];\n hosts.push({\n id: row.id, scope: d.name, table: t, pos,\n kind: (row.kind ?? '').trim(), fitting: (row.fitting ?? '').trim(),\n system: (row.system_type ?? '').trim(), circuitId: (row.circuit_id ?? '').trim(), load: num(row.load),\n flow: num(row.flow),\n });\n hostFrame.set(`${d.name}/${row.id}`, { pos, rot: pg.rotation ?? 0 });\n rowOf.set(`${d.name}/${row.id}`, row);\n }\n }\n if (files.has('connector.csv')) for (const r of readCsv(join(d.path, 'connector.csv')).rows) connectorRows.push({ ...r, __dir: d.name });\n if (files.has('circuit.csv')) {\n for (const r of readCsv(join(d.path, 'circuit.csv')).rows) {\n circuits.push({\n id: r.id, scope: d.name, hostId: r.host_id ?? '', number: r.number ?? '', voltage: num(r.voltage), rating: num(r.rating),\n phase: (r.phase ?? '').trim(), poles: num(r.poles), powerFactor: num(r.power_factor), cableSize: num(r.cable_size),\n trays: (r.cable_trays ?? '').split(/[;,\\s]+/).map(x => x.trim()).filter(Boolean),\n });\n }\n }\n }\n\n for (const r of connectorRows) {\n const host = hostFrame.get(`${r.__dir}/${r.host_id ?? ''}`) ?? hostFrame.get(`global/${r.host_id ?? ''}`);\n if (!host || !r.name) continue;\n const th = (host.rot * Math.PI) / 180;\n const ox = num(r.offset_x), oy = num(r.offset_y), oz = num(r.offset_z);\n ports.push({\n hostId: r.host_id, scope: hostFrame.has(`${r.__dir}/${r.host_id}`) ? r.__dir : 'global', name: r.name,\n pos: [host.pos[0] + ox * Math.cos(th) - oy * Math.sin(th), host.pos[1] + ox * Math.sin(th) + oy * Math.cos(th), host.pos[2] + oz],\n system: (r.system_type ?? '').trim(), domain: (r.domain ?? '').trim(),\n shape: (r.shape ?? '').trim(), w: num(r.size_w), h: num(r.size_h), flowDir: (r.flow_dir ?? '').trim(),\n });\n }\n\n return { curves, hosts, ports, circuits, rowOf };\n}\n\nexport interface SystemSummary {\n system: string;\n curves: number;\n length: number;\n devices: number;\n tables: string[];\n}\n\n/** Per system_type: curve count, total length, devices (equipment / terminals). */\nexport function summarizeSystems(m: MepModelIn): SystemSummary[] {\n const by = new Map<string, SystemSummary>();\n const get = (s: string) => {\n let e = by.get(s);\n if (!e) by.set(s, e = { system: s, curves: 0, length: 0, devices: 0, tables: [] });\n return e;\n };\n for (const c of m.curves) {\n const e = get(c.system || '(none)');\n e.curves++;\n e.length += Math.hypot(c.b[0] - c.a[0], c.b[1] - c.a[1], c.b[2] - c.a[2]);\n if (!e.tables.includes(c.table)) e.tables.push(c.table);\n }\n for (const h of m.hosts) {\n if (h.table === 'mep_node') continue;\n for (const s of (h.system || '').split(',').map(x => x.trim()).filter(Boolean)) get(s).devices++;\n }\n return [...by.values()].sort((a, b) => a.system.localeCompare(b.system));\n}\n"],"mappings":";;;;;;;;;;;;;;;AAIA,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AAMd,IAAM,mBAAmB,CAAC,QAAQ,QAAQ,cAAc,SAAS;AACxE,IAAM,cAAc,CAAC,aAAa,YAAY,UAAU;AAOjD,SAAS,IAAI,GAAY,WAAW,GAAW;AACpD,QAAM,IAAI,WAAW,OAAO,KAAK,EAAE,CAAC;AACpC,SAAO,OAAO,SAAS,CAAC,IAAI,IAAI;AAClC;AAEO,SAAS,gBAAgB,KAAkC;AAChE,QAAM,MAAM,oBAAI,IAAoB;AACpC,QAAM,IAAI,KAAK,KAAK,UAAU,WAAW;AACzC,MAAI,CAAC,WAAW,CAAC,EAAG,QAAO;AAC3B,aAAW,KAAK,QAAQ,CAAC,EAAE,KAAM,KAAI,IAAI,EAAE,IAAI,IAAI,EAAE,SAAS,CAAC;AAC/D,SAAO;AACT;AAEO,SAAS,aAAa,MAA2C;AACtE,QAAM,MAAM,oBAAI,IAA4B;AAC5C,MAAI,CAAC,WAAW,IAAI,EAAG,QAAO;AAC9B,MAAI;AACF,eAAW,KAAK,iBAAiB,IAAI,EAAE,UAAU;AAC/C,YAAM,KAAK,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AK,EAAE,QAAQ;AACxB,UAAM,IAAI,IAAI,EAAE,UAAU,QAAQ;AAClC,MAAE;AACF,MAAE,UAAU,KAAK,MAAM,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AACxE,QAAI,CAAC,EAAE,OAAO,SAAS,EAAE,KAAK,EAAG,GAAE,OAAO,KAAK,EAAE,KAAK;AAAA,EACxD;AACA,aAAW,KAAK,EAAE,OAAO;AACvB,QAAI,EAAE,UAAU,WAAY;AAC5B,eAAW,MAAM,EAAE,UAAU,IAAI,MAAM,GAAG,EAAE,IAAI,OAAK,EAAE,KAAK,CAAC,EAAE,OAAO,OAAO,EAAG,KAAI,CAAC,EAAE;AAAA,EACzF;AACA,SAAO,CAAC,GAAG,GAAG,OAAO,CAAC,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,OAAO,cAAc,EAAE,MAAM,CAAC;AACzE;","names":[]}
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/utils/csv.ts
4
+ import { readFileSync, writeFileSync } from "fs";
5
+
6
+ // src/utils/csv-core.ts
7
+ function parseCsvText(text) {
8
+ if (text.charCodeAt(0) === 65279) text = text.slice(1);
9
+ const lines = text.split(/\r?\n/).filter((l) => l.trim() !== "");
10
+ if (lines.length === 0) return { headers: [], rows: [] };
11
+ const rawHeaders = parseCsvLine(lines[0]);
12
+ const headers = [...new Set(rawHeaders)];
13
+ const duplicateHeaders = headers.filter((h) => rawHeaders.indexOf(h) !== rawHeaders.lastIndexOf(h));
14
+ const rows = lines.slice(1).map((line) => {
15
+ const values = parseCsvLine(line);
16
+ const row = {};
17
+ for (let i = 0; i < rawHeaders.length; i++) {
18
+ if (!row[rawHeaders[i]]) row[rawHeaders[i]] = values[i] ?? "";
19
+ }
20
+ return row;
21
+ });
22
+ return duplicateHeaders.length > 0 ? { headers, rows, duplicateHeaders } : { headers, rows };
23
+ }
24
+ function parseCsvLine(line) {
25
+ const result = [];
26
+ let current = "";
27
+ let inQuotes = false;
28
+ for (let i = 0; i < line.length; i++) {
29
+ const ch = line[i];
30
+ if (inQuotes) {
31
+ if (ch === '"') {
32
+ if (i + 1 < line.length && line[i + 1] === '"') {
33
+ current += '"';
34
+ i++;
35
+ } else {
36
+ inQuotes = false;
37
+ }
38
+ } else {
39
+ current += ch;
40
+ }
41
+ } else {
42
+ if (ch === '"') {
43
+ inQuotes = true;
44
+ } else if (ch === ",") {
45
+ result.push(current);
46
+ current = "";
47
+ } else {
48
+ current += ch;
49
+ }
50
+ }
51
+ }
52
+ result.push(current);
53
+ return result;
54
+ }
55
+
56
+ // src/utils/csv.ts
57
+ function readCsv(filePath) {
58
+ return parseCsvText(readFileSync(filePath, "utf-8"));
59
+ }
60
+ function writeCsv(filePath, data) {
61
+ const lines = [data.headers.join(",")];
62
+ for (const row of data.rows) {
63
+ const values = data.headers.map((h) => escapeCsvValue(row[h] ?? ""));
64
+ lines.push(values.join(","));
65
+ }
66
+ writeFileSync(filePath, lines.join("\n") + "\n", "utf-8");
67
+ }
68
+ function escapeCsvValue(val) {
69
+ if (val.includes(",") || val.includes('"') || val.includes("\n")) {
70
+ return '"' + val.replace(/"/g, '""') + '"';
71
+ }
72
+ return val;
73
+ }
74
+
75
+ export {
76
+ parseCsvText,
77
+ readCsv,
78
+ writeCsv
79
+ };
80
+ //# sourceMappingURL=chunk-JY6KWRDB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/csv.ts","../src/utils/csv-core.ts"],"sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport { parseCsvText, type CsvData } from './csv-core.js';\n\nexport { parseCsvText, type CsvData };\n\nexport function readCsv(filePath: string): CsvData {\n return parseCsvText(readFileSync(filePath, 'utf-8'));\n}\n\nexport function writeCsv(filePath: string, data: CsvData): void {\n const lines = [data.headers.join(',')];\n for (const row of data.rows) {\n const values = data.headers.map((h) => escapeCsvValue(row[h] ?? ''));\n lines.push(values.join(','));\n }\n writeFileSync(filePath, lines.join('\\n') + '\\n', 'utf-8');\n}\n\nfunction escapeCsvValue(val: string): string {\n if (val.includes(',') || val.includes('\"') || val.includes('\\n')) {\n return '\"' + val.replace(/\"/g, '\"\"') + '\"';\n }\n return val;\n}\n","/** CSV parsing without file access (shared with the browser IFC importer). */\n\nexport interface CsvData {\n headers: string[];\n rows: Record<string, string>[];\n /** Header names repeated in the file; merged into a single column. */\n duplicateHeaders?: string[];\n}\n\n/** Parse CSV text (BOM stripped, blank lines skipped). */\nexport function parseCsvText(text: string): CsvData {\n // Strip BOM\n if (text.charCodeAt(0) === 0xfeff) text = text.slice(1);\n\n const lines = text.split(/\\r?\\n/).filter((l) => l.trim() !== '');\n if (lines.length === 0) return { headers: [], rows: [] };\n\n // A repeated header (e.g. two `id` columns written by older editors) is\n // merged into one column, first non-empty value winning, so callers always\n // see unique headers and DuckDB can create the table.\n const rawHeaders = parseCsvLine(lines[0]);\n const headers = [...new Set(rawHeaders)];\n const duplicateHeaders = headers.filter((h) => rawHeaders.indexOf(h) !== rawHeaders.lastIndexOf(h));\n const rows = lines.slice(1).map((line) => {\n const values = parseCsvLine(line);\n const row: Record<string, string> = {};\n for (let i = 0; i < rawHeaders.length; i++) {\n if (!row[rawHeaders[i]]) row[rawHeaders[i]] = values[i] ?? '';\n }\n return row;\n });\n\n return duplicateHeaders.length > 0 ? { headers, rows, duplicateHeaders } : { headers, rows };\n}\n\nfunction parseCsvLine(line: string): string[] {\n const result: string[] = [];\n let current = '';\n let inQuotes = false;\n\n for (let i = 0; i < line.length; i++) {\n const ch = line[i];\n if (inQuotes) {\n if (ch === '\"') {\n if (i + 1 < line.length && line[i + 1] === '\"') {\n current += '\"';\n i++;\n } else {\n inQuotes = false;\n }\n } else {\n current += ch;\n }\n } else {\n if (ch === '\"') {\n inQuotes = true;\n } else if (ch === ',') {\n result.push(current);\n current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