@kensnzk/koyu 0.5.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +43 -11
- package/README.md +51 -11
- package/dist/axo.d.ts +16 -0
- package/dist/axo.d.ts.map +1 -0
- package/dist/axo.js +211 -0
- package/dist/axo.js.map +1 -0
- package/dist/check.d.ts +109 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +957 -0
- package/dist/check.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +410 -0
- package/dist/cli.js.map +1 -0
- package/dist/diff.d.ts +105 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +583 -0
- package/dist/diff.js.map +1 -0
- 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 +118 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +627 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/light.d.ts +15 -0
- package/dist/light.d.ts.map +1 -0
- package/dist/light.js +53 -0
- package/dist/light.js.map +1 -0
- package/dist/mcp.d.ts +3 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +361 -0
- package/dist/mcp.js.map +1 -0
- package/dist/model.d.ts +379 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +464 -0
- package/dist/model.js.map +1 -0
- package/dist/parse-file.d.ts +9 -0
- package/dist/parse-file.d.ts.map +1 -0
- package/dist/parse-file.js +22 -0
- package/dist/parse-file.js.map +1 -0
- package/dist/parse.d.ts +16 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +1040 -0
- package/dist/parse.js.map +1 -0
- package/dist/plan.d.ts +10 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +354 -0
- package/dist/plan.js.map +1 -0
- 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 +24 -0
- package/dist/site.d.ts.map +1 -0
- package/dist/site.js +54 -0
- package/dist/site.js.map +1 -0
- 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 +84 -0
- package/examples/comparison/README.md +64 -1
- package/examples/comparison/gen-ifc4.ts +1 -1
- package/examples/comparison/gen-ifcx.ts +2 -2
- package/examples/comparison/two-rooms.ifcx +1 -1
- package/examples/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 +16 -0
- package/examples/house/L2.muro +19 -0
- package/examples/house/assets.muro +9 -0
- package/examples/house/main.muro +27 -0
- package/examples/house/site.muro +31 -0
- package/examples/house.muro +3 -3
- package/examples/mansion.muro +18 -13
- package/examples/office.muro +1 -1
- package/examples/steps/01-one-room.muro +4 -0
- package/examples/steps/02-two-rooms.muro +5 -0
- package/examples/steps/03-door.muro +9 -0
- package/examples/steps/04-exterior.muro +15 -0
- package/examples/steps/05-two-storeys.muro +27 -0
- package/examples/steps/06-finished.muro +30 -0
- package/examples/steps/README.md +25 -0
- package/examples/tower/L1.muro +80 -0
- package/examples/tower/L11.muro +49 -0
- package/examples/tower/L2.muro +71 -0
- package/examples/tower/L3.muro +31 -0
- package/examples/tower/assets.muro +14 -0
- package/examples/tower/main.muro +37 -0
- package/examples/tower/site-geometry.muro +7 -0
- package/examples/tower/site.muro +33 -0
- package/examples/tower/typical.muro +131 -0
- package/examples/two-rooms.canonical.json +30 -3
- package/examples/two-rooms.muro +11 -7
- package/package.json +29 -2
- package/src/axo.ts +258 -0
- package/src/check.ts +948 -122
- package/src/cli.ts +175 -12
- package/src/diff.ts +676 -0
- package/src/fabric.ts +123 -0
- package/src/graph.ts +451 -61
- package/src/index.ts +38 -2
- package/src/light.ts +4 -7
- package/src/mcp.ts +397 -0
- package/src/model.ts +462 -67
- package/src/parse-file.ts +28 -0
- package/src/parse.ts +682 -45
- package/src/plan.ts +152 -14
- package/src/poly.ts +295 -0
- package/src/site.ts +19 -11
- package/src/vertical.ts +884 -0
- package/.github/workflows/ci.yml +0 -16
- package/.zenodo.json +0 -20
- package/CITATION.cff +0 -26
- package/docs/decisions/0001-notation-v0.md +0 -29
- package/docs/decisions/0002-height-and-offsets.md +0 -27
- package/docs/decisions/0003-uncounted-divisions.md +0 -36
- package/docs/decisions/0004-typical-floors.md +0 -21
- package/docs/decisions/0005-zones-and-unions.md +0 -23
- package/docs/decisions/0006-voids-and-light.md +0 -31
- package/docs/decisions/0007-semi-outdoor-air.md +0 -27
- package/docs/decisions/0008-vocabulary-and-level-attr.md +0 -23
- package/docs/decisions/0009-site-and-exterior.md +0 -29
- package/docs/ifc-coverage.md +0 -82
- package/docs/ifcx-notes.md +0 -25
- package/docs/img/house-L1.svg +0 -80
- package/docs/img/house-L2.svg +0 -53
- package/docs/img/mansion-L1.svg +0 -113
- package/docs/img/mansion-L10.svg +0 -111
- package/docs/img/mansion-L5.svg +0 -160
- package/docs/img/office-L1.svg +0 -116
- package/docs/img/office-L2.svg +0 -109
- package/docs/img/two-rooms.svg +0 -39
- package/docs/log/2026-07-22.md +0 -13
- package/docs/log/2026-07-23.md +0 -51
- package/docs/roadmap.md +0 -55
- package/docs/writing-architecture.md +0 -119
- package/spec/notation-v0.md +0 -164
- package/spec/vocabulary.md +0 -62
- package/test/core.test.ts +0 -171
- package/test/design2.test.ts +0 -97
- package/test/house.test.ts +0 -74
- package/test/mansion.test.ts +0 -99
- package/test/office.test.ts +0 -71
- package/test/uncounted.test.ts +0 -120
- package/test/vertical.test.ts +0 -75
- package/tsconfig.json +0 -13
package/src/graph.ts
CHANGED
|
@@ -3,15 +3,20 @@
|
|
|
3
3
|
// 変換なしにそのままグラフへの問いになる。
|
|
4
4
|
// 空間の領域は矩形の合併 (L字など)。壁は合併の外周と共有辺から導出される。
|
|
5
5
|
|
|
6
|
-
import type { Boundary, Edge, Model, Opening, Rect, Space } from "./model.js";
|
|
6
|
+
import type { Boundary, Edge, Model, Opening, Pt, Rect, Space } from "./model.js";
|
|
7
|
+
import { rectToPoly, srcRef } from "./model.js";
|
|
8
|
+
import * as poly from "./poly.js";
|
|
7
9
|
|
|
8
|
-
/** 壁芯線分 (mm)。水平なら y1===y2、垂直なら x1===x2
|
|
10
|
+
/** 壁芯線分 (mm)。水平なら y1===y2、垂直なら x1===x2。
|
|
11
|
+
* 描かれた線 (ADR-0022) は斜めになりうる — その場合 diagonal が立つ */
|
|
9
12
|
export interface Segment {
|
|
10
13
|
x1: number;
|
|
11
14
|
y1: number;
|
|
12
15
|
x2: number;
|
|
13
16
|
y2: number;
|
|
14
17
|
horizontal: boolean;
|
|
18
|
+
/** 軸に平行でない (描かれた線) */
|
|
19
|
+
diagonal?: boolean;
|
|
15
20
|
/** boundary.a 側 (領域を持つ側) の矩形から見た辺 */
|
|
16
21
|
edgeOfA?: Edge;
|
|
17
22
|
}
|
|
@@ -45,36 +50,96 @@ export function sharedSegment(a: Rect, b: Rect): Segment | undefined {
|
|
|
45
50
|
return undefined;
|
|
46
51
|
}
|
|
47
52
|
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
let
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
53
|
+
/**
|
|
54
|
+
* 凸片の軸平行な辺 (向きから N/E/S/W を読む)。頂点列は反時計回りなので、
|
|
55
|
+
* +x へ進む辺が南、+y が東、-x が北、-y が西の面になる。
|
|
56
|
+
* 斜めの辺は返さない — それは描かれた線であり、自分の境界が実現を持っている
|
|
57
|
+
*/
|
|
58
|
+
function polyEdges(poly: Pt[]): Array<{ edge: Edge; fixed: number; lo: number; hi: number }> {
|
|
59
|
+
const out: Array<{ edge: Edge; fixed: number; lo: number; hi: number }> = [];
|
|
60
|
+
for (let i = 0; i < poly.length; i++) {
|
|
61
|
+
const p = poly[i]!;
|
|
62
|
+
const q = poly[(i + 1) % poly.length]!;
|
|
63
|
+
const dx = q.x - p.x;
|
|
64
|
+
const dy = q.y - p.y;
|
|
65
|
+
if (Math.abs(dy) < EPS && Math.abs(dx) > EPS) {
|
|
66
|
+
out.push({
|
|
67
|
+
edge: dx > 0 ? "S" : "N",
|
|
68
|
+
fixed: p.y,
|
|
69
|
+
lo: Math.min(p.x, q.x),
|
|
70
|
+
hi: Math.max(p.x, q.x),
|
|
71
|
+
});
|
|
72
|
+
} else if (Math.abs(dx) < EPS && Math.abs(dy) > EPS) {
|
|
73
|
+
out.push({
|
|
74
|
+
edge: dy > 0 ? "E" : "W",
|
|
75
|
+
fixed: p.x,
|
|
76
|
+
lo: Math.min(p.y, q.y),
|
|
77
|
+
hi: Math.max(p.y, q.y),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
72
80
|
}
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const FACING: Record<Edge, Edge> = { N: "S", S: "N", E: "W", W: "E" };
|
|
85
|
+
|
|
86
|
+
/** 凸片の外周のうち、他の空間の凸片と向かい合っていない区間 (= 外部に面する壁) */
|
|
87
|
+
function pieceOutline(pieces: Pt[][], others: Pt[][]): Segment[] {
|
|
88
|
+
const otherEdges = others.flatMap(polyEdges);
|
|
89
|
+
const segs: Segment[] = [];
|
|
90
|
+
for (let i = 0; i < pieces.length; i++) {
|
|
91
|
+
const siblings = pieces.filter((_, k) => k !== i).flatMap(polyEdges);
|
|
92
|
+
for (const e of polyEdges(pieces[i]!)) {
|
|
93
|
+
let intervals: Array<[number, number]> = [[e.lo, e.hi]];
|
|
94
|
+
for (const o of [...otherEdges, ...siblings]) {
|
|
95
|
+
if (o.edge !== FACING[e.edge]) continue;
|
|
96
|
+
if (Math.abs(o.fixed - e.fixed) > EPS) continue;
|
|
97
|
+
intervals = intervals.flatMap(([s, t]) => {
|
|
98
|
+
const cs = Math.max(s, o.lo);
|
|
99
|
+
const ce = Math.min(t, o.hi);
|
|
100
|
+
if (ce - cs <= EPS) return [[s, t] as [number, number]];
|
|
101
|
+
const out: Array<[number, number]> = [];
|
|
102
|
+
if (cs - s > EPS) out.push([s, cs]);
|
|
103
|
+
if (t - ce > EPS) out.push([ce, t]);
|
|
104
|
+
return out;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
const horizontal = e.edge === "N" || e.edge === "S";
|
|
108
|
+
for (const [s, t] of intervals) {
|
|
109
|
+
segs.push(
|
|
110
|
+
horizontal
|
|
111
|
+
? { x1: s, y1: e.fixed, x2: t, y2: e.fixed, horizontal: true, edgeOfA: e.edge }
|
|
112
|
+
: { x1: e.fixed, y1: s, x2: e.fixed, y2: t, horizontal: false, edgeOfA: e.edge },
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return segs;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 二つの領域 (凸片の集合) が共有する軸平行な辺。
|
|
122
|
+
* `sharedSegment` の矩形版を凸片へ広げたもので、切られた形にも正しい。
|
|
123
|
+
* 斜めの辺は返さない — それは描かれた線であり、自分の境界が実現を持っている
|
|
124
|
+
*/
|
|
125
|
+
function sharedFromPieces(A: Pt[][], B: Pt[][]): Segment[] {
|
|
126
|
+
const eb = B.flatMap(polyEdges);
|
|
127
|
+
const out: Segment[] = [];
|
|
128
|
+
for (const ea of A.flatMap(polyEdges)) {
|
|
129
|
+
for (const o of eb) {
|
|
130
|
+
if (o.edge !== FACING[ea.edge]) continue;
|
|
131
|
+
if (Math.abs(o.fixed - ea.fixed) > EPS) continue;
|
|
132
|
+
const lo = Math.max(ea.lo, o.lo);
|
|
133
|
+
const hi = Math.min(ea.hi, o.hi);
|
|
134
|
+
if (hi - lo <= EPS) continue;
|
|
135
|
+
out.push(
|
|
136
|
+
ea.edge === "N" || ea.edge === "S"
|
|
137
|
+
? { x1: lo, y1: ea.fixed, x2: hi, y2: ea.fixed, horizontal: true, edgeOfA: ea.edge }
|
|
138
|
+
: { x1: ea.fixed, y1: lo, x2: ea.fixed, y2: hi, horizontal: false, edgeOfA: ea.edge },
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
78
143
|
}
|
|
79
144
|
|
|
80
145
|
/** 共線で連続する線分をまとめる (L字の合併外周を一本の壁にする) */
|
|
@@ -107,6 +172,134 @@ export function mergeCollinear(segs: Segment[]): Segment[] {
|
|
|
107
172
|
return out;
|
|
108
173
|
}
|
|
109
174
|
|
|
175
|
+
/**
|
|
176
|
+
* 既定境界の導出 (ADR-0014) — 垂直の「既定は床」と対称の、水平の「既定は壁」。
|
|
177
|
+
* 同一レベル (未特定同士を含む) で平面が接する領域つき空間の組に、宣言境界がその組に
|
|
178
|
+
* 一つも無ければ kind:wall の既定境界を導く。宣言は例外 (open・手すり) と属性のためにある。
|
|
179
|
+
* 領域を持たない空間 (exterior等) との境界は導かない — 相手の名指しが情報のため宣言する。
|
|
180
|
+
* 合成・スパン展開の完了後に呼ぶ (parse / parseWith の出口)。冪等。
|
|
181
|
+
*/
|
|
182
|
+
export function deriveDefaultBoundaries(model: Model): void {
|
|
183
|
+
const declared = new Set<string>();
|
|
184
|
+
for (const b of model.boundaries) declared.add([b.a, b.b].sort().join("|"));
|
|
185
|
+
const withRect = [...model.spaces.values()].filter((s) => s.rects.length > 0);
|
|
186
|
+
for (let i = 0; i < withRect.length; i++) {
|
|
187
|
+
for (let j = i + 1; j < withRect.length; j++) {
|
|
188
|
+
const a = withRect[i]!;
|
|
189
|
+
const b = withRect[j]!;
|
|
190
|
+
if (a.level !== b.level) continue;
|
|
191
|
+
const key = [a.path, b.path].sort().join("|");
|
|
192
|
+
if (declared.has(key)) continue;
|
|
193
|
+
// 接触は**導出された形**で見る — 線で接触が消えた組に既定の壁を作らない
|
|
194
|
+
if (sharedFromPieces(piecesOf(a), piecesOf(b)).length === 0) continue;
|
|
195
|
+
model.boundaries.push({
|
|
196
|
+
a: a.path,
|
|
197
|
+
b: b.path,
|
|
198
|
+
kind: "wall",
|
|
199
|
+
derived: true,
|
|
200
|
+
attrs: {},
|
|
201
|
+
openings: [],
|
|
202
|
+
segs: [],
|
|
203
|
+
line: 0,
|
|
204
|
+
});
|
|
205
|
+
declared.add(key);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* 描かれた線による領域の切り分け (ADR-0022)。
|
|
212
|
+
*
|
|
213
|
+
* 空間の `rects` は**書かれた割付** (セル) であって形ではない。形は凸片 `pieces` として
|
|
214
|
+
* ここで導かれる — 既定は矩形そのまま、境界に線が描かれていればその半平面で切り直す。
|
|
215
|
+
* 切り直しは「二空間の割付の合併を、線の両側へ分け直す」操作なので、
|
|
216
|
+
* 一方が失う三角形をもう一方が得る (合計面積は保存される)。
|
|
217
|
+
*
|
|
218
|
+
* 線の及ぶ範囲は**書かれた区間の外接矩形**に限る。無限直線として全体を切ると、
|
|
219
|
+
* 離れた翼まで巻き添えにするため。冪等ではないので parse の出口で一度だけ呼ぶ。
|
|
220
|
+
*/
|
|
221
|
+
export function derivePieces(model: Model): void {
|
|
222
|
+
for (const s of model.spaces.values()) s.pieces = s.rects.map(rectToPoly);
|
|
223
|
+
// 線は宣言順に効く。derivePieces は parse の出口で一度だけ呼ぶ (冪等ではない)
|
|
224
|
+
|
|
225
|
+
for (const b of model.boundaries) {
|
|
226
|
+
if (!b.drawn) continue;
|
|
227
|
+
const sa = model.spaces.get(b.a);
|
|
228
|
+
const sb = model.spaces.get(b.b);
|
|
229
|
+
if (!sa || !sb) continue;
|
|
230
|
+
const cut = drawnCut(sa, sb, b.drawn.a, b.drawn.b);
|
|
231
|
+
if (!cut) continue;
|
|
232
|
+
|
|
233
|
+
if (cut.solo) {
|
|
234
|
+
// 外皮を切る線 — 持つ側だけが窓の中で自分の側へ切り落とされる。相手は面積を得ない
|
|
235
|
+
const s = cut.solo;
|
|
236
|
+
const { inside, outside } = poly.splitByRect(s.pieces, cut.window);
|
|
237
|
+
s.pieces = [
|
|
238
|
+
...outside,
|
|
239
|
+
...inside.map((p) => poly.clipHalf(p, b.drawn!.a, b.drawn!.b, cut.sideA > 0)).filter((p) => p.length > 0),
|
|
240
|
+
];
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// 二空間の分け直し — 窓の中の割付を合併し、線の両側へ分け直す (合計面積は保存される)
|
|
245
|
+
const splitA = poly.splitByRect(sa.pieces, cut.window);
|
|
246
|
+
const splitB = poly.splitByRect(sb.pieces, cut.window);
|
|
247
|
+
const pool = [...splitA.inside, ...splitB.inside];
|
|
248
|
+
if (pool.length === 0) continue;
|
|
249
|
+
sa.pieces = [
|
|
250
|
+
...splitA.outside,
|
|
251
|
+
...pool.map((p) => poly.clipHalf(p, b.drawn!.a, b.drawn!.b, cut.sideA > 0)).filter((p) => p.length > 0),
|
|
252
|
+
];
|
|
253
|
+
sb.pieces = [
|
|
254
|
+
...splitB.outside,
|
|
255
|
+
...pool.map((p) => poly.clipHalf(p, b.drawn!.a, b.drawn!.b, cut.sideA < 0)).filter((p) => p.length > 0),
|
|
256
|
+
];
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* 描かれた線の切り方を一度に決める — 窓・残す側・片側かどうか (ADR-0022 / ADR-0027)。
|
|
262
|
+
*
|
|
263
|
+
* **窓と側は必ず一緒に決める。**別々に決めていたために、側は空間の全割付を無限直線で
|
|
264
|
+
* 測るのに切るのは線の近傍だけ、という母集団のずれが生まれ、線から遠い翼が符号を
|
|
265
|
+
* 支配して、残すつもりだった側が黙って切り落とされた (check は緑のまま)。
|
|
266
|
+
* check の LIN01/LIN03 もこの同じ関数を通す — 判定と操作が食い違わないために。
|
|
267
|
+
*/
|
|
268
|
+
export function drawnCut(
|
|
269
|
+
sa: Space,
|
|
270
|
+
sb: Space,
|
|
271
|
+
a: Pt,
|
|
272
|
+
b: Pt,
|
|
273
|
+
): { window: Rect; sideA: number; solo?: Space } | undefined {
|
|
274
|
+
const ba = poly.boundsOf(sa.pieces);
|
|
275
|
+
const bb = poly.boundsOf(sb.pieces);
|
|
276
|
+
// 片側が領域を持たない (外部) — 外皮を切る線
|
|
277
|
+
if (!ba || !bb) {
|
|
278
|
+
const solo = ba ? sa : bb ? sb : undefined;
|
|
279
|
+
const sb2 = ba ?? bb;
|
|
280
|
+
if (!solo || !sb2) return undefined;
|
|
281
|
+
const w = poly.lineWindow(a, b, sb2);
|
|
282
|
+
if (!poly.validWindow(w)) return undefined;
|
|
283
|
+
const side = poly.sideOfTouching(solo.pieces, w, a, b);
|
|
284
|
+
if (side === 0) return undefined; // 窓の中でちょうど二等分 — 残す側が決まらない (LIN01)
|
|
285
|
+
return { window: w, sideA: solo === sa ? side : -side, solo };
|
|
286
|
+
}
|
|
287
|
+
const w = poly.lineWindow(a, b, ba, bb);
|
|
288
|
+
if (!poly.validWindow(w)) return undefined;
|
|
289
|
+
let ia = poly.sideOfTouching(sa.pieces, w, a, b);
|
|
290
|
+
let ib = poly.sideOfTouching(sb.pieces, w, a, b);
|
|
291
|
+
if (ia === 0 && ib === 0) return undefined; // どちらも偏りなし — 分離が決まらない (LIN01)
|
|
292
|
+
if (ia === 0) ia = -ib;
|
|
293
|
+
if (ib === 0) ib = -ia;
|
|
294
|
+
if (ia === ib) return undefined; // 同じ側 — 分離していない (LIN01)
|
|
295
|
+
return { window: w, sideA: ia };
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
110
303
|
/** 境界の壁芯線分を導く。壁の位置は空間の割付から生成される — 壁を置く操作は存在しない */
|
|
111
304
|
export function segmentsFor(model: Model, b: Boundary): Segment[] {
|
|
112
305
|
const sa = model.spaces.get(b.a);
|
|
@@ -116,43 +309,181 @@ export function segmentsFor(model: Model, b: Boundary): Segment[] {
|
|
|
116
309
|
// 垂直境界 (stair/shaft/void/暗黙のslab) は壁線分を持たない
|
|
117
310
|
if (b.kind === "stair" || b.kind === "shaft" || b.kind === "void") return [];
|
|
118
311
|
|
|
312
|
+
// 描かれた線 (ADR-0022): 隣接からの導出ではなく、書かれた線がそのまま境界の実現になる。
|
|
313
|
+
// ただし**一本の設計線は複数の境界に共有されうる** — 貫通通路の壁は、その前を通る
|
|
314
|
+
// 区画の数だけ境界を持つ。この境界が実現するのは、線の両側がちょうど a と b に
|
|
315
|
+
// なっている区間だけであり、線の全長ではない
|
|
316
|
+
if (b.drawn) return drawnShare(model, sa, sb, b.drawn.a, b.drawn.b);
|
|
317
|
+
|
|
119
318
|
let segs: Segment[] = [];
|
|
120
319
|
const aHas = sa.rects.length > 0;
|
|
121
320
|
const bHas = sb.rects.length > 0;
|
|
122
321
|
|
|
123
322
|
if (aHas && bHas) {
|
|
124
323
|
if (sa.level !== sb.level) return []; // 異なるレベル間に壁は立たない
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (s) segs.push(s);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
324
|
+
// 共有辺も**導出された領域** (pieces) から取る。割付から取ると、
|
|
325
|
+
// 描かれた線で切り落とした側にまで壁が立つ (隅切りの外へ壁が飛び出す)
|
|
326
|
+
segs.push(...sharedFromPieces(piecesOf(sa), piecesOf(sb)));
|
|
131
327
|
} else if (aHas || bHas) {
|
|
132
|
-
// 片側が領域を持たない (外部など):
|
|
328
|
+
// 片側が領域を持たない (外部など): 導出された領域の外周から、
|
|
329
|
+
// 同レベルで向かい合う他室の区間を除いた残り。**割付ではなく形の縁を辿る** —
|
|
330
|
+
// 描かれた線で切り落とされた側には壁が立たない (ADR-0022)
|
|
133
331
|
const roomSpace = aHas ? sa : sb;
|
|
134
|
-
const others:
|
|
332
|
+
const others: Pt[][] = [];
|
|
135
333
|
for (const s of model.spaces.values()) {
|
|
136
334
|
if (s === sa || s === sb) continue;
|
|
137
335
|
if (s.level !== roomSpace.level) continue;
|
|
138
|
-
others.push(...s
|
|
139
|
-
}
|
|
140
|
-
for (let ri = 0; ri < roomSpace.rects.length; ri++) {
|
|
141
|
-
const room = roomSpace.rects[ri]!;
|
|
142
|
-
const siblings = roomSpace.rects.filter((_, i) => i !== ri);
|
|
143
|
-
const blockers = [...others, ...siblings];
|
|
144
|
-
for (const e of ["N", "E", "S", "W"] as const) {
|
|
145
|
-
segs.push(...rectPerimeterRemainder(room, e, blockers));
|
|
146
|
-
}
|
|
336
|
+
others.push(...piecesOf(s));
|
|
147
337
|
}
|
|
338
|
+
segs.push(...pieceOutline(piecesOf(roomSpace), others));
|
|
148
339
|
}
|
|
149
340
|
segs = mergeCollinear(segs);
|
|
150
341
|
if (b.edge) segs = segs.filter((s) => s.edgeOfA === b.edge);
|
|
151
342
|
return segs;
|
|
152
343
|
}
|
|
153
344
|
|
|
345
|
+
/**
|
|
346
|
+
* 空間の外周のうち、**何にも面していない**区間 (ADR-0025)。
|
|
347
|
+
* 他の空間とも、宣言された外部境界とも向かい合っていない縁 — 外皮の穴である。
|
|
348
|
+
* 既定境界 (ADR-0014) は領域を持たない空間との間には導かれないので、
|
|
349
|
+
* 外部への境界の書き忘れは黙って壁の不在になる。これを言葉にするための導出。
|
|
350
|
+
*/
|
|
351
|
+
export function envelopeGaps(model: Model, s: Space): Segment[] {
|
|
352
|
+
if (s.rects.length === 0 || !s.level) return [];
|
|
353
|
+
const others: Pt[][] = [];
|
|
354
|
+
for (const o of model.spaces.values()) {
|
|
355
|
+
if (o === s || o.level !== s.level) continue;
|
|
356
|
+
others.push(...piecesOf(o));
|
|
357
|
+
}
|
|
358
|
+
let gaps = pieceOutline(piecesOf(s), others);
|
|
359
|
+
// 宣言された境界 (外部・斜めを含む) が覆う区間を引く
|
|
360
|
+
for (const b of model.boundaries) {
|
|
361
|
+
if (b.a !== s.path && b.b !== s.path) continue;
|
|
362
|
+
if (b.kind === "stair" || b.kind === "shaft" || b.kind === "void") continue;
|
|
363
|
+
for (const seg of segmentsFor(model, b)) {
|
|
364
|
+
gaps = gaps.flatMap((g) => subtractOverlap(g, seg));
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return gaps.filter((g) => segmentLength(g) > 1);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/** 軸平行の線分から、同一直線上で重なる区間を引く */
|
|
371
|
+
function subtractOverlap(g: Segment, o: Segment): Segment[] {
|
|
372
|
+
if (o.diagonal || g.horizontal !== o.horizontal) return [g];
|
|
373
|
+
const fixedG = g.horizontal ? g.y1 : g.x1;
|
|
374
|
+
const fixedO = o.horizontal ? o.y1 : o.x1;
|
|
375
|
+
if (Math.abs(fixedG - fixedO) > EPS) return [g];
|
|
376
|
+
const [gl, gh] = g.horizontal ? [g.x1, g.x2] : [g.y1, g.y2];
|
|
377
|
+
const [ol, oh] = o.horizontal
|
|
378
|
+
? [Math.min(o.x1, o.x2), Math.max(o.x1, o.x2)]
|
|
379
|
+
: [Math.min(o.y1, o.y2), Math.max(o.y1, o.y2)];
|
|
380
|
+
const cs = Math.max(gl, ol);
|
|
381
|
+
const ce = Math.min(gh, oh);
|
|
382
|
+
if (ce - cs <= EPS) return [g];
|
|
383
|
+
const parts: Array<[number, number]> = [];
|
|
384
|
+
if (cs - gl > EPS) parts.push([gl, cs]);
|
|
385
|
+
if (gh - ce > EPS) parts.push([ce, gh]);
|
|
386
|
+
return parts.map(([a, b]) =>
|
|
387
|
+
g.horizontal
|
|
388
|
+
? { ...g, x1: a, x2: b }
|
|
389
|
+
: { ...g, y1: a, y2: b },
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function piecesOf(s: Space): Pt[][] {
|
|
394
|
+
return s.pieces.length > 0 ? s.pieces : s.rects.map(rectToPoly);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/** 線の左右へ少し離れた点。どちらの空間に属するかを見るための探り */
|
|
398
|
+
const PROBE = 5;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* 描かれた線のうち、この二空間が実際に向かい合っている区間だけを返す (ADR-0022)。
|
|
402
|
+
*
|
|
403
|
+
* 一本の設計線は複数の境界に共有される — 貫通通路の壁は、その前を通る区画の数だけ
|
|
404
|
+
* 境界を持つ。各境界が線の全長を実現すると、平面には同じ壁が何本も重なって現れる。
|
|
405
|
+
* 線を両空間の縁で切り、左右がちょうど a と b になっている区間だけを残す。
|
|
406
|
+
*/
|
|
407
|
+
function drawnShare(model: Model, sa: Space, sb: Space, p: Pt, q: Pt): Segment[] {
|
|
408
|
+
const dx = q.x - p.x;
|
|
409
|
+
const dy = q.y - p.y;
|
|
410
|
+
const len = Math.hypot(dx, dy);
|
|
411
|
+
if (len < EPS) return [];
|
|
412
|
+
const nx = -dy / len;
|
|
413
|
+
const ny = dx / len;
|
|
414
|
+
const A = piecesOf(sa);
|
|
415
|
+
const B = piecesOf(sb);
|
|
416
|
+
|
|
417
|
+
// 切り位置: 両空間の凸片の辺と線の交点
|
|
418
|
+
const cuts = new Set<number>([0, 1]);
|
|
419
|
+
for (const poly of [...A, ...B]) {
|
|
420
|
+
for (let i = 0; i < poly.length; i++) {
|
|
421
|
+
const t = lineHit(p, q, poly[i]!, poly[(i + 1) % poly.length]!);
|
|
422
|
+
if (t !== undefined && t > 1e-9 && t < 1 - 1e-9) cuts.add(t);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
const ts = [...cuts].sort((x, y) => x - y);
|
|
426
|
+
|
|
427
|
+
const kept: Array<[number, number]> = [];
|
|
428
|
+
for (let i = 0; i + 1 < ts.length; i++) {
|
|
429
|
+
const m = (ts[i]! + ts[i + 1]!) / 2;
|
|
430
|
+
const cx = p.x + m * dx;
|
|
431
|
+
const cy = p.y + m * dy;
|
|
432
|
+
const left = { x: cx + nx * PROBE, y: cy + ny * PROBE };
|
|
433
|
+
const right = { x: cx - nx * PROBE, y: cy - ny * PROBE };
|
|
434
|
+
const inA = (pt: Pt) => A.some((g) => poly.pointIn(pt, g, 0));
|
|
435
|
+
const inB = (pt: Pt) => B.some((g) => poly.pointIn(pt, g, 0));
|
|
436
|
+
// 片側が領域を持たない (外部) 相手なら、持つ側が片側に居るだけで境界になる
|
|
437
|
+
const soloB = sb.rects.length === 0;
|
|
438
|
+
const soloA = sa.rects.length === 0;
|
|
439
|
+
const ok = soloB
|
|
440
|
+
? inA(left) !== inA(right)
|
|
441
|
+
: soloA
|
|
442
|
+
? inB(left) !== inB(right)
|
|
443
|
+
: (inA(left) && inB(right)) || (inB(left) && inA(right));
|
|
444
|
+
if (ok) kept.push([ts[i]!, ts[i + 1]!]);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// 連続する区間をまとめる
|
|
448
|
+
const out: Segment[] = [];
|
|
449
|
+
for (const [a0, a1] of kept) {
|
|
450
|
+
const last = out[out.length - 1];
|
|
451
|
+
const start = { x: p.x + a0 * dx, y: p.y + a0 * dy };
|
|
452
|
+
const end = { x: p.x + a1 * dx, y: p.y + a1 * dy };
|
|
453
|
+
if (last && Math.hypot(last.x2 - start.x, last.y2 - start.y) < EPS) {
|
|
454
|
+
last.x2 = end.x;
|
|
455
|
+
last.y2 = end.y;
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
const horizontal = Math.abs(dy) < 0.5;
|
|
459
|
+
const vertical = Math.abs(dx) < 0.5;
|
|
460
|
+
out.push({
|
|
461
|
+
x1: start.x,
|
|
462
|
+
y1: start.y,
|
|
463
|
+
x2: end.x,
|
|
464
|
+
y2: end.y,
|
|
465
|
+
horizontal,
|
|
466
|
+
...(horizontal || vertical ? {} : { diagonal: true as const }),
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
return out;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/** 無限直線 p→q と線分 u→v の交点の、線側のパラメータ t (平行・範囲外は undefined) */
|
|
473
|
+
function lineHit(p: Pt, q: Pt, u: Pt, v: Pt): number | undefined {
|
|
474
|
+
const rx = q.x - p.x;
|
|
475
|
+
const ry = q.y - p.y;
|
|
476
|
+
const sx = v.x - u.x;
|
|
477
|
+
const sy = v.y - u.y;
|
|
478
|
+
const d = rx * sy - ry * sx;
|
|
479
|
+
if (Math.abs(d) < 1e-9) return undefined;
|
|
480
|
+
const t = ((u.x - p.x) * sy - (u.y - p.y) * sx) / d;
|
|
481
|
+
const w = ((u.x - p.x) * ry - (u.y - p.y) * rx) / d;
|
|
482
|
+
return w >= -1e-9 && w <= 1 + 1e-9 ? t : undefined;
|
|
483
|
+
}
|
|
484
|
+
|
|
154
485
|
export function segmentLength(s: Segment): number {
|
|
155
|
-
return
|
|
486
|
+
return Math.hypot(s.x2 - s.x1, s.y2 - s.y1);
|
|
156
487
|
}
|
|
157
488
|
|
|
158
489
|
/** 平面上の重なり (垂直隣接の導出に使う)。重ならなければ undefined */
|
|
@@ -179,6 +510,10 @@ export function spacesOverlap(a: Space, b: Space): boolean {
|
|
|
179
510
|
export interface Band {
|
|
180
511
|
w: number;
|
|
181
512
|
at: number;
|
|
513
|
+
/** 明示位置 (通り参照 at:X2+450 の解決値)。指定時はクランプせず、はみ出しをエラーにする */
|
|
514
|
+
atRef?: string;
|
|
515
|
+
atAbs?: number;
|
|
516
|
+
atAxis?: "X" | "Y";
|
|
182
517
|
edge?: Edge;
|
|
183
518
|
line: number;
|
|
184
519
|
}
|
|
@@ -190,41 +525,96 @@ export interface PlacedBand {
|
|
|
190
525
|
cy: number;
|
|
191
526
|
}
|
|
192
527
|
|
|
528
|
+
/** placeBand が出しうる診断コード (ADR-0016 の台帳の部分集合 — check の emit が型で受ける) */
|
|
529
|
+
export type BandCode =
|
|
530
|
+
| "OPN04" | "OPN05" | "OPN06" | "OPN07" | "OPN08"
|
|
531
|
+
| "SEG04" | "SEG05" | "SEG06" | "SEG07" | "SEG08";
|
|
532
|
+
|
|
533
|
+
/** 帯の配置失敗 — error は互換の完成文 (位置接頭辞つき)。code/line/message は診断契約 (ADR-0016) の材料 */
|
|
534
|
+
export interface BandError {
|
|
535
|
+
error: string;
|
|
536
|
+
/** 診断コード — 開口は OPN04〜08、seg は SEG04〜08 (呼び手のlabelで決まる) */
|
|
537
|
+
code: BandCode;
|
|
538
|
+
line: number;
|
|
539
|
+
file?: string;
|
|
540
|
+
/** 位置接頭辞を除いた本文 */
|
|
541
|
+
message: string;
|
|
542
|
+
}
|
|
543
|
+
|
|
193
544
|
/** 帯 (開口・seg) を境界線分上に配置する。曖昧なら error を返す */
|
|
194
545
|
export function placeBand(
|
|
195
546
|
model: Model,
|
|
196
547
|
b: Boundary,
|
|
197
548
|
band: Band,
|
|
198
549
|
label: string,
|
|
199
|
-
): PlacedBand |
|
|
550
|
+
): PlacedBand | BandError {
|
|
551
|
+
// 配置失敗の診断: label が "seg" なら SEG系、開口 (door/window等) なら OPN系のコード
|
|
552
|
+
const fail = (n: "04" | "05" | "06" | "07" | "08", message: string): BandError => ({
|
|
553
|
+
error: `${srcRef(band.line, b.file)}: ${message}`,
|
|
554
|
+
code: (label === "seg" ? `SEG${n}` : `OPN${n}`) as BandCode,
|
|
555
|
+
line: band.line,
|
|
556
|
+
...(b.file !== undefined ? { file: b.file } : {}),
|
|
557
|
+
message,
|
|
558
|
+
});
|
|
200
559
|
let segs = segmentsFor(model, b);
|
|
201
560
|
if (band.edge) segs = segs.filter((s) => s.edgeOfA === band.edge);
|
|
202
561
|
if (segs.length === 0) {
|
|
203
|
-
return
|
|
562
|
+
return fail("04", `${label} を置ける境界線分がありません (${b.a} | ${b.b})`);
|
|
204
563
|
}
|
|
205
564
|
if (segs.length > 1) {
|
|
206
|
-
return {
|
|
207
|
-
error: `${band.line}行目: 境界線分が複数あります。edge:N/E/S/W で辺を指定してください (${b.a} | ${b.b})`,
|
|
208
|
-
};
|
|
565
|
+
return fail("05", `境界線分が複数あります。edge:N/E/S/W で辺を指定してください (${b.a} | ${b.b})`);
|
|
209
566
|
}
|
|
210
567
|
const seg = segs[0]!;
|
|
211
568
|
const len = segmentLength(seg);
|
|
212
569
|
if (band.w > len) {
|
|
213
|
-
return {
|
|
214
|
-
error: `${band.line}行目: ${label}の幅 ${band.w} が境界線分の長さ ${len} を超えています`,
|
|
215
|
-
};
|
|
570
|
+
return fail("06", `${label}の幅 ${band.w} が境界線分の長さ ${len} を超えています`);
|
|
216
571
|
}
|
|
217
572
|
const half = band.w / 2;
|
|
218
|
-
|
|
573
|
+
let pos: number;
|
|
574
|
+
if (band.atAbs !== undefined) {
|
|
575
|
+
// 斜めの線分 (描かれた線) の上では、通り参照は一意に位置を定めない — 比率で書く
|
|
576
|
+
if (seg.diagonal) {
|
|
577
|
+
return fail(
|
|
578
|
+
"07",
|
|
579
|
+
`${label} の位置 ${band.atRef} は斜めの線分では使えません (at:0..1 の比率で書きます)`,
|
|
580
|
+
);
|
|
581
|
+
}
|
|
582
|
+
// 明示位置: 通り参照で置かれたものはクランプしない — はみ出しは言葉のエラーになる
|
|
583
|
+
const axisOk = seg.horizontal ? band.atAxis === "X" : band.atAxis === "Y";
|
|
584
|
+
if (!axisOk) {
|
|
585
|
+
return fail(
|
|
586
|
+
"07",
|
|
587
|
+
`${label} の位置 ${band.atRef} は${
|
|
588
|
+
seg.horizontal ? "水平線分なのでX系" : "垂直線分なのでY系"
|
|
589
|
+
}の通りで指定します`,
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
const start = seg.horizontal ? seg.x1 : seg.y1;
|
|
593
|
+
pos = band.atAbs - start;
|
|
594
|
+
if (pos < half - EPS || pos > len - half + EPS) {
|
|
595
|
+
return fail(
|
|
596
|
+
"08",
|
|
597
|
+
`位置 ${band.atRef} では ${label} (幅${band.w}) が境界線分からはみ出します (線分 ${Math.round(
|
|
598
|
+
start,
|
|
599
|
+
)}〜${Math.round(start + len)}mm、中心の許容 ${Math.round(start + half)}〜${Math.round(
|
|
600
|
+
start + len - half,
|
|
601
|
+
)}mm)`,
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
} else {
|
|
605
|
+
pos = Math.min(Math.max(band.at * len, half), len - half);
|
|
606
|
+
}
|
|
607
|
+
// 線分上の位置はパラメトリックに取る — 軸平行でも斜めでも同じ一つの式
|
|
608
|
+
const f = len > 0 ? pos / len : 0;
|
|
219
609
|
return {
|
|
220
610
|
segment: seg,
|
|
221
|
-
cx: seg.
|
|
222
|
-
cy: seg.
|
|
611
|
+
cx: seg.x1 + f * (seg.x2 - seg.x1),
|
|
612
|
+
cy: seg.y1 + f * (seg.y2 - seg.y1),
|
|
223
613
|
};
|
|
224
614
|
}
|
|
225
615
|
|
|
226
616
|
/** 開口を境界線分上に配置する */
|
|
227
|
-
export function placeOpening(model: Model, b: Boundary, o: Opening): PlacedBand |
|
|
617
|
+
export function placeOpening(model: Model, b: Boundary, o: Opening): PlacedBand | BandError {
|
|
228
618
|
return placeBand(model, b, o, o.kind);
|
|
229
619
|
}
|
|
230
620
|
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,44 @@
|
|
|
1
1
|
// koyu v0 — 公開API
|
|
2
2
|
export * from "./model.js";
|
|
3
|
-
export { parse, tokenize } from "./parse.js";
|
|
3
|
+
export { parse, parseFiles, parseWith, tokenize, type LayerLoader } from "./parse.js";
|
|
4
4
|
export * from "./graph.js";
|
|
5
|
-
export { check, type CheckResult } from "./check.js";
|
|
5
|
+
export { check, checkDiagnostics, DIAGNOSTIC_CODES, type CheckResult, type Diagnostic } from "./check.js";
|
|
6
|
+
export {
|
|
7
|
+
semanticDiff,
|
|
8
|
+
renderDiff,
|
|
9
|
+
type ModelDiff,
|
|
10
|
+
type FieldChange,
|
|
11
|
+
type ChangedItem,
|
|
12
|
+
type RenamedItem,
|
|
13
|
+
type GridChange,
|
|
14
|
+
type SpaceItem,
|
|
15
|
+
type BoundaryItem,
|
|
16
|
+
type BoundaryChange,
|
|
17
|
+
} from "./diff.js";
|
|
6
18
|
export { daylight, type DaylightResult } from "./light.js";
|
|
19
|
+
export { slabs, type Slab, type SlabKind } from "./fabric.js";
|
|
20
|
+
export {
|
|
21
|
+
verticalRuns,
|
|
22
|
+
verticalRun,
|
|
23
|
+
runDecls,
|
|
24
|
+
runSolids,
|
|
25
|
+
runDrawsForLevel,
|
|
26
|
+
runIssues,
|
|
27
|
+
slopeText,
|
|
28
|
+
toWorld,
|
|
29
|
+
CUT_HEIGHT,
|
|
30
|
+
RUN_KEYS,
|
|
31
|
+
RUN_FORMS,
|
|
32
|
+
type RunDevice,
|
|
33
|
+
type RunForm,
|
|
34
|
+
type RunPart,
|
|
35
|
+
type VerticalRun,
|
|
36
|
+
type RunSolid,
|
|
37
|
+
type RunDraw,
|
|
38
|
+
type RunArrow,
|
|
39
|
+
type RunIssue,
|
|
40
|
+
type Seg2,
|
|
41
|
+
} from "./vertical.js";
|
|
7
42
|
export { siteReport, type SiteReport, type RoadFrontage } from "./site.js";
|
|
8
43
|
export { svgPlan, type PlanOptions } from "./plan.js";
|
|
44
|
+
export { svgAxo, type AxoOptions } from "./axo.js";
|
package/src/light.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
// koyu — 採光の粗い判定 (法規検証の芽・第一号)
|
|
2
|
-
//
|
|
2
|
+
// 採光の対象と宣言された室について 窓面積/床面積 ≥ 1/7 を確かめる。
|
|
3
3
|
// 採光補正係数は掛けない甘い判定であり、基本計画の解像度に合わせた早期警報である。
|
|
4
|
-
//
|
|
4
|
+
// 対象は `daylight:1` を書いた空間だけ — 型からは推定しない (ADR-0020)。
|
|
5
5
|
|
|
6
6
|
import { areaM2, isCoveredAbove, isSemiOutdoor, type Model, type Space } from "./model.js";
|
|
7
7
|
|
|
8
|
-
const HABITABLE = new Set(["unit", "room", "ldk", "bedroom", "living"]);
|
|
9
|
-
|
|
10
8
|
/** 庇下・バルコニー下 (上に空間がある半屋外) 越しの窓の係数 — 縁側補正に倣う粗い値。
|
|
11
9
|
* 上が開いた半屋外 (庭・最上階バルコニー) 越しは 1.0 (ADR-0009) */
|
|
12
10
|
const COVERED_SEMI_FACTOR = 0.7;
|
|
@@ -28,9 +26,8 @@ export function daylight(model: Model): DaylightResult[] {
|
|
|
28
26
|
const out: DaylightResult[] = [];
|
|
29
27
|
for (const s of model.spaces.values()) {
|
|
30
28
|
if (s.rects.length === 0) continue;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (!target) continue;
|
|
29
|
+
// 採光の対象は宣言である (ADR-0020) — 型は解釈しない。既定は対象外
|
|
30
|
+
if (s.attrs["daylight"] !== 1) continue;
|
|
34
31
|
const floor = areaM2(s)!;
|
|
35
32
|
let win = 0;
|
|
36
33
|
let missingH = false;
|