@kensnzk/koyu 0.27.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/assets/plan/README.md +18 -0
  2. package/assets/plan/catalog.muro +87 -0
  3. package/assets/plan/library.muro +26 -0
  4. package/assets/plan/svg/bathtub.svg +9 -0
  5. package/assets/plan/svg/bed-double.svg +9 -0
  6. package/assets/plan/svg/bed-single.svg +8 -0
  7. package/assets/plan/svg/cabinet.svg +9 -0
  8. package/assets/plan/svg/chair.svg +8 -0
  9. package/assets/plan/svg/desk.svg +9 -0
  10. package/assets/plan/svg/hedge-2m.svg +7 -0
  11. package/assets/plan/svg/kitchen-sink.svg +10 -0
  12. package/assets/plan/svg/locker.svg +9 -0
  13. package/assets/plan/svg/office-chair.svg +25 -0
  14. package/assets/plan/svg/potted-plant.svg +14 -0
  15. package/assets/plan/svg/refrigerator.svg +10 -0
  16. package/assets/plan/svg/shelf.svg +9 -0
  17. package/assets/plan/svg/shrub-1m.svg +7 -0
  18. package/assets/plan/svg/sofa-2.svg +9 -0
  19. package/assets/plan/svg/sofa-3.svg +9 -0
  20. package/assets/plan/svg/table-rect.svg +7 -0
  21. package/assets/plan/svg/table-round.svg +7 -0
  22. package/assets/plan/svg/tree-3m.svg +8 -0
  23. package/assets/plan/svg/urinal.svg +9 -0
  24. package/assets/plan/svg/washing-machine-pan.svg +13 -0
  25. package/assets/plan/svg/washing-machine.svg +10 -0
  26. package/assets/plan/svg/washstand-500.svg +12 -0
  27. package/assets/plan/svg/washstand.svg +12 -0
  28. package/assets/plan/svg/wc-cabinet.svg +14 -0
  29. package/assets/plan/svg/wc.svg +9 -0
  30. package/dist/cli.js +2 -2
  31. package/dist/cli.js.map +1 -1
  32. package/dist/core/components.d.ts +31 -0
  33. package/dist/core/components.d.ts.map +1 -0
  34. package/dist/core/components.js +167 -0
  35. package/dist/core/components.js.map +1 -0
  36. package/dist/core/derive.d.ts +9 -1
  37. package/dist/core/derive.d.ts.map +1 -1
  38. package/dist/core/derive.js +33 -3
  39. package/dist/core/derive.js.map +1 -1
  40. package/dist/core/diagnose.d.ts +6 -0
  41. package/dist/core/diagnose.d.ts.map +1 -1
  42. package/dist/core/diagnose.js +137 -4
  43. package/dist/core/diagnose.js.map +1 -1
  44. package/dist/core/model.d.ts +5 -5
  45. package/dist/core/model.d.ts.map +1 -1
  46. package/dist/core/model.js +6 -1
  47. package/dist/core/model.js.map +1 -1
  48. package/dist/core/parse.d.ts.map +1 -1
  49. package/dist/core/parse.js +5 -4
  50. package/dist/core/parse.js.map +1 -1
  51. package/dist/core/vocabulary.d.ts +20 -4
  52. package/dist/core/vocabulary.d.ts.map +1 -1
  53. package/dist/core/vocabulary.js +107 -9
  54. package/dist/core/vocabulary.js.map +1 -1
  55. package/dist/draw/component-files.d.ts +8 -0
  56. package/dist/draw/component-files.d.ts.map +1 -0
  57. package/dist/draw/component-files.js +35 -0
  58. package/dist/draw/component-files.js.map +1 -0
  59. package/dist/draw/component-svg.d.ts +14 -0
  60. package/dist/draw/component-svg.d.ts.map +1 -0
  61. package/dist/draw/component-svg.js +67 -0
  62. package/dist/draw/component-svg.js.map +1 -0
  63. package/dist/draw/conventions/architectural.d.ts +32 -0
  64. package/dist/draw/conventions/architectural.d.ts.map +1 -0
  65. package/dist/draw/conventions/architectural.js +29 -0
  66. package/dist/draw/conventions/architectural.js.map +1 -0
  67. package/dist/draw/index.d.ts +1 -1
  68. package/dist/draw/index.d.ts.map +1 -1
  69. package/dist/draw/index.js +1 -1
  70. package/dist/draw/index.js.map +1 -1
  71. package/dist/draw/marks.d.ts +37 -12
  72. package/dist/draw/marks.d.ts.map +1 -1
  73. package/dist/draw/marks.js +508 -38
  74. package/dist/draw/marks.js.map +1 -1
  75. package/dist/draw/plan.d.ts +3 -1
  76. package/dist/draw/plan.d.ts.map +1 -1
  77. package/dist/draw/plan.js +247 -85
  78. package/dist/draw/plan.js.map +1 -1
  79. package/dist/form.d.ts +1 -1
  80. package/dist/form.d.ts.map +1 -1
  81. package/dist/form.js.map +1 -1
  82. package/dist/index.js +1 -1
  83. package/dist/mcp.js +21 -3
  84. package/dist/mcp.js.map +1 -1
  85. package/dist/parse-file.d.ts +1 -0
  86. package/dist/parse-file.d.ts.map +1 -1
  87. package/dist/parse-file.js +1 -0
  88. package/dist/parse-file.js.map +1 -1
  89. package/dist/validate/builtin/index.d.ts +4 -2
  90. package/dist/validate/builtin/index.d.ts.map +1 -1
  91. package/dist/validate/builtin/index.js +9 -2
  92. package/dist/validate/builtin/index.js.map +1 -1
  93. package/dist/validate/builtin/opening-operations.d.ts +63 -0
  94. package/dist/validate/builtin/opening-operations.d.ts.map +1 -0
  95. package/dist/validate/builtin/opening-operations.js +406 -0
  96. package/dist/validate/builtin/opening-operations.js.map +1 -0
  97. package/editors/vscode/syntaxes/koyu.tmLanguage.json +3 -3
  98. package/examples/basement/main.muro +3 -3
  99. package/examples/complex/L1.muro +1 -1
  100. package/examples/complex/assets.muro +2 -2
  101. package/examples/complex/main.muro +1 -1
  102. package/examples/house/L1.muro +3 -3
  103. package/examples/house/L2.muro +2 -2
  104. package/examples/house/assets.muro +8 -8
  105. package/examples/house/main.muro +1 -1
  106. package/examples/house/site.muro +2 -2
  107. package/examples/house.muro +6 -6
  108. package/examples/mansion.muro +1 -1
  109. package/examples/office.muro +1 -1
  110. package/examples/steps/06-finished.muro +1 -1
  111. package/examples/tower/assets.muro +1 -1
  112. package/examples/tower/main.muro +1 -1
  113. package/examples/twin/assets.muro +2 -2
  114. package/examples/twin/main.muro +1 -1
  115. package/examples/two-rooms.canonical.json +1 -1
  116. package/examples/two-rooms.muro +1 -1
  117. package/package.json +7 -4
  118. package/src/cli.ts +2 -2
  119. package/src/core/components.ts +224 -0
  120. package/src/core/derive.ts +47 -4
  121. package/src/core/diagnose.ts +182 -4
  122. package/src/core/model.ts +10 -5
  123. package/src/core/parse.ts +5 -4
  124. package/src/core/vocabulary.ts +115 -9
  125. package/src/draw/component-files.ts +36 -0
  126. package/src/draw/component-svg.ts +79 -0
  127. package/src/draw/conventions/architectural.ts +60 -0
  128. package/src/draw/index.ts +1 -1
  129. package/src/draw/marks.ts +564 -44
  130. package/src/draw/plan.ts +253 -88
  131. package/src/form.ts +1 -0
  132. package/src/index.ts +1 -1
  133. package/src/mcp.ts +21 -3
  134. package/src/parse-file.ts +1 -0
  135. package/src/validate/builtin/index.ts +14 -2
  136. package/src/validate/builtin/opening-operations.ts +519 -0
