@kensnzk/koyu 0.27.0 → 0.29.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 +1 -1
- package/README.md +1 -1
- package/assets/plan/README.md +18 -0
- package/assets/plan/catalog.muro +87 -0
- package/assets/plan/library.muro +26 -0
- package/assets/plan/svg/bathtub.svg +9 -0
- package/assets/plan/svg/bed-double.svg +9 -0
- package/assets/plan/svg/bed-single.svg +8 -0
- package/assets/plan/svg/cabinet.svg +9 -0
- package/assets/plan/svg/chair.svg +8 -0
- package/assets/plan/svg/desk.svg +9 -0
- package/assets/plan/svg/hedge-2m.svg +7 -0
- package/assets/plan/svg/kitchen-sink.svg +10 -0
- package/assets/plan/svg/locker.svg +9 -0
- package/assets/plan/svg/office-chair.svg +25 -0
- package/assets/plan/svg/potted-plant.svg +14 -0
- package/assets/plan/svg/refrigerator.svg +10 -0
- package/assets/plan/svg/shelf.svg +9 -0
- package/assets/plan/svg/shrub-1m.svg +7 -0
- package/assets/plan/svg/sofa-2.svg +9 -0
- package/assets/plan/svg/sofa-3.svg +9 -0
- package/assets/plan/svg/table-rect.svg +7 -0
- package/assets/plan/svg/table-round.svg +7 -0
- package/assets/plan/svg/tree-3m.svg +8 -0
- package/assets/plan/svg/urinal.svg +9 -0
- package/assets/plan/svg/washing-machine-pan.svg +13 -0
- package/assets/plan/svg/washing-machine.svg +10 -0
- package/assets/plan/svg/washstand-500.svg +12 -0
- package/assets/plan/svg/washstand.svg +12 -0
- package/assets/plan/svg/wc-cabinet.svg +14 -0
- package/assets/plan/svg/wc.svg +9 -0
- package/dist/analysis/contracts.d.ts +1 -0
- package/dist/analysis/contracts.d.ts.map +1 -1
- package/dist/cli.js +16 -4
- package/dist/cli.js.map +1 -1
- package/dist/core/components.d.ts +31 -0
- package/dist/core/components.d.ts.map +1 -0
- package/dist/core/components.js +167 -0
- package/dist/core/components.js.map +1 -0
- package/dist/core/derive.d.ts +13 -2
- package/dist/core/derive.d.ts.map +1 -1
- package/dist/core/derive.js +36 -5
- package/dist/core/derive.js.map +1 -1
- package/dist/core/diagnose.d.ts +7 -0
- package/dist/core/diagnose.d.ts.map +1 -1
- package/dist/core/diagnose.js +141 -5
- package/dist/core/diagnose.js.map +1 -1
- package/dist/core/diff.d.ts +4 -0
- package/dist/core/diff.d.ts.map +1 -1
- package/dist/core/diff.js +4 -0
- package/dist/core/diff.js.map +1 -1
- package/dist/core/fabric.js +1 -1
- package/dist/core/fabric.js.map +1 -1
- package/dist/core/graph.d.ts +8 -0
- package/dist/core/graph.d.ts.map +1 -1
- package/dist/core/graph.js +31 -1
- package/dist/core/graph.js.map +1 -1
- package/dist/core/light.d.ts.map +1 -1
- package/dist/core/light.js +2 -0
- package/dist/core/light.js.map +1 -1
- package/dist/core/model.d.ts +20 -14
- package/dist/core/model.d.ts.map +1 -1
- package/dist/core/model.js +15 -8
- package/dist/core/model.js.map +1 -1
- package/dist/core/parse.d.ts.map +1 -1
- package/dist/core/parse.js +23 -4
- package/dist/core/parse.js.map +1 -1
- package/dist/core/vocabulary.d.ts +20 -4
- package/dist/core/vocabulary.d.ts.map +1 -1
- package/dist/core/vocabulary.js +107 -9
- package/dist/core/vocabulary.js.map +1 -1
- package/dist/draw/component-files.d.ts +8 -0
- package/dist/draw/component-files.d.ts.map +1 -0
- package/dist/draw/component-files.js +35 -0
- package/dist/draw/component-files.js.map +1 -0
- package/dist/draw/component-svg.d.ts +14 -0
- package/dist/draw/component-svg.d.ts.map +1 -0
- package/dist/draw/component-svg.js +67 -0
- package/dist/draw/component-svg.js.map +1 -0
- package/dist/draw/conventions/architectural.d.ts +32 -0
- package/dist/draw/conventions/architectural.d.ts.map +1 -0
- package/dist/draw/conventions/architectural.js +29 -0
- package/dist/draw/conventions/architectural.js.map +1 -0
- package/dist/draw/index.d.ts +1 -1
- package/dist/draw/index.d.ts.map +1 -1
- package/dist/draw/index.js +1 -1
- package/dist/draw/index.js.map +1 -1
- package/dist/draw/marks.d.ts +37 -12
- package/dist/draw/marks.d.ts.map +1 -1
- package/dist/draw/marks.js +508 -38
- package/dist/draw/marks.js.map +1 -1
- package/dist/draw/plan.d.ts +3 -1
- package/dist/draw/plan.d.ts.map +1 -1
- package/dist/draw/plan.js +257 -86
- package/dist/draw/plan.js.map +1 -1
- package/dist/form.d.ts +1 -1
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp.js +22 -3
- package/dist/mcp.js.map +1 -1
- package/dist/parse-file.d.ts +1 -0
- package/dist/parse-file.d.ts.map +1 -1
- package/dist/parse-file.js +1 -0
- package/dist/parse-file.js.map +1 -1
- package/dist/validate/assessment.js +13 -2
- package/dist/validate/assessment.js.map +1 -1
- package/dist/validate/builtin/index.d.ts +4 -2
- package/dist/validate/builtin/index.d.ts.map +1 -1
- package/dist/validate/builtin/index.js +9 -2
- package/dist/validate/builtin/index.js.map +1 -1
- package/dist/validate/builtin/opening-operations.d.ts +63 -0
- package/dist/validate/builtin/opening-operations.d.ts.map +1 -0
- package/dist/validate/builtin/opening-operations.js +406 -0
- package/dist/validate/builtin/opening-operations.js.map +1 -0
- package/dist/validate/contracts.d.ts +1 -0
- package/dist/validate/contracts.d.ts.map +1 -1
- package/dist/validate/contracts.js.map +1 -1
- package/editors/vscode/syntaxes/koyu.tmLanguage.json +4 -4
- package/examples/basement/main.muro +3 -3
- package/examples/complex/L1.muro +1 -1
- package/examples/complex/assets.muro +2 -2
- package/examples/complex/main.muro +1 -1
- package/examples/house/L1.muro +3 -3
- package/examples/house/L2.muro +2 -2
- package/examples/house/assets.muro +8 -8
- package/examples/house/main.muro +1 -1
- package/examples/house/site.muro +2 -2
- package/examples/house.muro +6 -6
- package/examples/mansion.muro +1 -1
- package/examples/office.muro +1 -1
- package/examples/spatial/layout.muro +8 -0
- package/examples/spatial/main.muro +4 -0
- package/examples/steps/06-finished.muro +1 -1
- package/examples/tower/assets.muro +1 -1
- package/examples/tower/main.muro +1 -1
- package/examples/twin/assets.muro +2 -2
- package/examples/twin/main.muro +1 -1
- package/examples/two-rooms.canonical.json +1 -1
- package/examples/two-rooms.muro +1 -1
- package/package.json +9 -5
- package/src/analysis/contracts.ts +1 -0
- package/src/cli.ts +15 -4
- package/src/core/components.ts +224 -0
- package/src/core/derive.ts +53 -6
- package/src/core/diagnose.ts +185 -5
- package/src/core/diff.ts +3 -0
- package/src/core/fabric.ts +1 -1
- package/src/core/graph.ts +32 -0
- package/src/core/light.ts +1 -0
- package/src/core/model.ts +23 -13
- package/src/core/parse.ts +21 -4
- package/src/core/vocabulary.ts +115 -9
- package/src/draw/component-files.ts +36 -0
- package/src/draw/component-svg.ts +79 -0
- package/src/draw/conventions/architectural.ts +60 -0
- package/src/draw/index.ts +1 -1
- package/src/draw/marks.ts +564 -44
- package/src/draw/plan.ts +262 -89
- package/src/form.ts +1 -0
- package/src/index.ts +1 -1
- package/src/mcp.ts +22 -3
- package/src/parse-file.ts +1 -0
- package/src/validate/assessment.ts +17 -3
- package/src/validate/builtin/index.ts +14 -2
- package/src/validate/builtin/opening-operations.ts +519 -0
- package/src/validate/contracts.ts +1 -0
package/src/draw/plan.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
// koyu —
|
|
1
|
+
// koyu — plan SVG generation
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
3
|
+
// **No rule of building shape lives here.** Wall thickness, opening position, door hinge and stair
|
|
4
|
+
// cut are already in the `Form` returned by `derive(model)` (ADR-0040). This page owns colour,
|
|
5
|
+
// line type, line weight, typography, symbols, annotation wording, scale and sheet margins — all
|
|
6
|
+
// presentation, and all allowed to differ by consumer (docs/reference/scope.md).
|
|
7
7
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
8
|
+
// Form carries boundary coordinates, wall thickness, opening intervals, door-arc geometry and
|
|
9
|
+
// the position where a cut crosses a run. The architectural convention and this renderer decide
|
|
10
|
+
// whether a break becomes a diagonal zigzag and whether an arrowhead is open.
|
|
11
11
|
|
|
12
12
|
import { derive } from "../core/derive.js";
|
|
13
13
|
import { displayName, polyBounds, type Model, type Pt } from "../core/model.js";
|
|
14
14
|
import { slopeText } from "../core/vertical.js";
|
|
15
15
|
import { planMarks, type Mark } from "./marks.js";
|
|
16
|
+
import { ARCHITECTURAL_PLAN_CONVENTION } from "./conventions/architectural.js";
|
|
17
|
+
import { componentSvg } from "./component-svg.js";
|
|
16
18
|
import { esc, Extent, FAINT, GRID, INK, openSheet, OUTDOOR, PAPER, ROOM, SEMI_OUTDOOR } from "./sheet.js";
|
|
17
19
|
import { writtenOf } from "./written.js";
|
|
18
20
|
|
|
@@ -20,8 +22,10 @@ export interface PlanOptions {
|
|
|
20
22
|
level?: string;
|
|
21
23
|
/** px per mm */
|
|
22
24
|
scale?: number;
|
|
23
|
-
/**
|
|
25
|
+
/** Cut height above finished floor, mm. It changes the slice, so it is passed into Form. */
|
|
24
26
|
cut?: number;
|
|
27
|
+
/** Plan SVG bytes keyed by component asset name, for models made with the pure `parse` entry. */
|
|
28
|
+
componentSvgs?: Readonly<Record<string, string>>;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
export function svgPlan(model: Model, opts: PlanOptions = {}): string {
|
|
@@ -36,15 +40,15 @@ export function svgPlan(model: Model, opts: PlanOptions = {}): string {
|
|
|
36
40
|
throw new Error(`There is no space with a region on level ${level}`);
|
|
37
41
|
}
|
|
38
42
|
|
|
39
|
-
//
|
|
43
|
+
// Site geometry (ADR-0011) appears on the lowest plan, which also serves as the site plan.
|
|
40
44
|
const lowest = form.levels[0]?.name;
|
|
41
45
|
const sitePolys = level === lowest ? form.site : [];
|
|
42
46
|
|
|
43
|
-
//
|
|
47
|
+
// Sheet extent includes written allocation, even where it reaches outside the cut shape.
|
|
44
48
|
const modelRooms = [...model.spaces.values()].filter((s) => s.rects.length > 0 && s.level === level);
|
|
45
49
|
const allRects = modelRooms.flatMap((s) => s.rects);
|
|
46
50
|
const polyPts = [...sitePolys.flatMap((p) => p.points), ...rooms.flatMap((s) => s.outline.flat())];
|
|
47
|
-
//
|
|
51
|
+
// Fold through Extent: spreading every point can hit the call-stack limit on a large storey.
|
|
48
52
|
const ext = new Extent();
|
|
49
53
|
for (const r of allRects) {
|
|
50
54
|
ext.see(r.x1, r.y1);
|
|
@@ -56,7 +60,7 @@ export function svgPlan(model: Model, opts: PlanOptions = {}): string {
|
|
|
56
60
|
const minY = ext.min1;
|
|
57
61
|
const maxY = ext.max1;
|
|
58
62
|
|
|
59
|
-
const M = 84; //
|
|
63
|
+
const M = 84; // sheet margin in px, including grid bubbles
|
|
60
64
|
const W = (maxX - minX) * scale + M * 2;
|
|
61
65
|
const H = (maxY - minY) * scale + M * 2;
|
|
62
66
|
const sx = (x: number) => (x - minX) * scale + M;
|
|
@@ -69,22 +73,21 @@ export function svgPlan(model: Model, opts: PlanOptions = {}): string {
|
|
|
69
73
|
|
|
70
74
|
const parts: string[] = openSheet(W, H);
|
|
71
75
|
|
|
72
|
-
//
|
|
76
|
+
// Site boundary: a drafting dash pattern applied to the supplied geometry.
|
|
73
77
|
for (const poly of sitePolys) {
|
|
74
78
|
parts.push(
|
|
75
79
|
`<path d="${path2d(poly.points)}" fill="none" stroke="#8a8171" stroke-width="1.1" stroke-dasharray="14 3 2.5 3 2.5 3"/>`,
|
|
76
80
|
);
|
|
77
81
|
}
|
|
78
82
|
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
// 前庭と玄関ホールが同じ一枚のクリームに見えていた状態を分ける
|
|
83
|
+
// Space faces are the cut through volume. A shared fill and no outline make split convex pieces
|
|
84
|
+
// read as one room. Warm denotes indoors; cooler tones separate outside and semi-outdoor space.
|
|
82
85
|
for (const s of rooms) {
|
|
83
86
|
const isVoid = s.void;
|
|
84
87
|
for (const poly of s.outline) {
|
|
85
88
|
parts.push(fill(poly, isVoid ? PAPER : s.outside ? OUTDOOR : s.semiOutdoor ? SEMI_OUTDOOR : ROOM));
|
|
86
89
|
if (isVoid) {
|
|
87
|
-
//
|
|
90
|
+
// Void: dashed diagonals are a paper convention.
|
|
88
91
|
const r = polyBounds(poly);
|
|
89
92
|
parts.push(
|
|
90
93
|
line({ x1: r.x1, y1: r.y1, x2: r.x2, y2: r.y2 }, FAINT, 0.8, "6 4"),
|
|
@@ -94,14 +97,25 @@ export function svgPlan(model: Model, opts: PlanOptions = {}): string {
|
|
|
94
97
|
}
|
|
95
98
|
}
|
|
96
99
|
|
|
97
|
-
|
|
100
|
+
if (form.mode === "spatial") {
|
|
101
|
+
parts.push(`<desc>Spatial model: dashed faces are unresolved; circulation, daylight and egress are not evaluated.</desc>`);
|
|
102
|
+
for (const face of form.unresolved ?? []) {
|
|
103
|
+
if (face.level === level) parts.push(`<g data-unresolved="true">${line(face.segment, FAINT, 1, "6 4")}</g>`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Uncounted area subdivisions, such as a floor-finish change, reproduce the written input.
|
|
98
108
|
for (const s of modelRooms) {
|
|
99
109
|
for (const a of s.areas) {
|
|
100
110
|
const r = a.rect;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
)
|
|
104
|
-
|
|
111
|
+
const componentHost = a.attrs["asset"] !== undefined;
|
|
112
|
+
const visibleSubdivision = a.attrs["floor"] !== undefined || a.attrs["spec"] !== undefined;
|
|
113
|
+
if (!componentHost || visibleSubdivision) {
|
|
114
|
+
parts.push(
|
|
115
|
+
`<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="${FAINT}" stroke-width="0.8" stroke-dasharray="4 3"/>`,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
const label = [componentHost ? undefined : a.attrs["name"], a.attrs["floor"]]
|
|
105
119
|
.filter((v): v is string => typeof v === "string")
|
|
106
120
|
.join(" · ");
|
|
107
121
|
if (label) {
|
|
@@ -112,7 +126,29 @@ export function svgPlan(model: Model, opts: PlanOptions = {}): string {
|
|
|
112
126
|
}
|
|
113
127
|
}
|
|
114
128
|
|
|
115
|
-
//
|
|
129
|
+
// Components are below cut matter and room labels. The source SVG remains isolated as an image,
|
|
130
|
+
// preserving its defs and IDs while the Form supplies all placement geometry.
|
|
131
|
+
for (const component of form.components ?? []) {
|
|
132
|
+
if (component.level !== level) continue;
|
|
133
|
+
const asset = model.assets.get(component.asset);
|
|
134
|
+
if (!asset || asset.kind !== "component") continue;
|
|
135
|
+
const source = opts.componentSvgs?.[asset.name];
|
|
136
|
+
if (!source) {
|
|
137
|
+
throw new Error(
|
|
138
|
+
`Component asset ${asset.name} has no plan SVG bytes; pass PlanOptions.componentSvgs`,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
const artwork = componentSvg(asset, source);
|
|
142
|
+
const cx = sx(component.centre.x);
|
|
143
|
+
const cy = sy(component.centre.y);
|
|
144
|
+
const width = component.w * scale;
|
|
145
|
+
const height = component.d * scale;
|
|
146
|
+
parts.push(
|
|
147
|
+
`<image class="component-asset" data-asset="${esc(asset.name)}" x="${cx - width / 2}" y="${cy - height / 2}" width="${width}" height="${height}" preserveAspectRatio="none" href="${artwork.dataUri}" transform="rotate(${-component.rotation} ${cx} ${cy})"/>`,
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Written grid axes.
|
|
116
152
|
for (const [i, x] of model.grid.X.coords.entries()) {
|
|
117
153
|
if (x < minX - 1 || x > maxX + 1) continue;
|
|
118
154
|
parts.push(
|
|
@@ -130,15 +166,34 @@ export function svgPlan(model: Model, opts: PlanOptions = {}): string {
|
|
|
130
166
|
);
|
|
131
167
|
}
|
|
132
168
|
|
|
133
|
-
//
|
|
134
|
-
//
|
|
169
|
+
// Marks copy Form geometry. This page adds only colour, weight, dash, glyph and wording; another
|
|
170
|
+
// consumer can render the same marks differently.
|
|
135
171
|
const marks = planMarks(form, level);
|
|
136
172
|
const written = writtenOf(model);
|
|
137
173
|
const segByRef = new Map(form.segs.map((g) => [g.ref, g]));
|
|
174
|
+
// A generic room label over a stair repeats what the treads already say and obscures the arrow.
|
|
175
|
+
// Seed the set from actual stair runs, then follow only vertical boundaries connected to them so
|
|
176
|
+
// ramps, escalators and lift shafts keep their existing labels.
|
|
177
|
+
const stairSpaces = new Set(form.runs.filter((r) => r.device === "stair").map((r) => r.path));
|
|
178
|
+
let grew = true;
|
|
179
|
+
while (grew) {
|
|
180
|
+
grew = false;
|
|
181
|
+
for (const b of model.boundaries) {
|
|
182
|
+
if (b.kind !== "stair" || (!stairSpaces.has(b.a) && !stairSpaces.has(b.b))) continue;
|
|
183
|
+
if (!stairSpaces.has(b.a)) {
|
|
184
|
+
stairSpaces.add(b.a);
|
|
185
|
+
grew = true;
|
|
186
|
+
}
|
|
187
|
+
if (!stairSpaces.has(b.b)) {
|
|
188
|
+
stairSpaces.add(b.b);
|
|
189
|
+
grew = true;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
138
193
|
for (const k of marks) {
|
|
139
194
|
switch (k.role) {
|
|
140
|
-
//
|
|
141
|
-
//
|
|
195
|
+
// Space faces and subdivision bands are rendered from their full outlines elsewhere. Upper
|
|
196
|
+
// void projections are deliberately placed behind space labels.
|
|
142
197
|
case "space":
|
|
143
198
|
case "space-semi-outdoor":
|
|
144
199
|
case "space-outdoor":
|
|
@@ -146,10 +201,9 @@ export function svgPlan(model: Model, opts: PlanOptions = {}): string {
|
|
|
146
201
|
case "void-hatch":
|
|
147
202
|
case "void-above":
|
|
148
203
|
break;
|
|
149
|
-
//
|
|
150
|
-
//
|
|
151
|
-
//
|
|
152
|
-
// 注記が別の境界のものになる
|
|
204
|
+
// An uncounted segment can mark a wall specification change. Only the annotation wording is
|
|
205
|
+
// recovered from the source. `written.boundary` indexes canonical order, never declaration
|
|
206
|
+
// order, so a harmless source reorder cannot move the note to another boundary.
|
|
153
207
|
case "seg": {
|
|
154
208
|
parts.push(fill(k.polygon!, "#77716a"));
|
|
155
209
|
const spec = written.segSpec(k.written!.boundary, k.written!.index!);
|
|
@@ -162,43 +216,135 @@ export function svgPlan(model: Model, opts: PlanOptions = {}): string {
|
|
|
162
216
|
}
|
|
163
217
|
break;
|
|
164
218
|
}
|
|
165
|
-
//
|
|
219
|
+
// A boundary with no matter remains legible as a light dashed relation.
|
|
166
220
|
case "open":
|
|
167
221
|
for (const g of k.lines ?? []) parts.push(line(g, FAINT, 1, "6 4"));
|
|
168
222
|
break;
|
|
169
|
-
//
|
|
170
|
-
//
|
|
223
|
+
// A rail stays lighter than a wall, while the endpoint posts keep a short rail from reading
|
|
224
|
+
// as an accidental construction line. The axis itself comes from Form; the circles are a
|
|
225
|
+
// paper convention and add no building geometry.
|
|
171
226
|
case "rail":
|
|
172
|
-
|
|
227
|
+
parts.push(`<g class="boundary-rail">`);
|
|
228
|
+
for (const g of k.lines ?? []) {
|
|
229
|
+
parts.push(line(g, INK, 1.1));
|
|
230
|
+
parts.push(
|
|
231
|
+
`<circle class="boundary-rail-post" cx="${sx(g.x1)}" cy="${sy(g.y1)}" r="1.45" fill="${INK}"/>`,
|
|
232
|
+
`<circle class="boundary-rail-post" cx="${sx(g.x2)}" cy="${sy(g.y2)}" r="1.45" fill="${INK}"/>`,
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
parts.push(`</g>`);
|
|
173
236
|
break;
|
|
174
|
-
//
|
|
175
|
-
//
|
|
237
|
+
// Only intervals and columns cut by the plane become black bodies. Sill walls lie below the
|
|
238
|
+
// cut; no paper-coloured mask is needed to erase openings.
|
|
176
239
|
case "wall":
|
|
177
240
|
case "column":
|
|
178
241
|
parts.push(fill(k.polygon!, INK));
|
|
179
242
|
break;
|
|
180
|
-
//
|
|
243
|
+
// A sliding leaf has no swing trace. Its solid line closes the opening; the thin dashed
|
|
244
|
+
// continuation says which way it retracts without turning the opening into a box.
|
|
181
245
|
case "slide-panel":
|
|
182
|
-
|
|
246
|
+
parts.push(`<g class="opening-slide-panel">`);
|
|
247
|
+
for (const g of k.lines ?? []) parts.push(line(g, INK, 1.2));
|
|
248
|
+
parts.push(`</g>`);
|
|
183
249
|
break;
|
|
184
|
-
case "slide-
|
|
250
|
+
case "slide-centre":
|
|
251
|
+
parts.push(`<g class="opening-slide-centre">`);
|
|
185
252
|
for (const g of k.lines ?? []) parts.push(line(g, INK, 0.7));
|
|
253
|
+
parts.push(`</g>`);
|
|
254
|
+
break;
|
|
255
|
+
case "slide-tail":
|
|
256
|
+
parts.push(`<g class="opening-slide-guide">`);
|
|
257
|
+
for (const g of k.lines ?? []) parts.push(line(g, INK, 0.65, "5 3"));
|
|
258
|
+
parts.push(`</g>`);
|
|
259
|
+
break;
|
|
260
|
+
case "auto-direction":
|
|
261
|
+
parts.push(`<g class="opening-auto-direction">`);
|
|
262
|
+
for (const g of k.lines ?? []) parts.push(line(g, INK, 0.65));
|
|
263
|
+
parts.push(`</g>`);
|
|
264
|
+
break;
|
|
265
|
+
case "entrance":
|
|
266
|
+
parts.push(`<g class="opening-entrance">`);
|
|
267
|
+
for (const g of k.lines ?? []) parts.push(line(g, INK, 0.75));
|
|
268
|
+
parts.push(`</g>`);
|
|
269
|
+
break;
|
|
270
|
+
case "gate-post":
|
|
271
|
+
parts.push(`<g class="opening-gate-post">`);
|
|
272
|
+
for (const g of k.lines ?? []) parts.push(line(g, INK, 2));
|
|
273
|
+
parts.push(`</g>`);
|
|
274
|
+
break;
|
|
275
|
+
case "rolling-shutter":
|
|
276
|
+
parts.push(`<g class="opening-rolling-shutter">`);
|
|
277
|
+
for (const g of k.lines ?? []) {
|
|
278
|
+
parts.push(line(g, INK, 1));
|
|
279
|
+
parts.push(
|
|
280
|
+
`<rect x="${sx(g.x1) - 1.5}" y="${sy(g.y1) - 1.5}" width="3" height="3" fill="${INK}"/>`,
|
|
281
|
+
`<rect x="${sx(g.x2) - 1.5}" y="${sy(g.y2) - 1.5}" width="3" height="3" fill="${INK}"/>`,
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
parts.push(`</g>`);
|
|
285
|
+
break;
|
|
286
|
+
case "overhead-door":
|
|
287
|
+
parts.push(`<g class="opening-overhead-door">`);
|
|
288
|
+
for (const g of k.lines ?? []) parts.push(line(g, INK, 1.1, "2 1"));
|
|
289
|
+
parts.push(`</g>`);
|
|
186
290
|
break;
|
|
187
291
|
case "door-leaf":
|
|
188
|
-
for (const g of k.lines ?? []) parts.push(line(g, INK, 1.
|
|
292
|
+
for (const g of k.lines ?? []) parts.push(line(g, INK, 1.1));
|
|
293
|
+
break;
|
|
294
|
+
case "window-leaf":
|
|
295
|
+
parts.push(`<g class="opening-window-leaf">`);
|
|
296
|
+
for (const g of k.lines ?? []) parts.push(line(g, INK, 0.8));
|
|
297
|
+
parts.push(`</g>`);
|
|
189
298
|
break;
|
|
190
|
-
case "door-arc":
|
|
299
|
+
case "door-arc":
|
|
300
|
+
case "window-arc": {
|
|
191
301
|
const a = k.arc!;
|
|
192
302
|
const r = a.r * scale;
|
|
193
|
-
//
|
|
303
|
+
// World counter-clockwise becomes clockwise after the SVG y-axis is inverted.
|
|
194
304
|
const sweep = a.ccw ? 0 : 1;
|
|
305
|
+
const window = k.role === "window-arc";
|
|
195
306
|
parts.push(
|
|
196
|
-
`<path d="M ${sx(a.from.x)} ${sy(a.from.y)} A ${r} ${r} 0 0 ${sweep} ${sx(a.to.x)} ${sy(a.to.y)}" fill="none" stroke="${INK}" stroke-width="0.
|
|
307
|
+
`<path class="${window ? "opening-window-arc" : "opening-door-arc"}" d="M ${sx(a.from.x)} ${sy(a.from.y)} A ${r} ${r} 0 0 ${sweep} ${sx(a.to.x)} ${sy(a.to.y)}" fill="none" stroke="${INK}" stroke-width="${window ? 0.55 : 0.7}"/>`,
|
|
197
308
|
);
|
|
198
309
|
break;
|
|
199
310
|
}
|
|
200
|
-
case "window":
|
|
201
|
-
|
|
311
|
+
case "window": {
|
|
312
|
+
const cut = k.class === "cut";
|
|
313
|
+
const stroke = cut ? INK : FAINT;
|
|
314
|
+
const dash = cut ? "" : "5 3";
|
|
315
|
+
parts.push(`<g class="opening-window">`);
|
|
316
|
+
if (k.polygon && k.polygon.length >= 4) {
|
|
317
|
+
const p = k.polygon;
|
|
318
|
+
// A window continues the two faces of the wall as unfilled lines. Closing this path
|
|
319
|
+
// would add jamb caps and turn the window back into a boxed door opening.
|
|
320
|
+
parts.push(
|
|
321
|
+
`<path d="M ${sx(p[0]!.x)} ${sy(p[0]!.y)} L ${sx(p[1]!.x)} ${sy(p[1]!.y)} M ${sx(p[3]!.x)} ${sy(p[3]!.y)} L ${sx(p[2]!.x)} ${sy(p[2]!.y)}" fill="none" stroke="${stroke}" stroke-width="0.8"${dash ? ` stroke-dasharray="${dash}"` : ""}/>`,
|
|
322
|
+
);
|
|
323
|
+
} else {
|
|
324
|
+
for (const g of k.lines ?? []) parts.push(line(g, stroke, 0.55, dash));
|
|
325
|
+
}
|
|
326
|
+
parts.push(`</g>`);
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
case "window-sash":
|
|
330
|
+
parts.push(`<g class="opening-window-sash">`);
|
|
331
|
+
for (const g of k.lines ?? []) parts.push(line(g, INK, 0.7));
|
|
332
|
+
parts.push(`</g>`);
|
|
333
|
+
break;
|
|
334
|
+
case "window-fixed":
|
|
335
|
+
parts.push(`<g class="opening-window-fixed">`);
|
|
336
|
+
for (const g of k.lines ?? []) parts.push(line(g, INK, 0.65));
|
|
337
|
+
parts.push(`</g>`);
|
|
338
|
+
break;
|
|
339
|
+
case "curtain-wall-mullion":
|
|
340
|
+
parts.push(`<g class="opening-curtain-wall-mullion">`);
|
|
341
|
+
for (const g of k.lines ?? []) parts.push(line(g, INK, 0.55));
|
|
342
|
+
parts.push(`</g>`);
|
|
343
|
+
break;
|
|
344
|
+
case "window-sash-centre":
|
|
345
|
+
parts.push(`<g class="opening-window-sash-centre">`);
|
|
346
|
+
for (const g of k.lines ?? []) parts.push(line(g, INK, 0.55));
|
|
347
|
+
parts.push(`</g>`);
|
|
202
348
|
break;
|
|
203
349
|
case "run-outline":
|
|
204
350
|
for (const g of k.lines ?? []) parts.push(line(g, INK, 1.1));
|
|
@@ -212,24 +358,22 @@ export function svgPlan(model: Model, opts: PlanOptions = {}): string {
|
|
|
212
358
|
case "run-arrow":
|
|
213
359
|
parts.push(...arrow(k, line, sx, sy));
|
|
214
360
|
break;
|
|
215
|
-
//
|
|
361
|
+
// Wording and rounding begin here; the mark carries only unrounded facts.
|
|
216
362
|
case "run-note": {
|
|
217
363
|
const n = k.note;
|
|
218
|
-
if (!n || n.of === "direction") break;
|
|
219
|
-
const text =
|
|
220
|
-
n.of === "stair"
|
|
221
|
-
? `${n.risers}段 蹴上${Math.round(n.riser)}/踏面${Math.round(n.tread)}`
|
|
222
|
-
: `${n.lanes > 1 ? `${n.lanes}台 ` : ""}勾配 ${slopeText(n.slope)}`;
|
|
364
|
+
if (!n || n.of === "direction" || n.of === "stair") break;
|
|
365
|
+
const text = `${n.lanes > 1 ? `${n.lanes} units ` : ""}slope ${slopeText(n.slope)}`;
|
|
223
366
|
parts.push(
|
|
224
|
-
`<text x="${sx(k.at!.x)}" y="${sy(k.at!.y) + 42}" text-anchor="middle" font-size="8" fill="#8a8171">${esc(text)}</text>`,
|
|
367
|
+
`<text class="run-note" x="${sx(k.at!.x)}" y="${sy(k.at!.y) + 42}" text-anchor="middle" font-size="8" fill="#8a8171" stroke="${PAPER}" stroke-width="3" paint-order="stroke">${esc(text)}</text>`,
|
|
225
368
|
);
|
|
226
369
|
break;
|
|
227
370
|
}
|
|
228
371
|
}
|
|
229
372
|
}
|
|
230
373
|
|
|
231
|
-
//
|
|
374
|
+
// Place a space label at the centre of its largest convex piece.
|
|
232
375
|
for (const s of rooms) {
|
|
376
|
+
if (stairSpaces.has(s.path)) continue;
|
|
233
377
|
const space = model.spaces.get(s.path)!;
|
|
234
378
|
const poly = [...s.outline].sort((a, b) => polyArea(b) - polyArea(a))[0]!;
|
|
235
379
|
const r = polyBounds(poly);
|
|
@@ -246,7 +390,7 @@ export function svgPlan(model: Model, opts: PlanOptions = {}): string {
|
|
|
246
390
|
);
|
|
247
391
|
}
|
|
248
392
|
|
|
249
|
-
//
|
|
393
|
+
// Projection from above the cut, including an upper void, drawn after space labels.
|
|
250
394
|
for (const k of marks) {
|
|
251
395
|
if (k.role !== "void-above") continue;
|
|
252
396
|
parts.push(
|
|
@@ -255,19 +399,19 @@ export function svgPlan(model: Model, opts: PlanOptions = {}): string {
|
|
|
255
399
|
);
|
|
256
400
|
}
|
|
257
401
|
|
|
258
|
-
//
|
|
259
|
-
//
|
|
260
|
-
//
|
|
402
|
+
// North arrow (ADR-0057): drawn only when azimuth is written. It is presentation rather than
|
|
403
|
+
// shape, so it is placed directly in sheet coordinates instead of entering Form. The picture
|
|
404
|
+
// exposes a reversed bearing, a complementary angle or copied magnetic north.
|
|
261
405
|
//
|
|
262
|
-
//
|
|
406
|
+
// On screen model +Y is up and +X is right; true azimuth remains clockwise from +Y.
|
|
263
407
|
if (model.azimuth) {
|
|
264
408
|
const rad = (model.azimuth.deg * Math.PI) / 180;
|
|
265
409
|
const nx = Math.sin(rad);
|
|
266
410
|
const ny = -Math.cos(rad);
|
|
267
|
-
const cx = W - M / 2; //
|
|
411
|
+
const cx = W - M / 2; // centre of the right margin, separated from the grid bubbles
|
|
268
412
|
const cy = M / 2;
|
|
269
413
|
const R = 21;
|
|
270
|
-
const px = -ny; //
|
|
414
|
+
const px = -ny; // perpendicular direction for the arrowhead base
|
|
271
415
|
const py = nx;
|
|
272
416
|
const r2 = (n: number): string => String(Math.round(n * 100) / 100);
|
|
273
417
|
const head = [
|
|
@@ -286,8 +430,9 @@ export function svgPlan(model: Model, opts: PlanOptions = {}): string {
|
|
|
286
430
|
);
|
|
287
431
|
}
|
|
288
432
|
|
|
289
|
-
//
|
|
290
|
-
const title = `${model.name ?? "Untitled"} — ${level} plan`;
|
|
433
|
+
// Sheet title.
|
|
434
|
+
const title = `${model.name ?? "Untitled"} — ${level} ${model.mode === "spatial" ? "spatial plan" : "plan"}`;
|
|
435
|
+
if (model.mode === "spatial") parts.push(`<text x="${M - 62}" y="${H - 38}" font-size="9" fill="${FAINT}">Dashed: unresolved boundary</text>`);
|
|
291
436
|
parts.push(`<text x="${M - 62}" y="${H - 18}" font-size="12" fill="${INK}">${esc(title)}</text>`);
|
|
292
437
|
|
|
293
438
|
parts.push("</svg>");
|
|
@@ -302,47 +447,76 @@ type Line = (
|
|
|
302
447
|
) => string;
|
|
303
448
|
|
|
304
449
|
/**
|
|
305
|
-
*
|
|
306
|
-
*
|
|
450
|
+
* Form supplies the segment crossing the flight. The renderer scales the supplied 10 by 40 break
|
|
451
|
+
* glyph to that width and rotates it 30 degrees as a paper convention.
|
|
307
452
|
*/
|
|
308
453
|
function breakMark(g: { x1: number; y1: number; x2: number; y2: number }, line: Line): string[] {
|
|
454
|
+
const glyph = ARCHITECTURAL_PLAN_CONVENTION.stairs.breakGlyph;
|
|
309
455
|
const dx = g.x2 - g.x1;
|
|
310
456
|
const dy = g.y2 - g.y1;
|
|
311
457
|
const width = Math.hypot(dx, dy) || 1;
|
|
312
|
-
|
|
458
|
+
const ax = dx / width;
|
|
459
|
+
const ay = dy / width;
|
|
313
460
|
const tx = dy / width;
|
|
314
461
|
const ty = -dx / width;
|
|
315
|
-
const
|
|
316
|
-
const
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
462
|
+
const cx = (g.x1 + g.x2) / 2;
|
|
463
|
+
const cy = (g.y1 + g.y2) / 2;
|
|
464
|
+
const angle = glyph.angleDegrees * Math.PI / 180;
|
|
465
|
+
const longX = ax * Math.cos(angle) + tx * Math.sin(angle);
|
|
466
|
+
const longY = ay * Math.cos(angle) + ty * Math.sin(angle);
|
|
467
|
+
const crossX = -ax * Math.sin(angle) + tx * Math.cos(angle);
|
|
468
|
+
const crossY = -ay * Math.sin(angle) + ty * Math.cos(angle);
|
|
469
|
+
const scale = width / (glyph.height * Math.cos(angle));
|
|
470
|
+
const point = (x: number, y: number) => ({
|
|
471
|
+
x: cx + (longX * y + crossX * x) * scale,
|
|
472
|
+
y: cy + (longY * y + crossY * x) * scale,
|
|
322
473
|
});
|
|
323
|
-
|
|
474
|
+
const halfHeight = glyph.height / 2;
|
|
475
|
+
// Exact geometry of the convention's break glyph, centred and rotated on the flight.
|
|
476
|
+
const paths = [
|
|
477
|
+
[point(0, -halfHeight), point(0, -glyph.notch), point(-glyph.notch, -glyph.notch), point(0, 0)],
|
|
478
|
+
[point(0, 0), point(glyph.notch, glyph.notch), point(0, glyph.notch), point(0, halfHeight)],
|
|
479
|
+
];
|
|
480
|
+
return [
|
|
481
|
+
`<g class="run-break-zigzag">`,
|
|
482
|
+
...paths.flatMap((points) =>
|
|
483
|
+
points.slice(0, -1).map((p, i) =>
|
|
484
|
+
line({ x1: p.x, y1: p.y, x2: points[i + 1]!.x, y2: points[i + 1]!.y }, INK, 1.35),
|
|
485
|
+
),
|
|
486
|
+
),
|
|
487
|
+
`</g>`,
|
|
488
|
+
];
|
|
324
489
|
}
|
|
325
490
|
|
|
326
|
-
/**
|
|
491
|
+
/** A light, open direction arrow. Its line already points where the presentation mark intends. */
|
|
327
492
|
function arrow(
|
|
328
493
|
k: Mark,
|
|
329
494
|
line: Line,
|
|
330
495
|
sx: (x: number) => number,
|
|
331
496
|
sy: (y: number) => number,
|
|
332
497
|
): string[] {
|
|
333
|
-
const
|
|
334
|
-
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
const
|
|
340
|
-
const
|
|
341
|
-
const
|
|
498
|
+
const lines = k.lines ?? [];
|
|
499
|
+
const first = lines[0];
|
|
500
|
+
const g = lines[lines.length - 1];
|
|
501
|
+
if (!first || !g) return [];
|
|
502
|
+
// The head is paper-sized, not a dimension of the building. Keeping it in SVG coordinates
|
|
503
|
+
// makes the same stair legible on a compact house and a large floor plate.
|
|
504
|
+
const screenLen = Math.hypot(sx(g.x2) - sx(g.x1), sy(g.y2) - sy(g.y1)) || 1;
|
|
505
|
+
const vx = (sx(g.x2) - sx(g.x1)) / screenLen;
|
|
506
|
+
const vy = (sy(g.y2) - sy(g.y1)) / screenLen;
|
|
507
|
+
const px = -vy;
|
|
508
|
+
const py = vx;
|
|
509
|
+
const head = ARCHITECTURAL_PLAN_CONVENTION.stairs.arrowHead;
|
|
510
|
+
const tip = { x: sx(g.x2), y: sy(g.y2) };
|
|
511
|
+
const back = { x: tip.x - vx * head.length, y: tip.y - vy * head.length };
|
|
342
512
|
return [
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
513
|
+
`<g class="run-direction-arrow">`,
|
|
514
|
+
...lines.map((segment) => line(segment, INK, 0.8)),
|
|
515
|
+
...(k.class === "below"
|
|
516
|
+
? []
|
|
517
|
+
: [`<circle class="run-direction-arrow-start" cx="${sx(first.x1)}" cy="${sy(first.y1)}" r="${head.startRadius}" fill="${PAPER}" stroke="${INK}" stroke-width="0.8"/>`]),
|
|
518
|
+
`<path class="run-direction-arrow-head" d="M ${back.x + px * head.halfWidth} ${back.y + py * head.halfWidth} L ${tip.x} ${tip.y} L ${back.x - px * head.halfWidth} ${back.y - py * head.halfWidth}" fill="none" stroke="${INK}" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"/>`,
|
|
519
|
+
`</g>`,
|
|
346
520
|
];
|
|
347
521
|
}
|
|
348
522
|
|
|
@@ -355,4 +529,3 @@ function polyArea(poly: Pt[]): number {
|
|
|
355
529
|
}
|
|
356
530
|
return Math.abs(s / 2);
|
|
357
531
|
}
|
|
358
|
-
|
package/src/form.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
//
|
|
16
16
|
// root is browser-safe: nothing reachable from here pulls a Node builtin.
|
|
17
17
|
//
|
|
18
|
-
// The
|
|
18
|
+
// The public entry points:
|
|
19
19
|
//
|
|
20
20
|
// @kensnzk/koyu this file — compose, check, canonicalise
|
|
21
21
|
// @kensnzk/koyu/model Model, and the questions the model answers alone
|
package/src/mcp.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
SUPPORTED_LANGUAGE_VERSIONS,
|
|
20
20
|
} from "./core/model.js";
|
|
21
21
|
import { axisOf } from "./core/section.js";
|
|
22
|
+
import { placedComponents } from "./core/components.js";
|
|
22
23
|
import { check } from "./core/diagnose.js";
|
|
23
24
|
import { siteReport } from "./core/site.js";
|
|
24
25
|
import { assess } from "./validate/assessment.js";
|
|
@@ -41,7 +42,7 @@ import {
|
|
|
41
42
|
type Model,
|
|
42
43
|
type Space,
|
|
43
44
|
} from "./model.js";
|
|
44
|
-
import { parseFile, parseFileWith } from "./parse-file.js";
|
|
45
|
+
import { componentSvgFiles, parseFile, parseFileWith } from "./parse-file.js";
|
|
45
46
|
|
|
46
47
|
// ---- モデルの読み込みと要約 ----
|
|
47
48
|
|
|
@@ -109,8 +110,10 @@ function summarize(model: Model, file: string, by: readonly string[] = []): unkn
|
|
|
109
110
|
byM2[key] = bucket;
|
|
110
111
|
}
|
|
111
112
|
const r = check(model);
|
|
113
|
+
const components = placedComponents(model).components;
|
|
112
114
|
return {
|
|
113
115
|
name: model.name,
|
|
116
|
+
...(model.mode ? { mode: model.mode } : {}),
|
|
114
117
|
unit: model.unit,
|
|
115
118
|
layers: layerFiles(model),
|
|
116
119
|
levels: levelsSorted(model).map((l) => ({
|
|
@@ -134,6 +137,18 @@ function summarize(model: Model, file: string, by: readonly string[] = []): unkn
|
|
|
134
137
|
};
|
|
135
138
|
}),
|
|
136
139
|
assets: [...model.assets.values()].map((a) => ({ name: a.name, kind: a.kind, attrs: a.attrs })),
|
|
140
|
+
...(components.length > 0
|
|
141
|
+
? {
|
|
142
|
+
componentPlacements: components.map((component) => ({
|
|
143
|
+
space: component.space,
|
|
144
|
+
area: component.area,
|
|
145
|
+
asset: component.asset,
|
|
146
|
+
level: component.level,
|
|
147
|
+
centre: component.centre,
|
|
148
|
+
rotation: component.rotation,
|
|
149
|
+
})),
|
|
150
|
+
}
|
|
151
|
+
: {}),
|
|
137
152
|
...(model.polygons.size
|
|
138
153
|
? { sitePolygons: [...model.polygons.keys()] }
|
|
139
154
|
: {}),
|
|
@@ -222,7 +237,7 @@ const keys = (v: unknown, name: string): string[] => {
|
|
|
222
237
|
const TOOLS: Record<string, Tool> = {
|
|
223
238
|
model_summary: {
|
|
224
239
|
description:
|
|
225
|
-
"Summary of the building: name, levels, layer composition, zones,
|
|
240
|
+
"Summary of the building: name, levels, layer composition, zones, reusable assets, placed components, areas, and check counts. Call this first. Pass by:[\"lease.category\"] to also get floor area grouped by those attribute keys",
|
|
226
241
|
schema: {
|
|
227
242
|
type: "object",
|
|
228
243
|
properties: {
|
|
@@ -444,7 +459,11 @@ const TOOLS: Record<string, Tool> = {
|
|
|
444
459
|
properties: { ...FILE_PROP, level: { type: "string", description: "Level name (e.g. L5)" } },
|
|
445
460
|
required: ["file", "level"],
|
|
446
461
|
},
|
|
447
|
-
run: (a) =>
|
|
462
|
+
run: (a) => {
|
|
463
|
+
const model = load(str(a.file, "file"));
|
|
464
|
+
const level = str(a.level, "level");
|
|
465
|
+
return svgPlan(model, { level, componentSvgs: componentSvgFiles(model, level) });
|
|
466
|
+
},
|
|
448
467
|
},
|
|
449
468
|
section_svg: {
|
|
450
469
|
description:
|
package/src/parse-file.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { readFileSync, realpathSync } from "node:fs";
|
|
|
6
6
|
import { dirname, resolve } from "node:path";
|
|
7
7
|
import type { Model } from "./core/model.js";
|
|
8
8
|
import { parseWith } from "./core/parse.js";
|
|
9
|
+
export { componentSvgFiles } from "./draw/component-files.js";
|
|
9
10
|
|
|
10
11
|
/** ファイルから読む。import は書かれたファイルからの相対で解決される */
|
|
11
12
|
export function parseFile(filePath: string): Model {
|