@kensnzk/koyu 0.27.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +1 -1
- package/README.md +1 -1
- package/assets/plan/README.md +18 -0
- package/assets/plan/catalog.muro +87 -0
- package/assets/plan/library.muro +26 -0
- package/assets/plan/svg/bathtub.svg +9 -0
- package/assets/plan/svg/bed-double.svg +9 -0
- package/assets/plan/svg/bed-single.svg +8 -0
- package/assets/plan/svg/cabinet.svg +9 -0
- package/assets/plan/svg/chair.svg +8 -0
- package/assets/plan/svg/desk.svg +9 -0
- package/assets/plan/svg/hedge-2m.svg +7 -0
- package/assets/plan/svg/kitchen-sink.svg +10 -0
- package/assets/plan/svg/locker.svg +9 -0
- package/assets/plan/svg/office-chair.svg +25 -0
- package/assets/plan/svg/potted-plant.svg +14 -0
- package/assets/plan/svg/refrigerator.svg +10 -0
- package/assets/plan/svg/shelf.svg +9 -0
- package/assets/plan/svg/shrub-1m.svg +7 -0
- package/assets/plan/svg/sofa-2.svg +9 -0
- package/assets/plan/svg/sofa-3.svg +9 -0
- package/assets/plan/svg/table-rect.svg +7 -0
- package/assets/plan/svg/table-round.svg +7 -0
- package/assets/plan/svg/tree-3m.svg +8 -0
- package/assets/plan/svg/urinal.svg +9 -0
- package/assets/plan/svg/washing-machine-pan.svg +13 -0
- package/assets/plan/svg/washing-machine.svg +10 -0
- package/assets/plan/svg/washstand-500.svg +12 -0
- package/assets/plan/svg/washstand.svg +12 -0
- package/assets/plan/svg/wc-cabinet.svg +14 -0
- package/assets/plan/svg/wc.svg +9 -0
- package/dist/analysis/contracts.d.ts +1 -0
- package/dist/analysis/contracts.d.ts.map +1 -1
- package/dist/cli.js +16 -4
- package/dist/cli.js.map +1 -1
- package/dist/core/components.d.ts +31 -0
- package/dist/core/components.d.ts.map +1 -0
- package/dist/core/components.js +167 -0
- package/dist/core/components.js.map +1 -0
- package/dist/core/derive.d.ts +13 -2
- package/dist/core/derive.d.ts.map +1 -1
- package/dist/core/derive.js +36 -5
- package/dist/core/derive.js.map +1 -1
- package/dist/core/diagnose.d.ts +7 -0
- package/dist/core/diagnose.d.ts.map +1 -1
- package/dist/core/diagnose.js +141 -5
- package/dist/core/diagnose.js.map +1 -1
- package/dist/core/diff.d.ts +4 -0
- package/dist/core/diff.d.ts.map +1 -1
- package/dist/core/diff.js +4 -0
- package/dist/core/diff.js.map +1 -1
- package/dist/core/fabric.js +1 -1
- package/dist/core/fabric.js.map +1 -1
- package/dist/core/graph.d.ts +8 -0
- package/dist/core/graph.d.ts.map +1 -1
- package/dist/core/graph.js +31 -1
- package/dist/core/graph.js.map +1 -1
- package/dist/core/light.d.ts.map +1 -1
- package/dist/core/light.js +2 -0
- package/dist/core/light.js.map +1 -1
- package/dist/core/model.d.ts +20 -14
- package/dist/core/model.d.ts.map +1 -1
- package/dist/core/model.js +15 -8
- package/dist/core/model.js.map +1 -1
- package/dist/core/parse.d.ts.map +1 -1
- package/dist/core/parse.js +23 -4
- package/dist/core/parse.js.map +1 -1
- package/dist/core/vocabulary.d.ts +20 -4
- package/dist/core/vocabulary.d.ts.map +1 -1
- package/dist/core/vocabulary.js +107 -9
- package/dist/core/vocabulary.js.map +1 -1
- package/dist/draw/component-files.d.ts +8 -0
- package/dist/draw/component-files.d.ts.map +1 -0
- package/dist/draw/component-files.js +35 -0
- package/dist/draw/component-files.js.map +1 -0
- package/dist/draw/component-svg.d.ts +14 -0
- package/dist/draw/component-svg.d.ts.map +1 -0
- package/dist/draw/component-svg.js +67 -0
- package/dist/draw/component-svg.js.map +1 -0
- package/dist/draw/conventions/architectural.d.ts +32 -0
- package/dist/draw/conventions/architectural.d.ts.map +1 -0
- package/dist/draw/conventions/architectural.js +29 -0
- package/dist/draw/conventions/architectural.js.map +1 -0
- package/dist/draw/index.d.ts +1 -1
- package/dist/draw/index.d.ts.map +1 -1
- package/dist/draw/index.js +1 -1
- package/dist/draw/index.js.map +1 -1
- package/dist/draw/marks.d.ts +37 -12
- package/dist/draw/marks.d.ts.map +1 -1
- package/dist/draw/marks.js +508 -38
- package/dist/draw/marks.js.map +1 -1
- package/dist/draw/plan.d.ts +3 -1
- package/dist/draw/plan.d.ts.map +1 -1
- package/dist/draw/plan.js +257 -86
- package/dist/draw/plan.js.map +1 -1
- package/dist/form.d.ts +1 -1
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp.js +22 -3
- package/dist/mcp.js.map +1 -1
- package/dist/parse-file.d.ts +1 -0
- package/dist/parse-file.d.ts.map +1 -1
- package/dist/parse-file.js +1 -0
- package/dist/parse-file.js.map +1 -1
- package/dist/validate/assessment.js +13 -2
- package/dist/validate/assessment.js.map +1 -1
- package/dist/validate/builtin/index.d.ts +4 -2
- package/dist/validate/builtin/index.d.ts.map +1 -1
- package/dist/validate/builtin/index.js +9 -2
- package/dist/validate/builtin/index.js.map +1 -1
- package/dist/validate/builtin/opening-operations.d.ts +63 -0
- package/dist/validate/builtin/opening-operations.d.ts.map +1 -0
- package/dist/validate/builtin/opening-operations.js +406 -0
- package/dist/validate/builtin/opening-operations.js.map +1 -0
- package/dist/validate/contracts.d.ts +1 -0
- package/dist/validate/contracts.d.ts.map +1 -1
- package/dist/validate/contracts.js.map +1 -1
- package/editors/vscode/syntaxes/koyu.tmLanguage.json +4 -4
- package/examples/basement/main.muro +3 -3
- package/examples/complex/L1.muro +1 -1
- package/examples/complex/assets.muro +2 -2
- package/examples/complex/main.muro +1 -1
- package/examples/house/L1.muro +3 -3
- package/examples/house/L2.muro +2 -2
- package/examples/house/assets.muro +8 -8
- package/examples/house/main.muro +1 -1
- package/examples/house/site.muro +2 -2
- package/examples/house.muro +6 -6
- package/examples/mansion.muro +1 -1
- package/examples/office.muro +1 -1
- package/examples/spatial/layout.muro +8 -0
- package/examples/spatial/main.muro +4 -0
- package/examples/steps/06-finished.muro +1 -1
- package/examples/tower/assets.muro +1 -1
- package/examples/tower/main.muro +1 -1
- package/examples/twin/assets.muro +2 -2
- package/examples/twin/main.muro +1 -1
- package/examples/two-rooms.canonical.json +1 -1
- package/examples/two-rooms.muro +1 -1
- package/package.json +9 -5
- package/src/analysis/contracts.ts +1 -0
- package/src/cli.ts +15 -4
- package/src/core/components.ts +224 -0
- package/src/core/derive.ts +53 -6
- package/src/core/diagnose.ts +185 -5
- package/src/core/diff.ts +3 -0
- package/src/core/fabric.ts +1 -1
- package/src/core/graph.ts +32 -0
- package/src/core/light.ts +1 -0
- package/src/core/model.ts +23 -13
- package/src/core/parse.ts +21 -4
- package/src/core/vocabulary.ts +115 -9
- package/src/draw/component-files.ts +36 -0
- package/src/draw/component-svg.ts +79 -0
- package/src/draw/conventions/architectural.ts +60 -0
- package/src/draw/index.ts +1 -1
- package/src/draw/marks.ts +564 -44
- package/src/draw/plan.ts +262 -89
- package/src/form.ts +1 -0
- package/src/index.ts +1 -1
- package/src/mcp.ts +22 -3
- package/src/parse-file.ts +1 -0
- package/src/validate/assessment.ts +17 -3
- package/src/validate/builtin/index.ts +14 -2
- package/src/validate/builtin/opening-operations.ts +519 -0
- package/src/validate/contracts.ts +1 -0
package/examples/house/site.muro
CHANGED
|
@@ -19,9 +19,9 @@ boundary /site/garden /site/east type:open
|
|
|
19
19
|
boundary /site/west /site/north type:open
|
|
20
20
|
boundary /site/east /site/north type:open
|
|
21
21
|
|
|
22
|
-
# ----
|
|
22
|
+
# ---- Site boundary: the gate uses an asset reference at an explicit position. ----
|
|
23
23
|
boundary /site/garden /out/road edge:S t:120 spec:ブロック塀+フェンス air:1 h:1200
|
|
24
|
-
door GT1 at:X2 name
|
|
24
|
+
door GT1 at:X2 name:Gate # The grid-based position is explicit; overshooting is an error.
|
|
25
25
|
boundary /site/garden /out/w edge:W t:120 spec:ブロック塀 air:1 h:1200
|
|
26
26
|
boundary /site/garden /out/e edge:E t:120 spec:ブロック塀 air:1 h:1200
|
|
27
27
|
boundary /site/west /out/w edge:W t:120 spec:ブロック塀 air:1 h:1200
|
package/examples/house.muro
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
# 敷地 = zone site:1 (宣言面積と導出面積を site コマンドが突き合わせる)。
|
|
8
8
|
# L1の平面図はそのまま配置図兼用になる。
|
|
9
9
|
|
|
10
|
-
muro 1.
|
|
10
|
+
muro 1.6
|
|
11
11
|
name 小さな戸建住宅
|
|
12
12
|
unit mm
|
|
13
13
|
|
|
@@ -43,13 +43,13 @@ space /home/hall2 hall X2..X3 Y2..Y3 level:L2 name:2階ホール
|
|
|
43
43
|
boundary /home/ldk /home/hall1 t:120 spec:LGS
|
|
44
44
|
door w:800 edge:E hinge:S swing:b
|
|
45
45
|
boundary /home/ldk /site/garden t:150 spec:EW
|
|
46
|
-
window w:2600 h:2200 sill:0 name
|
|
46
|
+
window w:2600 h:2200 sill:0 name:Full-height-window
|
|
47
47
|
boundary /home/ldk /site/west t:150 spec:EW
|
|
48
48
|
window w:1650 h:1100 sill:900
|
|
49
49
|
boundary /home/ldk /site/east t:150 spec:EW
|
|
50
50
|
boundary /home/ldk /site/north t:150 spec:EW
|
|
51
51
|
boundary /home/hall1 /site/east t:150 spec:EW
|
|
52
|
-
door w:900 name
|
|
52
|
+
door w:900 name:Entrance
|
|
53
53
|
boundary /home/hall1 /site/north t:150 spec:EW
|
|
54
54
|
|
|
55
55
|
# ---- 庭同士は連続 ----
|
|
@@ -58,9 +58,9 @@ boundary /site/garden /site/east type:open
|
|
|
58
58
|
boundary /site/west /site/north type:open
|
|
59
59
|
boundary /site/east /site/north type:open
|
|
60
60
|
|
|
61
|
-
# ----
|
|
61
|
+
# ---- Site boundary: the wall is boundary specification; air:1 leaves it open to outside air. ----
|
|
62
62
|
boundary /site/garden /out/road edge:S t:120 spec:ブロック塀+フェンス air:1 h:1200
|
|
63
|
-
door w:900 name
|
|
63
|
+
door w:900 style:gate-hinged name:Gate
|
|
64
64
|
boundary /site/garden /out/w edge:W t:120 spec:ブロック塀 air:1 h:1200
|
|
65
65
|
boundary /site/garden /out/e edge:E t:120 spec:ブロック塀 air:1 h:1200
|
|
66
66
|
boundary /site/west /out/w edge:W t:120 spec:ブロック塀 air:1 h:1200
|
|
@@ -79,7 +79,7 @@ boundary /home/bed1 /home/hall2 t:120 spec:LGS
|
|
|
79
79
|
door w:800
|
|
80
80
|
boundary /home/void /home/hall2 t:120 spec:手すり air:1 h:1100
|
|
81
81
|
boundary /home/void /out/road edge:S t:150 spec:EW
|
|
82
|
-
window w:2600 h:1100 sill:1100 name
|
|
82
|
+
window w:2600 h:1100 sill:1100 name:Void-clerestory
|
|
83
83
|
boundary /home/void /out/e edge:E t:150 spec:EW
|
|
84
84
|
boundary /home/hall2 /out/e edge:E t:150 spec:EW
|
|
85
85
|
boundary /home/hall2 /out/n edge:N t:150 spec:EW
|
package/examples/mansion.muro
CHANGED
package/examples/office.muro
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
grid X 0 4000 6000 10000
|
|
2
|
+
grid Y 0 2000 6000
|
|
3
|
+
level L1 0
|
|
4
|
+
level L2 3200
|
|
5
|
+
space /L1/a room X1..X2 Y2..Y3 uid:space-a name:"Room A"
|
|
6
|
+
space /L1/b room X2..X4 Y2..Y3 uid:space-b name:"Room B"
|
|
7
|
+
space /L1/c circulation X1..X4 Y1..Y2 uid:space-c name:"Shared space"
|
|
8
|
+
space /L2/d room X1..X2 Y1..Y3 uid:space-d name:"Upper space"
|
|
@@ -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:高窓
|
package/examples/tower/main.muro
CHANGED
|
@@ -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:
|
|
13
|
-
asset LG1 door w:3600 h:3600 style:
|
|
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) 幅・天井いっぱいの窓 = その面はガラスである、という宣言
|
package/examples/twin/main.muro
CHANGED
package/examples/two-rooms.muro
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kensnzk/koyu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"muro": {
|
|
5
5
|
"reads": [
|
|
6
6
|
"0.1",
|
|
@@ -12,12 +12,14 @@
|
|
|
12
12
|
"1.1",
|
|
13
13
|
"1.2",
|
|
14
14
|
"1.3",
|
|
15
|
-
"1.4"
|
|
15
|
+
"1.4",
|
|
16
|
+
"1.5",
|
|
17
|
+
"1.6"
|
|
16
18
|
],
|
|
17
|
-
"newest": "1.
|
|
19
|
+
"newest": "1.6",
|
|
18
20
|
"undeclared": "1.1"
|
|
19
21
|
},
|
|
20
|
-
"description": "
|
|
22
|
+
"description": "A text-native architectural notation with space as the primary element",
|
|
21
23
|
"type": "module",
|
|
22
24
|
"main": "./dist/index.js",
|
|
23
25
|
"types": "./dist/index.d.ts",
|
|
@@ -71,6 +73,7 @@
|
|
|
71
73
|
"default": "./dist/parse-file.js"
|
|
72
74
|
},
|
|
73
75
|
"./examples/*": "./examples/*",
|
|
76
|
+
"./assets/*": "./assets/*",
|
|
74
77
|
"./syntax": "./editors/vscode/syntaxes/koyu.tmLanguage.json",
|
|
75
78
|
"./package.json": "./package.json"
|
|
76
79
|
},
|
|
@@ -82,6 +85,7 @@
|
|
|
82
85
|
"dist",
|
|
83
86
|
"src",
|
|
84
87
|
"examples",
|
|
88
|
+
"assets",
|
|
85
89
|
"editors",
|
|
86
90
|
"NOTICE"
|
|
87
91
|
],
|
|
@@ -94,7 +98,7 @@
|
|
|
94
98
|
"prepare": "npm run build",
|
|
95
99
|
"test": "node --import tsx --test test/*.test.ts",
|
|
96
100
|
"typecheck": "tsc --noEmit",
|
|
97
|
-
"check:examples": "for f in examples/two-rooms.muro examples/office.muro examples/mansion.muro examples/house.muro examples/house/main.muro examples/tower/main.muro examples/basement/main.muro examples/complex/main.muro examples/twin/main.muro examples/steps/*.muro skills/koyu-author/examples/flat-1ldk.muro skills/koyu-author/examples/office/main.muro; do tsx src/cli.ts check $f || exit 1; done",
|
|
101
|
+
"check:examples": "for f in examples/spatial/main.muro examples/two-rooms.muro examples/office.muro examples/mansion.muro examples/house.muro examples/house/main.muro examples/tower/main.muro examples/basement/main.muro examples/complex/main.muro examples/twin/main.muro examples/steps/*.muro skills/koyu-author/examples/flat-1ldk.muro skills/koyu-author/examples/office/main.muro; do tsx src/cli.ts check $f || exit 1; done",
|
|
98
102
|
"gate:examples": "node --import tsx scripts/gate.mjs",
|
|
99
103
|
"plan:examples": "tsx src/cli.ts plan examples/two-rooms.muro -o out/two-rooms.svg",
|
|
100
104
|
"conformance": "node --import tsx --test test/conformance.test.ts",
|
|
@@ -235,6 +235,7 @@ export interface AnalysisReport<T extends JsonValue = JsonValue> {
|
|
|
235
235
|
readonly profile: ComponentIdentity;
|
|
236
236
|
readonly model: {
|
|
237
237
|
readonly languageVersion: string;
|
|
238
|
+
readonly mode?: "spatial";
|
|
238
239
|
readonly name?: string;
|
|
239
240
|
readonly state: "consistent" | "inconsistent";
|
|
240
241
|
readonly diagnostics: readonly Diagnostic[];
|
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";
|
|
@@ -310,7 +310,9 @@ function main(argv: string[]): number {
|
|
|
310
310
|
);
|
|
311
311
|
// **緑の意味を、緑を出す場所で言う。**構造整合が成り立っただけであって、
|
|
312
312
|
// 建築として妥当かはここでは何も言っていない (docs/reference/scope.md)
|
|
313
|
-
console.log(
|
|
313
|
+
console.log(model.mode === "spatial"
|
|
314
|
+
? " Spatial model — unwritten boundaries are unresolved; architectural assessment is not evaluated"
|
|
315
|
+
: " Structural consistency only — architectural validity is what koyu validate says, separately");
|
|
314
316
|
return strict && warnings.length > 0 ? 1 : 0;
|
|
315
317
|
}
|
|
316
318
|
return 1;
|
|
@@ -334,7 +336,7 @@ function main(argv: string[]): number {
|
|
|
334
336
|
const violations = report.findings.filter((f) => f.level === "violation").length;
|
|
335
337
|
const cautions = report.findings.length - violations;
|
|
336
338
|
console.log(
|
|
337
|
-
report.findings.length === 0
|
|
339
|
+
model.mode === "spatial" ? "Spatial model — architectural assessment is not evaluated" : report.findings.length === 0
|
|
338
340
|
? "✔ Nothing caught by validation (this is a judgement, not a guarantee about the composition)"
|
|
339
341
|
: `Validation — ${qty(violations, "violation", "violations")} / ${qty(cautions, "caution", "cautions")}`,
|
|
340
342
|
);
|
|
@@ -381,13 +383,17 @@ function main(argv: string[]): number {
|
|
|
381
383
|
const explicit = opt(rest, "-o");
|
|
382
384
|
const outFile =
|
|
383
385
|
explicit ?? `${file.replace(/\.muro$/, "")}-${level}.svg`;
|
|
384
|
-
const svg = svgPlan(model, { level });
|
|
386
|
+
const svg = svgPlan(model, { level, componentSvgs: componentSvgFiles(model, level) });
|
|
385
387
|
mkdirSync(dirname(outFile), { recursive: true });
|
|
386
388
|
writeFileSync(outFile, svg);
|
|
387
389
|
console.log(`Generated the plan: ${outFile}`);
|
|
388
390
|
return 0;
|
|
389
391
|
}
|
|
390
392
|
case "doors": {
|
|
393
|
+
if (model.mode === "spatial") {
|
|
394
|
+
console.error("Circulation is not evaluated in spatial mode");
|
|
395
|
+
return 2;
|
|
396
|
+
}
|
|
391
397
|
const [from, to] = rest;
|
|
392
398
|
if (!from || !to) {
|
|
393
399
|
console.log("Usage: koyu doors <file> /pathA /pathB");
|
|
@@ -402,6 +408,7 @@ function main(argv: string[]): number {
|
|
|
402
408
|
return 0;
|
|
403
409
|
}
|
|
404
410
|
case "graph": {
|
|
411
|
+
if (model.mode === "spatial") console.log("Spatial model — declared relations only; missing boundaries are unresolved");
|
|
405
412
|
for (const s of model.spaces.values()) {
|
|
406
413
|
const ns = neighbors(model, s.path);
|
|
407
414
|
console.log(`${s.path} (${displayName(s)})`);
|
|
@@ -506,6 +513,10 @@ function main(argv: string[]): number {
|
|
|
506
513
|
return 0;
|
|
507
514
|
}
|
|
508
515
|
case "light": {
|
|
516
|
+
if (model.mode === "spatial") {
|
|
517
|
+
console.error("Daylight is not evaluated in spatial mode");
|
|
518
|
+
return 2;
|
|
519
|
+
}
|
|
509
520
|
// **数だけを返す。**床面積と有効窓面積は模型から出る事実であり、そこへ線を引くのは
|
|
510
521
|
// 規則の側の仕事である。閾値をここに書けば validate と二重になり、片方だけが古くなる
|
|
511
522
|
// (docs/reference/scope.md)。合否は koyu validate が言う
|
|
@@ -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
|
+
}
|
package/src/core/derive.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// 切断高さは Form の**入力**であって中身ではない。
|
|
20
20
|
|
|
21
21
|
import { CEILING_T, ROOF_T, slabs, type Slab } from "./fabric.js";
|
|
22
|
-
import { placeBand, placeOpening, segmentLength, segmentsFor, type Segment } from "./graph.js";
|
|
22
|
+
import { placeBand, placeOpening, segmentLength, segmentsFor, unresolvedBoundaries, type UnresolvedBoundary, type Segment } from "./graph.js";
|
|
23
23
|
import {
|
|
24
24
|
areaM2,
|
|
25
25
|
columnsFor,
|
|
@@ -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
|
-
/**
|
|
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
|
/** 切断面が切ったもの */
|
|
@@ -310,11 +341,16 @@ export interface FormPlan {
|
|
|
310
341
|
* 座標・厚み・z 範囲・向き・対象の同一性だけを持ち、描き方は消費者が決める
|
|
311
342
|
*/
|
|
312
343
|
export interface Form {
|
|
344
|
+
/** Present only in spatial mode. These faces have no physical or passage meaning. */
|
|
345
|
+
mode?: "spatial";
|
|
346
|
+
unresolved?: UnresolvedBoundary[];
|
|
313
347
|
input: FormInput;
|
|
314
348
|
levels: FormLevel[];
|
|
315
349
|
spaces: FormSpace[];
|
|
316
350
|
boundaries: FormBoundary[];
|
|
317
351
|
openings: FormOpening[];
|
|
352
|
+
/** Present only when the source places a component, preserving older Form bytes otherwise. */
|
|
353
|
+
components?: FormComponent[];
|
|
318
354
|
/** 数えない分節 (ADR-0003) — 面積にもグラフにも現れないが、位置は導出される */
|
|
319
355
|
segs: FormSeg[];
|
|
320
356
|
slabs: Slab[];
|
|
@@ -347,7 +383,7 @@ export function levelPitch(model: Model, level: string): number | undefined {
|
|
|
347
383
|
const h = heff(model, s);
|
|
348
384
|
if (h !== undefined && (top === undefined || h > top)) top = h;
|
|
349
385
|
}
|
|
350
|
-
return top === undefined ? undefined : top + ROOF_T;
|
|
386
|
+
return top === undefined ? undefined : top + (model.mode === "spatial" ? 0 : ROOF_T);
|
|
351
387
|
}
|
|
352
388
|
|
|
353
389
|
/** 境界が立つレベル — 領域を持つ側の空間が決める (a を先に見る) */
|
|
@@ -916,7 +952,8 @@ export function derive(model: Model, opts: DeriveOptions = {}): Form {
|
|
|
916
952
|
: z0 + OPENING_HEAD;
|
|
917
953
|
holes.push({ lo: d - p.o.w / 2, hi: d + p.o.w / 2, z0: oz0, z1: oz1 });
|
|
918
954
|
const style = p.o.attrs["style"];
|
|
919
|
-
const
|
|
955
|
+
const panels = p.o.attrs["panels"];
|
|
956
|
+
const sliding = typeof style === "string" && NON_SWING_OPENING_STYLES.has(style);
|
|
920
957
|
const name = p.o.attrs["name"];
|
|
921
958
|
openings.push({
|
|
922
959
|
ref: `${ref}/${p.index}`,
|
|
@@ -935,7 +972,12 @@ export function derive(model: Model, opts: DeriveOptions = {}): Form {
|
|
|
935
972
|
z1: oz1,
|
|
936
973
|
t,
|
|
937
974
|
...(typeof style === "string" ? { style } : {}),
|
|
938
|
-
...(
|
|
975
|
+
...(typeof panels === "number" ? { panels } : {}),
|
|
976
|
+
...(p.o.kind === "door" || (
|
|
977
|
+
!isNewerVersion("1.5", model.version)
|
|
978
|
+
&& typeof style === "string"
|
|
979
|
+
&& WINDOW_SWING_STYLES.has(style)
|
|
980
|
+
)
|
|
939
981
|
? (() => {
|
|
940
982
|
const sw = swingOf(model, b, p.o, seg, p.cx, p.cy);
|
|
941
983
|
return sw ? { swing: sw } : {};
|
|
@@ -1000,17 +1042,22 @@ export function derive(model: Model, opts: DeriveOptions = {}): Form {
|
|
|
1000
1042
|
areaM2: polygonAreaM2(p.points),
|
|
1001
1043
|
}));
|
|
1002
1044
|
|
|
1045
|
+
// ---- Area-hosted components ----
|
|
1046
|
+
const components = placedComponents(model).components;
|
|
1047
|
+
|
|
1003
1048
|
// ---- 平面 ----
|
|
1004
1049
|
const plans = levels.map((l) =>
|
|
1005
1050
|
planOf(model, l.name, l.z + cut, cut, { spaces, boundaries, openings, columns }),
|
|
1006
1051
|
);
|
|
1007
1052
|
|
|
1008
1053
|
return {
|
|
1054
|
+
...(model.mode === "spatial" ? { mode: model.mode, unresolved: unresolvedBoundaries(model) } : {}),
|
|
1009
1055
|
input: { cut },
|
|
1010
1056
|
levels: formLevels,
|
|
1011
1057
|
spaces,
|
|
1012
1058
|
boundaries,
|
|
1013
1059
|
openings,
|
|
1060
|
+
...(components.length > 0 ? { components } : {}),
|
|
1014
1061
|
segs,
|
|
1015
1062
|
slabs: slabs(model),
|
|
1016
1063
|
columns,
|