@kensnzk/koyu 0.15.0 → 0.16.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 +2 -2
- package/README.md +3 -3
- package/dist/cli.js +156 -81
- package/dist/cli.js.map +1 -1
- package/dist/core/derive.d.ts +259 -0
- package/dist/core/derive.d.ts.map +1 -0
- package/dist/core/derive.js +570 -0
- package/dist/core/derive.js.map +1 -0
- package/dist/{check.d.ts → core/diagnose.d.ts} +11 -12
- package/dist/core/diagnose.d.ts.map +1 -0
- package/dist/{check.js → core/diagnose.js} +232 -221
- package/dist/core/diagnose.js.map +1 -0
- package/dist/core/diff.d.ts.map +1 -0
- package/dist/{diff.js → core/diff.js} +84 -41
- package/dist/core/diff.js.map +1 -0
- package/dist/{fabric.d.ts → core/fabric.d.ts} +4 -0
- package/dist/core/fabric.d.ts.map +1 -0
- package/dist/{fabric.js → core/fabric.js} +4 -3
- package/dist/core/fabric.js.map +1 -0
- package/dist/{graph.d.ts → core/graph.d.ts} +1 -3
- package/dist/core/graph.d.ts.map +1 -0
- package/dist/{graph.js → core/graph.js} +43 -51
- 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} +15 -10
- package/dist/core/light.js.map +1 -0
- package/dist/{model.d.ts → core/model.d.ts} +124 -13
- package/dist/core/model.d.ts.map +1 -0
- package/dist/{model.js → core/model.js} +186 -49
- package/dist/core/model.js.map +1 -0
- package/dist/core/parse.d.ts.map +1 -0
- package/dist/{parse.js → core/parse.js} +528 -116
- package/dist/core/parse.js.map +1 -0
- package/dist/{poly.d.ts → core/poly.d.ts} +3 -2
- package/dist/core/poly.d.ts.map +1 -0
- package/dist/{poly.js → core/poly.js} +8 -9
- package/dist/core/poly.js.map +1 -0
- package/dist/core/site.d.ts.map +1 -0
- 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} +41 -12
- package/dist/core/vertical.d.ts.map +1 -0
- package/dist/{vertical.js → core/vertical.js} +45 -104
- 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 +164 -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 +15 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -12
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +71 -40
- 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 +1 -1
- 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 +238 -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 +1 -1
- package/examples/complex/main.muro +1 -1
- package/examples/house/main.muro +2 -2
- package/examples/house.muro +2 -2
- package/examples/mansion.muro +2 -2
- package/examples/office.muro +2 -2
- 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 +1 -1
- package/examples/steps/05-two-storeys.muro +1 -1
- package/examples/steps/06-finished.muro +2 -2
- package/examples/tower/main.muro +1 -1
- package/examples/twin/main.muro +2 -2
- package/examples/two-rooms.canonical.json +4 -2
- package/examples/two-rooms.muro +2 -2
- package/package.json +16 -1
- package/spec/README.md +28 -0
- package/spec/canonical-json.md +98 -0
- package/spec/composition.md +121 -0
- package/spec/derivation.md +393 -0
- package/spec/en/README.md +30 -0
- package/spec/en/canonical-json.md +101 -0
- package/spec/en/composition.md +121 -0
- package/spec/en/derivation.md +393 -0
- package/spec/en/language.md +164 -0
- package/spec/en/notation-v0.md +145 -0
- package/spec/en/scope.md +229 -0
- package/spec/en/semantics.md +132 -0
- package/spec/en/tools.md +108 -0
- package/spec/en/validation.md +79 -0
- package/spec/en/vocabulary.md +103 -0
- package/spec/language.md +163 -0
- package/spec/notation-v0.md +184 -0
- package/spec/scope.md +229 -0
- package/spec/semantics.md +130 -0
- package/spec/tools.md +106 -0
- package/spec/validation.md +79 -0
- package/spec/vocabulary.md +114 -0
- package/src/cli.ts +165 -80
- package/src/core/derive.ts +852 -0
- package/src/{check.ts → core/diagnose.ts} +260 -229
- package/src/{diff.ts → core/diff.ts} +84 -40
- package/src/{fabric.ts → core/fabric.ts} +4 -3
- package/src/{graph.ts → core/graph.ts} +47 -60
- package/src/core/light.ts +69 -0
- package/src/{model.ts → core/model.ts} +228 -51
- package/src/{parse.ts → core/parse.ts} +584 -116
- package/src/{poly.ts → core/poly.ts} +8 -9
- package/src/core/tolerance.ts +55 -0
- package/src/{vertical.ts → core/vertical.ts} +65 -115
- package/src/core/vocabulary.ts +197 -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 +181 -35
- package/src/mcp.ts +76 -40
- package/src/parse-file.ts +2 -2
- package/src/validate/access.ts +279 -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/{diff.d.ts → core/diff.d.ts} +0 -0
- /package/dist/{parse.d.ts → core/parse.d.ts} +0 -0
- /package/dist/{site.d.ts → core/site.d.ts} +0 -0
- /package/dist/{site.js → core/site.js} +0 -0
- /package/src/{site.ts → core/site.ts} +0 -0
package/src/plan.ts
DELETED
|
@@ -1,472 +0,0 @@
|
|
|
1
|
-
// koyu v0 — 平面図の生成
|
|
2
|
-
// ソースに形は無い。形は必要になった時にルールから生成する。まず平面図、その後に三次元。
|
|
3
|
-
// 壁は「二つの空間の境界」から導かれて現れる — 壁を描く操作はどこにも無い。
|
|
4
|
-
|
|
5
|
-
import { placeBand, placeOpening, segmentsFor, type Segment } from "./graph.js";
|
|
6
|
-
import {
|
|
7
|
-
areaM2,
|
|
8
|
-
columnsFor,
|
|
9
|
-
displayName,
|
|
10
|
-
regionOf,
|
|
11
|
-
isSemiOutdoor,
|
|
12
|
-
polygonAreaM2,
|
|
13
|
-
polyBounds,
|
|
14
|
-
rectToPoly,
|
|
15
|
-
type Boundary,
|
|
16
|
-
type Model,
|
|
17
|
-
type Opening,
|
|
18
|
-
type Pt,
|
|
19
|
-
} from "./model.js";
|
|
20
|
-
import { runDrawsForLevel, CUT_HEIGHT } from "./vertical.js";
|
|
21
|
-
|
|
22
|
-
export interface PlanOptions {
|
|
23
|
-
level?: string;
|
|
24
|
-
/** px per mm */
|
|
25
|
-
scale?: number;
|
|
26
|
-
/** 切断面の高さ mm (FLから) — 縦動線がどこで切れるかを決める */
|
|
27
|
-
cut?: number;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const WALL_DEFAULT_T = 100;
|
|
31
|
-
const INK = "#1f1f1f";
|
|
32
|
-
const PAPER = "#faf8f4";
|
|
33
|
-
const ROOM = "#f1ebdd";
|
|
34
|
-
const GRID = "#b5aa94";
|
|
35
|
-
|
|
36
|
-
export function svgPlan(model: Model, opts: PlanOptions = {}): string {
|
|
37
|
-
const level = opts.level ?? Object.keys(model.levels)[0];
|
|
38
|
-
if (!level) throw new Error("レベルが定義されていません");
|
|
39
|
-
const scale = opts.scale ?? 0.05;
|
|
40
|
-
|
|
41
|
-
const rooms = [...model.spaces.values()].filter(
|
|
42
|
-
(s) => s.rects.length > 0 && s.level === level,
|
|
43
|
-
);
|
|
44
|
-
if (rooms.length === 0) throw new Error(`レベル ${level} に領域を持つ空間がありません`);
|
|
45
|
-
|
|
46
|
-
// 敷地形状 (ADR-0011) は最下階の平面 (配置図兼用) に敷地境界線として描く
|
|
47
|
-
const lowest = Object.values(model.levels).sort((a, b) => a.z - b.z)[0]?.name;
|
|
48
|
-
const sitePolys = level === lowest ? [...model.polygons.values()] : [];
|
|
49
|
-
|
|
50
|
-
const allRects = rooms.flatMap((s) => s.rects);
|
|
51
|
-
const polyPts = [
|
|
52
|
-
...sitePolys.flatMap((p) => p.points),
|
|
53
|
-
...rooms.flatMap((s) => s.pieces.flat()),
|
|
54
|
-
];
|
|
55
|
-
const minX = Math.min(...allRects.map((r) => r.x1), ...polyPts.map((p) => p.x));
|
|
56
|
-
const maxX = Math.max(...allRects.map((r) => r.x2), ...polyPts.map((p) => p.x));
|
|
57
|
-
const minY = Math.min(...allRects.map((r) => r.y1), ...polyPts.map((p) => p.y));
|
|
58
|
-
const maxY = Math.max(...allRects.map((r) => r.y2), ...polyPts.map((p) => p.y));
|
|
59
|
-
|
|
60
|
-
const M = 84; // 余白 px (通り芯記号ぶん)
|
|
61
|
-
const W = (maxX - minX) * scale + M * 2;
|
|
62
|
-
const H = (maxY - minY) * scale + M * 2;
|
|
63
|
-
const sx = (x: number) => (x - minX) * scale + M;
|
|
64
|
-
const sy = (y: number) => (maxY - y) * scale + M;
|
|
65
|
-
|
|
66
|
-
const parts: string[] = [];
|
|
67
|
-
parts.push(
|
|
68
|
-
`<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}" font-family="'Hiragino Sans','Noto Sans JP',sans-serif">`,
|
|
69
|
-
);
|
|
70
|
-
parts.push(`<rect width="${W}" height="${H}" fill="${PAPER}"/>`);
|
|
71
|
-
|
|
72
|
-
// 敷地境界線 (一点二点鎖線 — 作図慣習)。形は生成しない: 書かれた所与の形をそのまま引く
|
|
73
|
-
for (const poly of sitePolys) {
|
|
74
|
-
const d = poly.points.map((pt, i) => `${i === 0 ? "M" : "L"} ${sx(pt.x)} ${sy(pt.y)}`).join(" ");
|
|
75
|
-
parts.push(
|
|
76
|
-
`<path d="${d} Z" fill="none" stroke="#8a8171" stroke-width="1.1" stroke-dasharray="14 3 2.5 3 2.5 3"/>`,
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// 空間の面 — 導出された凸片 (ADR-0022)。描かれた線で切られていれば斜めの面になる。
|
|
81
|
-
// 同色・輪郭なしなのでL字も切られた形も一体に見える。
|
|
82
|
-
// 半屋外 (外部にopen/railで接する空間) は淡く塗り分け、屋外であることが図から読めるように
|
|
83
|
-
const path2d = (poly: Pt[]): string =>
|
|
84
|
-
poly.map((p, i) => `${i === 0 ? "M" : "L"} ${sx(p.x)} ${sy(p.y)}`).join(" ") + " Z";
|
|
85
|
-
for (const s of rooms) {
|
|
86
|
-
const isVoid = s.type === "void";
|
|
87
|
-
const semi = isSemiOutdoor(model, s);
|
|
88
|
-
for (const poly of regionOf(s)) {
|
|
89
|
-
parts.push(
|
|
90
|
-
`<path d="${path2d(poly)}" fill="${isVoid ? PAPER : semi ? "#f8f5ec" : ROOM}"/>`,
|
|
91
|
-
);
|
|
92
|
-
if (isVoid) {
|
|
93
|
-
// 吹抜け: 破線の対角線 (作図慣習)
|
|
94
|
-
const r = polyBounds(poly);
|
|
95
|
-
parts.push(
|
|
96
|
-
`<line x1="${sx(r.x1)}" y1="${sy(r.y1)}" x2="${sx(r.x2)}" y2="${sy(r.y2)}" stroke="#b3ab9c" stroke-width="0.8" stroke-dasharray="6 4"/>`,
|
|
97
|
-
`<line x1="${sx(r.x1)}" y1="${sy(r.y2)}" x2="${sx(r.x2)}" y2="${sy(r.y1)}" stroke="#b3ab9c" stroke-width="0.8" stroke-dasharray="6 4"/>`,
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// 数えない分節 (area): 床材の切替など。面積にもグラフにも現れない — 淡い面と破線で示す
|
|
104
|
-
for (const s of rooms) {
|
|
105
|
-
for (const a of s.areas) {
|
|
106
|
-
const r = a.rect;
|
|
107
|
-
parts.push(
|
|
108
|
-
`<rect x="${sx(r.x1)}" y="${sy(r.y2)}" width="${(r.x2 - r.x1) * scale}" height="${(r.y2 - r.y1) * scale}" fill="#e7dfcc" fill-opacity="0.55" stroke="#b3ab9c" stroke-width="0.8" stroke-dasharray="4 3"/>`,
|
|
109
|
-
);
|
|
110
|
-
const label = [a.attrs["name"], a.attrs["floor"]]
|
|
111
|
-
.filter((v): v is string => typeof v === "string")
|
|
112
|
-
.join(" ・ ");
|
|
113
|
-
if (label) {
|
|
114
|
-
parts.push(
|
|
115
|
-
`<text x="${sx(r.x1) + 6}" y="${sy(r.y2) + 12}" font-size="8.5" fill="#8a8171">${esc(label)}</text>`,
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// 通り芯
|
|
122
|
-
for (const [i, x] of model.grid.X.coords.entries()) {
|
|
123
|
-
if (x < minX - 1 || x > maxX + 1) continue;
|
|
124
|
-
const name = model.grid.X.names[i]!;
|
|
125
|
-
parts.push(
|
|
126
|
-
`<line x1="${sx(x)}" y1="${M - 26}" x2="${sx(x)}" y2="${H - M + 26}" stroke="${GRID}" stroke-width="0.8" stroke-dasharray="7 3 1.5 3"/>`,
|
|
127
|
-
`<circle cx="${sx(x)}" cy="${M - 40}" r="11" fill="none" stroke="${GRID}" stroke-width="1"/>`,
|
|
128
|
-
`<text x="${sx(x)}" y="${M - 36}" text-anchor="middle" font-size="10" fill="${GRID}">${name}</text>`,
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
for (const [i, y] of model.grid.Y.coords.entries()) {
|
|
132
|
-
if (y < minY - 1 || y > maxY + 1) continue;
|
|
133
|
-
const name = model.grid.Y.names[i]!;
|
|
134
|
-
parts.push(
|
|
135
|
-
`<line x1="${M - 26}" y1="${sy(y)}" x2="${W - M + 26}" y2="${sy(y)}" stroke="${GRID}" stroke-width="0.8" stroke-dasharray="7 3 1.5 3"/>`,
|
|
136
|
-
`<circle cx="${M - 40}" cy="${sy(y)}" r="11" fill="none" stroke="${GRID}" stroke-width="1"/>`,
|
|
137
|
-
`<text x="${M - 40}" y="${sy(y) + 3.5}" text-anchor="middle" font-size="10" fill="${GRID}">${name}</text>`,
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// 壁 (境界から生成)。このレベルに触れる境界だけを描く
|
|
142
|
-
const placedOpenings: Array<{ b: Boundary; o: Opening; seg: Segment; cx: number; cy: number }> = [];
|
|
143
|
-
for (const b of model.boundaries) {
|
|
144
|
-
const onLevel = [b.a, b.b].some((p) => model.spaces.get(p)?.level === level);
|
|
145
|
-
if (!onLevel) continue;
|
|
146
|
-
if (b.kind === "open") {
|
|
147
|
-
// 開放的な分節: 壁は無いが構成の線として破線で示す (基本計画の抽象度)
|
|
148
|
-
for (const seg of segmentsFor(model, b)) {
|
|
149
|
-
parts.push(
|
|
150
|
-
`<line x1="${sx(seg.x1)}" y1="${sy(seg.y1)}" x2="${sx(seg.x2)}" y2="${sy(seg.y2)}" stroke="#b3ab9c" stroke-width="1" stroke-dasharray="6 4"/>`,
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
if (b.kind !== "wall") continue;
|
|
156
|
-
if (b.air) {
|
|
157
|
-
// 遮蔽しない物 (手すり・柵 = spec語彙): 細実線 —
|
|
158
|
-
// 壁の黒帯と描き分けることで「囲われていない」ことが図から読める
|
|
159
|
-
for (const seg of segmentsFor(model, b)) {
|
|
160
|
-
parts.push(
|
|
161
|
-
`<line x1="${sx(seg.x1)}" y1="${sy(seg.y1)}" x2="${sx(seg.x2)}" y2="${sy(seg.y2)}" stroke="${INK}" stroke-width="1.4"/>`,
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
// 柵の扉 (門扉など): 線を切って軌跡を描く
|
|
165
|
-
for (const o of b.openings) {
|
|
166
|
-
if (o.kind !== "door") continue;
|
|
167
|
-
const placed = placeOpening(model, b, o);
|
|
168
|
-
if (!("error" in placed)) {
|
|
169
|
-
parts.push(bandRect(placed.segment, o.w, placed.cx, placed.cy, 120, scale, sx, sy, PAPER));
|
|
170
|
-
parts.push(doorSwing(model, b, o, placed.segment, placed.cx, placed.cy, scale, sx, sy));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
const t = b.t ?? WALL_DEFAULT_T;
|
|
176
|
-
for (const seg of segmentsFor(model, b)) {
|
|
177
|
-
parts.push(wallRect(seg, t, scale, sx, sy));
|
|
178
|
-
}
|
|
179
|
-
// 数えない分節 (seg): 壁材が途中から変わる区間 — 色調を変えて示す
|
|
180
|
-
for (const g of b.segs) {
|
|
181
|
-
const placed = placeBand(model, b, g, "seg");
|
|
182
|
-
if (!("error" in placed)) {
|
|
183
|
-
parts.push(bandRect(placed.segment, g.w, placed.cx, placed.cy, t, scale, sx, sy, "#77716a"));
|
|
184
|
-
const spec = g.attrs["spec"];
|
|
185
|
-
if (typeof spec === "string") {
|
|
186
|
-
const horizontal = placed.segment.horizontal;
|
|
187
|
-
parts.push(
|
|
188
|
-
`<text x="${sx(placed.cx) + (horizontal ? 0 : 8)}" y="${sy(placed.cy) + (horizontal ? -7 : 3)}" text-anchor="${horizontal ? "middle" : "start"}" font-size="8" fill="#77716a">${esc(spec)}</text>`,
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
for (const o of b.openings) {
|
|
194
|
-
const placed = placeOpening(model, b, o);
|
|
195
|
-
if (!("error" in placed && placed.error) && "segment" in placed) {
|
|
196
|
-
placedOpenings.push({ b, o, seg: placed.segment, cx: placed.cx, cy: placed.cy });
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// 開口 (壁を欠き取り、扉は吊元と軌跡を描く)
|
|
202
|
-
for (const { b, o, seg, cx, cy } of placedOpenings) {
|
|
203
|
-
const t = (b.t ?? WALL_DEFAULT_T) + 30; // 欠き取りは少し深く
|
|
204
|
-
parts.push(bandRect(seg, o.w, cx, cy, t, scale, sx, sy, PAPER));
|
|
205
|
-
if (o.kind === "door") {
|
|
206
|
-
parts.push(doorSwing(model, b, o, seg, cx, cy, scale, sx, sy));
|
|
207
|
-
} else {
|
|
208
|
-
// 窓: 芯線一本
|
|
209
|
-
const wpx = o.w * scale;
|
|
210
|
-
if (seg.horizontal) {
|
|
211
|
-
parts.push(
|
|
212
|
-
`<line x1="${sx(cx) - wpx / 2}" y1="${sy(cy)}" x2="${sx(cx) + wpx / 2}" y2="${sy(cy)}" stroke="${INK}" stroke-width="1"/>`,
|
|
213
|
-
);
|
|
214
|
-
} else {
|
|
215
|
-
parts.push(
|
|
216
|
-
`<line x1="${sx(cx)}" y1="${sy(cy) - wpx / 2}" x2="${sx(cx)}" y2="${sy(cy) + wpx / 2}" stroke="${INK}" stroke-width="1"/>`,
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// 柱 (ADR-0023) — 位置はどこにも書かれていない。通り芯の交点と床の交わりから現れる
|
|
223
|
-
for (const c of columnsFor(model, level)) {
|
|
224
|
-
parts.push(
|
|
225
|
-
`<rect x="${sx(c.x - c.w / 2)}" y="${sy(c.y + c.d / 2)}" width="${c.w * scale}" height="${c.d * scale}" fill="${INK}"/>`,
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// 縦動線 (ADR-0021) — そのレベルで切った姿。上る走りは切断線で切れ、
|
|
230
|
-
// その先には下りる走り (下階の走りを上から見たもの) が現れる。
|
|
231
|
-
// 階段が階ごとに違う顔をするのは、平面図が「切った断面」だという事実そのものである
|
|
232
|
-
for (const d of runDrawsForLevel(model, level, opts.cut ?? CUT_HEIGHT)) {
|
|
233
|
-
for (const g of d.outline) {
|
|
234
|
-
parts.push(
|
|
235
|
-
`<line x1="${sx(g.x1)}" y1="${sy(g.y1)}" x2="${sx(g.x2)}" y2="${sy(g.y2)}" stroke="${INK}" stroke-width="1.1"/>`,
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
for (const g of d.treads) {
|
|
239
|
-
parts.push(
|
|
240
|
-
`<line x1="${sx(g.x1)}" y1="${sy(g.y1)}" x2="${sx(g.x2)}" y2="${sy(g.y2)}" stroke="${INK}" stroke-width="0.7"/>`,
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
for (const g of d.breaks) {
|
|
244
|
-
parts.push(
|
|
245
|
-
`<line x1="${sx(g.x1)}" y1="${sy(g.y1)}" x2="${sx(g.x2)}" y2="${sy(g.y2)}" stroke="${INK}" stroke-width="1.4"/>`,
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
for (const a of d.arrows) {
|
|
249
|
-
const dx = a.x2 - a.x1;
|
|
250
|
-
const dy = a.y2 - a.y1;
|
|
251
|
-
const len = Math.hypot(dx, dy) || 1;
|
|
252
|
-
const hx = (dx / len) * 420;
|
|
253
|
-
const hy = (dy / len) * 420;
|
|
254
|
-
const px = (-dy / len) * 200;
|
|
255
|
-
const py = (dx / len) * 200;
|
|
256
|
-
parts.push(
|
|
257
|
-
`<line x1="${sx(a.x1)}" y1="${sy(a.y1)}" x2="${sx(a.x2)}" y2="${sy(a.y2)}" stroke="${INK}" stroke-width="1"/>`,
|
|
258
|
-
`<path d="M ${sx(a.x2)} ${sy(a.y2)} L ${sx(a.x2 - hx + px)} ${sy(a.y2 - hy + py)} L ${sx(a.x2 - hx - px)} ${sy(a.y2 - hy - py)} Z" fill="${INK}"/>`,
|
|
259
|
-
`<text x="${sx(a.x1) + 4}" y="${sy(a.y1) + 4}" font-size="9" fill="${INK}">${a.label}</text>`,
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
for (const n of d.notes) {
|
|
263
|
-
parts.push(
|
|
264
|
-
`<text x="${sx(n.x)}" y="${sy(n.y) + 42}" text-anchor="middle" font-size="8" fill="#8a8171">${esc(n.text)}</text>`,
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// 空間ラベル (最大の凸片の中心に置く)
|
|
270
|
-
for (const s of rooms) {
|
|
271
|
-
const poly = [...regionOf(s)].sort((a, b) => polygonAreaM2(b) - polygonAreaM2(a))[0]!;
|
|
272
|
-
const r = polyBounds(poly);
|
|
273
|
-
const cx = sx((r.x1 + r.x2) / 2);
|
|
274
|
-
const cy = sy((r.y1 + r.y2) / 2);
|
|
275
|
-
const sub =
|
|
276
|
-
s.type === "void"
|
|
277
|
-
? "吹抜け"
|
|
278
|
-
: `${esc(s.type)} ・ ${areaM2(s)}㎡${isSemiOutdoor(model, s) ? " ・ 半屋外" : ""}`;
|
|
279
|
-
parts.push(
|
|
280
|
-
`<text x="${cx}" y="${cy - 4}" text-anchor="middle" font-size="14" fill="${INK}">${esc(displayName(s))}</text>`,
|
|
281
|
-
`<text x="${cx}" y="${cy + 13}" text-anchor="middle" font-size="10" fill="#8a8171">${sub}</text>`,
|
|
282
|
-
`<text x="${cx}" y="${cy + 27}" text-anchor="middle" font-size="8.5" fill="#b3ab9c">${esc(s.path)}</text>`,
|
|
283
|
-
);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// 下階の平面への「上部吹抜け」表示 (作図慣習)
|
|
287
|
-
for (const b of model.boundaries) {
|
|
288
|
-
if (b.kind !== "void") continue;
|
|
289
|
-
const sa = model.spaces.get(b.a);
|
|
290
|
-
const sb = model.spaces.get(b.b);
|
|
291
|
-
if (!sa?.level || !sb?.level) continue;
|
|
292
|
-
const za = model.levels[sa.level]?.z;
|
|
293
|
-
const zb = model.levels[sb.level]?.z;
|
|
294
|
-
if (za === undefined || zb === undefined) continue;
|
|
295
|
-
const lower = za < zb ? sa : sb;
|
|
296
|
-
const upper = za < zb ? sb : sa;
|
|
297
|
-
if (lower.level !== level) continue;
|
|
298
|
-
// 上階の**導出された形**を落とす — 割付で描くと、切られた吹抜けが切られる前の姿で出る
|
|
299
|
-
for (const poly of regionOf(upper)) {
|
|
300
|
-
const r = polyBounds(poly);
|
|
301
|
-
parts.push(
|
|
302
|
-
`<path d="${path2d(poly)}" fill="none" stroke="#b3ab9c" stroke-width="0.8" stroke-dasharray="6 4"/>`,
|
|
303
|
-
`<text x="${sx((r.x1 + r.x2) / 2)}" y="${sy((r.y1 + r.y2) / 2) + 40}" text-anchor="middle" font-size="9" fill="#b3ab9c">上部吹抜け</text>`,
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// 表題
|
|
309
|
-
const title = `${model.name ?? "無題"} — ${level} 平面`;
|
|
310
|
-
parts.push(
|
|
311
|
-
`<text x="${M - 62}" y="${H - 18}" font-size="12" fill="${INK}">${esc(title)}</text>`,
|
|
312
|
-
`<text x="${W - M + 62}" y="${H - 18}" text-anchor="end" font-size="9" fill="#a49b8a">koyu v0 — 空間から生成 (壁芯・mm)</text>`,
|
|
313
|
-
);
|
|
314
|
-
|
|
315
|
-
parts.push("</svg>");
|
|
316
|
-
return parts.join("\n") + "\n";
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
function wallRect(
|
|
320
|
-
seg: Segment,
|
|
321
|
-
t: number,
|
|
322
|
-
scale: number,
|
|
323
|
-
sx: (x: number) => number,
|
|
324
|
-
sy: (y: number) => number,
|
|
325
|
-
): string {
|
|
326
|
-
if (seg.diagonal) {
|
|
327
|
-
// 斜めの壁 (描かれた線 — ADR-0022): 芯線に対して法線方向へ t/2 ずつ振り分けた四辺形
|
|
328
|
-
const dx = seg.x2 - seg.x1;
|
|
329
|
-
const dy = seg.y2 - seg.y1;
|
|
330
|
-
const len = Math.hypot(dx, dy) || 1;
|
|
331
|
-
const nx = (-dy / len) * (t / 2);
|
|
332
|
-
const ny = (dx / len) * (t / 2);
|
|
333
|
-
const q: Array<[number, number]> = [
|
|
334
|
-
[seg.x1 + nx, seg.y1 + ny],
|
|
335
|
-
[seg.x2 + nx, seg.y2 + ny],
|
|
336
|
-
[seg.x2 - nx, seg.y2 - ny],
|
|
337
|
-
[seg.x1 - nx, seg.y1 - ny],
|
|
338
|
-
];
|
|
339
|
-
const d = q.map(([x, y], i) => `${i === 0 ? "M" : "L"} ${sx(x)} ${sy(y)}`).join(" ");
|
|
340
|
-
return `<path d="${d} Z" fill="${INK}"/>`;
|
|
341
|
-
}
|
|
342
|
-
if (seg.horizontal) {
|
|
343
|
-
const x = sx(seg.x1);
|
|
344
|
-
const y = sy(seg.y1 + t / 2);
|
|
345
|
-
return `<rect x="${x}" y="${y}" width="${(seg.x2 - seg.x1) * scale}" height="${t * scale}" fill="${INK}"/>`;
|
|
346
|
-
}
|
|
347
|
-
const x = sx(seg.x1 - t / 2);
|
|
348
|
-
const y = sy(seg.y2);
|
|
349
|
-
return `<rect x="${x}" y="${y}" width="${t * scale}" height="${(seg.y2 - seg.y1) * scale}" fill="${INK}"/>`;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
function bandRect(
|
|
353
|
-
seg: Segment,
|
|
354
|
-
w: number,
|
|
355
|
-
cx: number,
|
|
356
|
-
cy: number,
|
|
357
|
-
t: number,
|
|
358
|
-
scale: number,
|
|
359
|
-
sx: (x: number) => number,
|
|
360
|
-
sy: (y: number) => number,
|
|
361
|
-
fill: string,
|
|
362
|
-
): string {
|
|
363
|
-
if (seg.diagonal) {
|
|
364
|
-
const dx = seg.x2 - seg.x1;
|
|
365
|
-
const dy = seg.y2 - seg.y1;
|
|
366
|
-
const len = Math.hypot(dx, dy) || 1;
|
|
367
|
-
const ux = (dx / len) * (w / 2);
|
|
368
|
-
const uy = (dy / len) * (w / 2);
|
|
369
|
-
const nx = (-dy / len) * (t / 2);
|
|
370
|
-
const ny = (dx / len) * (t / 2);
|
|
371
|
-
const q: Array<[number, number]> = [
|
|
372
|
-
[cx - ux + nx, cy - uy + ny],
|
|
373
|
-
[cx + ux + nx, cy + uy + ny],
|
|
374
|
-
[cx + ux - nx, cy + uy - ny],
|
|
375
|
-
[cx - ux - nx, cy - uy - ny],
|
|
376
|
-
];
|
|
377
|
-
const d = q.map(([x, y], i) => `${i === 0 ? "M" : "L"} ${sx(x)} ${sy(y)}`).join(" ");
|
|
378
|
-
return `<path d="${d} Z" fill="${fill}"/>`;
|
|
379
|
-
}
|
|
380
|
-
if (seg.horizontal) {
|
|
381
|
-
return `<rect x="${sx(cx - w / 2)}" y="${sy(cy + t / 2)}" width="${w * scale}" height="${t * scale}" fill="${fill}"/>`;
|
|
382
|
-
}
|
|
383
|
-
return `<rect x="${sx(cx + t / 2 - t)}" y="${sy(cy + w / 2)}" width="${t * scale}" height="${w * scale}" fill="${fill}"/>`;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/** 扉: 吊元から開いた軌跡 (1/4円)。吊り込み側は「先に書いた空間」= boundary.a 側 */
|
|
387
|
-
function doorSwing(
|
|
388
|
-
model: Model,
|
|
389
|
-
b: Boundary,
|
|
390
|
-
o: Opening,
|
|
391
|
-
seg: Segment,
|
|
392
|
-
cx: number,
|
|
393
|
-
cy: number,
|
|
394
|
-
scale: number,
|
|
395
|
-
sx: (x: number) => number,
|
|
396
|
-
sy: (y: number) => number,
|
|
397
|
-
): string {
|
|
398
|
-
// 開く側の空間: swing:a/b の指定、既定はa側 (領域を持つ方)。合併なら扉に最も近い矩形へ開く
|
|
399
|
-
const sa = model.spaces.get(b.a);
|
|
400
|
-
const sb = model.spaces.get(b.b);
|
|
401
|
-
let into: typeof sa;
|
|
402
|
-
if (o.swing === "a") into = sa;
|
|
403
|
-
else if (o.swing === "b") into = sb;
|
|
404
|
-
else into = sa && sa.rects.length > 0 ? sa : sb;
|
|
405
|
-
if (!into || into.rects.length === 0) return "";
|
|
406
|
-
const dist = (rc: { x1: number; y1: number; x2: number; y2: number }) =>
|
|
407
|
-
((rc.x1 + rc.x2) / 2 - cx) ** 2 + ((rc.y1 + rc.y2) / 2 - cy) ** 2;
|
|
408
|
-
const r = [...into.rects].sort((p, q) => dist(p) - dist(q))[0]!;
|
|
409
|
-
const c = { x: (r.x1 + r.x2) / 2, y: (r.y1 + r.y2) / 2 };
|
|
410
|
-
|
|
411
|
-
// 世界座標: 吊元 hinge (hinge:W/E/S/N — 既定は始端側)、軌跡は hinge を中心とする1/4円
|
|
412
|
-
let hinge: { x: number; y: number };
|
|
413
|
-
let along: { x: number; y: number };
|
|
414
|
-
let inward: { x: number; y: number };
|
|
415
|
-
if (seg.diagonal) {
|
|
416
|
-
// 斜めの線分では吊元は始端側に固定し (hingeのN/E/S/Wは軸の言葉なので使えない)、
|
|
417
|
-
// 開く側は法線のうち開く空間の重心へ向く方をとる
|
|
418
|
-
const dx = seg.x2 - seg.x1;
|
|
419
|
-
const dy = seg.y2 - seg.y1;
|
|
420
|
-
const len = Math.hypot(dx, dy) || 1;
|
|
421
|
-
along = { x: dx / len, y: dy / len };
|
|
422
|
-
const n = { x: -along.y, y: along.x };
|
|
423
|
-
const toC = { x: c.x - cx, y: c.y - cy };
|
|
424
|
-
const sign = n.x * toC.x + n.y * toC.y >= 0 ? 1 : -1;
|
|
425
|
-
inward = { x: n.x * sign, y: n.y * sign };
|
|
426
|
-
hinge = { x: cx - along.x * (o.w / 2), y: cy - along.y * (o.w / 2) };
|
|
427
|
-
} else if (seg.horizontal) {
|
|
428
|
-
const fromEast = o.hinge === "E";
|
|
429
|
-
hinge = { x: fromEast ? cx + o.w / 2 : cx - o.w / 2, y: cy };
|
|
430
|
-
along = { x: fromEast ? -1 : 1, y: 0 };
|
|
431
|
-
inward = { x: 0, y: c.y > cy ? 1 : -1 };
|
|
432
|
-
} else {
|
|
433
|
-
const fromNorth = o.hinge === "N";
|
|
434
|
-
hinge = { x: cx, y: fromNorth ? cy + o.w / 2 : cy - o.w / 2 };
|
|
435
|
-
along = { x: 0, y: fromNorth ? -1 : 1 };
|
|
436
|
-
inward = { x: c.x > cx ? 1 : -1, y: 0 };
|
|
437
|
-
}
|
|
438
|
-
// 引き戸・自動ドア (style:sliding / style:auto — アセット語彙): 開き軌跡ではなく
|
|
439
|
-
// 吊元側の控え (戸袋側) にパネルを描く
|
|
440
|
-
const style = o.attrs["style"];
|
|
441
|
-
if (style === "sliding" || style === "auto") {
|
|
442
|
-
const off = 110; // 壁面からの控え mm
|
|
443
|
-
const s1 = {
|
|
444
|
-
x: hinge.x - along.x * o.w + inward.x * off,
|
|
445
|
-
y: hinge.y - along.y * o.w + inward.y * off,
|
|
446
|
-
};
|
|
447
|
-
const s2 = { x: hinge.x + inward.x * off, y: hinge.y + inward.y * off };
|
|
448
|
-
return (
|
|
449
|
-
`<line x1="${sx(s1.x)}" y1="${sy(s1.y)}" x2="${sx(s2.x)}" y2="${sy(s2.y)}" stroke="${INK}" stroke-width="2"/>` +
|
|
450
|
-
`<line x1="${sx(s2.x)}" y1="${sy(s2.y)}" x2="${sx(hinge.x)}" y2="${sy(hinge.y)}" stroke="${INK}" stroke-width="0.7"/>`
|
|
451
|
-
);
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
const leafEnd = { x: hinge.x + inward.x * o.w, y: hinge.y + inward.y * o.w };
|
|
455
|
-
const gapEnd = { x: hinge.x + along.x * o.w, y: hinge.y + along.y * o.w };
|
|
456
|
-
|
|
457
|
-
const p1 = { x: sx(leafEnd.x), y: sy(leafEnd.y) };
|
|
458
|
-
const p2 = { x: sx(gapEnd.x), y: sy(gapEnd.y) };
|
|
459
|
-
const ph = { x: sx(hinge.x), y: sy(hinge.y) };
|
|
460
|
-
const rad = o.w * scale;
|
|
461
|
-
// 掃引方向: 外積で決める
|
|
462
|
-
const crossZ = (p1.x - ph.x) * (p2.y - ph.y) - (p1.y - ph.y) * (p2.x - ph.x);
|
|
463
|
-
const sweep = crossZ > 0 ? 1 : 0;
|
|
464
|
-
return (
|
|
465
|
-
`<line x1="${ph.x}" y1="${ph.y}" x2="${p1.x}" y2="${p1.y}" stroke="${INK}" stroke-width="1.4"/>` +
|
|
466
|
-
`<path d="M ${p1.x} ${p1.y} A ${rad} ${rad} 0 0 ${sweep} ${p2.x} ${p2.y}" fill="none" stroke="${INK}" stroke-width="0.7" stroke-dasharray="3 2.5"/>`
|
|
467
|
-
);
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
function esc(s: string): string {
|
|
471
|
-
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
472
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|