@@ -2,7 +2,7 @@
2
2
  # 基本計画の解像度で書く。垂れ壁や建具詳細は表現しない — 省略ではなく抽象度の選択。
3
3
  # 高さの一貫性は level の宣言 (z / h / slab) と check の不変量が担保する。
4
4
 
5
- muro 1.4
5
+ muro 1.5
6
6
  name 小さなオフィス
7
7
  unit mm
8
8
 
@@ -1,4 +1,4 @@
1
- muro 1.4
1
+ muro 1.5
2
2
  name 小さな家
3
3
 
4
4
  grid X 0 3600 5400
@@ -7,7 +7,7 @@ asset D1 door w:900 h:2100 style:hinged name:住戸玄関ドア
7
7
  asset FD1 door w:900 h:2000 style:hinged fire:特定防火設備 name:防火戸
8
8
  asset SD1 door w:800 h:2000 style:sliding name:片引き戸
9
9
 
10
- asset BD1 door w:1200 h:2200 style:sliding name:掃き出し引違い戸 # 掃き出しサッシの引違い部 — 人が出る
10
+ asset BD1 door w:1200 h:2200 style:sliding-bypass name:Full-height-bypass-sash
11
11
  asset W1 window w:2600 h:2200 sill:0 name:掃き出し窓
