170 Commits

Author SHA1 Message Date
Seth Hillbrand
b207ec8817 Remove negative index access from CPoint
Callers should be responsible for index count and/or use iterators
2025-08-08 10:46:45 -07:00
Seth Hillbrand
4a41f4a525 Prevent overriding existing track width
Avoids resizing existing tracks to match new track.  Adds new parameter
to AssembleLine to allow current behavior while only preventing width
overrides when creating new lines

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20031
2025-04-29 17:51:31 -07:00
Jeff Young
144e660684 Treat changes in solder mask like a width change.
Also in theory keeps from losing tenting properties
on vias that are shoved, though I can't get via
shoving to work at all right now.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20085
2025-02-27 15:24:30 +00:00
Tomasz Wlostowski
95df6d8ef2 router: multiple fixes in shove algorithm:
- allow small modifications for LINE's ends as a fallback scenario in case of shove failure
- make sure unwindLineStack() won't remove tadpole vias with pending collisions on layer other than the current head line

fixes: https://gitlab.com/kicad/code/kicad/-/issues/19082
fixes: https://gitlab.com/kicad/code/kicad/-/issues/19045

(note to self: it often happens on boards imported from foreign tools of when the clearance has been subtly changed, the router would fail
if the start/end of a LINE is inside a hull of another LINE).
2025-01-04 20:03:24 +01:00
Seth Hillbrand
0b2d4d4879 Revise Copyright statement to align with TLF
Recommendation is to avoid using the year nomenclature as this
information is already encoded in the git repo.  Avoids needing to
repeatly update.

Also updates AUTHORS.txt from current repo with contributor names
2025-01-01 14:12:04 -08:00
Tomasz Wlostowski
7b6a344f45 router: provisional fix for crash when dragging footprints with exactly overlapping pad anchors
Fixes https://gitlab.com/kicad/code/kicad/issues/19382
2024-12-26 19:30:29 +01:00
Jon Evans
801311cf9c PNS: Fix several issues dragging footprints with shapes
Edge cuts, margin, and copper shapes need to be included
in the dragged item set

Shapes on the edge cut layer need to be painted with
their original width, but this has to be done by setting
the width on the router shape, not by re-cloning the
parent shape, because the router may now be moving that
shape.

Footprint drag position calculation needs to act only
on pad SOLIDs, not on any SOLID

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19280
2024-12-17 22:56:15 -05:00
Tomasz Wlostowski
55d5988430 router: fix rare assertion when adding a LINE to a NODE with duplicate segments 2024-11-06 23:23:23 +01:00
Jon Evans
d0b2334ceb PNS: Support via stacks 2024-11-04 21:30:38 -05:00
Tomasz Wlostowski
69210e684a router: move FindViaByHandle to NODE 2024-11-04 21:57:14 +01:00
Jon Evans
2d0e8c73d0 Fix crashes in qa_pns_regressions 2024-11-03 11:22:15 -05:00
Tomasz Wlostowski
e4ef642940 router: NODE::FindJoint() should also compare the matching joint's net/position. Another 'senior' bug in the P&S 2024-11-02 19:59:09 +01:00
Tomasz Wlostowski
5e77da4902 router: make a 'tadpole' via (via at the end of a LINE) linkable item 2024-11-02 19:59:09 +01:00
Tomasz Wlostowski
009e31d6df router: follow up with the changes to JOINT::NextSegment() 2024-11-02 19:59:08 +01:00
Tomasz Wlostowski
28927c713d router: when removing a JOINT completely (no links remaining) from a child node, insert a dummy one to prevent fallback to the root node
Private note: another "maladie de naissance", hopefully cured for good.
2024-11-02 19:59:08 +01:00
Tomasz Wlostowski
a6e111ec06 router: prevent double removal of a VIA/SOLID and its associated HOLE 2024-11-02 19:59:08 +01:00
Tomasz Wlostowski
76a0260d4a router: QueryColliding filter lambda should be applied in the obstacle visitor 2024-11-02 19:59:08 +01:00
Tomasz Wlostowski
fd502efffb router: ensure rebuildJoint() does not leave dangling root node (with incorrect links) joint in case the (overridden) joint has same hash value but different linked items. Probably the oldest bug in P&S, I can't stop wondering how it had worked reasonably well for so many years :D 2024-11-02 19:59:08 +01:00
Tomasz Wlostowski
b1c515b98a router: replace the restricted set in COLLISION_SEARCH_OPTION for a generic filter lambda 2024-11-02 19:59:08 +01:00
Seth Hillbrand
5e0abadb23 Reorganize layer numbering
F_Cu = 0
B_Cu = 2
Remaining internal copper layers are even and incrementing

