@seatmap-fyi/map-domain 0.1.0-alpha.3 → 0.1.0-alpha.48
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/dist/arc-fan-rebuild.d.ts +13 -0
- package/dist/arc-fan-rebuild.js +163 -0
- package/dist/arc-fan.d.ts +27 -0
- package/dist/arc-fan.interface.d.ts +83 -0
- package/dist/arc-fan.interface.js +30 -0
- package/dist/arc-fan.js +182 -0
- package/dist/catalog.d.ts +10 -3
- package/dist/catalog.js +66 -10
- package/dist/categories.d.ts +27 -0
- package/dist/categories.js +217 -0
- package/dist/editor-state.d.ts +4 -1
- package/dist/editor-state.js +61 -31
- package/dist/floors.d.ts +22 -0
- package/dist/floors.js +77 -0
- package/dist/geometry/boundary.d.ts +1 -1
- package/dist/geometry/boundary.js +16 -12
- package/dist/geometry/curve-warnings.d.ts +1 -1
- package/dist/geometry/curve-warnings.js +3 -5
- package/dist/geometry/decoration-bounds.d.ts +4 -0
- package/dist/geometry/decoration-bounds.js +42 -0
- package/dist/geometry/ellipse.js +4 -12
- package/dist/geometry/geometry.d.ts +12 -3
- package/dist/geometry/geometry.js +37 -28
- package/dist/geometry/layout-transform.d.ts +10 -0
- package/dist/geometry/layout-transform.interface.d.ts +6 -0
- package/dist/geometry/layout-transform.interface.js +1 -0
- package/dist/geometry/layout-transform.js +206 -0
- package/dist/geometry/polygon-curves.d.ts +17 -0
- package/dist/geometry/polygon-curves.interface.d.ts +21 -0
- package/dist/geometry/polygon-curves.interface.js +5 -0
- package/dist/geometry/polygon-curves.js +169 -0
- package/dist/geometry/primitives.d.ts +1 -1
- package/dist/geometry/primitives.js +2 -3
- package/dist/geometry/seat-shape.d.ts +24 -0
- package/dist/geometry/seat-shape.js +101 -0
- package/dist/geometry/seating-layout.d.ts +20 -3
- package/dist/geometry/seating-layout.js +113 -19
- package/dist/geometry/units.d.ts +8 -0
- package/dist/geometry/units.js +13 -0
- package/dist/geometry/venue-outline.d.ts +4 -18
- package/dist/geometry/venue-outline.interface.d.ts +23 -0
- package/dist/geometry/venue-outline.interface.js +7 -0
- package/dist/geometry/venue-outline.js +107 -49
- package/dist/identity.d.ts +3 -1
- package/dist/identity.js +32 -9
- package/dist/issues.d.ts +15 -2
- package/dist/issues.js +16 -6
- package/dist/labels.d.ts +12 -1
- package/dist/labels.js +76 -11
- package/dist/layers.d.ts +26 -0
- package/dist/layers.js +86 -0
- package/dist/media.d.ts +27 -0
- package/dist/media.js +89 -0
- package/dist/physical-document.interface.d.ts +592 -0
- package/dist/physical-document.interface.js +179 -0
- package/dist/preview.d.ts +1 -1
- package/dist/preview.js +70 -25
- package/dist/reference.js +1 -1
- package/dist/row-segments.d.ts +30 -0
- package/dist/row-segments.js +113 -0
- package/dist/schema.d.ts +1578 -68
- package/dist/schema.js +467 -98
- package/dist/seat-proximity.d.ts +4 -0
- package/dist/seat-proximity.js +119 -0
- package/dist/section-elevation.d.ts +5 -0
- package/dist/section-elevation.interface.d.ts +26 -0
- package/dist/section-elevation.interface.js +8 -0
- package/dist/section-elevation.js +53 -0
- package/dist/section-fill-rebuild.d.ts +10 -0
- package/dist/section-fill-rebuild.js +64 -0
- package/dist/section-fill.d.ts +84 -0
- package/dist/section-fill.interface.d.ts +94 -0
- package/dist/section-fill.interface.js +22 -0
- package/dist/section-fill.js +306 -0
- package/dist/section-growth.d.ts +11 -0
- package/dist/section-growth.interface.d.ts +12 -0
- package/dist/section-growth.interface.js +1 -0
- package/dist/section-growth.js +198 -0
- package/dist/section-layout.d.ts +95 -0
- package/dist/section-layout.interface.d.ts +8 -0
- package/dist/section-layout.interface.js +5 -0
- package/dist/section-layout.js +70 -0
- package/dist/section-outline-refit.d.ts +8 -0
- package/dist/section-outline-refit.js +246 -0
- package/dist/section-refit.d.ts +22 -0
- package/dist/section-refit.interface.d.ts +49 -0
- package/dist/section-refit.interface.js +6 -0
- package/dist/section-refit.js +179 -0
- package/dist/section-scale.d.ts +2 -0
- package/dist/section-scale.js +128 -0
- package/dist/sections.d.ts +23 -0
- package/dist/sections.js +144 -0
- package/dist/selling.d.ts +34 -0
- package/dist/selling.js +148 -0
- package/dist/spacing-repairs.d.ts +31 -0
- package/dist/spacing-repairs.js +168 -0
- package/dist/table-layout.d.ts +29 -0
- package/dist/table-layout.js +134 -0
- package/dist/validation.d.ts +7 -2
- package/dist/validation.interface.d.ts +20 -0
- package/dist/validation.interface.js +9 -0
- package/dist/validation.js +227 -78
- package/dist/wayfinding.d.ts +10 -0
- package/dist/wayfinding.interface.d.ts +52 -0
- package/dist/wayfinding.interface.js +28 -0
- package/dist/wayfinding.js +63 -0
- package/package.json +109 -4
- package/dist/types.d.ts +0 -313
- package/dist/types.js +0 -91
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { polygonContour } from "./polygon-curves.js";
|
|
2
|
+
import { DecorationKind, LabelAlignment } from "../physical-document.interface.js";
|
|
3
|
+
import { pointsBounds, project } from "./geometry.js";
|
|
4
|
+
/** World bounds of the physical artwork, independent of editor selection and section ownership. */
|
|
5
|
+
export function decorationBounds(decoration, matrix) {
|
|
6
|
+
let points;
|
|
7
|
+
switch (decoration.kind) {
|
|
8
|
+
case DecorationKind.Line:
|
|
9
|
+
points = decoration.pointsM;
|
|
10
|
+
break;
|
|
11
|
+
case DecorationKind.Polygon:
|
|
12
|
+
points = polygonContour(decoration.boundary).outer;
|
|
13
|
+
break;
|
|
14
|
+
case DecorationKind.Text: {
|
|
15
|
+
const width = Math.max(decoration.fontSizeM, Array.from(decoration.text).length * decoration.fontSizeM * 0.65);
|
|
16
|
+
let start = -width / 2;
|
|
17
|
+
if (decoration.align === LabelAlignment.Left)
|
|
18
|
+
start = 0;
|
|
19
|
+
else if (decoration.align === LabelAlignment.Right)
|
|
20
|
+
start = -width;
|
|
21
|
+
points = rectanglePoints(width, decoration.fontSizeM).map((point) => ({
|
|
22
|
+
x: point.x + start + width / 2,
|
|
23
|
+
y: point.y,
|
|
24
|
+
}));
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
case DecorationKind.Circle:
|
|
28
|
+
points = rectanglePoints(decoration.radiusM * 2, decoration.radiusM * 2);
|
|
29
|
+
break;
|
|
30
|
+
default:
|
|
31
|
+
points = rectanglePoints(decoration.sizeM.width, decoration.sizeM.height);
|
|
32
|
+
}
|
|
33
|
+
return pointsBounds(points.map((point) => project(matrix, point)));
|
|
34
|
+
}
|
|
35
|
+
function rectanglePoints(width, height) {
|
|
36
|
+
return [
|
|
37
|
+
{ x: -width / 2, y: -height / 2 },
|
|
38
|
+
{ x: width / 2, y: -height / 2 },
|
|
39
|
+
{ x: width / 2, y: height / 2 },
|
|
40
|
+
{ x: -width / 2, y: height / 2 },
|
|
41
|
+
];
|
|
42
|
+
}
|
package/dist/geometry/ellipse.js
CHANGED
|
@@ -21,11 +21,7 @@ function table(a, b) {
|
|
|
21
21
|
for (let i = 1; i <= count; i++) {
|
|
22
22
|
const start = (tau * (i - 1)) / count, end = (tau * i) / count;
|
|
23
23
|
angles[i] = end;
|
|
24
|
-
lengths[i] =
|
|
25
|
-
lengths[i - 1] +
|
|
26
|
-
((end - start) *
|
|
27
|
-
(speed(start) + 4 * speed((start + end) / 2) + speed(end))) /
|
|
28
|
-
6;
|
|
24
|
+
lengths[i] = lengths[i - 1] + ((end - start) * (speed(start) + 4 * speed((start + end) / 2) + speed(end))) / 6;
|
|
29
25
|
}
|
|
30
26
|
const result = { angles, lengths, perimeter: lengths[count] };
|
|
31
27
|
if (cache.size >= 128)
|
|
@@ -46,23 +42,19 @@ function interval(keys, value) {
|
|
|
46
42
|
}
|
|
47
43
|
function partial(a, b, start, end) {
|
|
48
44
|
const speed = (t) => Math.hypot(a * Math.sin(t), b * Math.cos(t));
|
|
49
|
-
return ((
|
|
50
|
-
(speed(start) + 4 * speed((start + end) / 2) + speed(end))) /
|
|
51
|
-
6);
|
|
45
|
+
return ((end - start) * (speed(start) + 4 * speed((start + end) / 2) + speed(end))) / 6;
|
|
52
46
|
}
|
|
53
47
|
export function ellipseArcLength(a, b, angle) {
|
|
54
48
|
if (a === b)
|
|
55
49
|
return a * angle;
|
|
56
50
|
const t = table(a, b), turns = Math.floor(angle / tau), within = angle - turns * tau, i = interval(t.angles, within);
|
|
57
|
-
return
|
|
51
|
+
return turns * t.perimeter + t.lengths[i] + partial(a, b, t.angles[i], within);
|
|
58
52
|
}
|
|
59
53
|
export function ellipseAngleAtDistance(a, b, center, distance) {
|
|
60
54
|
if (a === b)
|
|
61
55
|
return center + distance / a;
|
|
62
56
|
const t = table(a, b), length = ellipseArcLength(a, b, center) + distance, turns = Math.floor(length / t.perimeter), within = length - turns * t.perimeter, i = interval(t.lengths, within);
|
|
63
|
-
let angle = t.angles[i] +
|
|
64
|
-
((within - t.lengths[i]) / (t.lengths[i + 1] - t.lengths[i])) *
|
|
65
|
-
(t.angles[i + 1] - t.angles[i]);
|
|
57
|
+
let angle = t.angles[i] + ((within - t.lengths[i]) / (t.lengths[i + 1] - t.lengths[i])) * (t.angles[i + 1] - t.angles[i]);
|
|
66
58
|
for (let n = 0; n < 5; n++) {
|
|
67
59
|
const error = t.lengths[i] + partial(a, b, t.angles[i], angle) - within;
|
|
68
60
|
angle = Math.max(t.angles[i], Math.min(t.angles[i + 1], angle - error / Math.hypot(a * Math.sin(angle), b * Math.cos(angle))));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PhysicalDocumentV1, type PointM, type PolygonM, type SeatingGroup, type SeatSlot, type SizeM, type Transform, type UUID } from "../
|
|
1
|
+
import { type PhysicalDocumentV1, type PointM, type PolygonM, type SeatingGroup, type SeatSlot, type SizeM, type Transform, type UUID, type LabelSequence } from "../physical-document.interface.js";
|
|
2
2
|
export type Matrix = {
|
|
3
3
|
a: number;
|
|
4
4
|
b: number;
|
|
@@ -8,18 +8,26 @@ export type Matrix = {
|
|
|
8
8
|
ty: number;
|
|
9
9
|
};
|
|
10
10
|
import { type Bounds } from "./primitives.js";
|
|
11
|
-
export { containsPoint, emptyBounds, extend, intersects, pointsBounds, type Bounds
|
|
11
|
+
export { containsPoint, emptyBounds, extend, intersects, pointsBounds, type Bounds } from "./primitives.js";
|
|
12
12
|
export type GeneratedSeat = {
|
|
13
13
|
id: UUID;
|
|
14
14
|
groupId: UUID;
|
|
15
15
|
rowId: UUID | null;
|
|
16
|
-
sectionId: UUID | null;
|
|
17
16
|
label: string;
|
|
17
|
+
/** Canonical sequence label, independent of an authored display override. */
|
|
18
|
+
bookingLabel: string;
|
|
18
19
|
ownerLabel: string;
|
|
20
|
+
addressRowLabel?: string;
|
|
21
|
+
logicalRowLabel?: string;
|
|
22
|
+
logicalRowId?: UUID;
|
|
23
|
+
logicalPartIndex?: number;
|
|
24
|
+
logicalSequence?: LabelSequence;
|
|
19
25
|
position: PointM;
|
|
20
26
|
rotationDeg: number;
|
|
21
27
|
size: SizeM;
|
|
22
28
|
slot: SeatSlot;
|
|
29
|
+
aisle: boolean;
|
|
30
|
+
categoryId: UUID | null;
|
|
23
31
|
};
|
|
24
32
|
export declare const identityMatrix: Matrix;
|
|
25
33
|
export declare const radians: (value: number) => number;
|
|
@@ -31,6 +39,7 @@ export declare function project(m: Matrix, p: PointM): PointM;
|
|
|
31
39
|
/** Table bodies remain part of drawable bounds even with chairs on one side. */
|
|
32
40
|
export declare function tableBodyBounds(group: SeatingGroup, matrix: Matrix): Bounds | null;
|
|
33
41
|
export declare function worldMatrices(document: PhysicalDocumentV1): Map<UUID, Matrix>;
|
|
42
|
+
export declare function generatedSeats(group: SeatingGroup): readonly GeneratedSeat[];
|
|
34
43
|
export declare function generateGroup(group: SeatingGroup): Generator<GeneratedSeat>;
|
|
35
44
|
export declare function footprint(seat: GeneratedSeat, world?: Matrix): PointM[];
|
|
36
45
|
export declare function footprintInside(points: PointM[], polygon: PolygonM): boolean;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { polygonContour } from "./polygon-curves.js";
|
|
2
|
+
import { rowPlacementOffset, rowSeatGeometry, roundChairGeometry, rectangularChairGeometry, TableSide, } from "./seating-layout.js";
|
|
3
|
+
import { SeatingKind, TableChairDistribution, RowEnds, } from "../physical-document.interface.js";
|
|
4
|
+
import { inventoryName, sequenceLabel, rowDisplayLabel } from "../labels.js";
|
|
5
|
+
import { seatCategoryId } from "../categories.js";
|
|
6
|
+
import { containsPoint, intersects, pointsBounds } from "./primitives.js";
|
|
7
|
+
export { containsPoint, emptyBounds, extend, intersects, pointsBounds } from "./primitives.js";
|
|
6
8
|
import { prepareBoundary, footprintInBoundary } from "./boundary.js";
|
|
7
9
|
export const identityMatrix = { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 };
|
|
8
10
|
export const radians = (value) => (value * Math.PI) / 180;
|
|
@@ -80,21 +82,26 @@ export function worldMatrices(document) {
|
|
|
80
82
|
};
|
|
81
83
|
for (const c of document.collections)
|
|
82
84
|
resolve(c.id);
|
|
83
|
-
for (const entity of [
|
|
84
|
-
...document.seatingGroups,
|
|
85
|
-
...document.areas,
|
|
86
|
-
...document.decorations,
|
|
87
|
-
])
|
|
85
|
+
for (const entity of [...document.seatingGroups, ...document.areas, ...document.decorations])
|
|
88
86
|
result.set(entity.id, multiply(entity.parentId ? resolve(entity.parentId) : identityMatrix, transformMatrix(entity.transform)));
|
|
89
87
|
return result;
|
|
90
88
|
}
|
|
89
|
+
const generated = new WeakMap();
|
|
90
|
+
export function generatedSeats(group) {
|
|
91
|
+
let cached = generated.get(group);
|
|
92
|
+
if (!cached) {
|
|
93
|
+
cached = Object.freeze([...generateGroup(group)]);
|
|
94
|
+
generated.set(group, cached);
|
|
95
|
+
}
|
|
96
|
+
return cached;
|
|
97
|
+
}
|
|
91
98
|
export function* generateGroup(group) {
|
|
92
|
-
const emit = (slot, p, rotationDeg, label, ownerLabel, rowId) => ({
|
|
99
|
+
const emit = (slot, p, rotationDeg, label, ownerLabel, rowId, aisle = false, categoryId = seatCategoryId(group, slot)) => ({
|
|
93
100
|
id: slot.id,
|
|
94
101
|
groupId: group.id,
|
|
95
102
|
rowId,
|
|
96
|
-
sectionId: group.sectionId,
|
|
97
103
|
label: slot.labelOverride ?? label,
|
|
104
|
+
bookingLabel: label,
|
|
98
105
|
ownerLabel,
|
|
99
106
|
position: {
|
|
100
107
|
x: p.x + (slot.override?.offsetM?.x ?? 0),
|
|
@@ -103,38 +110,42 @@ export function* generateGroup(group) {
|
|
|
103
110
|
rotationDeg: normalizeAngle(rotationDeg + (slot.override?.rotationDeltaDeg ?? 0)),
|
|
104
111
|
size: slot.override?.sizeM ?? group.seatSizeM,
|
|
105
112
|
slot,
|
|
113
|
+
aisle,
|
|
114
|
+
categoryId,
|
|
106
115
|
});
|
|
107
|
-
if (group.kind === SeatingKind.Straight ||
|
|
108
|
-
group.kind === SeatingKind.Curved) {
|
|
116
|
+
if (group.kind === SeatingKind.Straight || group.kind === SeatingKind.Curved) {
|
|
109
117
|
const longestRow = group.rows.reduce((max, row) => Math.max(max, row.seats.length), 0);
|
|
110
118
|
for (let r = 0; r < group.rows.length; r++) {
|
|
111
119
|
const row = group.rows[r];
|
|
112
|
-
const owner =
|
|
113
|
-
|
|
120
|
+
const owner = rowDisplayLabel(group, r);
|
|
121
|
+
const offset = rowPlacementOffset(group, r, row.offsetM);
|
|
114
122
|
for (let i = 0; i < row.seats.length; i++) {
|
|
115
|
-
const geometry = rowSeatGeometry(group, r, i, row.seats.length, longestRow);
|
|
116
|
-
|
|
123
|
+
const geometry = rowSeatGeometry(group, r, i, row.seats.length, longestRow, row.layout);
|
|
124
|
+
const p = { x: geometry.position.x + offset.x, y: geometry.position.y + offset.y };
|
|
117
125
|
const rotation = geometry.rotationDeg;
|
|
118
|
-
|
|
119
|
-
|
|
126
|
+
const seat = emit(row.seats[i], p, rotation, sequenceLabel(row.seatSequenceOverride ?? group.labels.seats, i, row.seats.length), owner, row.id, (i === 0 && (row.aisleSeats === RowEnds.Start || row.aisleSeats === RowEnds.Both)) ||
|
|
127
|
+
(i === row.seats.length - 1 && (row.aisleSeats === RowEnds.End || row.aisleSeats === RowEnds.Both)), seatCategoryId(group, row.seats[i], row));
|
|
128
|
+
yield seat;
|
|
120
129
|
}
|
|
121
130
|
}
|
|
122
131
|
}
|
|
123
132
|
else if (group.kind === SeatingKind.Round) {
|
|
124
133
|
for (let i = 0; i < group.chairs.length; i++) {
|
|
125
134
|
const geometry = roundChairGeometry(group.recipe, group.seatSizeM.height, i, group.chairs.length);
|
|
126
|
-
yield emit(group.chairs[i], geometry.position, geometry.rotationDeg, sequenceLabel(group.labels.chairs, i, group.chairs.length), group.labels
|
|
135
|
+
yield emit(group.chairs[i], geometry.position, geometry.rotationDeg, sequenceLabel(group.labels.chairs, i, group.chairs.length), inventoryName(group.labels), null);
|
|
127
136
|
}
|
|
128
137
|
}
|
|
129
138
|
else {
|
|
130
|
-
const sides =
|
|
139
|
+
const sides = group.recipe.chairDistribution === TableChairDistribution.EqualSegments
|
|
140
|
+
? [TableSide.Top, TableSide.Bottom, TableSide.Left, TableSide.Right]
|
|
141
|
+
: Object.values(TableSide);
|
|
131
142
|
const total = sides.reduce((n, s) => n + group.chairsBySide[s].length, 0);
|
|
132
143
|
let ordinal = 0;
|
|
133
144
|
for (const side of sides) {
|
|
134
145
|
const list = group.chairsBySide[side];
|
|
135
146
|
for (let i = 0; i < list.length; i++) {
|
|
136
147
|
const geometry = rectangularChairGeometry(group.recipe, group.seatSizeM.height, side, i, list.length);
|
|
137
|
-
yield emit(list[i], geometry.position, geometry.rotationDeg, sequenceLabel(group.labels.chairs, ordinal++, total), group.labels
|
|
148
|
+
yield emit(list[i], geometry.position, geometry.rotationDeg, sequenceLabel(group.labels.chairs, ordinal++, total), inventoryName(group.labels), null);
|
|
138
149
|
}
|
|
139
150
|
}
|
|
140
151
|
}
|
|
@@ -153,8 +164,7 @@ export function footprint(seat, world = identityMatrix) {
|
|
|
153
164
|
}
|
|
154
165
|
function crosses(a, b, c, d) {
|
|
155
166
|
const side = (p, q, r) => (q.x - p.x) * (r.y - p.y) - (q.y - p.y) * (r.x - p.x);
|
|
156
|
-
return
|
|
157
|
-
side(c, d, a) * side(c, d, b) < -1e-12);
|
|
167
|
+
return side(a, b, c) * side(a, b, d) < -1e-12 && side(c, d, a) * side(c, d, b) < -1e-12;
|
|
158
168
|
}
|
|
159
169
|
export function footprintInside(points, polygon) {
|
|
160
170
|
return footprintInBoundary(prepareBoundary(polygon), points);
|
|
@@ -164,7 +174,7 @@ export function invalidPolygon(polygon) {
|
|
|
164
174
|
const cached = polygonValidity.get(polygon);
|
|
165
175
|
if (cached !== undefined)
|
|
166
176
|
return cached;
|
|
167
|
-
const result = calculateInvalidPolygon(polygon);
|
|
177
|
+
const result = calculateInvalidPolygon(polygonContour(polygon));
|
|
168
178
|
polygonValidity.set(polygon, result);
|
|
169
179
|
return result;
|
|
170
180
|
}
|
|
@@ -191,8 +201,7 @@ function calculateInvalidPolygon(polygon) {
|
|
|
191
201
|
for (let i = 0; i < edges.length; i++)
|
|
192
202
|
for (let j = i + 1; j < edges.length && edges[j].bounds.minX <= edges[i].bounds.maxX; j++) {
|
|
193
203
|
const a = edges[i], b = edges[j];
|
|
194
|
-
if (Math.abs(a.index - b.index) === 1 ||
|
|
195
|
-
Math.abs(a.index - b.index) === ring.length - 1)
|
|
204
|
+
if (Math.abs(a.index - b.index) === 1 || Math.abs(a.index - b.index) === ring.length - 1)
|
|
196
205
|
continue;
|
|
197
206
|
if (intersects(a.bounds, b.bounds) &&
|
|
198
207
|
(crosses(a.a, a.b, b.a, b.b) ||
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PhysicalDocumentV1, type PointM, type PolygonM, type SeatSlot, type SeatingGroup, type Transform, type UUID } from "../physical-document.interface.js";
|
|
2
|
+
import { type Matrix } from "./geometry.js";
|
|
3
|
+
import type { LayoutTransformScope } from "./layout-transform.interface.js";
|
|
4
|
+
/** Ordinary complete row banks share a transform; generated rows retain manual geometry edits. */
|
|
5
|
+
export declare function compactRowTargets(doc: PhysicalDocumentV1, ids: Iterable<UUID>): Set<UUID>;
|
|
6
|
+
export declare function transformFromMatrix(m: Matrix): Transform;
|
|
7
|
+
export declare function sectionOutlinePivot(outline: PolygonM): PointM;
|
|
8
|
+
/** Apply the prepared scope to the same world geometry used by the editor preview. */
|
|
9
|
+
export declare function transformLayout(doc: PhysicalDocumentV1, scope: LayoutTransformScope, delta: PointM, angle: number): PhysicalDocumentV1;
|
|
10
|
+
export declare function mapSeats(group: SeatingGroup, change: (s: SeatSlot) => SeatSlot): SeatingGroup;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { rowPlacementOffset } from "./seating-layout.js";
|
|
2
|
+
import { documentCatalog } from "../catalog.js";
|
|
3
|
+
import { SeatingKind, } from "../physical-document.interface.js";
|
|
4
|
+
import { identityMatrix, inverse, multiply, normalizeAngle, project, radians, worldMatrices, } from "./geometry.js";
|
|
5
|
+
/** Ordinary complete row banks share a transform; generated rows retain manual geometry edits. */
|
|
6
|
+
export function compactRowTargets(doc, ids) {
|
|
7
|
+
const targets = new Set(ids);
|
|
8
|
+
const catalog = documentCatalog(doc);
|
|
9
|
+
const rowsByGroup = new Map();
|
|
10
|
+
for (const id of targets) {
|
|
11
|
+
const group = catalog.rows.get(id);
|
|
12
|
+
if (!group)
|
|
13
|
+
continue;
|
|
14
|
+
const rows = rowsByGroup.get(group.id) ?? [];
|
|
15
|
+
rows.push(id);
|
|
16
|
+
rowsByGroup.set(group.id, rows);
|
|
17
|
+
}
|
|
18
|
+
for (const [groupId, rows] of rowsByGroup) {
|
|
19
|
+
const group = catalog.groups.get(groupId);
|
|
20
|
+
if (!("rows" in group) || group.arcFan || rows.length !== group.rows.length)
|
|
21
|
+
continue;
|
|
22
|
+
for (const id of rows)
|
|
23
|
+
targets.delete(id);
|
|
24
|
+
targets.add(groupId);
|
|
25
|
+
}
|
|
26
|
+
return targets;
|
|
27
|
+
}
|
|
28
|
+
export function transformFromMatrix(m) {
|
|
29
|
+
const flipped = m.a * m.d - m.b * m.c < 0;
|
|
30
|
+
return {
|
|
31
|
+
positionM: { x: m.tx, y: m.ty },
|
|
32
|
+
rotationDeg: normalizeAngle((Math.atan2(m.b, m.a) * 180) / Math.PI),
|
|
33
|
+
flipX: false,
|
|
34
|
+
flipY: flipped,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function sectionOutlinePivot(outline) {
|
|
38
|
+
const points = outline.outer;
|
|
39
|
+
return {
|
|
40
|
+
x: points.reduce((sum, point) => sum + point.x, 0) / points.length,
|
|
41
|
+
y: points.reduce((sum, point) => sum + point.y, 0) / points.length,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Apply the prepared scope to the same world geometry used by the editor preview. */
|
|
45
|
+
export function transformLayout(doc, scope, delta, angle) {
|
|
46
|
+
const sectionIds = new Set(scope.sections);
|
|
47
|
+
const targets = new Set(scope.objects);
|
|
48
|
+
const matrices = worldMatrices(doc);
|
|
49
|
+
const center = scope.pivot;
|
|
50
|
+
const cos = Math.cos(radians(angle));
|
|
51
|
+
const sin = Math.sin(radians(angle));
|
|
52
|
+
const rotation = {
|
|
53
|
+
a: cos,
|
|
54
|
+
b: sin,
|
|
55
|
+
c: -sin,
|
|
56
|
+
d: cos,
|
|
57
|
+
tx: center.x + delta.x - cos * center.x + sin * center.y,
|
|
58
|
+
ty: center.y + delta.y - sin * center.x - cos * center.y,
|
|
59
|
+
};
|
|
60
|
+
const moveDrawable = (entity) => {
|
|
61
|
+
if (!targets.has(entity.id))
|
|
62
|
+
return entity;
|
|
63
|
+
const world = matrices.get(entity.id);
|
|
64
|
+
return {
|
|
65
|
+
...entity,
|
|
66
|
+
transform: transformFromMatrix(multiply(entity.parentId ? inverse(matrices.get(entity.parentId)) : identityMatrix, multiply(rotation, world))),
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
const movePoint = (p) => ({
|
|
70
|
+
x: center.x + delta.x + cos * (p.x - center.x) - sin * (p.y - center.y),
|
|
71
|
+
y: center.y + delta.y + sin * (p.x - center.x) + cos * (p.y - center.y),
|
|
72
|
+
});
|
|
73
|
+
const result = {
|
|
74
|
+
...doc,
|
|
75
|
+
collections: doc.collections.map(moveDrawable),
|
|
76
|
+
seatingGroups: doc.seatingGroups.map(moveDrawable),
|
|
77
|
+
areas: doc.areas.map(moveDrawable),
|
|
78
|
+
decorations: doc.decorations.map(moveDrawable),
|
|
79
|
+
sections: doc.sections.map((s) => sectionIds.has(s.id)
|
|
80
|
+
? {
|
|
81
|
+
...s,
|
|
82
|
+
...(s.outline
|
|
83
|
+
? {
|
|
84
|
+
outline: {
|
|
85
|
+
...s.outline,
|
|
86
|
+
outer: s.outline.outer.map(movePoint),
|
|
87
|
+
holes: s.outline.holes.map((h) => h.map(movePoint)),
|
|
88
|
+
},
|
|
89
|
+
}
|
|
90
|
+
: {}),
|
|
91
|
+
...(s.labelPlacement
|
|
92
|
+
? {
|
|
93
|
+
labelPlacement: {
|
|
94
|
+
...s.labelPlacement,
|
|
95
|
+
positionM: movePoint(s.labelPlacement.positionM),
|
|
96
|
+
rotationDeg: normalizeAngle(s.labelPlacement.rotationDeg + angle),
|
|
97
|
+
},
|
|
98
|
+
}
|
|
99
|
+
: {}),
|
|
100
|
+
}
|
|
101
|
+
: s),
|
|
102
|
+
};
|
|
103
|
+
const catalog = documentCatalog(doc);
|
|
104
|
+
const physical = new Set([...targets].flatMap((id) => {
|
|
105
|
+
if (catalog.seats.has(id))
|
|
106
|
+
return [id];
|
|
107
|
+
const group = catalog.rows.get(id);
|
|
108
|
+
return group && (group.kind === SeatingKind.Straight || group.kind === SeatingKind.Curved)
|
|
109
|
+
? (group.rows.find((row) => row.id === id)?.seats.map((seat) => seat.id) ?? [])
|
|
110
|
+
: [];
|
|
111
|
+
})), affectedGroups = new Set([...physical].map((id) => catalog.seats.get(id).group.id));
|
|
112
|
+
if (!physical.size)
|
|
113
|
+
return result;
|
|
114
|
+
return {
|
|
115
|
+
...result,
|
|
116
|
+
seatingGroups: result.seatingGroups.map((group) => {
|
|
117
|
+
if (!affectedGroups.has(group.id))
|
|
118
|
+
return group;
|
|
119
|
+
const m = matrices.get(group.id);
|
|
120
|
+
const movedRowSeats = new Set();
|
|
121
|
+
const movedRows = new Map();
|
|
122
|
+
if (group.kind === SeatingKind.Straight || group.kind === SeatingKind.Curved) {
|
|
123
|
+
for (const [index, row] of group.rows.entries()) {
|
|
124
|
+
if (!targets.has(row.id) || (angle !== 0 && !row.layout))
|
|
125
|
+
continue;
|
|
126
|
+
for (const slot of row.seats)
|
|
127
|
+
movedRowSeats.add(slot.id);
|
|
128
|
+
if (angle === 0) {
|
|
129
|
+
const offset = row.offsetM ?? { x: 0, y: 0 };
|
|
130
|
+
const origin = project(inverse(m), project(rotation, project(m, offset)));
|
|
131
|
+
movedRows.set(row.id, { ...row, offsetM: origin });
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
const offset = rowPlacementOffset(group, index, row.offsetM);
|
|
135
|
+
const layout = row.layout;
|
|
136
|
+
const origin = project(inverse(m), project(rotation, project(m, {
|
|
137
|
+
x: layout.originM.x + offset.x,
|
|
138
|
+
y: layout.originM.y + offset.y,
|
|
139
|
+
})));
|
|
140
|
+
const localRotation = multiply(inverse(m), multiply(rotation, m));
|
|
141
|
+
const rotateOffset = (point) => ({
|
|
142
|
+
x: localRotation.a * point.x + localRotation.c * point.y,
|
|
143
|
+
y: localRotation.b * point.x + localRotation.d * point.y,
|
|
144
|
+
});
|
|
145
|
+
movedRows.set(row.id, {
|
|
146
|
+
...row,
|
|
147
|
+
layout: {
|
|
148
|
+
...layout,
|
|
149
|
+
originM: { x: origin.x - offset.x, y: origin.y - offset.y },
|
|
150
|
+
rotationDeg: normalizeAngle(layout.rotationDeg + angle * (m.a * m.d - m.b * m.c < 0 ? -1 : 1)),
|
|
151
|
+
},
|
|
152
|
+
seats: row.seats.map((slot) => slot.override?.offsetM
|
|
153
|
+
? {
|
|
154
|
+
...slot,
|
|
155
|
+
override: {
|
|
156
|
+
...slot.override,
|
|
157
|
+
offsetM: rotateOffset(slot.override.offsetM),
|
|
158
|
+
},
|
|
159
|
+
}
|
|
160
|
+
: slot),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const movedSeats = mapSeats(group, (slot) => {
|
|
165
|
+
if (!physical.has(slot.id) || movedRowSeats.has(slot.id))
|
|
166
|
+
return slot;
|
|
167
|
+
const seat = catalog.seats.get(slot.id).seat, world = project(m, seat.position), local = project(inverse(m), project(rotation, world));
|
|
168
|
+
return {
|
|
169
|
+
...slot,
|
|
170
|
+
override: {
|
|
171
|
+
...slot.override,
|
|
172
|
+
offsetM: {
|
|
173
|
+
x: (slot.override?.offsetM?.x ?? 0) + local.x - seat.position.x,
|
|
174
|
+
y: (slot.override?.offsetM?.y ?? 0) + local.y - seat.position.y,
|
|
175
|
+
},
|
|
176
|
+
rotationDeltaDeg: normalizeAngle((slot.override?.rotationDeltaDeg ?? 0) + angle * (m.a * m.d - m.b * m.c < 0 ? -1 : 1)),
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
});
|
|
180
|
+
if (!movedRows.size || (movedSeats.kind !== SeatingKind.Straight && movedSeats.kind !== SeatingKind.Curved))
|
|
181
|
+
return movedSeats;
|
|
182
|
+
return {
|
|
183
|
+
...movedSeats,
|
|
184
|
+
rows: movedSeats.rows.map((row) => movedRows.get(row.id) ?? row),
|
|
185
|
+
};
|
|
186
|
+
}),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
export function mapSeats(group, change) {
|
|
190
|
+
if (group.kind === SeatingKind.Straight || group.kind === SeatingKind.Curved)
|
|
191
|
+
return {
|
|
192
|
+
...group,
|
|
193
|
+
rows: group.rows.map((r) => ({ ...r, seats: r.seats.map(change) })),
|
|
194
|
+
};
|
|
195
|
+
if (group.kind === SeatingKind.Round)
|
|
196
|
+
return { ...group, chairs: group.chairs.map(change) };
|
|
197
|
+
return {
|
|
198
|
+
...group,
|
|
199
|
+
chairsBySide: {
|
|
200
|
+
top: group.chairsBySide.top.map(change),
|
|
201
|
+
right: group.chairsBySide.right.map(change),
|
|
202
|
+
bottom: group.chairsBySide.bottom.map(change),
|
|
203
|
+
left: group.chairsBySide.left.map(change),
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PointM, PolygonM } from "../physical-document.interface.js";
|
|
2
|
+
import { type PolygonCornerFillet } from "./polygon-curves.interface.js";
|
|
3
|
+
export type { PolygonCornerFillet } from "./polygon-curves.interface.js";
|
|
4
|
+
export declare const PolygonVertexLimit = 10000;
|
|
5
|
+
export declare const PolygonCornerRadiusMaxM = 2.75;
|
|
6
|
+
/** Quadratic control lies at the chord midpoint plus its signed, dimensionless normal offset. */
|
|
7
|
+
export declare function sideCurvePoint(start: PointM, end: PointM, curvature: number, fraction: number): PointM;
|
|
8
|
+
/** Uniform quadratic subdivision bounds the chord deviation by the existing 1mm curve tolerance. */
|
|
9
|
+
export declare function sideCurveSegments(start: PointM, end: PointM, curvature: number): number;
|
|
10
|
+
/** Tangent fillets on the authored outer ring, shared by rendering and section fitting. */
|
|
11
|
+
export declare function polygonCornerFillets(polygon: PolygonM): readonly (PolygonCornerFillet | null)[];
|
|
12
|
+
/** A rounding input takes effect when at least one authored corner can use it. */
|
|
13
|
+
export declare function effectiveCornerRounding(polygon: PolygonM): number;
|
|
14
|
+
export declare function polygonContourVertexCount(polygon: PolygonM): number;
|
|
15
|
+
export declare function polygonCornerSamples(corner: PolygonCornerFillet, segments?: number): PointM[];
|
|
16
|
+
/** Authored corners remain stable; all geometric consumers share one derived, immutable contour. */
|
|
17
|
+
export declare function polygonContour(polygon: PolygonM): PolygonM;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PointM } from "../physical-document.interface.js";
|
|
2
|
+
export declare enum PolygonCornerKind {
|
|
3
|
+
Circular = "circular",
|
|
4
|
+
Cubic = "cubic"
|
|
5
|
+
}
|
|
6
|
+
type PolygonCornerSpan = {
|
|
7
|
+
before: PointM;
|
|
8
|
+
after: PointM;
|
|
9
|
+
segments: number;
|
|
10
|
+
};
|
|
11
|
+
export type PolygonCornerFillet = PolygonCornerSpan & ({
|
|
12
|
+
kind: PolygonCornerKind.Circular;
|
|
13
|
+
center: PointM;
|
|
14
|
+
radius: number;
|
|
15
|
+
sweep: number;
|
|
16
|
+
} | {
|
|
17
|
+
kind: PolygonCornerKind.Cubic;
|
|
18
|
+
control1: PointM;
|
|
19
|
+
control2: PointM;
|
|
20
|
+
});
|
|
21
|
+
export {};
|