@kensnzk/koyu 0.26.0 → 0.28.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/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/cli.js +2 -2
- 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 +9 -1
- package/dist/core/derive.d.ts.map +1 -1
- package/dist/core/derive.js +33 -3
- package/dist/core/derive.js.map +1 -1
- package/dist/core/diagnose.d.ts +6 -0
- package/dist/core/diagnose.d.ts.map +1 -1
- package/dist/core/diagnose.js +137 -4
- package/dist/core/diagnose.js.map +1 -1
- package/dist/core/model.d.ts +5 -5
- package/dist/core/model.d.ts.map +1 -1
- package/dist/core/model.js +6 -1
- package/dist/core/model.js.map +1 -1
- package/dist/core/parse.d.ts.map +1 -1
- package/dist/core/parse.js +5 -4
- package/dist/core/parse.js.map +1 -1
- package/dist/core/section.d.ts +27 -2
- package/dist/core/section.d.ts.map +1 -1
- package/dist/core/section.js +63 -11
- package/dist/core/section.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 +2 -2
- package/dist/draw/index.d.ts.map +1 -1
- package/dist/draw/index.js +2 -2
- 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 +247 -85
- package/dist/draw/plan.js.map +1 -1
- package/dist/draw/section.d.ts +20 -2
- package/dist/draw/section.d.ts.map +1 -1
- package/dist/draw/section.js +43 -10
- package/dist/draw/section.js.map +1 -1
- package/dist/form.d.ts +2 -2
- 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 +21 -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/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/editors/vscode/syntaxes/koyu.tmLanguage.json +3 -3
- 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/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 +7 -4
- package/src/cli.ts +2 -2
- package/src/core/components.ts +224 -0
- package/src/core/derive.ts +47 -4
- package/src/core/diagnose.ts +182 -4
- package/src/core/model.ts +10 -5
- package/src/core/parse.ts +5 -4
- package/src/core/section.ts +107 -8
- 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 +9 -2
- package/src/draw/marks.ts +564 -44
- package/src/draw/plan.ts +253 -88
- package/src/draw/section.ts +78 -14
- package/src/form.ts +4 -0
- package/src/index.ts +1 -1
- package/src/mcp.ts +21 -3
- package/src/parse-file.ts +1 -0
- package/src/validate/builtin/index.ts +14 -2
- package/src/validate/builtin/opening-operations.ts +519 -0
package/examples/office.muro
CHANGED
|
@@ -7,7 +7,7 @@ asset D1 door w:900 h:2100 style:hinged name:住戸玄関ドア
|
|
|
7
7
|
asset FD1 door w:900 h:2000 style:hinged fire:特定防火設備 name:防火戸
|
|
8
8
|
asset SD1 door w:800 h:2000 style:sliding name:片引き戸
|
|
9
9
|
|
|
10
|
-
asset BD1 door w:1200 h:2200 style:sliding name
|
|
10
|
+
asset BD1 door w:1200 h:2200 style:sliding-bypass name:Full-height-bypass-sash
|
|
11
11
|
asset W1 window w:2600 h:2200 sill:0 name:掃き出し窓
|
|
12
12
|
asset W2 window w:1650 h:1100 sill:900 name:腰窓
|
|
13
13
|
asset W3 window w:2600 h:1100 sill:1100 name:高窓
|
package/examples/tower/main.muro
CHANGED
|
@@ -9,8 +9,8 @@ asset D1 door w:900 h:2100 style:hinged name:片開き戸
|
|
|
9
9
|
asset D2 door w:1000 h:2400 style:hinged name:住戸玄関ドア
|
|
10
10
|
asset FD1 door w:900 h:2000 style:hinged fire:特定防火設備 name:防火戸
|
|
11
11
|
asset FD2 door w:1800 h:2400 style:hinged fire:特定防火設備 name:防火戸大
|
|
12
|
-
asset VG1 door w:6000 h:3000 style:
|
|
13
|
-
asset LG1 door w:3600 h:3600 style:
|
|
12
|
+
asset VG1 door w:6000 h:3000 style:rolling-shutter name:Vehicle-shutter
|
|
13
|
+
asset LG1 door w:3600 h:3600 style:rolling-shutter name:Loading-shutter
|
|
14
14
|
|
|
15
15
|
# **カーテンウォールは「方立てだけの全面ガラス」を一枚の窓で言う。**
|
|
16
16
|
# 1スパン (8,400) 幅・天井いっぱいの窓 = その面はガラスである、という宣言
|
package/examples/twin/main.muro
CHANGED
package/examples/two-rooms.muro
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kensnzk/koyu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"muro": {
|
|
5
5
|
"reads": [
|
|
6
6
|
"0.1",
|
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
"1.1",
|
|
13
13
|
"1.2",
|
|
14
14
|
"1.3",
|
|
15
|
-
"1.4"
|
|
15
|
+
"1.4",
|
|
16
|
+
"1.5"
|
|
16
17
|
],
|
|
17
|
-
"newest": "1.
|
|
18
|
+
"newest": "1.5",
|
|
18
19
|
"undeclared": "1.1"
|
|
19
20
|
},
|
|
20
|
-
"description": "
|
|
21
|
+
"description": "A text-native architectural notation with space as the primary element",
|
|
21
22
|
"type": "module",
|
|
22
23
|
"main": "./dist/index.js",
|
|
23
24
|
"types": "./dist/index.d.ts",
|
|
@@ -71,6 +72,7 @@
|
|
|
71
72
|
"default": "./dist/parse-file.js"
|
|
72
73
|
},
|
|
73
74
|
"./examples/*": "./examples/*",
|
|
75
|
+
"./assets/*": "./assets/*",
|
|
74
76
|
"./syntax": "./editors/vscode/syntaxes/koyu.tmLanguage.json",
|
|
75
77
|
"./package.json": "./package.json"
|
|
76
78
|
},
|
|
@@ -82,6 +84,7 @@
|
|
|
82
84
|
"dist",
|
|
83
85
|
"src",
|
|
84
86
|
"examples",
|
|
87
|
+
"assets",
|
|
85
88
|
"editors",
|
|
86
89
|
"NOTICE"
|
|
87
90
|
],
|
package/src/cli.ts
CHANGED
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
isVoid,
|
|
42
42
|
versionLine
|
|
43
43
|
} from "./core/model.js";
|
|
44
|
-
import { parseFile } from "./parse-file.js";
|
|
44
|
+
import { componentSvgFiles, parseFile } from "./parse-file.js";
|
|
45
45
|
import { svgPlan } from "./draw/plan.js";
|
|
46
46
|
import { svgAxo } from "./draw/axo.js";
|
|
47
47
|
import { svgElevation, svgSection } from "./draw/section.js";
|
|
@@ -381,7 +381,7 @@ function main(argv: string[]): number {
|
|
|
381
381
|
const explicit = opt(rest, "-o");
|
|
382
382
|
const outFile =
|
|
383
383
|
explicit ?? `${file.replace(/\.muro$/, "")}-${level}.svg`;
|
|
384
|
-
const svg = svgPlan(model, { level });
|
|
384
|
+
const svg = svgPlan(model, { level, componentSvgs: componentSvgFiles(model, level) });
|
|
385
385
|
mkdirSync(dirname(outFile), { recursive: true });
|
|
386
386
|
writeFileSync(outFile, svg);
|
|
387
387
|
console.log(`Generated the plan: ${outFile}`);
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import {
|
|
2
|
+
canonicalSpaceOrder,
|
|
3
|
+
compareCanonical,
|
|
4
|
+
pointInPolygon,
|
|
5
|
+
regionOf,
|
|
6
|
+
type Area,
|
|
7
|
+
type Asset,
|
|
8
|
+
type Model,
|
|
9
|
+
type Pt,
|
|
10
|
+
type Space,
|
|
11
|
+
} from "./model.js";
|
|
12
|
+
import { EPS } from "./tolerance.js";
|
|
13
|
+
|
|
14
|
+
export type ComponentAlignment = "min" | "center" | "max";
|
|
15
|
+
|
|
16
|
+
/** A placed component is physical plan geometry without any drawing vocabulary. */
|
|
17
|
+
export interface PlacedComponent {
|
|
18
|
+
space: string;
|
|
19
|
+
area: string;
|
|
20
|
+
asset: string;
|
|
21
|
+
level: string;
|
|
22
|
+
centre: Pt;
|
|
23
|
+
w: number;
|
|
24
|
+
d: number;
|
|
25
|
+
rotation: number;
|
|
26
|
+
footprint: Pt[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ComponentIssue {
|
|
30
|
+
code: "CMP01" | "CMP02";
|
|
31
|
+
message: string;
|
|
32
|
+
line: number;
|
|
33
|
+
file?: string;
|
|
34
|
+
path: string[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface ComponentPlacementResult {
|
|
38
|
+
components: PlacedComponent[];
|
|
39
|
+
issues: ComponentIssue[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Resolve every area-hosted component. A named area is the only placement frame: there is no
|
|
44
|
+
* second absolute-position spelling that could drift away from the space allocation.
|
|
45
|
+
*/
|
|
46
|
+
export function placedComponents(model: Model): ComponentPlacementResult {
|
|
47
|
+
const components: PlacedComponent[] = [];
|
|
48
|
+
const issues: ComponentIssue[] = [];
|
|
49
|
+
|
|
50
|
+
for (const space of canonicalSpaceOrder(model)) {
|
|
51
|
+
const areas = [...space.areas].sort((a, b) => compareCanonical(areaKey(a), areaKey(b)));
|
|
52
|
+
for (const area of areas) {
|
|
53
|
+
const ref = area.attrs["asset"];
|
|
54
|
+
const at = location(space, area);
|
|
55
|
+
if (ref === undefined) {
|
|
56
|
+
const orphan = ["align-x", "align-y", "offset-x", "offset-y", "rotate"]
|
|
57
|
+
.find((key) => area.attrs[key] !== undefined);
|
|
58
|
+
if (orphan) {
|
|
59
|
+
issues.push({
|
|
60
|
+
code: "CMP01",
|
|
61
|
+
message: `${orphan}: on an area requires asset: because it only controls component placement`,
|
|
62
|
+
...at,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (typeof ref !== "string") {
|
|
68
|
+
issues.push({ code: "CMP01", message: `asset on an area names a component asset: asset:${ref}`, ...at });
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const name = area.attrs["name"];
|
|
72
|
+
if (typeof name !== "string" || name.length === 0) {
|
|
73
|
+
issues.push({
|
|
74
|
+
code: "CMP01",
|
|
75
|
+
message: `An area that places asset ${ref} requires name: (the name identifies the placed component)`,
|
|
76
|
+
...at,
|
|
77
|
+
});
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const asset = model.assets.get(ref);
|
|
81
|
+
if (!asset) {
|
|
82
|
+
issues.push({ code: "CMP01", message: `Undefined component asset on area ${name}: ${ref}`, ...at });
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (asset.kind !== "component") {
|
|
86
|
+
issues.push({
|
|
87
|
+
code: "CMP01",
|
|
88
|
+
message: `The asset ${ref} is a ${asset.kind} (an area can place only a component asset)`,
|
|
89
|
+
...at,
|
|
90
|
+
});
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const dimensions = componentDimensions(asset);
|
|
94
|
+
if (!dimensions || !space.level) continue;
|
|
95
|
+
const settings = placementSettings(area);
|
|
96
|
+
if (settings === undefined) continue;
|
|
97
|
+
if ("message" in settings) {
|
|
98
|
+
issues.push({ code: "CMP01", message: `${settings.message} on area ${name}`, ...at });
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const component = place(space, area, asset, name, dimensions, settings);
|
|
103
|
+
components.push(component);
|
|
104
|
+
const insideHost = inside(area, component.footprint);
|
|
105
|
+
const insideSpace = regionOf(space).some((piece) =>
|
|
106
|
+
component.footprint.every((point) => pointInPolygon(point, piece, EPS))
|
|
107
|
+
);
|
|
108
|
+
if (!insideHost) {
|
|
109
|
+
const alternate = place(space, area, asset, name, dimensions, {
|
|
110
|
+
...settings,
|
|
111
|
+
rotation: (settings.rotation + 90) % 360,
|
|
112
|
+
});
|
|
113
|
+
const suggestion = inside(area, alternate.footprint) ? "; rotate it by a further 90 degrees to fit" : "";
|
|
114
|
+
issues.push({
|
|
115
|
+
code: "CMP02",
|
|
116
|
+
message: `${ref} extends outside its host area ${name}${suggestion}`,
|
|
117
|
+
...at,
|
|
118
|
+
});
|
|
119
|
+
} else if (!insideSpace) {
|
|
120
|
+
issues.push({
|
|
121
|
+
code: "CMP02",
|
|
122
|
+
message: `${ref} extends outside its parent space ${space.path}`,
|
|
123
|
+
...at,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return { components, issues };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function componentDimensions(asset: Asset): { w: number; d: number } | undefined {
|
|
133
|
+
const w = asset.attrs["w"];
|
|
134
|
+
const d = asset.attrs["d"];
|
|
135
|
+
return typeof w === "number" && w > 0 && typeof d === "number" && d > 0 ? { w, d } : undefined;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function placementSettings(area: Area):
|
|
139
|
+
| { alignX: ComponentAlignment; alignY: ComponentAlignment; offsetX: number; offsetY: number; rotation: number }
|
|
140
|
+
| { message: string }
|
|
141
|
+
| undefined {
|
|
142
|
+
const alignX = area.attrs["align-x"] ?? "center";
|
|
143
|
+
const alignY = area.attrs["align-y"] ?? "center";
|
|
144
|
+
const offsetX = area.attrs["offset-x"] ?? 0;
|
|
145
|
+
const offsetY = area.attrs["offset-y"] ?? 0;
|
|
146
|
+
const rotation = area.attrs["rotate"] ?? 0;
|
|
147
|
+
// The attribute ledger owns these enum errors as ATT02. Omit the unresolved component here so
|
|
148
|
+
// one invalid value does not also produce CMP01 for the same spelling.
|
|
149
|
+
if (!isAlignment(alignX) || !isAlignment(alignY)) return undefined;
|
|
150
|
+
if (typeof offsetX !== "number" || !Number.isFinite(offsetX)) {
|
|
151
|
+
return { message: `offset-x is a finite number in mm: offset-x:${offsetX}` };
|
|
152
|
+
}
|
|
153
|
+
if (typeof offsetY !== "number" || !Number.isFinite(offsetY)) {
|
|
154
|
+
return { message: `offset-y is a finite number in mm: offset-y:${offsetY}` };
|
|
155
|
+
}
|
|
156
|
+
if (typeof rotation !== "number" || !Number.isFinite(rotation) || rotation < 0 || rotation >= 360) {
|
|
157
|
+
return { message: `rotate is a number in 0 <= degrees < 360: rotate:${rotation}` };
|
|
158
|
+
}
|
|
159
|
+
return { alignX, alignY, offsetX, offsetY, rotation };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function place(
|
|
163
|
+
space: Space,
|
|
164
|
+
area: Area,
|
|
165
|
+
asset: Asset,
|
|
166
|
+
name: string,
|
|
167
|
+
dimensions: { w: number; d: number },
|
|
168
|
+
settings: { alignX: ComponentAlignment; alignY: ComponentAlignment; offsetX: number; offsetY: number; rotation: number },
|
|
169
|
+
): PlacedComponent {
|
|
170
|
+
const rad = settings.rotation * Math.PI / 180;
|
|
171
|
+
const cos = Math.cos(rad);
|
|
172
|
+
const sin = Math.sin(rad);
|
|
173
|
+
const halfX = Math.abs(cos) * dimensions.w / 2 + Math.abs(sin) * dimensions.d / 2;
|
|
174
|
+
const halfY = Math.abs(sin) * dimensions.w / 2 + Math.abs(cos) * dimensions.d / 2;
|
|
175
|
+
const cx = aligned(area.rect.x1, area.rect.x2, halfX, settings.alignX) + settings.offsetX;
|
|
176
|
+
const cy = aligned(area.rect.y1, area.rect.y2, halfY, settings.alignY) + settings.offsetY;
|
|
177
|
+
const corners: Pt[] = [
|
|
178
|
+
{ x: -dimensions.w / 2, y: -dimensions.d / 2 },
|
|
179
|
+
{ x: dimensions.w / 2, y: -dimensions.d / 2 },
|
|
180
|
+
{ x: dimensions.w / 2, y: dimensions.d / 2 },
|
|
181
|
+
{ x: -dimensions.w / 2, y: dimensions.d / 2 },
|
|
182
|
+
];
|
|
183
|
+
const footprint = corners.map((p) => ({
|
|
184
|
+
x: cx + p.x * cos - p.y * sin,
|
|
185
|
+
y: cy + p.x * sin + p.y * cos,
|
|
186
|
+
}));
|
|
187
|
+
return {
|
|
188
|
+
space: space.path,
|
|
189
|
+
area: name,
|
|
190
|
+
asset: asset.name,
|
|
191
|
+
level: space.level!,
|
|
192
|
+
centre: { x: cx, y: cy },
|
|
193
|
+
w: dimensions.w,
|
|
194
|
+
d: dimensions.d,
|
|
195
|
+
rotation: settings.rotation,
|
|
196
|
+
footprint,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function aligned(lo: number, hi: number, half: number, alignment: ComponentAlignment): number {
|
|
201
|
+
if (alignment === "min") return lo + half;
|
|
202
|
+
if (alignment === "max") return hi - half;
|
|
203
|
+
return (lo + hi) / 2;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function inside(area: Area, footprint: readonly Pt[]): boolean {
|
|
207
|
+
return footprint.every((p) =>
|
|
208
|
+
p.x >= area.rect.x1 - EPS && p.x <= area.rect.x2 + EPS
|
|
209
|
+
&& p.y >= area.rect.y1 - EPS && p.y <= area.rect.y2 + EPS
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function isAlignment(value: unknown): value is ComponentAlignment {
|
|
214
|
+
return value === "min" || value === "center" || value === "max";
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function location(space: Space, area: Area): { line: number; file?: string; path: string[] } {
|
|
218
|
+
return { line: area.line, ...(space.file ? { file: space.file } : {}), path: [space.path] };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function areaKey(area: Area): string {
|
|
222
|
+
const name = area.attrs["name"];
|
|
223
|
+
return `${typeof name === "string" ? name : ""}\u0000${JSON.stringify([area.grid, area.attrs])}`;
|
|
224
|
+
}
|
package/src/core/derive.ts
CHANGED
|
@@ -44,10 +44,12 @@ import {
|
|
|
44
44
|
canonicalSegOrder,
|
|
45
45
|
canonicalSpaceOrder,
|
|
46
46
|
isOutside,
|
|
47
|
-
isVoid
|
|
47
|
+
isVoid,
|
|
48
|
+
isNewerVersion,
|
|
48
49
|
} from "./model.js";
|
|
49
50
|
import { clipHalf } from "./poly.js";
|
|
50
51
|
import { EPS, PARALLEL_EPS, POINT_EPS, SPAN_EPS } from "./tolerance.js";
|
|
52
|
+
import { placedComponents, type PlacedComponent } from "./components.js";
|
|
51
53
|
import {
|
|
52
54
|
CUT_HEIGHT,
|
|
53
55
|
ARROW_SPAN_MIN,
|
|
@@ -229,12 +231,38 @@ export interface FormOpening {
|
|
|
229
231
|
/** 建具の見付け厚 = 壁厚 */
|
|
230
232
|
t: number;
|
|
231
233
|
style?: string;
|
|
234
|
+
/** Explicit equal panel count for a curtain wall. One when omitted. */
|
|
235
|
+
panels?: number;
|
|
232
236
|
/** 扉が開く先 (引戸・自動扉なら軌跡ではなく引き込みの向き) */
|
|
233
237
|
swing?: FormSwing;
|
|
234
|
-
/**
|
|
238
|
+
/** whether the opening has no swing arc because its operation is sliding or non-swinging */
|
|
235
239
|
sliding: boolean;
|
|
236
240
|
}
|
|
237
241
|
|
|
242
|
+
const NON_SWING_OPENING_STYLES = new Set([
|
|
243
|
+
"sliding",
|
|
244
|
+
"sliding-double",
|
|
245
|
+
"sliding-bypass",
|
|
246
|
+
"auto",
|
|
247
|
+
"auto-single",
|
|
248
|
+
"auto-double",
|
|
249
|
+
"entrance",
|
|
250
|
+
"gate-sliding",
|
|
251
|
+
"rolling-shutter",
|
|
252
|
+
"overhead",
|
|
253
|
+
"projecting",
|
|
254
|
+
"curtain-wall",
|
|
255
|
+
]);
|
|
256
|
+
|
|
257
|
+
const WINDOW_SWING_STYLES = new Set([
|
|
258
|
+
"hinged",
|
|
259
|
+
"hinged-double",
|
|
260
|
+
"sliding",
|
|
261
|
+
"sliding-double",
|
|
262
|
+
"sliding-bypass",
|
|
263
|
+
"projecting",
|
|
264
|
+
]);
|
|
265
|
+
|
|
238
266
|
export interface FormSeg {
|
|
239
267
|
/** 分節の同一性 — 境界と、その中の並びの位置 */
|
|
240
268
|
ref: string;
|
|
@@ -265,6 +293,9 @@ export interface FormSite {
|
|
|
265
293
|
areaM2: number;
|
|
266
294
|
}
|
|
267
295
|
|
|
296
|
+
/** A component footprint placed by a named uncounted area. Artwork remains a draw concern. */
|
|
297
|
+
export interface FormComponent extends PlacedComponent {}
|
|
298
|
+
|
|
268
299
|
/** 2Dエンティティの分類 — 平面が純粋な断面でないことを、この五つが言う */
|
|
269
300
|
export type PlanClass =
|
|
270
301
|
/** 切断面が切ったもの */
|
|
@@ -315,6 +346,8 @@ export interface Form {
|
|
|
315
346
|
spaces: FormSpace[];
|
|
316
347
|
boundaries: FormBoundary[];
|
|
317
348
|
openings: FormOpening[];
|
|
349
|
+
/** Present only when the source places a component, preserving older Form bytes otherwise. */
|
|
350
|
+
components?: FormComponent[];
|
|
318
351
|
/** 数えない分節 (ADR-0003) — 面積にもグラフにも現れないが、位置は導出される */
|
|
319
352
|
segs: FormSeg[];
|
|
320
353
|
slabs: Slab[];
|
|
@@ -916,7 +949,8 @@ export function derive(model: Model, opts: DeriveOptions = {}): Form {
|
|
|
916
949
|
: z0 + OPENING_HEAD;
|
|
917
950
|
holes.push({ lo: d - p.o.w / 2, hi: d + p.o.w / 2, z0: oz0, z1: oz1 });
|
|
918
951
|
const style = p.o.attrs["style"];
|
|
919
|
-
const
|
|
952
|
+
const panels = p.o.attrs["panels"];
|
|
953
|
+
const sliding = typeof style === "string" && NON_SWING_OPENING_STYLES.has(style);
|
|
920
954
|
const name = p.o.attrs["name"];
|
|
921
955
|
openings.push({
|
|
922
956
|
ref: `${ref}/${p.index}`,
|
|
@@ -935,7 +969,12 @@ export function derive(model: Model, opts: DeriveOptions = {}): Form {
|
|
|
935
969
|
z1: oz1,
|
|
936
970
|
t,
|
|
937
971
|
...(typeof style === "string" ? { style } : {}),
|
|
938
|
-
...(
|
|
972
|
+
...(typeof panels === "number" ? { panels } : {}),
|
|
973
|
+
...(p.o.kind === "door" || (
|
|
974
|
+
!isNewerVersion("1.5", model.version)
|
|
975
|
+
&& typeof style === "string"
|
|
976
|
+
&& WINDOW_SWING_STYLES.has(style)
|
|
977
|
+
)
|
|
939
978
|
? (() => {
|
|
940
979
|
const sw = swingOf(model, b, p.o, seg, p.cx, p.cy);
|
|
941
980
|
return sw ? { swing: sw } : {};
|
|
@@ -1000,6 +1039,9 @@ export function derive(model: Model, opts: DeriveOptions = {}): Form {
|
|
|
1000
1039
|
areaM2: polygonAreaM2(p.points),
|
|
1001
1040
|
}));
|
|
1002
1041
|
|
|
1042
|
+
// ---- Area-hosted components ----
|
|
1043
|
+
const components = placedComponents(model).components;
|
|
1044
|
+
|
|
1003
1045
|
// ---- 平面 ----
|
|
1004
1046
|
const plans = levels.map((l) =>
|
|
1005
1047
|
planOf(model, l.name, l.z + cut, cut, { spaces, boundaries, openings, columns }),
|
|
@@ -1011,6 +1053,7 @@ export function derive(model: Model, opts: DeriveOptions = {}): Form {
|
|
|
1011
1053
|
spaces,
|
|
1012
1054
|
boundaries,
|
|
1013
1055
|
openings,
|
|
1056
|
+
...(components.length > 0 ? { components } : {}),
|
|
1014
1057
|
segs,
|
|
1015
1058
|
slabs: slabs(model),
|
|
1016
1059
|
columns,
|