@mark1russell7/layout-contract 0.3.6 → 0.3.7

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/README.md CHANGED
@@ -8,7 +8,7 @@ The package has one runtime dependency: `@mark1russell7/rigor-generators`, the h
8
8
 
9
9
  | Part | Exports |
10
10
  |---|---|
11
- | Geometry | `Point`, `Rect`, `Region`, `Side`, `Sides`, `Margin`, `marginSides`, `grow`, `boundsOf`, `regionArea`, `translate`, `overlapOf` |
11
+ | Geometry | `Point`, `Rect`, `Region`, `Side`, `Sides`, `Margin`, `marginSides`, `grow`, `boundsOf`, `regionArea`, `translate`, `overlapOf`, `segmentsCross`, `pointSegmentDistance` |
12
12
  | The shape kinds | `ShapeKind`, `SHAPE_KINDS`, `SHAPE_KIND_IDS`, `ShapeKindSpec`, `ShapeGeometry`, `DEFAULT_SHAPES`, `ShapeSupport`, `ShapeBound`, `RuleLevel`, `ShapeLevel`, `ShapeCheck`, `isShapeKind`, `shapeKindOf`, `shapeKindsOf`, `itemShapeOf`, `shapeKindProblem`, `shapesOf`, `ruleLevel`, `shapeLevel`, `shapeSupportProblems`, `boxArea`, `checkShapes` |
13
13
  | The input `layout-input/1` | `LayoutInput`, `LayoutBox` (`Item` for the packer), `Port`, `portPoint`, `LayoutEdge`, `LayoutContainer`, `Obstacle`, `LayoutCell`, `LayoutGenerator`, `PairGap`, `canonicalInput` |
14
14
  | The packer | `PackInput`, `PackLink`, `toPackInput`, `packLinks`, `Placement`, `PackOutput`, `StageTrace`, `applyPack` |
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as FAMILY_ANY_KIND, A as shapesOf, B as PackInputOptions, C as itemShapeOf, Ct as grow, D as shapeKindsOf, Dt as toRect, E as shapeKindProblem, Et as regionArea, F as LayoutEdge, G as packLinks, H as PairGap, I as LayoutGenerator, J as ClaimBreak, K as portPoint, L as LayoutInput, M as LayoutBox, N as LayoutCell, O as shapeLevel, Ot as toSizedRect, P as LayoutContainer, Q as Declares, R as Obstacle, S as isShapeKind, St as boundsOf, T as shapeKindOf, Tt as overlapOf, U as Port, V as PackLink, W as canonicalInput, X as CorpusSplit, Y as CorpusEntry, Z as DeclaredClaim, _ as ShapeKindSpec, _t as Region, a as MeasureSpec, at as checkDeclared, b as boxArea, bt as Sides, c as minEffectOf, ct as declaredClaimOf, d as SHAPE_KINDS, dt as leaveOneSeedOut, et as FamilyBy, f as SHAPE_KIND_IDS, ft as splitFileName, g as ShapeKind, gt as Rect, h as ShapeGeometry, ht as Point, i as JointMeasureId, it as SplitFold, j as Item, k as shapeSupportProblems, kt as translate, l as DEFAULT_SHAPES, lt as declaredCounts, m as ShapeCheck, mt as Margin, n as JOINT_MEASURES, nt as SPLIT_SCHEMA, o as Verdict, ot as checkSplit, p as ShapeBound, pt as splitFolds, q as toPackInput, r as JOINT_MOVED_MIN, rt as SplitCorpus, s as compareMeasure, st as corpusHashOf, t as Direction, tt as FamilyCell, u as RuleLevel, ut as familyOf, v as ShapeLevel, vt as SIDES, w as ruleLevel, wt as marginSides, x as checkShapes, xt as SizedRect, y as ShapeSupport, yt as Side, z as PackInput } from "./measures-WwacWhot.js";
1
+ import { $ as FAMILY_ANY_KIND, A as shapesOf, At as toSizedRect, B as PackInputOptions, C as itemShapeOf, Ct as grow, D as shapeKindsOf, Dt as regionArea, E as shapeKindProblem, Et as pointSegmentDistance, F as LayoutEdge, G as packLinks, H as PairGap, I as LayoutGenerator, J as ClaimBreak, K as portPoint, L as LayoutInput, M as LayoutBox, N as LayoutCell, O as shapeLevel, Ot as segmentsCross, P as LayoutContainer, Q as Declares, R as Obstacle, S as isShapeKind, St as boundsOf, T as shapeKindOf, Tt as overlapOf, U as Port, V as PackLink, W as canonicalInput, X as CorpusSplit, Y as CorpusEntry, Z as DeclaredClaim, _ as ShapeKindSpec, _t as Region, a as MeasureSpec, at as checkDeclared, b as boxArea, bt as Sides, c as minEffectOf, ct as declaredClaimOf, d as SHAPE_KINDS, dt as leaveOneSeedOut, et as FamilyBy, f as SHAPE_KIND_IDS, ft as splitFileName, g as ShapeKind, gt as Rect, h as ShapeGeometry, ht as Point, i as JointMeasureId, it as SplitFold, j as Item, jt as translate, k as shapeSupportProblems, kt as toRect, l as DEFAULT_SHAPES, lt as declaredCounts, m as ShapeCheck, mt as Margin, n as JOINT_MEASURES, nt as SPLIT_SCHEMA, o as Verdict, ot as checkSplit, p as ShapeBound, pt as splitFolds, q as toPackInput, r as JOINT_MOVED_MIN, rt as SplitCorpus, s as compareMeasure, st as corpusHashOf, t as Direction, tt as FamilyCell, u as RuleLevel, ut as familyOf, v as ShapeLevel, vt as SIDES, w as ruleLevel, wt as marginSides, x as checkShapes, xt as SizedRect, y as ShapeSupport, yt as Side, z as PackInput } from "./measures-C-Tuv8GU.js";
2
2
  /** The epsilon for the float compares in an engine. */
