@kensnzk/koyu 0.5.0 → 0.11.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 +43 -11
- package/README.md +51 -11
- package/dist/check.d.ts +34 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +500 -0
- package/dist/check.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +319 -0
- package/dist/cli.js.map +1 -0
- package/dist/diff.d.ts +90 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +522 -0
- package/dist/diff.js.map +1 -0
- package/dist/graph.d.ts +81 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +328 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/light.d.ts +15 -0
- package/dist/light.d.ts.map +1 -0
- package/dist/light.js +55 -0
- package/dist/light.js.map +1 -0
- package/dist/mcp.d.ts +3 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +354 -0
- package/dist/mcp.js.map +1 -0
- package/dist/model.d.ts +264 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +361 -0
- package/dist/model.js.map +1 -0
- package/dist/parse-file.d.ts +9 -0
- package/dist/parse-file.d.ts.map +1 -0
- package/dist/parse-file.js +22 -0
- package/dist/parse-file.js.map +1 -0
- package/dist/parse.d.ts +16 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +922 -0
- package/dist/parse.js.map +1 -0
- package/dist/plan.d.ts +8 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +267 -0
- package/dist/plan.js.map +1 -0
- package/dist/site.d.ts +24 -0
- package/dist/site.d.ts.map +1 -0
- package/dist/site.js +53 -0
- package/dist/site.js.map +1 -0
- package/examples/comparison/README.md +16 -1
- package/examples/comparison/gen-ifc4.ts +1 -1
- package/examples/comparison/gen-ifcx.ts +2 -2
- package/examples/comparison/two-rooms.ifcx +1 -1
- package/examples/house/L1.muro +16 -0
- package/examples/house/L2.muro +19 -0
- package/examples/house/assets.muro +9 -0
- package/examples/house/main.muro +27 -0
- package/examples/house/site.muro +31 -0
- package/examples/house.muro +1 -1
- package/examples/mansion.muro +1 -1
- package/examples/office.muro +1 -1
- package/examples/steps/01-one-room.muro +4 -0
- package/examples/steps/02-two-rooms.muro +5 -0
- package/examples/steps/03-door.muro +9 -0
- package/examples/steps/04-exterior.muro +15 -0
- package/examples/steps/05-two-storeys.muro +27 -0
- package/examples/steps/06-finished.muro +30 -0
- package/examples/steps/README.md +25 -0
- package/examples/tower/L1.muro +80 -0
- package/examples/tower/L11.muro +47 -0
- package/examples/tower/L2.muro +69 -0
- package/examples/tower/L3.muro +28 -0
- package/examples/tower/assets.muro +13 -0
- package/examples/tower/main.muro +37 -0
- package/examples/tower/site-geometry.muro +7 -0
- package/examples/tower/site.muro +33 -0
- package/examples/tower/typical.muro +124 -0
- package/examples/two-rooms.canonical.json +5 -2
- package/examples/two-rooms.muro +6 -5
- package/package.json +28 -2
- package/src/check.ts +352 -63
- package/src/cli.ts +76 -11
- package/src/diff.ts +608 -0
- package/src/graph.ts +90 -10
- package/src/index.ts +14 -2
- package/src/mcp.ts +390 -0
- package/src/model.ts +260 -55
- package/src/parse-file.ts +28 -0
- package/src/parse.ts +562 -44
- package/src/plan.ts +33 -4
- package/src/site.ts +13 -5
- package/.github/workflows/ci.yml +0 -16
- package/.zenodo.json +0 -20
- package/CITATION.cff +0 -26
- package/docs/decisions/0001-notation-v0.md +0 -29
- package/docs/decisions/0002-height-and-offsets.md +0 -27
- package/docs/decisions/0003-uncounted-divisions.md +0 -36
- package/docs/decisions/0004-typical-floors.md +0 -21
- package/docs/decisions/0005-zones-and-unions.md +0 -23
- package/docs/decisions/0006-voids-and-light.md +0 -31
- package/docs/decisions/0007-semi-outdoor-air.md +0 -27
- package/docs/decisions/0008-vocabulary-and-level-attr.md +0 -23
- package/docs/decisions/0009-site-and-exterior.md +0 -29
- package/docs/ifc-coverage.md +0 -82
- package/docs/ifcx-notes.md +0 -25
- package/docs/img/house-L1.svg +0 -80
- package/docs/img/house-L2.svg +0 -53
- package/docs/img/mansion-L1.svg +0 -113
- package/docs/img/mansion-L10.svg +0 -111
- package/docs/img/mansion-L5.svg +0 -160
- package/docs/img/office-L1.svg +0 -116
- package/docs/img/office-L2.svg +0 -109
- package/docs/img/two-rooms.svg +0 -39
- package/docs/log/2026-07-22.md +0 -13
- package/docs/log/2026-07-23.md +0 -51
- package/docs/roadmap.md +0 -55
- package/docs/writing-architecture.md +0 -119
- package/spec/notation-v0.md +0 -164
- package/spec/vocabulary.md +0 -62
- package/test/core.test.ts +0 -171
- package/test/design2.test.ts +0 -97
- package/test/house.test.ts +0 -74
- package/test/mansion.test.ts +0 -99
- package/test/office.test.ts +0 -71
- package/test/uncounted.test.ts +0 -120
- package/test/vertical.test.ts +0 -75
- package/tsconfig.json +0 -13
package/src/check.ts
CHANGED
|
@@ -3,38 +3,186 @@
|
|
|
3
3
|
// 高さ方向の一貫性 — BIMが3Dであることで暗黙に担保していたもの — は、
|
|
4
4
|
// ここでは宣言された不変量 (天井高 + 上階slab ≤ 階高) の検査として明示的に持つ。
|
|
5
5
|
// 吹抜け (type:void) はこの不変量の宣言的な免除である。
|
|
6
|
+
//
|
|
7
|
+
// 診断契約 (ADR-0016): 一次形式は checkDiagnostics の Diagnostic[] — code / severity /
|
|
8
|
+
// 日本語本文 / 出所 / 対象パス。check は互換層で、従来の文字列 (位置接頭辞つき) を組み立てる。
|
|
9
|
+
// severity はコードの不変属性 — 重さを変えたくなったら新コードを切る。
|
|
6
10
|
|
|
7
11
|
import {
|
|
8
12
|
placeBand,
|
|
9
13
|
placeOpening,
|
|
10
14
|
planOverlap,
|
|
11
15
|
segmentsFor,
|
|
12
|
-
sharedSegment,
|
|
13
16
|
spacesOverlap,
|
|
14
17
|
} from "./graph.js";
|
|
15
|
-
import { heff, isSemiOutdoor, levelsSorted, type
|
|
18
|
+
import { heff, isSemiOutdoor, levelsSorted, type Attrs, type Boundary, type Model, type Space,
|
|
19
|
+
srcRef,
|
|
20
|
+
polygonAreaM2,
|
|
21
|
+
polygonSelfIntersection,
|
|
22
|
+
rectEscapesPolygon,
|
|
23
|
+
} from "./model.js";
|
|
16
24
|
|
|
17
25
|
export interface CheckResult {
|
|
18
26
|
errors: string[];
|
|
19
27
|
warnings: string[];
|
|
20
28
|
}
|
|
21
29
|
|
|
30
|
+
/** 構造化診断 (ADR-0016)。message は本文のみ — 位置接頭辞「file:N行目: 」を含まない */
|
|
31
|
+
export interface Diagnostic {
|
|
32
|
+
/** 台帳 DIAGNOSTIC_CODES のコード (領域2-3字 + 2桁連番) */
|
|
33
|
+
code: string;
|
|
34
|
+
severity: "error" | "warning";
|
|
35
|
+
/** 日本語の本文 (位置接頭辞なし) */
|
|
36
|
+
message: string;
|
|
37
|
+
/** 出所の行 (位置を持たない診断は省略) */
|
|
38
|
+
line?: number;
|
|
39
|
+
/** 出所レイヤー (合成時) */
|
|
40
|
+
file?: string;
|
|
41
|
+
/** 対象の空間/ゾーン/polygonのパス (境界は両パス) */
|
|
42
|
+
path?: string[];
|
|
43
|
+
/** 関連位置 (重複の既出側・重なりの相手など) */
|
|
44
|
+
related?: Array<{ line: number; file?: string }>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 診断コードの台帳 — 全コードと規範severity。specの表 (semantics.md §5) とテストで一致を守る。
|
|
49
|
+
* BND07 は欠番 — 「接しているのに境界が無い」警告はADR-0014 (既定境界) で廃止された。
|
|
50
|
+
* SYN01 は構文・合成エラー (SourceError) の写し — checkは例外を診断にしない。CLIの check --json だけが写す。
|
|
51
|
+
*/
|
|
52
|
+
export const DIAGNOSTIC_CODES: Record<string, "error" | "warning"> = {
|
|
53
|
+
REF01: "error", // 境界が未定義の空間パスを参照
|
|
54
|
+
BND01: "error", // 同一空間同士の境界
|
|
55
|
+
BND02: "error", // 同一空間対の境界の重複 (edge限定まで同一 — ADR-0013)
|
|
56
|
+
BND03: "error", // 異レベルの空間への壁境界
|
|
57
|
+
BND04: "error", // 接していない空間の境界
|
|
58
|
+
BND05: "warning", // 同一空間対でedge限定の有無が混在
|
|
59
|
+
BND06: "warning", // 境界線分がゼロ
|
|
60
|
+
LVL01: "error", // レベルzの重複
|
|
61
|
+
GEO01: "error", // 自らの領域 (合併の矩形) 同士の重なり
|
|
62
|
+
GEO02: "error", // 同一レベルの空間同士の重なり
|
|
63
|
+
VRT01: "error", // 垂直境界の前提 (領域とレベルを持つ空間同士)
|
|
64
|
+
VRT02: "error", // 非隣接レベル間の垂直境界
|
|
65
|
+
VRT03: "error", // 平面が重ならない垂直境界
|
|
66
|
+
VRT04: "warning", // void境界の上側が非void
|
|
67
|
+
VRT05: "warning", // 垂直境界の開口 (解釈されない)
|
|
68
|
+
VRT06: "warning", // 垂直境界のseg (解釈されない)
|
|
69
|
+
OPN01: "error", // hingeの軸違い
|
|
70
|
+
OPN02: "error", // 開口同士の重なり
|
|
71
|
+
OPN03: "warning", // open境界の開口 (通行に影響しない)
|
|
72
|
+
OPN04: "error", // 開口を置ける境界線分が無い
|
|
73
|
+
OPN05: "error", // 境界線分が複数で曖昧
|
|
74
|
+
OPN06: "error", // 開口の幅が線分長を超える
|
|
75
|
+
OPN07: "error", // 開口の明示位置の軸違い
|
|
76
|
+
OPN08: "error", // 開口の明示位置のはみ出し
|
|
77
|
+
SEG01: "error", // 領域を持たない空間へのarea
|
|
78
|
+
SEG02: "warning", // areaのはみ出し
|
|
79
|
+
SEG03: "warning", // open境界のseg (解釈されない)
|
|
80
|
+
SEG04: "error", // segを置ける境界線分が無い
|
|
81
|
+
SEG05: "error", // segの境界線分が複数で曖昧
|
|
82
|
+
SEG06: "error", // segの幅が線分長を超える
|
|
83
|
+
SEG07: "error", // segの明示位置の軸違い
|
|
84
|
+
SEG08: "error", // segの明示位置のはみ出し
|
|
85
|
+
ZON01: "warning", // 空のゾーン
|
|
86
|
+
ZON02: "warning", // ゾーンと同パスの空間
|
|
87
|
+
HGT01: "error", // 上階への食い込み (高さ不変量違反)
|
|
88
|
+
HGT02: "error", // 部分吹抜けの被覆不足
|
|
89
|
+
HGT03: "warning", // 上階slab未宣言で高さ検査ができない
|
|
90
|
+
HGT04: "warning", // 天井高不明で高さ検査ができない
|
|
91
|
+
HGT05: "warning", // レベルが特定できない領域つき空間
|
|
92
|
+
SIT01: "error", // 敷地形状の重複頂点
|
|
93
|
+
SIT02: "error", // 敷地形状の自己交差
|
|
94
|
+
SIT03: "error", // 建物の敷地形状からのはみ出し
|
|
95
|
+
SIT04: "warning", // 対応するゾーンの無いpolygon
|
|
96
|
+
SIT05: "warning", // 敷地面積の宣言と導出の食い違い
|
|
97
|
+
UID01: "error", // 数字だけのuid (ADR-0015)
|
|
98
|
+
UID02: "error", // 空白を含むuid
|
|
99
|
+
UID03: "error", // uidの重複
|
|
100
|
+
VER01: "error", // koyu 0.1 での既定境界の導出 (ADR-0017)
|
|
101
|
+
SYN01: "error", // 構文・合成エラー (SourceError の写し — check --json のみ)
|
|
102
|
+
};
|
|
103
|
+
|
|
22
104
|
const EPS = 0.5;
|
|
105
|
+
/** 敷地まわりの幾何の許容 (境界上は内側扱い) — ADR-0011の1mm */
|
|
106
|
+
const EPS_SITE = 1;
|
|
23
107
|
const VERTICAL = new Set(["stair", "shaft", "void"]);
|
|
24
108
|
|
|
109
|
+
/** 互換層 — 従来の文字列形式。位置を持つ診断は「file:N行目: 本文」に組み立てる */
|
|
25
110
|
export function check(model: Model): CheckResult {
|
|
26
111
|
const errors: string[] = [];
|
|
27
112
|
const warnings: string[] = [];
|
|
113
|
+
for (const d of checkDiagnostics(model)) {
|
|
114
|
+
const text = d.line !== undefined ? `${srcRef(d.line, d.file)}: ${d.message}` : d.message;
|
|
115
|
+
(d.severity === "error" ? errors : warnings).push(text);
|
|
116
|
+
}
|
|
117
|
+
return { errors, warnings };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
121
|
+
const diags: Diagnostic[] = [];
|
|
122
|
+
/** line:0 は「位置なし」— フィールドごと省略する (既定境界などの導出物) */
|
|
123
|
+
const emit = (
|
|
124
|
+
code: string,
|
|
125
|
+
message: string,
|
|
126
|
+
at: {
|
|
127
|
+
line?: number;
|
|
128
|
+
file?: string;
|
|
129
|
+
path?: string[];
|
|
130
|
+
related?: Array<{ line: number; file?: string }>;
|
|
131
|
+
} = {},
|
|
132
|
+
) => {
|
|
133
|
+
diags.push({
|
|
134
|
+
code,
|
|
135
|
+
severity: DIAGNOSTIC_CODES[code]!,
|
|
136
|
+
message,
|
|
137
|
+
...(at.line ? { line: at.line } : {}),
|
|
138
|
+
...(at.line && at.file !== undefined ? { file: at.file } : {}),
|
|
139
|
+
...(at.path ? { path: at.path } : {}),
|
|
140
|
+
...(at.related ? { related: at.related } : {}),
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
const loc = (line: number, file?: string): { line: number; file?: string } => ({
|
|
144
|
+
line,
|
|
145
|
+
...(file !== undefined ? { file } : {}),
|
|
146
|
+
});
|
|
28
147
|
|
|
29
148
|
// 境界の参照先
|
|
30
149
|
for (const b of model.boundaries) {
|
|
31
150
|
for (const p of [b.a, b.b]) {
|
|
32
151
|
if (!model.spaces.has(p)) {
|
|
33
|
-
|
|
152
|
+
emit("REF01", `未定義の空間を参照しています: ${p}`, { line: b.line, file: b.file, path: [b.a, b.b] });
|
|
34
153
|
}
|
|
35
154
|
}
|
|
36
155
|
if (b.a === b.b) {
|
|
37
|
-
|
|
156
|
+
emit("BND01", `同じ空間同士の境界は書けません: ${b.a}`, { line: b.line, file: b.file, path: [b.a, b.b] });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// 境界の同一性: 同じ空間対 (edge限定まで同一) の重複宣言は矛盾の温床 — エラー (ADR-0013)。
|
|
161
|
+
// wall/openの食い違いもこの検査が捕まえる。edge限定の有無が混在する対は線分が重なるため警告
|
|
162
|
+
const seenBoundary = new Map<string, Boundary>();
|
|
163
|
+
const pairEdges = new Map<string, Set<string>>();
|
|
164
|
+
for (const b of model.boundaries) {
|
|
165
|
+
const pair = [b.a, b.b].sort().join(" | ");
|
|
166
|
+
const key = `${pair}#${b.edge ?? ""}`;
|
|
167
|
+
const prev = seenBoundary.get(key);
|
|
168
|
+
if (prev) {
|
|
169
|
+
emit(
|
|
170
|
+
"BND02",
|
|
171
|
+
`境界が重複しています: ${pair}${b.edge ? ` edge:${b.edge}` : ""} (既出: ${srcRef(prev.line, prev.file)})`,
|
|
172
|
+
{ line: b.line, file: b.file, path: [b.a, b.b], related: [loc(prev.line, prev.file)] },
|
|
173
|
+
);
|
|
174
|
+
} else {
|
|
175
|
+
seenBoundary.set(key, b);
|
|
176
|
+
}
|
|
177
|
+
const set = pairEdges.get(pair) ?? new Set<string>();
|
|
178
|
+
set.add(b.edge ?? "");
|
|
179
|
+
pairEdges.set(pair, set);
|
|
180
|
+
}
|
|
181
|
+
for (const [pair, edges] of pairEdges) {
|
|
182
|
+
if (edges.has("") && edges.size > 1) {
|
|
183
|
+
emit("BND05", `同じ空間対に edge 限定つきと無しの境界が併存しています (線分が重なります): ${pair}`, {
|
|
184
|
+
path: pair.split(" | "),
|
|
185
|
+
});
|
|
38
186
|
}
|
|
39
187
|
}
|
|
40
188
|
|
|
@@ -44,7 +192,7 @@ export function check(model: Model): CheckResult {
|
|
|
44
192
|
// レベルの重複
|
|
45
193
|
for (let i = 1; i < levels.length; i++) {
|
|
46
194
|
if (Math.abs(levels[i]!.z - levels[i - 1]!.z) < EPS) {
|
|
47
|
-
|
|
195
|
+
emit("LVL01", `レベル ${levels[i - 1]!.name} と ${levels[i]!.name} のzが同じです`);
|
|
48
196
|
}
|
|
49
197
|
}
|
|
50
198
|
|
|
@@ -53,7 +201,7 @@ export function check(model: Model): CheckResult {
|
|
|
53
201
|
for (let i = 0; i < s.rects.length; i++) {
|
|
54
202
|
for (let j = i + 1; j < s.rects.length; j++) {
|
|
55
203
|
if (planOverlap(s.rects[i]!, s.rects[j]!)) {
|
|
56
|
-
|
|
204
|
+
emit("GEO01", `${s.path} の領域同士が重なっています`, { line: s.line, file: s.file, path: [s.path] });
|
|
57
205
|
}
|
|
58
206
|
}
|
|
59
207
|
}
|
|
@@ -66,111 +214,177 @@ export function check(model: Model): CheckResult {
|
|
|
66
214
|
const b = withRect[j]!;
|
|
67
215
|
if (a.level !== b.level) continue;
|
|
68
216
|
if (spacesOverlap(a, b)) {
|
|
69
|
-
|
|
217
|
+
emit("GEO02", `空間の領域が重なっています: ${a.path} と ${b.path}`, {
|
|
218
|
+
path: [a.path, b.path],
|
|
219
|
+
related: [loc(b.line, b.file)],
|
|
220
|
+
});
|
|
70
221
|
}
|
|
71
222
|
}
|
|
72
223
|
}
|
|
73
224
|
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
for (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
warnings.push(`接しているのに境界が宣言されていません: ${a.path} | ${b.path}`);
|
|
225
|
+
// 言語版の受理条件 (ADR-0017): 0.1は意味保存の場合のみ受理する。
|
|
226
|
+
// 既定境界 (ADR-0014) が導出されるファイルは、0.1の意味 (境界なし+警告) と食い違う — エラーで二択を示す
|
|
227
|
+
if (model.version === "0.1") {
|
|
228
|
+
for (const b of model.boundaries) {
|
|
229
|
+
if (b.derived) {
|
|
230
|
+
emit(
|
|
231
|
+
"VER01",
|
|
232
|
+
`koyu 0.1 のファイルに境界が宣言されていない接触ペアがあります: ${b.a} | ${b.b} — 0.2では既定の壁が導出され意味が変わります。境界を宣言するか、koyu 0.2 へ上げます`,
|
|
233
|
+
{ path: [b.a, b.b] },
|
|
234
|
+
);
|
|
85
235
|
}
|
|
86
236
|
}
|
|
87
237
|
}
|
|
88
238
|
|
|
239
|
+
// uid (ADR-0015): 不透明トークン、space/zone横断でモデル全体一意。
|
|
240
|
+
// 数字だけの形は禁じる — parseの数値化で 0123 が 123 になり、書いたトークンの区別が失われる
|
|
241
|
+
const uidOwners = new Map<string, Array<{ kind: string; path: string; line: number; file?: string }>>();
|
|
242
|
+
const collectUid = (kind: string, path: string, attrs: Attrs, line: number, file?: string) => {
|
|
243
|
+
const v = attrs["uid"];
|
|
244
|
+
if (v === undefined) return;
|
|
245
|
+
if (typeof v === "number") {
|
|
246
|
+
emit("UID01", `uid は数字だけのトークンにできません: uid:${v} (sp-${v} のような形にします)`, {
|
|
247
|
+
line,
|
|
248
|
+
file,
|
|
249
|
+
path: [path],
|
|
250
|
+
});
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (v === "" || /\s/.test(v)) {
|
|
254
|
+
emit("UID02", `uid に空白は使えません: "${v}"`, { line, file, path: [path] });
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const arr = uidOwners.get(v) ?? [];
|
|
258
|
+
arr.push({ kind, path, line, file });
|
|
259
|
+
uidOwners.set(v, arr);
|
|
260
|
+
};
|
|
261
|
+
for (const s of model.spaces.values()) collectUid("space", s.path, s.attrs, s.line, s.file);
|
|
262
|
+
for (const z of model.zones.values()) collectUid("zone", z.path, z.attrs, z.line, z.file);
|
|
263
|
+
for (const [uid, owners] of uidOwners) {
|
|
264
|
+
if (owners.length > 1) {
|
|
265
|
+
emit(
|
|
266
|
+
"UID03",
|
|
267
|
+
`uid が重複しています: ${uid} (${owners.map((o) => `${o.kind} ${o.path} — ${srcRef(o.line, o.file)}`).join(", ")})`,
|
|
268
|
+
{ path: owners.map((o) => o.path), related: owners.map((o) => loc(o.line, o.file)) },
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
89
273
|
// 境界の妥当性
|
|
90
274
|
const levelIndex = new Map(levels.map((l, i) => [l.name, i]));
|
|
91
275
|
for (const b of model.boundaries) {
|
|
92
276
|
const sa = model.spaces.get(b.a);
|
|
93
277
|
const sb = model.spaces.get(b.b);
|
|
94
278
|
if (!sa || !sb) continue;
|
|
279
|
+
const bAt = { line: b.line, file: b.file, path: [b.a, b.b] };
|
|
95
280
|
|
|
96
281
|
if (VERTICAL.has(b.kind)) {
|
|
97
282
|
// 垂直境界: 隣り合うレベルの、平面で重なる空間同士にしか張れない
|
|
98
283
|
if (sa.rects.length === 0 || sb.rects.length === 0 || !sa.level || !sb.level) {
|
|
99
|
-
|
|
284
|
+
emit("VRT01", `${b.kind} 境界は領域とレベルを持つ空間同士に書きます`, bAt);
|
|
100
285
|
continue;
|
|
101
286
|
}
|
|
102
287
|
const ia = levelIndex.get(sa.level);
|
|
103
288
|
const ib = levelIndex.get(sb.level);
|
|
104
289
|
if (ia === undefined || ib === undefined || Math.abs(ia - ib) !== 1) {
|
|
105
|
-
|
|
106
|
-
`${b.line}行目: ${b.kind} 境界は隣り合うレベルの間に書きます: ${b.a} | ${b.b}`,
|
|
107
|
-
);
|
|
290
|
+
emit("VRT02", `${b.kind} 境界は隣り合うレベルの間に書きます: ${b.a} | ${b.b}`, bAt);
|
|
108
291
|
} else if (!spacesOverlap(sa, sb)) {
|
|
109
|
-
|
|
110
|
-
`${b.line}行目: ${b.kind} 境界の空間が平面上で重なっていません: ${b.a} | ${b.b}`,
|
|
111
|
-
);
|
|
292
|
+
emit("VRT03", `${b.kind} 境界の空間が平面上で重なっていません: ${b.a} | ${b.b}`, bAt);
|
|
112
293
|
}
|
|
113
294
|
if (b.kind === "void") {
|
|
114
295
|
const upper = (ia ?? 0) > (ib ?? 0) ? sa : sb;
|
|
115
296
|
if (upper.type !== "void") {
|
|
116
|
-
|
|
117
|
-
`${b.line}行目: void境界の上側は type:void の空間を想定しています: ${upper.path}`,
|
|
118
|
-
);
|
|
297
|
+
emit("VRT04", `void境界の上側は type:void の空間を想定しています: ${upper.path}`, bAt);
|
|
119
298
|
}
|
|
120
299
|
}
|
|
121
300
|
if (b.openings.length > 0) {
|
|
122
|
-
|
|
301
|
+
emit("VRT05", `垂直境界の開口は解釈されません`, bAt);
|
|
123
302
|
}
|
|
124
303
|
if (b.segs.length > 0) {
|
|
125
|
-
|
|
304
|
+
emit("VRT06", `垂直境界の seg は解釈されません`, bAt);
|
|
126
305
|
}
|
|
127
306
|
continue;
|
|
128
307
|
}
|
|
129
308
|
|
|
130
309
|
// 水平境界
|
|
131
310
|
if (sa.rects.length > 0 && sb.rects.length > 0 && sa.level !== sb.level) {
|
|
132
|
-
|
|
133
|
-
|
|
311
|
+
emit(
|
|
312
|
+
"BND03",
|
|
313
|
+
`異なるレベルの空間に壁境界は書けません (垂直は type:stair/shaft/void): ${b.a} | ${b.b}`,
|
|
314
|
+
bAt,
|
|
134
315
|
);
|
|
135
316
|
continue;
|
|
136
317
|
}
|
|
137
318
|
const segs = segmentsFor(model, b);
|
|
138
319
|
if (sa.rects.length > 0 && sb.rects.length > 0 && segs.length === 0) {
|
|
139
|
-
|
|
320
|
+
emit("BND04", `空間が接していないため境界を導けません: ${b.a} | ${b.b}`, bAt);
|
|
140
321
|
}
|
|
141
322
|
if ((sa.rects.length > 0 ? 1 : 0) + (sb.rects.length > 0 ? 1 : 0) === 1 && segs.length === 0) {
|
|
142
|
-
|
|
323
|
+
emit("BND06", `外周に残る辺が無く、境界線分がゼロです: ${b.a} | ${b.b}`, bAt);
|
|
143
324
|
}
|
|
144
325
|
if (b.kind === "open" && b.openings.length > 0) {
|
|
145
|
-
|
|
326
|
+
emit("OPN03", `open境界の開口は通行に影響しません (常に通れます)`, bAt);
|
|
146
327
|
}
|
|
328
|
+
const placedOnSeg: Array<{ o: (typeof b.openings)[number]; key: string; c: number }> = [];
|
|
147
329
|
for (const o of b.openings) {
|
|
148
330
|
const placed = placeOpening(model, b, o);
|
|
149
331
|
if ("error" in placed && placed.error) {
|
|
150
|
-
|
|
332
|
+
emit(placed.code, placed.message, { line: placed.line, file: placed.file, path: [b.a, b.b] });
|
|
151
333
|
continue;
|
|
152
334
|
}
|
|
335
|
+
if ("segment" in placed) {
|
|
336
|
+
const s = placed.segment;
|
|
337
|
+
placedOnSeg.push({
|
|
338
|
+
o,
|
|
339
|
+
key: `${s.x1},${s.y1},${s.x2},${s.y2}`,
|
|
340
|
+
c: s.horizontal ? placed.cx : placed.cy,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
153
343
|
if (o.hinge && "segment" in placed) {
|
|
154
344
|
const okAxis = placed.segment.horizontal
|
|
155
345
|
? o.hinge === "W" || o.hinge === "E"
|
|
156
346
|
: o.hinge === "N" || o.hinge === "S";
|
|
157
347
|
if (!okAxis) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
348
|
+
emit(
|
|
349
|
+
"OPN01",
|
|
350
|
+
`hinge:${o.hinge} は${placed.segment.horizontal ? "水平線分 (W/E)" : "垂直線分 (N/S)"}で指定します`,
|
|
351
|
+
{ line: o.line, file: b.file, path: [b.a, b.b] },
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
// 同じ線分の上の開口同士は重なってはならない
|
|
357
|
+
const byKey = new Map<string, typeof placedOnSeg>();
|
|
358
|
+
for (const p of placedOnSeg) {
|
|
359
|
+
const arr = byKey.get(p.key) ?? [];
|
|
360
|
+
arr.push(p);
|
|
361
|
+
byKey.set(p.key, arr);
|
|
362
|
+
}
|
|
363
|
+
for (const group of byKey.values()) {
|
|
364
|
+
group.sort((p, q) => p.c - q.c);
|
|
365
|
+
for (let k = 0; k + 1 < group.length; k++) {
|
|
366
|
+
const p = group[k]!;
|
|
367
|
+
const q = group[k + 1]!;
|
|
368
|
+
const need = (p.o.w + q.o.w) / 2;
|
|
369
|
+
if (q.c - p.c < need - EPS) {
|
|
370
|
+
emit(
|
|
371
|
+
"OPN02",
|
|
372
|
+
`開口同士が重なっています (${p.o.kind}と${q.o.kind} — 中心間 ${Math.round(
|
|
373
|
+
q.c - p.c,
|
|
374
|
+
)}mm < 必要 ${Math.round(need)}mm)`,
|
|
375
|
+
{ line: q.o.line, file: b.file, path: [b.a, b.b], related: [loc(p.o.line, b.file)] },
|
|
162
376
|
);
|
|
163
377
|
}
|
|
164
378
|
}
|
|
165
379
|
}
|
|
166
380
|
for (const g of b.segs) {
|
|
167
381
|
if (b.kind === "open") {
|
|
168
|
-
|
|
382
|
+
emit("SEG03", `open境界 (壁が無い) の seg は解釈されません`, { line: g.line, file: b.file, path: [b.a, b.b] });
|
|
169
383
|
continue;
|
|
170
384
|
}
|
|
171
385
|
const placed = placeBand(model, b, g, "seg");
|
|
172
386
|
if ("error" in placed && placed.error) {
|
|
173
|
-
|
|
387
|
+
emit(placed.code, placed.message, { line: placed.line, file: placed.file, path: [b.a, b.b] });
|
|
174
388
|
}
|
|
175
389
|
}
|
|
176
390
|
}
|
|
@@ -179,7 +393,11 @@ export function check(model: Model): CheckResult {
|
|
|
179
393
|
for (const s of model.spaces.values()) {
|
|
180
394
|
for (const a of s.areas) {
|
|
181
395
|
if (s.rects.length === 0) {
|
|
182
|
-
|
|
396
|
+
emit("SEG01", `領域を持たない空間 ${s.path} に area は書けません`, {
|
|
397
|
+
line: a.line,
|
|
398
|
+
file: s.file,
|
|
399
|
+
path: [s.path],
|
|
400
|
+
});
|
|
183
401
|
continue;
|
|
184
402
|
}
|
|
185
403
|
const inside = s.rects.some(
|
|
@@ -190,7 +408,7 @@ export function check(model: Model): CheckResult {
|
|
|
190
408
|
a.rect.y2 <= r.y2 + EPS,
|
|
191
409
|
);
|
|
192
410
|
if (!inside) {
|
|
193
|
-
|
|
411
|
+
emit("SEG02", `area が ${s.path} の領域からはみ出しています`, { line: a.line, file: s.file, path: [s.path] });
|
|
194
412
|
}
|
|
195
413
|
}
|
|
196
414
|
}
|
|
@@ -199,10 +417,14 @@ export function check(model: Model): CheckResult {
|
|
|
199
417
|
for (const z of model.zones.values()) {
|
|
200
418
|
const children = [...model.spaces.keys()].filter((p) => p.startsWith(z.path + "/"));
|
|
201
419
|
if (children.length === 0) {
|
|
202
|
-
|
|
420
|
+
emit("ZON01", `ゾーン ${z.path} の下に空間がありません`, { line: z.line, file: z.file, path: [z.path] });
|
|
203
421
|
}
|
|
204
422
|
if (model.spaces.has(z.path)) {
|
|
205
|
-
|
|
423
|
+
emit("ZON02", `ゾーンと同じパスの空間があります (どちらかに寄せます): ${z.path}`, {
|
|
424
|
+
line: z.line,
|
|
425
|
+
file: z.file,
|
|
426
|
+
path: [z.path],
|
|
427
|
+
});
|
|
206
428
|
}
|
|
207
429
|
}
|
|
208
430
|
|
|
@@ -249,41 +471,108 @@ export function check(model: Model): CheckResult {
|
|
|
249
471
|
}
|
|
250
472
|
const h = heff(model, s);
|
|
251
473
|
if (h === undefined) {
|
|
252
|
-
|
|
474
|
+
emit("HGT04", `${s.path} の天井高が不明で、${lu.name} との高さ検査ができません`, { path: [s.path] });
|
|
253
475
|
continue;
|
|
254
476
|
}
|
|
255
477
|
if (h + lu.slab > pitch + EPS) {
|
|
256
478
|
const partners = voidPartners.get(`${s.path}|${lu.name}`) ?? [];
|
|
257
479
|
const cover = partners.length ? voidCoverage(s, partners) : 0;
|
|
258
480
|
if (cover >= 0.99) continue; // 全面吹抜け — 宣言的免除
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
481
|
+
if (partners.length) {
|
|
482
|
+
emit(
|
|
483
|
+
"HGT02",
|
|
484
|
+
`${s.path} の天井高${h}は階高${pitch}を超えますが、吹抜けの被覆は${Math.round(
|
|
485
|
+
cover * 100,
|
|
486
|
+
)}%です。部分吹抜けでは天井高を階高内に収めます (吹抜け部分の高さは導出)`,
|
|
487
|
+
{ path: [s.path] },
|
|
488
|
+
);
|
|
489
|
+
} else {
|
|
490
|
+
emit(
|
|
491
|
+
"HGT01",
|
|
492
|
+
`${s.path} が上階に食い込みます: 天井高${h} + ${lu.name}のslab${lu.slab} = ${h + lu.slab} > 階高${pitch}`,
|
|
493
|
+
{ path: [s.path] },
|
|
494
|
+
);
|
|
495
|
+
}
|
|
268
496
|
}
|
|
269
497
|
}
|
|
270
498
|
if (slabMissing) {
|
|
271
|
-
|
|
272
|
-
`レベル ${lu.name} に slab が未宣言のため、${lb.name} との高さ検査ができません`,
|
|
273
|
-
);
|
|
499
|
+
emit("HGT03", `レベル ${lu.name} に slab が未宣言のため、${lb.name} との高さ検査ができません`);
|
|
274
500
|
}
|
|
275
501
|
}
|
|
276
502
|
|
|
277
503
|
// レベルに載らない領域つき空間
|
|
278
504
|
for (const s of withRect) {
|
|
279
505
|
if (!s.level) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
506
|
+
emit("HGT05", `${s.path} は領域を持ちますが、レベルが特定できません (パス先頭か level: で指定します)`, {
|
|
507
|
+
line: s.line,
|
|
508
|
+
file: s.file,
|
|
509
|
+
path: [s.path],
|
|
510
|
+
});
|
|
283
511
|
}
|
|
284
512
|
}
|
|
285
513
|
|
|
286
|
-
|
|
514
|
+
// 敷地形状 (ADR-0011): 形の妥当性、対応ゾーンの存在、宣言面積との照合、建物のはみ出し検査。
|
|
515
|
+
// はみ出しは四隅の内包に加え、多角形の頂点の入り込みと辺の交差を見る — 凹敷地でも正しい (ADR-0013)。
|
|
516
|
+
// 地上の外部空間タイル (庭・通路) は近似なので検査しない — 面積の真は多角形が持つ
|
|
517
|
+
for (const poly of model.polygons.values()) {
|
|
518
|
+
for (let i = 0; i < poly.points.length; i++) {
|
|
519
|
+
const a = poly.points[i]!;
|
|
520
|
+
const b = poly.points[(i + 1) % poly.points.length]!;
|
|
521
|
+
if (Math.hypot(b.x - a.x, b.y - a.y) <= EPS_SITE) {
|
|
522
|
+
emit("SIT01", `敷地形状に重複する頂点があります (${Math.round(a.x)},${Math.round(a.y)})`, {
|
|
523
|
+
line: poly.line,
|
|
524
|
+
file: poly.file,
|
|
525
|
+
path: [poly.path],
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
const selfX = polygonSelfIntersection(poly.points);
|
|
530
|
+
if (selfX) {
|
|
531
|
+
emit("SIT02", `敷地形状が自己交差しています (${Math.round(selfX.x)},${Math.round(selfX.y)} 付近)`, {
|
|
532
|
+
line: poly.line,
|
|
533
|
+
file: poly.file,
|
|
534
|
+
path: [poly.path],
|
|
535
|
+
});
|
|
536
|
+
continue; // 不正な形に対する包含・面積は判定しない
|
|
537
|
+
}
|
|
538
|
+
const zone = model.zones.get(poly.path);
|
|
539
|
+
if (!zone) {
|
|
540
|
+
emit("SIT04", `polygon ${poly.path} に対応するゾーンがありません`, {
|
|
541
|
+
line: poly.line,
|
|
542
|
+
file: poly.file,
|
|
543
|
+
path: [poly.path],
|
|
544
|
+
});
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
if (zone.attrs["site"] !== 1) continue;
|
|
548
|
+
const declared = zone.attrs["area"];
|
|
549
|
+
if (typeof declared === "number") {
|
|
550
|
+
const derived = polygonAreaM2(poly.points);
|
|
551
|
+
if (Math.abs(declared - derived) >= 0.05) {
|
|
552
|
+
emit(
|
|
553
|
+
"SIT05",
|
|
554
|
+
`敷地面積の宣言と導出が食い違います: 宣言 ${declared}㎡ / 導出 ${derived.toFixed(2)}㎡`,
|
|
555
|
+
{ line: zone.line, file: zone.file, path: [zone.path] },
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
for (const s of withRect) {
|
|
560
|
+
if (s.type === "exterior" || s.path.startsWith(poly.path + "/")) continue;
|
|
561
|
+
for (const r of s.rects) {
|
|
562
|
+
const out = rectEscapesPolygon(r, poly.points, EPS_SITE);
|
|
563
|
+
if (out) {
|
|
564
|
+
emit("SIT03", `${s.path} が敷地形状からはみ出しています (${Math.round(out.x)},${Math.round(out.y)} 付近)`, {
|
|
565
|
+
line: s.line,
|
|
566
|
+
file: s.file,
|
|
567
|
+
path: [s.path],
|
|
568
|
+
});
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
return diags;
|
|
287
576
|
}
|
|
288
577
|
|
|
289
578
|
/** 吹抜けが下階の空間の平面をどれだけ覆うか (0..1) */
|