@willcgage/module-schematic 0.83.1 → 0.84.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1528,9 +1528,11 @@ interface TrackPart {
1528
1528
  * (#193). */
1529
1529
  /** ⚠️ `crossover` is an ASSEMBLY, not a single turnout. A Fast Tracks
1530
1530
  * crossover fixture builds ONE SYMMETRICAL HALF; you build a second, rotate it
1531
- * 180° and butt the two together at the through routes and the diamond to get
1532
- * a complete DOUBLE (scissors) crossover — four turnouts, two diagonals and
1533
- * the X where they cross. So it carries {@link trackSpacing} and
1531
+ * 180° and butt the two together at the through routes and the scissors to get
1532
+ * a complete DOUBLE CROSSOVER — four turnouts, two diagonals, and the SCISSORS
1533
+ * where they cross. ⚠️ Will Gage, 2026-07-26: *"A double crossover contains
1534
+ * the scissors."* The scissors is that X, not the whole assembly — do not use
1535
+ * it as another name for the part. So it carries {@link trackSpacing} and
1534
1536
  * {@link secondaryFrogAngle}, which no single turnout has, and
1535
1537
  * {@link piecesPerAssembly} — because its lengths describe the HALF, not the
1536
1538
  * finished crossover. */
@@ -1620,8 +1622,9 @@ interface TrackPart {
1620
1622
  * than reconciled: it is a fact about the product, and an owner deciding what
1621
1623
  * to buy is better served by the true number than by a convenient one. */
1622
1624
  trackSpacing?: PartDimension;
1623
- /** The SECOND frog angle on a part that has two — the diamond where the
1624
- * diagonals of a scissors crossover cross. Published in degrees. */
1625
+ /** The SECOND frog angle on a part that has two — the SCISSORS of a double
1626
+ * crossover, the X where its two opposite diverging routes meet and cross.
1627
+ * Published in degrees. */
1625
1628
  secondaryFrogAngle?: PartAngle;
1626
1629
  /** The part's drawn geometry in its own frame, when it came from a library
1627
1630
  * file. This is the payload worth importing — real outlines we can draw
@@ -1783,17 +1786,24 @@ declare const FAST_TRACKS_N_ME55: TrackPart[];
1783
1786
  * read as the assembly's.
1784
1787
  *
1785
1788
  * ⚠️ THE FINISHED LENGTH IS NOT PUBLISHED, and is deliberately not stored. The
1786
- * two halves are related by a 180° rotation about the diamond, so they cover the
1789
+ * two halves are related by a 180° rotation about the scissors, so they cover the
1787
1790
  * same longitudinal span and the finished crossover is plausibly also ~10.07″ —
1788
1791
  * but that is an inference from the symmetry, not a reading, and this library
1789
1792
  * has been burned four times by exactly that kind of plausible reconstruction.
1790
1793
  * If it matters, measure a built one.
1791
1794
  *
1792
- * ⚠️ THESE MAKE A DOUBLE (SCISSORS) CROSSOVER — four turnouts, two diagonals,
1793
- * and the X where the diagonals cross. A half carries one full 9.46° frog and
1794
- * HALF of the 19° diamond, which is why the diamond only exists once the second
1795
- * piece is butted up. Not a single crossover: half a diamond is not usable on
1796
- * its own.
1795
+ * ⚠️ THESE MAKE A DOUBLE CROSSOVER — four turnouts, two diagonals, and the
1796
+ * SCISSORS where the two opposite diverging routes meet and cross in an X.
1797
+ * A half carries one full 9.46° frog and HALF of the 19° scissors, which is why
1798
+ * the scissors only exists once the second piece is butted up. Not a single
1799
+ * crossover: half a scissors is not usable on its own.
1800
+ *
1801
+ * ⚠️ TERMINOLOGY, from Will Gage 2026-07-26: *"A double crossover contains the
1802
+ * scissors. The location where both opposite diverging routes meet and cross
1803
+ * like an 'X'."* The scissors is that crossing, NOT another name for the whole
1804
+ * part — the assembly is a double crossover. Nor is it this library's
1805
+ * `crossing`/diamond kind, which is two tracks crossing with no route choice
1806
+ * (#170); the scissors is internal to the crossover.
1797
1807
  *
1798
1808
  * ⚠️⚠️ **THE TRACK SPACING IS 1.09″, AND FREE-moN §2.0 REQUIRES 1.125″.**
1799
1809
  * A crossover fixture is machined for ONE spacing; it is not adjustable. So a
@@ -2292,6 +2302,62 @@ declare function turnoutClosure(size: number, opts?: {
2292
2302
  * around 25″ on a #7 — clear of the Free-moN 22″ minimum. */
2293
2303
  easeInches?: number;
2294
2304
  }): TurnoutClosure;
2305
+ /** Which end of a part this is. A graph connects joints; a walk uses `routes`. */
2306
+ type PartJointRole = "throat" | "through" | "diverge" | "divergeB";
2307
+ /** One end of a part, in part-local inches: `x` along the through route from
2308
+ * the tie end, `y` lateral toward the diverging side, `angleDeg` the OUTWARD
2309
+ * tangent (0 = +x). Named, unlike {@link PartEnd}, because a graph has to know
2310
+ * a throat from a frog. */
2311
+ interface PartJoint extends PartEnd {
2312
+ id: string;
2313
+ role: PartJointRole;
2314
+ }
2315
+ interface PartGeometry {
2316
+ joints: PartJoint[];
2317
+ /** Joint id pairs a train can run between. A turnout has two routes sharing
2318
+ * its throat; flex has one; a double crossover has four. */
2319
+ routes: [string, string][];
2320
+ /** The weakest provenance among the dimensions used — so a caller can tell a
2321
+ * placed-from-measurement part from a placed-from-a-catalogue-figure one. */
2322
+ source: DimensionSource;
2323
+ /** True when the diverging end came from a measured {@link
2324
+ * TrackPart.divergingLength} rather than from assuming the diverging rail
2325
+ * leaves the moulding at the same place the through route does. */
2326
+ divergingEndMeasured: boolean;
2327
+ }
2328
+ /**
2329
+ * Why a part has no derivable geometry — null when it has.
2330
+ *
2331
+ * Worth its own function because "we cannot place this yet" is a fact an owner
2332
+ * should see in the picker, not a silent absence. It is also the parts-library
2333
+ * backlog in machine-readable form: every string this returns is a measurement
2334
+ * someone could take.
2335
+ */
2336
+ declare function partGeometryGap(part: TrackPart): string | null;
2337
+ /**
2338
+ * A part's joints and routes, in its own frame.
2339
+ *
2340
+ * The through route runs along +x from the tie end; the diverging side is +y.
2341
+ * A placed piece is this, transformed — which is the whole point: the geometry
2342
+ * belongs to the PART, and placement is a rotation and a translation.
2343
+ *
2344
+ * ⚠️ THE DIVERGING END IS MEASURED WHERE WE HAVE A MEASUREMENT. `divergingLength`
2345
+ * (frog → end of the diverging rail, along the rail) says exactly where that end
2346
+ * is. Without it we fall back to assuming the diverging rail leaves the moulding
2347
+ * at the same x as the through route — which is what `partExtent` has always
2348
+ * assumed, and is an assumption, not a reading. `divergingEndMeasured` says
2349
+ * which you got.
2350
+ */
2351
+ declare function partGeometry(part: TrackPart, library?: TrackPart[]): PartGeometry | null;
2352
+ /** Every part that can be PLACED on a board today, and every one that can only
2353
+ * be named — with the reason. The gap list is the parts backlog. */
2354
+ declare function partsPlaceable(library?: TrackPart[]): {
2355
+ placeable: TrackPart[];
2356
+ blocked: {
2357
+ part: TrackPart;
2358
+ why: string;
2359
+ }[];
2360
+ };
2295
2361
  /** A frog casting's parts, in TURNOUT-LOCAL inches: `x` = distance past the
2296
2362
  * points, `y` = lateral offset from the through route. */
2297
2363
  interface FrogCasting {
@@ -2498,4 +2564,4 @@ declare function poseOverridesFromDoc(doc: ModuleSchematicDoc): Record<string, {
2498
2564
  heading: number;
2499
2565
  }>;
2500
2566
 
2501
- export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, type DimensionSource, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FlexPiece, type FlexPieceEnd, type FrogCasting, type GeometryType, type ImportedPart, type IndustryLabelMode, type IndustrySpot, type LanePinch, MAIN2_TRACK_ID, MAIN_TRACK_ID, type ModuleFeatures, type ModuleFootprint, type ModuleFootprintInput, type ModuleGeometryInput, type ModuleSchematicDoc, type ModuleTrackRow, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, type OccupiedSpan, type OutlineFace, PINCH_EASE_INCHES, type PartAngle, type PartDimension, type PartEnd, type PartExtent, type PartSegment, RAIL_GAUGE_INCHES, type ReturnLoopGeometry, type ReturnLoopShape, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionEnd, type SectionEndAssessment, type SectionFootprint, type SectionJointAssessment, type SectionRelativePos, type SignalFacing, type SignalSide, type SpanOverhang, type StoredTrackPart, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackPart, type TrackRole, type TurnoutClosure, type TurnoutKind, type UsableCapacity, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partOutlineAtFrog, pastFrogInchesForSize, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity };
2567
+ export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, type DimensionSource, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FlexPiece, type FlexPieceEnd, type FrogCasting, type GeometryType, type ImportedPart, type IndustryLabelMode, type IndustrySpot, type LanePinch, MAIN2_TRACK_ID, MAIN_TRACK_ID, type ModuleFeatures, type ModuleFootprint, type ModuleFootprintInput, type ModuleGeometryInput, type ModuleSchematicDoc, type ModuleTrackRow, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, type OccupiedSpan, type OutlineFace, PINCH_EASE_INCHES, type PartAngle, type PartDimension, type PartEnd, type PartExtent, type PartGeometry, type PartJoint, type PartJointRole, type PartSegment, RAIL_GAUGE_INCHES, type ReturnLoopGeometry, type ReturnLoopShape, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionEnd, type SectionEndAssessment, type SectionFootprint, type SectionJointAssessment, type SectionRelativePos, type SignalFacing, type SignalSide, type SpanOverhang, type StoredTrackPart, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackPart, type TrackRole, type TurnoutClosure, type TurnoutKind, type UsableCapacity, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partGeometry, partGeometryGap, partOutlineAtFrog, partsPlaceable, pastFrogInchesForSize, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity };
package/dist/index.d.ts CHANGED
@@ -1528,9 +1528,11 @@ interface TrackPart {
1528
1528
  * (#193). */
1529
1529
  /** ⚠️ `crossover` is an ASSEMBLY, not a single turnout. A Fast Tracks
1530
1530
  * crossover fixture builds ONE SYMMETRICAL HALF; you build a second, rotate it
1531
- * 180° and butt the two together at the through routes and the diamond to get
1532
- * a complete DOUBLE (scissors) crossover — four turnouts, two diagonals and
1533
- * the X where they cross. So it carries {@link trackSpacing} and
1531
+ * 180° and butt the two together at the through routes and the scissors to get
1532
+ * a complete DOUBLE CROSSOVER — four turnouts, two diagonals, and the SCISSORS
1533
+ * where they cross. ⚠️ Will Gage, 2026-07-26: *"A double crossover contains
1534
+ * the scissors."* The scissors is that X, not the whole assembly — do not use
1535
+ * it as another name for the part. So it carries {@link trackSpacing} and
1534
1536
  * {@link secondaryFrogAngle}, which no single turnout has, and
1535
1537
  * {@link piecesPerAssembly} — because its lengths describe the HALF, not the
1536
1538
  * finished crossover. */
@@ -1620,8 +1622,9 @@ interface TrackPart {
1620
1622
  * than reconciled: it is a fact about the product, and an owner deciding what
1621
1623
  * to buy is better served by the true number than by a convenient one. */
1622
1624
  trackSpacing?: PartDimension;
1623
- /** The SECOND frog angle on a part that has two — the diamond where the
1624
- * diagonals of a scissors crossover cross. Published in degrees. */
1625
+ /** The SECOND frog angle on a part that has two — the SCISSORS of a double
1626
+ * crossover, the X where its two opposite diverging routes meet and cross.
1627
+ * Published in degrees. */
1625
1628
  secondaryFrogAngle?: PartAngle;
1626
1629
  /** The part's drawn geometry in its own frame, when it came from a library
1627
1630
  * file. This is the payload worth importing — real outlines we can draw
@@ -1783,17 +1786,24 @@ declare const FAST_TRACKS_N_ME55: TrackPart[];
1783
1786
  * read as the assembly's.
1784
1787
  *
1785
1788
  * ⚠️ THE FINISHED LENGTH IS NOT PUBLISHED, and is deliberately not stored. The
1786
- * two halves are related by a 180° rotation about the diamond, so they cover the
1789
+ * two halves are related by a 180° rotation about the scissors, so they cover the
1787
1790
  * same longitudinal span and the finished crossover is plausibly also ~10.07″ —
1788
1791
  * but that is an inference from the symmetry, not a reading, and this library
1789
1792
  * has been burned four times by exactly that kind of plausible reconstruction.
1790
1793
  * If it matters, measure a built one.
1791
1794
  *
1792
- * ⚠️ THESE MAKE A DOUBLE (SCISSORS) CROSSOVER — four turnouts, two diagonals,
1793
- * and the X where the diagonals cross. A half carries one full 9.46° frog and
1794
- * HALF of the 19° diamond, which is why the diamond only exists once the second
1795
- * piece is butted up. Not a single crossover: half a diamond is not usable on
1796
- * its own.
1795
+ * ⚠️ THESE MAKE A DOUBLE CROSSOVER — four turnouts, two diagonals, and the
1796
+ * SCISSORS where the two opposite diverging routes meet and cross in an X.
1797
+ * A half carries one full 9.46° frog and HALF of the 19° scissors, which is why
1798
+ * the scissors only exists once the second piece is butted up. Not a single
1799
+ * crossover: half a scissors is not usable on its own.
1800
+ *
1801
+ * ⚠️ TERMINOLOGY, from Will Gage 2026-07-26: *"A double crossover contains the
1802
+ * scissors. The location where both opposite diverging routes meet and cross
1803
+ * like an 'X'."* The scissors is that crossing, NOT another name for the whole
1804
+ * part — the assembly is a double crossover. Nor is it this library's
1805
+ * `crossing`/diamond kind, which is two tracks crossing with no route choice
1806
+ * (#170); the scissors is internal to the crossover.
1797
1807
  *
1798
1808
  * ⚠️⚠️ **THE TRACK SPACING IS 1.09″, AND FREE-moN §2.0 REQUIRES 1.125″.**
1799
1809
  * A crossover fixture is machined for ONE spacing; it is not adjustable. So a
@@ -2292,6 +2302,62 @@ declare function turnoutClosure(size: number, opts?: {
2292
2302
  * around 25″ on a #7 — clear of the Free-moN 22″ minimum. */
2293
2303
  easeInches?: number;
2294
2304
  }): TurnoutClosure;
2305
+ /** Which end of a part this is. A graph connects joints; a walk uses `routes`. */
2306
+ type PartJointRole = "throat" | "through" | "diverge" | "divergeB";
2307
+ /** One end of a part, in part-local inches: `x` along the through route from
2308
+ * the tie end, `y` lateral toward the diverging side, `angleDeg` the OUTWARD
2309
+ * tangent (0 = +x). Named, unlike {@link PartEnd}, because a graph has to know
2310
+ * a throat from a frog. */
2311
+ interface PartJoint extends PartEnd {
2312
+ id: string;
2313
+ role: PartJointRole;
2314
+ }
2315
+ interface PartGeometry {
2316
+ joints: PartJoint[];
2317
+ /** Joint id pairs a train can run between. A turnout has two routes sharing
2318
+ * its throat; flex has one; a double crossover has four. */
2319
+ routes: [string, string][];
2320
+ /** The weakest provenance among the dimensions used — so a caller can tell a
2321
+ * placed-from-measurement part from a placed-from-a-catalogue-figure one. */
2322
+ source: DimensionSource;
2323
+ /** True when the diverging end came from a measured {@link
2324
+ * TrackPart.divergingLength} rather than from assuming the diverging rail
2325
+ * leaves the moulding at the same place the through route does. */
2326
+ divergingEndMeasured: boolean;
2327
+ }
2328
+ /**
2329
+ * Why a part has no derivable geometry — null when it has.
2330
+ *
2331
+ * Worth its own function because "we cannot place this yet" is a fact an owner
2332
+ * should see in the picker, not a silent absence. It is also the parts-library
2333
+ * backlog in machine-readable form: every string this returns is a measurement
2334
+ * someone could take.
2335
+ */
2336
+ declare function partGeometryGap(part: TrackPart): string | null;
2337
+ /**
2338
+ * A part's joints and routes, in its own frame.
2339
+ *
2340
+ * The through route runs along +x from the tie end; the diverging side is +y.
2341
+ * A placed piece is this, transformed — which is the whole point: the geometry
2342
+ * belongs to the PART, and placement is a rotation and a translation.
2343
+ *
2344
+ * ⚠️ THE DIVERGING END IS MEASURED WHERE WE HAVE A MEASUREMENT. `divergingLength`
2345
+ * (frog → end of the diverging rail, along the rail) says exactly where that end
2346
+ * is. Without it we fall back to assuming the diverging rail leaves the moulding
2347
+ * at the same x as the through route — which is what `partExtent` has always
2348
+ * assumed, and is an assumption, not a reading. `divergingEndMeasured` says
2349
+ * which you got.
2350
+ */
2351
+ declare function partGeometry(part: TrackPart, library?: TrackPart[]): PartGeometry | null;
2352
+ /** Every part that can be PLACED on a board today, and every one that can only
2353
+ * be named — with the reason. The gap list is the parts backlog. */
2354
+ declare function partsPlaceable(library?: TrackPart[]): {
2355
+ placeable: TrackPart[];
2356
+ blocked: {
2357
+ part: TrackPart;
2358
+ why: string;
2359
+ }[];
2360
+ };
2295
2361
  /** A frog casting's parts, in TURNOUT-LOCAL inches: `x` = distance past the
2296
2362
  * points, `y` = lateral offset from the through route. */
2297
2363
  interface FrogCasting {
@@ -2498,4 +2564,4 @@ declare function poseOverridesFromDoc(doc: ModuleSchematicDoc): Record<string, {
2498
2564
  heading: number;
2499
2565
  }>;
2500
2566
 
2501
- export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, type DimensionSource, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FlexPiece, type FlexPieceEnd, type FrogCasting, type GeometryType, type ImportedPart, type IndustryLabelMode, type IndustrySpot, type LanePinch, MAIN2_TRACK_ID, MAIN_TRACK_ID, type ModuleFeatures, type ModuleFootprint, type ModuleFootprintInput, type ModuleGeometryInput, type ModuleSchematicDoc, type ModuleTrackRow, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, type OccupiedSpan, type OutlineFace, PINCH_EASE_INCHES, type PartAngle, type PartDimension, type PartEnd, type PartExtent, type PartSegment, RAIL_GAUGE_INCHES, type ReturnLoopGeometry, type ReturnLoopShape, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionEnd, type SectionEndAssessment, type SectionFootprint, type SectionJointAssessment, type SectionRelativePos, type SignalFacing, type SignalSide, type SpanOverhang, type StoredTrackPart, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackPart, type TrackRole, type TurnoutClosure, type TurnoutKind, type UsableCapacity, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partOutlineAtFrog, pastFrogInchesForSize, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity };
2567
+ export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, type DimensionSource, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FlexPiece, type FlexPieceEnd, type FrogCasting, type GeometryType, type ImportedPart, type IndustryLabelMode, type IndustrySpot, type LanePinch, MAIN2_TRACK_ID, MAIN_TRACK_ID, type ModuleFeatures, type ModuleFootprint, type ModuleFootprintInput, type ModuleGeometryInput, type ModuleSchematicDoc, type ModuleTrackRow, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, type OccupiedSpan, type OutlineFace, PINCH_EASE_INCHES, type PartAngle, type PartDimension, type PartEnd, type PartExtent, type PartGeometry, type PartJoint, type PartJointRole, type PartSegment, RAIL_GAUGE_INCHES, type ReturnLoopGeometry, type ReturnLoopShape, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionEnd, type SectionEndAssessment, type SectionFootprint, type SectionJointAssessment, type SectionRelativePos, type SignalFacing, type SignalSide, type SpanOverhang, type StoredTrackPart, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackPart, type TrackRole, type TurnoutClosure, type TurnoutKind, type UsableCapacity, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partGeometry, partGeometryGap, partOutlineAtFrog, partsPlaceable, pastFrogInchesForSize, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity };
package/dist/index.js CHANGED
@@ -1649,7 +1649,7 @@ var FAST_TRACKS_N_ME55_CROSSOVERS = [
1649
1649
  secondaryFrogAngle: {
1650
1650
  deg: second,
1651
1651
  source: manufacturer,
1652
- note: `${spec}. The diamond of a scissors crossover \u2014 2 \xD7 ${deg}\xB0 within the published rounding.`
1652
+ note: `${spec}. The SCISSORS of a double crossover \u2014 the X where its two opposite diverging routes cross \u2014 at 2 \xD7 ${deg}\xB0 within the published rounding.`
1653
1653
  },
1654
1654
  overallLength: {
1655
1655
  inches: dflt,
@@ -2126,6 +2126,107 @@ function turnoutClosure(size, opts = {}) {
2126
2126
  }
2127
2127
  };
2128
2128
  }
