@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.
Files changed (109) hide show
  1. package/dist/arc-fan-rebuild.d.ts +13 -0
  2. package/dist/arc-fan-rebuild.js +163 -0
  3. package/dist/arc-fan.d.ts +27 -0
  4. package/dist/arc-fan.interface.d.ts +83 -0
  5. package/dist/arc-fan.interface.js +30 -0
  6. package/dist/arc-fan.js +182 -0
  7. package/dist/catalog.d.ts +10 -3
  8. package/dist/catalog.js +66 -10
  9. package/dist/categories.d.ts +27 -0
  10. package/dist/categories.js +217 -0
  11. package/dist/editor-state.d.ts +4 -1
  12. package/dist/editor-state.js +61 -31
  13. package/dist/floors.d.ts +22 -0
  14. package/dist/floors.js +77 -0
  15. package/dist/geometry/boundary.d.ts +1 -1
  16. package/dist/geometry/boundary.js +16 -12
  17. package/dist/geometry/curve-warnings.d.ts +1 -1
  18. package/dist/geometry/curve-warnings.js +3 -5
  19. package/dist/geometry/decoration-bounds.d.ts +4 -0
  20. package/dist/geometry/decoration-bounds.js +42 -0
  21. package/dist/geometry/ellipse.js +4 -12
  22. package/dist/geometry/geometry.d.ts +12 -3
  23. package/dist/geometry/geometry.js +37 -28
  24. package/dist/geometry/layout-transform.d.ts +10 -0
  25. package/dist/geometry/layout-transform.interface.d.ts +6 -0
  26. package/dist/geometry/layout-transform.interface.js +1 -0
  27. package/dist/geometry/layout-transform.js +206 -0
  28. package/dist/geometry/polygon-curves.d.ts +17 -0
  29. package/dist/geometry/polygon-curves.interface.d.ts +21 -0
  30. package/dist/geometry/polygon-curves.interface.js +5 -0
  31. package/dist/geometry/polygon-curves.js +169 -0
  32. package/dist/geometry/primitives.d.ts +1 -1
  33. package/dist/geometry/primitives.js +2 -3
  34. package/dist/geometry/seat-shape.d.ts +24 -0
  35. package/dist/geometry/seat-shape.js +101 -0
  36. package/dist/geometry/seating-layout.d.ts +20 -3
  37. package/dist/geometry/seating-layout.js +113 -19
  38. package/dist/geometry/units.d.ts +8 -0
  39. package/dist/geometry/units.js +13 -0
  40. package/dist/geometry/venue-outline.d.ts +4 -18
  41. package/dist/geometry/venue-outline.interface.d.ts +23 -0
  42. package/dist/geometry/venue-outline.interface.js +7 -0
  43. package/dist/geometry/venue-outline.js +107 -49
  44. package/dist/identity.d.ts +3 -1
  45. package/dist/identity.js +32 -9
  46. package/dist/issues.d.ts +15 -2
  47. package/dist/issues.js +16 -6
  48. package/dist/labels.d.ts +12 -1
  49. package/dist/labels.js +76 -11
  50. package/dist/layers.d.ts +26 -0
  51. package/dist/layers.js +86 -0
  52. package/dist/media.d.ts +27 -0
  53. package/dist/media.js +89 -0
  54. package/dist/physical-document.interface.d.ts +592 -0
  55. package/dist/physical-document.interface.js +179 -0
  56. package/dist/preview.d.ts +1 -1
  57. package/dist/preview.js +70 -25
  58. package/dist/reference.js +1 -1
  59. package/dist/row-segments.d.ts +30 -0
  60. package/dist/row-segments.js +113 -0
  61. package/dist/schema.d.ts +1578 -68
  62. package/dist/schema.js +467 -98
  63. package/dist/seat-proximity.d.ts +4 -0
  64. package/dist/seat-proximity.js +119 -0
  65. package/dist/section-elevation.d.ts +5 -0
  66. package/dist/section-elevation.interface.d.ts +26 -0
  67. package/dist/section-elevation.interface.js +8 -0
  68. package/dist/section-elevation.js +53 -0
  69. package/dist/section-fill-rebuild.d.ts +10 -0
  70. package/dist/section-fill-rebuild.js +64 -0
  71. package/dist/section-fill.d.ts +84 -0
  72. package/dist/section-fill.interface.d.ts +94 -0
  73. package/dist/section-fill.interface.js +22 -0
  74. package/dist/section-fill.js +306 -0
  75. package/dist/section-growth.d.ts +11 -0
  76. package/dist/section-growth.interface.d.ts +12 -0
  77. package/dist/section-growth.interface.js +1 -0
  78. package/dist/section-growth.js +198 -0
  79. package/dist/section-layout.d.ts +95 -0
  80. package/dist/section-layout.interface.d.ts +8 -0
  81. package/dist/section-layout.interface.js +5 -0
  82. package/dist/section-layout.js +70 -0
  83. package/dist/section-outline-refit.d.ts +8 -0
  84. package/dist/section-outline-refit.js +246 -0
  85. package/dist/section-refit.d.ts +22 -0
  86. package/dist/section-refit.interface.d.ts +49 -0
  87. package/dist/section-refit.interface.js +6 -0
  88. package/dist/section-refit.js +179 -0
  89. package/dist/section-scale.d.ts +2 -0
  90. package/dist/section-scale.js +128 -0
  91. package/dist/sections.d.ts +23 -0
  92. package/dist/sections.js +144 -0
  93. package/dist/selling.d.ts +34 -0
  94. package/dist/selling.js +148 -0
  95. package/dist/spacing-repairs.d.ts +31 -0
  96. package/dist/spacing-repairs.js +168 -0
  97. package/dist/table-layout.d.ts +29 -0
  98. package/dist/table-layout.js +134 -0
  99. package/dist/validation.d.ts +7 -2
  100. package/dist/validation.interface.d.ts +20 -0
  101. package/dist/validation.interface.js +9 -0
  102. package/dist/validation.js +227 -78
  103. package/dist/wayfinding.d.ts +10 -0
  104. package/dist/wayfinding.interface.d.ts +52 -0
  105. package/dist/wayfinding.interface.js +28 -0
  106. package/dist/wayfinding.js +63 -0
  107. package/package.json +109 -4
  108. package/dist/types.d.ts +0 -313
  109. package/dist/types.js +0 -91
