@kensnzk/koyu 0.15.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 +14 -10
- package/README.md +16 -13
- package/dist/cli.js +162 -84
- package/dist/cli.js.map +1 -1
- package/dist/core/derive.d.ts +264 -0
- package/dist/core/derive.d.ts.map +1 -0
- package/dist/core/derive.js +576 -0
- package/dist/core/derive.js.map +1 -0
- package/dist/{check.d.ts → core/diagnose.d.ts} +15 -15
- package/dist/core/diagnose.d.ts.map +1 -0
- package/dist/{check.js → core/diagnose.js} +269 -223
- package/dist/core/diagnose.js.map +1 -0
- package/dist/{diff.d.ts → core/diff.d.ts} +3 -2
- package/dist/core/diff.d.ts.map +1 -0
- package/dist/{diff.js → core/diff.js} +89 -43
- package/dist/core/diff.js.map +1 -0
- package/dist/{fabric.d.ts → core/fabric.d.ts} +5 -3
- package/dist/core/fabric.d.ts.map +1 -0
- package/dist/{fabric.js → core/fabric.js} +12 -11
- package/dist/core/fabric.js.map +1 -0
- package/dist/{graph.d.ts → core/graph.d.ts} +2 -4
- package/dist/core/graph.d.ts.map +1 -0
- package/dist/{graph.js → core/graph.js} +53 -54
- package/dist/core/graph.js.map +1 -0
- package/dist/core/light.d.ts +24 -0
- package/dist/core/light.d.ts.map +1 -0
- package/dist/{light.js → core/light.js} +17 -12
- package/dist/core/light.js.map +1 -0
- package/dist/{model.d.ts → core/model.d.ts} +178 -18
- package/dist/core/model.d.ts.map +1 -0
- package/dist/{model.js → core/model.js} +307 -68
- package/dist/core/model.js.map +1 -0
- package/dist/core/parse.d.ts.map +1 -0
- package/dist/{parse.js → core/parse.js} +546 -133
- package/dist/core/parse.js.map +1 -0
- package/dist/{poly.d.ts → core/poly.d.ts} +3 -6
- package/dist/core/poly.d.ts.map +1 -0
- package/dist/{poly.js → core/poly.js} +8 -13
- package/dist/core/poly.js.map +1 -0
- package/dist/core/site.d.ts.map +1 -0
- package/dist/{site.js → core/site.js} +2 -2
- package/dist/core/site.js.map +1 -0
- package/dist/core/tolerance.d.ts +26 -0
- package/dist/core/tolerance.d.ts.map +1 -0
- package/dist/core/tolerance.js +48 -0
- package/dist/core/tolerance.js.map +1 -0
- package/dist/{vertical.d.ts → core/vertical.d.ts} +48 -12
- package/dist/core/vertical.d.ts.map +1 -0
- package/dist/{vertical.js → core/vertical.js} +53 -105
- package/dist/core/vertical.js.map +1 -0
- package/dist/core/vocabulary.d.ts +40 -0
- package/dist/core/vocabulary.d.ts.map +1 -0
- package/dist/core/vocabulary.js +176 -0
- package/dist/core/vocabulary.js.map +1 -0
- package/dist/{axo.d.ts → draw/axo.d.ts} +1 -1
- package/dist/draw/axo.d.ts.map +1 -0
- package/dist/{axo.js → draw/axo.js} +53 -81
- package/dist/draw/axo.js.map +1 -0
- package/dist/draw/index.d.ts +3 -0
- package/dist/draw/index.d.ts.map +1 -0
- package/dist/draw/index.js +11 -0
- package/dist/draw/index.js.map +1 -0
- package/dist/draw/plan.d.ts +10 -0
- package/dist/draw/plan.d.ts.map +1 -0
- package/dist/draw/plan.js +284 -0
- package/dist/draw/plan.js.map +1 -0
- package/dist/index.d.ts +16 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -12
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +112 -50
- package/dist/mcp.js.map +1 -1
- package/dist/parse-file.d.ts +1 -1
- package/dist/parse-file.d.ts.map +1 -1
- package/dist/parse-file.js +19 -4
- package/dist/parse-file.js.map +1 -1
- package/dist/validate/access.d.ts +6 -0
- package/dist/validate/access.d.ts.map +1 -0
- package/dist/validate/access.js +248 -0
- package/dist/validate/access.js.map +1 -0
- package/dist/validate/envelope.d.ts +4 -0
- package/dist/validate/envelope.d.ts.map +1 -0
- package/dist/validate/envelope.js +55 -0
- package/dist/validate/envelope.js.map +1 -0
- package/dist/validate/index.d.ts +60 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +77 -0
- package/dist/validate/index.js.map +1 -0
- package/dist/validate/light.d.ts +6 -0
- package/dist/validate/light.d.ts.map +1 -0
- package/dist/validate/light.js +28 -0
- package/dist/validate/light.js.map +1 -0
- package/dist/validate/runs.d.ts +16 -0
- package/dist/validate/runs.d.ts.map +1 -0
- package/dist/validate/runs.js +60 -0
- package/dist/validate/runs.js.map +1 -0
- package/dist/validate/site.d.ts +6 -0
- package/dist/validate/site.d.ts.map +1 -0
- package/dist/validate/site.js +63 -0
- package/dist/validate/site.js.map +1 -0
- package/editors/vscode/.vscodeignore +2 -0
- package/editors/vscode/README.md +28 -0
- package/editors/vscode/extension.js +150 -0
- package/editors/vscode/language-configuration.json +19 -0
- package/editors/vscode/package.json +57 -0
- package/editors/vscode/syntaxes/koyu.tmLanguage.json +226 -0
- 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 +2 -2
- package/examples/house/site.muro +4 -4
- package/examples/house.muro +7 -7
- package/examples/mansion.muro +3 -3
- package/examples/office.muro +4 -4
- package/examples/steps/01-one-room.muro +1 -1
- package/examples/steps/02-two-rooms.muro +1 -1
- package/examples/steps/03-door.muro +1 -1
- package/examples/steps/04-exterior.muro +2 -2
- package/examples/steps/05-two-storeys.muro +2 -2
- package/examples/steps/06-finished.muro +3 -3
- 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 +2 -2
- package/examples/twin/podium.muro +4 -4
- package/examples/twin/site.muro +8 -8
- package/examples/two-rooms.canonical.json +6 -4
- package/examples/two-rooms.muro +3 -3
- package/package.json +18 -3
- package/src/cli.ts +173 -83
- package/src/core/derive.ts +869 -0
- package/src/{check.ts → core/diagnose.ts} +313 -235
- package/src/{diff.ts → core/diff.ts} +91 -43
- package/src/{fabric.ts → core/fabric.ts} +22 -12
- package/src/{graph.ts → core/graph.ts} +64 -63
- package/src/core/light.ts +69 -0
- package/src/{model.ts → core/model.ts} +361 -74
- package/src/{parse.ts → core/parse.ts} +618 -135
- package/src/{poly.ts → core/poly.ts} +8 -16
- package/src/{site.ts → core/site.ts} +2 -2
- package/src/core/tolerance.ts +55 -0
- package/src/{vertical.ts → core/vertical.ts} +73 -116
- package/src/core/vocabulary.ts +210 -0
- package/src/{axo.ts → draw/axo.ts} +51 -94
- package/src/draw/index.ts +11 -0
- package/src/draw/plan.ts +344 -0
- package/src/index.ts +201 -34
- package/src/mcp.ts +119 -50
- package/src/parse-file.ts +19 -5
- package/src/validate/access.ts +291 -0
- package/src/validate/envelope.ts +59 -0
- package/src/validate/index.ts +107 -0
- package/src/validate/light.ts +43 -0
- package/src/validate/runs.ts +87 -0
- package/src/validate/site.ts +84 -0
- package/dist/axo.d.ts.map +0 -1
- package/dist/axo.js.map +0 -1
- package/dist/check.d.ts.map +0 -1
- package/dist/check.js.map +0 -1
- package/dist/diff.d.ts.map +0 -1
- package/dist/diff.js.map +0 -1
- package/dist/fabric.d.ts.map +0 -1
- package/dist/fabric.js.map +0 -1
- package/dist/graph.d.ts.map +0 -1
- package/dist/graph.js.map +0 -1
- package/dist/light.d.ts +0 -15
- package/dist/light.d.ts.map +0 -1
- package/dist/light.js.map +0 -1
- package/dist/model.d.ts.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/parse.d.ts.map +0 -1
- package/dist/parse.js.map +0 -1
- package/dist/plan.d.ts +0 -10
- package/dist/plan.d.ts.map +0 -1
- package/dist/plan.js +0 -354
- package/dist/plan.js.map +0 -1
- package/dist/poly.d.ts.map +0 -1
- package/dist/poly.js.map +0 -1
- package/dist/site.d.ts.map +0 -1
- package/dist/site.js.map +0 -1
- package/dist/vertical.d.ts.map +0 -1
- package/dist/vertical.js.map +0 -1
- package/src/light.ts +0 -63
- package/src/plan.ts +0 -472
- /package/dist/{parse.d.ts → core/parse.d.ts} +0 -0
- /package/dist/{site.d.ts → core/site.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// koyu — 凸片の幾何 (ADR-
|
|
1
|
+
// koyu — 凸片の幾何 (ADR-0022 / docs/reference/form/index.md)
|
|
2
2
|
//
|
|
3
3
|
// 空間の形は**凸片の集合** (`Pt[][]`) である (ADR-0022)。矩形はその入口の綴りにすぎない。
|
|
4
4
|
// この層が存在しなかったあいだ、面積・被覆・切り分けの計算が model / graph / fabric /
|
|
@@ -11,11 +11,10 @@
|
|
|
11
11
|
// どの範囲で測り、どの範囲を切るのかを、呼び手が必ず一緒に言う。
|
|
12
12
|
|
|
13
13
|
import type { Pt, Rect } from "./model.js";
|
|
14
|
+
import { AREA_EPS, CROSS_EPS, EPS, POINT_EPS } from "./tolerance.js";
|
|
14
15
|
|
|
15
|
-
/** 幾何の許容 mm
|
|
16
|
-
export
|
|
17
|
-
/** 面積の退化の閾値 mm² — 1mm×1mm 未満の片は捨てる */
|
|
18
|
-
const AREA_EPS = 1;
|
|
16
|
+
/** 幾何の許容 mm — 台帳は tolerance.ts が持つ (ADR-0040) */
|
|
17
|
+
export { EPS };
|
|
19
18
|
|
|
20
19
|
// ---- 基本 ----
|
|
21
20
|
|
|
@@ -79,8 +78,8 @@ export function clipHalf(poly: Pt[], a: Pt, b: Pt, keepLeft: boolean): Pt[] {
|
|
|
79
78
|
const q = poly[(i + 1) % poly.length]!;
|
|
80
79
|
const sp = side(p);
|
|
81
80
|
const sq = side(q);
|
|
82
|
-
if (sp >= -
|
|
83
|
-
if ((sp >
|
|
81
|
+
if (sp >= -CROSS_EPS) out.push(p);
|
|
82
|
+
if ((sp > CROSS_EPS && sq < -CROSS_EPS) || (sp < -CROSS_EPS && sq > CROSS_EPS)) {
|
|
84
83
|
const t = sp / (sp - sq);
|
|
85
84
|
out.push({ x: p.x + t * (q.x - p.x), y: p.y + t * (q.y - p.y) });
|
|
86
85
|
}
|
|
@@ -111,9 +110,6 @@ export function splitByRect(pieces: Pt[][], w: Rect): { inside: Pt[][]; outside:
|
|
|
111
110
|
return { inside, outside };
|
|
112
111
|
}
|
|
113
112
|
|
|
114
|
-
/** 軸平行の窓の内側だけ */
|
|
115
|
-
export const clipToRect = (poly: Pt[], w: Rect): Pt[] => splitByRect([poly], w).inside[0] ?? [];
|
|
116
|
-
|
|
117
113
|
/**
|
|
118
114
|
* 凸片から凸片群を引く (差集合)。結果も凸片の集合。
|
|
119
115
|
*
|
|
@@ -169,10 +165,6 @@ export function unionArea(pieces: Pt[][]): number {
|
|
|
169
165
|
return total;
|
|
170
166
|
}
|
|
171
167
|
|
|
172
|
-
/** 凸片の集合から凸片群を引く */
|
|
173
|
-
export const subtractAll = (pieces: Pt[][], covers: Pt[][]): Pt[][] =>
|
|
174
|
-
pieces.flatMap((p) => subtract(p, covers));
|
|
175
|
-
|
|
176
168
|
// ---- 窓 (どの範囲で測り、どの範囲を切るか) ----
|
|
177
169
|
|
|
178
170
|
/**
|
|
@@ -250,7 +242,7 @@ export function cutsInWindow(pieces: Pt[][], w: Rect, a: Pt, b: Pt): boolean {
|
|
|
250
242
|
// ---- 包含 ----
|
|
251
243
|
|
|
252
244
|
/** 点が多角形の辺の上にあるか */
|
|
253
|
-
export function onEdge(p: Pt, poly: Pt[], eps =
|
|
245
|
+
export function onEdge(p: Pt, poly: Pt[], eps = POINT_EPS): boolean {
|
|
254
246
|
for (let i = 0; i < poly.length; i++) {
|
|
255
247
|
const a = poly[i]!;
|
|
256
248
|
const b = poly[(i + 1) % poly.length]!;
|
|
@@ -266,7 +258,7 @@ export function onEdge(p: Pt, poly: Pt[], eps = 1): boolean {
|
|
|
266
258
|
}
|
|
267
259
|
|
|
268
260
|
/** 点が多角形の内側にあるか (境界上は内側扱い) */
|
|
269
|
-
export function pointIn(p: Pt, poly: Pt[], eps =
|
|
261
|
+
export function pointIn(p: Pt, poly: Pt[], eps = POINT_EPS): boolean {
|
|
270
262
|
if (onEdge(p, poly, eps)) return true;
|
|
271
263
|
let inside = false;
|
|
272
264
|
for (let i = 0, j = poly.length - 1; i < poly.length; j = i++) {
|
|
@@ -8,7 +8,6 @@ import { segmentLength, segmentsFor } from "./graph.js";
|
|
|
8
8
|
import {
|
|
9
9
|
areaM2,
|
|
10
10
|
isIndoor,
|
|
11
|
-
isSemiOutdoor,
|
|
12
11
|
polygonAreaM2,
|
|
13
12
|
regionOf,
|
|
14
13
|
unionAreaM2,
|
|
@@ -16,6 +15,7 @@ import {
|
|
|
16
15
|
type SitePolygon,
|
|
17
16
|
type Space,
|
|
18
17
|
type Zone,
|
|
18
|
+
isOutside
|
|
19
19
|
} from "./model.js";
|
|
20
20
|
|
|
21
21
|
export interface RoadFrontage {
|
|
@@ -67,7 +67,7 @@ export function siteReport(model: Model): SiteReport {
|
|
|
67
67
|
// 建物の外壁が道路に面していても、それは接道ではない
|
|
68
68
|
const roads: RoadFrontage[] = [];
|
|
69
69
|
for (const road of spaces) {
|
|
70
|
-
if (road
|
|
70
|
+
if (!isOutside(road) || typeof road.attrs["road"] !== "number") continue;
|
|
71
71
|
let frontage = 0;
|
|
72
72
|
for (const b of model.boundaries) {
|
|
73
73
|
const otherPath = b.a === road.path ? b.b : b.b === road.path ? b.a : undefined;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// koyu — 許容値の族 (ADR-0040)
|
|
2
|
+
//
|
|
3
|
+
// **同じ問いに二つの許容値があってはならない。**
|
|
4
|
+
//
|
|
5
|
+
// これらの数は「どれだけ違えば別のものか」を決める。値がモジュールごとに置かれていた
|
|
6
|
+
// あいだ、`poly.ts` の EPS と `graph.ts` の EPS は同じ 0.5 を別々に持ち、`vertical.ts` は
|
|
7
|
+
// 1 を四箇所に直値で書き、`drawnShare` は軸平行の判定に graph の EPS ではなく直値の 0.5 を
|
|
8
|
+
// 使っていた。どれも同じ値なので事故は起きていないが、**一つを動かしたときに何が動くのかを
|
|
9
|
+
// 誰も言えない**状態だった。許容値は導出の規則の一部であり (docs/reference/form/index.md)、
|
|
10
|
+
// 規則が消費者ごとに違えば同じ原本から違う建物が出る。
|
|
11
|
+
//
|
|
12
|
+
// 座標は mm の整数が基本である。だから長さの許容は 0.5mm — 「これより細かい差は同一」の線が、
|
|
13
|
+
// 整数の刻みの半分に置かれている。面積の許容 1mm² は 1mm×1mm の破片であり、
|
|
14
|
+
// 半平面で切った残りがこれ以下なら形として数えない。
|
|
15
|
+
|
|
16
|
+
/** 長さ・座標の許容 mm。辺の共線・向かい合わせ・区間の一致・共線マージの隙間 */
|
|
17
|
+
export const EPS = 0.5;
|
|
18
|
+
|
|
19
|
+
/** 面積の退化の閾値 mm²。切った残りがこれ以下なら空、左右の面積差がこれ未満なら偏りなし */
|
|
20
|
+
export const AREA_EPS = 1;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 描かれた線の左右を探る距離 mm。**形の解像度の下限である** —
|
|
24
|
+
* この幅を下回る空間は左右のどちらにも判定できず、境界の線分が一本も出ない
|
|
25
|
+
*/
|
|
26
|
+
export const PROBE = 5;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 区間・切断・枠の一致の許容 mm。切断面と部品の z の比較、可視区間の長さの下限、
|
|
30
|
+
* 上る走りと下りる走りが同じ枠かの判定、外皮の穴の長さの下限
|
|
31
|
+
*/
|
|
32
|
+
export const SPAN_EPS = 1;
|
|
33
|
+
|
|
34
|
+
/** 半平面で切るときの符号の許容 (単位は外積 = 面積の二倍)。頂点を残すか、交点を挿むか */
|
|
35
|
+
export const CROSS_EPS = 1e-6;
|
|
36
|
+
|
|
37
|
+
/** 無限直線と線分の平行判定・線分側パラメータの範囲の許容 (無次元) */
|
|
38
|
+
export const PARALLEL_EPS = 1e-9;
|
|
39
|
+
|
|
40
|
+
/** 点が多角形の辺の上にあるとみなす幅 mm (境界上は内側扱い) */
|
|
41
|
+
export const POINT_EPS = 1;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 許容値の台帳。**docs/reference/form/index.md の表の唯一の出所である** —
|
|
45
|
+
* `test/derive.test.ts` が表とここの一致を縛る。
|
|
46
|
+
*/
|
|
47
|
+
export const TOLERANCES: Readonly<Record<string, number>> = {
|
|
48
|
+
EPS,
|
|
49
|
+
AREA_EPS,
|
|
50
|
+
PROBE,
|
|
51
|
+
SPAN_EPS,
|
|
52
|
+
CROSS_EPS,
|
|
53
|
+
PARALLEL_EPS,
|
|
54
|
+
POINT_EPS,
|
|
55
|
+
};
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// 段数も踏面も勾配も書かれない — 書かないが検査する (RUN06 / RUN07)。
|
|
9
9
|
|
|
10
10
|
import { levelsSorted, type Edge, type Model, type Pt, type Rect, type Space } from "./model.js";
|
|
11
|
+
import { EPS, SPAN_EPS } from "./tolerance.js";
|
|
11
12
|
|
|
12
13
|
/** 装置。トポロジーではなく形の生成規則を選ぶ語 */
|
|
13
14
|
export type RunDevice = "stair" | "ramp" | "escalator" | "lift";
|
|
@@ -19,29 +20,30 @@ export type RunForm = "straight" | "return";
|
|
|
19
20
|
export const RUN_FORMS: readonly RunForm[] = ["straight", "return"];
|
|
20
21
|
|
|
21
22
|
/** 既定の蹴上げ上限 mm (riser: で上書き) */
|
|
22
|
-
const DEFAULT_RISER_MAX = 180;
|
|
23
|
-
/** 踏面がこれを下回ると窮屈 (RUN06) */
|
|
24
|
-
const TREAD_MIN = 240;
|
|
23
|
+
export const DEFAULT_RISER_MAX = 180;
|
|
25
24
|
/** 折返し階段の踊り場を導くときの目標踏面 mm (tread: で上書き) */
|
|
26
|
-
const TREAD_TARGET = 300;
|
|
27
|
-
/** 蹴上げ2倍+踏面 の快適域 (RUN06) */
|
|
28
|
-
const STEP_RULE = { lo: 550, hi: 700 };
|
|
29
|
-
/** エスカレーターの標準勾配 (30度 ≒ 1/1.73) と許容 */
|
|
30
|
-
const ESCALATOR_SLOPE = { lo: 1 / 2.3, hi: 1 / 1.4 };
|
|
25
|
+
export const TREAD_TARGET = 300;
|
|
31
26
|
/** 平面図の切断面 — FLからの高さ mm */
|
|
32
27
|
export const CUT_HEIGHT = 1200;
|
|
33
28
|
/** 踊り場の最小奥行 mm */
|
|
34
|
-
const LANDING_MIN = 1100;
|
|
29
|
+
export const LANDING_MIN = 1100;
|
|
35
30
|
/** 乗り込みの床の既定の奥行 mm (entry: で上書き) — 扉が段板に直接ぶつからないための帯 */
|
|
36
|
-
const ENTRY_LANDING = 1100;
|
|
31
|
+
export const ENTRY_LANDING = 1100;
|
|
37
32
|
/** エスカレーター一台の既定の呼び幅 mm (lane: で上書き) */
|
|
38
|
-
const LANE_ESCALATOR = 1200;
|
|
33
|
+
export const LANE_ESCALATOR = 1200;
|
|
39
34
|
/** 平面のエスカレーターの段の刻みのピッチ mm */
|
|
40
|
-
const STEP_MARK = 400;
|
|
35
|
+
export const STEP_MARK = 400;
|
|
41
36
|
/** 段板の見付け厚 (立体) mm */
|
|
42
|
-
const TREAD_SOLID = 200;
|
|
37
|
+
export const TREAD_SOLID = 200;
|
|
43
38
|
/** 斜路・エスカレーター床版の厚さ mm */
|
|
44
|
-
const SLAB_T = 200;
|
|
39
|
+
export const SLAB_T = 200;
|
|
40
|
+
/**
|
|
41
|
+
* The shortest visible run interval that still carries a direction arrow, in mm.
|
|
42
|
+
*
|
|
43
|
+
* Below this the arrow would be longer than what it points along. The comparison is strict, so an
|
|
44
|
+
* interval of exactly this length carries none.
|
|
45
|
+
*/
|
|
46
|
+
export const ARROW_SPAN_MIN = 900;
|
|
45
47
|
|
|
46
48
|
/** 走りと踊り場の一区間。局所座標は t (走り方向) と s (進行方向の左からの幅) */
|
|
47
49
|
export interface RunPart {
|
|
@@ -201,7 +203,7 @@ export function verticalRun(
|
|
|
201
203
|
|
|
202
204
|
const z0 = levels[li]!.z;
|
|
203
205
|
const upper = levels[li + 1];
|
|
204
|
-
if (!upper && device !== "lift") return undefined; // 上る先が無い —
|
|
206
|
+
if (!upper && device !== "lift") return undefined; // 上る先が無い — SUF04
|
|
205
207
|
const z1 = upper?.z ?? z0;
|
|
206
208
|
const rise = z1 - z0;
|
|
207
209
|
|
|
@@ -512,23 +514,33 @@ export interface Seg2 {
|
|
|
512
514
|
y2: number;
|
|
513
515
|
}
|
|
514
516
|
|
|
517
|
+
/**
|
|
518
|
+
* 進む向きを指す線分。**文字列は持たない** — "UP" と "DN" は言葉であって形ではない
|
|
519
|
+
* (docs/reference/scope.md)。この面で人が上るかどうかを `up` が言い、注記は描画側が組む
|
|
520
|
+
*/
|
|
515
521
|
export interface RunArrow extends Seg2 {
|
|
516
|
-
|
|
522
|
+
/** この面でこの走りを進むと上るか */
|
|
523
|
+
up: boolean;
|
|
517
524
|
}
|
|
518
525
|
|
|
519
|
-
/**
|
|
526
|
+
/**
|
|
527
|
+
* そのレベルで切った縦動線の作図。平面図とビュアーが共有する唯一の答え。
|
|
528
|
+
* **色も線種も注記文字列も持たない** (docs/reference/scope.md / docs/reference/form/index.md)
|
|
529
|
+
*/
|
|
520
530
|
export interface RunDraw {
|
|
521
531
|
path: string;
|
|
522
532
|
device: RunDevice;
|
|
533
|
+
/** この面に現れるのは上る走りか、下りる走りか */
|
|
534
|
+
dir: "up" | "down";
|
|
523
535
|
/** 段鼻 (階段) / 段の刻み (エスカレーター) */
|
|
524
536
|
treads: Seg2[];
|
|
525
537
|
/** 輪郭 — 走りの側線・踊り場の縁 */
|
|
526
538
|
outline: Seg2[];
|
|
527
|
-
/**
|
|
539
|
+
/** 走りが切断面を跨ぐ位置を、走りの幅いっぱいに横切る線分。作図慣習の二本の斜線は描画側が引く */
|
|
528
540
|
breaks: Seg2[];
|
|
529
541
|
arrows: RunArrow[];
|
|
530
|
-
/**
|
|
531
|
-
|
|
542
|
+
/** 注記を置く座 (上る走りにだけ、一つ)。**言葉は持たない** — 数は VerticalRun にある */
|
|
543
|
+
anchor?: { x: number; y: number };
|
|
532
544
|
}
|
|
533
545
|
|
|
534
546
|
/**
|
|
@@ -542,11 +554,11 @@ function upWindows(run: VerticalRun, cutZ: number | undefined): Array<[number, n
|
|
|
542
554
|
if (cutZ === undefined) return [p.t0, p.t1] as [number, number];
|
|
543
555
|
const lo = Math.min(p.z0, p.z1);
|
|
544
556
|
const hi = Math.max(p.z0, p.z1);
|
|
545
|
-
if (cutZ >= hi -
|
|
546
|
-
if (cutZ <= lo +
|
|
557
|
+
if (cutZ >= hi - SPAN_EPS) return [p.t0, p.t1] as [number, number]; // 丸ごと切断面より下
|
|
558
|
+
if (cutZ <= lo + SPAN_EPS || hi - lo < SPAN_EPS) return undefined; // 丸ごと上 (踊り場もここ)
|
|
547
559
|
const t = p.t0 + ((cutZ - p.z0) / (p.z1 - p.z0)) * (p.t1 - p.t0);
|
|
548
560
|
const [a, b] = p.z0 < p.z1 ? [p.t0, t] : [t, p.t1];
|
|
549
|
-
return b - a >
|
|
561
|
+
return b - a > SPAN_EPS ? ([a, b] as [number, number]) : undefined;
|
|
550
562
|
});
|
|
551
563
|
}
|
|
552
564
|
|
|
@@ -566,8 +578,8 @@ function downWindows(
|
|
|
566
578
|
if (!w) return [p.t0, p.t1] as [number, number];
|
|
567
579
|
const [a, b] = w;
|
|
568
580
|
// 上りが占めたのが手前側 ([t0,t]) なら残りは奥側、逆なら手前側
|
|
569
|
-
const out: [number, number] = a <= p.t0 +
|
|
570
|
-
return out[1] - out[0] >
|
|
581
|
+
const out: [number, number] = a <= p.t0 + SPAN_EPS ? [b, p.t1] : [p.t0, a];
|
|
582
|
+
return out[1] - out[0] > SPAN_EPS ? out : undefined;
|
|
571
583
|
});
|
|
572
584
|
}
|
|
573
585
|
|
|
@@ -606,10 +618,10 @@ export function runDrawsForLevel(model: Model, level: string, cut = CUT_HEIGHT):
|
|
|
606
618
|
*/
|
|
607
619
|
function sameFrame(a: VerticalRun, b: VerticalRun): boolean {
|
|
608
620
|
return (
|
|
609
|
-
Math.abs(a.rect.x1 - b.rect.x1) <
|
|
610
|
-
Math.abs(a.rect.y1 - b.rect.y1) <
|
|
611
|
-
Math.abs(a.rect.x2 - b.rect.x2) <
|
|
612
|
-
Math.abs(a.rect.y2 - b.rect.y2) <
|
|
621
|
+
Math.abs(a.rect.x1 - b.rect.x1) < SPAN_EPS &&
|
|
622
|
+
Math.abs(a.rect.y1 - b.rect.y1) < SPAN_EPS &&
|
|
623
|
+
Math.abs(a.rect.x2 - b.rect.x2) < SPAN_EPS &&
|
|
624
|
+
Math.abs(a.rect.y2 - b.rect.y2) < SPAN_EPS &&
|
|
613
625
|
a.up === b.up &&
|
|
614
626
|
a.form === b.form &&
|
|
615
627
|
a.device === b.device &&
|
|
@@ -623,7 +635,7 @@ function crossings(run: VerticalRun, cutZ: number): Array<number | undefined> {
|
|
|
623
635
|
if (p.kind !== "flight") return undefined;
|
|
624
636
|
const lo = Math.min(p.z0, p.z1);
|
|
625
637
|
const hi = Math.max(p.z0, p.z1);
|
|
626
|
-
if (cutZ < lo || cutZ > hi || hi - lo <
|
|
638
|
+
if (cutZ < lo || cutZ > hi || hi - lo < SPAN_EPS) return undefined;
|
|
627
639
|
return p.t0 + ((cutZ - p.z0) / (p.z1 - p.z0)) * (p.t1 - p.t0);
|
|
628
640
|
});
|
|
629
641
|
}
|
|
@@ -638,11 +650,11 @@ function drawRun(
|
|
|
638
650
|
const draw: RunDraw = {
|
|
639
651
|
path: run.path,
|
|
640
652
|
device: run.device,
|
|
653
|
+
dir,
|
|
641
654
|
treads: [],
|
|
642
655
|
outline: [],
|
|
643
656
|
breaks: [],
|
|
644
657
|
arrows: [],
|
|
645
|
-
notes: [],
|
|
646
658
|
};
|
|
647
659
|
const { rect, up } = run;
|
|
648
660
|
const seg = (t0: number, s0: number, t1: number, s1: number): Seg2 => {
|
|
@@ -675,12 +687,12 @@ function drawRun(
|
|
|
675
687
|
|
|
676
688
|
if (run.device === "stair") {
|
|
677
689
|
const d = (p.t1 - p.t0) / Math.max(1, (p.risers ?? 2) - 1);
|
|
678
|
-
for (let t = p.t0 + d; t < p.t1 -
|
|
679
|
-
if (t < lo -
|
|
690
|
+
for (let t = p.t0 + d; t < p.t1 - SPAN_EPS; t += d) {
|
|
691
|
+
if (t < lo - EPS || t > hi + EPS) continue;
|
|
680
692
|
draw.treads.push(seg(t, p.s0, t, p.s1));
|
|
681
693
|
}
|
|
682
694
|
} else if (run.device === "escalator") {
|
|
683
|
-
for (let t = lo + STEP_MARK; t < hi -
|
|
695
|
+
for (let t = lo + STEP_MARK; t < hi - SPAN_EPS; t += STEP_MARK) {
|
|
684
696
|
draw.treads.push(seg(t, p.s0, t, p.s1));
|
|
685
697
|
}
|
|
686
698
|
}
|
|
@@ -690,7 +702,7 @@ function drawRun(
|
|
|
690
702
|
const isFirst = i === run.parts.findIndex((q) => q.kind === "flight");
|
|
691
703
|
const isLast = i === run.parts.map((q) => q.kind).lastIndexOf("flight");
|
|
692
704
|
const wantArrow = run.device === "escalator" ? true : dir === "up" ? isFirst : isLast;
|
|
693
|
-
if (wantArrow && hi - lo >
|
|
705
|
+
if (wantArrow && hi - lo > ARROW_SPAN_MIN) {
|
|
694
706
|
const c = (p.s0 + p.s1) / 2;
|
|
695
707
|
// **矢印は人の進む向きだけから決まる。**reversed が「t の減る向きに進む」、
|
|
696
708
|
// 昇り降りは進む先の高さで決まる。エスカレーターは機械の向きが固定なので
|
|
@@ -701,11 +713,12 @@ function drawRun(
|
|
|
701
713
|
const back = flip ? !p.reversed : p.reversed; // t が減る向きに進むか
|
|
702
714
|
const from = back ? hi - 150 : lo + 150;
|
|
703
715
|
const to = back ? lo + 150 : hi - 150;
|
|
704
|
-
draw.arrows.push({ ...seg(from, c, to, c),
|
|
716
|
+
draw.arrows.push({ ...seg(from, c, to, c), up: goUp });
|
|
705
717
|
}
|
|
706
718
|
}
|
|
707
719
|
|
|
708
|
-
// 切断線:
|
|
720
|
+
// 切断線: 走りが切断面を跨ぐ位置を、走りの幅いっぱいに横切る一本の線分として返す。
|
|
721
|
+
// **作図慣習 (平行な二本の斜線・その振り分け寸法) は描画側が持つ** — 形は跨いだ位置だけである
|
|
709
722
|
if (dir === "up" && cross) {
|
|
710
723
|
// 並列の台はどれも同じ高さで切られる。切断線は**跨いだ走りに、その走り自身の
|
|
711
724
|
// 位置で**引く — 一台の位置を全台に配ると、何も無い所に線が乗る
|
|
@@ -713,32 +726,23 @@ function drawRun(
|
|
|
713
726
|
const p = run.parts[i]!;
|
|
714
727
|
const ct = cross[i];
|
|
715
728
|
if (ct === undefined || !windows?.[i]) continue;
|
|
716
|
-
|
|
717
|
-
const off = Math.min(220, g);
|
|
718
|
-
draw.breaks.push(
|
|
719
|
-
seg(ct - g - off, p.s0, ct + g - off, p.s1),
|
|
720
|
-
seg(ct - g + off, p.s0, ct + g + off, p.s1),
|
|
721
|
-
);
|
|
729
|
+
draw.breaks.push(seg(ct, p.s0, ct, p.s1));
|
|
722
730
|
}
|
|
723
731
|
}
|
|
724
732
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
x: (rect.x1 + rect.x2) / 2,
|
|
728
|
-
y: (rect.y1 + rect.y2) / 2,
|
|
729
|
-
text:
|
|
730
|
-
run.device === "stair"
|
|
731
|
-
? `${run.risers}段 蹴上${Math.round(run.riser)}/踏面${Math.round(run.tread)}`
|
|
732
|
-
: `${run.lanes > 1 ? `${run.lanes}台 ` : ""}勾配 ${slopeText(run.slope)}`,
|
|
733
|
-
});
|
|
734
|
-
}
|
|
733
|
+
// 注記の座だけを返す。段数も勾配も VerticalRun が持っており、言葉にするのは描画側である
|
|
734
|
+
if (dir === "up") draw.anchor = { x: (rect.x1 + rect.x2) / 2, y: (rect.y1 + rect.y2) / 2 };
|
|
735
735
|
return draw;
|
|
736
736
|
}
|
|
737
737
|
|
|
738
738
|
// ---- 検査の材料 (check.ts が言葉にする) ----
|
|
739
739
|
|
|
740
|
-
/**
|
|
741
|
-
|
|
740
|
+
/**
|
|
741
|
+
* runIssues が出しうる診断コード (ADR-0016 の台帳の部分集合 — check の emit が型で受ける)。
|
|
742
|
+
* SUF04 だけ族が違う — 「形が一つも生成されない」は縦動線の話ではなく充足性の話であり、
|
|
743
|
+
* コードは SUF に属したまま、この走査の順に出る (節の粒度は走査単位である — ADR-0028 / ADR-0034)
|
|
744
|
+
*/
|
|
745
|
+
export type RunCode = "RUN01" | "RUN02" | "RUN03" | "RUN05" | "SUF04";
|
|
742
746
|
|
|
743
747
|
export interface RunIssue {
|
|
744
748
|
code: RunCode;
|
|
@@ -749,21 +753,13 @@ export interface RunIssue {
|
|
|
749
753
|
}
|
|
750
754
|
|
|
751
755
|
/**
|
|
752
|
-
*
|
|
753
|
-
* (
|
|
754
|
-
*
|
|
756
|
+
* 縦動線の構造整合 (RUN01..03 / RUN05 と、形が一つも生成されない SUF04) — **宣言から形が一意に決まるか**だけを見る。
|
|
757
|
+
* 決まった形が登りやすいか (段の窮屈さ・勾配・上下の繋がり) は建築の側の判断で、
|
|
758
|
+
* 検証の面 (src/validate/runs.ts) が持つ。ここは合否を言わない (ADR-0021)。
|
|
755
759
|
*/
|
|
756
760
|
export function runIssues(model: Model): RunIssue[] {
|
|
757
761
|
const out: RunIssue[] = [];
|
|
758
762
|
const levels = levelsSorted(model);
|
|
759
|
-
const stairLinked = new Set<string>();
|
|
760
|
-
for (const b of model.boundaries) {
|
|
761
|
-
if (b.kind === "stair" || b.kind === "shaft") {
|
|
762
|
-
stairLinked.add(b.a);
|
|
763
|
-
stairLinked.add(b.b);
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
|
|
767
763
|
for (const s of model.spaces.values()) {
|
|
768
764
|
const decls = runDecls(s);
|
|
769
765
|
if (decls.length === 0) continue;
|
|
@@ -771,7 +767,7 @@ export function runIssues(model: Model): RunIssue[] {
|
|
|
771
767
|
if (decls.length > 1) {
|
|
772
768
|
out.push({
|
|
773
769
|
code: "RUN01",
|
|
774
|
-
message:
|
|
770
|
+
message: `More than one vertical circulation declaration: ${decls.map((d) => `${d.device}:${d.value}`).join(" ")} (one space carries one)`,
|
|
775
771
|
...at,
|
|
776
772
|
});
|
|
777
773
|
continue;
|
|
@@ -782,8 +778,8 @@ export function runIssues(model: Model): RunIssue[] {
|
|
|
782
778
|
code: "RUN02",
|
|
783
779
|
message:
|
|
784
780
|
device === "lift"
|
|
785
|
-
? `lift
|
|
786
|
-
:
|
|
781
|
+
? `The value of lift is 1: lift:${value}`
|
|
782
|
+
: `The value of ${device} is the direction it rises, N/E/S/W: ${device}:${value}`,
|
|
787
783
|
...at,
|
|
788
784
|
});
|
|
789
785
|
continue;
|
|
@@ -793,21 +789,21 @@ export function runIssues(model: Model): RunIssue[] {
|
|
|
793
789
|
code: "RUN03",
|
|
794
790
|
message:
|
|
795
791
|
s.rects.length === 0
|
|
796
|
-
?
|
|
797
|
-
:
|
|
792
|
+
? `Vertical circulation requires a region: ${s.path}`
|
|
793
|
+
: `The region of vertical circulation is a single rectangle (a union leaves the step division undetermined): ${s.path}`,
|
|
798
794
|
...at,
|
|
799
795
|
});
|
|
800
796
|
continue;
|
|
801
797
|
}
|
|
802
798
|
if (!s.level) {
|
|
803
|
-
out.push({ code: "RUN03", message:
|
|
799
|
+
out.push({ code: "RUN03", message: `The level of the vertical circulation cannot be determined: ${s.path}`, ...at });
|
|
804
800
|
continue;
|
|
805
801
|
}
|
|
806
802
|
const formRaw = String(s.attrs["form"] ?? "straight");
|
|
807
803
|
if (!RUN_FORMS.includes(formRaw as RunForm)) {
|
|
808
804
|
out.push({
|
|
809
805
|
code: "RUN05",
|
|
810
|
-
message: `form
|
|
806
|
+
message: `form is ${RUN_FORMS.join(" / ")}: form:${formRaw} (write a spiral as a succession of turns)`,
|
|
811
807
|
...at,
|
|
812
808
|
});
|
|
813
809
|
continue;
|
|
@@ -815,7 +811,7 @@ export function runIssues(model: Model): RunIssue[] {
|
|
|
815
811
|
if (device !== "stair" && device !== "ramp" && formRaw !== "straight") {
|
|
816
812
|
out.push({
|
|
817
813
|
code: "RUN05",
|
|
818
|
-
message:
|
|
814
|
+
message: `form:${formRaw} may not be written on ${device} (only a stair and a ramp turn back)`,
|
|
819
815
|
...at,
|
|
820
816
|
});
|
|
821
817
|
continue;
|
|
@@ -824,8 +820,8 @@ export function runIssues(model: Model): RunIssue[] {
|
|
|
824
820
|
const li = levels.findIndex((l) => l.name === s.level);
|
|
825
821
|
if (device !== "lift" && (li < 0 || !levels[li + 1])) {
|
|
826
822
|
out.push({
|
|
827
|
-
code: "
|
|
828
|
-
message:
|
|
823
|
+
code: "SUF04",
|
|
824
|
+
message: `No level sits above ${s.level}, so no form is generated for ${s.path}`,
|
|
829
825
|
...at,
|
|
830
826
|
});
|
|
831
827
|
continue;
|
|
@@ -835,50 +831,11 @@ export function runIssues(model: Model): RunIssue[] {
|
|
|
835
831
|
if (!run) {
|
|
836
832
|
out.push({
|
|
837
833
|
code: "RUN05",
|
|
838
|
-
message:
|
|
834
|
+
message: `The form of the vertical circulation is undetermined: ${s.path} (check that the landing does not exceed the full length)`,
|
|
839
835
|
...at,
|
|
840
836
|
});
|
|
841
837
|
continue;
|
|
842
838
|
}
|
|
843
|
-
if (device === "lift") continue;
|
|
844
|
-
|
|
845
|
-
if (!stairLinked.has(s.path)) {
|
|
846
|
-
out.push({
|
|
847
|
-
code: "RUN08",
|
|
848
|
-
message: `${s.path} は縦動線の形を持ちますが、上下を繋ぐ垂直境界がありません (stack か boundary type:stair を書きます — 形はあってもグラフでは通れません)`,
|
|
849
|
-
...at,
|
|
850
|
-
});
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
if (device === "stair") {
|
|
854
|
-
const t = Math.round(run.tread);
|
|
855
|
-
const r = Math.round(run.riser);
|
|
856
|
-
const rule = 2 * r + t;
|
|
857
|
-
if (t < TREAD_MIN || rule < STEP_RULE.lo || rule > STEP_RULE.hi) {
|
|
858
|
-
out.push({
|
|
859
|
-
code: "RUN06",
|
|
860
|
-
message: `導出された段の寸法が窮屈です: ${run.risers}段 蹴上${r}mm / 踏面${t}mm (2×蹴上+踏面 = ${Math.round(rule)}mm、目安 ${STEP_RULE.lo}〜${STEP_RULE.hi}mm)`,
|
|
861
|
-
...at,
|
|
862
|
-
});
|
|
863
|
-
}
|
|
864
|
-
} else if (device === "ramp") {
|
|
865
|
-
const declared = s.attrs["slope"];
|
|
866
|
-
if (typeof declared === "number" && declared > 0 && run.slope > 1 / declared + 1e-9) {
|
|
867
|
-
out.push({
|
|
868
|
-
code: "RUN07",
|
|
869
|
-
message: `導出された勾配 ${slopeText(run.slope)} が宣言 1/${declared} より急です (走り長を伸ばすか階高を下げます)`,
|
|
870
|
-
...at,
|
|
871
|
-
});
|
|
872
|
-
}
|
|
873
|
-
} else if (device === "escalator") {
|
|
874
|
-
if (run.slope < ESCALATOR_SLOPE.lo || run.slope > ESCALATOR_SLOPE.hi) {
|
|
875
|
-
out.push({
|
|
876
|
-
code: "RUN07",
|
|
877
|
-
message: `導出された勾配 ${slopeText(run.slope)} はエスカレーターの常用域 (約1/1.7 = 30度) から外れています`,
|
|
878
|
-
...at,
|
|
879
|
-
});
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
839
|
}
|
|
883
840
|
return out;
|
|
884
841
|
}
|