@tscircuit/rectdiff 0.0.33 → 0.0.35

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 (36) hide show
  1. package/components/SolverDebugger3d.tsx +64 -10
  2. package/lib/RectDiffPipeline.ts +23 -0
  3. package/lib/fixtures/twoNodeExpansionFixture.ts +1 -1
  4. package/lib/solvers/GapFillSolver/ExpandEdgesToEmptySpaceSolver.ts +2 -2
  5. package/lib/solvers/GapFillSolver/FindSegmentsWithAdjacentEmptySpaceSolver.ts +1 -1
  6. package/lib/solvers/GapFillSolver/GapFillSolverPipeline.ts +2 -2
  7. package/lib/solvers/OuterLayerContainmentMergeSolver/OuterLayerContainmentMergeSolver.ts +311 -0
  8. package/lib/solvers/RectDiffExpansionSolver/RectDiffExpansionSolver.ts +5 -2
  9. package/lib/solvers/RectDiffGridSolverPipeline/RectDiffGridSolverPipeline.ts +8 -5
  10. package/lib/solvers/RectDiffGridSolverPipeline/buildObstacleIndexes.ts +6 -6
  11. package/lib/solvers/RectDiffSeedingSolver/RectDiffSeedingSolver.ts +4 -4
  12. package/lib/solvers/RectDiffSeedingSolver/computeCandidates3D.ts +1 -1
  13. package/lib/solvers/RectDiffSeedingSolver/computeEdgeCandidates3D.ts +1 -1
  14. package/lib/solvers/RectDiffSeedingSolver/longestFreeSpanAroundZ.ts +1 -1
  15. package/lib/types/capacity-mesh-types.ts +1 -1
  16. package/lib/types/srj-types.ts +1 -0
  17. package/lib/utils/expandRectFromSeed.ts +1 -1
  18. package/lib/utils/finalizeRects.ts +1 -1
  19. package/lib/utils/isFullyOccupiedAtPoint.ts +1 -1
  20. package/lib/utils/isSelfRect.ts +1 -1
  21. package/lib/utils/rectToTree.ts +2 -2
  22. package/lib/utils/renderObstacleClearance.ts +1 -1
  23. package/lib/utils/resizeSoftOverlaps.ts +1 -1
  24. package/lib/utils/sameTreeRect.ts +1 -1
  25. package/lib/utils/searchStrip.ts +1 -1
  26. package/lib/utils/z-filter.ts +43 -0
  27. package/package.json +6 -2
  28. package/tests/solver/arduino-uno-inner2-ground-bottom-power/__snapshots__/arduino-uno-inner2-ground-bottom-power.snap.svg +1 -1
  29. package/tests/solver/arduino-uno-inner2-ground-inner1-power/__snapshots__/arduino-uno-inner2-ground-inner1-power.snap.svg +3 -3
  30. package/tests/solver/bugreport08-e3ec95/__snapshots__/bugreport08-e3ec95.snap.svg +1 -1
  31. package/tests/solver/bugreport22-2a75ce/__snapshots__/bugreport22-2a75ce.snap.svg +1 -1
  32. package/tests/solver/bugreport24-05597c/__snapshots__/bugreport24-05597c.snap.svg +1 -1
  33. package/tests/solver/repros/merge-single-layer-node/__snapshots__/merge-single-layer-node.snap.svg +44 -0
  34. package/tests/z-filter.test.ts +33 -0
  35. package/dist/index.d.ts +0 -381
  36. package/dist/index.js +0 -2764
@@ -3,7 +3,7 @@ import { EPS, distancePointToRectEdges } from "../../utils/rectdiff-geometry"
3
3
  import { isFullyOccupiedAtPoint } from "../../utils/isFullyOccupiedAtPoint"
4
4
  import { longestFreeSpanAroundZ } from "./longestFreeSpanAroundZ"
5
5
  import type RBush from "rbush"
6
- import type { RTreeRect } from "lib/types/capacity-mesh-types"
6
+ import type { RTreeRect } from "../../types/capacity-mesh-types"
7
7
  const quantize = (value: number, precision = 1e-6) =>
8
8
  Math.round(value / precision) * precision
9
9
 
@@ -1,4 +1,4 @@
1
- import type { RTreeRect } from "lib/types/capacity-mesh-types"
1
+ import type { RTreeRect } from "../../types/capacity-mesh-types"
2
2
  import type { XYRect } from "../../rectdiff-types"
3
3
  import { clamp, containsPoint } from "../../utils/rectdiff-geometry"
4
4
  import type RBush from "rbush"
@@ -1,4 +1,4 @@
1
- import type { XYRect } from "lib/rectdiff-types"
1
+ import type { XYRect } from "../rectdiff-types"
2
2
 
3
3
  export type CapacityMeshNodeId = string
4
4
 