Non-copper layers are odd and incrementing.

This means that we can no longer do things like:
for( PCB_LAYER_ID layer = F_Cu; layer <= B_Cu; ++layer)
Instead, we have the class LAYER_RANGE:
for( PCB_LAYER_ID layer : LAYER_RANGE( F_Cu, B_Cu) )

Similarly, gt/lt tests should not refer to the integer value of the
layer.  We have functions such as IsCopperLayer to test whether a layer
is copper or not.

When using the connectivity RTree, the third dimension is layer, so we
provide B_Cu with the special INT_MAX value, ensuring that elements
between F_Cu and B_Cu will be identified.  There is a new, special
function GetBoardLayer() for interfacing with CN_ITEMS

Similarly, PNS layers remain unchanged and sequential.  A set of
interface functions is provided to map PNS layers to Board layers and
back.  This allows the PNS_LAYER_RANGE to function as expected
2024-09-06 23:07:58 +00:00
Jeff Young
b8819b4636 Another reduction in asserts. 2024-07-19 22:11:56 +01:00
Seth Hillbrand
59f99d9a6a Re-add routine to remove duplicate points
The router needs to elimitate duplicate points but keep colinear
segments.  This re-creates the partial routine from the old Simplify()
function

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17582
2024-04-10 17:25:58 -07:00
Seth Hillbrand
5e850911c5 When dragging a via, we need to get all obstacles
The clearance epsilon should not be used to limit which force elements
we return in the query.  Otherwise, we can drag elements into a
DRC-violating space

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16293
2024-03-29 15:39:57 -07:00
Seth Hillbrand
b2a25cb59e Correct usage signature for PNS_NODE::Add()
When moving a unique_ptr, you are actually passing the object, not a
reference to the object.  So we either std::move with the bare
unique_ptr parameter or we pass a reference.  But we should never pass
an rvalue reference for this or we'll make a copy without holding the
tracking (because it was moved)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16839
2024-02-27 19:49:13 +00:00
Jeff Young
24846d3f44 Repair earlier fix for VVIAs. 2023-12-19 16:48:01 +00:00
Alex Shvartzkop
7abe2e3ea0 Restore clearance cache usage in PNS::NODE::NearestObstacle.
This (and the other commit) restores router performance to pre-7.0.3 levels.

