Require a trace endpoint's pad to be on the same layer#166
Require a trace endpoint's pad to be on the same layer#166abdalraof-albarbar wants to merge 1 commit into
Conversation
aae93b9 to
ff51782
Compare
There was a problem hiding this comment.
Good call — I removed that snapshot. This is a verdict-only fix (the DRC now flags a trace endpoint whose pad is on a different layer), so the board render was byte-identical on both branches and the snapshot showed nothing to compare. The layer check is covered by the numeric test instead. Mind taking another look when you get a sec? 🙏
ff51782 to
b9add1a
Compare
|
that snapshot wasn't showing anything useful. It just rendered the board, which is identical whether the check passes or fails (the fix changes the check's result, not the geometry), so there was genuinely nothing to see in it. Removed it. The layer bug is covered by the assertion test instead — a top-layer wire endpoint on a bottom-layer pad now returns an error. @0hmX @seveibar |
b9add1a to
adf816a
Compare
There was a problem hiding this comment.
the fix looks valid; i am not sure i can approve this because i am not the code owner maybe @MustafaMulla29 can take a look he last edited this file
| isPointInPad({ x: lastPoint.x, y: lastPoint.y }, pad), | ||
| pads.some( | ||
| (pad) => | ||
| isPointInPad({ x: lastPoint.x, y: lastPoint.y }, pad) && |
There was a problem hiding this comment.
i do not think you need a new function isPointInPad should also check the layer
There was a problem hiding this comment.
Good call — folded the layer check into isPointInPad and removed the separate isPadOnLayer.
MustafaMulla29
left a comment
There was a problem hiding this comment.
you should first try to reproduce it with a snapshot test along with "shouldDrawErrors: true".
|
@MustafaMulla29 added a snapshot test rendered with |
MustafaMulla29
left a comment
There was a problem hiding this comment.
Repro should be merged first and then the solution
b555e1e to
59e8651
Compare
|
@MustafaMulla29 restructured as suggested: the repro (#165) now carries the |
|
|
||
| export function isPointInPad( | ||
| point: { x: number; y: number }, | ||
| point: { x: number; y: number; layer?: string }, |
There was a problem hiding this comment.
Layer can be a separate param, point is represented only with x an y
There was a problem hiding this comment.
Done — isPointInPad(point, pad, layer?) now takes layer as a separate param; point stays { x, y }. All call sites pass the endpoint's layer through.
MustafaMulla29
left a comment
There was a problem hiding this comment.
See comment and now just update the repro snapshot and remove this repro from pr.
checkTracesAreContiguous matched an endpoint to a pad by x/y only, so a top-layer wire endpoint counted as connected to a bottom-layer pad. Gate the match on layer: isPointInPad now takes the endpoint's layer as a separate param and rejects a pad on a different layer (smt pad -> its layer, plated hole -> its copper layers). Flips the repro tests from tscircuit#165 to passing and updates the shouldDrawErrors snapshot to show the now-flagged endpoint. Co-authored-by: abdalrouf-AAA <236259618+technologyet31-create@users.noreply.github.com>
59e8651 to
5831e27
Compare
|
@MustafaMulla29 addressed both points:
Diff is now just the lib fix + the snapshot update + the |
| point: { x: number; y: number }, | ||
| pad: PcbSmtPad | PcbPlatedHole, | ||
| layer?: string, | ||
| ): boolean { |
There was a problem hiding this comment.
See if we have a layer type we can import from circuit-json. Otherwise looks good
| const padIsOnLayer = | ||
| pad.type === "pcb_smtpad" | ||
| ? pad.layer === layer | ||
| : pad.layers.some((padLayer) => padLayer === layer) |
There was a problem hiding this comment.
Simplify this, remove ternary
Closes #167
Fixes the false negative from #165.
checkTracesAreContiguousmatched endpoints to pads by x/y only, so a top-layer wire endpoint was accepted as connected to a bottom-layer pad. Now eachisPointInPadcheck is gated by the endpoint's layer (SMT pad → its layer, plated hole → its copper layers). Legit via routes still pass since each endpoint lands on its own pad's layer; full suite stays green.