@kensnzk/koyu 0.11.0 → 0.14.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 +3 -3
- package/README.md +2 -2
- package/dist/axo.d.ts +16 -0
- package/dist/axo.d.ts.map +1 -0
- package/dist/axo.js +216 -0
- package/dist/axo.js.map +1 -0
- package/dist/check.d.ts +78 -3
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +578 -121
- package/dist/check.js.map +1 -1
- package/dist/cli.js +93 -2
- package/dist/cli.js.map +1 -1
- package/dist/diff.d.ts +15 -0
- package/dist/diff.d.ts.map +1 -1
- package/dist/diff.js +68 -7
- package/dist/diff.js.map +1 -1
- package/dist/fabric.d.ts +28 -0
- package/dist/fabric.d.ts.map +1 -0
- package/dist/fabric.js +105 -0
- package/dist/fabric.js.map +1 -0
- package/dist/graph.d.ts +40 -3
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +352 -53
- package/dist/graph.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/light.d.ts.map +1 -1
- package/dist/light.js +4 -6
- package/dist/light.js.map +1 -1
- package/dist/mcp.js +16 -9
- package/dist/mcp.js.map +1 -1
- package/dist/model.d.ts +123 -8
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +171 -68
- package/dist/model.js.map +1 -1
- package/dist/parse.d.ts.map +1 -1
- package/dist/parse.js +123 -5
- package/dist/parse.js.map +1 -1
- package/dist/plan.d.ts +2 -0
- package/dist/plan.d.ts.map +1 -1
- package/dist/plan.js +97 -10
- package/dist/plan.js.map +1 -1
- package/dist/poly.d.ts +78 -0
- package/dist/poly.d.ts.map +1 -0
- package/dist/poly.js +277 -0
- package/dist/poly.js.map +1 -0
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +5 -4
- package/dist/site.js.map +1 -1
- package/dist/vertical.d.ts +176 -0
- package/dist/vertical.d.ts.map +1 -0
- package/dist/vertical.js +669 -0
- package/dist/vertical.js.map +1 -0
- package/examples/basement/main.muro +86 -0
- package/examples/comparison/README.md +48 -0
- package/examples/complex/L1.muro +132 -0
- package/examples/complex/assets.muro +17 -0
- package/examples/complex/basement.muro +40 -0
- package/examples/complex/core.muro +40 -0
- package/examples/complex/hotel.muro +117 -0
- package/examples/complex/main.muro +67 -0
- package/examples/complex/office.muro +41 -0
- package/examples/complex/plant.muro +34 -0
- package/examples/complex/podium.muro +140 -0
- package/examples/complex/site.muro +18 -0
- package/examples/house/L1.muro +1 -1
- package/examples/house/L2.muro +1 -1
- package/examples/house/main.muro +1 -1
- package/examples/house.muro +3 -3
- package/examples/mansion.muro +18 -13
- package/examples/office.muro +1 -1
- package/examples/steps/04-exterior.muro +1 -1
- package/examples/steps/05-two-storeys.muro +2 -2
- package/examples/steps/06-finished.muro +3 -3
- package/examples/tower/L11.muro +4 -2
- package/examples/tower/L2.muro +2 -0
- package/examples/tower/L3.muro +3 -0
- package/examples/tower/assets.muro +1 -0
- package/examples/tower/main.muro +1 -1
- package/examples/tower/typical.muro +16 -9
- package/examples/twin/L1.muro +139 -0
- package/examples/twin/L5.muro +133 -0
- package/examples/twin/assets.muro +19 -0
- package/examples/twin/basement.muro +48 -0
- package/examples/twin/core.muro +75 -0
- package/examples/twin/hotel.muro +129 -0
- package/examples/twin/main.muro +96 -0
- package/examples/twin/office.muro +104 -0
- package/examples/twin/podium.muro +120 -0
- package/examples/twin/residence.muro +131 -0
- package/examples/twin/site.muro +29 -0
- package/examples/two-rooms.canonical.json +26 -2
- package/examples/two-rooms.muro +6 -3
- package/package.json +3 -2
- package/src/axo.ts +263 -0
- package/src/check.ts +680 -143
- package/src/cli.ts +100 -2
- package/src/diff.ts +75 -7
- package/src/fabric.ts +123 -0
- package/src/graph.ts +366 -56
- package/src/index.ts +24 -0
- package/src/light.ts +4 -7
- package/src/mcp.ts +17 -10
- package/src/model.ts +256 -66
- package/src/parse.ts +124 -5
- package/src/plan.ts +120 -11
- package/src/poly.ts +295 -0
- package/src/site.ts +6 -6
- package/src/vertical.ts +884 -0
package/src/check.ts
CHANGED
|
@@ -13,14 +13,24 @@ import {
|
|
|
13
13
|
placeOpening,
|
|
14
14
|
planOverlap,
|
|
15
15
|
segmentsFor,
|
|
16
|
+
segmentLength,
|
|
17
|
+
envelopeGaps,
|
|
18
|
+
drawnCut,
|
|
16
19
|
spacesOverlap,
|
|
17
20
|
} from "./graph.js";
|
|
18
|
-
import { heff, isSemiOutdoor, levelsSorted, type Attrs, type Boundary, type Model, type Space,
|
|
21
|
+
import { heff, isSemiOutdoor, levelsSorted, type Attrs, type Boundary, type Edge, type Level, type Model, type Pt, type Rect, type Space,
|
|
22
|
+
columnSites,
|
|
23
|
+
columnsFor,
|
|
24
|
+
pointInPolygon,
|
|
25
|
+
rectToPoly,
|
|
26
|
+
regionOf,
|
|
19
27
|
srcRef,
|
|
20
28
|
polygonAreaM2,
|
|
21
29
|
polygonSelfIntersection,
|
|
22
|
-
|
|
30
|
+
shapeEscapesPolygon,
|
|
23
31
|
} from "./model.js";
|
|
32
|
+
import { cutsInWindow } from "./poly.js";
|
|
33
|
+
import { runDecls, runIssues } from "./vertical.js";
|
|
24
34
|
|
|
25
35
|
export interface CheckResult {
|
|
26
36
|
errors: string[];
|
|
@@ -30,7 +40,7 @@ export interface CheckResult {
|
|
|
30
40
|
/** 構造化診断 (ADR-0016)。message は本文のみ — 位置接頭辞「file:N行目: 」を含まない */
|
|
31
41
|
export interface Diagnostic {
|
|
32
42
|
/** 台帳 DIAGNOSTIC_CODES のコード (領域2-3字 + 2桁連番) */
|
|
33
|
-
code:
|
|
43
|
+
code: DiagnosticCode;
|
|
34
44
|
severity: "error" | "warning";
|
|
35
45
|
/** 日本語の本文 (位置接頭辞なし) */
|
|
36
46
|
message: string;
|
|
@@ -49,7 +59,7 @@ export interface Diagnostic {
|
|
|
49
59
|
* BND07 は欠番 — 「接しているのに境界が無い」警告はADR-0014 (既定境界) で廃止された。
|
|
50
60
|
* SYN01 は構文・合成エラー (SourceError) の写し — checkは例外を診断にしない。CLIの check --json だけが写す。
|
|
51
61
|
*/
|
|
52
|
-
export const DIAGNOSTIC_CODES
|
|
62
|
+
export const DIAGNOSTIC_CODES = {
|
|
53
63
|
REF01: "error", // 境界が未定義の空間パスを参照
|
|
54
64
|
BND01: "error", // 同一空間同士の境界
|
|
55
65
|
BND02: "error", // 同一空間対の境界の重複 (edge限定まで同一 — ADR-0013)
|
|
@@ -97,16 +107,108 @@ export const DIAGNOSTIC_CODES: Record<string, "error" | "warning"> = {
|
|
|
97
107
|
UID01: "error", // 数字だけのuid (ADR-0015)
|
|
98
108
|
UID02: "error", // 空白を含むuid
|
|
99
109
|
UID03: "error", // uidの重複
|
|
110
|
+
ATT01: "error", // 解釈される属性の値が数値でない (ADR-0028)
|
|
111
|
+
ATT02: "error", // 解釈される属性の値が台帳の語彙にない (ADR-0028)
|
|
112
|
+
DAY01: "error", // daylightの値が 0/1 以外 (ADR-0020)
|
|
113
|
+
RUN01: "error", // 一つの空間に縦動線の宣言が複数 (ADR-0021)
|
|
114
|
+
RUN02: "error", // 縦動線の値が上る向き (N/E/S/W) でない
|
|
115
|
+
RUN03: "error", // 縦動線の領域が矩形一つでない / レベルが不明
|
|
116
|
+
RUN04: "warning", // 上にレベルが無く縦動線の形が生成できない
|
|
117
|
+
RUN05: "error", // form の値が不正、または形が決まらない
|
|
118
|
+
RUN06: "warning", // 導出された段の寸法が窮屈 (書かないが検査する)
|
|
119
|
+
RUN07: "warning", // 導出された勾配が宣言・常用域から外れる
|
|
120
|
+
RUN08: "warning", // 縦動線の形はあるが上下を繋ぐ垂直境界が無い
|
|
121
|
+
LIN01: "error", // 描かれた線が二つの空間を分離しない (ADR-0022)
|
|
122
|
+
LIN02: "error", // 垂直境界に描かれた線
|
|
123
|
+
LIN03: "warning", // 描かれた線が何も切っていない
|
|
124
|
+
ENV01: "warning", // 外皮に穴 — 何にも面していない外周 (ADR-0025)
|
|
125
|
+
COL01: "warning", // 柱の宣言に対して立つ柱が0本 (ADR-0023)
|
|
126
|
+
COL02: "warning", // 同じ通りの交点に複数の柱宣言が重なる (先の宣言が勝つ)
|
|
100
127
|
VER01: "error", // koyu 0.1 での既定境界の導出 (ADR-0017)
|
|
128
|
+
VER02: "error", // koyu 0.3以前で採光の推定対象だった型に daylight が無い (ADR-0020)
|
|
129
|
+
VER03: "error", // koyu 0.4以前のファイルに0.5の語 (縦動線・線・柱・地下)
|
|
101
130
|
SYN01: "error", // 構文・合成エラー (SourceError の写し — check --json のみ)
|
|
102
|
-
}
|
|
131
|
+
} as const satisfies Record<string, "error" | "warning">;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* 診断コードの型 (ADR-0016)。台帳が唯一の出所であり、**登録していないコードは型が通らない**。
|
|
135
|
+
* 以前は Record<string, ...> だったので、台帳に無いコードを emit すると severity が
|
|
136
|
+
* undefined になり、error が黙って warning に落ち、--strict でも終了コード0になった。
|
|
137
|
+
* 「忘れる自由は無い」という契約を、文ではなく型が守る。
|
|
138
|
+
*/
|
|
139
|
+
export type DiagnosticCode = keyof typeof DIAGNOSTIC_CODES;
|
|
103
140
|
|
|
104
141
|
const EPS = 0.5;
|
|
105
142
|
/** 敷地まわりの幾何の許容 (境界上は内側扱い) — ADR-0011の1mm */
|
|
106
143
|
const EPS_SITE = 1;
|
|
107
144
|
const VERTICAL = new Set(["stair", "shaft", "void"]);
|
|
145
|
+
/** 0.3以前が採光の対象と推定していた型 (ADR-0020で廃止)。旧版の受理条件の判定にだけ使う — 意味論には効かない */
|
|
146
|
+
const LEGACY_DAYLIT = new Set(["unit", "room", "ldk", "bedroom", "living"]);
|
|
108
147
|
|
|
109
148
|
/** 互換層 — 従来の文字列形式。位置を持つ診断は「file:N行目: 本文」に組み立てる */
|
|
149
|
+
/**
|
|
150
|
+
* 解釈される属性の値の台帳 (ADR-0028)。**spec/vocabulary.md の★が契約であり、これはその写しである。**
|
|
151
|
+
*
|
|
152
|
+
* `of` があれば列挙、無ければ正の数値。ここに無い属性は自由に書けてそのまま運ばれる
|
|
153
|
+
* (台帳の規則3)。daylight は DAY01 が、form は RUN05 が、縦動線の向きは RUN02 が
|
|
154
|
+
* 既に守っているので重ねない。
|
|
155
|
+
*/
|
|
156
|
+
const ATTR_RULES: Record<string, Record<string, { of?: Array<string | number> }>> = {
|
|
157
|
+
space: {
|
|
158
|
+
h: {},
|
|
159
|
+
ceiling: { of: [0, 1] },
|
|
160
|
+
turn: { of: ["R", "L"] },
|
|
161
|
+
riser: {},
|
|
162
|
+
tread: {},
|
|
163
|
+
entry: {},
|
|
164
|
+
landing: {},
|
|
165
|
+
lane: {},
|
|
166
|
+
slope: {},
|
|
167
|
+
road: {},
|
|
168
|
+
},
|
|
169
|
+
zone: { site: { of: [0, 1] }, area: {} },
|
|
170
|
+
// air:1 の境界の天端高 (手すり・腰壁) — 立体が読むので台帳に載る (ADR-0028)
|
|
171
|
+
boundary: { h: {} },
|
|
172
|
+
opening: { style: { of: ["hinged", "sliding", "auto"] } },
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
interface AttrSubject {
|
|
176
|
+
rules: Record<string, { of?: Array<string | number> }>;
|
|
177
|
+
of: Attrs;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** 値を検査すべき宣言を、出所つきで数え上げる — 母集団は**書かれた宣言**である */
|
|
181
|
+
function attrSubjects(
|
|
182
|
+
model: Model,
|
|
183
|
+
): Array<[string, AttrSubject, { line?: number; file?: string; path?: string[] }]> {
|
|
184
|
+
const out: Array<[string, AttrSubject, { line?: number; file?: string; path?: string[] }]> = [];
|
|
185
|
+
for (const s of model.spaces.values()) {
|
|
186
|
+
out.push([s.path, { rules: ATTR_RULES["space"]!, of: s.attrs }, { line: s.line, file: s.file, path: [s.path] }]);
|
|
187
|
+
}
|
|
188
|
+
for (const z of model.zones.values()) {
|
|
189
|
+
out.push([`ゾーン ${z.path}`, { rules: ATTR_RULES["zone"]!, of: z.attrs }, { line: z.line, file: z.file, path: [z.path] }]);
|
|
190
|
+
}
|
|
191
|
+
for (const b of model.boundaries) {
|
|
192
|
+
const at = { line: b.line, file: b.file, path: [b.a, b.b] };
|
|
193
|
+
out.push([`境界 ${b.a} | ${b.b}`, { rules: ATTR_RULES["boundary"]!, of: b.attrs }, at]);
|
|
194
|
+
for (const o of b.openings) {
|
|
195
|
+
out.push([
|
|
196
|
+
`${o.kind} (${b.a} | ${b.b})`,
|
|
197
|
+
{ rules: ATTR_RULES["opening"]!, of: o.attrs },
|
|
198
|
+
{ line: o.line, file: b.file, path: [b.a, b.b] },
|
|
199
|
+
]);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return out;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** 書かれた通り語で矩形を名指す — 「どの組が重なっているか」を言えるようにする */
|
|
206
|
+
function gridRefText(s: Space, i: number): string {
|
|
207
|
+
const g = s.grids[i];
|
|
208
|
+
if (!g) return `#${i + 1}`;
|
|
209
|
+
return `${g.xa}..${g.xb} ${g.ya}..${g.yb}`;
|
|
210
|
+
}
|
|
211
|
+
|
|
110
212
|
export function check(model: Model): CheckResult {
|
|
111
213
|
const errors: string[] = [];
|
|
112
214
|
const warnings: string[] = [];
|
|
@@ -117,11 +219,40 @@ export function check(model: Model): CheckResult {
|
|
|
117
219
|
return { errors, warnings };
|
|
118
220
|
}
|
|
119
221
|
|
|
222
|
+
/**
|
|
223
|
+
* 節が共有する文脈。**節をまたいで読まれる値だけ**がここに載る —
|
|
224
|
+
* seenBoundary・pairEdges・siteZones・envelopedLevels・stood・uidOwners・
|
|
225
|
+
* voidPartners・byLevel はどれも一つの節の内側で閉じているので、載せない。
|
|
226
|
+
*/
|
|
227
|
+
/** 診断の出所 (境界に対する診断が共有する) */
|
|
228
|
+
type At = { line?: number; file?: string; path?: string[]; related?: Array<{ line: number; file?: string }> };
|
|
229
|
+
|
|
230
|
+
interface Ctx {
|
|
231
|
+
model: Model;
|
|
232
|
+
emit: (
|
|
233
|
+
code: DiagnosticCode,
|
|
234
|
+
message: string,
|
|
235
|
+
at?: {
|
|
236
|
+
line?: number;
|
|
237
|
+
file?: string;
|
|
238
|
+
path?: string[];
|
|
239
|
+
related?: Array<{ line: number; file?: string }>;
|
|
240
|
+
},
|
|
241
|
+
) => void;
|
|
242
|
+
loc: (line: number, file?: string) => { line: number; file?: string };
|
|
243
|
+
/** 領域を持つ空間 (7つの節が読む) */
|
|
244
|
+
withRect: Space[];
|
|
245
|
+
/** z昇順のレベル */
|
|
246
|
+
levels: Level[];
|
|
247
|
+
/** レベル名 → z昇順の添字 (境界の妥当性と高さの節が読む) */
|
|
248
|
+
levelIndex: Map<string, number>;
|
|
249
|
+
}
|
|
250
|
+
|
|
120
251
|
export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
121
252
|
const diags: Diagnostic[] = [];
|
|
122
253
|
/** line:0 は「位置なし」— フィールドごと省略する (既定境界などの導出物) */
|
|
123
254
|
const emit = (
|
|
124
|
-
code:
|
|
255
|
+
code: DiagnosticCode,
|
|
125
256
|
message: string,
|
|
126
257
|
at: {
|
|
127
258
|
line?: number;
|
|
@@ -132,7 +263,7 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
132
263
|
) => {
|
|
133
264
|
diags.push({
|
|
134
265
|
code,
|
|
135
|
-
severity: DIAGNOSTIC_CODES[code]
|
|
266
|
+
severity: DIAGNOSTIC_CODES[code],
|
|
136
267
|
message,
|
|
137
268
|
...(at.line ? { line: at.line } : {}),
|
|
138
269
|
...(at.line && at.file !== undefined ? { file: at.file } : {}),
|
|
@@ -145,6 +276,57 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
145
276
|
...(file !== undefined ? { file } : {}),
|
|
146
277
|
});
|
|
147
278
|
|
|
279
|
+
|
|
280
|
+
const withRect = [...model.spaces.values()].filter((s) => s.rects.length > 0);
|
|
281
|
+
const levels = levelsSorted(model);
|
|
282
|
+
const levelIndex = new Map(levels.map((l, i) => [l.name, i]));
|
|
283
|
+
const ctx: Ctx = { model, emit, loc, withRect, levels, levelIndex };
|
|
284
|
+
|
|
285
|
+
// **節の順序が出力の順序である。**互換層は診断を出た順に文字列へ写すので、
|
|
286
|
+
// ここの並びを入れ替えると check の出力が変わる (test/diagnostics.test.ts が固定している)。
|
|
287
|
+
// 節の粒度は「走査単位」であって「診断コードの族」ではない — 一つのループが
|
|
288
|
+
// 複数のコードを出すとき、それらは走査の順に交互に出る。族で割ると並びが崩れる
|
|
289
|
+
checkBoundaryRefs(ctx);
|
|
290
|
+
checkBoundaryIdentity(ctx);
|
|
291
|
+
checkLevelDepth(ctx);
|
|
292
|
+
checkSelfOverlap(ctx);
|
|
293
|
+
checkSpaceOverlap(ctx);
|
|
294
|
+
checkDaylightScope(ctx);
|
|
295
|
+
checkAttrValues(ctx);
|
|
296
|
+
checkRuns(ctx);
|
|
297
|
+
checkDrawnLines(ctx);
|
|
298
|
+
checkEnvelopeGaps(ctx);
|
|
299
|
+
checkColumns(ctx);
|
|
300
|
+
checkLanguageVersion(ctx);
|
|
301
|
+
checkUids(ctx);
|
|
302
|
+
checkBoundaryValidity(ctx);
|
|
303
|
+
checkAreas(ctx);
|
|
304
|
+
checkZones(ctx);
|
|
305
|
+
checkHeights(ctx);
|
|
306
|
+
checkOrphanSpaces(ctx);
|
|
307
|
+
checkSite(ctx);
|
|
308
|
+
return diags;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
/** 吹抜けが下階の空間の平面をどれだけ覆うか (0..1) */
|
|
313
|
+
function voidCoverage(s: Space, partners: Space[]): number {
|
|
314
|
+
let inter = 0;
|
|
315
|
+
for (const r of s.rects) {
|
|
316
|
+
for (const p of partners) {
|
|
317
|
+
for (const pr of p.rects) {
|
|
318
|
+
const o = planOverlap(r, pr);
|
|
319
|
+
if (o) inter += (o.x2 - o.x1) * (o.y2 - o.y1);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const area = s.rects.reduce((sum, r) => sum + (r.x2 - r.x1) * (r.y2 - r.y1), 0);
|
|
324
|
+
return area > 0 ? inter / area : 0;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/** 境界の参照先 — REF01 / BND01 */
|
|
328
|
+
function checkBoundaryRefs(ctx: Ctx): void {
|
|
329
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
148
330
|
// 境界の参照先
|
|
149
331
|
for (const b of model.boundaries) {
|
|
150
332
|
for (const p of [b.a, b.b]) {
|
|
@@ -156,14 +338,20 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
156
338
|
emit("BND01", `同じ空間同士の境界は書けません: ${b.a}`, { line: b.line, file: b.file, path: [b.a, b.b] });
|
|
157
339
|
}
|
|
158
340
|
}
|
|
341
|
+
}
|
|
159
342
|
|
|
343
|
+
/** 境界の同一性 — BND02 / BND05 */
|
|
344
|
+
function checkBoundaryIdentity(ctx: Ctx): void {
|
|
345
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
160
346
|
// 境界の同一性: 同じ空間対 (edge限定まで同一) の重複宣言は矛盾の温床 — エラー (ADR-0013)。
|
|
161
347
|
// wall/openの食い違いもこの検査が捕まえる。edge限定の有無が混在する対は線分が重なるため警告
|
|
162
348
|
const seenBoundary = new Map<string, Boundary>();
|
|
163
349
|
const pairEdges = new Map<string, Set<string>>();
|
|
164
350
|
for (const b of model.boundaries) {
|
|
165
351
|
const pair = [b.a, b.b].sort().join(" | ");
|
|
166
|
-
|
|
352
|
+
// 描かれた線を持つ境界は、線そのものが実現なので同一性の鍵に線の綴りが入る。
|
|
353
|
+
// 同じ空間対に二本の線 (二箇所の隅切りなど) を引くのは矛盾ではない
|
|
354
|
+
const key = `${pair}#${b.edge ?? ""}#${b.drawn ? `${b.drawn.aRef}..${b.drawn.bRef}` : ""}`;
|
|
167
355
|
const prev = seenBoundary.get(key);
|
|
168
356
|
if (prev) {
|
|
169
357
|
emit(
|
|
@@ -174,39 +362,66 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
174
362
|
} else {
|
|
175
363
|
seenBoundary.set(key, b);
|
|
176
364
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
365
|
+
// 線を持つ境界は外周の残りを取らない (線が線分そのもの) ので、edge の混在の話に入れない
|
|
366
|
+
if (!b.drawn) {
|
|
367
|
+
const set = pairEdges.get(pair) ?? new Set<string>();
|
|
368
|
+
set.add(b.edge ?? "");
|
|
369
|
+
pairEdges.set(pair, set);
|
|
370
|
+
}
|
|
180
371
|
}
|
|
181
372
|
for (const [pair, edges] of pairEdges) {
|
|
182
373
|
if (edges.has("") && edges.size > 1) {
|
|
374
|
+
// 集合に対する診断でも、集合を作った宣言の行は必ず指す —
|
|
375
|
+
// 「どこかで併存している」だけでは直す場所が無い
|
|
376
|
+
const members = model.boundaries.filter((b) => !b.drawn && [b.a, b.b].sort().join(" | ") === pair);
|
|
377
|
+
const first = members.find((b) => !b.edge) ?? members[0];
|
|
183
378
|
emit("BND05", `同じ空間対に edge 限定つきと無しの境界が併存しています (線分が重なります): ${pair}`, {
|
|
379
|
+
...(first ? { line: first.line, file: first.file } : {}),
|
|
184
380
|
path: pair.split(" | "),
|
|
381
|
+
related: members.filter((b) => b !== first).map((b) => loc(b.line, b.file)),
|
|
185
382
|
});
|
|
186
383
|
}
|
|
187
384
|
}
|
|
385
|
+
}
|
|
188
386
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
387
|
+
/** レベルの重複 — LVL01 */
|
|
388
|
+
function checkLevelDepth(ctx: Ctx): void {
|
|
389
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
192
390
|
// レベルの重複
|
|
193
391
|
for (let i = 1; i < levels.length; i++) {
|
|
194
392
|
if (Math.abs(levels[i]!.z - levels[i - 1]!.z) < EPS) {
|
|
195
|
-
emit("LVL01", `レベル ${levels[i - 1]!.name} と ${levels[i]!.name} のz
|
|
393
|
+
emit("LVL01", `レベル ${levels[i - 1]!.name} と ${levels[i]!.name} のzが同じです`, {
|
|
394
|
+
line: levels[i]!.line,
|
|
395
|
+
file: levels[i]!.file,
|
|
396
|
+
related: [loc(levels[i - 1]!.line, levels[i - 1]!.file)],
|
|
397
|
+
});
|
|
196
398
|
}
|
|
197
399
|
}
|
|
400
|
+
}
|
|
198
401
|
|
|
402
|
+
/** 自らの領域の重なり — GEO01 */
|
|
403
|
+
function checkSelfOverlap(ctx: Ctx): void {
|
|
404
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
199
405
|
// 自らの領域 (合併の矩形同士) の重なり
|
|
200
406
|
for (const s of withRect) {
|
|
201
407
|
for (let i = 0; i < s.rects.length; i++) {
|
|
202
408
|
for (let j = i + 1; j < s.rects.length; j++) {
|
|
203
409
|
if (planOverlap(s.rects[i]!, s.rects[j]!)) {
|
|
204
|
-
|
|
410
|
+
// どの組かを言わなければ、三つ重なる空間にバイト同一の診断が三件並ぶ
|
|
411
|
+
emit("GEO01", `${s.path} の領域同士が重なっています: ${gridRefText(s, i)} と ${gridRefText(s, j)}`, {
|
|
412
|
+
line: s.line,
|
|
413
|
+
file: s.file,
|
|
414
|
+
path: [s.path],
|
|
415
|
+
});
|
|
205
416
|
}
|
|
206
417
|
}
|
|
207
418
|
}
|
|
208
419
|
}
|
|
420
|
+
}
|
|
209
421
|
|
|
422
|
+
/** 空間同士の重なり — GEO02 */
|
|
423
|
+
function checkSpaceOverlap(ctx: Ctx): void {
|
|
424
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
210
425
|
// 同一レベルでの空間同士の重なり
|
|
211
426
|
for (let i = 0; i < withRect.length; i++) {
|
|
212
427
|
for (let j = i + 1; j < withRect.length; j++) {
|
|
@@ -215,14 +430,205 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
215
430
|
if (a.level !== b.level) continue;
|
|
216
431
|
if (spacesOverlap(a, b)) {
|
|
217
432
|
emit("GEO02", `空間の領域が重なっています: ${a.path} と ${b.path}`, {
|
|
433
|
+
line: a.line,
|
|
434
|
+
file: a.file,
|
|
218
435
|
path: [a.path, b.path],
|
|
219
436
|
related: [loc(b.line, b.file)],
|
|
220
437
|
});
|
|
221
438
|
}
|
|
222
439
|
}
|
|
223
440
|
}
|
|
441
|
+
}
|
|
224
442
|
|
|
225
|
-
|
|
443
|
+
/** 採光の対象の宣言 — DAY01 */
|
|
444
|
+
function checkDaylightScope(ctx: Ctx): void {
|
|
445
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
446
|
+
// 採光の対象の宣言 (ADR-0020): daylight は「この室に 1/7 の判定を掛ける」という二値の宣言。
|
|
447
|
+
// 綴りの揺れ (daylight:true / daylight:yes) が黙って対象外に落ちるのを防ぐ
|
|
448
|
+
for (const s of model.spaces.values()) {
|
|
449
|
+
const v = s.attrs["daylight"];
|
|
450
|
+
if (v === undefined) continue;
|
|
451
|
+
if (v !== 0 && v !== 1) {
|
|
452
|
+
emit("DAY01", `daylight は 1 (採光判定の対象) か 0 (対象外) です: ${s.path} に daylight:${v}`, {
|
|
453
|
+
line: s.line,
|
|
454
|
+
file: s.file,
|
|
455
|
+
path: [s.path],
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/** 解釈される属性の値 — ATT01 / ATT02 */
|
|
462
|
+
function checkAttrValues(ctx: Ctx): void {
|
|
463
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
464
|
+
// 解釈される属性の値 (ADR-0028): **書いたのに解釈されなかった値は、黙って既定へ落とさない。**
|
|
465
|
+
//
|
|
466
|
+
// daylight だけが DAY01 で守られていて、他の★属性は素通りだった。帰結は黙殺である —
|
|
467
|
+
// `site:yes` は敷地の検査 (SIT03 error) を丸ごと無効にし、`h:35OO` は高さ不変量
|
|
468
|
+
// (HGT01 error) を消し、`ceiling:none` は天井を張り、`turn:l` は階段を鏡像にする。
|
|
469
|
+
// どれも check は緑のままだった。台帳 (spec/vocabulary.md) が契約である以上、
|
|
470
|
+
// 台帳の型に合わない値はエラーである。
|
|
471
|
+
for (const [where, attrs, at] of attrSubjects(model)) {
|
|
472
|
+
for (const [key, rule] of Object.entries(attrs.rules)) {
|
|
473
|
+
const v = attrs.of[key];
|
|
474
|
+
if (v === undefined) continue;
|
|
475
|
+
if (rule.of) {
|
|
476
|
+
if (!rule.of.includes(v as string | number)) {
|
|
477
|
+
emit("ATT02", `${where} の ${key} は ${rule.of.join(" / ")} のどれかです: ${key}:${v}`, at);
|
|
478
|
+
}
|
|
479
|
+
} else if (typeof v !== "number" || !(v > 0)) {
|
|
480
|
+
emit("ATT01", `${where} の ${key} は正の数値で書きます: ${key}:${v}`, at);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/** 縦動線 — RUN01〜RUN08 */
|
|
487
|
+
function checkRuns(ctx: Ctx): void {
|
|
488
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
489
|
+
// 縦動線 (ADR-0021): 宣言の妥当性と、**書かれていない導出値**の妥当性。
|
|
490
|
+
// 段数も踏面も勾配も書かない — だから導出したものを検査する
|
|
491
|
+
for (const i of runIssues(model)) {
|
|
492
|
+
emit(i.code, i.message, { line: i.line, file: i.file, path: [i.path] });
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/** 描かれた線 — LIN01〜LIN03 */
|
|
497
|
+
function checkDrawnLines(ctx: Ctx): void {
|
|
498
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
499
|
+
// 描かれた線 (ADR-0022): 線は二つの空間を実際に分離しなければならない。
|
|
500
|
+
// 「宣言どおりに切れているか」は arrangement の検査であり、check の仕事
|
|
501
|
+
for (const b of model.boundaries) {
|
|
502
|
+
if (!b.drawn) continue;
|
|
503
|
+
const bAt = { line: b.drawn.line, file: b.file, path: [b.a, b.b] };
|
|
504
|
+
if (VERTICAL.has(b.kind)) {
|
|
505
|
+
emit("LIN02", `垂直境界に線は描けません (線は平面を区切る行為です): ${b.a} | ${b.b}`, bAt);
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
508
|
+
const sa = model.spaces.get(b.a);
|
|
509
|
+
const sb = model.spaces.get(b.b);
|
|
510
|
+
if (!sa || !sb) continue;
|
|
511
|
+
if (sa.rects.length === 0 && sb.rects.length === 0) {
|
|
512
|
+
emit("LIN01", `領域を持たない空間同士に線は描けません: ${b.a} | ${b.b}`, bAt);
|
|
513
|
+
continue;
|
|
514
|
+
}
|
|
515
|
+
// 判定と操作を同じ関数に通す (ADR-0027)。窓の中で分離が決まらなければ LIN01、
|
|
516
|
+
// 決まるが実際には何も切っていなければ LIN03。以前は判定だけが別の窓 (線分の
|
|
517
|
+
// 外接矩形) を使っていたので、軸平行の線では窓が潰れて必ず誤報していた
|
|
518
|
+
const cut = drawnCut(sa, sb, b.drawn.a, b.drawn.b);
|
|
519
|
+
if (!cut) {
|
|
520
|
+
emit(
|
|
521
|
+
"LIN01",
|
|
522
|
+
sa.rects.length > 0 && sb.rects.length > 0
|
|
523
|
+
? `線 ${b.drawn.aRef}..${b.drawn.bRef} は ${b.a} と ${b.b} を分離していません (二つの割付が線の両側に来るように引きます)`
|
|
524
|
+
: `線 ${b.drawn.aRef}..${b.drawn.bRef} が割付をちょうど二等分していて、どちらを残すか決まりません`,
|
|
525
|
+
bAt,
|
|
526
|
+
);
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
const target = cut.solo ? [cut.solo] : [sa, sb];
|
|
530
|
+
if (!target.some((s) => cutsInWindow(s.rects.map(rectToPoly), cut.window, b.drawn!.a, b.drawn!.b))) {
|
|
531
|
+
emit(
|
|
532
|
+
"LIN03",
|
|
533
|
+
`線 ${b.drawn.aRef}..${b.drawn.bRef} は何も切っていません (既定の隣接線と同じか、割付の外にあります)`,
|
|
534
|
+
bAt,
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/** 外皮の穴 — ENV01 */
|
|
541
|
+
function checkEnvelopeGaps(ctx: Ctx): void {
|
|
542
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
543
|
+
// 外皮の穴 (ADR-0025): 既定境界は領域を持たない空間との間には導かれない (ADR-0014) ので、
|
|
544
|
+
// 外部への境界の書き忘れは黙って壁の不在になる。導出された外周のうち、
|
|
545
|
+
// 他の空間とも宣言された境界とも向かい合っていない区間を数える。
|
|
546
|
+
// 外構のタイル (site:1 ゾーンの配下)・外部・半屋外は囲われていないのが正常なので数えない。
|
|
547
|
+
// そして**外皮を書き始めているレベルだけ**を見る — 外部への境界が一本も無い階は
|
|
548
|
+
// 外皮をまだ模型にしていないだけであって、穴が開いているのではない。
|
|
549
|
+
// 「書き始めたなら閉じきる」という整合の検査であって、完全性の要求ではない
|
|
550
|
+
const siteZones = [...model.zones.values()].filter((z) => z.attrs["site"] === 1).map((z) => z.path);
|
|
551
|
+
const envelopedLevels = new Set<string>();
|
|
552
|
+
for (const b of model.boundaries) {
|
|
553
|
+
if (b.derived || VERTICAL.has(b.kind)) continue;
|
|
554
|
+
const sa = model.spaces.get(b.a);
|
|
555
|
+
const sb = model.spaces.get(b.b);
|
|
556
|
+
if (!sa || !sb) continue;
|
|
557
|
+
const outer = sa.rects.length === 0 ? sb : sb.rects.length === 0 ? sa : undefined;
|
|
558
|
+
if (outer?.level) envelopedLevels.add(outer.level);
|
|
559
|
+
}
|
|
560
|
+
for (const s of withRect) {
|
|
561
|
+
if (!s.level || !envelopedLevels.has(s.level)) continue;
|
|
562
|
+
if (s.type === "exterior" || isSemiOutdoor(model, s)) continue;
|
|
563
|
+
if (siteZones.some((z) => s.path.startsWith(z + "/"))) continue;
|
|
564
|
+
const gaps = envelopeGaps(model, s);
|
|
565
|
+
if (gaps.length === 0) continue;
|
|
566
|
+
// **どの辺かを言う。**合計長だけでは、edge を書き分けている図面で直す辺が特定できない。
|
|
567
|
+
// envelopeGaps は座標つきの線分を返しているので、方角は既に手元にある
|
|
568
|
+
const byDir = new Map<string, number>();
|
|
569
|
+
for (const g of gaps) {
|
|
570
|
+
const d = g.edgeOfA ?? (g.horizontal ? "N/S" : "E/W");
|
|
571
|
+
byDir.set(d, (byDir.get(d) ?? 0) + segmentLength(g));
|
|
572
|
+
}
|
|
573
|
+
const total = gaps.reduce((a, g) => a + segmentLength(g), 0);
|
|
574
|
+
const where = [...byDir].map(([d, mm]) => `${d} ${Math.round(mm)}mm`).join(" / ");
|
|
575
|
+
emit(
|
|
576
|
+
"ENV01",
|
|
577
|
+
`外皮に面していない外周があります: ${s.path} — ${where} (合計 ${Math.round(total)}mm・${gaps.length}区間)。外部への境界を書きます`,
|
|
578
|
+
{ line: s.line, file: s.file, path: [s.path] },
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/** 柱 — COL01 / COL02 */
|
|
584
|
+
function checkColumns(ctx: Ctx): void {
|
|
585
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
586
|
+
// 柱 (ADR-0023): 位置は書かれない。宣言に対して一本も立たなければ、
|
|
587
|
+
// 通りか階の指定が実際の床とすれ違っている
|
|
588
|
+
//
|
|
589
|
+
// **母集団は宣言である。**「このレベルに何本立ったか」ではなく「この宣言から何本立ったか」を
|
|
590
|
+
// 問う。前者を数えると、同じ階の別の宣言が一本でも立てた瞬間に、一本も立たない宣言が
|
|
591
|
+
// 黙って通る (ADR-0028)。Column.decl がその帰属を持つ。
|
|
592
|
+
const stood = new Map<number, number>();
|
|
593
|
+
const levelsOfDecl = new Set<string>();
|
|
594
|
+
for (const c of model.columns) for (const lv of c.levels) levelsOfDecl.add(lv);
|
|
595
|
+
for (const lv of levelsOfDecl) {
|
|
596
|
+
for (const col of columnsFor(model, lv)) stood.set(col.decl, (stood.get(col.decl) ?? 0) + 1);
|
|
597
|
+
}
|
|
598
|
+
for (let ci = 0; ci < model.columns.length; ci++) {
|
|
599
|
+
const c = model.columns[ci]!;
|
|
600
|
+
if ((stood.get(ci) ?? 0) > 0) continue;
|
|
601
|
+
const at = { line: c.line, file: c.file };
|
|
602
|
+
// 一本も立たない理由は二つある。**狙う交点に床が無い**か、床はあるが先の宣言に
|
|
603
|
+
// 取られたか。後者を「床がありません」と言うと、直しようのない場所へ人を送る
|
|
604
|
+
const sites = new Set(c.levels.flatMap((lv) => columnSites(model, c, lv).map((p) => `${lv}|${p.grid}`)));
|
|
605
|
+
if (sites.size > 0) {
|
|
606
|
+
// 影を作ったのは、この宣言と同じ交点に**実際に立った**先の宣言だけである
|
|
607
|
+
const shadow = model.columns.filter((o, oi) => {
|
|
608
|
+
if (oi >= ci) return false;
|
|
609
|
+
return o.levels.some((lv) =>
|
|
610
|
+
columnsFor(model, lv).some((k) => k.decl === oi && sites.has(`${lv}|${k.grid}`)),
|
|
611
|
+
);
|
|
612
|
+
});
|
|
613
|
+
emit(
|
|
614
|
+
"COL02",
|
|
615
|
+
`この柱の宣言 (${c.levels.join(",")} ${c.size}角) は同じ交点を先の宣言に取られていて、一本も立ちません (同じ交点では先の宣言が勝ちます)`,
|
|
616
|
+
{ ...at, related: shadow.map((o) => loc(o.line, o.file)) },
|
|
617
|
+
);
|
|
618
|
+
} else {
|
|
619
|
+
emit(
|
|
620
|
+
"COL01",
|
|
621
|
+
`柱の宣言に対して立つ柱がありません (通りの交点に床がありません): ${c.levels.join(",")} ${c.size}角`,
|
|
622
|
+
at,
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/** 言語版の受理条件 — VER01〜VER03 */
|
|
629
|
+
function checkLanguageVersion(ctx: Ctx): void {
|
|
630
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
631
|
+
// 言語版の受理条件 (ADR-0017): 旧版は意味保存の場合のみ受理する。
|
|
226
632
|
// 既定境界 (ADR-0014) が導出されるファイルは、0.1の意味 (境界なし+警告) と食い違う — エラーで二択を示す
|
|
227
633
|
if (model.version === "0.1") {
|
|
228
634
|
for (const b of model.boundaries) {
|
|
@@ -236,6 +642,59 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
236
642
|
}
|
|
237
643
|
}
|
|
238
644
|
|
|
645
|
+
// 0.3以前は型から採光の対象を推定していた (ADR-0020で廃止)。推定対象だった型の空間に daylight が
|
|
646
|
+
// 書かれていなければ、0.4では判定から黙って外れる — 意味が変わるのでエラーで二択を示す
|
|
647
|
+
if (["0.1", "0.2", "0.3"].includes(model.version)) {
|
|
648
|
+
for (const s of model.spaces.values()) {
|
|
649
|
+
if (!LEGACY_DAYLIT.has(s.type) || s.attrs["daylight"] !== undefined) continue;
|
|
650
|
+
emit(
|
|
651
|
+
"VER02",
|
|
652
|
+
`koyu ${model.version} のファイルに daylight の無い ${s.type} があります: ${s.path} — 0.4では型から採光の対象を推定しないので判定から外れます。daylight:1 (対象) か daylight:0 (対象外) を書いてから koyu 0.4 へ上げます`,
|
|
653
|
+
{ line: s.line, file: s.file, path: [s.path] },
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// 0.5 で入った語 (縦動線の宣言・描かれた線・柱・地下) は 0.4 以前の処理系が知らない。
|
|
659
|
+
// 知らない処理系では黙って形が生成されないので、版を上げずに使うのはエラー (ADR-0017 決定3)
|
|
660
|
+
if (model.version !== "0.5") {
|
|
661
|
+
const older = `koyu ${model.version} のファイルに 0.5 の語があります`;
|
|
662
|
+
for (const s of model.spaces.values()) {
|
|
663
|
+
const d = runDecls(s);
|
|
664
|
+
if (d.length > 0) {
|
|
665
|
+
emit("VER03", `${older}: ${s.path} の ${d[0]!.device}: (縦動線) — koyu 0.5 へ上げます`, {
|
|
666
|
+
line: s.line,
|
|
667
|
+
file: s.file,
|
|
668
|
+
path: [s.path],
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
for (const b of model.boundaries) {
|
|
673
|
+
if (b.drawn) {
|
|
674
|
+
emit("VER03", `${older}: ${b.a} | ${b.b} の line (描かれた線) — koyu 0.5 へ上げます`, {
|
|
675
|
+
line: b.drawn.line,
|
|
676
|
+
file: b.file,
|
|
677
|
+
path: [b.a, b.b],
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
for (const c of model.columns) {
|
|
682
|
+
emit("VER03", `${older}: column (柱) — koyu 0.5 へ上げます`, { line: c.line, file: c.file });
|
|
683
|
+
}
|
|
684
|
+
for (const l of Object.values(model.levels)) {
|
|
685
|
+
if (l.underground) {
|
|
686
|
+
emit("VER03", `${older}: level ${l.name} の underground: — koyu 0.5 へ上げます`, {
|
|
687
|
+
line: l.line,
|
|
688
|
+
file: l.file,
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/** uid — UID01〜UID03 */
|
|
696
|
+
function checkUids(ctx: Ctx): void {
|
|
697
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
239
698
|
// uid (ADR-0015): 不透明トークン、space/zone横断でモデル全体一意。
|
|
240
699
|
// 数字だけの形は禁じる — parseの数値化で 0123 が 123 になり、書いたトークンの区別が失われる
|
|
241
700
|
const uidOwners = new Map<string, Array<{ kind: string; path: string; line: number; file?: string }>>();
|
|
@@ -269,126 +728,193 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
269
728
|
);
|
|
270
729
|
}
|
|
271
730
|
}
|
|
731
|
+
}
|
|
272
732
|
|
|
273
|
-
|
|
274
|
-
|
|
733
|
+
/** 境界の妥当性 — VRT / BND03〜06 / OPN / SEG */
|
|
734
|
+
function checkBoundaryValidity(ctx: Ctx): void {
|
|
735
|
+
const { model, emit } = ctx;
|
|
736
|
+
// 境界の妥当性。**一本のループを保つ** — 一つの境界が出す複数のコードは
|
|
737
|
+
// 走査の順に固まって出るので、コードの族で節に割ると並びが崩れる (ADR-0028)。
|
|
738
|
+
// ループの `continue` は「この境界の残りを飛ばす」を意味するので、
|
|
739
|
+
// 段に切り出すときは**呼び出し側の continue として残す** — 判定の綴りを
|
|
740
|
+
// ヘルパの中へ持ち込むと、同じ条件が二箇所に分かれて片方だけ直る
|
|
275
741
|
for (const b of model.boundaries) {
|
|
276
742
|
const sa = model.spaces.get(b.a);
|
|
277
743
|
const sb = model.spaces.get(b.b);
|
|
278
|
-
if (!sa || !sb) continue;
|
|
744
|
+
if (!sa || !sb) continue; // 未定義の参照は REF01 が言う — 形の検査には進まない
|
|
279
745
|
const bAt = { line: b.line, file: b.file, path: [b.a, b.b] };
|
|
280
746
|
|
|
281
747
|
if (VERTICAL.has(b.kind)) {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
emit("VRT01", `${b.kind} 境界は領域とレベルを持つ空間同士に書きます`, bAt);
|
|
285
|
-
continue;
|
|
286
|
-
}
|
|
287
|
-
const ia = levelIndex.get(sa.level);
|
|
288
|
-
const ib = levelIndex.get(sb.level);
|
|
289
|
-
if (ia === undefined || ib === undefined || Math.abs(ia - ib) !== 1) {
|
|
290
|
-
emit("VRT02", `${b.kind} 境界は隣り合うレベルの間に書きます: ${b.a} | ${b.b}`, bAt);
|
|
291
|
-
} else if (!spacesOverlap(sa, sb)) {
|
|
292
|
-
emit("VRT03", `${b.kind} 境界の空間が平面上で重なっていません: ${b.a} | ${b.b}`, bAt);
|
|
293
|
-
}
|
|
294
|
-
if (b.kind === "void") {
|
|
295
|
-
const upper = (ia ?? 0) > (ib ?? 0) ? sa : sb;
|
|
296
|
-
if (upper.type !== "void") {
|
|
297
|
-
emit("VRT04", `void境界の上側は type:void の空間を想定しています: ${upper.path}`, bAt);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
if (b.openings.length > 0) {
|
|
301
|
-
emit("VRT05", `垂直境界の開口は解釈されません`, bAt);
|
|
302
|
-
}
|
|
303
|
-
if (b.segs.length > 0) {
|
|
304
|
-
emit("VRT06", `垂直境界の seg は解釈されません`, bAt);
|
|
305
|
-
}
|
|
306
|
-
continue;
|
|
748
|
+
checkVerticalBoundary(ctx, b, sa, sb, bAt);
|
|
749
|
+
continue; // 垂直境界は水平の検査 (線分・開口・seg) を一切受けない
|
|
307
750
|
}
|
|
308
|
-
|
|
309
|
-
// 水平境界
|
|
310
751
|
if (sa.rects.length > 0 && sb.rects.length > 0 && sa.level !== sb.level) {
|
|
311
752
|
emit(
|
|
312
753
|
"BND03",
|
|
313
754
|
`異なるレベルの空間に壁境界は書けません (垂直は type:stair/shaft/void): ${b.a} | ${b.b}`,
|
|
314
755
|
bAt,
|
|
315
756
|
);
|
|
316
|
-
continue;
|
|
757
|
+
continue; // レベルを跨ぐ壁は成立していない — 線分も開口も問わない
|
|
758
|
+
}
|
|
759
|
+
checkBoundarySegments(ctx, b, sa, sb, bAt);
|
|
760
|
+
checkOpenings(ctx, b);
|
|
761
|
+
checkBoundarySegs(ctx, b);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/** 垂直境界 (stair/shaft/void) — VRT01〜VRT06 */
|
|
766
|
+
function checkVerticalBoundary(ctx: Ctx, b: Boundary, sa: Space, sb: Space, bAt: At): void {
|
|
767
|
+
const { emit, levelIndex } = ctx;
|
|
768
|
+
// 垂直境界: 隣り合うレベルの、平面で重なる空間同士にしか張れない
|
|
769
|
+
if (sa.rects.length === 0 || sb.rects.length === 0 || !sa.level || !sb.level) {
|
|
770
|
+
emit("VRT01", `${b.kind} 境界は領域とレベルを持つ空間同士に書きます`, bAt);
|
|
771
|
+
return; // 前提が崩れているので、以降の判定は意味を持たない
|
|
772
|
+
}
|
|
773
|
+
const ia = levelIndex.get(sa.level);
|
|
774
|
+
const ib = levelIndex.get(sb.level);
|
|
775
|
+
if (ia === undefined || ib === undefined || Math.abs(ia - ib) !== 1) {
|
|
776
|
+
emit("VRT02", `${b.kind} 境界は隣り合うレベルの間に書きます: ${b.a} | ${b.b}`, bAt);
|
|
777
|
+
} else if (!spacesOverlap(sa, sb)) {
|
|
778
|
+
emit("VRT03", `${b.kind} 境界の空間が平面上で重なっていません: ${b.a} | ${b.b}`, bAt);
|
|
779
|
+
}
|
|
780
|
+
if (b.kind === "void") {
|
|
781
|
+
const upper = (ia ?? 0) > (ib ?? 0) ? sa : sb;
|
|
782
|
+
if (upper.type !== "void") {
|
|
783
|
+
emit("VRT04", `void境界の上側は type:void の空間を想定しています: ${upper.path}`, bAt);
|
|
317
784
|
}
|
|
318
|
-
|
|
319
|
-
|
|
785
|
+
}
|
|
786
|
+
// 咎めているのは字下げされた door / window / seg の行そのものなので、
|
|
787
|
+
// 親の境界宣言ではなくその行を指す。宣言が複数あれば診断も複数出る
|
|
788
|
+
for (const o of b.openings) {
|
|
789
|
+
emit("VRT05", `垂直境界の${o.kind}は解釈されません`, { line: o.line, file: b.file, path: [b.a, b.b] });
|
|
790
|
+
}
|
|
791
|
+
for (const g of b.segs) {
|
|
792
|
+
emit("VRT06", `垂直境界の seg は解釈されません`, { line: g.line, file: b.file, path: [b.a, b.b] });
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/** 水平境界の線分がゼロ — BND04 / BND06 */
|
|
797
|
+
function checkBoundarySegments(ctx: Ctx, b: Boundary, sa: Space, sb: Space, bAt: At): void {
|
|
798
|
+
const { model, emit } = ctx;
|
|
799
|
+
// 線を持つ境界の線分ゼロは「接していない」ではない — 線が分離していないか
|
|
800
|
+
// 何も切っていないかであり、それは LIN01 / LIN03 が言う
|
|
801
|
+
if (b.drawn) return;
|
|
802
|
+
const segs = segmentsFor(model, b);
|
|
803
|
+
if (sa.rects.length > 0 && sb.rects.length > 0 && segs.length === 0) {
|
|
804
|
+
// **線分がゼロの理由は二つある。**接していないか、edge: で絞った先に共有辺が
|
|
805
|
+
// 無いか。前者だと断言すると、実際には接している二室について「割付を直せ」と
|
|
806
|
+
// 言うことになる — 直すべきは方角一語である (N=+Y, S=-Y, E=+X, W=-X)
|
|
807
|
+
const without = b.edge ? segmentsFor(model, { ...b, edge: undefined }) : [];
|
|
808
|
+
if (without.length > 0) {
|
|
809
|
+
const dirs = [...new Set(without.map((g) => g.edgeOfA))].filter((d): d is Edge => d !== undefined);
|
|
810
|
+
emit(
|
|
811
|
+
"BND04",
|
|
812
|
+
`edge:${b.edge} に共有辺がありません: ${b.a} | ${b.b} (実際に接しているのは ${
|
|
813
|
+
dirs.join("・") || "別の辺"
|
|
814
|
+
} です)`,
|
|
815
|
+
bAt,
|
|
816
|
+
);
|
|
817
|
+
} else {
|
|
320
818
|
emit("BND04", `空間が接していないため境界を導けません: ${b.a} | ${b.b}`, bAt);
|
|
321
819
|
}
|
|
322
|
-
|
|
323
|
-
|
|
820
|
+
}
|
|
821
|
+
if ((sa.rects.length > 0 ? 1 : 0) + (sb.rects.length > 0 ? 1 : 0) === 1 && segs.length === 0) {
|
|
822
|
+
emit(
|
|
823
|
+
"BND06",
|
|
824
|
+
`${b.edge ? `edge:${b.edge} の` : ""}外周に残る辺が無く、境界線分がゼロです: ${b.a} | ${b.b}`,
|
|
825
|
+
bAt,
|
|
826
|
+
);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* 開口 — OPN03 / 配置エラー (OPN04〜08) / OPN01 / OPN02。
|
|
832
|
+
* **一つの関数に保つ** — 配置に失敗した開口は OPN01 も受けず OPN02 の母集団からも外れる。
|
|
833
|
+
* 配置の結果 (placedOnSeg) を跨いで持つのはここだけである
|
|
834
|
+
*/
|
|
835
|
+
function checkOpenings(ctx: Ctx, b: Boundary): void {
|
|
836
|
+
const { model, emit, loc } = ctx;
|
|
837
|
+
if (b.kind === "open" && b.openings.length > 0) {
|
|
838
|
+
for (const o of b.openings) {
|
|
839
|
+
emit("OPN03", `open境界の${o.kind}は通行に影響しません (常に通れます)`, {
|
|
840
|
+
line: o.line,
|
|
841
|
+
file: b.file,
|
|
842
|
+
path: [b.a, b.b],
|
|
843
|
+
});
|
|
324
844
|
}
|
|
325
|
-
|
|
326
|
-
|
|
845
|
+
}
|
|
846
|
+
const placedOnSeg: Array<{ o: (typeof b.openings)[number]; key: string; c: number }> = [];
|
|
847
|
+
for (const o of b.openings) {
|
|
848
|
+
const placed = placeOpening(model, b, o);
|
|
849
|
+
if ("error" in placed && placed.error) {
|
|
850
|
+
emit(placed.code, placed.message, { line: placed.line, file: placed.file, path: [b.a, b.b] });
|
|
851
|
+
continue; // 置けなかった開口は、以降 (hinge の軸・重なり) の対象にならない
|
|
327
852
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
-
}
|
|
343
|
-
if (o.hinge && "segment" in placed) {
|
|
344
|
-
const okAxis = placed.segment.horizontal
|
|
345
|
-
? o.hinge === "W" || o.hinge === "E"
|
|
346
|
-
: o.hinge === "N" || o.hinge === "S";
|
|
347
|
-
if (!okAxis) {
|
|
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
|
-
}
|
|
853
|
+
if ("segment" in placed) {
|
|
854
|
+
const s = placed.segment;
|
|
855
|
+
placedOnSeg.push({
|
|
856
|
+
o,
|
|
857
|
+
key: `${s.x1},${s.y1},${s.x2},${s.y2}`,
|
|
858
|
+
c: s.horizontal ? placed.cx : placed.cy,
|
|
859
|
+
});
|
|
355
860
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
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)] },
|
|
376
|
-
);
|
|
377
|
-
}
|
|
861
|
+
if (o.hinge && "segment" in placed) {
|
|
862
|
+
const okAxis = placed.segment.horizontal
|
|
863
|
+
? o.hinge === "W" || o.hinge === "E"
|
|
864
|
+
: o.hinge === "N" || o.hinge === "S";
|
|
865
|
+
if (!okAxis) {
|
|
866
|
+
emit(
|
|
867
|
+
"OPN01",
|
|
868
|
+
`hinge:${o.hinge} は${placed.segment.horizontal ? "水平線分 (W/E)" : "垂直線分 (N/S)"}で指定します`,
|
|
869
|
+
{ line: o.line, file: b.file, path: [b.a, b.b] },
|
|
870
|
+
);
|
|
378
871
|
}
|
|
379
872
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
873
|
+
}
|
|
874
|
+
// 同じ線分の上の開口同士は重なってはならない
|
|
875
|
+
const byKey = new Map<string, typeof placedOnSeg>();
|
|
876
|
+
for (const p of placedOnSeg) {
|
|
877
|
+
const arr = byKey.get(p.key) ?? [];
|
|
878
|
+
arr.push(p);
|
|
879
|
+
byKey.set(p.key, arr);
|
|
880
|
+
}
|
|
881
|
+
for (const group of byKey.values()) {
|
|
882
|
+
group.sort((p, q) => p.c - q.c);
|
|
883
|
+
for (let k = 0; k + 1 < group.length; k++) {
|
|
884
|
+
const p = group[k]!;
|
|
885
|
+
const q = group[k + 1]!;
|
|
886
|
+
const need = (p.o.w + q.o.w) / 2;
|
|
887
|
+
if (q.c - p.c < need - EPS) {
|
|
888
|
+
emit(
|
|
889
|
+
"OPN02",
|
|
890
|
+
`開口同士が重なっています (${p.o.kind}と${q.o.kind} — 中心間 ${Math.round(
|
|
891
|
+
q.c - p.c,
|
|
892
|
+
)}mm < 必要 ${Math.round(need)}mm)`,
|
|
893
|
+
{ line: q.o.line, file: b.file, path: [b.a, b.b], related: [loc(p.o.line, b.file)] },
|
|
894
|
+
);
|
|
388
895
|
}
|
|
389
896
|
}
|
|
390
897
|
}
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/** 数えない分節 (seg) の配置 — SEG03 / SEG04〜08 */
|
|
901
|
+
function checkBoundarySegs(ctx: Ctx, b: Boundary): void {
|
|
902
|
+
const { model, emit } = ctx;
|
|
903
|
+
for (const g of b.segs) {
|
|
904
|
+
if (b.kind === "open") {
|
|
905
|
+
emit("SEG03", `open境界 (壁が無い) の seg は解釈されません`, { line: g.line, file: b.file, path: [b.a, b.b] });
|
|
906
|
+
continue;
|
|
907
|
+
}
|
|
908
|
+
const placed = placeBand(model, b, g, "seg");
|
|
909
|
+
if ("error" in placed && placed.error) {
|
|
910
|
+
emit(placed.code, placed.message, { line: placed.line, file: placed.file, path: [b.a, b.b] });
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
}
|
|
391
914
|
|
|
915
|
+
/** 数えない分節 — SEG01 / SEG02 */
|
|
916
|
+
function checkAreas(ctx: Ctx): void {
|
|
917
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
392
918
|
// 数えない分節 (area) は親の領域に収まっているか
|
|
393
919
|
for (const s of model.spaces.values()) {
|
|
394
920
|
for (const a of s.areas) {
|
|
@@ -400,19 +926,20 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
400
926
|
});
|
|
401
927
|
continue;
|
|
402
928
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
a.rect.x2 <= r.x2 + EPS &&
|
|
407
|
-
a.rect.y1 >= r.y1 - EPS &&
|
|
408
|
-
a.rect.y2 <= r.y2 + EPS,
|
|
929
|
+
// 内包も導出された形で見る — 割付で見ると、切り落とした側に置いた床材が通ってしまう
|
|
930
|
+
const inside = regionOf(s).some((g) =>
|
|
931
|
+
rectToPoly(a.rect).every((pt) => pointInPolygon(pt, g, EPS)),
|
|
409
932
|
);
|
|
410
933
|
if (!inside) {
|
|
411
934
|
emit("SEG02", `area が ${s.path} の領域からはみ出しています`, { line: a.line, file: s.file, path: [s.path] });
|
|
412
935
|
}
|
|
413
936
|
}
|
|
414
937
|
}
|
|
938
|
+
}
|
|
415
939
|
|
|
940
|
+
/** ゾーン — ZON01 / ZON02 */
|
|
941
|
+
function checkZones(ctx: Ctx): void {
|
|
942
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
416
943
|
// ゾーン: 束ねる空間が実在するか
|
|
417
944
|
for (const z of model.zones.values()) {
|
|
418
945
|
const children = [...model.spaces.keys()].filter((p) => p.startsWith(z.path + "/"));
|
|
@@ -427,7 +954,11 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
427
954
|
});
|
|
428
955
|
}
|
|
429
956
|
}
|
|
957
|
+
}
|
|
430
958
|
|
|
959
|
+
/** 高さ方向の一貫性 — HGT01〜HGT04 */
|
|
960
|
+
function checkHeights(ctx: Ctx): void {
|
|
961
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
431
962
|
// 高さ方向の一貫性: 下階の空間の天井高 + 上階のslab ≤ 階高
|
|
432
963
|
// 吹抜け (void境界) は宣言的な免除だが、免除が効くのは吹抜けが平面を覆う範囲まで —
|
|
433
964
|
// 部分吹抜けでは下階の天井高は階高内に収める (吹抜け部分の高さは導出) (ADR-0006追記)
|
|
@@ -463,6 +994,10 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
463
994
|
let slabMissing = false;
|
|
464
995
|
for (const s of below) {
|
|
465
996
|
if (isSemiOutdoor(model, s)) continue; // 屋外・半屋外 (庭・バルコニー等) に天井は無い
|
|
997
|
+
// 縦動線の宣言的免除 (ADR-0021)。void の免除が「床の不在」だったのに対し、
|
|
998
|
+
// こちらは「天井が面でない」— 階段室・斜路の天井は上の走りに沿って傾いている。
|
|
999
|
+
// h を一つの数で語れない以上、この不変量は成立しない。頭上高さの検査は別の問い
|
|
1000
|
+
if (runDecls(s).length > 0) continue;
|
|
466
1001
|
const covered = above.some((u) => spacesOverlap(s, u)) || above.length === 0;
|
|
467
1002
|
if (!covered) continue;
|
|
468
1003
|
if (lu.slab === undefined) {
|
|
@@ -471,7 +1006,11 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
471
1006
|
}
|
|
472
1007
|
const h = heff(model, s);
|
|
473
1008
|
if (h === undefined) {
|
|
474
|
-
emit("HGT04", `${s.path} の天井高が不明で、${lu.name} との高さ検査ができません`, {
|
|
1009
|
+
emit("HGT04", `${s.path} の天井高が不明で、${lu.name} との高さ検査ができません`, {
|
|
1010
|
+
line: s.line,
|
|
1011
|
+
file: s.file,
|
|
1012
|
+
path: [s.path],
|
|
1013
|
+
});
|
|
475
1014
|
continue;
|
|
476
1015
|
}
|
|
477
1016
|
if (h + lu.slab > pitch + EPS) {
|
|
@@ -479,27 +1018,37 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
479
1018
|
const cover = partners.length ? voidCoverage(s, partners) : 0;
|
|
480
1019
|
if (cover >= 0.99) continue; // 全面吹抜け — 宣言的免除
|
|
481
1020
|
if (partners.length) {
|
|
1021
|
+
// 本文は HGT01 と同じ三項を出す — 決め手が上階の slab のとき
|
|
1022
|
+
// 「天井高3000は階高3000を超えます」という成り立たない不等式になっていた。
|
|
1023
|
+
// 被覆は免除しきい値 (99%) と衝突しないよう小数一桁で言う
|
|
482
1024
|
emit(
|
|
483
1025
|
"HGT02",
|
|
484
|
-
`${s.path}
|
|
485
|
-
|
|
486
|
-
)}
|
|
487
|
-
{ path: [s.path] },
|
|
1026
|
+
`${s.path} が上階に食い込みます: 天井高${h} + ${lu.name}のslab${lu.slab} = ${
|
|
1027
|
+
h + lu.slab
|
|
1028
|
+
} > 階高${pitch}。吹抜けの被覆は${(cover * 100).toFixed(1)}%しかありません — 部分吹抜けでは天井高を階高内に収めます (吹抜け部分の高さは導出)`,
|
|
1029
|
+
{ line: s.line, file: s.file, path: [s.path] },
|
|
488
1030
|
);
|
|
489
1031
|
} else {
|
|
490
1032
|
emit(
|
|
491
1033
|
"HGT01",
|
|
492
1034
|
`${s.path} が上階に食い込みます: 天井高${h} + ${lu.name}のslab${lu.slab} = ${h + lu.slab} > 階高${pitch}`,
|
|
493
|
-
{ path: [s.path] },
|
|
1035
|
+
{ line: s.line, file: s.file, path: [s.path] },
|
|
494
1036
|
);
|
|
495
1037
|
}
|
|
496
1038
|
}
|
|
497
1039
|
}
|
|
498
1040
|
if (slabMissing) {
|
|
499
|
-
emit("HGT03", `レベル ${lu.name} に slab が未宣言のため、${lb.name}
|
|
1041
|
+
emit("HGT03", `レベル ${lu.name} に slab が未宣言のため、${lb.name} との高さ検査ができません`, {
|
|
1042
|
+
line: lu.line,
|
|
1043
|
+
file: lu.file,
|
|
1044
|
+
});
|
|
500
1045
|
}
|
|
501
1046
|
}
|
|
1047
|
+
}
|
|
502
1048
|
|
|
1049
|
+
/** レベルに載らない空間 — HGT05 */
|
|
1050
|
+
function checkOrphanSpaces(ctx: Ctx): void {
|
|
1051
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
503
1052
|
// レベルに載らない領域つき空間
|
|
504
1053
|
for (const s of withRect) {
|
|
505
1054
|
if (!s.level) {
|
|
@@ -510,7 +1059,11 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
510
1059
|
});
|
|
511
1060
|
}
|
|
512
1061
|
}
|
|
1062
|
+
}
|
|
513
1063
|
|
|
1064
|
+
/** 敷地形状 — SIT01〜SIT05 */
|
|
1065
|
+
function checkSite(ctx: Ctx): void {
|
|
1066
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
514
1067
|
// 敷地形状 (ADR-0011): 形の妥当性、対応ゾーンの存在、宣言面積との照合、建物のはみ出し検査。
|
|
515
1068
|
// はみ出しは四隅の内包に加え、多角形の頂点の入り込みと辺の交差を見る — 凹敷地でも正しい (ADR-0013)。
|
|
516
1069
|
// 地上の外部空間タイル (庭・通路) は近似なので検査しない — 面積の真は多角形が持つ
|
|
@@ -558,8 +1111,9 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
558
1111
|
}
|
|
559
1112
|
for (const s of withRect) {
|
|
560
1113
|
if (s.type === "exterior" || s.path.startsWith(poly.path + "/")) continue;
|
|
561
|
-
|
|
562
|
-
|
|
1114
|
+
// 照合するのは割付ではなく**導出された領域** — 敷地なりに切った外形はここで通る
|
|
1115
|
+
for (const r of regionOf(s)) {
|
|
1116
|
+
const out = shapeEscapesPolygon(r, poly.points, EPS_SITE);
|
|
563
1117
|
if (out) {
|
|
564
1118
|
emit("SIT03", `${s.path} が敷地形状からはみ出しています (${Math.round(out.x)},${Math.round(out.y)} 付近)`, {
|
|
565
1119
|
line: s.line,
|
|
@@ -571,21 +1125,4 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
571
1125
|
}
|
|
572
1126
|
}
|
|
573
1127
|
}
|
|
574
|
-
|
|
575
|
-
return diags;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
/** 吹抜けが下階の空間の平面をどれだけ覆うか (0..1) */
|
|
579
|
-
function voidCoverage(s: Space, partners: Space[]): number {
|
|
580
|
-
let inter = 0;
|
|
581
|
-
for (const r of s.rects) {
|
|
582
|
-
for (const p of partners) {
|
|
583
|
-
for (const pr of p.rects) {
|
|
584
|
-
const o = planOverlap(r, pr);
|
|
585
|
-
if (o) inter += (o.x2 - o.x1) * (o.y2 - o.y1);
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
const area = s.rects.reduce((sum, r) => sum + (r.x2 - r.x1) * (r.y2 - r.y1), 0);
|
|
590
|
-
return area > 0 ? inter / area : 0;
|
|
591
1128
|
}
|