Skip to content

Conversation

@0hmX
Copy link
Contributor

@0hmX 0hmX commented Nov 27, 2025

How GapFillSubSolver Works

GapFillSubSolver operates as a post-processing cleanup algorithm that creates brand new rectangles to fill empty spaces left after the main RectDiff placement. It follows a four-stage process:

  1. SCAN: Detects uncovered areas using grid-based sweep-line algorithm, merging adjacent empty cells into maximal gap rectangles
  2. SELECT: Prioritizes gaps by size and multi-layer coverage, choosing the most valuable gap to fill next
  3. EXPAND: Places seed point at gap center and grows a rectangle outward until hitting existing rectangles, obstacles, or boundaries
  4. PLACE: Adds the successfully expanded rectangle to the solution as a new placement

Fundamental Difference from RectDiff

RectDiff solves the routing problem - it places rectangles to enable electrical signal connections based on circuit topology and routing requirements from SimpleRouteJson input.

GapFillSubSolver solves the coverage problem - it maximizes board area utilization by filling leftover empty spaces with new rectangles, regardless of routing needs.

RectDiff creates rectangles for electrical functionality (routing paths), while GapFillSubSolver creates rectangles for geometric efficiency (space utilization). They serve complementary but entirely different purposes in the placement pipeline: connectivity versus coverage optimization.

@vercel
Copy link

vercel bot commented Nov 27, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
rectdiff Ready Ready Preview Comment Nov 29, 2025 3:44am

@0hmX
Copy link
Contributor Author

0hmX commented Nov 27, 2025

The preview for this repo is broken by default https://rectdiff.tscircuit.com

* Maximizes board coverage by detecting uncovered areas and placing optimally-sized rectangles.
*
* ## How It Works
* 1. **Gap Detection**: Scans board to find uncovered rectangular regions, prioritizing larger gaps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whenever i see something like "scan", it's a hint that there's a very inefficient algorithm taking place- never iterate over X/Y coordinates because that is very expensive N^2 , this PR is massive so i'm not exactly sure how the scan works

@seveibar
Copy link
Contributor

@0hmX there is a big problem in that i can't understand the preview and the activeSubSolver isn't appearing so i don't know which phase is running

image

@seveibar
Copy link
Contributor

We really need to graphics-debug preview to work

@0hmX 0hmX mentioned this pull request Nov 28, 2025
@0hmX 0hmX merged commit 58de2db into main Nov 29, 2025
5 checks passed
@tscircuitbot
Copy link
Contributor


Thank you for your contribution! 🎉

PR Rating: ⭐⭐⭐
Impact: Major

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants