Commit Graph

102 Commits

Author SHA1 Message Date
Jeff Young b76ef8c7e2 Multi-threading safety.
(Possible fix for KICAD-74.)
2023-04-16 15:36:21 +01:00
Jeff Young d6dd58fff9 Keep track of single-pad-islands so we can discount spokes to them. 2023-03-25 10:44:46 +00:00
Seth Hillbrand 6fb9d190ac Use the common subset of nets for local update
When adding new data, we may have differing sizes of the dynamic
ratsnest and our local copy, so ensure that we are only referencing
elements that exist in both
2023-02-10 12:50:29 -08:00
Seth Hillbrand dde336ee40 Split connectivity mutex locking
Internal routines have no need for locking the mutex they already own.
While external routines that want to recalculate the Ratsnest do need an
exclusive lock before being allowed access

Fixes https://gitlab.com/kicad/code/kicad/issues/13011
2023-02-03 15:26:19 +01:00
Seth Hillbrand a0236113da Attempt fix to RATSNEST crash
We call 'RecalculateRatsnest' in multiple locations, this will
invalidate various pointers needed by VIEW::Redraw().  When this is
called through the normal connectivity routines, we have the mutex
locked to prevent conflict but we've added more locations that update
just the Ratsnest.  The std::adopt_lock should take over the existing
lock when needed

Fixes https://gitlab.com/kicad/code/kicad/issues/13011
2023-01-26 17:32:38 -08:00
Seth Hillbrand e713a3eac2 Handle cleanup safely
Make sure that the connectivity has successfully completed before
attempting to merge segments.  Also avoids reaching into the shared_ptr
if we don't need to

Fixes https://gitlab.com/kicad/code/kicad/issues/13639
2023-01-23 15:56:46 -08:00
Jeff Young 509b39e9e4 Propagate nets within non-conflicting clusters immediately.
Fixes https://gitlab.com/kicad/code/kicad/issues/13601
2023-01-23 16:25:29 +00:00
Jeff Young e916b715d5 Special case for very-short tracks was killing both-ends-in-a-zone.
(And doing so randomly as if the closer endpoint to the zone center
was the one without a pad then it would get marked as good, while if
it was the other way around we'd notch 2 connections for the pad end
and none for the other end.)

Fixes https://gitlab.com/kicad/code/kicad/issues/13420
2023-01-09 13:35:54 +00:00
Seth Hillbrand 66e9d5c61c Return reference rather than copy
No need to return a const copy by default in GetItems().  The const
reference will be faster.  Thanks to @GyrosGeier for the suggestion
2022-12-16 10:52:57 -08:00
Seth Hillbrand f9a36b9c91 Update thread_pool to 3.3
Fixes an issue with `wait_for_tasks()` and adds a lower-overhead
`push_loop` helper.  We replace our usage of `parallelize_loop` with
`push_loop` as we didn't use the multi-future vector return and don't
need the extra overhead.
2022-12-02 12:01:34 -08:00
Jeff Young 19eab62516 More safety around ratsnest state.
Fixes https://gitlab.com/kicad/code/kicad/issues/13011
2022-11-30 13:00:21 +00:00
Jeff Young 226529235c Mostly const safety, but also performance opt. by avoiding shared_ptr overhead. 2022-11-22 12:21:30 +00:00
Jeff Young 11130bfd88 Backing out earlier fix in favour of fixing std::shared_ptr usage.
Assigning to a reference to a std::shared_ptr does not update the
reference to a different std::shared_ptr; it changes what the
std::shared_ptr points to.

Fixes https://gitlab.com/kicad/code/kicad/issues/12968
2022-11-21 21:56:17 +00:00
Jeff Young 106508f266 Split ratsnest optimization into separate parallel threads.
Fixes https://gitlab.com/kicad/code/kicad/issues/12968
2022-11-21 18:50:44 +00:00
Jeff Young 437d2c4589 Overhaul of remove-unconnected's zone filling and drawing strategies.
1) The highest priority zone that a via/pad collides with "owns" its
connectivity state.  Once set, lower priority zones cannot change it --
and in fact, if they would have connected to it are forced not to.