3
3
  export declare const EPS = 1e-6;
4
4
  /**
@@ -1152,5 +1152,5 @@ export declare const EDGES_STEP: CorpusStep;
1152
1152
  * The steps `container`, `obstacles` and `boxes` each have a stream of `stepRandom`. Each value is a whole number, so the family is `exact`.
1153
1153
  */
1154
1154
  export declare const RECT_SCATTERED: CorpusFamily<LayoutInput>;
1155
- export { ClaimBreak, CorpusEntry, CorpusSplit, DEFAULT_SHAPES, DeclaredClaim, Declares, Direction, FAMILY_ANY_KIND, FamilyBy, FamilyCell, Item, JOINT_MEASURES, JOINT_MOVED_MIN, JointMeasureId, LayoutBox, LayoutCell, LayoutContainer, LayoutEdge, LayoutGenerator, LayoutInput, Margin, MeasureSpec, Obstacle, PackInput, PackInputOptions, PackLink, PairGap, Point, Port, Rect, Region, RuleLevel, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, ShapeBound, ShapeCheck, ShapeGeometry, ShapeKind, ShapeKindSpec, ShapeLevel, ShapeSupport, Side, Sides, SizedRect, SplitCorpus, SplitFold, Verdict, boundsOf, boxArea, canonicalInput, checkDeclared, checkShapes, checkSplit, compareMeasure, corpusHashOf, declaredClaimOf, declaredCounts, familyOf, grow, isShapeKind, itemShapeOf, leaveOneSeedOut, marginSides, minEffectOf, overlapOf, packLinks, portPoint, regionArea, ruleLevel, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, splitFileName, splitFolds, toPackInput, toRect, toSizedRect, translate };
1155
+ export { ClaimBreak, CorpusEntry, CorpusSplit, DEFAULT_SHAPES, DeclaredClaim, Declares, Direction, FAMILY_ANY_KIND, FamilyBy, FamilyCell, Item, JOINT_MEASURES, JOINT_MOVED_MIN, JointMeasureId, LayoutBox, LayoutCell, LayoutContainer, LayoutEdge, LayoutGenerator, LayoutInput, Margin, MeasureSpec, Obstacle, PackInput, PackInputOptions, PackLink, PairGap, Point, Port, Rect, Region, RuleLevel, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, ShapeBound, ShapeCheck, ShapeGeometry, ShapeKind, ShapeKindSpec, ShapeLevel, ShapeSupport, Side, Sides, SizedRect, SplitCorpus, SplitFold, Verdict, boundsOf, boxArea, canonicalInput, checkDeclared, checkShapes, checkSplit, compareMeasure, corpusHashOf, declaredClaimOf, declaredCounts, familyOf, grow, isShapeKind, itemShapeOf, leaveOneSeedOut, marginSides, minEffectOf, overlapOf, packLinks, pointSegmentDistance, portPoint, regionArea, ruleLevel, segmentsCross, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, splitFileName, splitFolds, toPackInput, toRect, toSizedRect, translate };
1156
1156
  //# sourceMappingURL=index.d.ts.map
package/build/index.js CHANGED
@@ -151,6 +151,29 @@ function overlapOf(a, b) {
151
151
  y: Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y)
152
152
  };
153
153
  }
154
+ /** This function gives the cross product of `ab` and `ac`. The sign tells the side of `ab` that has `c`. */
155
+ function orient(a, b, c) {
156
+ return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
157
+ }
158
+ /** This function tells if two numbers have opposite signs. Zero and NaN give false, so a touch at an end does not count. */
159
+ function opposite(p, q) {
160
+ return p < 0 && q > 0 || p > 0 && q < 0;
161
+ }
162
+ /**
163
+ * This function tells if the segments `ab` and `cd` cross at one point inside both of them.
164
+ * Segments that only touch at an end, or that are collinear, do not cross. The test has no tolerance.
165
+ */
166
+ function segmentsCross(a, b, c, d) {
167
+ return opposite(orient(c, d, a), orient(c, d, b)) && opposite(orient(a, b, c), orient(a, b, d));
168
+ }
169
+ /** This function gives the shortest distance from `p` to the segment `ab`. A segment of length 0 is the point `a`. */
170
+ function pointSegmentDistance(p, a, b) {
171
+ const dx = b.x - a.x;
172
+ const dy = b.y - a.y;
173
+ const l2 = dx * dx + dy * dy;
174
+ const t = l2 === 0 ? 0 : Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / l2));
175
+ return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy));
176
+ }
154
177
  // src/shapes.ts
