GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - tscircuit/rectdiff: An algorithm for subtracting 3d rects for the purpose of autorouting

BranchesTags
Open more actions menu

Latest commit

 

History

164 Commits
164 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
components
components
 
 
experiments
experiments
 
 
lib
lib
 
 
pages
pages
 
 
scripts
scripts
 
 
test-assets
test-assets
 
 
tests
tests
 
 
utils
utils
 
 
.gitignore
.gitignore
 
 
AGENTS.md
AGENTS.md
 
 
CLAUDE.md
CLAUDE.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
benchmark.sh
benchmark.sh
 
 
biome.json
biome.json
 
 
bunfig.toml
bunfig.toml
 
 
cosmos.config.json
cosmos.config.json
 
 
cosmos.decorator.tsx
cosmos.decorator.tsx
 
 
global.d.ts
global.d.ts
 
 
index.html
index.html
 
 
main.tsx
main.tsx
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 
vite.config.ts
vite.config.ts
 
 

Repository files navigation

@tscircuit/rectdiff

This is a 3D rectangle diffing algorithm made to quickly break apart a circuit board into capacity nodes for the purpose of global routing.

Online Demo

Usage

Basic Usage

import { RectDiffSolver } from "@tscircuit/rectdiff"
import type { SimpleRouteJson } from "@tscircuit/rectdiff"

// Define your circuit board layout
const simpleRouteJson: SimpleRouteJson = {
  bounds: {
    minX: 0,
    maxX: 10,
    minY: 0,
    maxY: 10,
  },
  obstacles: [
    {
      type: "rect",
      layers: ["top"],
      center: { x: 2.5, y: 2.5 },
      width: 2,
      height: 2,
      connectedTo: [],
    },
  ],
  connections: [],
  layerCount: 2,
  minTraceWidth: 0.15,
}

// Create and run the solver
const solver = new RectDiffSolver({
  simpleRouteJson,
  mode: "grid",
})

solver.solve()

// Get the capacity mesh nodes
const output = solver.getOutput()
console.log(`Generated ${output.meshNodes.length} capacity mesh nodes`)

// Each mesh node contains:
// - center: { x, y } - center point of the node
// - width, height - dimensions
// - availableZ - array of available z-layers (e.g., [0, 1, 2])

Advanced Configuration with Grid Options

const solver = new RectDiffSolver({
  simpleRouteJson,
  mode: "grid",
  gridOptions: {
    minSingle: { width: 0.4, height: 0.4 },
    minMulti: { width: 1.0, height: 1.0, minLayers: 2 },
    preferMultiLayer: true,
  },
})

solver.solve()

Incremental Solving with Visualization

The solver supports incremental solving for visualization and progress tracking:

const solver = new RectDiffSolver({ simpleRouteJson })

solver.setup()

// Step through the algorithm incrementally
while (!solver.solved) {
  solver.step()

  // Get current progress
  const progress = solver.computeProgress()
  console.log(`Progress: ${(progress * 100).toFixed(1)}%`)

  // Visualize current state
  const graphicsObject = solver.visualize()
  // Use graphicsObject with graphics-debug package
}

const output = solver.getOutput()

Working with Results

const output = solver.getOutput()

// Iterate through mesh nodes
for (const node of output.meshNodes) {
  console.log(`Node at (${node.center.x}, ${node.center.y})`)
  console.log(`  Size: ${node.width} x ${node.height}`)
  console.log(`  Available layers: ${node.availableZ?.join(", ") || "none"}`)

  // Use node for routing decisions
  if (node.availableZ && node.availableZ.length >= 2) {
    console.log("  This node spans multiple layers!")
  }
}

API Reference

Constructor Options

  • simpleRouteJson (required): The circuit board layout definition

    • bounds: Board boundaries (minX, maxX, minY, maxY)
    • obstacles: Array of rectangular obstacles on the board
    • connections: Connection requirements between points
    • layerCount: Number of layers in the board
    • minTraceWidth: Minimum trace width for routing
  • mode: "grid" | "exact" (default: "grid")

    • Currently only "grid" mode is implemented
  • gridOptions: Fine-tune the grid-based expansion algorithm

    • minSingle: Minimum dimensions for single-layer nodes
    • minMulti: Minimum dimensions and layer count for multi-layer nodes
    • preferMultiLayer: Whether to prefer multi-layer spanning nodes

Methods

  • setup(): Initialize the solver
  • step(): Execute one iteration step
  • solve(): Run solver to completion
  • computeProgress(): Get current progress (0.0 to 1.0)
  • getOutput(): Get the capacity mesh nodes result
  • visualize(): Get GraphicsObject for visualization with graphics-debug

About

An algorithm for subtracting 3d rects for the purpose of autorouting

rectdiff.tscircuit.com/

Resources

Readme
MIT license
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

5 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.