2) The connectivity state goes with the zone fill state, and therefore
must be saved in the file.

3) Display of remove-unconnected's pads is no longer done in GetViewLOD()
(which isn't called for selected items), and is instead done in PCB_PAINTER.
This allows us to draw the full pad in outline mode when a via/pad is
selected which would otherwise only show the hole.

4) Note that in some cases this will still generate DRC errors -- in
particular when a via nearly collides with a higher priority zone it
won't get "owned" by that zone and may therefore have insufficient
clearance if said zone concludes it's unconnected and a subsequent
(lower priority) zone connects to it (causing it to now become flashed).

Fixes https://gitlab.com/kicad/code/kicad/issues/11299
2022-10-18 13:05:42 +01:00
Seth Hillbrand 87171f53c7 Speedup dynamic ratsnest
Removes some unneeded calculations and threads the remaining.

Threading was previously removed to avoid overhead issues with small
boards.  This is no longer needed with the thread pool implementation

Fixes https://gitlab.com/kicad/code/kicad/issues/12131
2022-10-04 17:06:45 -07:00
Seth Hillbrand 15d52c91e4 Clear ratsnest when removing nets
While we can keep the vector for nets, we need to ensure that the data
are cleared to prevent stale pointer access

Fixes https://gitlab.com/kicad/code/kicad/issues/12564
2022-10-03 09:33:31 -07:00
Seth Hillbrand 6d298b661a Minor speedup for some dynamic ratsnest cases 2022-10-01 13:43:57 -07:00
Jeff Young d67437a2aa Move ratsnest exclusion processing to a post-pass.
Also fixes a few cases where we were unnecessarily rebuilding
connectivity more than once for an operation.
2022-09-29 17:08:49 +01:00
Alex dc07ab9df1 Replace PROF_COUNTER with PROF_TIMER in some conditional places. 2022-09-27 14:07:47 +00:00
Jeff Young c30a557810 ADDED netclass assignment from PCB canvas.
Fixes https://gitlab.com/kicad/code/kicad/issues/5975
2022-09-03 19:29:59 +01:00
Jeff Young aa2ad3b44c Move KICAD_T[] to std::initializer_list<KICAD_T>. 2022-08-20 10:28:11 +01:00
Seth Hillbrand 35ac39844f Clean up some auto usage
Don't make new copies of shared_ptr if we can use references.  Keep auto
usage down to hard-to-type-out sequences
2022-08-15 11:29:45 -07:00
Jeff Young a9536b5de9 CHANGED netclass assignments now done via canvas or via patterns. 2022-08-14 22:56:29 +01:00
Jeff Young f41af10007 Clean up hole shapes for safety (smart pointer) and consistency. 2022-07-22 23:06:07 +01:00
Seth Hillbrand 03c279ffd4 ADDED: Threadpool
Thread pools are long-lasting executors that have close to zero overhead
when launching new jobs.  This is advantageous over creating new threads
as we can use this for threading smalling jobs and smaller quanta.  It
also avoids the heuristics needed to determine the optimal number of
threads to spawn
2022-06-24 22:59:24 +00:00
Jeff Young 82ebc247b8 More performance enhancements for DRC. 2022-06-18 19:47:11 +01:00
Jeff Young 3f502b313d Don't return false when a particular item doesn't connect.
We still have to search all the other items, as they might connect.
2022-05-23 10:26:18 +01:00
Jeff Young cabcaf933c Cleanup. 2022-03-16 14:56:32 +00:00
jean-pierre charras 7fb4a2c0a5 CONNECTIVITY_DATA::IsConnectedOnLayer(): fix crash in some cases.
Fix crash when a zone do not have filled areas on a given layer.
2022-03-12 19:31:46 +01:00
Jeff Young 0a8718cd1d Fix issue when we ask if a pad is connected to a zone we're in the middle of filling. 2022-03-12 14:17:53 +00:00
Jeff Young eb9ccea559 Performance improvement. 2022-03-10 13:46:42 +00:00
Jeff Young fed5bcbdf6 Improvements for pads/vias in zones which knockout other zones.
1) Drop tiny islands which might cause connection problems.
2) Cleanup some dead code in filler
3) Don't estabilish a connection to an island that is fully covered
by whatever its connecting to.