155
178
  /**
156
179
  * The declared shape kinds, in their order. Only `rect` has all of its geometry.
@@ -4452,6 +4475,6 @@ const RECT_SCATTERED = /* @__PURE__ */ Object.freeze({
4452
4475
  };
4453
4476
  }
4454
4477
  });
4455
- export { BALANCE_MEASURE_SUFFIXES, BALANCE_SIDE_DEPTH, CORPUS_DIMENSIONS, DEFAULT_FAMILY_BY, DEFAULT_RNG, DEFAULT_SHAPES, DEFAULT_TOLERANCE, EDGES_STEP, EDGE_DENSITY, EDGE_STEP_VERSION, EPS, FAMILY_ANY_KIND, INVALIDATED_FIELD, JOINT_MEASURES, JOINT_MOVED_MIN, PACK_HARD_RULES, RECORD_EPS, RECORD_SCALE, RECT_SCATTERED, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, STRATEGY_SPACE_SCHEMA, VERDICT_DRAWS, VERDICT_EXACT_CAP, VERDICT_EXACT_MAX, VERDICT_RUNS, VERDICT_SEED, applyPack, balanceMeasureSpecs, balanceMeasures, balanceOf, boundsOf, boxArea, canonicalConfig, canonicalInput, canonicalJson, checkConfig, checkDeclared, checkInput, checkLayoutRecord, checkShapes, checkSpace, checkSplit, compareMeasure, composeFamily, configId, corpusHashOf, countObstacleHits, countOutside, countOverlaps, countPortsOffBorder, createFamilyRegistry, declaredClaimOf, declaredCounts, dimensionAt, dimensionSupports, dimensionUnit, documentHash, edgeStep, enumerateSpace, exercised, familyKind, familyOf, fnv1a32, grow, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, levelsOf, marginSides, minEffectOf, mulberry32, nearestGaps, outputGroups, outputHash, overlapOf, ownerDimension, packHard, packLinks, paramActive, paramLevels, paramProblem, paramValue, parseLayoutRecord, perChange, pickMoves, placedRect, portPoint, portfolio, procrustesOf, productSpace, randomInt, rectInRegion, regionArea, regionHitsRect, resolveDimensions, ruleLevel, selectBest, sha256Hex, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, sharedDimension, spaceShapeKinds, spaceSize, splitConfig, splitFileName, splitFolds, stepRandom, toLayoutRecord, toPackInput, toRect, toSizedRect, translate, turnBox, turnMargin, turnPoint, turnPort, turnRegion, turnSide, verdict };
4478
+ export { BALANCE_MEASURE_SUFFIXES, BALANCE_SIDE_DEPTH, CORPUS_DIMENSIONS, DEFAULT_FAMILY_BY, DEFAULT_RNG, DEFAULT_SHAPES, DEFAULT_TOLERANCE, EDGES_STEP, EDGE_DENSITY, EDGE_STEP_VERSION, EPS, FAMILY_ANY_KIND, INVALIDATED_FIELD, JOINT_MEASURES, JOINT_MOVED_MIN, PACK_HARD_RULES, RECORD_EPS, RECORD_SCALE, RECT_SCATTERED, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, STRATEGY_SPACE_SCHEMA, VERDICT_DRAWS, VERDICT_EXACT_CAP, VERDICT_EXACT_MAX, VERDICT_RUNS, VERDICT_SEED, applyPack, balanceMeasureSpecs, balanceMeasures, balanceOf, boundsOf, boxArea, canonicalConfig, canonicalInput, canonicalJson, checkConfig, checkDeclared, checkInput, checkLayoutRecord, checkShapes, checkSpace, checkSplit, compareMeasure, composeFamily, configId, corpusHashOf, countObstacleHits, countOutside, countOverlaps, countPortsOffBorder, createFamilyRegistry, declaredClaimOf, declaredCounts, dimensionAt, dimensionSupports, dimensionUnit, documentHash, edgeStep, enumerateSpace, exercised, familyKind, familyOf, fnv1a32, grow, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, levelsOf, marginSides, minEffectOf, mulberry32, nearestGaps, outputGroups, outputHash, overlapOf, ownerDimension, packHard, packLinks, paramActive, paramLevels, paramProblem, paramValue, parseLayoutRecord, perChange, pickMoves, placedRect, pointSegmentDistance, portPoint, portfolio, procrustesOf, productSpace, randomInt, rectInRegion, regionArea, regionHitsRect, resolveDimensions, ruleLevel, segmentsCross, selectBest, sha256Hex, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, sharedDimension, spaceShapeKinds, spaceSize, splitConfig, splitFileName, splitFolds, stepRandom, toLayoutRecord, toPackInput, toRect, toSizedRect, translate, turnBox, turnMargin, turnPoint, turnPort, turnRegion, turnSide, verdict };
4456
4479
 
4457
4480
  //# sourceMappingURL=index.js.map