@@ -0,0 +1,169 @@
1
+ import { CurveToleranceM } from "./ellipse.js";
2
+ import { PolygonCornerKind } from "./polygon-curves.interface.js";
3
+ export const PolygonVertexLimit = 10_000;
4
+ export const PolygonCornerRadiusMaxM = 2.75;
5
+ const RoundingTravelDeg = 180;
6
+ const RoundingStartDeg = 48;
7
+ const CornerTurnWeight = 1.1;
8
+ const CornerTangentWeight = 0.5523;
9
+ const fillets = new WeakMap();
10
+ const contours = new WeakMap();
11
+ /** Quadratic control lies at the chord midpoint plus its signed, dimensionless normal offset. */
12
+ export function sideCurvePoint(start, end, curvature, fraction) {
13
+ const x = end.x - start.x, y = end.y - start.y;
14
+ const bow = (2 * fraction * (1 - fraction) * curvature) / 100;
15
+ return { x: start.x + fraction * x - bow * y, y: start.y + fraction * y + bow * x };
16
+ }
17
+ /** Uniform quadratic subdivision bounds the chord deviation by the existing 1mm curve tolerance. */
18
+ export function sideCurveSegments(start, end, curvature) {
19
+ const sagitta = (Math.abs(curvature) * Math.hypot(end.x - start.x, end.y - start.y)) / 200;
20
+ return Math.max(1, Math.ceil(Math.sqrt(sagitta / CurveToleranceM)));
21
+ }
22
+ function cornerFillet(previous, point, next, strength, radiusM) {
23
+ const incomingX = point.x - previous.x;
24
+ const incomingY = point.y - previous.y;
25
+ const outgoingX = next.x - point.x;
26
+ const outgoingY = next.y - point.y;
27
+ const incomingLength = Math.hypot(incomingX, incomingY);
28
+ const outgoingLength = Math.hypot(outgoingX, outgoingY);
29
+ const sweep = Math.atan2(incomingX * outgoingY - incomingY * outgoingX, incomingX * outgoingX + incomingY * outgoingY);
30
+ if (!incomingLength || !outgoingLength || Math.abs(sweep) < 1e-9)
31
+ return null;
32
+ const halfTurn = Math.tan(Math.abs(sweep) / 2);
33
+ const halfSide = Math.min(incomingLength, outgoingLength) / 2;
34
+ const turnDeg = (Math.abs(sweep) * 180) / Math.PI;
35
+ const limitDeg = (RoundingTravelDeg * strength - RoundingStartDeg) / CornerTurnWeight;
36
+ const weight = limitDeg > turnDeg ? 1 - turnDeg / limitDeg : 0;
37
+ const trim = radiusM ? Math.min(halfSide, radiusM * halfTurn) : halfSide * strength * weight ** 2 * (3 - 2 * weight);
38
+ if (!trim)
39
+ return null;
40
+ const before = { x: point.x - (incomingX * trim) / incomingLength, y: point.y - (incomingY * trim) / incomingLength };
41
+ const after = { x: point.x + (outgoingX * trim) / outgoingLength, y: point.y + (outgoingY * trim) / outgoingLength };
42
+ if (!radiusM) {
43
+ const control1 = {
44
+ x: before.x + (point.x - before.x) * CornerTangentWeight,
45
+ y: before.y + (point.y - before.y) * CornerTangentWeight,
46
+ };
47
+ const control2 = {
48
+ x: after.x + (point.x - after.x) * CornerTangentWeight,
49
+ y: after.y + (point.y - after.y) * CornerTangentWeight,
50
+ };
51
+ // The second derivative bounds the deviation from each straight interpolation segment.
52
+ const curvature = Math.max(Math.hypot(before.x - 2 * control1.x + control2.x, before.y - 2 * control1.y + control2.y), Math.hypot(control1.x - 2 * control2.x + after.x, control1.y - 2 * control2.y + after.y));
53
+ const segments = Math.max(1, Math.ceil(Math.sqrt((3 * curvature) / (4 * CurveToleranceM))));
54
+ return { kind: PolygonCornerKind.Cubic, before, after, control1, control2, segments };
55
+ }
56
+ const radius = trim / halfTurn;
57
+ const signedRadius = Math.sign(sweep) * radius;
58
+ const center = {
59
+ x: before.x - (incomingY * signedRadius) / incomingLength,
60
+ y: before.y + (incomingX * signedRadius) / incomingLength,
61
+ };
62
+ const maxStep = 4 * Math.asin(Math.sqrt(Math.min(1, CurveToleranceM / (2 * radius))));
63
+ return {
64
+ kind: PolygonCornerKind.Circular,
65
+ before,
66
+ after,
67
+ center,
68
+ radius,
69
+ sweep,
70
+ segments: Math.max(1, Math.ceil(Math.abs(sweep) / maxStep)),
71
+ };
72
+ }
73
+ /** Tangent fillets on the authored outer ring, shared by rendering and section fitting. */
74
+ export function polygonCornerFillets(polygon) {
75
+ const cached = fillets.get(polygon);
76
+ if (cached)
77
+ return cached;
78
+ const strength = (polygon.cornerRounding ?? 0) / 100;
79
+ const radiusM = polygon.cornerRadiusM ?? 0;
80
+ const { outer } = polygon;
81
+ const corners = strength || radiusM
82
+ ? outer.map((point, index) => cornerFillet(outer[(index + outer.length - 1) % outer.length], point, outer[(index + 1) % outer.length], strength, radiusM))
83
+ : [];
84
+ fillets.set(polygon, corners);
85
+ return corners;
86
+ }
87
+ /** A rounding input takes effect when at least one authored corner can use it. */
88
+ export function effectiveCornerRounding(polygon) {
89
+ return polygon.cornerRounding && polygonCornerFillets(polygon).some(Boolean) ? polygon.cornerRounding : 0;
90
+ }
91
+ function contourSpanSegments(polygon, corners, side) {
92
+ const next = (side + 1) % polygon.outer.length;
93
+ const start = polygon.outer[side];
94
+ const end = polygon.outer[next];
95
+ const curvature = polygon.edgeCurvature?.[side] ?? 0;
96
+ const from = corners[side]?.after;
97
+ const to = corners[next]?.before;
98
+ if (!curvature && from && to && Math.hypot(to.x - from.x, to.y - from.y) < 1e-9)
99
+ return 0;
100
+ return sideCurveSegments(start, end, curvature);
101
+ }
102
+ export function polygonContourVertexCount(polygon) {
103
+ const { outer, edgeCurvature } = polygon;
104
+ if (!polygon.cornerRounding && !polygon.cornerRadiusM && !edgeCurvature)
105
+ return outer.length;
106
+ const corners = polygonCornerFillets(polygon);
107
+ return outer.reduce((total, _, side) => total + (corners[side]?.segments ?? 0) + contourSpanSegments(polygon, corners, side), 0);
108
+ }
109
+ export function polygonCornerSamples(corner, segments = corner.segments) {
110
+ const { before, after } = corner;
111
+ if (corner.kind === PolygonCornerKind.Circular) {
112
+ const { center, radius, sweep } = corner;
113
+ const startAngle = Math.atan2(before.y - center.y, before.x - center.x);
114
+ return Array.from({ length: segments }, (_, index) => {
115
+ if (index === 0)
116
+ return before;
117
+ const angle = startAngle + (sweep * index) / segments;
118
+ return { x: center.x + radius * Math.cos(angle), y: center.y + radius * Math.sin(angle) };
119
+ });
120
+ }
121
+ const { control1, control2 } = corner;
122
+ return Array.from({ length: segments }, (_, index) => {
123
+ const t = index / segments;
124
+ const u = 1 - t;
125
+ const first = 3 * u ** 2 * t;
126
+ const second = 3 * u * t ** 2;
127
+ return {
128
+ x: u ** 3 * before.x + first * control1.x + second * control2.x + t ** 3 * after.x,
129
+ y: u ** 3 * before.y + first * control1.y + second * control2.y + t ** 3 * after.y,
130
+ };
131
+ });
132
+ }
133
+ /** Authored corners remain stable; all geometric consumers share one derived, immutable contour. */
134
+ export function polygonContour(polygon) {
135
+ const curved = polygon.edgeCurvature?.some((value) => value !== 0);
136
+ if (!polygon.cornerRounding && !polygon.cornerRadiusM && !curved)
137
+ return polygon;
138
+ const cached = contours.get(polygon);
139
+ if (cached)
140
+ return cached;
141
+ const corners = polygonCornerFillets(polygon);
142
+ if (!curved && !corners.some(Boolean))
143
+ return polygon;
144
+ if (polygonContourVertexCount(polygon) > PolygonVertexLimit)
145
+ throw new RangeError("The boundary exceeds the 1mm / 10,000-vertex curve limit.");
146
+ const outer = polygon.outer.flatMap((start, side) => {
147
+ const next = (side + 1) % polygon.outer.length;
148
+ const end = polygon.outer[next];
149
+ const corner = corners[side];
150
+ const trimmedStart = corner?.after ?? start;
151
+ const trimmedEnd = corners[next]?.before ?? end;
152
+ const arc = corner ? polygonCornerSamples(corner) : [];
153
+ const curvature = polygon.edgeCurvature?.[side] ?? 0;
154
+ const segments = contourSpanSegments(polygon, corners, side);
155
+ const span = Array.from({ length: segments }, (_, index) => {
156
+ const t = index / segments;
157
+ const point = sideCurvePoint(start, end, curvature, t);
158
+ // Trim the span without changing the authored side's bow vector.
159
+ return {
160
+ x: point.x + (1 - t) * (trimmedStart.x - start.x) + t * (trimmedEnd.x - end.x),
161
+ y: point.y + (1 - t) * (trimmedStart.y - start.y) + t * (trimmedEnd.y - end.y),
162
+ };
163
+ });
164
+ return [...arc, ...span];
165
+ });
166
+ const contour = { outer, holes: polygon.holes };
167
+ contours.set(polygon, contour);
168
+ return contour;
169
+ }
@@ -1,4 +1,4 @@
1
- import type { PointM } from "../types.js";
1
+ import type { PointM } from "../physical-document.interface.js";
2
2
  export type Bounds = {
3
3
  minX: number;
4
4
  minY: number;
@@ -8,7 +8,7 @@ export function extend(bounds, p) {
8
8
  bounds.maxY = Math.max(bounds.maxY, p.y);
9
9
  }
10
10
  export function intersects(a, b) {
11
- return (a.minX <= b.maxX && a.maxX >= b.minX && a.minY <= b.maxY && a.maxY >= b.minY);
11
+ return a.minX <= b.maxX && a.maxX >= b.minX && a.minY <= b.maxY && a.maxY >= b.minY;
12
12
  }
13
13
  export function pointsBounds(points) {
14
14
  const b = emptyBounds();
@@ -27,8 +27,7 @@ export function containsPoint(ring, p) {
27
27
  p.y >= Math.min(a.y, b.y) - 1e-6 &&
28
28
  p.y <= Math.max(a.y, b.y) + 1e-6)
29
29
  return true;
30
- if (a.y > p.y !== b.y > p.y &&
31
- p.x < ((b.x - a.x) * (p.y - a.y)) / (b.y - a.y) + a.x)
30
+ if (a.y > p.y !== b.y > p.y && p.x < ((b.x - a.x) * (p.y - a.y)) / (b.y - a.y) + a.x)
32
31
  inside = !inside;
33
32
  }
34
33
  return inside;
@@ -0,0 +1,24 @@
1
+ import { SeatShape } from "../physical-document.interface.js";
2
+ export declare enum SeatShapePartKind {
3
+ Rectangle = "rectangle",
4
+ Polygon = "polygon"
5
+ }
6
+ export type SeatShapePart = {
7
+ kind: SeatShapePartKind.Rectangle;
8
+ x: number;
9
+ y: number;
10
+ width: number;
11
+ height: number;
12
+ radius: number;
13
+ } | {
14
+ kind: SeatShapePartKind.Polygon;
15
+ points: readonly number[];
16
+ };
17
+ export declare function seatShapeParts(shape: SeatShape): readonly SeatShapePart[];
18
+ /**
19
+ * @method seatShapeContour
20
+ * @description Reuses bounded normalized contours so small furniture corners stay smooth after scaling.
21
+ * @param {SeatShapePart} part Shared normalized furniture primitive.
22
+ * @returns {readonly number[]} Cached polygon coordinates for the primitive.
23
+ */
24
+ export declare function seatShapeContour(part: SeatShapePart): readonly number[];
@@ -0,0 +1,101 @@
1
+ import { SeatShape } from "../physical-document.interface.js";
2
+ export var SeatShapePartKind;
3
+ (function (SeatShapePartKind) {
4
+ SeatShapePartKind["Rectangle"] = "rectangle";
5
+ SeatShapePartKind["Polygon"] = "polygon";
6
+ })(SeatShapePartKind || (SeatShapePartKind = {}));
7
+ const rectangle = (x, y, width, height, radius = 0) => ({
8
+ kind: SeatShapePartKind.Rectangle,
9
+ x,
10
+ y,
11
+ width,
12
+ height,
13
+ radius,
14
+ });
15
+ const polygon = (...points) => ({
16
+ kind: SeatShapePartKind.Polygon,
17
+ points,
18
+ });
19
+ // Normalized to the existing physical seat footprint. Category appearance never
20
+ // changes positions, pitch, inventory identity or the personal geometry recipe.
21
+ const furniture = {
22
+ [SeatShape.Theatre]: [
23
+ rectangle(-0.3, -0.42, 0.6, 0.52, 0.06),
24
+ rectangle(-0.42, 0, 0.84, 0.22, 0.06),
25
+ rectangle(-0.42, 0.12, 0.12, 0.3, 0.04),
26
+ rectangle(0.3, 0.12, 0.12, 0.3, 0.04),
27
+ ],
28
+ [SeatShape.Dining]: [
29
+ polygon(-0.23, -0.42, 0.23, -0.42, 0.19, -0.055, -0.19, -0.055),
30
+ rectangle(-0.315, -0.055, 0.63, 0.18, 0.025),
31
+ polygon(-0.19, 0.08, -0.08, 0.08, -0.19, 0.42, -0.3, 0.42),
32
+ polygon(0.08, 0.08, 0.19, 0.08, 0.3, 0.42, 0.19, 0.42),
33
+ ],
34
+ [SeatShape.Folding]: [
35
+ polygon(-0.3, -0.42, 0.3, -0.42, 0.25, -0.2, -0.25, -0.2),
36
+ polygon(-0.315, -0.14, 0.315, -0.14, 0.26, 0.02, -0.26, 0.02),
37
+ polygon(-0.2, 0.0, -0.1, -0.02, 0.2, 0.42, 0.08, 0.42),
38
+ polygon(0.1, -0.02, 0.2, 0.0, -0.08, 0.42, -0.2, 0.42),
39
+ ],
40
+ [SeatShape.Armchair]: [
41
+ rectangle(-0.34, -0.4, 0.68, 0.46, 0.08),
42
+ rectangle(-0.42, -0.08, 0.14, 0.42, 0.07),
43
+ rectangle(0.28, -0.08, 0.14, 0.42, 0.07),
44
+ rectangle(-0.42, 0.08, 0.84, 0.34, 0.07),
45
+ ],
46
+ [SeatShape.Recliner]: [
47
+ polygon(-0.18, -0.42, 0.18, -0.42, 0.26, 0.1, -0.26, 0.1),
48
+ rectangle(-0.39, -0.12, 0.15, 0.36, 0.07),
49
+ rectangle(0.24, -0.12, 0.15, 0.36, 0.07),
50
+ rectangle(-0.26, 0.04, 0.52, 0.1, 0.02),
51
+ polygon(-0.21, 0.22, 0.21, 0.22, 0.3, 0.42, -0.3, 0.42),
52
+ ],
53
+ [SeatShape.Stool]: [
54
+ rectangle(-0.42, -0.42, 0.84, 0.57, 0.1),
55
+ polygon(-0.18, 0.1, -0.04, 0.1, -0.2, 0.42, -0.36, 0.42),
56
+ polygon(0.04, 0.1, 0.18, 0.1, 0.36, 0.42, 0.2, 0.42),
57
+ ],
58
+ [SeatShape.Bench]: [
59
+ rectangle(-0.42, -0.4, 0.84, 0.21, 0.035),
60
+ rectangle(-0.42, -0.12, 0.84, 0.35, 0.025),
61
+ rectangle(-0.23, 0.17, 0.09, 0.25, 0.015),
62
+ rectangle(0.14, 0.17, 0.09, 0.25, 0.015),
63
+ ],
64
+ };
65
+ export function seatShapeParts(shape) {
66
+ return shape === SeatShape.Circle ? [] : furniture[shape];
67
+ }
68
+ const contours = new WeakMap();
69
+ /**
70
+ * @method seatShapeContour
71
+ * @description Reuses bounded normalized contours so small furniture corners stay smooth after scaling.
72
+ * @param {SeatShapePart} part Shared normalized furniture primitive.
73
+ * @returns {readonly number[]} Cached polygon coordinates for the primitive.
74
+ */
75
+ export function seatShapeContour(part) {
76
+ if (part.kind === SeatShapePartKind.Polygon) {
77
+ return part.points;
78
+ }
79
+ const cached = contours.get(part);
80
+ if (cached) {
81
+ return cached;
82
+ }
83
+ const { x, y, width, height } = part;
84
+ const radius = Math.min(part.radius, width / 2, height / 2);
85
+ const points = [];
86
+ const centers = [
87
+ [x + width - radius, y + radius],
88
+ [x + width - radius, y + height - radius],
89
+ [x + radius, y + height - radius],
90
+ [x + radius, y + radius],
91
+ ];
92
+ for (let corner = 0; corner < 4; corner++) {
93
+ const center = centers[corner];
94
+ for (let step = 0; step <= 8; step++) {
95
+ const angle = ((corner - 1) * Math.PI) / 2 + (step * Math.PI) / 16;
96
+ points.push(center[0] + radius * Math.cos(angle), center[1] + radius * Math.sin(angle));
97
+ }
98
+ }
99
+ contours.set(part, points);
100
+ return points;
101
+ }
@@ -1,4 +1,4 @@
1
- import { SeatingKind, type StraightRows, type CurvedRows, type RoundTable, type RectangularTable, type PointM } from "../types.js";
1
+ import { SeatingKind, type StraightRows, type CurvedRows, type RoundTable, type RectangularTable, type PointM, type RowLayout, type LabelSequence } from "../physical-document.interface.js";
2
2
  export type RowsGeometry = Pick<StraightRows, "kind" | "recipe"> | Pick<CurvedRows, "kind" | "recipe">;
3
3
  export declare enum TableSide {
4
4
  Top = "top",
@@ -6,17 +6,28 @@ export declare enum TableSide {
6
6
  Bottom = "bottom",
7
7
  Left = "left"
8
8
  }
9
+ export declare function rowStaggerOffset(recipe: StraightRows["recipe"], index: number): number;
10
+ /** A lane shift is derived from the recipe. The row offset remains an independent edit. */
11
+ export declare function rowPlacementOffset(group: RowsGeometry, index: number, offset?: PointM): PointM;
9
12
  export type SeatGeometry = {
10
13
  position: PointM;
11
14
  rotationDeg: number;
12
15
  };
13
- export declare function rowSeatGeometry(group: RowsGeometry, row: number, seat: number, count: number, longestRow?: number): SeatGeometry;
16
+ export declare function rowSeatGeometry(group: RowsGeometry, row: number, seat: number, count: number, longestRow?: number, layout?: RowLayout): SeatGeometry;
17
+ /** The row axis is independent of its chair-facing offset. */
18
+ export declare function rowLayoutAxisRotation(layout: RowLayout): number;
19
+ export declare function setRowLayoutAxisRotation(layout: RowLayout, rotationDeg: number): RowLayout;
20
+ /** Curve edits preserve the row axis and its independent chair-facing offset. */
21
+ export declare function setRowLayoutCurve(layout: RowLayout, curveDeg: number): RowLayout;
22
+ /** Resolves inherited geometry once when a row becomes independently editable. */
23
+ export declare function resolveRowLayout(group: StraightRows | CurvedRows, rowIndex: number): RowLayout | null;
14
24
  export declare function roundChairGeometry(recipe: RoundTable["recipe"], chairHeightM: number, seat: number, count: number): SeatGeometry;
15
25
  export declare function rectangularChairGeometry(recipe: RectangularTable["recipe"], chairHeightM: number, side: TableSide, seat: number, count: number): SeatGeometry;
16
26
  export type SeatingPreview = (RowsGeometry & {
17
27
  rows: number;
18
28
  seatsPerRow: number;
19
29
  rowCounts?: readonly number[];
30
+ rowLayouts?: readonly (RowLayout | undefined)[];
20
31
  seatSizeM: number;
21
32
  }) | {
22
33
  kind: SeatingKind.Round;
@@ -30,7 +41,13 @@ export type SeatingPreview = (RowsGeometry & {
30
41
  seatSizeM: number;
31
42
  };
32
43
  export type PreviewNumbering = {
33
- rowStart: number;
44
+ rowSequence: LabelSequence;
45
+ logicalRow?: {
46
+ label: string;
47
+ sequence: LabelSequence;
48
+ offset: number;
49
+ total: number;
50
+ };
34
51
  tableLabel: string;
35
52
  seatFontSizeM: number;
36
53
  rowFontSizeM: number;
@@ -1,4 +1,4 @@
1
- import { CurveMode, RowAlignment, SeatingKind, } from "../types.js";
1
+ import { CurveMode, TableChairDistribution, RowAlignment, RowStagger, SeatingKind, } from "../physical-document.interface.js";
2
2
  import { ellipseAngleAtDistance } from "./ellipse.js";
3
3
  export var TableSide;
4
4
  (function (TableSide) {
@@ -7,7 +7,33 @@ export var TableSide;
7
7
  TableSide["Bottom"] = "bottom";
8
8
  TableSide["Left"] = "left";
9
9
  })(TableSide || (TableSide = {}));
10
- export function rowSeatGeometry(group, row, seat, count, longestRow = count) {
10
+ export function rowStaggerOffset(recipe, index) {
11
+ const lane = index % 2 === 0 ? RowStagger.First : RowStagger.Second;
12
+ return recipe.stagger === lane ? recipe.seatPitchM / 2 : 0;
13
+ }
14
+ /** A lane shift is derived from the recipe. The row offset remains an independent edit. */
15
+ export function rowPlacementOffset(group, index, offset) {
16
+ return {
17
+ x: (offset?.x ?? 0) + (group.kind === SeatingKind.Straight ? rowStaggerOffset(group.recipe, index) : 0),
18
+ y: offset?.y ?? 0,
19
+ };
20
+ }
21
+ export function rowSeatGeometry(group, row, seat, count, longestRow = count, layout) {
22
+ if (layout) {
23
+ const halfStep = (layout.curveDeg * Math.PI) / (360 * Math.max(1, count - 1));
24
+ const halfAngle = seat * halfStep;
25
+ // The pitch is a straight-line gap between adjacent seat centres.
26
+ const chord = halfStep ? Math.sin(halfAngle) / Math.sin(halfStep) : seat;
27
+ const distance = layout.seatPitchM * chord;
28
+ const direction = (layout.rotationDeg * Math.PI) / 180 - halfAngle;
29
+ return {
30
+ position: {
31
+ x: layout.originM.x + distance * Math.cos(direction),
32
+ y: layout.originM.y + distance * Math.sin(direction),
33
+ },
34
+ rotationDeg: layout.rotationDeg - (halfAngle * 360) / Math.PI + (layout.seatRotationOffsetDeg ?? 0),
35
+ };
36
+ }
11
37
  if (group.kind === SeatingKind.Straight)
12
38
  return {
13
39
  position: {
@@ -24,30 +50,90 @@ export function rowSeatGeometry(group, row, seat, count, longestRow = count) {
24
50
  rotationDeg: 0,
25
51
  };
26
52
  const radius = group.recipe.innerRadiusM + row * group.recipe.rowPitchM;
27
- const horizontal = group.recipe.innerRadiusM * (group.recipe.axisRatio ?? 1) +
28
- row * group.recipe.rowPitchM;
53
+ const horizontal = group.recipe.innerRadiusM * (group.recipe.axisRatio ?? 1) + row * group.recipe.rowPitchM;
29
54
  const p = group.recipe.placement;
30
55
  const angle = p.kind === CurveMode.Pitch
31
56
  ? ellipseAngleAtDistance(horizontal, radius, (p.centerAngleDeg * Math.PI) / 180, (seat - (count - 1) / 2) * p.seatPitchM)
32
57
  : ((p.startAngleDeg +
33
58
  (count === 1
34
59
  ? p.sweepAngleDeg / 2
35
- : (p.sweepAngleDeg * seat) /
36
- (Math.abs(p.sweepAngleDeg) === 360 ? count : count - 1))) *
60
+ : (p.sweepAngleDeg * seat) / (Math.abs(p.sweepAngleDeg) === 360 ? count : count - 1))) *
37
61
  Math.PI) /
38
62
  180;
39
63
  return {
40
64
  position: { x: horizontal * Math.cos(angle), y: radius * Math.sin(angle) },
41
65
  rotationDeg: horizontal === radius
42
66
  ? (angle * 180) / Math.PI + 90
43
- : (Math.atan2(radius * Math.cos(angle), -horizontal * Math.sin(angle)) *
44
- 180) /
45
- Math.PI,
67
+ : (Math.atan2(radius * Math.cos(angle), -horizontal * Math.sin(angle)) * 180) / Math.PI,
68
+ };
69
+ }
70
+ function normalizeRowAngle(rotationDeg) {
71
+ return ((((rotationDeg + 180) % 360) + 360) % 360) - 180;
72
+ }
73
+ function rowCurveAxisOffset(curveDeg) {
74
+ return curveDeg < 0 ? 180 : 0;
75
+ }
76
+ /** The row axis is independent of its chair-facing offset. */
77
+ export function rowLayoutAxisRotation(layout) {
78
+ return layout.rotationDeg - rowCurveAxisOffset(layout.curveDeg);
79
+ }
80
+ export function setRowLayoutAxisRotation(layout, rotationDeg) {
81
+ const rotation = rotationDeg + rowCurveAxisOffset(layout.curveDeg);
82
+ return {
83
+ ...layout,
84
+ rotationDeg: normalizeRowAngle(rotation),
85
+ };
86
+ }
87
+ /** Curve edits preserve the row axis and its independent chair-facing offset. */
88
+ export function setRowLayoutCurve(layout, curveDeg) {
89
+ const axisRotation = rowLayoutAxisRotation(layout);
90
+ const facingOffset = layout.rotationDeg + (layout.seatRotationOffsetDeg ?? 0) - axisRotation;
91
+ return setRowLayoutAxisRotation({
92
+ ...layout,
93
+ curveDeg,
94
+ seatRotationOffsetDeg: normalizeRowAngle(facingOffset - rowCurveAxisOffset(curveDeg)),
95
+ }, axisRotation);
96
+ }
97
+ /** Resolves inherited geometry once when a row becomes independently editable. */
98
+ export function resolveRowLayout(group, rowIndex) {
99
+ const row = group.rows[rowIndex];
100
+ if (row.layout)
101
+ return row.layout;
102
+ if (group.kind === SeatingKind.Curved && (group.recipe.axisRatio ?? 1) !== 1)
103
+ return null;
104
+ const longest = group.rows.reduce((max, item) => Math.max(max, item.seats.length), 0);
105
+ const first = rowSeatGeometry(group, rowIndex, 0, row.seats.length, longest);
106
+ if (group.kind === SeatingKind.Straight)
107
+ return {
108
+ originM: first.position,
109
+ seatPitchM: group.recipe.seatPitchM,
110
+ curveDeg: 0,
111
+ rotationDeg: normalizeRowAngle(first.rotationDeg),
112
+ };
113
+ const radius = group.recipe.innerRadiusM + rowIndex * group.recipe.rowPitchM;
114
+ const placement = group.recipe.placement;
115
+ const intervals = Math.max(0, row.seats.length - 1);
116
+ const sweep = placement.kind === CurveMode.Pitch
117
+ ? (((intervals * placement.seatPitchM) / radius) * 180) / Math.PI
118
+ : placement.sweepAngleDeg * (Math.abs(placement.sweepAngleDeg) === 360 ? intervals / row.seats.length : 1);
119
+ let pitch = placement.kind === CurveMode.Pitch ? placement.seatPitchM : 0.55;
120
+ if (intervals) {
121
+ const second = rowSeatGeometry(group, rowIndex, 1, row.seats.length, longest).position;
122
+ pitch = Math.hypot(second.x - first.position.x, second.y - first.position.y);
123
+ }
124
+ const tangent = first.rotationDeg + (sweep < 0 ? 180 : 0);
125
+ return {
126
+ originM: first.position,
127
+ seatPitchM: pitch,
128
+ curveDeg: -sweep,
129
+ rotationDeg: normalizeRowAngle(tangent),
130
+ ...(sweep < 0 ? { seatRotationOffsetDeg: -180 } : {}),
46
131
  };
47
132
  }
48
133
  export function roundChairGeometry(recipe, chairHeightM, seat, count) {
49
134
  const radius = recipe.diameterM / 2 + recipe.chairGapM + chairHeightM / 2;
50
- const angle = recipe.startAngleDeg + (360 * seat) / count;
135
+ const arc = recipe.seatArcDeg ?? 360;
136
+ const angle = recipe.startAngleDeg + (count === 1 ? 0 : (360 - arc) / 2 + (arc * seat) / (arc === 360 ? count : count - 1));
51
137
  return {
52
138
  position: {
53
139
  x: radius * Math.cos((angle * Math.PI) / 180),
@@ -59,9 +145,11 @@ export function roundChairGeometry(recipe, chairHeightM, seat, count) {
59
145
  export function rectangularChairGeometry(recipe, chairHeightM, side, seat, count) {
60
146
  const horizontal = side === TableSide.Top || side === TableSide.Bottom;
61
147
  const length = horizontal ? recipe.widthM : recipe.depthM;
62
- const along = recipe.chairPitchM === undefined
63
- ? -length / 2 + ((seat + 1) * length) / (count + 1)
64
- : (seat - (count - 1) / 2) * recipe.chairPitchM;
148
+ const along = recipe.chairDistribution === TableChairDistribution.EqualSegments
149
+ ? -length / 2 + ((seat + 0.5) * length) / count
150
+ : recipe.chairPitchM === undefined
151
+ ? -length / 2 + ((seat + 1) * length) / (count + 1)
152
+ : (seat - (count - 1) / 2) * recipe.chairPitchM;
65
153
  const gap = recipe.chairGapM + chairHeightM / 2;
66
154
  switch (side) {
67
155
  case TableSide.Top:
@@ -76,12 +164,18 @@ export function rectangularChairGeometry(recipe, chairHeightM, side, seat, count
76
164
  };
77
165
  case TableSide.Bottom:
78
166
  return {
79
- position: { x: -along, y: recipe.depthM / 2 + gap },
167
+ position: {
168
+ x: recipe.chairDistribution === TableChairDistribution.EqualSegments ? along : -along,
169
+ y: recipe.depthM / 2 + gap,
170
+ },
80
171
  rotationDeg: -90,
81
172
  };
82
173
  case TableSide.Left:
83
174
  return {
84
- position: { x: -recipe.widthM / 2 - gap, y: -along },
175
+ position: {
176
+ x: -recipe.widthM / 2 - gap,
177
+ y: recipe.chairDistribution === TableChairDistribution.EqualSegments ? along : -along,
178
+ },
85
179
  rotationDeg: 0,
86
180
  };
87
181
  default: {
@@ -94,12 +188,11 @@ export function* previewSeats(layout) {
94
188
  switch (layout.kind) {
95
189
  case SeatingKind.Straight:
96
190
  case SeatingKind.Curved: {
97
- const longestRow = layout.rowCounts?.reduce((max, count) => Math.max(max, count), 0) ??
98
- layout.seatsPerRow;
191
+ const longestRow = layout.rowCounts?.reduce((max, count) => Math.max(max, count), 0) ?? layout.seatsPerRow;
99
192
  for (let row = 0; row < layout.rows; row++)
100
193
  for (let seat = 0; seat < (layout.rowCounts?.[row] ?? layout.seatsPerRow); seat++)
101
194
  yield {
102
- position: rowSeatGeometry(layout, row, seat, layout.rowCounts?.[row] ?? layout.seatsPerRow, longestRow).position,
195
+ position: rowSeatGeometry(layout, row, seat, layout.rowCounts?.[row] ?? layout.seatsPerRow, longestRow, layout.rowLayouts?.[row]).position,
103
196
  row,
104
197
  ordinal: seat + 1,
105
198
  };
@@ -118,7 +211,8 @@ export function* previewSeats(layout) {
118
211
  for (const side of Object.values(TableSide))
119
212
  for (let seat = 0; seat < layout.sides[side]; seat++)
120
213
  yield {
121
- position: rectangularChairGeometry(layout.recipe, layout.seatSizeM, side, seat, layout.sides[side]).position,
214
+ position: rectangularChairGeometry(layout.recipe, layout.seatSizeM, side, seat, layout.sides[side])
215
+ .position,
122
216
  row: null,
123
217
  ordinal: ++ordinal,
124
218
  };
@@ -0,0 +1,8 @@
1
+ export declare const LayoutUnitM: number;
2
+ /**
3
+ * @method toLayoutUnits
4
+ * @description Convert through the authored scale without rounding precise geometry to a canvas grid.
5
+ * @param {number} distanceM - Distance in metres.
6
+ * @returns {number} Distance in authoring layout units.
7
+ */
8
+ export declare function toLayoutUnits(distanceM: number): number;
@@ -0,0 +1,13 @@
1
+ const layoutScaleM = 0.55;
2
+ const layoutScaleUnits = 24;
3
+ // Standard authoring scale: 24 canvas units span a 0.55m seat pitch.
4
+ export const LayoutUnitM = layoutScaleM / layoutScaleUnits;
5
+ /**
6
+ * @method toLayoutUnits
7
+ * @description Convert through the authored scale without rounding precise geometry to a canvas grid.
8
+ * @param {number} distanceM - Distance in metres.
9
+ * @returns {number} Distance in authoring layout units.
10
+ */
11
+ export function toLayoutUnits(distanceM) {
12
+ return (distanceM / layoutScaleM) * layoutScaleUnits;
13
+ }
@@ -1,21 +1,7 @@
1
- import type { PointM, PolygonM } from "../types.js";
2
- export declare enum OutlineKind {
3
- Rectangle = "rectangle",
4
- Ellipse = "ellipse",
5
- Sector = "sector",
6
- Envelope = "envelope"
7
- }
8
- export type OutlineParameters = {
9
- kind: Exclude<OutlineKind, "envelope">;
10
- center: PointM;
11
- radiusX: number;
12
- radiusY: number;
13
- innerRatio: number;
14
- startDeg: number;
15
- sweepDeg: number;
16
- };
1
+ import type { PointM, PolygonM } from "../physical-document.interface.js";
2
+ import { type OutlineParameters } from "./venue-outline.interface.js";
17
3
  export declare function sampledOutline(p: OutlineParameters): PolygonM;
18
4
  /** Conservative convex envelope, with no invented architectural voids. */
19
5
  export declare function memberEnvelope(points: readonly PointM[], paddingM?: number): PolygonM;
20
- /** Deterministic widest interior scan interval; holes participate in every scan. */
21
- export declare function interiorLabelPoint(polygon: PolygonM): PointM;
6
+ /** Maximum-clearance interior anchor. Holes and curved contours share the same geometry owner. */
7
+ export declare function interiorLabelPoint(source: PolygonM): PointM;
@@ -0,0 +1,23 @@
1
+ import type { PointM } from "../physical-document.interface.js";
2
+ export declare enum OutlineKind {
3
+ Rectangle = "rectangle",
4
+ Ellipse = "ellipse",
5
+ Sector = "sector",
6
+ Envelope = "envelope"
7
+ }
8
+ export type OutlineParameters = {
9
+ kind: Exclude<OutlineKind, OutlineKind.Envelope>;
10
+ center: PointM;
11
+ radiusX: number;
12
+ radiusY: number;
13
+ innerRatio: number;
14
+ startDeg: number;
15
+ sweepDeg: number;
16
+ };
17
+ export interface InteriorLabelCell {
18
+ center: PointM;
19
+ halfWidthM: number;
20
+ halfHeightM: number;
21
+ distanceM: number;
22
+ maximumM: number;
23
+ }
@@ -0,0 +1,7 @@
1
+ export var OutlineKind;
2
+ (function (OutlineKind) {
3
+ OutlineKind["Rectangle"] = "rectangle";
4
+ OutlineKind["Ellipse"] = "ellipse";
5
+ OutlineKind["Sector"] = "sector";
6
+ OutlineKind["Envelope"] = "envelope";
7
+ })(OutlineKind || (OutlineKind = {}));