@tscircuit/schematic-trace-solver 0.0.82 → 0.0.84

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.
@@ -20,8 +20,7 @@ import type {
20
20
  TracePathScore,
21
21
  } from "./types"
22
22
 
23
- const LABEL_SIDE_CLEARANCE = 0.1
24
- const LABEL_HUG_CLEARANCE = 0.001
23
+ const LABEL_CLEARANCE = 0.1
25
24
 
26
25
  export const findBestReroutePath = ({
27
26
  trace,
@@ -102,7 +101,7 @@ export const generateRerouteCandidateResults = ({
102
101
  trace,
103
102
  label,
104
103
  problem: inputProblem,
105
- paddingBuffer: LABEL_SIDE_CLEARANCE,
104
+ paddingBuffer: LABEL_CLEARANCE,
106
105
  detourCount: 0,
107
106
  }),
108
107
  ...generateEndpointDetourCandidates(trace, label),
@@ -188,9 +187,11 @@ const generateEndpointDetourCandidates = (
188
187
  const start = trace.tracePath[0]
189
188
  const end = trace.tracePath[trace.tracePath.length - 1]
190
189
  if (!start || !end) return []
190
+ const startExit = trace.tracePath[1] ?? start
191
+ const endEntry = trace.tracePath[trace.tracePath.length - 2] ?? end
191
192
 
192
193
  const bounds = getRectBounds(label.center, label.width, label.height)
193
- const padding = LABEL_SIDE_CLEARANCE
194
+ const padding = LABEL_CLEARANCE
194
195
  const labelDirection = dir(label.orientation)
195
196
  const labelSideX =
196
197
  labelDirection.x < 0 ? bounds.minX - padding : bounds.maxX + padding
@@ -204,18 +205,22 @@ const generateEndpointDetourCandidates = (
204
205
  candidates.push(
205
206
  [
206
207
  start,
207
- { x: start.x, y: topY },
208
+ startExit,
209
+ { x: startExit.x, y: topY },
208
210
  { x: sideX, y: topY },
209
211
  { x: sideX, y: bottomY },
210
- { x: end.x, y: bottomY },
212
+ { x: endEntry.x, y: bottomY },
213
+ endEntry,
211
214
  end,
212
215
  ],
213
216
  [
214
217
  start,
215
- { x: start.x, y: bottomY },
218
+ startExit,
219
+ { x: startExit.x, y: bottomY },
216
220
  { x: sideX, y: bottomY },
217
221
  { x: sideX, y: topY },
218
- { x: end.x, y: topY },
222
+ { x: endEntry.x, y: topY },
223
+ endEntry,
219
224
  end,
220
225
  ],
221
226
  )
@@ -231,6 +236,8 @@ const generateLabelHugCandidates = (
231
236
  const start = trace.tracePath[0]
232
237
  const end = trace.tracePath[trace.tracePath.length - 1]
233
238
  if (!start || !end) return []
239
+ const startExit = trace.tracePath[1] ?? start
240
+ const endEntry = trace.tracePath[trace.tracePath.length - 2] ?? end
234
241
 
235
242
  const labelDirection = dir(label.orientation)
236
243
  if (labelDirection.x === 0) return []
@@ -238,29 +245,33 @@ const generateLabelHugCandidates = (
238
245
  const bounds = getRectBounds(label.center, label.width, label.height)
239
246
  const sideX =
240
247
  labelDirection.x < 0
241
- ? bounds.minX - LABEL_SIDE_CLEARANCE
242
- : bounds.maxX + LABEL_SIDE_CLEARANCE
243
- const topY = bounds.maxY + LABEL_HUG_CLEARANCE
244
- const bottomY = bounds.minY - LABEL_HUG_CLEARANCE
245
- const startsAboveEnd = start.y >= end.y
248
+ ? bounds.minX - LABEL_CLEARANCE
249
+ : bounds.maxX + LABEL_CLEARANCE
250
+ const topY = bounds.maxY + LABEL_CLEARANCE
251
+ const bottomY = bounds.minY - LABEL_CLEARANCE
252
+ const startsAboveEnd = startExit.y >= endEntry.y
246
253
  const firstY = startsAboveEnd ? topY : bottomY
247
254
  const secondY = startsAboveEnd ? bottomY : topY
248
255
 
249
256
  return [
250
257
  [
251
258
  start,
252
- { x: start.x, y: firstY },
259
+ startExit,
260
+ { x: startExit.x, y: firstY },
253
261
  { x: sideX, y: firstY },
254
262
  { x: sideX, y: secondY },
255
- { x: end.x, y: secondY },
263
+ { x: endEntry.x, y: secondY },
264
+ endEntry,
256
265
  end,
257
266
  ],
258
267
  [
259
268
  start,
260
- { x: start.x, y: secondY },
269
+ startExit,
270
+ { x: startExit.x, y: secondY },
261
271
  { x: sideX, y: secondY },
262
272
  { x: sideX, y: firstY },
263
- { x: end.x, y: firstY },
273
+ { x: endEntry.x, y: firstY },
274
+ endEntry,
264
275
  end,
265
276
  ],
266
277
  ]
@@ -341,9 +352,9 @@ const generateHorizontalSegmentPushCandidate = (
341
352
  return null
342
353
  }
343
354
 
344
- let segmentPushX = bounds.minX - LABEL_SIDE_CLEARANCE
355
+ let segmentPushX = bounds.minX - LABEL_CLEARANCE
345
356
  if (labelDirection.x > 0) {
346
- segmentPushX = bounds.maxX + LABEL_SIDE_CLEARANCE
357
+ segmentPushX = bounds.maxX + LABEL_CLEARANCE
347
358
  }
348
359
  const segmentPushStartY = getClearedHorizontalY({
349
360
  start: previousAnchor,
@@ -393,10 +404,10 @@ const getClearedHorizontalY = ({
393
404
 
394
405
  const labelCenterY = (labelBounds.minY + labelBounds.maxY) / 2
395
406
  if (start.y >= labelCenterY) {
396
- return labelBounds.maxY + LABEL_HUG_CLEARANCE
407
+ return labelBounds.maxY + LABEL_CLEARANCE
397
408
  }
398
409
 
399
- return labelBounds.minY - LABEL_HUG_CLEARANCE
410
+ return labelBounds.minY - LABEL_CLEARANCE
400
411
  }
401
412
 
402
413
  const markSelectedCandidate = (
@@ -281,6 +281,7 @@ export class NetLabelTraceCollisionSolver extends BaseSolver {
281
281
  problem: this.inputProblem,
282
282
  paddingBuffer: PADDING_BUFFER,
283
283
  detourCount,
284
+ tracesToAvoidOverlapping: this.outputTraces,
284
285
  })
285
286
  }
286
287
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/schematic-trace-solver",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.82",
4
+ "version": "0.0.84",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "start": "cosmos",