@tscircuit/rectdiff 0.0.9 → 0.0.11

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 (30) hide show
  1. package/dist/index.d.ts +97 -12
  2. package/dist/index.js +714 -81
  3. package/lib/RectDiffPipeline.ts +79 -13
  4. package/lib/solvers/GapFillSolver/ExpandEdgesToEmptySpaceSolver.ts +284 -0
  5. package/lib/solvers/GapFillSolver/FindSegmentsWithAdjacentEmptySpaceSolver.ts +213 -0
  6. package/lib/solvers/GapFillSolver/GapFillSolverPipeline.ts +129 -0
  7. package/lib/solvers/GapFillSolver/edge-constants.ts +48 -0
  8. package/lib/solvers/GapFillSolver/getBoundsFromCorners.ts +10 -0
  9. package/lib/solvers/GapFillSolver/projectToUncoveredSegments.ts +92 -0
  10. package/lib/solvers/GapFillSolver/visuallyOffsetLine.ts +32 -0
  11. package/lib/solvers/RectDiffSolver.ts +1 -33
  12. package/package.json +9 -6
  13. package/tests/board-outline.test.ts +1 -1
  14. package/tsconfig.json +4 -0
  15. package/vite.config.ts +6 -0
  16. package/lib/solvers/rectdiff/gapfill/detection/deduplicateGaps.ts +0 -28
  17. package/lib/solvers/rectdiff/gapfill/detection/findAllGaps.ts +0 -83
  18. package/lib/solvers/rectdiff/gapfill/detection/findGapsOnLayer.ts +0 -100
  19. package/lib/solvers/rectdiff/gapfill/detection/mergeUncoveredCells.ts +0 -75
  20. package/lib/solvers/rectdiff/gapfill/detection.ts +0 -3
  21. package/lib/solvers/rectdiff/gapfill/engine/addPlacement.ts +0 -27
  22. package/lib/solvers/rectdiff/gapfill/engine/calculateCoverage.ts +0 -44
  23. package/lib/solvers/rectdiff/gapfill/engine/findUncoveredPoints.ts +0 -43
  24. package/lib/solvers/rectdiff/gapfill/engine/getGapFillProgress.ts +0 -42
  25. package/lib/solvers/rectdiff/gapfill/engine/initGapFillState.ts +0 -57
  26. package/lib/solvers/rectdiff/gapfill/engine/stepGapFill.ts +0 -128
  27. package/lib/solvers/rectdiff/gapfill/engine/tryExpandGap.ts +0 -78
  28. package/lib/solvers/rectdiff/gapfill/engine.ts +0 -7
  29. package/lib/solvers/rectdiff/gapfill/types.ts +0 -60
  30. package/lib/solvers/rectdiff/subsolvers/GapFillSubSolver.ts +0 -253
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- import * as _tscircuit_solver_utils from '@tscircuit/solver-utils';
2
- import { BaseSolver, BasePipelineSolver } from '@tscircuit/solver-utils';
1
+ import { BaseSolver, BasePipelineSolver, PipelineStep } from '@tscircuit/solver-utils';
3
2
  import { GraphicsObject } from 'graphics-debug';
3
+ import Flatbush from 'flatbush';
4
+ import RBush from 'rbush';
5
+ import { Bounds } from '@tscircuit/math-utils';
4
6
 
5
7
  type TraceId = string;