12
12
  asset W2 window w:1650 h:1100 sill:900 name:腰窓
13
13
  asset W3 window w:2600 h:1100 sill:1100 name:高窓
@@ -5,7 +5,7 @@
5
5
  # L1-L2 商業 / L3-L10 住宅基準階 (L3は低層部屋根のテラス付き例外階) / L11 ペントハウス
6
6
  # koyu check examples/tower/main.muro が一棟のビルドの門番。
7
7
 
8
- muro 1.4
8
+ muro 1.5
9
9
  name 街角の複合ビル — 低層商業+高層住宅
10
10
  unit mm
11
11
 
@@ -9,8 +9,8 @@ asset D1 door w:900 h:2100 style:hinged name:片開き戸
9
9
  asset D2 door w:1000 h:2400 style:hinged name:住戸玄関ドア
10
10
  asset FD1 door w:900 h:2000 style:hinged fire:特定防火設備 name:防火戸
11
11
  asset FD2 door w:1800 h:2400 style:hinged fire:特定防火設備 name:防火戸大
12
- asset VG1 door w:6000 h:3000 style:sliding name:車路シャッター
13
- asset LG1 door w:3600 h:3600 style:sliding name:荷捌きシャッター
12
+ asset VG1 door w:6000 h:3000 style:rolling-shutter name:Vehicle-shutter
13
+ asset LG1 door w:3600 h:3600 style:rolling-shutter name:Loading-shutter
14
14
 
15
15
  # **カーテンウォールは「方立てだけの全面ガラス」を一枚の窓で言う。**
16
16
  # 1スパン (8,400) 幅・天井いっぱいの窓 = その面はガラスである、という宣言
@@ -28,7 +28,7 @@
28
28
  # koyu plan examples/twin/main.muro -l L8 A棟基準階とB棟ホテル階
29
29
  # koyu axo examples/twin/main.muro -l L1,L2,L3,L4,L5
30
30
 
31
- muro 1.4
31
+ muro 1.5
32
32
  name 双塔複合建築 — 商業・事務所・ホテル・レジデンス
33
33
  unit mm
34
34
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "format": "koyu-canonical/2.0",
3
- "muro": "1.4",
3
+ "muro": "1.5",
4
4
  "name": "二室",
5
5
  "unit": "mm",
6
6
  "grid": {
@@ -4,7 +4,7 @@
4
4
  # 書いてあるのは、扉を吊るために宣言した境界と、外皮の境界だけ。
5
5
  # 両室に daylight:1 を書いたので、窓が要る — `koyu light` が 1/7 を確かめる (ADR-0020)。
6
6
 
7
- muro 1.4
7
+ muro 1.5
8
8
  name 二室
9
9
  unit mm
10
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kensnzk/koyu",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "muro": {
5
5
  "reads": [
6
6
  "0.1",
@@ -12,12 +12,13 @@
12
12
  "1.1",
13
13
  "1.2",
14
14
  "1.3",
15
- "1.4"
15
+ "1.4",
16
+ "1.5"
16
17
  ],
17
- "newest": "1.4",
18
+ "newest": "1.5",
18
19
  "undeclared": "1.1"
19
20
  },
20
- "description": "\u7a7a\u9593\u3092\u4e00\u6b21\u8981\u7d20\u3068\u3059\u308b\u30c6\u30ad\u30b9\u30c8\u30cd\u30a4\u30c6\u30a3\u30d6\u5efa\u7bc9\u8a18\u8ff0\u306e\u63a2\u6c42 \u2014 writing architecture, not buildings",
21
+ "description": "A text-native architectural notation with space as the primary element",
21
22
  "type": "module",