Fixes https://gitlab.com/kicad/code/kicad/issues/11036
2022-03-05 18:59:53 +00:00
Seth Hillbrand b5c2f0d39a Remove the open array in favor of std containers
The containers allow iteration, size knowledge and lower bug surface
2022-03-03 16:03:26 -08:00
Jeff Young d9d23dd06b Commenting. 2022-02-21 12:26:59 +00:00
Jeff Young aa2c8e9b0c A more discerning un-flashed-connectivity test. 2022-02-20 23:49:02 +00:00
Jeff Young fad4c135fa Use only a physical connection to determine flashing of pads.
Checking for proper nets just confuses things when the nets are set
wrongly for some reason.  This way we generate clearer DRC errors.

Fixes https://gitlab.com/kicad/code/kicad/issues/10645
2022-02-20 20:54:56 +00:00
Jeff Young 3b292a4941 Cleanup and code clarity. 2022-02-16 12:00:18 +00:00
Jeff Young 8e26946567 Don't shrink progress reporter when message changes; only grow. 2022-02-15 19:19:02 +00:00
Jeff Young 5c9e718407 Performance enhancements for connectivity.
1) Generate SHAPE_POLY_SET triangulation by outline so they can be
shared between connectivity system and other clients.
2) Don't add items to connectivity when reading board; we're going
to do a total rebuild anyway.
3) Use multithreading when caching triangulation.
2022-02-15 12:20:34 +00:00
Jeff Young 98b9c6e2a1 Better progress reporting and a slight performance boost on commit. 2022-02-15 12:20:34 +00:00
Jeff Young c4e133fdf7 Auto reduction and std::shared_ptr cover types reduction.
And a performance optimization or two resulting from above.  (Using
const& intead of copying std::shared_ptrs.)
2022-02-13 12:04:03 +00:00
Jeff Young e59aaf05c6 Make sure that GetConnectedItems searches from the root item.
Fixes https://gitlab.com/kicad/code/kicad/issues/10583
2022-02-06 19:43:25 +00:00
Marek Roszko 41f54349a5 Replace inserts/push_backs with emplace in some spots 2022-02-05 19:53:31 -05:00
Jeff Young 7ccac79192 More wxString wide literals. 2022-02-05 21:29:34 +00:00
Marek Roszko ac715d2e51 Scoop up some more wxPoint instances 2022-01-03 20:00:53 -05:00
Marek Roszko c4c56de708 Neurotically update position wxPoint usages 2022-01-01 11:55:51 -05:00
Jon Evans 992952e3d5 Tune connectivity progress reporter
We don't need quite as many updates, this helps speed a little

See https://gitlab.com/kicad/code/kicad/-/issues/10154

(cherry picked from commit 0ec440805d)
2021-12-30 09:20:41 -05:00
Jeff Young b4c5e64db2 Exclusions for Unconnected Items; Markers & exclusions for Parity checks
Fixes https://gitlab.com/kicad/code/kicad/issues/5589

Fixes https://gitlab.com/kicad/code/kicad/issues/5504
2021-12-24 21:10:28 +00:00
Seth Hillbrand 40d44c94cd Fix single-threaded loads/connectivity
We cannot set thread counts to hardware_concurrency()-1 without
considering that single core machines will get a thread count of 0.
2021-12-14 17:18:46 -08:00