@seatmap-fyi/map-domain 0.1.0-alpha.54 → 0.1.0-alpha.56
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/physical-document.interface.d.ts +14 -0
- package/dist/physical-document.interface.js +12 -0
- package/dist/schema.d.ts +7 -1
- package/dist/schema.js +8 -3
- package/dist/section-fill.d.ts +16 -5
- package/dist/section-fill.interface.d.ts +5 -1
- package/dist/section-fill.js +112 -18
- package/package.json +1 -1
|
@@ -422,6 +422,17 @@ export type DecorationStyle = {
|
|
|
422
422
|
stroke?: Paint;
|
|
423
423
|
strokeWidthM?: number;
|
|
424
424
|
};
|
|
425
|
+
export declare enum LandmarkKind {
|
|
426
|
+
Screen = "screen",
|
|
427
|
+
SoundDesk = "sound",
|
|
428
|
+
BarCounter = "bar",
|
|
429
|
+
Concession = "concession",
|
|
430
|
+
CoatCheck = "coat",
|
|
431
|
+
Wall = "wall",
|
|
432
|
+
Rail = "rail",
|
|
433
|
+
Suite = "suite",
|
|
434
|
+
Pillar = "obstruction"
|
|
435
|
+
}
|
|
425
436
|
export declare enum StagePreset {
|
|
426
437
|
Flat = "flat",
|
|
427
438
|
Rounded = "rounded",
|
|
@@ -495,9 +506,11 @@ export type Decoration = DrawableBase & ({
|
|
|
495
506
|
cornerRadiusM: number;
|
|
496
507
|
gate?: GateDetails;
|
|
497
508
|
wayfindingBlock?: WayfindingBlockKind;
|
|
509
|
+
landmark?: LandmarkKind;
|
|
498
510
|
} | {
|
|
499
511
|
kind: DecorationKind.Circle;
|
|
500
512
|
radiusM: number;
|
|
513
|
+
landmark?: LandmarkKind;
|
|
501
514
|
} | {
|
|
502
515
|
kind: DecorationKind.Line;
|
|
503
516
|
pointsM: PointM[];
|
|
@@ -513,6 +526,7 @@ export type Decoration = DrawableBase & ({
|
|
|
513
526
|
boundary: PolygonM;
|
|
514
527
|
gate?: GateDetails;
|
|
515
528
|
wayfindingBlock?: WayfindingBlockKind;
|
|
529
|
+
landmark?: LandmarkKind;
|
|
516
530
|
/** Authored caption of an ordinary polygon, including a converted Stage. */
|
|
517
531
|
labelStyle?: StageLabelStyle;
|
|
518
532
|
stage?: {
|
|
@@ -120,6 +120,18 @@ export var TableChairDistribution;
|
|
|
120
120
|
TableChairDistribution["Interior"] = "interior";
|
|
121
121
|
TableChairDistribution["EqualSegments"] = "equalSegments";
|
|
122
122
|
})(TableChairDistribution || (TableChairDistribution = {}));
|
|
123
|
+
export var LandmarkKind;
|
|
124
|
+
(function (LandmarkKind) {
|
|
125
|
+
LandmarkKind["Screen"] = "screen";
|
|
126
|
+
LandmarkKind["SoundDesk"] = "sound";
|
|
127
|
+
LandmarkKind["BarCounter"] = "bar";
|
|
128
|
+
LandmarkKind["Concession"] = "concession";
|
|
129
|
+
LandmarkKind["CoatCheck"] = "coat";
|
|
130
|
+
LandmarkKind["Wall"] = "wall";
|
|
131
|
+
LandmarkKind["Rail"] = "rail";
|
|
132
|
+
LandmarkKind["Suite"] = "suite";
|
|
133
|
+
LandmarkKind["Pillar"] = "obstruction";
|
|
134
|
+
})(LandmarkKind || (LandmarkKind = {}));
|
|
123
135
|
export var StagePreset;
|
|
124
136
|
(function (StagePreset) {
|
|
125
137
|
StagePreset["Flat"] = "flat";
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ArcFanFacing, ArcFanFit, ArcFanSectionOrigin } from "./arc-fan.interface.js";
|
|
2
2
|
import { EntranceKind, GateUse, LineCap, LineJoin, LineEnding, LineShape, WayfindingBlockKind } from "./wayfinding.interface.js";
|
|
3
|
-
import { TicketRestriction, TableBookingMode, TableChairDistribution, StandingBookingMode, SeatShape, type PhysicalDocumentV1, type SeatingGroup, type SeatSlot, type UUID, NumberingScheme, LabelDirection, TableChairNumberFormat, RowLabelPosition, AccessNeed, SeatingKind, CurveMode, DecorationKind, ReferencePlanLayer, LabelAlignment, RowAlignment, RowStagger, RowEnds, RowJoin, SectionOutlineRole, SectionTier, AreaKind, ShapeKind, VenueGlyph, StagePreset, StageCaptionDirection } from "./physical-document.interface.js";
|
|
3
|
+
import { TicketRestriction, TableBookingMode, TableChairDistribution, StandingBookingMode, SeatShape, type PhysicalDocumentV1, type SeatingGroup, type SeatSlot, type UUID, NumberingScheme, LabelDirection, TableChairNumberFormat, RowLabelPosition, AccessNeed, SeatingKind, CurveMode, DecorationKind, ReferencePlanLayer, LabelAlignment, RowAlignment, RowStagger, RowEnds, RowJoin, SectionOutlineRole, SectionTier, AreaKind, ShapeKind, VenueGlyph, LandmarkKind, StagePreset, StageCaptionDirection } from "./physical-document.interface.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { type DomainIssue } from "./issues.js";
|
|
6
6
|
export declare const storedLabelSchema: z.ZodString;
|
|
@@ -2368,6 +2368,7 @@ export declare const documentSchema: z.ZodObject<{
|
|
|
2368
2368
|
showToBuyers: z.ZodOptional<z.ZodBoolean>;
|
|
2369
2369
|
}, z.core.$strict>>;
|
|
2370
2370
|
wayfindingBlock: z.ZodOptional<z.ZodEnum<typeof WayfindingBlockKind>>;
|
|
2371
|
+
landmark: z.ZodOptional<z.ZodEnum<typeof LandmarkKind>>;
|
|
2371
2372
|
sizeM: z.ZodObject<{
|
|
2372
2373
|
width: z.ZodNumber;
|
|
2373
2374
|
height: z.ZodNumber;
|
|
@@ -2402,6 +2403,7 @@ export declare const documentSchema: z.ZodObject<{
|
|
|
2402
2403
|
}, z.core.$strict>, z.ZodObject<{
|
|
2403
2404
|
kind: z.ZodLiteral<DecorationKind.Circle>;
|
|
2404
2405
|
radiusM: z.ZodNumber;
|
|
2406
|
+
landmark: z.ZodOptional<z.ZodEnum<typeof LandmarkKind>>;
|
|
2405
2407
|
label: z.ZodOptional<z.ZodString>;
|
|
2406
2408
|
heightM: z.ZodOptional<z.ZodNumber>;
|
|
2407
2409
|
style: z.ZodOptional<z.ZodObject<{
|
|
@@ -2477,6 +2479,7 @@ export declare const documentSchema: z.ZodObject<{
|
|
|
2477
2479
|
showToBuyers: z.ZodOptional<z.ZodBoolean>;
|
|
2478
2480
|
}, z.core.$strict>>;
|
|
2479
2481
|
wayfindingBlock: z.ZodOptional<z.ZodEnum<typeof WayfindingBlockKind>>;
|
|
2482
|
+
landmark: z.ZodOptional<z.ZodEnum<typeof LandmarkKind>>;
|
|
2480
2483
|
labelStyle: z.ZodOptional<z.ZodObject<{
|
|
2481
2484
|
size: z.ZodOptional<z.ZodNumber>;
|
|
2482
2485
|
color: z.ZodOptional<z.ZodString>;
|
|
@@ -2813,6 +2816,7 @@ export declare const decorationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
2813
2816
|
showToBuyers: z.ZodOptional<z.ZodBoolean>;
|
|
2814
2817
|
}, z.core.$strict>>;
|
|
2815
2818
|
wayfindingBlock: z.ZodOptional<z.ZodEnum<typeof WayfindingBlockKind>>;
|
|
2819
|
+
landmark: z.ZodOptional<z.ZodEnum<typeof LandmarkKind>>;
|
|
2816
2820
|
sizeM: z.ZodObject<{
|
|
2817
2821
|
width: z.ZodNumber;
|
|
2818
2822
|
height: z.ZodNumber;
|
|
@@ -2847,6 +2851,7 @@ export declare const decorationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
2847
2851
|
}, z.core.$strict>, z.ZodObject<{
|
|
2848
2852
|
kind: z.ZodLiteral<DecorationKind.Circle>;
|
|
2849
2853
|
radiusM: z.ZodNumber;
|
|
2854
|
+
landmark: z.ZodOptional<z.ZodEnum<typeof LandmarkKind>>;
|
|
2850
2855
|
label: z.ZodOptional<z.ZodString>;
|
|
2851
2856
|
heightM: z.ZodOptional<z.ZodNumber>;
|
|
2852
2857
|
style: z.ZodOptional<z.ZodObject<{
|
|
@@ -2922,6 +2927,7 @@ export declare const decorationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
2922
2927
|
showToBuyers: z.ZodOptional<z.ZodBoolean>;
|
|
2923
2928
|
}, z.core.$strict>>;
|
|
2924
2929
|
wayfindingBlock: z.ZodOptional<z.ZodEnum<typeof WayfindingBlockKind>>;
|
|
2930
|
+
landmark: z.ZodOptional<z.ZodEnum<typeof LandmarkKind>>;
|
|
2925
2931
|
labelStyle: z.ZodOptional<z.ZodObject<{
|
|
2926
2932
|
size: z.ZodOptional<z.ZodNumber>;
|
|
2927
2933
|
color: z.ZodOptional<z.ZodString>;
|
package/dist/schema.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ArcFanFacing, ArcFanFit, ArcFanMaximumRows, ArcFanMaximumPartsPerRow, ArcFanSectionOrigin, } from "./arc-fan.interface.js";
|
|
2
2
|
import { EntranceKind, GateUse, LineCap, LineJoin, LineEnding, LineShape, WayfindingBlockKind, } from "./wayfinding.interface.js";
|
|
3
3
|
import { polygonContour, polygonContourVertexCount, PolygonVertexLimit, PolygonCornerRadiusMaxM, } from "./geometry/polygon-curves.js";
|
|
4
|
-
import { DocumentLimits, TicketRestriction, TableBookingMode, TableChairDistribution, StandingBookingMode, SeatShape, TicketOptionLimit, NumberingScheme, LabelDirection, TableChairNumberFormat, RowLabelPosition, AccessNeed, SeatingKind, CurveMode, DecorationKind, ReferencePlanLayer, ReferencePlanPageLimit, LabelAlignment, RowAlignment, RowStagger, RowEnds, RowJoin, SectionOutlineRole, RowRefitStrength, SectionRotation, SectionScale, SectionTier, SectionRake, SectionFrontRowHeight, AreaKind, ShapeKind, VenueGlyph, StagePreset, StageCaptionDirection, StageCaptionSize, VenuePhotoLimit, } from "./physical-document.interface.js";
|
|
4
|
+
import { DocumentLimits, TicketRestriction, TableBookingMode, TableChairDistribution, StandingBookingMode, SeatShape, TicketOptionLimit, NumberingScheme, LabelDirection, TableChairNumberFormat, RowLabelPosition, AccessNeed, SeatingKind, CurveMode, DecorationKind, ReferencePlanLayer, ReferencePlanPageLimit, LabelAlignment, RowAlignment, RowStagger, RowEnds, RowJoin, SectionOutlineRole, RowRefitStrength, SectionRotation, SectionScale, SectionTier, SectionRake, SectionFrontRowHeight, AreaKind, ShapeKind, VenueGlyph, LandmarkKind, StagePreset, StageCaptionDirection, StageCaptionSize, VenuePhotoLimit, } from "./physical-document.interface.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { tableSellingValid, standingSellingValid } from "./selling.js";
|
|
7
7
|
import { ticketOptionNameKey } from "./categories.js";
|
|
@@ -464,15 +464,18 @@ const decoration = z.discriminatedUnion("kind", [
|
|
|
464
464
|
kind: z.literal(DecorationKind.Rectangle),
|
|
465
465
|
gate: gateDetails.optional(),
|
|
466
466
|
wayfindingBlock: z.enum(WayfindingBlockKind).optional(),
|
|
467
|
+
landmark: z.enum(LandmarkKind).optional(),
|
|
467
468
|
sizeM: size,
|
|
468
469
|
cornerRadiusM: nonNegative,
|
|
469
470
|
})
|
|
470
471
|
.refine((v) => v.cornerRadiusM <= Math.min(v.sizeM.width, v.sizeM.height) / 2)
|
|
471
|
-
.refine((v) => !v.gate || !v.wayfindingBlock, "A gate cannot also be a wayfinding block.")
|
|
472
|
+
.refine((v) => !v.gate || !v.wayfindingBlock, "A gate cannot also be a wayfinding block.")
|
|
473
|
+
.refine((v) => !v.landmark || (!v.gate && !v.wayfindingBlock), "A landmark cannot also be a gate or wayfinding block."),
|
|
472
474
|
z.strictObject({
|
|
473
475
|
...decorationBase,
|
|
474
476
|
kind: z.literal(DecorationKind.Circle),
|
|
475
477
|
radiusM: dimension,
|
|
478
|
+
landmark: z.enum(LandmarkKind).optional(),
|
|
476
479
|
}),
|
|
477
480
|
z.strictObject({
|
|
478
481
|
...decorationBase,
|
|
@@ -491,6 +494,7 @@ const decoration = z.discriminatedUnion("kind", [
|
|
|
491
494
|
kind: z.literal(DecorationKind.Polygon),
|
|
492
495
|
gate: gateDetails.optional(),
|
|
493
496
|
wayfindingBlock: z.enum(WayfindingBlockKind).optional(),
|
|
497
|
+
landmark: z.enum(LandmarkKind).optional(),
|
|
494
498
|
labelStyle: stageLabelStyleSchema.optional(),
|
|
495
499
|
stage: z
|
|
496
500
|
.strictObject({
|
|
@@ -502,7 +506,8 @@ const decoration = z.discriminatedUnion("kind", [
|
|
|
502
506
|
boundary: polygon,
|
|
503
507
|
})
|
|
504
508
|
.refine((value) => !value.gate || !value.stage, "A stage cannot also be a gate.")
|
|
505
|
-
.refine((value) => !value.wayfindingBlock || (!value.gate && !value.stage), "A wayfinding block cannot also be a gate or stage.")
|
|
509
|
+
.refine((value) => !value.wayfindingBlock || (!value.gate && !value.stage), "A wayfinding block cannot also be a gate or stage.")
|
|
510
|
+
.refine((value) => !value.landmark || (!value.gate && !value.stage && !value.wayfindingBlock), "A landmark cannot also be a gate, stage or wayfinding block."),
|
|
506
511
|
z.strictObject({
|
|
507
512
|
...decorationBase,
|
|
508
513
|
kind: z.literal(DecorationKind.Icon),
|
package/dist/section-fill.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { SectionOutlineRole, type PhysicalDocumentV1, type PointM, type PolygonM, type Section } from "./physical-document.interface.js";
|
|
2
|
+
import { SectionOutlineRole, type PhysicalDocumentV1, type PointM, type PolygonM, type Section, type UUID } from "./physical-document.interface.js";
|
|
3
3
|
import { SectionFillDirection, SectionFillNumbering, type SectionFillInput, type SectionFillPlan, type SectionGrowInput } from "./section-fill.interface.js";
|
|
4
4
|
export { SectionFillDirection, SectionFillNumbering, SectionFillStatus } from "./section-fill.interface.js";
|
|
5
5
|
export type { SectionFillInput, SectionFillPart, SectionFillPlan, SectionFillRow, SectionFillReview, SectionGrowInput, } from "./section-fill.interface.js";
|
|
@@ -49,16 +49,27 @@ export declare const sectionGrowInputSchema: z.ZodObject<{
|
|
|
49
49
|
}, z.core.$strict>;
|
|
50
50
|
}, z.core.$strict>;
|
|
51
51
|
export declare function sectionFillFocalPoint(document: PhysicalDocumentV1, section: Section): PointM;
|
|
52
|
+
/**
|
|
53
|
+
* @method planFillForSection
|
|
54
|
+
* @description Plan rows in the part of the section available under the document's inventory ownership order.
|
|
55
|
+
* @param {PhysicalDocumentV1} document - Current physical document.
|
|
56
|
+
* @param {Section & { outline: PolygonM }} section - Section with an authored outline.
|
|
57
|
+
* @param {SectionFillInput} request - Capacity, spacing and orientation settings.
|
|
58
|
+
* @returns {SectionFillPlan} Preview and capacity for the selected section.
|
|
59
|
+
*/
|
|
60
|
+
export declare function planFillForSection(document: PhysicalDocumentV1, section: Section & {
|
|
61
|
+
outline: PolygonM;
|
|
62
|
+
}, request: SectionFillInput): SectionFillPlan;
|
|
52
63
|
export declare function planSectionGrowth(document: PhysicalDocumentV1, { sectionId, fill }: SectionGrowInput): {
|
|
53
64
|
section: {
|
|
54
65
|
outline: PolygonM;
|
|
55
66
|
entrance?: import("./wayfinding.interface.js").EntranceAssignment;
|
|
56
67
|
buyerPhoto?: import("./physical-document.interface.js").BuyerPhoto;
|
|
57
|
-
floorId?:
|
|
58
|
-
zoneId?:
|
|
68
|
+
floorId?: UUID;
|
|
69
|
+
zoneId?: UUID;
|
|
59
70
|
elevation?: import("./physical-document.interface.js").SectionElevation;
|
|
60
|
-
categoryId?:
|
|
61
|
-
id:
|
|
71
|
+
categoryId?: UUID | null;
|
|
72
|
+
id: UUID;
|
|
62
73
|
label: string;
|
|
63
74
|
displayLabel?: string;
|
|
64
75
|
outlineRole?: SectionOutlineRole;
|
|
@@ -41,9 +41,11 @@ export type SectionFillPlan = {
|
|
|
41
41
|
recipe: Pick<StraightRows["recipe"], "seatPitchM" | "rowPitchM">;
|
|
42
42
|
rows: SectionFillRow[];
|
|
43
43
|
};
|
|
44
|
-
export type
|
|
44
|
+
export type SectionFillSpan = {
|
|
45
45
|
start: number;
|
|
46
46
|
end: number;
|
|
47
|
+
};
|
|
48
|
+
export type SectionFillInterval = SectionFillSpan & {
|
|
47
49
|
capacity: number;
|
|
48
50
|
};
|
|
49
51
|
export type SectionFillBand = {
|
|
@@ -57,6 +59,7 @@ export type SectionFillEdge = {
|
|
|
57
59
|
slope: number;
|
|
58
60
|
};
|
|
59
61
|
export type SectionFillGrid = {
|
|
62
|
+
earlier: readonly PreparedBoundary[];
|
|
60
63
|
angle: number;
|
|
61
64
|
seatPitchM: number;
|
|
62
65
|
rowPitchM: number;
|
|
@@ -64,6 +67,7 @@ export type SectionFillGrid = {
|
|
|
64
67
|
capacity: number;
|
|
65
68
|
};
|
|
66
69
|
export type SectionFillBend = {
|
|
70
|
+
earlier: readonly PreparedBoundary[];
|
|
67
71
|
focalPoint: PointM;
|
|
68
72
|
boundary: PreparedBoundary;
|
|
69
73
|
normal: PointM;
|
package/dist/section-fill.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { authoredFloorFocalPoint, DefaultFloorFocalPoint } from "./floors.js";
|
|
3
|
-
import { BoundaryLocation, classifyBoundary, prepareBoundary } from "./geometry/boundary.js";
|
|
3
|
+
import { BoundaryLocation, BoundaryToleranceM, classifyBoundary, prepareBoundary, } from "./geometry/boundary.js";
|
|
4
4
|
import { normalizeAngle } from "./geometry/geometry.js";
|
|
5
5
|
import { sectionOutlineSampleContour, sectionOutlineSamplingScale } from "./section-outline-refit.js";
|
|
6
|
-
import { pointsBounds } from "./geometry/primitives.js";
|
|
6
|
+
import { intersects, pointsBounds } from "./geometry/primitives.js";
|
|
7
7
|
import { rowSeatGeometry } from "./geometry/seating-layout.js";
|
|
8
8
|
import { LayoutUnitM } from "./geometry/units.js";
|
|
9
9
|
import { LabelDirection, SeatingKind, SectionOutlineRole, } from "./physical-document.interface.js";
|
|
@@ -21,6 +21,8 @@ const MinimumPitchM = 20.7 * LayoutUnitM;
|
|
|
21
21
|
const DegreesPerRadian = 180 / Math.PI;
|
|
22
22
|
const GeometryToleranceM = 1e-9;
|
|
23
23
|
const fillGrids = new WeakMap();
|
|
24
|
+
const sectionBoundaries = new WeakMap();
|
|
25
|
+
const NoEarlierBoundaries = [];
|
|
24
26
|
export const sectionFillDefaults = {
|
|
25
27
|
direction: SectionFillDirection.Straight,
|
|
26
28
|
numbering: SectionFillNumbering.Snake,
|
|
@@ -49,6 +51,41 @@ export function sectionFillFocalPoint(document, section) {
|
|
|
49
51
|
const zone = document.zones?.find(({ id }) => id === section.zoneId);
|
|
50
52
|
return zone?.focalPoint ?? authoredFloorFocalPoint(document, section.floorId ?? null) ?? DefaultFloorFocalPoint;
|
|
51
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* @method planFillForSection
|
|
56
|
+
* @description Plan rows in the part of the section available under the document's inventory ownership order.
|
|
57
|
+
* @param {PhysicalDocumentV1} document - Current physical document.
|
|
58
|
+
* @param {Section & { outline: PolygonM }} section - Section with an authored outline.
|
|
59
|
+
* @param {SectionFillInput} request - Capacity, spacing and orientation settings.
|
|
60
|
+
* @returns {SectionFillPlan} Preview and capacity for the selected section.
|
|
61
|
+
*/
|
|
62
|
+
export function planFillForSection(document, section, request) {
|
|
63
|
+
const contour = sectionOutlineSampleContour(section.outline, sectionOutlineSamplingScale(section));
|
|
64
|
+
return planFill(contour, request, sectionFillFocalPoint(document, section), earlierSectionBoundaries(document, section));
|
|
65
|
+
}
|
|
66
|
+
// The section catalogue assigns spatial inventory to the first containing boundary on the same floor.
|
|
67
|
+
function earlierSectionBoundaries(document, section) {
|
|
68
|
+
let cached = sectionBoundaries.get(document);
|
|
69
|
+
if (!cached) {
|
|
70
|
+
cached = new Map();
|
|
71
|
+
sectionBoundaries.set(document, cached);
|
|
72
|
+
}
|
|
73
|
+
const previous = cached.get(section.id);
|
|
74
|
+
if (previous)
|
|
75
|
+
return previous;
|
|
76
|
+
const earlier = [];
|
|
77
|
+
for (const current of document.sections) {
|
|
78
|
+
if (current.id === section.id)
|
|
79
|
+
break;
|
|
80
|
+
if (!current.outline || current.outlineRole === SectionOutlineRole.Overview)
|
|
81
|
+
continue;
|
|
82
|
+
if ((current.floorId ?? null) !== (section.floorId ?? null))
|
|
83
|
+
continue;
|
|
84
|
+
earlier.push(prepareBoundary(current.outline));
|
|
85
|
+
}
|
|
86
|
+
cached.set(section.id, earlier);
|
|
87
|
+
return earlier;
|
|
88
|
+
}
|
|
52
89
|
export function planSectionGrowth(document, { sectionId, fill }) {
|
|
53
90
|
const section = document.sections.find(({ id }) => id === sectionId);
|
|
54
91
|
if (!section?.outline || section.outlineRole === SectionOutlineRole.Overview)
|
|
@@ -72,12 +109,10 @@ function scanEdges(rings) {
|
|
|
72
109
|
}
|
|
73
110
|
return edges.sort((a, b) => a.low.y - b.low.y);
|
|
74
111
|
}
|
|
75
|
-
function
|
|
112
|
+
function scanSpans(edges) {
|
|
76
113
|
let cursor = 0;
|
|
77
114
|
let active = [];
|
|
78
|
-
|
|
79
|
-
for (let index = 0; top + index * rowPitchM <= bottom + GeometryToleranceM; index++) {
|
|
80
|
-
const y = top + index * rowPitchM;
|
|
115
|
+
return (y) => {
|
|
81
116
|
active = active.filter((edge) => edge.high.y > y);
|
|
82
117
|
while (cursor < edges.length && edges[cursor].low.y <= y) {
|
|
83
118
|
const edge = edges[cursor++];
|
|
@@ -85,11 +120,50 @@ function scanBands(edges, top, bottom, { rowPitchM, seatPitchM }) {
|
|
|
85
120
|
active.push(edge);
|
|
86
121
|
}
|
|
87
122
|
const crossings = active.map(({ low, slope }) => low.x + (y - low.y) * slope).sort((a, b) => a - b);
|
|
123
|
+
const spans = [];
|
|
124
|
+
for (let i = 0; i + 1 < crossings.length; i += 2) {
|
|
125
|
+
spans.push({ start: crossings[i], end: crossings[i + 1] });
|
|
126
|
+
}
|
|
127
|
+
return spans;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function subtractSpans(spans, blocked) {
|
|
131
|
+
return spans.flatMap(({ start, end }) => {
|
|
132
|
+
const available = [];
|
|
133
|
+
for (const span of blocked) {
|
|
134
|
+
if (span.end <= start)
|
|
135
|
+
continue;
|
|
136
|
+
if (span.start >= end)
|
|
137
|
+
break;
|
|
138
|
+
if (span.start > start)
|
|
139
|
+
available.push({ start, end: span.start });
|
|
140
|
+
start = span.end;
|
|
141
|
+
if (start >= end)
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
if (start < end)
|
|
145
|
+
available.push({ start, end });
|
|
146
|
+
return available;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function scanBands(edges, exclusions, top, bottom, { rowPitchM, seatPitchM }) {
|
|
150
|
+
const scanOutline = scanSpans(edges);
|
|
151
|
+
// Sample both sides so a track on the closed edge of an earlier section is excluded too.
|
|
152
|
+
const scanExclusions = exclusions.map((edges) => {
|
|
153
|
+
const below = scanSpans(edges);
|
|
154
|
+
const at = scanSpans(edges);
|
|
155
|
+
const above = scanSpans(edges);
|
|
156
|
+
return (y) => [...below(y - BoundaryToleranceM), ...at(y), ...above(y + BoundaryToleranceM)];
|
|
157
|
+
});
|
|
158
|
+
const bands = [];
|
|
159
|
+
for (let index = 0; top + index * rowPitchM <= bottom + GeometryToleranceM; index++) {
|
|
160
|
+
const y = top + index * rowPitchM;
|
|
161
|
+
const blocked = scanExclusions.flatMap((scan) => scan(y)).sort((first, second) => first.start - second.start);
|
|
88
162
|
const intervals = [];
|
|
89
163
|
let capacity = 0;
|
|
90
|
-
for (
|
|
91
|
-
const start =
|
|
92
|
-
const end =
|
|
164
|
+
for (const span of subtractSpans(scanOutline(y), blocked)) {
|
|
165
|
+
const start = span.start + ClearanceM;
|
|
166
|
+
const end = span.end - ClearanceM;
|
|
93
167
|
if (end < start - GeometryToleranceM)
|
|
94
168
|
continue;
|
|
95
169
|
const seats = 1 + Math.floor((end - start + GeometryToleranceM) / seatPitchM);
|
|
@@ -130,18 +204,25 @@ function allocateRows(total, capacities) {
|
|
|
130
204
|
}
|
|
131
205
|
return counts;
|
|
132
206
|
}
|
|
133
|
-
function fillGrid(contour, angle, input, project) {
|
|
207
|
+
function fillGrid(contour, angle, input, project, earlier) {
|
|
134
208
|
const cached = fillGrids.get(contour);
|
|
135
|
-
if (cached?.angle === angle &&
|
|
209
|
+
if (cached?.angle === angle &&
|
|
210
|
+
cached.earlier === earlier &&
|
|
211
|
+
cached.seatPitchM === input.seatPitchM &&
|
|
212
|
+
cached.rowPitchM === input.rowPitchM)
|
|
136
213
|
return cached;
|
|
137
214
|
const outer = contour.outer.map(project);
|
|
138
215
|
const { minY, maxY } = pointsBounds(outer);
|
|
139
216
|
const edges = scanEdges([outer, ...contour.holes.map((ring) => ring.map(project))]);
|
|
217
|
+
const bounds = pointsBounds(contour.outer);
|
|
218
|
+
const exclusions = earlier
|
|
219
|
+
.filter((boundary) => intersects(bounds, boundary.bounds))
|
|
220
|
+
.map(({ polygon }) => scanEdges([polygon.outer, ...polygon.holes].map((ring) => ring.map(project))));
|
|
140
221
|
let best = [];
|
|
141
222
|
let maximum = 0;
|
|
142
223
|
for (let phase = 0; phase < GridPhases; phase++) {
|
|
143
224
|
const top = minY + ClearanceM + (phase * input.rowPitchM) / GridPhases;
|
|
144
|
-
const bands = scanBands(edges, top, maxY - ClearanceM, input)
|
|
225
|
+
const bands = scanBands(edges, exclusions, top, maxY - ClearanceM, input)
|
|
145
226
|
.sort((first, second) => second.capacity - first.capacity)
|
|
146
227
|
.slice(0, SectionFillLimits.rows.max);
|
|
147
228
|
const capacity = bands.reduce((sum, band) => sum + band.capacity, 0);
|
|
@@ -152,6 +233,7 @@ function fillGrid(contour, angle, input, project) {
|
|
|
152
233
|
}
|
|
153
234
|
const grid = {
|
|
154
235
|
angle,
|
|
236
|
+
earlier,
|
|
155
237
|
seatPitchM: input.seatPitchM,
|
|
156
238
|
rowPitchM: input.rowPitchM,
|
|
157
239
|
bands: best,
|
|
@@ -161,7 +243,7 @@ function fillGrid(contour, angle, input, project) {
|
|
|
161
243
|
return grid;
|
|
162
244
|
}
|
|
163
245
|
function bendPart(layout, midpoint, seats, bend) {
|
|
164
|
-
const { focalPoint, boundary, normal, clearanceM } = bend;
|
|
246
|
+
const { focalPoint, boundary, normal, clearanceM, earlier } = bend;
|
|
165
247
|
const dx = midpoint.x - focalPoint.x;
|
|
166
248
|
const dy = midpoint.y - focalPoint.y;
|
|
167
249
|
const radiusM = Math.hypot(dx, dy);
|
|
@@ -195,14 +277,18 @@ function bendPart(layout, midpoint, seats, bend) {
|
|
|
195
277
|
...(facing < 0 && { seatRotationOffsetDeg: -180 }),
|
|
196
278
|
};
|
|
197
279
|
let seat = 0;
|
|
280
|
+
const anchor = { x: 0, y: 0 };
|
|
198
281
|
for (; seat < seats; seat++) {
|
|
199
282
|
const { position } = rowSeatGeometry(geometry, 0, seat, seats, seats, candidate);
|
|
200
283
|
const acrossTrack = (position.x - midpoint.x) * normal.x + (position.y - midpoint.y) * normal.y;
|
|
201
284
|
if (Math.abs(acrossTrack) > clearanceM + GeometryToleranceM ||
|
|
202
|
-
classifyBoundary(boundary, position) === BoundaryLocation.Outside
|
|
285
|
+
classifyBoundary(boundary, position) === BoundaryLocation.Outside ||
|
|
286
|
+
earlier.some((other) => classifyBoundary(other, position) !== BoundaryLocation.Outside))
|
|
203
287
|
break;
|
|
288
|
+
anchor.x += position.x / seats;
|
|
289
|
+
anchor.y += position.y / seats;
|
|
204
290
|
}
|
|
205
|
-
if (seat === seats)
|
|
291
|
+
if (seat === seats && earlier.every((other) => classifyBoundary(other, anchor) === BoundaryLocation.Outside))
|
|
206
292
|
return candidate;
|
|
207
293
|
}
|
|
208
294
|
return layout;
|
|
@@ -217,8 +303,10 @@ function outlineCenter(outer) {
|
|
|
217
303
|
}
|
|
218
304
|
/** Preview a section fill without allocating inventory identities or editing the outline. */
|
|
219
305
|
export function planSectionFill(outline, request, focalPoint, sampleScale = 1) {
|
|
306
|
+
return planFill(sectionOutlineSampleContour(outline, sampleScale), request, focalPoint, NoEarlierBoundaries);
|
|
307
|
+
}
|
|
308
|
+
function planFill(contour, request, focalPoint, earlier) {
|
|
220
309
|
const input = sectionFillInputSchema.parse(request);
|
|
221
|
-
const contour = sectionOutlineSampleContour(outline, sampleScale);
|
|
222
310
|
const recipe = {
|
|
223
311
|
seatPitchM: Math.max(input.seatPitchM, MinimumPitchM),
|
|
224
312
|
rowPitchM: Math.max(input.rowPitchM, MinimumPitchM),
|
|
@@ -233,7 +321,7 @@ export function planSectionFill(outline, request, focalPoint, sampleScale = 1) {
|
|
|
233
321
|
x: (x - center.x) * cos + (y - center.y) * sin,
|
|
234
322
|
y: (y - center.y) * cos - (x - center.x) * sin,
|
|
235
323
|
});
|
|
236
|
-
const grid = fillGrid(contour, angle, recipe, project);
|
|
324
|
+
const grid = fillGrid(contour, angle, recipe, project, earlier);
|
|
237
325
|
const selected = grid.bands.slice(0, input.rowCount ?? input.targetSeats).sort((a, b) => a.y - b.y);
|
|
238
326
|
const maximumSeats = input.rowCount === undefined ? grid.capacity : selected.reduce((sum, band) => sum + band.capacity, 0);
|
|
239
327
|
const limits = { maximumRows: grid.bands.length, maximumSeats, recipe };
|
|
@@ -245,7 +333,13 @@ export function planSectionFill(outline, request, focalPoint, sampleScale = 1) {
|
|
|
245
333
|
const rotationDeg = normalizeAngle(angle * DegreesPerRadian);
|
|
246
334
|
const clearanceM = recipe.rowPitchM - MinimumPitchM;
|
|
247
335
|
const bend = input.direction === SectionFillDirection.Focal && clearanceM > 0
|
|
248
|
-
? {
|
|
336
|
+
? {
|
|
337
|
+
focalPoint,
|
|
338
|
+
clearanceM,
|
|
339
|
+
boundary: prepareBoundary(contour),
|
|
340
|
+
normal: { x: -sin, y: cos },
|
|
341
|
+
earlier: earlier.filter((other) => intersects(prepareBoundary(contour).bounds, other.bounds)),
|
|
342
|
+
}
|
|
249
343
|
: null;
|
|
250
344
|
const world = (x, y) => ({
|
|
251
345
|
x: center.x + x * cos - y * sin,
|