22
23
  "main": "./dist/index.js",
23
24
  "types": "./dist/index.d.ts",
@@ -71,6 +72,7 @@
71
72
  "default": "./dist/parse-file.js"
72
73
  },
73
74
  "./examples/*": "./examples/*",
75
+ "./assets/*": "./assets/*",
74
76
  "./syntax": "./editors/vscode/syntaxes/koyu.tmLanguage.json",
75
77
  "./package.json": "./package.json"
76
78
  },
@@ -82,6 +84,7 @@
82
84
  "dist",
83
85
  "src",
84
86
  "examples",
87
+ "assets",
85
88
  "editors",
86
89
  "NOTICE"
87
90
  ],
package/src/cli.ts CHANGED
@@ -41,7 +41,7 @@ import {
41
41
  isVoid,
42
42
  versionLine
43
43
  } from "./core/model.js";
44
- import { parseFile } from "./parse-file.js";
44
+ import { componentSvgFiles, parseFile } from "./parse-file.js";
45
45
  import { svgPlan } from "./draw/plan.js";
46
46
  import { svgAxo } from "./draw/axo.js";
47
47
  import { svgElevation, svgSection } from "./draw/section.js";
@@ -381,7 +381,7 @@ function main(argv: string[]): number {
381
381
  const explicit = opt(rest, "-o");
382
382
  const outFile =
383
383
  explicit ?? `${file.replace(/\.muro$/, "")}-${level}.svg`;
384
- const svg = svgPlan(model, { level });
384
+ const svg = svgPlan(model, { level, componentSvgs: componentSvgFiles(model, level) });
385
385
  mkdirSync(dirname(outFile), { recursive: true });
386
386
  writeFileSync(outFile, svg);
387
387
  console.log(`Generated the plan: ${outFile}`);
@@ -0,0 +1,224 @@
1
+ import {
2
+ canonicalSpaceOrder,
3
+ compareCanonical,
4
+ pointInPolygon,
5
+ regionOf,
6
+ type Area,
7
+ type Asset,
8
+ type Model,
9
+ type Pt,
10
+ type Space,
11
+ } from "./model.js";
12
+ import { EPS } from "./tolerance.js";
13
+
14
+ export type ComponentAlignment = "min" | "center" | "max";
15
+
16
+ /** A placed component is physical plan geometry without any drawing vocabulary. */
17
+ export interface PlacedComponent {
18
+ space: string;
19
+ area: string;
20
+ asset: string;
21
+ level: string;
22
+ centre: Pt;
23
+ w: number;
24
+ d: number;
25
+ rotation: number;
26
+ footprint: Pt[];
27
+ }
28
+
29
+ export interface ComponentIssue {
30
+ code: "CMP01" | "CMP02";
31
+ message: string;
32
+ line: number;
33
+ file?: string;
34
+ path: string[];
35
+ }
36
+
37
+ export interface ComponentPlacementResult {
38
+ components: PlacedComponent[];
39
+ issues: ComponentIssue[];
40
+ }
41
+
42
+ /**
43
+ * Resolve every area-hosted component. A named area is the only placement frame: there is no
44
+ * second absolute-position spelling that could drift away from the space allocation.
45
+ */
46
+ export function placedComponents(model: Model): ComponentPlacementResult {
47
+ const components: PlacedComponent[] = [];
48
+ const issues: ComponentIssue[] = [];
49
+
50
+ for (const space of canonicalSpaceOrder(model)) {
51
+ const areas = [...space.areas].sort((a, b) => compareCanonical(areaKey(a), areaKey(b)));
52
+ for (const area of areas) {
53
+ const ref = area.attrs["asset"];
54
+ const at = location(space, area);
55
+ if (ref === undefined) {
56
+ const orphan = ["align-x", "align-y", "offset-x", "offset-y", "rotate"]
57
+ .find((key) => area.attrs[key] !== undefined);
58
+ if (orphan) {
59
+ issues.push({
60
+ code: "CMP01",
61
+ message: `${orphan}: on an area requires asset: because it only controls component placement`,
62
+ ...at,
63
+ });
64
+ }
65
+ continue;
66
+ }
67
+ if (typeof ref !== "string") {
68
+ issues.push({ code: "CMP01", message: `asset on an area names a component asset: asset:${ref}`, ...at });
69
+ continue;
70
+ }
71
+ const name = area.attrs["name"];
72
+ if (typeof name !== "string" || name.length === 0) {
73
+ issues.push({
74
+ code: "CMP01",
75
+ message: `An area that places asset ${ref} requires name: (the name identifies the placed component)`,
76
+ ...at,
77
+ });
78
+ continue;
79
+ }
80
+ const asset = model.assets.get(ref);
81
+ if (!asset) {
82
+ issues.push({ code: "CMP01", message: `Undefined component asset on area ${name}: ${ref}`, ...at });
83
+ continue;
84
+ }
85
+ if (asset.kind !== "component") {
86
+ issues.push({
87
+ code: "CMP01",
88
+ message: `The asset ${ref} is a ${asset.kind} (an area can place only a component asset)`,
89
+ ...at,
90
+ });
91
+ continue;
92
+ }
93
+ const dimensions = componentDimensions(asset);
94
+ if (!dimensions || !space.level) continue;
95
+ const settings = placementSettings(area);
96
+ if (settings === undefined) continue;
97
+ if ("message" in settings) {
98
+ issues.push({ code: "CMP01", message: `${settings.message} on area ${name}`, ...at });
99
+ continue;
100
+ }
101
+
102
+ const component = place(space, area, asset, name, dimensions, settings);
103
+ components.push(component);
104
+ const insideHost = inside(area, component.footprint);
105
+ const insideSpace = regionOf(space).some((piece) =>
106
+ component.footprint.every((point) => pointInPolygon(point, piece, EPS))
107
+ );
108
+ if (!insideHost) {
109
+ const alternate = place(space, area, asset, name, dimensions, {
110
+ ...settings,
111
+ rotation: (settings.rotation + 90) % 360,
112
+ });
113
+ const suggestion = inside(area, alternate.footprint) ? "; rotate it by a further 90 degrees to fit" : "";
114
+ issues.push({
115
+ code: "CMP02",
116
+ message: `${ref} extends outside its host area ${name}${suggestion}`,
117
+ ...at,
118
+ });
119
+ } else if (!insideSpace) {
120
+ issues.push({
121
+ code: "CMP02",
122
+ message: `${ref} extends outside its parent space ${space.path}`,
123
+ ...at,
124
+ });
125
+ }
126
+ }
127
+ }
128
+
129
+ return { components, issues };
130
+ }
131
+
132
+ function componentDimensions(asset: Asset): { w: number; d: number } | undefined {
133
+ const w = asset.attrs["w"];
134
+ const d = asset.attrs["d"];
135
+ return typeof w === "number" && w > 0 && typeof d === "number" && d > 0 ? { w, d } : undefined;
136
+ }
137
+
138
+ function placementSettings(area: Area):
139
+ | { alignX: ComponentAlignment; alignY: ComponentAlignment; offsetX: number; offsetY: number; rotation: number }
140
+ | { message: string }
141
+ | undefined {
142
+ const alignX = area.attrs["align-x"] ?? "center";
143
+ const alignY = area.attrs["align-y"] ?? "center";
144
+ const offsetX = area.attrs["offset-x"] ?? 0;
145
+ const offsetY = area.attrs["offset-y"] ?? 0;
146
+ const rotation = area.attrs["rotate"] ?? 0;
147
+ // The attribute ledger owns these enum errors as ATT02. Omit the unresolved component here so
148
+ // one invalid value does not also produce CMP01 for the same spelling.
149
+ if (!isAlignment(alignX) || !isAlignment(alignY)) return undefined;
150
+ if (typeof offsetX !== "number" || !Number.isFinite(offsetX)) {
151
+ return { message: `offset-x is a finite number in mm: offset-x:${offsetX}` };
152
+ }
153
+ if (typeof offsetY !== "number" || !Number.isFinite(offsetY)) {
154
+ return { message: `offset-y is a finite number in mm: offset-y:${offsetY}` };
155
+ }
156
+ if (typeof rotation !== "number" || !Number.isFinite(rotation) || rotation < 0 || rotation >= 360) {
157
+ return { message: `rotate is a number in 0 <= degrees < 360: rotate:${rotation}` };
158
+ }
159
+ return { alignX, alignY, offsetX, offsetY, rotation };
160
+ }
161
+
162
+ function place(
163
+ space: Space,
164
+ area: Area,
165
+ asset: Asset,
166
+ name: string,
167
+ dimensions: { w: number; d: number },
168
+ settings: { alignX: ComponentAlignment; alignY: ComponentAlignment; offsetX: number; offsetY: number; rotation: number },
169
+ ): PlacedComponent {
170
+ const rad = settings.rotation * Math.PI / 180;
171
+ const cos = Math.cos(rad);
172
+ const sin = Math.sin(rad);
173
+ const halfX = Math.abs(cos) * dimensions.w / 2 + Math.abs(sin) * dimensions.d / 2;
174
+ const halfY = Math.abs(sin) * dimensions.w / 2 + Math.abs(cos) * dimensions.d / 2;
175
+ const cx = aligned(area.rect.x1, area.rect.x2, halfX, settings.alignX) + settings.offsetX;
176
+ const cy = aligned(area.rect.y1, area.rect.y2, halfY, settings.alignY) + settings.offsetY;
177
+ const corners: Pt[] = [
178
+ { x: -dimensions.w / 2, y: -dimensions.d / 2 },
179
+ { x: dimensions.w / 2, y: -dimensions.d / 2 },
180
+ { x: dimensions.w / 2, y: dimensions.d / 2 },
181
+ { x: -dimensions.w / 2, y: dimensions.d / 2 },
182
+ ];
183
+ const footprint = corners.map((p) => ({
184
+ x: cx + p.x * cos - p.y * sin,
185
+ y: cy + p.x * sin + p.y * cos,
186
+ }));
187
+ return {
188
+ space: space.path,
189
+ area: name,
190
+ asset: asset.name,
191
+ level: space.level!,
192
+ centre: { x: cx, y: cy },
193
+ w: dimensions.w,
194
+ d: dimensions.d,
195
+ rotation: settings.rotation,
196
+ footprint,
197
+ };
198
+ }
199
+
200
+ function aligned(lo: number, hi: number, half: number, alignment: ComponentAlignment): number {
201
+ if (alignment === "min") return lo + half;
202
+ if (alignment === "max") return hi - half;
203
+ return (lo + hi) / 2;
204
+ }
205
+
206
+ function inside(area: Area, footprint: readonly Pt[]): boolean {
207
+ return footprint.every((p) =>
208
+ p.x >= area.rect.x1 - EPS && p.x <= area.rect.x2 + EPS
209
+ && p.y >= area.rect.y1 - EPS && p.y <= area.rect.y2 + EPS
210
+ );
211
+ }
212
+
213
+ function isAlignment(value: unknown): value is ComponentAlignment {
214
+ return value === "min" || value === "center" || value === "max";
215
+ }
216
+
217
+ function location(space: Space, area: Area): { line: number; file?: string; path: string[] } {
218
+ return { line: area.line, ...(space.file ? { file: space.file } : {}), path: [space.path] };
219
+ }
220
+
221
+ function areaKey(area: Area): string {
222
+ const name = area.attrs["name"];
223
+ return `${typeof name === "string" ? name : ""}\u0000${JSON.stringify([area.grid, area.attrs])}`;
224
+ }
@@ -44,10 +44,12 @@ import {
44
44
  canonicalSegOrder,
45
45
  canonicalSpaceOrder,
46
46
  isOutside,
47
- isVoid
47
+ isVoid,
48
+ isNewerVersion,
48
49
  } from "./model.js";
49
50
  import { clipHalf } from "./poly.js";
50
51
  import { EPS, PARALLEL_EPS, POINT_EPS, SPAN_EPS } from "./tolerance.js";
52
+ import { placedComponents, type PlacedComponent } from "./components.js";
51
53
  import {
52
54
  CUT_HEIGHT,
53
55
  ARROW_SPAN_MIN,
@@ -229,12 +231,38 @@ export interface FormOpening {
229
231
  /** 建具の見付け厚 = 壁厚 */
230
232
  t: number;
231
233
  style?: string;
234
+ /** Explicit equal panel count for a curtain wall. One when omitted. */
235
+ panels?: number;
232
236
  /** 扉が開く先 (引戸・自動扉なら軌跡ではなく引き込みの向き) */
233
237
  swing?: FormSwing;
234
- /** 引き戸か (style:sliding / style:auto) */
238
+ /** whether the opening has no swing arc because its operation is sliding or non-swinging */
235
239
  sliding: boolean;
236
240
  }
237
241
 
242
+ const NON_SWING_OPENING_STYLES = new Set([
243
+ "sliding",
244
+ "sliding-double",
245
+ "sliding-bypass",
246
+ "auto",
247
+ "auto-single",
248
+ "auto-double",
249
+ "entrance",
250
+ "gate-sliding",
251
+ "rolling-shutter",
252
+ "overhead",
253
+ "projecting",
254
+ "curtain-wall",
255
+ ]);
256
+
257
+ const WINDOW_SWING_STYLES = new Set([
258
+ "hinged",
259
+ "hinged-double",
260
+ "sliding",
261
+ "sliding-double",
262
+ "sliding-bypass",
263
+ "projecting",
264
+ ]);
265
+
238
266
  export interface FormSeg {
239
267
  /** 分節の同一性 — 境界と、その中の並びの位置 */
240
268
  ref: string;
@@ -265,6 +293,9 @@ export interface FormSite {
265
293
  areaM2: number;
266
294
  }
267
295
 
296
+ /** A component footprint placed by a named uncounted area. Artwork remains a draw concern. */
297
+ export interface FormComponent extends PlacedComponent {}
298
+
268
299
  /** 2Dエンティティの分類 — 平面が純粋な断面でないことを、この五つが言う */
269
300
  export type PlanClass =
270
301
  /** 切断面が切ったもの */
@@ -315,6 +346,8 @@ export interface Form {
315
346
  spaces: FormSpace[];
316
347
  boundaries: FormBoundary[];
317
348
  openings: FormOpening[];
349
+ /** Present only when the source places a component, preserving older Form bytes otherwise. */
350
+ components?: FormComponent[];
318
351
  /** 数えない分節 (ADR-0003) — 面積にもグラフにも現れないが、位置は導出される */
319
352
  segs: FormSeg[];
320
353
  slabs: Slab[];
@@ -916,7 +949,8 @@ export function derive(model: Model, opts: DeriveOptions = {}): Form {
916
949
  : z0 + OPENING_HEAD;
917
950
  holes.push({ lo: d - p.o.w / 2, hi: d + p.o.w / 2, z0: oz0, z1: oz1 });
918
951
  const style = p.o.attrs["style"];
919
- const sliding = style === "sliding" || style === "auto";
952
+ const panels = p.o.attrs["panels"];
953
+ const sliding = typeof style === "string" && NON_SWING_OPENING_STYLES.has(style);
920
954
  const name = p.o.attrs["name"];
921
955
  openings.push({
922
956
  ref: `${ref}/${p.index}`,
@@ -935,7 +969,12 @@ export function derive(model: Model, opts: DeriveOptions = {}): Form {
935
969
  z1: oz1,
936
970
  t,
937
971
  ...(typeof style === "string" ? { style } : {}),
938
- ...(p.o.kind === "door"
972
+ ...(typeof panels === "number" ? { panels } : {}),
973
+ ...(p.o.kind === "door" || (
974
+ !isNewerVersion("1.5", model.version)
975
+ && typeof style === "string"
976
+ && WINDOW_SWING_STYLES.has(style)
977
+ )
939
978
  ? (() => {
940
979
  const sw = swingOf(model, b, p.o, seg, p.cx, p.cy);
941
980
  return sw ? { swing: sw } : {};
@@ -1000,6 +1039,9 @@ export function derive(model: Model, opts: DeriveOptions = {}): Form {
1000
1039
  areaM2: polygonAreaM2(p.points),
1001
1040
  }));
1002
1041
 
1042
+ // ---- Area-hosted components ----
1043
+ const components = placedComponents(model).components;
1044
+
1003
1045
  // ---- 平面 ----
1004
1046
  const plans = levels.map((l) =>
1005
1047
  planOf(model, l.name, l.z + cut, cut, { spaces, boundaries, openings, columns }),
@@ -1011,6 +1053,7 @@ export function derive(model: Model, opts: DeriveOptions = {}): Form {
1011
1053
  spaces,
1012
1054
  boundaries,
1013
1055
  openings,
1056
+ ...(components.length > 0 ? { components } : {}),
1014
1057
  segs,
1015
1058
  slabs: slabs(model),
1016
1059
  columns,