@@ -19,6 +19,7 @@ export interface Obstacle {
19
19
  height: number
20
20
  connectedTo: TraceId[]
21
21
  netIsAssignable?: boolean
22
+ isCopperPour?: boolean
22
23
  offBoardConnectsTo?: TraceId[]
23
24
  }
24
25
 
@@ -1,7 +1,7 @@
1
1
  import type RBush from "rbush"
2
2
  import type { XYRect } from "../rectdiff-types"
3
3
  import { EPS, gt, gte, lt, lte, overlaps } from "./rectdiff-geometry"
4
- import type { RTreeRect } from "lib/types/capacity-mesh-types"
4
+ import type { RTreeRect } from "../types/capacity-mesh-types"
5
5
  import { isSelfRect } from "./isSelfRect"
6
6
  import {
7
7
  searchStripDown,
@@ -1,4 +1,4 @@
1
- import type { Obstacle } from "lib/types/srj-types"
1
+ import type { Obstacle } from "../types/srj-types"
2
2
  import type { Placed3D, Rect3d, XYRect } from "../rectdiff-types"
3
3
  import {
4
4
  obstacleToXYRect,
@@ -1,4 +1,4 @@
1
- import type { RTreeRect } from "lib/types/capacity-mesh-types"
1
+ import type { RTreeRect } from "../types/capacity-mesh-types"
2
2
  import RBush from "rbush"
3
3
 
4
4
  export type OccupancyParams = {
@@ -1,4 +1,4 @@
1
- import type { XYRect } from "lib/rectdiff-types"
1
+ import type { XYRect } from "../rectdiff-types"
2
2
 
3
3
  const EPS = 1e-9
4
4
 
@@ -1,5 +1,5 @@
1
- import type { XYRect } from "lib/rectdiff-types"
2
- import type { RTreeRect } from "lib/types/capacity-mesh-types"
1
+ import type { XYRect } from "../rectdiff-types"
2
+ import type { RTreeRect } from "../types/capacity-mesh-types"
3
3
 
4
4
  export const rectToTree = (
5
5
  rect: XYRect,
@@ -1,4 +1,4 @@
1
- import type { SimpleRouteJson } from "lib/types/srj-types"
1
+ import type { SimpleRouteJson } from "../types/srj-types"
2
2
  import type { GraphicsObject } from "graphics-debug"
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { RTreeRect } from "lib/types/capacity-mesh-types"
1
+ import type { RTreeRect } from "../types/capacity-mesh-types"
2
2
  import type { Placed3D } from "../rectdiff-types"
3
3
  import { overlaps, subtractRect2D, EPS } from "./rectdiff-geometry"
4
4
  import type RBush from "rbush"
@@ -1,4 +1,4 @@
1
- import type { RTreeRect } from "lib/types/capacity-mesh-types"
1
+ import type { RTreeRect } from "../types/capacity-mesh-types"
2
2
 
3
3
  export const sameTreeRect = (a: RTreeRect, b: RTreeRect) =>
4
4
  a.minX === b.minX &&
@@ -1,4 +1,4 @@
1
- import type { XYRect } from "lib/rectdiff-types"
1
+ import type { XYRect } from "../rectdiff-types"
2
2
 
3
3
  export const searchStripRight = ({
4
4
  rect,
@@ -0,0 +1,43 @@
1
+ export function normalizeZValues(zValues: number[]): number[] {
2
+ return [...new Set(zValues)].sort((a, b) => a - b)
3
+ }
4
+
5
+ export function parseZFilterInput(input: string): number[] | null {
6
+ const zValues: number[] = []
7
+ let current = ""
8
+
9
+ for (const char of input) {
10
+ if (char >= "0" && char <= "9") {
11
+ current += char
12
+ continue
13
+ }
14
+
15
+ if (char === "," || char === " " || char === "\t" || char === "\n") {
16
+ if (char === ",") {
17
+ if (current === "") return null
18
+ zValues.push(Number(current))
19
+ current = ""
20
+ }
21
+ continue
22
+ }
23
+
24
+ return null
25
+ }
26
+
27
+ if (current !== "") zValues.push(Number(current))
28
+ if (zValues.length === 0) return null
29
+
30
+ return normalizeZValues(zValues)
31
+ }
32
+
33
+ export function matchesExactZFilter(
34
+ zValues: number[],
35
+ selectedZValues: number[] | null,
36
+ ): boolean {
37
+ if (!selectedZValues) return true
38
+
39
+ const normalized = normalizeZValues(zValues)
40
+ if (normalized.length !== selectedZValues.length) return false
41
+
42
+ return normalized.every((z, index) => z === selectedZValues[index])
43
+ }
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@tscircuit/rectdiff",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "type": "module",
5
- "main": "dist/index.js",
5
+ "main": "lib/index.ts",
6
+ "types": "lib/index.ts",
7
+ "exports": {
8
+ ".": "./lib/index.ts"
9
+ },
6
10
  "scripts": {
7
11
  "start": "cosmos",
8
12
  "build": "tsup-node ./lib/index.ts --format esm --dts",