@kensnzk/koyu 0.16.0 → 0.17.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 +12 -8
- package/README.md +13 -10
- package/dist/cli.js +14 -11
- package/dist/cli.js.map +1 -1
- package/dist/core/derive.d.ts +13 -8
- package/dist/core/derive.d.ts.map +1 -1
- package/dist/core/derive.js +19 -13
- package/dist/core/derive.js.map +1 -1
- package/dist/core/diagnose.d.ts +4 -3
- package/dist/core/diagnose.d.ts.map +1 -1
- package/dist/core/diagnose.js +46 -11
- package/dist/core/diagnose.js.map +1 -1
- package/dist/core/diff.d.ts +3 -2
- package/dist/core/diff.d.ts.map +1 -1
- package/dist/core/diff.js +8 -5
- package/dist/core/diff.js.map +1 -1
- package/dist/core/fabric.d.ts +1 -3
- package/dist/core/fabric.d.ts.map +1 -1
- package/dist/core/fabric.js +8 -8
- package/dist/core/fabric.js.map +1 -1
- package/dist/core/graph.d.ts +2 -2
- package/dist/core/graph.d.ts.map +1 -1
- package/dist/core/graph.js +12 -5
- package/dist/core/graph.js.map +1 -1
- package/dist/core/light.d.ts.map +1 -1
- package/dist/core/light.js +2 -2
- package/dist/core/light.js.map +1 -1
- package/dist/core/model.d.ts +59 -10
- package/dist/core/model.d.ts.map +1 -1
- package/dist/core/model.js +128 -26
- package/dist/core/model.js.map +1 -1
- package/dist/core/parse.d.ts.map +1 -1
- package/dist/core/parse.js +83 -82
- package/dist/core/parse.js.map +1 -1
- package/dist/core/poly.d.ts +0 -4
- package/dist/core/poly.d.ts.map +1 -1
- package/dist/core/poly.js +1 -5
- package/dist/core/poly.js.map +1 -1
- package/dist/core/site.d.ts.map +1 -1
- package/dist/core/site.js +2 -2
- package/dist/core/site.js.map +1 -1
- package/dist/core/tolerance.d.ts +1 -1
- package/dist/core/tolerance.js +2 -2
- package/dist/core/tolerance.js.map +1 -1
- package/dist/core/vertical.d.ts +9 -2
- package/dist/core/vertical.d.ts.map +1 -1
- package/dist/core/vertical.js +8 -1
- package/dist/core/vertical.js.map +1 -1
- package/dist/core/vocabulary.d.ts.map +1 -1
- package/dist/core/vocabulary.js +17 -5
- package/dist/core/vocabulary.js.map +1 -1
- package/dist/draw/index.js +1 -1
- package/dist/draw/index.js.map +1 -1
- package/dist/draw/plan.js +5 -5
- package/dist/draw/plan.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -11
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +43 -12
- package/dist/mcp.js.map +1 -1
- package/dist/parse-file.d.ts.map +1 -1
- package/dist/parse-file.js +18 -3
- package/dist/parse-file.js.map +1 -1
- package/dist/validate/access.d.ts.map +1 -1
- package/dist/validate/access.js +23 -13
- package/dist/validate/access.js.map +1 -1
- package/dist/validate/envelope.d.ts.map +1 -1
- package/dist/validate/envelope.js +3 -3
- package/dist/validate/envelope.js.map +1 -1
- package/dist/validate/index.d.ts +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +1 -1
- package/dist/validate/index.js.map +1 -1
- package/dist/validate/light.js +1 -1
- package/dist/validate/light.js.map +1 -1
- package/dist/validate/site.d.ts.map +1 -1
- package/dist/validate/site.js +2 -2
- package/dist/validate/site.js.map +1 -1
- package/editors/vscode/syntaxes/koyu.tmLanguage.json +2 -2
- package/examples/basement/main.muro +3 -3
- package/examples/complex/main.muro +1 -1
- package/examples/complex/podium.muro +1 -1
- package/examples/complex/site.muro +6 -6
- package/examples/house/L2.muro +1 -1
- package/examples/house/main.muro +1 -1
- package/examples/house/site.muro +4 -4
- package/examples/house.muro +6 -6
- package/examples/mansion.muro +2 -2
- package/examples/office.muro +3 -3
- package/examples/steps/04-exterior.muro +1 -1
- package/examples/steps/05-two-storeys.muro +1 -1
- package/examples/steps/06-finished.muro +2 -2
- package/examples/tower/L2.muro +1 -1
- package/examples/tower/main.muro +1 -1
- package/examples/tower/site.muro +4 -4
- package/examples/twin/main.muro +1 -1
- package/examples/twin/podium.muro +4 -4
- package/examples/twin/site.muro +8 -8
- package/examples/two-rooms.canonical.json +4 -4
- package/examples/two-rooms.muro +2 -2
- package/package.json +5 -5
- package/src/cli.ts +15 -10
- package/src/core/derive.ts +32 -15
- package/src/core/diagnose.ts +63 -16
- package/src/core/diff.ts +10 -6
- package/src/core/fabric.ts +18 -9
- package/src/core/graph.ts +19 -5
- package/src/core/light.ts +2 -2
- package/src/core/model.ts +141 -31
- package/src/core/parse.ts +100 -85
- package/src/core/poly.ts +1 -8
- package/src/core/site.ts +2 -2
- package/src/core/tolerance.ts +2 -2
- package/src/core/vertical.ts +10 -3
- package/src/core/vocabulary.ts +18 -5
- package/src/draw/index.ts +1 -1
- package/src/draw/plan.ts +5 -5
- package/src/index.ts +30 -9
- package/src/mcp.ts +44 -11
- package/src/parse-file.ts +17 -3
- package/src/validate/access.ts +24 -12
- package/src/validate/envelope.ts +3 -3
- package/src/validate/index.ts +2 -2
- package/src/validate/light.ts +1 -1
- package/src/validate/site.ts +2 -2
- package/spec/README.md +0 -28
- package/spec/canonical-json.md +0 -98
- package/spec/composition.md +0 -121
- package/spec/derivation.md +0 -393
- package/spec/en/README.md +0 -30
- package/spec/en/canonical-json.md +0 -101
- package/spec/en/composition.md +0 -121
- package/spec/en/derivation.md +0 -393
- package/spec/en/language.md +0 -164
- package/spec/en/notation-v0.md +0 -145
- package/spec/en/scope.md +0 -229
- package/spec/en/semantics.md +0 -132
- package/spec/en/tools.md +0 -108
- package/spec/en/validation.md +0 -79
- package/spec/en/vocabulary.md +0 -103
- package/spec/language.md +0 -163
- package/spec/notation-v0.md +0 -184
- package/spec/scope.md +0 -229
- package/spec/semantics.md +0 -130
- package/spec/tools.md +0 -106
- package/spec/validation.md +0 -79
- package/spec/vocabulary.md +0 -114
package/src/core/derive.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// koyu — 形の参照実装 (ADR-0040 /
|
|
1
|
+
// koyu — 形の参照実装 (ADR-0040 / docs/reference/form/index.md)
|
|
2
2
|
//
|
|
3
3
|
// **`derive(model)` が形の唯一の入口である。**
|
|
4
4
|
//
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// 上部吹抜けの投影が ugatsu の平面から 11 件落ち、最上階の壁の上端は koyu と ugatsu で
|
|
9
9
|
// 150mm 割れ、壁厚の既定 100mm は四箇所に別々のリテラルとして書かれていた。
|
|
10
10
|
//
|
|
11
|
-
// **Form は見た目を持たない** (
|
|
11
|
+
// **Form は見た目を持たない** (docs/reference/scope.md)。返すのは座標・厚み・z 範囲・向き・
|
|
12
12
|
// そして対象の同一性だけである。色も書体も線幅も注記文字列も記号も縮尺も紙面の余白も、
|
|
13
13
|
// この型のどこにも現れない。`src/draw/` と ugatsu はこれを描くだけである。
|
|
14
14
|
//
|
|
@@ -40,10 +40,16 @@ import {
|
|
|
40
40
|
type Pt,
|
|
41
41
|
type Space,
|
|
42
42
|
canonicalBoundaryOrder,
|
|
43
|
+
canonicalOpeningOrder,
|
|
44
|
+
canonicalSegOrder,
|
|
45
|
+
canonicalSpaceOrder,
|
|
46
|
+
isOutside,
|
|
47
|
+
isVoid
|
|
43
48
|
} from "./model.js";
|
|
44
49
|
import { EPS, SPAN_EPS } from "./tolerance.js";
|
|
45
50
|
import {
|
|
46
51
|
CUT_HEIGHT,
|
|
52
|
+
ARROW_SPAN_MIN,
|
|
47
53
|
DEFAULT_RISER_MAX,
|
|
48
54
|
ENTRY_LANDING,
|
|
49
55
|
LANDING_MIN,
|
|
@@ -79,8 +85,8 @@ export const OPENING_HEAD = 2000;
|
|
|
79
85
|
export const OPENING_H = 1200;
|
|
80
86
|
|
|
81
87
|
/**
|
|
82
|
-
* 導出の定数の台帳。**
|
|
83
|
-
* `test/derive.test.ts` が表とここの一致を縛る (語彙台帳と
|
|
88
|
+
* 導出の定数の台帳。**docs/reference/form/index.md の表の唯一の出所である** —
|
|
89
|
+
* `test/derive.test.ts` が表とここの一致を縛る (語彙台帳と docs/reference/muro/attributes.md と同じ構え)。
|
|
84
90
|
*/
|
|
85
91
|
export const DERIVATION_CONSTANTS: Readonly<Record<string, number>> = {
|
|
86
92
|
WALL_T,
|
|
@@ -94,6 +100,7 @@ export const DERIVATION_CONSTANTS: Readonly<Record<string, number>> = {
|
|
|
94
100
|
CUT_HEIGHT,
|
|
95
101
|
DEFAULT_RISER_MAX,
|
|
96
102
|
TREAD_TARGET,
|
|
103
|
+
ARROW_SPAN_MIN,
|
|
97
104
|
LANDING_MIN,
|
|
98
105
|
ENTRY_LANDING,
|
|
99
106
|
LANE_ESCALATOR,
|
|
@@ -129,7 +136,8 @@ export interface FormLevel {
|
|
|
129
136
|
|
|
130
137
|
export interface FormSpace {
|
|
131
138
|
path: string;
|
|
132
|
-
|
|
139
|
+
/** 書かれた自由なラベル。導出はこれを読まない — 構成の事実は [[outside]] / [[void]] にある */
|
|
140
|
+
type?: string;
|
|
133
141
|
level?: string;
|
|
134
142
|
/** 導出された領域 (凸片)。反時計回り */
|
|
135
143
|
outline: Pt[][];
|
|
@@ -139,6 +147,10 @@ export interface FormSpace {
|
|
|
139
147
|
z1?: number;
|
|
140
148
|
indoor: boolean;
|
|
141
149
|
semiOutdoor: boolean;
|
|
150
|
+
/** 建物の外部と宣言されているか (`outside:1`)。半屋外は外部ではない — [[indoor]] と併せて読む */
|
|
151
|
+
outside: boolean;
|
|
152
|
+
/** 吹抜けと宣言されているか (`void:1`)。床が無いので面積にも通行にも数えない */
|
|
153
|
+
void: boolean;
|
|
142
154
|
/** 上に空間が重なっているか */
|
|
143
155
|
covered: boolean;
|
|
144
156
|
}
|
|
@@ -155,7 +167,7 @@ export interface FormPanel {
|
|
|
155
167
|
|
|
156
168
|
/** 境界の実体 — 芯線分と、物があるならその材 */
|
|
157
169
|
export interface FormBoundary {
|
|
158
|
-
/** 関係の同一性 — 両端の空間と、宣言の並びの中の位置 (
|
|
170
|
+
/** 関係の同一性 — 両端の空間と、宣言の並びの中の位置 (docs/reference/scope.md) */
|
|
159
171
|
ref: string;
|
|
160
172
|
boundary: number;
|
|
161
173
|
a: string;
|
|
@@ -191,7 +203,7 @@ export interface FormSwing {
|
|
|
191
203
|
}
|
|
192
204
|
|
|
193
205
|
export interface FormOpening {
|
|
194
|
-
/** 開口の同一性 — 境界と、その中の並びの位置 (
|
|
206
|
+
/** 開口の同一性 — 境界と、その中の並びの位置 (docs/reference/scope.md) */
|
|
195
207
|
ref: string;
|
|
196
208
|
boundary: number;
|
|
197
209
|
index: number;
|
|
@@ -287,7 +299,7 @@ export interface FormPlan {
|
|
|
287
299
|
}
|
|
288
300
|
|
|
289
301
|
/**
|
|
290
|
-
* 形。**見た目を一つも持たない** (
|
|
302
|
+
* 形。**見た目を一つも持たない** (docs/reference/scope.md)。
|
|
291
303
|
* 座標・厚み・z 範囲・向き・対象の同一性だけを持ち、描き方は消費者が決める
|
|
292
304
|
*/
|
|
293
305
|
export interface Form {
|
|
@@ -450,13 +462,13 @@ function swingOf(
|
|
|
450
462
|
// ---- 実体の構成子 --------------------------------------------------------
|
|
451
463
|
//
|
|
452
464
|
// **Form が持つのは芯線と厚みと z である。**そこから実体 (厚みのある四辺形・立体の角柱) を
|
|
453
|
-
// 組み立てる規則も導出の一部なので、ここが唯一の実装を持つ (
|
|
465
|
+
// 組み立てる規則も導出の一部なので、ここが唯一の実装を持つ (docs/reference/form/index.md)。
|
|
454
466
|
// 描画側がそれぞれ書き直せば、同じ Form から違う形が出る余地がまた開く — ADR-0040 が
|
|
455
467
|
// 数えた「壁厚 100mm が四箇所に別々のリテラルとして書かれていた」のと同じ壊れ方である。
|
|
456
468
|
|
|
457
469
|
/**
|
|
458
470
|
* 芯線を厚みのある四辺形へ。**厚みは芯線に対して両側へ半分ずつ振り分ける**
|
|
459
|
-
* (
|
|
471
|
+
* (docs/reference/form/index.md)。単位法線へ ±t/2 だけ振るので斜めの線分でも同じ一つの式である。
|
|
460
472
|
* 頂点は 始点+n → 終点+n → 終点−n → 始点−n の順で、`0番と3番の中点`〜`1番と2番の中点`が芯線に戻る。
|
|
461
473
|
*/
|
|
462
474
|
export function thicken(x1: number, y1: number, x2: number, y2: number, t: number): Pt[] {
|
|
@@ -501,7 +513,7 @@ export interface FormPrism {
|
|
|
501
513
|
|
|
502
514
|
/**
|
|
503
515
|
* 縦動線の立体を角柱へ。**傾いた版の四隅の高さは、走る向きに線形で振る** —
|
|
504
|
-
* `up` 側が高い (
|
|
516
|
+
* `up` 側が高い (docs/reference/form/index.md)。箱は四隅とも同じ高さになる。
|
|
505
517
|
*/
|
|
506
518
|
export function runPrism(s: RunSolid): FormPrism {
|
|
507
519
|
const poly = rectToPoly(s.rect);
|
|
@@ -546,20 +558,24 @@ export function derive(model: Model, opts: DeriveOptions = {}): Form {
|
|
|
546
558
|
const zOf = new Map(levels.map((l) => [l.name, l.z]));
|
|
547
559
|
|
|
548
560
|
// ---- 空間 ----
|
|
561
|
+
// Canonical order, not declaration order. The canonical form discards declaration order,
|
|
562
|
+
// so a shape that reads it yields two different `Form`s for one building (promise 1)
|
|
549
563
|
const spaces: FormSpace[] = [];
|
|
550
|
-
for (const s of model
|
|
564
|
+
for (const s of canonicalSpaceOrder(model)) {
|
|
551
565
|
if (s.rects.length === 0) continue;
|
|
552
566
|
const h = heff(model, s);
|
|
553
567
|
const z = s.level !== undefined ? zOf.get(s.level) : undefined;
|
|
554
568
|
spaces.push({
|
|
555
569
|
path: s.path,
|
|
556
|
-
type: s.type,
|
|
570
|
+
...(s.type !== undefined ? { type: s.type } : {}),
|
|
557
571
|
...(s.level !== undefined ? { level: s.level } : {}),
|
|
558
572
|
outline: regionOf(s),
|
|
559
573
|
...(areaM2(s) !== undefined ? { areaM2: areaM2(s)! } : {}),
|
|
560
574
|
...(z !== undefined && h !== undefined ? { z0: z, z1: z + h } : {}),
|
|
561
575
|
indoor: isIndoor(model, s),
|
|
562
576
|
semiOutdoor: isSemiOutdoor(model, s),
|
|
577
|
+
outside: isOutside(s),
|
|
578
|
+
void: isVoid(s),
|
|
563
579
|
covered: isCoveredAbove(model, s),
|
|
564
580
|
});
|
|
565
581
|
}
|
|
@@ -581,7 +597,8 @@ export function derive(model: Model, opts: DeriveOptions = {}): Form {
|
|
|
581
597
|
|
|
582
598
|
// この境界の開口を、載っている線分ごとに集める
|
|
583
599
|
const placed: Array<{ o: Opening; index: number; seg: Segment; cx: number; cy: number }> = [];
|
|
584
|
-
|
|
600
|
+
// Canonical order, not declaration order — the index is part of the identity spelling
|
|
601
|
+
for (const [oi, o] of canonicalOpeningOrder(b).entries()) {
|
|
585
602
|
const p = placeOpening(model, b, o);
|
|
586
603
|
if ("error" in p) continue;
|
|
587
604
|
placed.push({ o, index: oi, seg: p.segment, cx: p.cx, cy: p.cy });
|
|
@@ -648,7 +665,7 @@ export function derive(model: Model, opts: DeriveOptions = {}): Form {
|
|
|
648
665
|
sliding,
|
|
649
666
|
});
|
|
650
667
|
}
|
|
651
|
-
for (const [gi, g] of b.
|
|
668
|
+
for (const [gi, g] of canonicalSegOrder(b).entries()) {
|
|
652
669
|
const p = placeBand(model, b, g, "seg");
|
|
653
670
|
if ("error" in p || !sameSegment(p.segment, seg)) continue;
|
|
654
671
|
segs.push({
|
package/src/core/diagnose.ts
CHANGED
|
@@ -13,10 +13,9 @@ import {
|
|
|
13
13
|
placeOpening,
|
|
14
14
|
planOverlap,
|
|
15
15
|
segmentsFor,
|
|
16
|
-
drawnCut,
|
|
17
16
|
spacesOverlap,
|
|
18
17
|
} from "./graph.js";
|
|
19
|
-
import { heff, isSemiOutdoor, levelsSorted, SUPPORTED_LANGUAGE_VERSIONS, type Attrs, type Boundary, type Edge, type Level, type Model, type
|
|
18
|
+
import { heff, isSemiOutdoor, levelsSorted, SUPPORTED_LANGUAGE_VERSIONS, type Attrs, type Boundary, type Edge, type Level, type Model, type Space,
|
|
20
19
|
columnSites,
|
|
21
20
|
openingIdentity,
|
|
22
21
|
regionOf,
|
|
@@ -25,8 +24,9 @@ import { heff, isSemiOutdoor, levelsSorted, SUPPORTED_LANGUAGE_VERSIONS, type At
|
|
|
25
24
|
rectToPoly,
|
|
26
25
|
srcRef,
|
|
27
26
|
polygonSelfIntersection,
|
|
27
|
+
isOutside,
|
|
28
|
+
isVoid
|
|
28
29
|
} from "./model.js";
|
|
29
|
-
import { cutsInWindow } from "./poly.js";
|
|
30
30
|
import { ASSET_ELEM, attrSpec, isNamespaced } from "./vocabulary.js";
|
|
31
31
|
import { runDecls, runIssues } from "./vertical.js";
|
|
32
32
|
|
|
@@ -35,9 +35,9 @@ export interface CheckResult {
|
|
|
35
35
|
warnings: string[];
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
/** 構造化診断 (ADR-0016)。message は本文のみ — 位置接頭辞「file:N
|
|
38
|
+
/** 構造化診断 (ADR-0016)。message は本文のみ — 位置接頭辞「file:line N: 」を含まない */
|
|
39
39
|
export interface Diagnostic {
|
|
40
|
-
/** 台帳 DIAGNOSTIC_CODES のコード (領域
|
|
40
|
+
/** 台帳 DIAGNOSTIC_CODES のコード (領域3字 + 2桁連番) */
|
|
41
41
|
code: DiagnosticCode;
|
|
42
42
|
severity: "error" | "warning";
|
|
43
43
|
/** 本文 (位置接頭辞なし) */
|
|
@@ -53,7 +53,7 @@ export interface Diagnostic {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* 診断コードの台帳 — 全コードと規範severity
|
|
56
|
+
* 診断コードの台帳 — 全コードと規範severity。公開文書の表 (docs/reference/diagnostics/index.md) とテストで一致を守る。
|
|
57
57
|
* BND07 は欠番 — 「接しているのに境界が無い」警告はADR-0014 (既定境界) で廃止された。
|
|
58
58
|
* HGT03・HGT04・HGT05・RUN04 も欠番 — この四つは「高さがどうか」「縦動線がどうか」ではなく
|
|
59
59
|
* 「形を作るのに必要な情報が書かれていない」という一つの話であり、SUF01-04 へ合流した (ADR-0034)。
|
|
@@ -124,6 +124,7 @@ export const DIAGNOSTIC_CODES = {
|
|
|
124
124
|
VER02: "error", // koyu 0.3以前で採光の推定対象だった型に daylight が無い (ADR-0020)
|
|
125
125
|
VER03: "error", // koyu 0.4以前のファイルに0.5の語 (縦動線・線・柱・地下)
|
|
126
126
|
VER04: "error", // koyu 0.5以前のファイルに1.0の語 (over・drop・集合編集 — ADR-0035/0038)
|
|
127
|
+
VER05: "error", // koyu 1.0以前のファイルの型の位置に exterior / void (ADR-0051)
|
|
127
128
|
SYN01: "error", // 構文・合成エラー (SourceError の写し — check --json のみ)
|
|
128
129
|
} as const satisfies Record<string, "error" | "warning">;
|
|
129
130
|
|
|
@@ -142,6 +143,16 @@ const VERTICAL = new Set(["stair", "shaft", "void"]);
|
|
|
142
143
|
/** 0.3以前が採光の対象と推定していた型 (ADR-0020で廃止)。旧版の受理条件の判定にだけ使う — 意味論には効かない */
|
|
143
144
|
const LEGACY_DAYLIT = new Set(["unit", "room", "ldk", "bedroom", "living"]);
|
|
144
145
|
|
|
146
|
+
/**
|
|
147
|
+
* 1.0以前が型の位置から構造として読んでいた二語 (ADR-0051で廃止)。
|
|
148
|
+
* **VER05 の受理条件の判定にだけ使う — 意味論には効かない。**
|
|
149
|
+
* 型を読む場所がここにしか無いことは test/vocabulary.test.ts が守っている
|
|
150
|
+
*/
|
|
151
|
+
const RETIRED_STRUCTURAL_TYPES: Record<string, { decl: string; loses: string }> = {
|
|
152
|
+
exterior: { decl: "outside:1", loses: "stops being outside (it becomes indoor floor area)" },
|
|
153
|
+
void: { decl: "void:1", loses: "stops being a void (a floor is generated in it)" },
|
|
154
|
+
};
|
|
155
|
+
|
|
145
156
|
/**
|
|
146
157
|
* 版の新旧は `SUPPORTED_LANGUAGE_VERSIONS` の並びで決まる。**辞書順で比べてはならない** —
|
|
147
158
|
* 文字列としては "0.5" > "1.0" であり、比較を綴りに任せると新しい版が古い版と判定される
|
|
@@ -149,7 +160,7 @@ const LEGACY_DAYLIT = new Set(["unit", "room", "ldk", "bedroom", "living"]);
|
|
|
149
160
|
const olderThan = (version: string, ref: string): boolean =>
|
|
150
161
|
SUPPORTED_LANGUAGE_VERSIONS.indexOf(version) < SUPPORTED_LANGUAGE_VERSIONS.indexOf(ref);
|
|
151
162
|
|
|
152
|
-
/** 互換層 — 従来の文字列形式。位置を持つ診断は「file:N
|
|
163
|
+
/** 互換層 — 従来の文字列形式。位置を持つ診断は「file:line N: 本文」に組み立てる */
|
|
153
164
|
interface AttrSubject {
|
|
154
165
|
/** 台帳を引く要素名 */
|
|
155
166
|
elem: string;
|
|
@@ -460,7 +471,7 @@ function checkDaylightScope(ctx: Ctx): void {
|
|
|
460
471
|
/** 解釈される属性の値 — ATT01 / ATT02 */
|
|
461
472
|
function checkAttrValues(ctx: Ctx): void {
|
|
462
473
|
const { model, emit } = ctx;
|
|
463
|
-
// 属性の三層 (
|
|
474
|
+
// 属性の三層 (docs/reference/scope.md)。**書いたのに解釈されなかったものを、黙って落とさない。**
|
|
464
475
|
//
|
|
465
476
|
// ADR-0028 は値を守った — `site:yes` は敷地の判定を、`h:35OO` は高さ不変量を、
|
|
466
477
|
// それぞれ丸ごと無音にしていた。だが**キー**は無防備のままだった。
|
|
@@ -589,7 +600,7 @@ function checkColumns(ctx: Ctx): void {
|
|
|
589
600
|
}
|
|
590
601
|
}
|
|
591
602
|
|
|
592
|
-
/** 言語版の受理条件 — VER01〜
|
|
603
|
+
/** 言語版の受理条件 — VER01〜VER05 */
|
|
593
604
|
function checkLanguageVersion(ctx: Ctx): void {
|
|
594
605
|
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
595
606
|
// 言語版の受理条件 (ADR-0017): 旧版は意味保存の場合のみ受理する。
|
|
@@ -610,7 +621,7 @@ function checkLanguageVersion(ctx: Ctx): void {
|
|
|
610
621
|
// 書かれていなければ、0.4では判定から黙って外れる — 意味が変わるのでエラーで二択を示す
|
|
611
622
|
if (["0.1", "0.2", "0.3"].includes(model.version)) {
|
|
612
623
|
for (const s of model.spaces.values()) {
|
|
613
|
-
if (!LEGACY_DAYLIT.has(s.type) || s.attrs["daylight"] !== undefined) continue;
|
|
624
|
+
if (s.type === undefined || !LEGACY_DAYLIT.has(s.type) || s.attrs["daylight"] !== undefined) continue;
|
|
614
625
|
emit(
|
|
615
626
|
"VER02",
|
|
616
627
|
`A koyu ${model.version} file has a ${s.type} with no daylight: ${s.path} — 0.4 does not infer the daylight scope from the type, so it falls out of the check. Write daylight:1 (in scope) or daylight:0 (out of scope), then raise the version to koyu 0.4`,
|
|
@@ -619,6 +630,42 @@ function checkLanguageVersion(ctx: Ctx): void {
|
|
|
619
630
|
}
|
|
620
631
|
}
|
|
621
632
|
|
|
633
|
+
// 1.0 以前は型の位置に書かれた `exterior` と `void` が構造として読まれていた (ADR-0051 で廃止)。
|
|
634
|
+
// 1.1 の処理系はそこを一切読まないので、**書き換えないまま版を上げないと黙って別の建物になる** —
|
|
635
|
+
// 外部が屋内の床になり、吹抜けに床が生成される。実測で複合用途の例は延床 31,606.24㎡ が
|
|
636
|
+
// 33,004.00㎡ に増えながら check は緑で通った。ADR-0020 が `daylight` で下したのと同じ判断で、
|
|
637
|
+
// エラーにして二択を示す。
|
|
638
|
+
if (olderThan(model.version, "1.1")) {
|
|
639
|
+
for (const s of model.spaces.values()) {
|
|
640
|
+
const retired = RETIRED_STRUCTURAL_TYPES[s.type ?? ""];
|
|
641
|
+
if (!retired) continue;
|
|
642
|
+
emit(
|
|
643
|
+
"VER05",
|
|
644
|
+
`A koyu ${model.version} file writes ${s.type} in the type position: ${s.path} — 1.1 reads no meaning from the type, so this space silently ${retired.loses}. Write ${retired.decl} instead, then raise the version to koyu 1.1`,
|
|
645
|
+
{ line: s.line, file: s.file, path: [s.path] },
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
// 逆向きも同じ境界である — 1.1 で入った語を古い版で書けば、知らない処理系は
|
|
649
|
+
// ATT03 で拒む。版の宣言と語彙は一致していなければならない (VER03/VER04 と同型)
|
|
650
|
+
for (const s of model.spaces.values()) {
|
|
651
|
+
if (s.type === undefined) {
|
|
652
|
+
emit(
|
|
653
|
+
"VER05",
|
|
654
|
+
`A koyu ${model.version} file writes a space with no type: ${s.path} — the type became optional in 1.1, and an older processor refuses the line. Write a type, or raise the version to koyu 1.1`,
|
|
655
|
+
{ line: s.line, file: s.file, path: [s.path] },
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
for (const key of ["outside", "void"]) {
|
|
659
|
+
if (s.attrs[key] === undefined) continue;
|
|
660
|
+
emit(
|
|
661
|
+
"VER05",
|
|
662
|
+
`A koyu ${model.version} file carries ${key}: on ${s.path} — that word arrives in 1.1. Raise the version to koyu 1.1`,
|
|
663
|
+
{ line: s.line, file: s.file, path: [s.path] },
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
622
669
|
// 0.5 で入った語 (縦動線の宣言・描かれた線・柱・地下) は 0.4 以前の処理系が知らない。
|
|
623
670
|
// 知らない処理系では黙って形が生成されないので、版を上げずに使うのはエラー (ADR-0017 決定3)
|
|
624
671
|
if (olderThan(model.version, "0.5")) {
|
|
@@ -712,7 +759,7 @@ function checkUids(ctx: Ctx): void {
|
|
|
712
759
|
}
|
|
713
760
|
}
|
|
714
761
|
|
|
715
|
-
// 開口・内包物の同一性は「含む対象 + その中で一意な名」から導かれる (
|
|
762
|
+
// 開口・内包物の同一性は「含む対象 + その中で一意な名」から導かれる (docs/reference/scope.md)。
|
|
716
763
|
// 名が重複していれば、その同一性は成り立たない — `over ... = door D1` はどちらを指すのか
|
|
717
764
|
// 決められず、`drop column C1` は二本まとめて消してしまう。**推測せずに拒む** (ADR-0039)。
|
|
718
765
|
// 名を書かない要素は同一性を主張していないので、母集団に入らない
|
|
@@ -810,8 +857,8 @@ function checkVerticalBoundary(ctx: Ctx, b: Boundary, sa: Space, sb: Space, bAt:
|
|
|
810
857
|
}
|
|
811
858
|
if (b.kind === "void") {
|
|
812
859
|
const upper = (ia ?? 0) > (ib ?? 0) ? sa : sb;
|
|
813
|
-
if (upper
|
|
814
|
-
emit("VRT04", `The space above a void boundary is expected to
|
|
860
|
+
if (!isVoid(upper)) {
|
|
861
|
+
emit("VRT04", `The space above a void boundary is expected to declare void:1: ${upper.path}`, bAt);
|
|
815
862
|
}
|
|
816
863
|
}
|
|
817
864
|
// 咎めているのは字下げされた door / window / seg の行そのものなので、
|
|
@@ -1068,7 +1115,7 @@ function checkHeights(ctx: Ctx): void {
|
|
|
1068
1115
|
/**
|
|
1069
1116
|
* 充足性 — 領域を持つ空間の走査 (SUF02 / SUF01)。
|
|
1070
1117
|
*
|
|
1071
|
-
* **妥当性の判定ではなく、完全性の検査である** (
|
|
1118
|
+
* **妥当性の判定ではなく、完全性の検査である** (docs/reference/scope.md-2)。形を作らないことと
|
|
1072
1119
|
* 形を作れないことは違う — 天井高が決まらなければ押し出す高さが無く、レベルが決まらなければ
|
|
1073
1120
|
* z が無い。どちらも「書いてある構成から一意な形が出る」という契約 (ADR-0034) の破れである。
|
|
1074
1121
|
*
|
|
@@ -1084,7 +1131,7 @@ function checkSpaceSufficiency(ctx: Ctx): void {
|
|
|
1084
1131
|
emit("SUF02", `${s.path} has a region, but its level cannot be determined (give it at the head of the path or with level:)`, at);
|
|
1085
1132
|
continue; // z が決まらない空間には、天井高を問う意味が無い
|
|
1086
1133
|
}
|
|
1087
|
-
if (s
|
|
1134
|
+
if (isVoid(s) || isOutside(s) || isSemiOutdoor(model, s)) continue;
|
|
1088
1135
|
if (heff(model, s) === undefined) {
|
|
1089
1136
|
emit(
|
|
1090
1137
|
"SUF01",
|
|
@@ -1109,7 +1156,7 @@ function checkLevelSufficiency(ctx: Ctx): void {
|
|
|
1109
1156
|
// 床を持ちうる空間が一つも載っていない階 (最上階の上限を与えるだけの屋上レベルなど) には
|
|
1110
1157
|
// 言うことが無い — 生成されなかった床が無いのだから
|
|
1111
1158
|
const n = withRect.filter(
|
|
1112
|
-
(s) => s.level === l.name && s
|
|
1159
|
+
(s) => s.level === l.name && !isVoid(s) && !isOutside(s),
|
|
1113
1160
|
).length;
|
|
1114
1161
|
if (n === 0) continue;
|
|
1115
1162
|
emit("SUF03", `Level ${l.name} has no slab:, so not one floor is generated on this storey`, {
|
package/src/core/diff.ts
CHANGED
|
@@ -57,7 +57,8 @@ export interface GridChange {
|
|
|
57
57
|
|
|
58
58
|
export interface SpaceItem {
|
|
59
59
|
path: string;
|
|
60
|
-
|
|
60
|
+
/** 書かれていれば。型は任意である */
|
|
61
|
+
type?: string;
|
|
61
62
|
areaM2?: number;
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -266,7 +267,7 @@ function comparable(b: Boundary, tok: (p: string) => string): string {
|
|
|
266
267
|
|
|
267
268
|
/**
|
|
268
269
|
* 開口の対のキー。**名があれば名が優先である** (ADR-0039) —
|
|
269
|
-
* 開口の同一性は「含む対象 + その中で一意な名」から導かれるので (
|
|
270
|
+
* 開口の同一性は「含む対象 + その中で一意な名」から導かれるので (docs/reference/scope.md)、
|
|
270
271
|
* 名の付いた扉を動かせば「同じ扉の at が変わった」であって「消えて生えた」ではない。
|
|
271
272
|
* 名が無ければ位置で対応づける他にない: (kind, edge??"", atRef??at)。
|
|
272
273
|
* 名のある開口と無い開口は別のキー空間に落ちるので、名を後から書き足した編集は追加/削除に見える —
|
|
@@ -587,7 +588,7 @@ export function semanticDiff(a: Model, b: Model): ModelDiff {
|
|
|
587
588
|
d.spaces.renamed = sm.renamed.sort((x, y) => (key(x.to) < key(y.to) ? -1 : 1));
|
|
588
589
|
const spaceItem = (s: Space): SpaceItem => {
|
|
589
590
|
const ar = areaM2(s);
|
|
590
|
-
return { path: s.path, type: s.type, ...(ar !== undefined ? { areaM2: ar } : {}) };
|
|
591
|
+
return { path: s.path, ...(s.type !== undefined ? { type: s.type } : {}), ...(ar !== undefined ? { areaM2: ar } : {}) };
|
|
591
592
|
};
|
|
592
593
|
d.spaces.added = sm.added.map(spaceItem).sort((x, y) => (key(x.path) < key(y.path) ? -1 : 1));
|
|
593
594
|
d.spaces.removed = sm.removed.map(spaceItem).sort((x, y) => (key(x.path) < key(y.path) ? -1 : 1));
|
|
@@ -677,7 +678,7 @@ const fmtFields = (fields: FieldChange[]): string => fields.map(fmtField).join("
|
|
|
677
678
|
const betweenLabel = (x: { between: [string, string]; edge?: Edge }): string =>
|
|
678
679
|
`${x.between[0]} | ${x.between[1]}${x.edge ? ` edge:${x.edge}` : ""}`;
|
|
679
680
|
|
|
680
|
-
/**
|
|
681
|
+
/** 差分行 (英語・空なら差分なし)。並びはsemanticDiffが決めた正準順のまま */
|
|
681
682
|
export function renderDiff(d: ModelDiff): string[] {
|
|
682
683
|
const out: string[] = [];
|
|
683
684
|
for (const g of d.grid) {
|
|
@@ -701,11 +702,14 @@ export function renderDiff(d: ModelDiff): string[] {
|
|
|
701
702
|
for (const p of d.zones.removed) out.push(`− zone ${p}`);
|
|
702
703
|
for (const c of d.zones.changed) out.push(`± zone ${c.path}: ${fmtFields(c.fields)}`);
|
|
703
704
|
for (const r of d.spaces.renamed) out.push(`renamed ${r.from} → ${r.to} (uid:${r.uid})`);
|
|
705
|
+
// 型は任意なので、書かれていない空間もある。`${undefined}` が "undefined" と刷られると
|
|
706
|
+
// 型がそう綴られたように読めるので、集計の見出しと同じ形で言う (cli.ts と同じ構え)
|
|
707
|
+
const label = (t?: string) => t ?? "(untyped)";
|
|
704
708
|
for (const s of d.spaces.added) {
|
|
705
|
-
out.push(`+ space ${s.path} (${s.type}${s.areaM2 !== undefined ? ` ${s.areaM2.toFixed(2)} m2` : ""})`);
|
|
709
|
+
out.push(`+ space ${s.path} (${label(s.type)}${s.areaM2 !== undefined ? ` ${s.areaM2.toFixed(2)} m2` : ""})`);
|
|
706
710
|
}
|
|
707
711
|
for (const s of d.spaces.removed) {
|
|
708
|
-
out.push(`− space ${s.path} (${s.type}${s.areaM2 !== undefined ? ` ${s.areaM2.toFixed(2)} m2` : ""})`);
|
|
712
|
+
out.push(`− space ${s.path} (${label(s.type)}${s.areaM2 !== undefined ? ` ${s.areaM2.toFixed(2)} m2` : ""})`);
|
|
709
713
|
}
|
|
710
714
|
for (const c of d.spaces.changed) out.push(`± ${c.path}: ${fmtFields(c.fields)}`);
|
|
711
715
|
for (const x of d.boundaries.added) {
|
package/src/core/fabric.ts
CHANGED
|
@@ -6,7 +6,18 @@
|
|
|
6
6
|
// 壁が境界から現れ、柱が通りの交点から現れるのと同じ構えで、面もまた宣言から現れる —
|
|
7
7
|
// 床を置く操作も、天井を張る操作も、屋根を架ける操作も存在しない。
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
canonicalSpaceOrder,
|
|
11
|
+
heff,
|
|
12
|
+
isSemiOutdoor,
|
|
13
|
+
levelsSorted,
|
|
14
|
+
regionOf,
|
|
15
|
+
type Model,
|
|
16
|
+
type Pt,
|
|
17
|
+
type Space,
|
|
18
|
+
isOutside,
|
|
19
|
+
isVoid as isVoidSpace
|
|
20
|
+
} from "./model.js";
|
|
10
21
|
import { areaOf, rectToPoly, subtract } from "./poly.js";
|
|
11
22
|
import { AREA_EPS } from "./tolerance.js";
|
|
12
23
|
import { runDecls } from "./vertical.js";
|
|
@@ -16,10 +27,6 @@ export const CEILING_T = 30;
|
|
|
16
27
|
/** 上に何も無いときの屋根版の厚さ mm (上階レベルの slab が無い場合の既定) */
|
|
17
28
|
export const ROOF_T = 200;
|
|
18
29
|
|
|
19
|
-
/** 空間の導出された領域。parse の出口で必ず埋まる (ADR-0022) — 割付への退避は持たない */
|
|
20
|
-
export const regionOf = (s: Space): Pt[][] =>
|
|
21
|
-
s.pieces.length > 0 ? s.pieces : s.rects.map(rectToPoly);
|
|
22
|
-
|
|
23
30
|
export type SlabKind = "floor" | "ceiling" | "roof";
|
|
24
31
|
|
|
25
32
|
/** 生成された面。ビュアーはこれを幾何へ写すだけである */
|
|
@@ -49,7 +56,9 @@ export function slabs(model: Model): Slab[] {
|
|
|
49
56
|
const levels = levelsSorted(model);
|
|
50
57
|
const out: Slab[] = [];
|
|
51
58
|
const byLevel = new Map<string, Space[]>();
|
|
52
|
-
|
|
59
|
+
// Canonical order — the canonical form discards declaration order, so a surface that reads
|
|
60
|
+
// it makes the shape a function of it (promise 1)
|
|
61
|
+
for (const s of canonicalSpaceOrder(model)) {
|
|
53
62
|
if (s.rects.length === 0 || !s.level) continue;
|
|
54
63
|
const arr = byLevel.get(s.level) ?? [];
|
|
55
64
|
arr.push(s);
|
|
@@ -60,8 +69,8 @@ export function slabs(model: Model): Slab[] {
|
|
|
60
69
|
const upper = levels[li + 1];
|
|
61
70
|
for (const s of byLevel.get(level.name) ?? []) {
|
|
62
71
|
const pieces = regionOf(s);
|
|
63
|
-
const isVoid = s
|
|
64
|
-
const isExterior = s
|
|
72
|
+
const isVoid = isVoidSpace(s);
|
|
73
|
+
const isExterior = isOutside(s);
|
|
65
74
|
const semi = isSemiOutdoor(model, s);
|
|
66
75
|
const isRun = runDecls(s).length > 0;
|
|
67
76
|
|
|
@@ -106,7 +115,7 @@ export function slabs(model: Model): Slab[] {
|
|
|
106
115
|
const covers: Pt[][] = [];
|
|
107
116
|
for (const up of levels.slice(li + 1)) {
|
|
108
117
|
for (const o of byLevel.get(up.name) ?? []) {
|
|
109
|
-
if (o
|
|
118
|
+
if (isOutside(o)) continue;
|
|
110
119
|
covers.push(...regionOf(o));
|
|
111
120
|
}
|
|
112
121
|
}
|
package/src/core/graph.ts
CHANGED
|
@@ -4,7 +4,13 @@
|
|
|
4
4
|
// 空間の領域は矩形の合併 (L字など)。壁は合併の外周と共有辺から導出される。
|
|
5
5
|
|
|
6
6
|
import type { Boundary, Edge, Model, Opening, Pt, Rect, Space } from "./model.js";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
canonicalBoundaryOrder,
|
|
9
|
+
canonicalizeDrawn,
|
|
10
|
+
compareCanonical,
|
|
11
|
+
rectToPoly,
|
|
12
|
+
srcRef,
|
|
13
|
+
} from "./model.js";
|
|
8
14
|
import * as poly from "./poly.js";
|
|
9
15
|
import { EPS, PARALLEL_EPS, PROBE, SPAN_EPS } from "./tolerance.js";
|
|
10
16
|
|
|
@@ -148,7 +154,7 @@ export function mergeCollinear(segs: Segment[]): Segment[] {
|
|
|
148
154
|
* 既定境界の導出 (ADR-0014) — 垂直の「既定は床」と対称の、水平の「既定は壁」。
|
|
149
155
|
* 同一レベル (未特定同士を含む) で平面が接する領域つき空間の組に、宣言境界がその組に
|
|
150
156
|
* 一つも無ければ kind:wall の既定境界を導く。宣言は例外 (open・手すり) と属性のためにある。
|
|
151
|
-
* 領域を持たない空間 (
|
|
157
|
+
* 領域を持たない空間 (`outside:1` の外部など) との境界は導かない — 相手の名指しが情報のため宣言する。
|
|
152
158
|
* 合成・スパン展開の完了後に呼ぶ (parse / parseWith の出口)。冪等。
|
|
153
159
|
*/
|
|
154
160
|
export function deriveDefaultBoundaries(model: Model): void {
|
|
@@ -164,9 +170,17 @@ export function deriveDefaultBoundaries(model: Model): void {
|
|
|
164
170
|
if (declared.has(key)) continue;
|
|
165
171
|
// 接触は**導出された形**で見る — 線で接触が消えた組に既定の壁を作らない
|
|
166
172
|
if (sharedFromPieces(piecesOf(a), piecesOf(b)).length === 0) continue;
|
|
173
|
+
// The a/b orientation is decided in **canonical order**. On a declared boundary, `a` is
|
|
174
|
+
// the side as written and the canonical form preserves it as the `a` key, so the shape
|
|
175
|
+
// may read it. A derived boundary never appears in the canonical form, so it has no
|
|
176
|
+
// written orientation; taking the declaration order of the spaces would let discarded
|
|
177
|
+
// information change the shape — the relation identity (`a|b@i`) and the `edgeOfA`
|
|
178
|
+
// bearing would flip with it, against promise 1
|
|
179
|
+
const [pa, pb] =
|
|
180
|
+
compareCanonical(a.path, b.path) <= 0 ? [a.path, b.path] : [b.path, a.path];
|
|
167
181
|
model.boundaries.push({
|
|
168
|
-
a:
|
|
169
|
-
b:
|
|
182
|
+
a: pa,
|
|
183
|
+
b: pb,
|
|
170
184
|
kind: "wall",
|
|
171
185
|
derived: true,
|
|
172
186
|
attrs: {},
|
|
@@ -248,7 +262,7 @@ export function derivePieces(model: Model): void {
|
|
|
248
262
|
}
|
|
249
263
|
|
|
250
264
|
/**
|
|
251
|
-
* 描かれた線の切り方を一度に決める — 窓・残す側・片側かどうか (ADR-0022 /
|
|
265
|
+
* 描かれた線の切り方を一度に決める — 窓・残す側・片側かどうか (ADR-0022 / docs/reference/form/index.md-1.3)。
|
|
252
266
|
*
|
|
253
267
|
* **窓と側は必ず一緒に決める。**別々に決めていたために、側は空間の全割付を無限直線で
|
|
254
268
|
* 測るのに切るのは線の近傍だけ、という母集団のずれが生まれ、線から遠い翼が符号を
|
package/src/core/light.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// 対象は `daylight:1` を書いた空間だけ — 型からは推定しない (ADR-0020)。
|
|
8
8
|
// 「どの室に採光の問いを掛けるか」は書き手の宣言であって、core の推定ではない。
|
|
9
9
|
|
|
10
|
-
import { areaM2, isCoveredAbove, isSemiOutdoor, type Model, type Space } from "./model.js";
|
|
10
|
+
import { areaM2, isCoveredAbove, isSemiOutdoor, type Model, type Space, isOutside} from "./model.js";
|
|
11
11
|
|
|
12
12
|
/** 庇下・バルコニー下 (上に空間がある半屋外) 越しの窓の係数 — 縁側補正に倣う粗い値。
|
|
13
13
|
* 上が開いた半屋外 (庭・最上階バルコニー) 越しは 1.0 (ADR-0009) */
|
|
@@ -46,7 +46,7 @@ export function daylightInputs(model: Model): DaylightInput[] {
|
|
|
46
46
|
const os = model.spaces.get(other);
|
|
47
47
|
if (!os) continue;
|
|
48
48
|
const factor =
|
|
49
|
-
os
|
|
49
|
+
isOutside(os)
|
|
50
50
|
? 1
|
|
51
51
|
: isSemiOutdoor(model, os)
|
|
52
52
|
? isCoveredAbove(model, os)
|