2129
+ function partGeometryGap(part) {
2130
+ if (part.kind === "flex") return null;
2131
+ if (part.kind === "crossover")
2132
+ return "a crossover fixture builds one HALF of the assembly (piecesPerAssembly), so its published lengths describe a piece, not the finished part \u2014 the geometry of the whole crossover is not yet derivable from them";
2133
+ if (part.kind === "crossing") return "crossing geometry is not modelled yet";
2134
+ if (part.kind === "curved-turnout")
2135
+ return "a curved turnout needs both radii AND its points/frog landmarks; only the radii are published";
2136
+ if (!part.pointsOffset)
2137
+ return "no points offset \u2014 without it there is nowhere for the diverging route to begin";
2138
+ if (!part.overallLength) return "no overall length \u2014 the part has no end to put a joint on";
2139
+ if (part.frogNumber == null) return "no frog number \u2014 the diverging angle is unknown";
2140
+ return null;
2141
+ }
2142
+ function partGeometry(part, library = BUILT_IN_TRACK_PARTS) {
2143
+ if (partGeometryGap(part)) return null;
2144
+ if (part.kind === "flex") {
2145
+ return {
2146
+ joints: [
2147
+ { id: "a", role: "throat", x: 0, y: 0, angleDeg: 180 },
2148
+ { id: "b", role: "through", x: 0, y: 0, angleDeg: 0 }
2149
+ ],
2150
+ routes: [["a", "b"]],
2151
+ source: "derived",
2152
+ divergingEndMeasured: false
2153
+ };
2154
+ }
2155
+ const N = part.frogNumber;
2156
+ const points = part.pointsOffset;
2157
+ const overall = part.overallLength;
2158
+ const frog = part.frogOffset;
2159
+ const lead = part.lead?.inches ?? (frog ? frog.inches - points.inches : void 0);
2160
+ if (lead == null || !(lead > 0)) return null;
2161
+ const isWye = part.kind === "wye";
2162
+ const effN = isWye ? N * 2 : N;
2163
+ const closure = turnoutClosure(effN, { leadInches: lead });
2164
+ const divergingEnd = () => {
2165
+ const frogX = frog ? frog.inches : points.inches + lead;
2166
+ const slope = closure.frogSlope;
2167
+ const dir = 1 / Math.hypot(1, slope);
2168
+ if (part.divergingLength) {
2169
+ const L = part.divergingLength.inches;
2170
+ return {
2171
+ x: frogX + L * dir,
2172
+ y: closure.offsetAt(frogX - points.inches) + L * slope * dir,
2173
+ measured: true
2174
+ };
2175
+ }
2176
+ return {
2177
+ x: overall.inches,
2178
+ y: closure.offsetAt(overall.inches - points.inches),
2179
+ measured: false
2180
+ };
2181
+ };
2182
+ const weakest = (...ds) => {
2183
+ const rank = ["measured", "manufacturer", "derived", "unverified"];
2184
+ let worst = 0;
2185
+ for (const d of ds) if (d) worst = Math.max(worst, rank.indexOf(d.source));
2186
+ return rank[worst];
2187
+ };
2188
+ const de = divergingEnd();
2189
+ const legAngle = Math.atan(closure.frogSlope) * 180 / Math.PI;
2190
+ if (isWye) {
2191
+ return {
2192
+ joints: [
2193
+ { id: "throat", role: "throat", x: 0, y: 0, angleDeg: 180 },
2194
+ { id: "legA", role: "diverge", x: de.x, y: de.y, angleDeg: legAngle },
2195
+ { id: "legB", role: "divergeB", x: de.x, y: -de.y, angleDeg: -legAngle }
2196
+ ],
2197
+ routes: [
2198
+ ["throat", "legA"],
2199
+ ["throat", "legB"]
2200
+ ],
2201
+ source: weakest(points, overall, frog, part.divergingLength),
2202
+ divergingEndMeasured: de.measured
2203
+ };
2204
+ }
2205
+ return {
2206
+ joints: [
2207
+ { id: "throat", role: "throat", x: 0, y: 0, angleDeg: 180 },
2208
+ { id: "through", role: "through", x: overall.inches, y: 0, angleDeg: 0 },
2209
+ { id: "diverge", role: "diverge", x: de.x, y: de.y, angleDeg: legAngle }
2210
+ ],
2211
+ routes: [
2212
+ ["throat", "through"],
2213
+ ["throat", "diverge"]
2214
+ ],
2215
+ source: weakest(points, overall, frog, part.divergingLength),
2216
+ divergingEndMeasured: de.measured
2217
+ };
2218
+ }
2219
+ function partsPlaceable(library = BUILT_IN_TRACK_PARTS) {
2220
+ const placeable = [];
2221
+ const blocked = [];
2222
+ for (const p of library) {
2223
+ const why = partGeometryGap(p);
2224
+ if (why) blocked.push({ part: p, why });
2225
+ else if (partGeometry(p, library)) placeable.push(p);
2226
+ else blocked.push({ part: p, why: "dimensions present but inconsistent" });
2227
+ }
2228
+ return { placeable, blocked };
2229
+ }
2129
2230
  function frogCasting(cl, opts = {}) {
2130
2231
  const g = opts.gaugeInches ?? RAIL_GAUGE_INCHES;
2131
2232
  const w = opts.reachInches ?? g * 1.5;
@@ -2705,6 +2806,6 @@ function poseOverridesFromDoc(doc) {
2705
2806
  return out;
2706
2807
  }
2707
2808
 
2708
- export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, MAIN2_TRACK_ID, MAIN_TRACK_ID, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, PINCH_EASE_INCHES, RAIL_GAUGE_INCHES, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partOutlineAtFrog, pastFrogInchesForSize, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity };
2809
+ export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, MAIN2_TRACK_ID, MAIN_TRACK_ID, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, PINCH_EASE_INCHES, RAIL_GAUGE_INCHES, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partGeometry, partGeometryGap, partOutlineAtFrog, partsPlaceable, pastFrogInchesForSize, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity };
2709
2810
  //# sourceMappingURL=index.js.map
2710
2811
  //# sourceMappingURL=index.js.map