@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/dist/check.js
CHANGED
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
// 診断契約 (ADR-0016): 一次形式は checkDiagnostics の Diagnostic[] — code / severity /
|
|
8
8
|
// 日本語本文 / 出所 / 対象パス。check は互換層で、従来の文字列 (位置接頭辞つき) を組み立てる。
|
|
9
9
|
// severity はコードの不変属性 — 重さを変えたくなったら新コードを切る。
|
|
10
|
-
import { placeBand, placeOpening, planOverlap, segmentsFor, spacesOverlap, } from "./graph.js";
|
|
11
|
-
import { heff, isSemiOutdoor, levelsSorted, srcRef, polygonAreaM2, polygonSelfIntersection,
|
|
10
|
+
import { placeBand, placeOpening, planOverlap, segmentsFor, segmentLength, envelopeGaps, drawnCut, spacesOverlap, } from "./graph.js";
|
|
11
|
+
import { heff, isSemiOutdoor, levelsSorted, columnSites, columnsFor, pointInPolygon, rectToPoly, regionOf, srcRef, polygonAreaM2, polygonSelfIntersection, shapeEscapesPolygon, } from "./model.js";
|
|
12
|
+
import { cutsInWindow } from "./poly.js";
|
|
13
|
+
import { runDecls, runIssues } from "./vertical.js";
|
|
12
14
|
/**
|
|
13
15
|
* 診断コードの台帳 — 全コードと規範severity。specの表 (semantics.md §5) とテストで一致を守る。
|
|
14
16
|
* BND07 は欠番 — 「接しているのに境界が無い」警告はADR-0014 (既定境界) で廃止された。
|
|
@@ -62,14 +64,89 @@ export const DIAGNOSTIC_CODES = {
|
|
|
62
64
|
UID01: "error", // 数字だけのuid (ADR-0015)
|
|
63
65
|
UID02: "error", // 空白を含むuid
|
|
64
66
|
UID03: "error", // uidの重複
|
|
67
|
+
ATT01: "error", // 解釈される属性の値が数値でない (ADR-0028)
|
|
68
|
+
ATT02: "error", // 解釈される属性の値が台帳の語彙にない (ADR-0028)
|
|
69
|
+
DAY01: "error", // daylightの値が 0/1 以外 (ADR-0020)
|
|
70
|
+
RUN01: "error", // 一つの空間に縦動線の宣言が複数 (ADR-0021)
|
|
71
|
+
RUN02: "error", // 縦動線の値が上る向き (N/E/S/W) でない
|
|
72
|
+
RUN03: "error", // 縦動線の領域が矩形一つでない / レベルが不明
|
|
73
|
+
RUN04: "warning", // 上にレベルが無く縦動線の形が生成できない
|
|
74
|
+
RUN05: "error", // form の値が不正、または形が決まらない
|
|
75
|
+
RUN06: "warning", // 導出された段の寸法が窮屈 (書かないが検査する)
|
|
76
|
+
RUN07: "warning", // 導出された勾配が宣言・常用域から外れる
|
|
77
|
+
RUN08: "warning", // 縦動線の形はあるが上下を繋ぐ垂直境界が無い
|
|
78
|
+
LIN01: "error", // 描かれた線が二つの空間を分離しない (ADR-0022)
|
|
79
|
+
LIN02: "error", // 垂直境界に描かれた線
|
|
80
|
+
LIN03: "warning", // 描かれた線が何も切っていない
|
|
81
|
+
ENV01: "warning", // 外皮に穴 — 何にも面していない外周 (ADR-0025)
|
|
82
|
+
COL01: "warning", // 柱の宣言に対して立つ柱が0本 (ADR-0023)
|
|
83
|
+
COL02: "warning", // 同じ通りの交点に複数の柱宣言が重なる (先の宣言が勝つ)
|
|
65
84
|
VER01: "error", // koyu 0.1 での既定境界の導出 (ADR-0017)
|
|
85
|
+
VER02: "error", // koyu 0.3以前で採光の推定対象だった型に daylight が無い (ADR-0020)
|
|
86
|
+
VER03: "error", // koyu 0.4以前のファイルに0.5の語 (縦動線・線・柱・地下)
|
|
66
87
|
SYN01: "error", // 構文・合成エラー (SourceError の写し — check --json のみ)
|
|
67
88
|
};
|
|
68
89
|
const EPS = 0.5;
|
|
69
90
|
/** 敷地まわりの幾何の許容 (境界上は内側扱い) — ADR-0011の1mm */
|
|
70
91
|
const EPS_SITE = 1;
|
|
71
92
|
const VERTICAL = new Set(["stair", "shaft", "void"]);
|
|
93
|
+
/** 0.3以前が採光の対象と推定していた型 (ADR-0020で廃止)。旧版の受理条件の判定にだけ使う — 意味論には効かない */
|
|
94
|
+
const LEGACY_DAYLIT = new Set(["unit", "room", "ldk", "bedroom", "living"]);
|
|
72
95
|
/** 互換層 — 従来の文字列形式。位置を持つ診断は「file:N行目: 本文」に組み立てる */
|
|
96
|
+
/**
|
|
97
|
+
* 解釈される属性の値の台帳 (ADR-0028)。**spec/vocabulary.md の★が契約であり、これはその写しである。**
|
|
98
|
+
*
|
|
99
|
+
* `of` があれば列挙、無ければ正の数値。ここに無い属性は自由に書けてそのまま運ばれる
|
|
100
|
+
* (台帳の規則3)。daylight は DAY01 が、form は RUN05 が、縦動線の向きは RUN02 が
|
|
101
|
+
* 既に守っているので重ねない。
|
|
102
|
+
*/
|
|
103
|
+
const ATTR_RULES = {
|
|
104
|
+
space: {
|
|
105
|
+
h: {},
|
|
106
|
+
ceiling: { of: [0, 1] },
|
|
107
|
+
turn: { of: ["R", "L"] },
|
|
108
|
+
riser: {},
|
|
109
|
+
tread: {},
|
|
110
|
+
entry: {},
|
|
111
|
+
landing: {},
|
|
112
|
+
lane: {},
|
|
113
|
+
slope: {},
|
|
114
|
+
road: {},
|
|
115
|
+
},
|
|
116
|
+
zone: { site: { of: [0, 1] }, area: {} },
|
|
117
|
+
// air:1 の境界の天端高 (手すり・腰壁) — 立体が読むので台帳に載る (ADR-0028)
|
|
118
|
+
boundary: { h: {} },
|
|
119
|
+
opening: { style: { of: ["hinged", "sliding", "auto"] } },
|
|
120
|
+
};
|
|
121
|
+
/** 値を検査すべき宣言を、出所つきで数え上げる — 母集団は**書かれた宣言**である */
|
|
122
|
+
function attrSubjects(model) {
|
|
123
|
+
const out = [];
|
|
124
|
+
for (const s of model.spaces.values()) {
|
|
125
|
+
out.push([s.path, { rules: ATTR_RULES["space"], of: s.attrs }, { line: s.line, file: s.file, path: [s.path] }]);
|
|
126
|
+
}
|
|
127
|
+
for (const z of model.zones.values()) {
|
|
128
|
+
out.push([`ゾーン ${z.path}`, { rules: ATTR_RULES["zone"], of: z.attrs }, { line: z.line, file: z.file, path: [z.path] }]);
|
|
129
|
+
}
|
|
130
|
+
for (const b of model.boundaries) {
|
|
131
|
+
const at = { line: b.line, file: b.file, path: [b.a, b.b] };
|
|
132
|
+
out.push([`境界 ${b.a} | ${b.b}`, { rules: ATTR_RULES["boundary"], of: b.attrs }, at]);
|
|
133
|
+
for (const o of b.openings) {
|
|
134
|
+
out.push([
|
|
135
|
+
`${o.kind} (${b.a} | ${b.b})`,
|
|
136
|
+
{ rules: ATTR_RULES["opening"], of: o.attrs },
|
|
137
|
+
{ line: o.line, file: b.file, path: [b.a, b.b] },
|
|
138
|
+
]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
/** 書かれた通り語で矩形を名指す — 「どの組が重なっているか」を言えるようにする */
|
|
144
|
+
function gridRefText(s, i) {
|
|
145
|
+
const g = s.grids[i];
|
|
146
|
+
if (!g)
|
|
147
|
+
return `#${i + 1}`;
|
|
148
|
+
return `${g.xa}..${g.xb} ${g.ya}..${g.yb}`;
|
|
149
|
+
}
|
|
73
150
|
export function check(model) {
|
|
74
151
|
const errors = [];
|
|
75
152
|
const warnings = [];
|
|
@@ -97,6 +174,53 @@ export function checkDiagnostics(model) {
|
|
|
97
174
|
line,
|
|
98
175
|
...(file !== undefined ? { file } : {}),
|
|
99
176
|
});
|
|
177
|
+
const withRect = [...model.spaces.values()].filter((s) => s.rects.length > 0);
|
|
178
|
+
const levels = levelsSorted(model);
|
|
179
|
+
const levelIndex = new Map(levels.map((l, i) => [l.name, i]));
|
|
180
|
+
const ctx = { model, emit, loc, withRect, levels, levelIndex };
|
|
181
|
+
// **節の順序が出力の順序である。**互換層は診断を出た順に文字列へ写すので、
|
|
182
|
+
// ここの並びを入れ替えると check の出力が変わる (test/diagnostics.test.ts が固定している)。
|
|
183
|
+
// 節の粒度は「走査単位」であって「診断コードの族」ではない — 一つのループが
|
|
184
|
+
// 複数のコードを出すとき、それらは走査の順に交互に出る。族で割ると並びが崩れる
|
|
185
|
+
checkBoundaryRefs(ctx);
|
|
186
|
+
checkBoundaryIdentity(ctx);
|
|
187
|
+
checkLevelDepth(ctx);
|
|
188
|
+
checkSelfOverlap(ctx);
|
|
189
|
+
checkSpaceOverlap(ctx);
|
|
190
|
+
checkDaylightScope(ctx);
|
|
191
|
+
checkAttrValues(ctx);
|
|
192
|
+
checkRuns(ctx);
|
|
193
|
+
checkDrawnLines(ctx);
|
|
194
|
+
checkEnvelopeGaps(ctx);
|
|
195
|
+
checkColumns(ctx);
|
|
196
|
+
checkLanguageVersion(ctx);
|
|
197
|
+
checkUids(ctx);
|
|
198
|
+
checkBoundaryValidity(ctx);
|
|
199
|
+
checkAreas(ctx);
|
|
200
|
+
checkZones(ctx);
|
|
201
|
+
checkHeights(ctx);
|
|
202
|
+
checkOrphanSpaces(ctx);
|
|
203
|
+
checkSite(ctx);
|
|
204
|
+
return diags;
|
|
205
|
+
}
|
|
206
|
+
/** 吹抜けが下階の空間の平面をどれだけ覆うか (0..1) */
|
|
207
|
+
function voidCoverage(s, partners) {
|
|
208
|
+
let inter = 0;
|
|
209
|
+
for (const r of s.rects) {
|
|
210
|
+
for (const p of partners) {
|
|
211
|
+
for (const pr of p.rects) {
|
|
212
|
+
const o = planOverlap(r, pr);
|
|
213
|
+
if (o)
|
|
214
|
+
inter += (o.x2 - o.x1) * (o.y2 - o.y1);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const area = s.rects.reduce((sum, r) => sum + (r.x2 - r.x1) * (r.y2 - r.y1), 0);
|
|
219
|
+
return area > 0 ? inter / area : 0;
|
|
220
|
+
}
|
|
221
|
+
/** 境界の参照先 — REF01 / BND01 */
|
|
222
|
+
function checkBoundaryRefs(ctx) {
|
|
223
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
100
224
|
// 境界の参照先
|
|
101
225
|
for (const b of model.boundaries) {
|
|
102
226
|
for (const p of [b.a, b.b]) {
|
|
@@ -108,13 +232,19 @@ export function checkDiagnostics(model) {
|
|
|
108
232
|
emit("BND01", `同じ空間同士の境界は書けません: ${b.a}`, { line: b.line, file: b.file, path: [b.a, b.b] });
|
|
109
233
|
}
|
|
110
234
|
}
|
|
235
|
+
}
|
|
236
|
+
/** 境界の同一性 — BND02 / BND05 */
|
|
237
|
+
function checkBoundaryIdentity(ctx) {
|
|
238
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
111
239
|
// 境界の同一性: 同じ空間対 (edge限定まで同一) の重複宣言は矛盾の温床 — エラー (ADR-0013)。
|
|
112
240
|
// wall/openの食い違いもこの検査が捕まえる。edge限定の有無が混在する対は線分が重なるため警告
|
|
113
241
|
const seenBoundary = new Map();
|
|
114
242
|
const pairEdges = new Map();
|
|
115
243
|
for (const b of model.boundaries) {
|
|
116
244
|
const pair = [b.a, b.b].sort().join(" | ");
|
|
117
|
-
|
|
245
|
+
// 描かれた線を持つ境界は、線そのものが実現なので同一性の鍵に線の綴りが入る。
|
|
246
|
+
// 同じ空間対に二本の線 (二箇所の隅切りなど) を引くのは矛盾ではない
|
|
247
|
+
const key = `${pair}#${b.edge ?? ""}#${b.drawn ? `${b.drawn.aRef}..${b.drawn.bRef}` : ""}`;
|
|
118
248
|
const prev = seenBoundary.get(key);
|
|
119
249
|
if (prev) {
|
|
120
250
|
emit("BND02", `境界が重複しています: ${pair}${b.edge ? ` edge:${b.edge}` : ""} (既出: ${srcRef(prev.line, prev.file)})`, { line: b.line, file: b.file, path: [b.a, b.b], related: [loc(prev.line, prev.file)] });
|
|
@@ -122,35 +252,63 @@ export function checkDiagnostics(model) {
|
|
|
122
252
|
else {
|
|
123
253
|
seenBoundary.set(key, b);
|
|
124
254
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
255
|
+
// 線を持つ境界は外周の残りを取らない (線が線分そのもの) ので、edge の混在の話に入れない
|
|
256
|
+
if (!b.drawn) {
|
|
257
|
+
const set = pairEdges.get(pair) ?? new Set();
|
|
258
|
+
set.add(b.edge ?? "");
|
|
259
|
+
pairEdges.set(pair, set);
|
|
260
|
+
}
|
|
128
261
|
}
|
|
129
262
|
for (const [pair, edges] of pairEdges) {
|
|
130
263
|
if (edges.has("") && edges.size > 1) {
|
|
264
|
+
// 集合に対する診断でも、集合を作った宣言の行は必ず指す —
|
|
265
|
+
// 「どこかで併存している」だけでは直す場所が無い
|
|
266
|
+
const members = model.boundaries.filter((b) => !b.drawn && [b.a, b.b].sort().join(" | ") === pair);
|
|
267
|
+
const first = members.find((b) => !b.edge) ?? members[0];
|
|
131
268
|
emit("BND05", `同じ空間対に edge 限定つきと無しの境界が併存しています (線分が重なります): ${pair}`, {
|
|
269
|
+
...(first ? { line: first.line, file: first.file } : {}),
|
|
132
270
|
path: pair.split(" | "),
|
|
271
|
+
related: members.filter((b) => b !== first).map((b) => loc(b.line, b.file)),
|
|
133
272
|
});
|
|
134
273
|
}
|
|
135
274
|
}
|
|
136
|
-
|
|
137
|
-
|
|
275
|
+
}
|
|
276
|
+
/** レベルの重複 — LVL01 */
|
|
277
|
+
function checkLevelDepth(ctx) {
|
|
278
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
138
279
|
// レベルの重複
|
|
139
280
|
for (let i = 1; i < levels.length; i++) {
|
|
140
281
|
if (Math.abs(levels[i].z - levels[i - 1].z) < EPS) {
|
|
141
|
-
emit("LVL01", `レベル ${levels[i - 1].name} と ${levels[i].name} のz
|
|
282
|
+
emit("LVL01", `レベル ${levels[i - 1].name} と ${levels[i].name} のzが同じです`, {
|
|
283
|
+
line: levels[i].line,
|
|
284
|
+
file: levels[i].file,
|
|
285
|
+
related: [loc(levels[i - 1].line, levels[i - 1].file)],
|
|
286
|
+
});
|
|
142
287
|
}
|
|
143
288
|
}
|
|
289
|
+
}
|
|
290
|
+
/** 自らの領域の重なり — GEO01 */
|
|
291
|
+
function checkSelfOverlap(ctx) {
|
|
292
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
144
293
|
// 自らの領域 (合併の矩形同士) の重なり
|
|
145
294
|
for (const s of withRect) {
|
|
146
295
|
for (let i = 0; i < s.rects.length; i++) {
|
|
147
296
|
for (let j = i + 1; j < s.rects.length; j++) {
|
|
148
297
|
if (planOverlap(s.rects[i], s.rects[j])) {
|
|
149
|
-
|
|
298
|
+
// どの組かを言わなければ、三つ重なる空間にバイト同一の診断が三件並ぶ
|
|
299
|
+
emit("GEO01", `${s.path} の領域同士が重なっています: ${gridRefText(s, i)} と ${gridRefText(s, j)}`, {
|
|
300
|
+
line: s.line,
|
|
301
|
+
file: s.file,
|
|
302
|
+
path: [s.path],
|
|
303
|
+
});
|
|
150
304
|
}
|
|
151
305
|
}
|
|
152
306
|
}
|
|
153
307
|
}
|
|
308
|
+
}
|
|
309
|
+
/** 空間同士の重なり — GEO02 */
|
|
310
|
+
function checkSpaceOverlap(ctx) {
|
|
311
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
154
312
|
// 同一レベルでの空間同士の重なり
|
|
155
313
|
for (let i = 0; i < withRect.length; i++) {
|
|
156
314
|
for (let j = i + 1; j < withRect.length; j++) {
|
|
@@ -160,13 +318,194 @@ export function checkDiagnostics(model) {
|
|
|
160
318
|
continue;
|
|
161
319
|
if (spacesOverlap(a, b)) {
|
|
162
320
|
emit("GEO02", `空間の領域が重なっています: ${a.path} と ${b.path}`, {
|
|
321
|
+
line: a.line,
|
|
322
|
+
file: a.file,
|
|
163
323
|
path: [a.path, b.path],
|
|
164
324
|
related: [loc(b.line, b.file)],
|
|
165
325
|
});
|
|
166
326
|
}
|
|
167
327
|
}
|
|
168
328
|
}
|
|
169
|
-
|
|
329
|
+
}
|
|
330
|
+
/** 採光の対象の宣言 — DAY01 */
|
|
331
|
+
function checkDaylightScope(ctx) {
|
|
332
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
333
|
+
// 採光の対象の宣言 (ADR-0020): daylight は「この室に 1/7 の判定を掛ける」という二値の宣言。
|
|
334
|
+
// 綴りの揺れ (daylight:true / daylight:yes) が黙って対象外に落ちるのを防ぐ
|
|
335
|
+
for (const s of model.spaces.values()) {
|
|
336
|
+
const v = s.attrs["daylight"];
|
|
337
|
+
if (v === undefined)
|
|
338
|
+
continue;
|
|
339
|
+
if (v !== 0 && v !== 1) {
|
|
340
|
+
emit("DAY01", `daylight は 1 (採光判定の対象) か 0 (対象外) です: ${s.path} に daylight:${v}`, {
|
|
341
|
+
line: s.line,
|
|
342
|
+
file: s.file,
|
|
343
|
+
path: [s.path],
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
/** 解釈される属性の値 — ATT01 / ATT02 */
|
|
349
|
+
function checkAttrValues(ctx) {
|
|
350
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
351
|
+
// 解釈される属性の値 (ADR-0028): **書いたのに解釈されなかった値は、黙って既定へ落とさない。**
|
|
352
|
+
//
|
|
353
|
+
// daylight だけが DAY01 で守られていて、他の★属性は素通りだった。帰結は黙殺である —
|
|
354
|
+
// `site:yes` は敷地の検査 (SIT03 error) を丸ごと無効にし、`h:35OO` は高さ不変量
|
|
355
|
+
// (HGT01 error) を消し、`ceiling:none` は天井を張り、`turn:l` は階段を鏡像にする。
|
|
356
|
+
// どれも check は緑のままだった。台帳 (spec/vocabulary.md) が契約である以上、
|
|
357
|
+
// 台帳の型に合わない値はエラーである。
|
|
358
|
+
for (const [where, attrs, at] of attrSubjects(model)) {
|
|
359
|
+
for (const [key, rule] of Object.entries(attrs.rules)) {
|
|
360
|
+
const v = attrs.of[key];
|
|
361
|
+
if (v === undefined)
|
|
362
|
+
continue;
|
|
363
|
+
if (rule.of) {
|
|
364
|
+
if (!rule.of.includes(v)) {
|
|
365
|
+
emit("ATT02", `${where} の ${key} は ${rule.of.join(" / ")} のどれかです: ${key}:${v}`, at);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
else if (typeof v !== "number" || !(v > 0)) {
|
|
369
|
+
emit("ATT01", `${where} の ${key} は正の数値で書きます: ${key}:${v}`, at);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
/** 縦動線 — RUN01〜RUN08 */
|
|
375
|
+
function checkRuns(ctx) {
|
|
376
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
377
|
+
// 縦動線 (ADR-0021): 宣言の妥当性と、**書かれていない導出値**の妥当性。
|
|
378
|
+
// 段数も踏面も勾配も書かない — だから導出したものを検査する
|
|
379
|
+
for (const i of runIssues(model)) {
|
|
380
|
+
emit(i.code, i.message, { line: i.line, file: i.file, path: [i.path] });
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
/** 描かれた線 — LIN01〜LIN03 */
|
|
384
|
+
function checkDrawnLines(ctx) {
|
|
385
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
386
|
+
// 描かれた線 (ADR-0022): 線は二つの空間を実際に分離しなければならない。
|
|
387
|
+
// 「宣言どおりに切れているか」は arrangement の検査であり、check の仕事
|
|
388
|
+
for (const b of model.boundaries) {
|
|
389
|
+
if (!b.drawn)
|
|
390
|
+
continue;
|
|
391
|
+
const bAt = { line: b.drawn.line, file: b.file, path: [b.a, b.b] };
|
|
392
|
+
if (VERTICAL.has(b.kind)) {
|
|
393
|
+
emit("LIN02", `垂直境界に線は描けません (線は平面を区切る行為です): ${b.a} | ${b.b}`, bAt);
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
const sa = model.spaces.get(b.a);
|
|
397
|
+
const sb = model.spaces.get(b.b);
|
|
398
|
+
if (!sa || !sb)
|
|
399
|
+
continue;
|
|
400
|
+
if (sa.rects.length === 0 && sb.rects.length === 0) {
|
|
401
|
+
emit("LIN01", `領域を持たない空間同士に線は描けません: ${b.a} | ${b.b}`, bAt);
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
// 判定と操作を同じ関数に通す (ADR-0027)。窓の中で分離が決まらなければ LIN01、
|
|
405
|
+
// 決まるが実際には何も切っていなければ LIN03。以前は判定だけが別の窓 (線分の
|
|
406
|
+
// 外接矩形) を使っていたので、軸平行の線では窓が潰れて必ず誤報していた
|
|
407
|
+
const cut = drawnCut(sa, sb, b.drawn.a, b.drawn.b);
|
|
408
|
+
if (!cut) {
|
|
409
|
+
emit("LIN01", sa.rects.length > 0 && sb.rects.length > 0
|
|
410
|
+
? `線 ${b.drawn.aRef}..${b.drawn.bRef} は ${b.a} と ${b.b} を分離していません (二つの割付が線の両側に来るように引きます)`
|
|
411
|
+
: `線 ${b.drawn.aRef}..${b.drawn.bRef} が割付をちょうど二等分していて、どちらを残すか決まりません`, bAt);
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
const target = cut.solo ? [cut.solo] : [sa, sb];
|
|
415
|
+
if (!target.some((s) => cutsInWindow(s.rects.map(rectToPoly), cut.window, b.drawn.a, b.drawn.b))) {
|
|
416
|
+
emit("LIN03", `線 ${b.drawn.aRef}..${b.drawn.bRef} は何も切っていません (既定の隣接線と同じか、割付の外にあります)`, bAt);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
/** 外皮の穴 — ENV01 */
|
|
421
|
+
function checkEnvelopeGaps(ctx) {
|
|
422
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
423
|
+
// 外皮の穴 (ADR-0025): 既定境界は領域を持たない空間との間には導かれない (ADR-0014) ので、
|
|
424
|
+
// 外部への境界の書き忘れは黙って壁の不在になる。導出された外周のうち、
|
|
425
|
+
// 他の空間とも宣言された境界とも向かい合っていない区間を数える。
|
|
426
|
+
// 外構のタイル (site:1 ゾーンの配下)・外部・半屋外は囲われていないのが正常なので数えない。
|
|
427
|
+
// そして**外皮を書き始めているレベルだけ**を見る — 外部への境界が一本も無い階は
|
|
428
|
+
// 外皮をまだ模型にしていないだけであって、穴が開いているのではない。
|
|
429
|
+
// 「書き始めたなら閉じきる」という整合の検査であって、完全性の要求ではない
|
|
430
|
+
const siteZones = [...model.zones.values()].filter((z) => z.attrs["site"] === 1).map((z) => z.path);
|
|
431
|
+
const envelopedLevels = new Set();
|
|
432
|
+
for (const b of model.boundaries) {
|
|
433
|
+
if (b.derived || VERTICAL.has(b.kind))
|
|
434
|
+
continue;
|
|
435
|
+
const sa = model.spaces.get(b.a);
|
|
436
|
+
const sb = model.spaces.get(b.b);
|
|
437
|
+
if (!sa || !sb)
|
|
438
|
+
continue;
|
|
439
|
+
const outer = sa.rects.length === 0 ? sb : sb.rects.length === 0 ? sa : undefined;
|
|
440
|
+
if (outer?.level)
|
|
441
|
+
envelopedLevels.add(outer.level);
|
|
442
|
+
}
|
|
443
|
+
for (const s of withRect) {
|
|
444
|
+
if (!s.level || !envelopedLevels.has(s.level))
|
|
445
|
+
continue;
|
|
446
|
+
if (s.type === "exterior" || isSemiOutdoor(model, s))
|
|
447
|
+
continue;
|
|
448
|
+
if (siteZones.some((z) => s.path.startsWith(z + "/")))
|
|
449
|
+
continue;
|
|
450
|
+
const gaps = envelopeGaps(model, s);
|
|
451
|
+
if (gaps.length === 0)
|
|
452
|
+
continue;
|
|
453
|
+
// **どの辺かを言う。**合計長だけでは、edge を書き分けている図面で直す辺が特定できない。
|
|
454
|
+
// envelopeGaps は座標つきの線分を返しているので、方角は既に手元にある
|
|
455
|
+
const byDir = new Map();
|
|
456
|
+
for (const g of gaps) {
|
|
457
|
+
const d = g.edgeOfA ?? (g.horizontal ? "N/S" : "E/W");
|
|
458
|
+
byDir.set(d, (byDir.get(d) ?? 0) + segmentLength(g));
|
|
459
|
+
}
|
|
460
|
+
const total = gaps.reduce((a, g) => a + segmentLength(g), 0);
|
|
461
|
+
const where = [...byDir].map(([d, mm]) => `${d} ${Math.round(mm)}mm`).join(" / ");
|
|
462
|
+
emit("ENV01", `外皮に面していない外周があります: ${s.path} — ${where} (合計 ${Math.round(total)}mm・${gaps.length}区間)。外部への境界を書きます`, { line: s.line, file: s.file, path: [s.path] });
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
/** 柱 — COL01 / COL02 */
|
|
466
|
+
function checkColumns(ctx) {
|
|
467
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
468
|
+
// 柱 (ADR-0023): 位置は書かれない。宣言に対して一本も立たなければ、
|
|
469
|
+
// 通りか階の指定が実際の床とすれ違っている
|
|
470
|
+
//
|
|
471
|
+
// **母集団は宣言である。**「このレベルに何本立ったか」ではなく「この宣言から何本立ったか」を
|
|
472
|
+
// 問う。前者を数えると、同じ階の別の宣言が一本でも立てた瞬間に、一本も立たない宣言が
|
|
473
|
+
// 黙って通る (ADR-0028)。Column.decl がその帰属を持つ。
|
|
474
|
+
const stood = new Map();
|
|
475
|
+
const levelsOfDecl = new Set();
|
|
476
|
+
for (const c of model.columns)
|
|
477
|
+
for (const lv of c.levels)
|
|
478
|
+
levelsOfDecl.add(lv);
|
|
479
|
+
for (const lv of levelsOfDecl) {
|
|
480
|
+
for (const col of columnsFor(model, lv))
|
|
481
|
+
stood.set(col.decl, (stood.get(col.decl) ?? 0) + 1);
|
|
482
|
+
}
|
|
483
|
+
for (let ci = 0; ci < model.columns.length; ci++) {
|
|
484
|
+
const c = model.columns[ci];
|
|
485
|
+
if ((stood.get(ci) ?? 0) > 0)
|
|
486
|
+
continue;
|
|
487
|
+
const at = { line: c.line, file: c.file };
|
|
488
|
+
// 一本も立たない理由は二つある。**狙う交点に床が無い**か、床はあるが先の宣言に
|
|
489
|
+
// 取られたか。後者を「床がありません」と言うと、直しようのない場所へ人を送る
|
|
490
|
+
const sites = new Set(c.levels.flatMap((lv) => columnSites(model, c, lv).map((p) => `${lv}|${p.grid}`)));
|
|
491
|
+
if (sites.size > 0) {
|
|
492
|
+
// 影を作ったのは、この宣言と同じ交点に**実際に立った**先の宣言だけである
|
|
493
|
+
const shadow = model.columns.filter((o, oi) => {
|
|
494
|
+
if (oi >= ci)
|
|
495
|
+
return false;
|
|
496
|
+
return o.levels.some((lv) => columnsFor(model, lv).some((k) => k.decl === oi && sites.has(`${lv}|${k.grid}`)));
|
|
497
|
+
});
|
|
498
|
+
emit("COL02", `この柱の宣言 (${c.levels.join(",")} ${c.size}角) は同じ交点を先の宣言に取られていて、一本も立ちません (同じ交点では先の宣言が勝ちます)`, { ...at, related: shadow.map((o) => loc(o.line, o.file)) });
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
emit("COL01", `柱の宣言に対して立つ柱がありません (通りの交点に床がありません): ${c.levels.join(",")} ${c.size}角`, at);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
/** 言語版の受理条件 — VER01〜VER03 */
|
|
506
|
+
function checkLanguageVersion(ctx) {
|
|
507
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
508
|
+
// 言語版の受理条件 (ADR-0017): 旧版は意味保存の場合のみ受理する。
|
|
170
509
|
// 既定境界 (ADR-0014) が導出されるファイルは、0.1の意味 (境界なし+警告) と食い違う — エラーで二択を示す
|
|
171
510
|
if (model.version === "0.1") {
|
|
172
511
|
for (const b of model.boundaries) {
|
|
@@ -175,6 +514,54 @@ export function checkDiagnostics(model) {
|
|
|
175
514
|
}
|
|
176
515
|
}
|
|
177
516
|
}
|
|
517
|
+
// 0.3以前は型から採光の対象を推定していた (ADR-0020で廃止)。推定対象だった型の空間に daylight が
|
|
518
|
+
// 書かれていなければ、0.4では判定から黙って外れる — 意味が変わるのでエラーで二択を示す
|
|
519
|
+
if (["0.1", "0.2", "0.3"].includes(model.version)) {
|
|
520
|
+
for (const s of model.spaces.values()) {
|
|
521
|
+
if (!LEGACY_DAYLIT.has(s.type) || s.attrs["daylight"] !== undefined)
|
|
522
|
+
continue;
|
|
523
|
+
emit("VER02", `koyu ${model.version} のファイルに daylight の無い ${s.type} があります: ${s.path} — 0.4では型から採光の対象を推定しないので判定から外れます。daylight:1 (対象) か daylight:0 (対象外) を書いてから koyu 0.4 へ上げます`, { line: s.line, file: s.file, path: [s.path] });
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
// 0.5 で入った語 (縦動線の宣言・描かれた線・柱・地下) は 0.4 以前の処理系が知らない。
|
|
527
|
+
// 知らない処理系では黙って形が生成されないので、版を上げずに使うのはエラー (ADR-0017 決定3)
|
|
528
|
+
if (model.version !== "0.5") {
|
|
529
|
+
const older = `koyu ${model.version} のファイルに 0.5 の語があります`;
|
|
530
|
+
for (const s of model.spaces.values()) {
|
|
531
|
+
const d = runDecls(s);
|
|
532
|
+
if (d.length > 0) {
|
|
533
|
+
emit("VER03", `${older}: ${s.path} の ${d[0].device}: (縦動線) — koyu 0.5 へ上げます`, {
|
|
534
|
+
line: s.line,
|
|
535
|
+
file: s.file,
|
|
536
|
+
path: [s.path],
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
for (const b of model.boundaries) {
|
|
541
|
+
if (b.drawn) {
|
|
542
|
+
emit("VER03", `${older}: ${b.a} | ${b.b} の line (描かれた線) — koyu 0.5 へ上げます`, {
|
|
543
|
+
line: b.drawn.line,
|
|
544
|
+
file: b.file,
|
|
545
|
+
path: [b.a, b.b],
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
for (const c of model.columns) {
|
|
550
|
+
emit("VER03", `${older}: column (柱) — koyu 0.5 へ上げます`, { line: c.line, file: c.file });
|
|
551
|
+
}
|
|
552
|
+
for (const l of Object.values(model.levels)) {
|
|
553
|
+
if (l.underground) {
|
|
554
|
+
emit("VER03", `${older}: level ${l.name} の underground: — koyu 0.5 へ上げます`, {
|
|
555
|
+
line: l.line,
|
|
556
|
+
file: l.file,
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
/** uid — UID01〜UID03 */
|
|
563
|
+
function checkUids(ctx) {
|
|
564
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
178
565
|
// uid (ADR-0015): 不透明トークン、space/zone横断でモデル全体一意。
|
|
179
566
|
// 数字だけの形は禁じる — parseの数値化で 0123 が 123 になり、書いたトークンの区別が失われる
|
|
180
567
|
const uidOwners = new Map();
|
|
@@ -207,110 +594,166 @@ export function checkDiagnostics(model) {
|
|
|
207
594
|
emit("UID03", `uid が重複しています: ${uid} (${owners.map((o) => `${o.kind} ${o.path} — ${srcRef(o.line, o.file)}`).join(", ")})`, { path: owners.map((o) => o.path), related: owners.map((o) => loc(o.line, o.file)) });
|
|
208
595
|
}
|
|
209
596
|
}
|
|
210
|
-
|
|
211
|
-
|
|
597
|
+
}
|
|
598
|
+
/** 境界の妥当性 — VRT / BND03〜06 / OPN / SEG */
|
|
599
|
+
function checkBoundaryValidity(ctx) {
|
|
600
|
+
const { model, emit } = ctx;
|
|
601
|
+
// 境界の妥当性。**一本のループを保つ** — 一つの境界が出す複数のコードは
|
|
602
|
+
// 走査の順に固まって出るので、コードの族で節に割ると並びが崩れる (ADR-0028)。
|
|
603
|
+
// ループの `continue` は「この境界の残りを飛ばす」を意味するので、
|
|
604
|
+
// 段に切り出すときは**呼び出し側の continue として残す** — 判定の綴りを
|
|
605
|
+
// ヘルパの中へ持ち込むと、同じ条件が二箇所に分かれて片方だけ直る
|
|
212
606
|
for (const b of model.boundaries) {
|
|
213
607
|
const sa = model.spaces.get(b.a);
|
|
214
608
|
const sb = model.spaces.get(b.b);
|
|
215
609
|
if (!sa || !sb)
|
|
216
|
-
continue;
|
|
610
|
+
continue; // 未定義の参照は REF01 が言う — 形の検査には進まない
|
|
217
611
|
const bAt = { line: b.line, file: b.file, path: [b.a, b.b] };
|
|
218
612
|
if (VERTICAL.has(b.kind)) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
emit("VRT01", `${b.kind} 境界は領域とレベルを持つ空間同士に書きます`, bAt);
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
const ia = levelIndex.get(sa.level);
|
|
225
|
-
const ib = levelIndex.get(sb.level);
|
|
226
|
-
if (ia === undefined || ib === undefined || Math.abs(ia - ib) !== 1) {
|
|
227
|
-
emit("VRT02", `${b.kind} 境界は隣り合うレベルの間に書きます: ${b.a} | ${b.b}`, bAt);
|
|
228
|
-
}
|
|
229
|
-
else if (!spacesOverlap(sa, sb)) {
|
|
230
|
-
emit("VRT03", `${b.kind} 境界の空間が平面上で重なっていません: ${b.a} | ${b.b}`, bAt);
|
|
231
|
-
}
|
|
232
|
-
if (b.kind === "void") {
|
|
233
|
-
const upper = (ia ?? 0) > (ib ?? 0) ? sa : sb;
|
|
234
|
-
if (upper.type !== "void") {
|
|
235
|
-
emit("VRT04", `void境界の上側は type:void の空間を想定しています: ${upper.path}`, bAt);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
if (b.openings.length > 0) {
|
|
239
|
-
emit("VRT05", `垂直境界の開口は解釈されません`, bAt);
|
|
240
|
-
}
|
|
241
|
-
if (b.segs.length > 0) {
|
|
242
|
-
emit("VRT06", `垂直境界の seg は解釈されません`, bAt);
|
|
243
|
-
}
|
|
244
|
-
continue;
|
|
613
|
+
checkVerticalBoundary(ctx, b, sa, sb, bAt);
|
|
614
|
+
continue; // 垂直境界は水平の検査 (線分・開口・seg) を一切受けない
|
|
245
615
|
}
|
|
246
|
-
// 水平境界
|
|
247
616
|
if (sa.rects.length > 0 && sb.rects.length > 0 && sa.level !== sb.level) {
|
|
248
617
|
emit("BND03", `異なるレベルの空間に壁境界は書けません (垂直は type:stair/shaft/void): ${b.a} | ${b.b}`, bAt);
|
|
249
|
-
continue;
|
|
618
|
+
continue; // レベルを跨ぐ壁は成立していない — 線分も開口も問わない
|
|
250
619
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
620
|
+
checkBoundarySegments(ctx, b, sa, sb, bAt);
|
|
621
|
+
checkOpenings(ctx, b);
|
|
622
|
+
checkBoundarySegs(ctx, b);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
/** 垂直境界 (stair/shaft/void) — VRT01〜VRT06 */
|
|
626
|
+
function checkVerticalBoundary(ctx, b, sa, sb, bAt) {
|
|
627
|
+
const { emit, levelIndex } = ctx;
|
|
628
|
+
// 垂直境界: 隣り合うレベルの、平面で重なる空間同士にしか張れない
|
|
629
|
+
if (sa.rects.length === 0 || sb.rects.length === 0 || !sa.level || !sb.level) {
|
|
630
|
+
emit("VRT01", `${b.kind} 境界は領域とレベルを持つ空間同士に書きます`, bAt);
|
|
631
|
+
return; // 前提が崩れているので、以降の判定は意味を持たない
|
|
632
|
+
}
|
|
633
|
+
const ia = levelIndex.get(sa.level);
|
|
634
|
+
const ib = levelIndex.get(sb.level);
|
|
635
|
+
if (ia === undefined || ib === undefined || Math.abs(ia - ib) !== 1) {
|
|
636
|
+
emit("VRT02", `${b.kind} 境界は隣り合うレベルの間に書きます: ${b.a} | ${b.b}`, bAt);
|
|
637
|
+
}
|
|
638
|
+
else if (!spacesOverlap(sa, sb)) {
|
|
639
|
+
emit("VRT03", `${b.kind} 境界の空間が平面上で重なっていません: ${b.a} | ${b.b}`, bAt);
|
|
640
|
+
}
|
|
641
|
+
if (b.kind === "void") {
|
|
642
|
+
const upper = (ia ?? 0) > (ib ?? 0) ? sa : sb;
|
|
643
|
+
if (upper.type !== "void") {
|
|
644
|
+
emit("VRT04", `void境界の上側は type:void の空間を想定しています: ${upper.path}`, bAt);
|
|
254
645
|
}
|
|
255
|
-
|
|
256
|
-
|
|
646
|
+
}
|
|
647
|
+
// 咎めているのは字下げされた door / window / seg の行そのものなので、
|
|
648
|
+
// 親の境界宣言ではなくその行を指す。宣言が複数あれば診断も複数出る
|
|
649
|
+
for (const o of b.openings) {
|
|
650
|
+
emit("VRT05", `垂直境界の${o.kind}は解釈されません`, { line: o.line, file: b.file, path: [b.a, b.b] });
|
|
651
|
+
}
|
|
652
|
+
for (const g of b.segs) {
|
|
653
|
+
emit("VRT06", `垂直境界の seg は解釈されません`, { line: g.line, file: b.file, path: [b.a, b.b] });
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
/** 水平境界の線分がゼロ — BND04 / BND06 */
|
|
657
|
+
function checkBoundarySegments(ctx, b, sa, sb, bAt) {
|
|
658
|
+
const { model, emit } = ctx;
|
|
659
|
+
// 線を持つ境界の線分ゼロは「接していない」ではない — 線が分離していないか
|
|
660
|
+
// 何も切っていないかであり、それは LIN01 / LIN03 が言う
|
|
661
|
+
if (b.drawn)
|
|
662
|
+
return;
|
|
663
|
+
const segs = segmentsFor(model, b);
|
|
664
|
+
if (sa.rects.length > 0 && sb.rects.length > 0 && segs.length === 0) {
|
|
665
|
+
// **線分がゼロの理由は二つある。**接していないか、edge: で絞った先に共有辺が
|
|
666
|
+
// 無いか。前者だと断言すると、実際には接している二室について「割付を直せ」と
|
|
667
|
+
// 言うことになる — 直すべきは方角一語である (N=+Y, S=-Y, E=+X, W=-X)
|
|
668
|
+
const without = b.edge ? segmentsFor(model, { ...b, edge: undefined }) : [];
|
|
669
|
+
if (without.length > 0) {
|
|
670
|
+
const dirs = [...new Set(without.map((g) => g.edgeOfA))].filter((d) => d !== undefined);
|
|
671
|
+
emit("BND04", `edge:${b.edge} に共有辺がありません: ${b.a} | ${b.b} (実際に接しているのは ${dirs.join("・") || "別の辺"} です)`, bAt);
|
|
257
672
|
}
|
|
258
|
-
|
|
259
|
-
emit("
|
|
673
|
+
else {
|
|
674
|
+
emit("BND04", `空間が接していないため境界を導けません: ${b.a} | ${b.b}`, bAt);
|
|
260
675
|
}
|
|
261
|
-
|
|
676
|
+
}
|
|
677
|
+
if ((sa.rects.length > 0 ? 1 : 0) + (sb.rects.length > 0 ? 1 : 0) === 1 && segs.length === 0) {
|
|
678
|
+
emit("BND06", `${b.edge ? `edge:${b.edge} の` : ""}外周に残る辺が無く、境界線分がゼロです: ${b.a} | ${b.b}`, bAt);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* 開口 — OPN03 / 配置エラー (OPN04〜08) / OPN01 / OPN02。
|
|
683
|
+
* **一つの関数に保つ** — 配置に失敗した開口は OPN01 も受けず OPN02 の母集団からも外れる。
|
|
684
|
+
* 配置の結果 (placedOnSeg) を跨いで持つのはここだけである
|
|
685
|
+
*/
|
|
686
|
+
function checkOpenings(ctx, b) {
|
|
687
|
+
const { model, emit, loc } = ctx;
|
|
688
|
+
if (b.kind === "open" && b.openings.length > 0) {
|
|
262
689
|
for (const o of b.openings) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
if ("segment" in placed) {
|
|
269
|
-
const s = placed.segment;
|
|
270
|
-
placedOnSeg.push({
|
|
271
|
-
o,
|
|
272
|
-
key: `${s.x1},${s.y1},${s.x2},${s.y2}`,
|
|
273
|
-
c: s.horizontal ? placed.cx : placed.cy,
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
if (o.hinge && "segment" in placed) {
|
|
277
|
-
const okAxis = placed.segment.horizontal
|
|
278
|
-
? o.hinge === "W" || o.hinge === "E"
|
|
279
|
-
: o.hinge === "N" || o.hinge === "S";
|
|
280
|
-
if (!okAxis) {
|
|
281
|
-
emit("OPN01", `hinge:${o.hinge} は${placed.segment.horizontal ? "水平線分 (W/E)" : "垂直線分 (N/S)"}で指定します`, { line: o.line, file: b.file, path: [b.a, b.b] });
|
|
282
|
-
}
|
|
283
|
-
}
|
|
690
|
+
emit("OPN03", `open境界の${o.kind}は通行に影響しません (常に通れます)`, {
|
|
691
|
+
line: o.line,
|
|
692
|
+
file: b.file,
|
|
693
|
+
path: [b.a, b.b],
|
|
694
|
+
});
|
|
284
695
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
}
|
|
696
|
+
}
|
|
697
|
+
const placedOnSeg = [];
|
|
698
|
+
for (const o of b.openings) {
|
|
699
|
+
const placed = placeOpening(model, b, o);
|
|
700
|
+
if ("error" in placed && placed.error) {
|
|
701
|
+
emit(placed.code, placed.message, { line: placed.line, file: placed.file, path: [b.a, b.b] });
|
|
702
|
+
continue; // 置けなかった開口は、以降 (hinge の軸・重なり) の対象にならない
|
|
703
|
+
}
|
|
704
|
+
if ("segment" in placed) {
|
|
705
|
+
const s = placed.segment;
|
|
706
|
+
placedOnSeg.push({
|
|
707
|
+
o,
|
|
708
|
+
key: `${s.x1},${s.y1},${s.x2},${s.y2}`,
|
|
709
|
+
c: s.horizontal ? placed.cx : placed.cy,
|
|
710
|
+
});
|
|
302
711
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
712
|
+
if (o.hinge && "segment" in placed) {
|
|
713
|
+
const okAxis = placed.segment.horizontal
|
|
714
|
+
? o.hinge === "W" || o.hinge === "E"
|
|
715
|
+
: o.hinge === "N" || o.hinge === "S";
|
|
716
|
+
if (!okAxis) {
|
|
717
|
+
emit("OPN01", `hinge:${o.hinge} は${placed.segment.horizontal ? "水平線分 (W/E)" : "垂直線分 (N/S)"}で指定します`, { line: o.line, file: b.file, path: [b.a, b.b] });
|
|
307
718
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
// 同じ線分の上の開口同士は重なってはならない
|
|
722
|
+
const byKey = new Map();
|
|
723
|
+
for (const p of placedOnSeg) {
|
|
724
|
+
const arr = byKey.get(p.key) ?? [];
|
|
725
|
+
arr.push(p);
|
|
726
|
+
byKey.set(p.key, arr);
|
|
727
|
+
}
|
|
728
|
+
for (const group of byKey.values()) {
|
|
729
|
+
group.sort((p, q) => p.c - q.c);
|
|
730
|
+
for (let k = 0; k + 1 < group.length; k++) {
|
|
731
|
+
const p = group[k];
|
|
732
|
+
const q = group[k + 1];
|
|
733
|
+
const need = (p.o.w + q.o.w) / 2;
|
|
734
|
+
if (q.c - p.c < need - EPS) {
|
|
735
|
+
emit("OPN02", `開口同士が重なっています (${p.o.kind}と${q.o.kind} — 中心間 ${Math.round(q.c - p.c)}mm < 必要 ${Math.round(need)}mm)`, { line: q.o.line, file: b.file, path: [b.a, b.b], related: [loc(p.o.line, b.file)] });
|
|
311
736
|
}
|
|
312
737
|
}
|
|
313
738
|
}
|
|
739
|
+
}
|
|
740
|
+
/** 数えない分節 (seg) の配置 — SEG03 / SEG04〜08 */
|
|
741
|
+
function checkBoundarySegs(ctx, b) {
|
|
742
|
+
const { model, emit } = ctx;
|
|
743
|
+
for (const g of b.segs) {
|
|
744
|
+
if (b.kind === "open") {
|
|
745
|
+
emit("SEG03", `open境界 (壁が無い) の seg は解釈されません`, { line: g.line, file: b.file, path: [b.a, b.b] });
|
|
746
|
+
continue;
|
|
747
|
+
}
|
|
748
|
+
const placed = placeBand(model, b, g, "seg");
|
|
749
|
+
if ("error" in placed && placed.error) {
|
|
750
|
+
emit(placed.code, placed.message, { line: placed.line, file: placed.file, path: [b.a, b.b] });
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
/** 数えない分節 — SEG01 / SEG02 */
|
|
755
|
+
function checkAreas(ctx) {
|
|
756
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
314
757
|
// 数えない分節 (area) は親の領域に収まっているか
|
|
315
758
|
for (const s of model.spaces.values()) {
|
|
316
759
|
for (const a of s.areas) {
|
|
@@ -322,15 +765,17 @@ export function checkDiagnostics(model) {
|
|
|
322
765
|
});
|
|
323
766
|
continue;
|
|
324
767
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
a.rect.y1 >= r.y1 - EPS &&
|
|
328
|
-
a.rect.y2 <= r.y2 + EPS);
|
|
768
|
+
// 内包も導出された形で見る — 割付で見ると、切り落とした側に置いた床材が通ってしまう
|
|
769
|
+
const inside = regionOf(s).some((g) => rectToPoly(a.rect).every((pt) => pointInPolygon(pt, g, EPS)));
|
|
329
770
|
if (!inside) {
|
|
330
771
|
emit("SEG02", `area が ${s.path} の領域からはみ出しています`, { line: a.line, file: s.file, path: [s.path] });
|
|
331
772
|
}
|
|
332
773
|
}
|
|
333
774
|
}
|
|
775
|
+
}
|
|
776
|
+
/** ゾーン — ZON01 / ZON02 */
|
|
777
|
+
function checkZones(ctx) {
|
|
778
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
334
779
|
// ゾーン: 束ねる空間が実在するか
|
|
335
780
|
for (const z of model.zones.values()) {
|
|
336
781
|
const children = [...model.spaces.keys()].filter((p) => p.startsWith(z.path + "/"));
|
|
@@ -345,6 +790,10 @@ export function checkDiagnostics(model) {
|
|
|
345
790
|
});
|
|
346
791
|
}
|
|
347
792
|
}
|
|
793
|
+
}
|
|
794
|
+
/** 高さ方向の一貫性 — HGT01〜HGT04 */
|
|
795
|
+
function checkHeights(ctx) {
|
|
796
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
348
797
|
// 高さ方向の一貫性: 下階の空間の天井高 + 上階のslab ≤ 階高
|
|
349
798
|
// 吹抜け (void境界) は宣言的な免除だが、免除が効くのは吹抜けが平面を覆う範囲まで —
|
|
350
799
|
// 部分吹抜けでは下階の天井高は階高内に収める (吹抜け部分の高さは導出) (ADR-0006追記)
|
|
@@ -383,6 +832,11 @@ export function checkDiagnostics(model) {
|
|
|
383
832
|
for (const s of below) {
|
|
384
833
|
if (isSemiOutdoor(model, s))
|
|
385
834
|
continue; // 屋外・半屋外 (庭・バルコニー等) に天井は無い
|
|
835
|
+
// 縦動線の宣言的免除 (ADR-0021)。void の免除が「床の不在」だったのに対し、
|
|
836
|
+
// こちらは「天井が面でない」— 階段室・斜路の天井は上の走りに沿って傾いている。
|
|
837
|
+
// h を一つの数で語れない以上、この不変量は成立しない。頭上高さの検査は別の問い
|
|
838
|
+
if (runDecls(s).length > 0)
|
|
839
|
+
continue;
|
|
386
840
|
const covered = above.some((u) => spacesOverlap(s, u)) || above.length === 0;
|
|
387
841
|
if (!covered)
|
|
388
842
|
continue;
|
|
@@ -392,7 +846,11 @@ export function checkDiagnostics(model) {
|
|
|
392
846
|
}
|
|
393
847
|
const h = heff(model, s);
|
|
394
848
|
if (h === undefined) {
|
|
395
|
-
emit("HGT04", `${s.path} の天井高が不明で、${lu.name} との高さ検査ができません`, {
|
|
849
|
+
emit("HGT04", `${s.path} の天井高が不明で、${lu.name} との高さ検査ができません`, {
|
|
850
|
+
line: s.line,
|
|
851
|
+
file: s.file,
|
|
852
|
+
path: [s.path],
|
|
853
|
+
});
|
|
396
854
|
continue;
|
|
397
855
|
}
|
|
398
856
|
if (h + lu.slab > pitch + EPS) {
|
|
@@ -401,17 +859,27 @@ export function checkDiagnostics(model) {
|
|
|
401
859
|
if (cover >= 0.99)
|
|
402
860
|
continue; // 全面吹抜け — 宣言的免除
|
|
403
861
|
if (partners.length) {
|
|
404
|
-
|
|
862
|
+
// 本文は HGT01 と同じ三項を出す — 決め手が上階の slab のとき
|
|
863
|
+
// 「天井高3000は階高3000を超えます」という成り立たない不等式になっていた。
|
|
864
|
+
// 被覆は免除しきい値 (99%) と衝突しないよう小数一桁で言う
|
|
865
|
+
emit("HGT02", `${s.path} が上階に食い込みます: 天井高${h} + ${lu.name}のslab${lu.slab} = ${h + lu.slab} > 階高${pitch}。吹抜けの被覆は${(cover * 100).toFixed(1)}%しかありません — 部分吹抜けでは天井高を階高内に収めます (吹抜け部分の高さは導出)`, { line: s.line, file: s.file, path: [s.path] });
|
|
405
866
|
}
|
|
406
867
|
else {
|
|
407
|
-
emit("HGT01", `${s.path} が上階に食い込みます: 天井高${h} + ${lu.name}のslab${lu.slab} = ${h + lu.slab} > 階高${pitch}`, { path: [s.path] });
|
|
868
|
+
emit("HGT01", `${s.path} が上階に食い込みます: 天井高${h} + ${lu.name}のslab${lu.slab} = ${h + lu.slab} > 階高${pitch}`, { line: s.line, file: s.file, path: [s.path] });
|
|
408
869
|
}
|
|
409
870
|
}
|
|
410
871
|
}
|
|
411
872
|
if (slabMissing) {
|
|
412
|
-
emit("HGT03", `レベル ${lu.name} に slab が未宣言のため、${lb.name}
|
|
873
|
+
emit("HGT03", `レベル ${lu.name} に slab が未宣言のため、${lb.name} との高さ検査ができません`, {
|
|
874
|
+
line: lu.line,
|
|
875
|
+
file: lu.file,
|
|
876
|
+
});
|
|
413
877
|
}
|
|
414
878
|
}
|
|
879
|
+
}
|
|
880
|
+
/** レベルに載らない空間 — HGT05 */
|
|
881
|
+
function checkOrphanSpaces(ctx) {
|
|
882
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
415
883
|
// レベルに載らない領域つき空間
|
|
416
884
|
for (const s of withRect) {
|
|
417
885
|
if (!s.level) {
|
|
@@ -422,6 +890,10 @@ export function checkDiagnostics(model) {
|
|
|
422
890
|
});
|
|
423
891
|
}
|
|
424
892
|
}
|
|
893
|
+
}
|
|
894
|
+
/** 敷地形状 — SIT01〜SIT05 */
|
|
895
|
+
function checkSite(ctx) {
|
|
896
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
425
897
|
// 敷地形状 (ADR-0011): 形の妥当性、対応ゾーンの存在、宣言面積との照合、建物のはみ出し検査。
|
|
426
898
|
// はみ出しは四隅の内包に加え、多角形の頂点の入り込みと辺の交差を見る — 凹敷地でも正しい (ADR-0013)。
|
|
427
899
|
// 地上の外部空間タイル (庭・通路) は近似なので検査しない — 面積の真は多角形が持つ
|
|
@@ -467,8 +939,9 @@ export function checkDiagnostics(model) {
|
|
|
467
939
|
for (const s of withRect) {
|
|
468
940
|
if (s.type === "exterior" || s.path.startsWith(poly.path + "/"))
|
|
469
941
|
continue;
|
|
470
|
-
|
|
471
|
-
|
|
942
|
+
// 照合するのは割付ではなく**導出された領域** — 敷地なりに切った外形はここで通る
|
|
943
|
+
for (const r of regionOf(s)) {
|
|
944
|
+
const out = shapeEscapesPolygon(r, poly.points, EPS_SITE);
|
|
472
945
|
if (out) {
|
|
473
946
|
emit("SIT03", `${s.path} が敷地形状からはみ出しています (${Math.round(out.x)},${Math.round(out.y)} 付近)`, {
|
|
474
947
|
line: s.line,
|
|
@@ -480,21 +953,5 @@ export function checkDiagnostics(model) {
|
|
|
480
953
|
}
|
|
481
954
|
}
|
|
482
955
|
}
|
|
483
|
-
return diags;
|
|
484
|
-
}
|
|
485
|
-
/** 吹抜けが下階の空間の平面をどれだけ覆うか (0..1) */
|
|
486
|
-
function voidCoverage(s, partners) {
|
|
487
|
-
let inter = 0;
|
|
488
|
-
for (const r of s.rects) {
|
|
489
|
-
for (const p of partners) {
|
|
490
|
-
for (const pr of p.rects) {
|
|
491
|
-
const o = planOverlap(r, pr);
|
|
492
|
-
if (o)
|
|
493
|
-
inter += (o.x2 - o.x1) * (o.y2 - o.y1);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
const area = s.rects.reduce((sum, r) => sum + (r.x2 - r.x1) * (r.y2 - r.y1), 0);
|
|
498
|
-
return area > 0 ? inter / area : 0;
|
|
499
956
|
}
|
|
500
957
|
//# sourceMappingURL=check.js.map
|