(cherry-picked from commit 5e938142836990f485a64b70d85521c9dc2d80bf)
2023-11-07 23:25:53 +03:00
Wayne Stambaugh
6269453416 Coverity warning fixes. 2023-10-27 16:48:14 -04:00
Jeff Young
8d3a3419f8 Honour 90-degree router mode in a few more places.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/10421
2023-10-26 14:18:28 +01:00
Jeff Young
76cd637895 Make the net identifier opaque to PNS router.
This also improves performance as we don't have to look up the
netcodes in a map.
2023-08-22 15:17:02 +00:00
Tomasz Wlostowski
61391e3984 router: take holes into account when building the restricted items set for collision search 2023-06-23 14:52:45 +02:00
Tomasz Wlostowski
3667e4f6b2 router: correctly assign owner via/pad to its hole when committing the world state
fixes #14852
2023-06-08 11:57:23 +02:00
Jeff Young
3c8d2bfca5 Assertion checking for hole/parent ownership mismatch.
(This mismatch is the root of the problem in issue #14852.)
2023-06-02 18:30:16 +01:00
Tomasz Włostowski
3c3517cc36 router: can't add a clone of a VIA's hole when adding the via to INDEX - this will result in bogus colliding objects
This commit partially reverts deb3cbf8. VIA and SOLID operator='s introduced in it do a good job but the cloning of holes in addHole() causes bogus collisions.
2023-06-01 22:47:02 +02:00
Jeff Young
deb3cbf89b Prevent use-after-free crashes by not fighting over who owns a HOLE.
The diff-pair placer creates DIFF_PAIRs on the stack, which have
VIAs in them, which have HOLEs in them.  The HOLEs get put in the
NODE's index, and we then crash later when doing a collision after
the stack variable has gone out of scope.

The stack variable is also copied while doing a search for "best",
and without the operator= definitions the "best" and the "original"
both think they own the HOLE.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14852
2023-06-01 15:07:29 +01:00
Tomasz Wlostowski
7966126040 router: invalidate items freed by PNS::NODE in the clearance cache
This was causing intermittent shove hiccups/freezes as RULE_RESOLVER::GetClearance() could return a bogus clearance value, taking
a cached value for an item that does not exist anymore. If the allocator/stack accidentally reclaimed such item's address - we were getting
very nasty and difficult to reproduce misbehaviours of the shove algorithm. Hopefully this patch fixes this. More info in the comments.

Note to self - I'm still not fully convinced I want PNS::ITEM pointers as the cache key, probably a unique counter would be better here.
2023-06-01 00:01:15 +02:00
Jeff Young
2dcbc10a09 Performance optimization. 2023-05-08 11:46:04 +01:00
Jon Evans
b06f90335b PNS: Remove holes when removing items with holes
Related to https://gitlab.com/kicad/code/kicad/-/issues/14702
2023-05-07 22:12:11 -04:00
Lucas Dumont
a22e6db982 Add Zone when dragging component
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14629
2023-05-06 09:32:38 +00:00
Jeff Young
16e000f2b0 Use Net() accessor uniformly; init hole parent in VIA::Clone()
Fixes https://gitlab.com/kicad/code/kicad/issues/14603
2023-04-28 18:32:58 +01:00
Lucas Dumont
e2e901de1d Don't override clearance when routing
The default `m_overrideClearance = -1` used here was changed to 1.
Reseting it to -1 to solve linked issue

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14595
2023-04-25 09:18:53 +00:00
Seth Hillbrand
990641d2eb Cleanup printf bits 2023-04-20 15:19:04 -07:00
Jeff Young
ab0dbeb523 Post-holes-work cleanup. 2023-04-11 15:51:00 +01:00
Jeff Young
6f0d963683 Add PNS::ITEM::BoardItem() call.
About 1/3 of callers to Parent() don't care if they get the immediate
parent or not, about 1/3 want only the immediate parent, and about 1/3
want the hole parent's Parent().

I had earlier changed PNS::ITEM::HOLE to override Parent() and return
the hole parent's Parent(), but since the callers are pretty evenly
split I've reverted that and added BoardItem() for callers who want the
eventual BOARD_ITEM (whether a direct parent or a grandparent).

(Also removes a dead routine so I didn't have to figure out which of
the two it wanted....)
2023-04-11 15:51:00 +01:00
Jeff Young
b18bf09208 Don't return holes that have a parent pad or via.
(While we don't currently have holes without a parent pad or via, you
could imagine using HOLEs in the future to represent a hole in a first-class
board outline, so better not to build this assumption in.)
2023-04-11 15:51:00 +01:00
Jeff Young
4cc289c6fb Post-merge cleanup of holes-as-first-class-citizens. 2023-04-11 15:51:00 +01:00
Tomasz Wlostowski
d961cdce3f router: further changes to the ownership model
- LINEs now own their vias optionally (depending whether a LINE with its VIA belongs to a node)
- get rid of unique_ptr on the internal NODE::Add API (and also made it private)
- make sure stack pointers are not added to the node
- use rvalue reference for NODE::Add/NODE::Replace

Manually rebased by Jeff Young <jeff@rokeby.ie> 5 April 2023
2023-04-11 15:51:00 +01:00
Tomasz Wlostowski
bfbda978b8 router: hole as first class objects, wip
Rebased by Jeff Young <jeff@rokeby.ie> 5 April 2023

(Also includes a bug-fix for highlighting collisions with edge-cut
items.)
2023-04-11 15:51:00 +01:00
Tomasz Wlostowski
1283c4713f router: rework ITEM ownership model.
- prerequisite for holes as first class objects code
- introduced the OWNABLE_ITEM interface that defines the owning container (NODE/other ITEM/ITEM_SET)
- simplified the ITEM_SET interface
- constified a lot of APIs (ownership/JOINT management) as a side effect

Rebased and cleaned up by Jeff Young <jeff@rokeby.ie> 5 April 2023
- some STL cover types removed
2023-04-05 11:21:31 +01:00
Tomasz Wlostowski
eed05191a9 router: pass collision query options in a structure
Selectively cherry-picked by Jeff Young <jeff@rokeby.ie> 4 April 2023
- Jon's user-clearance-epsilon algo kept intact
- Jeff's castellated-pad code kept intact
2023-04-05 11:21:31 +01:00
Wayne Stambaugh
4e99812145 Coverity fixes and code cleaning. 2023-03-04 13:02:05 -05:00