6
8
  interface SimpleRouteJson {
@@ -107,32 +109,115 @@ declare class RectDiffSolver extends BaseSolver {
107
109
  getOutput(): {
108
110
  meshNodes: CapacityMeshNode[];
109
111
  };
110
- /** Get coverage percentage (0-1). */
111
- getCoverage(sampleResolution?: number): number;
112
- /** Find uncovered points for debugging gaps. */
113
- getUncoveredPoints(sampleResolution?: number): Array<{
114
- x: number;
115
- y: number;
116
- z: number;
117
- }>;
118
112
  /** Get color based on z layer for visualization. */
119
113
  private getColorForZLayer;
120
114
  /** Streaming visualization: board + obstacles + current placements. */
121
115
  visualize(): GraphicsObject;
122
116
  }
123
117
 
118
+ interface SegmentWithAdjacentEmptySpace {
119
+ parent: CapacityMeshNode;
120
+ start: {
121
+ x: number;
122
+ y: number;
123
+ };
124
+ end: {
125
+ x: number;
126
+ y: number;
127
+ };
128
+ z: number;
129
+ facingDirection: "x+" | "x-" | "y+" | "y-";
130
+ }
131
+ /**
132
+ * Find edges with adjacent empty space in the mesh
133
+ *
134
+ * Do this by iterating over each edge of the rect (each step is one edge)
135
+ * and checking if the is completely covered by any other edge
136
+ *
137
+ * If it is completely covered, then it doesn't have an adjacent empty space,
138
+ * continue
139
+ *
140
+ * If it is partially uncovered, then divide it into uncovered segments and add
141
+ * each uncovered segment as a new edge with an adjacent empty space
142
+ */
143
+ declare class FindSegmentsWithAdjacentEmptySpaceSolver extends BaseSolver {
144
+ private input;
145
+ allEdges: Array<SegmentWithAdjacentEmptySpace>;
146
+ unprocessedEdges: Array<SegmentWithAdjacentEmptySpace>;
147
+ segmentsWithAdjacentEmptySpace: Array<SegmentWithAdjacentEmptySpace>;
148
+ edgeSpatialIndex: Flatbush;
149
+ lastCandidateEdge: SegmentWithAdjacentEmptySpace | null;
150
+ lastOverlappingEdges: Array<SegmentWithAdjacentEmptySpace> | null;
151
+ lastUncoveredSegments: Array<SegmentWithAdjacentEmptySpace> | null;
152
+ constructor(input: {
153
+ meshNodes: CapacityMeshNode[];
154
+ });
155
+ _step(): void;
156
+ getOutput(): {
157
+ segmentsWithAdjacentEmptySpace: Array<SegmentWithAdjacentEmptySpace>;
158
+ };
159
+ visualize(): Required<GraphicsObject>;
160
+ }
161
+
162
+ interface ExpandedSegment {
163
+ segment: SegmentWithAdjacentEmptySpace;
164
+ newNode: CapacityMeshNode;
165
+ }
166
+ declare class ExpandEdgesToEmptySpaceSolver extends BaseSolver {
167
+ private input;
168
+ unprocessedSegments: Array<SegmentWithAdjacentEmptySpace>;
169
+ expandedSegments: Array<ExpandedSegment>;
170
+ lastSegment: SegmentWithAdjacentEmptySpace | null;
171
+ lastSearchBounds: Bounds | null;
172
+ lastCollidingNodes: CapacityMeshNode[] | null;
173
+ lastSearchCorner1: {
174
+ x: number;
175
+ y: number;
176
+ } | null;
177
+ lastSearchCorner2: {
178
+ x: number;
179
+ y: number;
180
+ } | null;
181
+ lastExpandedSegment: ExpandedSegment | null;
182
+ rectSpatialIndex: RBush<CapacityMeshNode>;
183
+ constructor(input: {
184
+ inputMeshNodes: CapacityMeshNode[];
185
+ segmentsWithAdjacentEmptySpace: Array<SegmentWithAdjacentEmptySpace>;
186
+ });
187
+ _step(): void;
188
+ getOutput(): {
189
+ expandedSegments: ExpandedSegment[];
190
+ };
191
+ visualize(): Required<GraphicsObject>;
192
+ }
193
+
194
+ declare class GapFillSolverPipeline extends BasePipelineSolver<{
195
+ meshNodes: CapacityMeshNode[];
196
+ }> {
197
+ findSegmentsWithAdjacentEmptySpaceSolver?: FindSegmentsWithAdjacentEmptySpaceSolver;
198
+ expandEdgesToEmptySpaceSolver?: ExpandEdgesToEmptySpaceSolver;
199
+ pipelineDef: PipelineStep<any>[];
200
+ getOutput(): {
201
+ outputNodes: CapacityMeshNode[];
202
+ };
203
+ initialVisualize(): GraphicsObject;
204
+ finalVisualize(): GraphicsObject;
205
+ }
206
+
124
207
  interface RectDiffPipelineInput {
125
208
  simpleRouteJson: SimpleRouteJson;
126
209
  gridOptions?: Partial<GridFill3DOptions>;
127
210
  }
128
211
  declare class RectDiffPipeline extends BasePipelineSolver<RectDiffPipelineInput> {
129
212
  rectDiffSolver?: RectDiffSolver;
130
- pipelineDef: _tscircuit_solver_utils.PipelineStep<RectDiffSolver>[];
213
+ gapFillSolver?: GapFillSolverPipeline;
214
+ pipelineDef: PipelineStep<any>[];
131
215
  getConstructorParams(): RectDiffPipelineInput[];
132
216
  getOutput(): {
133
217
  meshNodes: CapacityMeshNode[];
134
218
  };
135
- visualize(): GraphicsObject;
219
+ initialVisualize(): GraphicsObject;
220
+ finalVisualize(): GraphicsObject;
136
221
  }
137
222
 
138
223
  export { RectDiffPipeline, type RectDiffPipelineInput };